534 lines
31 KiB
Plaintext
534 lines
31 KiB
Plaintext
<div class="panel-user-right-con clearfix">
|
||
<div id="edit_account_div" class="<%= @force ? '' : 'none' %>">
|
||
<div class="alert alert-orange mb15 mt15 <%= (@s_message.nil? && @d_message.nil?) ? 'none' : '' %>" id="account_tip">
|
||
<a data-dismiss="alert" class="task-close fr" type="button" id="account_tip_a">×</a>
|
||
|
||
<% unless @s_message.nil? %>
|
||
<p>您添加新的单位“<%= @s_message.name %>”的申请,经确认为无效的单位信息,已被删除,请重新编辑您的单位资料。谢谢!</p>
|
||
<% end %>
|
||
<% unless @d_message.nil? %>
|
||
<p>您添加新的部门“<%= @d_message.name %>”的申请,经确认为无效的部门信息,已被删除,请重新编辑您的部门资料。谢谢!</p>
|
||
<% end %>
|
||
</div>
|
||
<div class="panel-form ml30">
|
||
<%= labelled_form_for :user, @user, :url => {:action => "account"}, :html => {:id => 'my_account_form', :method => :post} do |f| %>
|
||
<ul>
|
||
<li class="clearfix mb10">
|
||
<label class="panel-form-label fl mr18"><span class="color-red mr5">*</span>真实姓名</label>
|
||
<input type="text" id="lastname" name="lastname" maxlength="20" nh_required="1" required="required" class="input-height select-width panel-box-sizing fl" placeholder="填写您的真实姓名" value="<%= @user.lastname+@user.firstname %>">
|
||
|
||
<div class="cl"></div>
|
||
<span class="color-orange fl hint none" id="lastname_hint" style="margin-left:90px;"><i class="fa fa-exclamation-circle mr5"></i>请填写您的真实姓名</span>
|
||
</li>
|
||
<li class="clearfix mb10">
|
||
<label class=" panel-form-label fl mr18"><span class="color-red mr5">*</span>我的性别</label>
|
||
<% if User.current.user_extensions && User.current.user_extensions.gender && User.current.user_extensions.gender == 1 %>
|
||
<span class="fl mt10 mr15">
|
||
<input type="radio" name="sex" value="0">
|
||
<label>男</label>
|
||
</span>
|
||
<span class="fl mt10 ">
|
||
<input type="radio" name="sex" value="1" checked>
|
||
<label>女</label>
|
||
</span>
|
||
<% else %>
|
||
<span class="fl mt10 mr15">
|
||
<input type="radio" name="sex" value="0" checked>
|
||
<label>男</label>
|
||
</span>
|
||
<span class="fl mt10 ">
|
||
<input type="radio" name="sex" value="1">
|
||
<label>女</label>
|
||
</span>
|
||
<% end %>
|
||
<div class="cl"></div>
|
||
</li>
|
||
<li class="clearfix mb10 hascontont">
|
||
<label class="panel-form-label fl mr18"><span class="color-red mr5">*</span>职业</label>
|
||
<select id="userIdentity" name="identity" required="required" nh_required="1" class="fl input-height mr15 select-width">
|
||
<option value="-1" style="display:none">请选择职业</option>
|
||
<option value="0">教师</option>
|
||
<option value="1">学生</option>
|
||
<option value="2">专业人士</option>
|
||
</select>
|
||
<select id="teacher" name="te_technical_title" nhname="tag_1" nh_tag_0="true" class="fl input-height select-width">
|
||
<option value="0" style="display:none">请选择职称</option>
|
||
<option value="教授">教授</option>
|
||
<option value="副教授">副教授</option>
|
||
<option value="讲师">讲师</option>
|
||
<option value="助教">助教</option>
|
||
</select>
|
||
<select id="profession" name="pro_technical_title" nhname="tag_1" nh_tag_2="true" class="fl input-height select-width">
|
||
<option value="0" style="display:none">请选择职称</option>
|
||
<option value="企业管理者">企业管理者</option>
|
||
<option value="部门管理者">部门管理者</option>
|
||
<option value="高级工程师">高级工程师</option>
|
||
<option value="工程师">工程师</option>
|
||
<option value="助理工程师">助理工程师</option>
|
||
</select>
|
||
|
||
<div class="cl"></div>
|
||
<span class="color-orange fl hint none" id="identity_hint" style="margin-left:90px;"><i class="fa fa-exclamation-circle mr5"></i>请选择你的职业/职称</span>
|
||
</li>
|
||
<li class="clearfix mb10" id="number">
|
||
<label class="panel-form-label fl mr18"><span class="color-red mr5">*</span>学号</label>
|
||
<input type="text" nhname="tag_1" nh_tag_1="true" id="user_student_id" class="input-height select-width panel-box-sizing fl" name="no" value="<%= @user.user_extensions.student_id %>" placeholder="填写您的学号">
|
||
|
||
<div class="cl"></div>
|
||
<span class="color-orange fl hint none" id="student_id_hint" style="margin-left:90px;"><i class="fa fa-exclamation-circle mr5"></i>请选择你的职业</span>
|
||
</li>
|
||
<li class="clearfix mb10">
|
||
<label class="panel-form-label fl mr18"><span class="color-red mr5">*</span>地区</label>
|
||
<select onchange="showcity(this.value, document.getElementById('userCity'));" name="province" id="userProvince" class="fl input-height mr15 select-width">
|
||
<option value="0">请选择所在省份</option>
|
||
<option value="北京">北京</option>
|
||
<option value="上海">上海</option>
|
||
<option value="广东">广东</option>
|
||
<option value="江苏">江苏</option>
|
||
<option value="浙江">浙江</option>
|
||
<option value="重庆">重庆</option>
|
||
<option value="安徽">安徽</option>
|
||
<option value="福建">福建</option>
|
||
<option value="甘肃">甘肃</option>
|
||
<option value="广西">广西</option>
|
||
<option value="贵州">贵州</option>
|
||
<option value="海南">海南</option>
|
||
<option value="河北">河北</option>
|
||
<option value="黑龙江">黑龙江</option>
|
||
<option value="河南">河南</option>
|
||
<option value="湖北">湖北</option>
|
||
<option value="湖南">湖南</option>
|
||
<option value="江西">江西</option>
|
||
<option value="吉林">吉林</option>
|
||
<option value="辽宁">辽宁</option>
|
||
<option value="内蒙古">内蒙古</option>
|
||
<option value="宁夏">宁夏</option>
|
||
<option value="青海">青海</option>
|
||
<option value="山东">山东</option>
|
||
<option value="山西">山西</option>
|
||
<option value="陕西">陕西</option>
|
||
<option value="四川">四川</option>
|
||
<option value="天津">天津</option>
|
||
<option value="新疆">新疆</option>
|
||
<option value="西藏">西藏</option>
|
||
<option value="云南">云南</option>
|
||
<option value="香港">香港特别行政区</option>
|
||
<option value="澳门">澳门特别行政区</option>
|
||
<option value="台湾">台湾</option>
|
||
<option value="海外">海外</option>
|
||
</select>
|
||
<select id="userCity" class="fl input-height select-width" name="city">
|
||
<option value="0">请选择所在城市</option>
|
||
</select>
|
||
|
||
<div class="cl"></div>
|
||
<span class="color-orange fl none" id="province_hint" style="margin-left:90px;"><i class="fa fa-exclamation-circle mr5"></i>请选择你所在的省份/城市</span>
|
||
</li>
|
||
<li class="clearfix mb10">
|
||
<label class="panel-form-label fl mr18"><span class="color-red mr5">*</span>单位名称</label>
|
||
<input nhname="tag" autocomplete="off" maxlength="36" nh_tag_0="true" nh_tag_1="true" nh_tag_3="true" id="province" name="school" class="task-form-40 task-height-40 panel-box-sizing fl" type="text" value="<%= User.current.user_extensions.school.try(:name) %>" placeholder="在校师生请写所在学校,其它用户填写所在工作单位"/>
|
||
<input nhname="tag" nh_tag_4="true" class="fl" id="occupation" name="occupation" style="display: none;" type="text" value="<%= @user.user_extensions.school.try(:id) %>"/> <!-- 单位名称的test框选中下拉列表框的id -->
|
||
<p id="no_school_hint" class="none fl ml10 mt8">你的单位不在列表中?请点击<a href="javascript:void(0);" class="link-color-blue">申请添加</a></p>
|
||
<div class="cl"></div>
|
||
<span class="color-orange fl none" id="school_name_hint" style="margin-left:90px;"><i class="fa fa-exclamation-circle mr5"></i>请从下拉列表中选择你的单位</span>
|
||
</li>
|
||
<li class="clearfix mb10 <%= @user.user_extensions.school.blank? ? 'none' : '' %>" id="user_department_li">
|
||
<label class="panel-form-label fl mr18">学院/单位</label>
|
||
<input type="text" autocomplete="off" id="department" name="department" class="task-form-40 task-height-40 panel-box-sizing fl" placeholder="所在学院或者所在部门" value="<%= @user.user_extensions.department.try(:name) %>">
|
||
<input nhname="tag" nh_tag_5="true" class="fl" id="department_id" name="department_id" style="display: none;" type="text" value="<%= @user.user_extensions.department.try(:id) %>"/> <!-- 单位名称的test框选中下拉列表框的id -->
|
||
<p id="no_department_hint" class="none fl ml10 mt8">你的部门不在列表中?请点击<a href="javascript:void(0);" class="link-color-blue">申请添加</a></p>
|
||
<div class="cl"></div>
|
||
</li>
|
||
<li class="clearfix mb10">
|
||
<label class="panel-form-label fl mr18">介绍</label>
|
||
<textarea class="task-form-80 task-height-150 panel-box-sizing fl" name="brief_introduction" style="width:82%; resize: none;" placeholder=" 一句话介绍一下自己吧~(最多100个字符)"><%= @user.user_extensions.brief_introduction %></textarea>
|
||
|
||
<div class="cl"></div>
|
||
</li>
|
||
<li class="clearfix" style="margin-right:41px;">
|
||
<a href="javascript:void(0);" id="my_account_form_link" class="task-btn task-btn-blue fr">保存</a>
|
||
<a href="javascript:void(0);" onclick="cancel_edit_account('<%= @force %>');" class="task-btn fr mr10">取消</a>
|
||
</li>
|
||
</ul>
|
||
<% end %>
|
||
</div>
|
||
</div>
|
||
|
||
<div id="show_account_div" class="<%= @force ? 'none' : '' %>">
|
||
<div class="panel-form mr15 mt30">
|
||
<a href="javascript:void(0);" class="fr mb10" title="编辑资料" id="edit_my_account"><i class="fa fa-edit font-16"></i></a>
|
||
|
||
<div class="cl"></div>
|
||
<ul>
|
||
<li class="clearfix mb10">
|
||
<label class="panel-form-label fl"><span class="color-red mr5">*</span>真实姓名:</label>
|
||
|
||
<p class="fl task-bg-grey02 panel-box-sizing "><%= @user.try(:lastname) + @user.try(:firstname) %></p>
|
||
</li>
|
||
<li class="clearfix mb10">
|
||
<label class="panel-form-label fl"><span class="color-red mr5">*</span>我的性别:</label>
|
||
|
||
<p class="fl task-bg-grey02 panel-box-sizing"><%= @user.user_extensions && @user.user_extensions.gender && @user.user_extensions.gender == 1 ? '女' : '男' %></p>
|
||
</li>
|
||
<li class="clearfix mb10">
|
||
<label class="panel-form-label fl"><span class="color-red mr5">*</span>职业:</label>
|
||
|
||
<p class="fl task-bg-grey02 panel-box-sizing">
|
||
<%= @user.user_extensions.show_identity %>
|
||
<% if @user.authentication %>
|
||
<span class="color-green ml20">
|
||
<i class="fa fa-check-circle-o" aria-hidden="true"></i>
|
||
已认证
|
||
</span>
|
||
<% else %>
|
||
<span class="color-grey ml20">
|
||
<i class="fa fa-times-circle-o" aria-hidden="true"></i>
|
||
未认证
|
||
</span>
|
||
<% end %>
|
||
</p>
|
||
</li>
|
||
<li class="clearfix mb10">
|
||
<% if @user.user_extensions && @user.user_extensions.identity && @user.user_extensions.identity == 1 %>
|
||
<label class="panel-form-label fl"><span class="color-red mr5">*</span>学号:</label>
|
||
|
||
<p class="fl task-bg-grey02 panel-box-sizing"><%= @user.user_extensions.try(:student_id) %></p>
|
||
<% else %>
|
||
<label class="panel-form-label fl"><span class="color-red mr5">*</span>职称:</label>
|
||
|
||
<p class="fl task-bg-grey02 panel-box-sizing"><%= @user.user_extensions.try(:technical_title) %></p>
|
||
<% end %>
|
||
</li>
|
||
<li class="clearfix mb10">
|
||
<label class="panel-form-label fl"><span class="color-red mr5">*</span>地区:</label>
|
||
|
||
<p class="fl task-bg-grey02 panel-box-sizing"><span class="mr15"><%= @user.user_extensions.try(:location) %></span><span><%= @user.user_extensions.try(:location_city) %></span></p>
|
||
</li>
|
||
<li class="clearfix mb10">
|
||
<label class="panel-form-label fl"><span class="color-red mr5">*</span>单位名称:</label>
|
||
|
||
<p class="fl task-bg-grey02 panel-box-sizing">
|
||
<span class="mr15"><%= @user.user_extensions.school ? @user.user_extensions.school.try(:name) : '' %></span>
|
||
<span><%= @user.user_extensions.department ? @user.user_extensions.department.try(:name) : '' %></span>
|
||
</p>
|
||
</li>
|
||
<li class="clearfix mb10">
|
||
<label class=" panel-form-label fl">介绍:</label>
|
||
|
||
<p class="fl task-bg-grey02 panel-box-sizing"><%= @user.user_extensions.brief_introduction.blank? ? "无" : @user.user_extensions.brief_introduction %></p>
|
||
</li>
|
||
</ul>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="cl"></div>
|
||
|
||
<div id="search_school_result_list" style="width: 330px;line-height: 1.5;min-height:20px; max-height: 200px; height: auto !important;display: none;background: white;overflow: scroll;border: solid 1px #cccccc; overflow-x: hidden; overflow-y: auto;">
|
||
</div>
|
||
<div id="search_department_result_list" style="width: 330px;line-height: 1.5;min-height:20px; max-height: 200px; height: auto !important;display: none;background: white;overflow: scroll;border: solid 1px #cccccc; overflow-x: hidden; overflow-y: auto;">
|
||
</div>
|
||
|
||
<% if !User.current.user_extensions.nil? %>
|
||
<% province = User.current.user_extensions.location %>
|
||
<% city = User.current.user_extensions.location_city %>
|
||
<% identity = User.current.user_extensions.identity %>
|
||
<% title = User.current.user_extensions.technical_title %>
|
||
<% language = User.current.language %>
|
||
<% else %>
|
||
<% province = "湖南省" %>
|
||
<% city = "长沙" %>
|
||
<% identity = "" %>
|
||
<% title = "" %>
|
||
<% language = "" %>
|
||
<% end %>
|
||
|
||
<script type="text/javascript">
|
||
function apply_add_school() {
|
||
var htmlvalue = "<%= escape_javascript(render :partial => 'my/apply_add_school')%>";
|
||
pop_box_new(htmlvalue, 575, 465);
|
||
$("#schoolname").val($("input[name='school']").val());
|
||
}
|
||
|
||
function apply_add_department() {
|
||
if($("#schoolname").val() == ""){
|
||
$("#school_name_hint").show();
|
||
} else{
|
||
var htmlvalue = "<%= escape_javascript(render :partial => 'my/apply_add_department')%>";
|
||
pop_box_new(htmlvalue, 575, 465);
|
||
$("#schoolname").html($("input[name='school']").val());
|
||
$("#school_id").val($("input[name='occupation']").val());
|
||
$("#department_name").val($("input[name='department']").val());
|
||
}
|
||
}
|
||
|
||
var d_lastSearchCondition = '';
|
||
var d_page = 1; //唯一控制页码 变量
|
||
var d_count = 0; //查询结果的总量
|
||
var d_maxPage = 0;//最大页面值
|
||
$(function () {
|
||
$("#search_department_result_list").scroll(function (e) {
|
||
d_nScrollHight = $(this)[0].scrollHeight;
|
||
d_nScrollTop = $(this)[0].scrollTop;
|
||
var nDivHight = $(this).height();
|
||
if (d_nScrollTop + nDivHight >= d_nScrollHight) //到底部了,
|
||
{
|
||
//判断页码是否是最大值,如果是的,就不去请求了
|
||
if (page >= maxPage) {
|
||
return;
|
||
} else { //如果不是,那就请求下一页,请求数据处理
|
||
page++;
|
||
$.ajax({
|
||
url: '<%= url_for(:controller => 'department',:action => 'on_search') %>' + '?name=' + $("input[name='department']").val()+ '&school_id=' + $("input[name='occupation']").val() + '&page=' + page,
|
||
type: 'post',
|
||
success: function (data) {
|
||
d_schoolsResult = data.departments;
|
||
if (d_schoolsResult.length != undefined && d_schoolsResult.length != 0) {
|
||
var i = 0;
|
||
for (; i < d_schoolsResult.length; i++) {
|
||
link = '<a onclick="window.changeDepValue(\'' + d_schoolsResult[i].department.name.replace(/\s/g, " ") + '\',\'' + d_schoolsResult[i].department.id + '\')" href="javascript:void(0)">' + d_schoolsResult[i].department.name + '</a><br/>';
|
||
$("#search_department_result_list").append(link);
|
||
}
|
||
} else {
|
||
|
||
}
|
||
}
|
||
});
|
||
}
|
||
}
|
||
});
|
||
//查询学校
|
||
$("input[name='department']").on('input', function (e) {
|
||
throttle(department_search_fn, window, e);
|
||
});
|
||
|
||
function throttle(method, context, e) {
|
||
clearTimeout(method.tId);
|
||
method.tId = setTimeout(function () {
|
||
method.call(context, e);
|
||
}, 500);
|
||
}
|
||
|
||
function department_search_fn(e) {
|
||
|
||
if ($(e.target).val().trim() == d_lastSearchCondition && $(e.target).val().trim() != '') {//如果输入框没有改变或者输入框为空就返回
|
||
return;
|
||
}
|
||
$("input[name='department_id']").val(''); //一旦有输入就清空id。
|
||
d_lastSearchCondition = $(e.target).val().trim();
|
||
page = 1; //有新的搜索,页面重置为1
|
||
$.ajax({
|
||
url: '<%= url_for(:controller => 'department',:action => 'on_search') %>' + '?name=' + e.target.value + '&school_id=' + $("input[name='occupation']").val() + '&page=' + d_page,
|
||
type: 'post',
|
||
success: function (data) {
|
||
d_schoolsResult = data.departments;
|
||
count = data.count;
|
||
maxPage = Math.ceil(count / 100); //最大页码值
|
||
if (d_schoolsResult.length != undefined && d_schoolsResult.length != 0) {
|
||
var i = 0;
|
||
$("#search_department_result_list").html('');
|
||
for (; i < d_schoolsResult.length; i++) {
|
||
link = '<a onclick="window.changeDepValue(\'' + d_schoolsResult[i].department.name.replace(/\s/g, " ") + '\',\'' + d_schoolsResult[i].department.id + '\')" href="javascript:void(0)">' + d_schoolsResult[i].department.name + '</a><br/>';
|
||
$("#search_department_result_list").append(link);
|
||
}
|
||
$("#search_department_result_list").css('left', $(e.target).offset().left);
|
||
$("#search_department_result_list").css('top', $(e.target).offset().top + 40);
|
||
$("#search_department_result_list").css("position", "absolute");
|
||
$("#search_department_result_list").show();
|
||
} else {
|
||
$("#search_department_result_list").html('');
|
||
str = e.target.value.length > 4 ? e.target.value.substr(0, 4) + "..." : e.target.value;
|
||
$("#no_department_hint").html('你的学院/部门不在列表中?请点击<a class="link-color-blue" onclick="apply_add_department();" href="javascript:void(0);">申请添加</a>');
|
||
$("#no_department_hint").show();
|
||
}
|
||
}
|
||
});
|
||
}
|
||
|
||
$(document.body).click(function (e) {
|
||
if ($(e.target).attr("id") != 'search_department_result_list' && $(e.target).attr("id") != 'department') {
|
||
$("#search_department_result_list").hide();
|
||
}
|
||
});
|
||
$("input[name='department']").on('focus', function (e) {
|
||
if ($("input[name='department_id']").val() != '') { //如果已经有id了。肯定存在,不用去找了。
|
||
return;
|
||
}
|
||
|
||
$.ajax({
|
||
url: '<%= url_for(:controller => 'department',:action => 'on_search') %>' + '?name=' + e.target.value + '&school_id=' + $("input[name='occupation']").val() + '&page=' + page,
|
||
type: 'post',
|
||
success: function (data) {
|
||
schoolsResult = data.departments;
|
||
count = data.count;
|
||
maxPage = Math.ceil(count / 100); //最大页码值
|
||
if (schoolsResult.length != undefined && schoolsResult.length != 0) {
|
||
var i = 0;
|
||
$("#search_department_result_list").html('');
|
||
for (; i < schoolsResult.length; i++) {
|
||
link = '<a onclick="window.changeDepValue(\'' + schoolsResult[i].department.name.replace(/\s/g, " ") + '\',\'' + schoolsResult[i].department.id + '\')" href="javascript:void(0)">' + schoolsResult[i].department.name + '</a><br/>';
|
||
$("#search_department_result_list").append(link);
|
||
}
|
||
$("#search_department_result_list").css('left', $(e.target).offset().left);
|
||
$("#search_department_result_list").css('top', $(e.target).offset().top + 40);
|
||
$("#search_department_result_list").css("position", "absolute");
|
||
$("#search_department_result_list").show();
|
||
} else {
|
||
$("#search_department_result_list").html('');
|
||
str = e.target.value.length > 4 ? e.target.value.substr(0, 4) + "..." : e.target.value;
|
||
$("#no_department_hint").html('你的学院/部门不在列表中?请点击<a class="link-color-blue" onclick="apply_add_department();" href="javascript:void(0);">申请添加</a>');
|
||
$("#no_department_hint").show();
|
||
}
|
||
}
|
||
});
|
||
});
|
||
|
||
var lastSearchCondition = '';
|
||
var page = 1; //唯一控制页码 变量
|
||
var count = 0; //查询结果的总量
|
||
var maxPage = 0;//最大页面值
|
||
$(function () {
|
||
$("#search_school_result_list").scroll(function (e) {
|
||
nScrollHight = $(this)[0].scrollHeight;
|
||
nScrollTop = $(this)[0].scrollTop;
|
||
var nDivHight = $(this).height();
|
||
if (nScrollTop + nDivHight >= nScrollHight) //到底部了,
|
||
{
|
||
//判断页码是否是最大值,如果是的,就不去请求了
|
||
if (page >= maxPage) {
|
||
return;
|
||
} else { //如果不是,那就请求下一页,请求数据处理
|
||
page++;
|
||
$.ajax({
|
||
url: '<%= url_for(:controller => 'school',:action => 'on_search') %>' + '?name=' + $("input[name='school']").val() + '&page=' + page,
|
||
type: 'post',
|
||
success: function (data) {
|
||
schoolsResult = data.schools;
|
||
if (schoolsResult.length != undefined && schoolsResult.length != 0) {
|
||
var i = 0;
|
||
for (; i < schoolsResult.length; i++) {
|
||
link = '<a onclick="window.changeValue(\'' + schoolsResult[i].school.name.replace(/\s/g, " ") + '\',\'' + schoolsResult[i].school.id + '\')" href="javascript:void(0)">' + schoolsResult[i].school.name + '</a><br/>';
|
||
$("#search_school_result_list").append(link);
|
||
}
|
||
} else {
|
||
|
||
}
|
||
}
|
||
});
|
||
}
|
||
}
|
||
});
|
||
//查询学校
|
||
$("input[name='school']").on('input', function (e) {
|
||
throttle(shcool_search_fn, window, e);
|
||
});
|
||
|
||
function throttle(method, context, e) {
|
||
clearTimeout(method.tId);
|
||
method.tId = setTimeout(function () {
|
||
method.call(context, e);
|
||
}, 500);
|
||
}
|
||
|
||
function shcool_search_fn(e) {
|
||
|
||
if ($(e.target).val().trim() == lastSearchCondition && $(e.target).val().trim() != '') {//如果输入框没有改变或者输入框为空就返回
|
||
return;
|
||
}
|
||
$("input[name='occupation']").val(''); //一旦有输入就清空id。
|
||
lastSearchCondition = $(e.target).val().trim();
|
||
page = 1; //有新的搜索,页面重置为1
|
||
$.ajax({
|
||
url: '<%= url_for(:controller => 'school',:action => 'on_search') %>' + '?name=' + e.target.value + '&page=' + page,
|
||
type: 'post',
|
||
success: function (data) {
|
||
schoolsResult = data.schools;
|
||
count = data.count;
|
||
maxPage = Math.ceil(count / 100) //最大页码值
|
||
if (schoolsResult.length != undefined && schoolsResult.length != 0) {
|
||
var i = 0;
|
||
$("#search_school_result_list").html('');
|
||
for (; i < schoolsResult.length; i++) {
|
||
link = '<a onclick="window.changeValue(\'' + schoolsResult[i].school.name.replace(/\s/g, " ") + '\',\'' + schoolsResult[i].school.id + '\')" href="javascript:void(0)">' + schoolsResult[i].school.name + '</a><br/>';
|
||
$("#search_school_result_list").append(link);
|
||
}
|
||
$("#search_school_result_list").css('left', $(e.target).offset().left);
|
||
$("#search_school_result_list").css('top', $(e.target).offset().top + 40);
|
||
$("#search_school_result_list").css("position", "absolute");
|
||
$("#search_school_result_list").show();
|
||
if ($(e.target).val().trim() != '') {
|
||
str = e.target.value.length > 8 ? e.target.value.substr(0, 6) + "..." : e.target.value;
|
||
$("#no_school_hint").html('找到了' + count + '个包含"' + str + '"的高校(单位)');
|
||
$("#no_school_hint").show();
|
||
} else {
|
||
$("#no_school_hint").hide();
|
||
}
|
||
} else {
|
||
$("#search_school_result_list").html('');
|
||
str = e.target.value.length > 4 ? e.target.value.substr(0, 4) + "..." : e.target.value;
|
||
$("#no_school_hint").html('你的单位不在列表中?请点击<a class="link-color-blue" onclick="apply_add_school();" href="javascript:void(0);">申请添加</a>');
|
||
$("#no_school_hint").show();
|
||
}
|
||
}
|
||
});
|
||
}
|
||
|
||
$(document.body).click(function (e) {
|
||
if ($(e.target).attr("id") != 'search_school_result_list' && $(e.target).attr("id") != 'province') {
|
||
$("#search_school_result_list").hide();
|
||
}
|
||
});
|
||
$("input[name='school']").on('focus', function (e) {
|
||
if ($("input[name='occupation']").val() != '') { //如果已经有id了。肯定存在,不用去找了。
|
||
return;
|
||
}
|
||
|
||
$.ajax({
|
||
url: '<%= url_for(:controller => 'school',:action => 'on_search') %>' + '?name=' + e.target.value + '&page=' + page,
|
||
type: 'post',
|
||
success: function (data) {
|
||
schoolsResult = data.schools;
|
||
count = data.count;
|
||
maxPage = Math.ceil(count / 100); //最大页码值
|
||
if (schoolsResult.length != undefined && schoolsResult.length != 0) {
|
||
var i = 0;
|
||
$("#search_school_result_list").html('');
|
||
for (; i < schoolsResult.length; i++) {
|
||
link = '<a onclick="window.changeValue(\'' + schoolsResult[i].school.name.replace(/\s/g, " ") + '\',\'' + schoolsResult[i].school.id + '\')" href="javascript:void(0)">' + schoolsResult[i].school.name + '</a><br/>';
|
||
$("#search_school_result_list").append(link);
|
||
}
|
||
$("#search_school_result_list").css('left', $(e.target).offset().left);
|
||
$("#search_school_result_list").css('top', $(e.target).offset().top + 40);
|
||
$("#search_school_result_list").css("position", "absolute");
|
||
$("#search_school_result_list").show();
|
||
if ($(e.target).val().trim() != '') {
|
||
str = e.target.value.length > 8 ? e.target.value.substr(0, 6) + "..." : e.target.value;
|
||
$("#no_school_hint").html('找到了' + count + '个包含"' + str + '"的高校(单位)');
|
||
$("#no_school_hint").show();
|
||
} else {
|
||
$("#no_school_hint").hide();
|
||
}
|
||
} else {
|
||
$("#search_school_result_list").html('');
|
||
str = e.target.value.length > 4 ? e.target.value.substr(0, 4) + "..." : e.target.value;
|
||
$("#no_school_hint").html('你的单位不在列表中?请点击<a class="link-color-blue" onclick="apply_add_school();" href="javascript:void(0);">申请添加</a>');
|
||
$("#no_school_hint").show();
|
||
}
|
||
}
|
||
});
|
||
});
|
||
});
|
||
|
||
//地区
|
||
var province = "<%= "#{province}" %>";
|
||
var city = "<%= "#{city}" %>";
|
||
init_province_and_city(document.getElementById('userProvince'), province, document.getElementById('userCity'), city);
|
||
|
||
//select
|
||
var identity = "<%= "#{identity}" %>";
|
||
var title = "<%= "#{title}" %>";
|
||
var language = "<%= "#{language}" %>";
|
||
init_identity_and_title(document.getElementById('userIdentity'), identity, title);
|
||
|
||
$("#userIdentity").change();
|
||
});
|
||
</script> |