From 933041866872e048d30f57f914478c820bc583f3 Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Tue, 20 Oct 2015 10:11:07 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=AD=A6=E6=A0=A1=E5=88=97=E8=A1=A8div=20?= =?UTF-8?q?=E4=B8=8B=E6=8B=89=E5=88=86=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/school_controller.rb | 8 +- app/views/my/account.html.erb | 142 ++++++++++++++++----------- 2 files changed, 90 insertions(+), 60 deletions(-) diff --git a/app/controllers/school_controller.rb b/app/controllers/school_controller.rb index 85bd6a784..d20a58b75 100644 --- a/app/controllers/school_controller.rb +++ b/app/controllers/school_controller.rb @@ -125,16 +125,18 @@ class SchoolController < ApplicationController end end if(condition == '') - @school = School.all + @school = School.page((params[:page].to_i || 1) - 1).per(100) + @school_count = School.count else - @school = School.where("name like '%#{chinese.join("")}%' and pinyin like '%#{pinyin.join("")}%'").all + @school = School.where("name like '%#{chinese.join("")}%' and pinyin like '%#{pinyin.join("")}%'").page((params[:page].to_i || 1) - 1).per(100) + @school_count = School.where("name like '%#{chinese.join("")}%' and pinyin like '%#{pinyin.join("")}%'").count end result = [] # @school.each do |sc| # result << {:value=>sc.name,:data=>sc.id} # end - render :json => @school.to_json + render :json =>{ :schools => @school,:count=>@school_count}.to_json end #添加学校 diff --git a/app/views/my/account.html.erb b/app/views/my/account.html.erb index 4a2fe446d..0531ea9e7 100644 --- a/app/views/my/account.html.erb +++ b/app/views/my/account.html.erb @@ -542,19 +542,41 @@ }); } var lastSearchCondition = ''; + var page = 1; //唯一控制页码 变量 + var count = 0; //查询结果的总量 + var maxPage = 0 ;//最大页面值 $(function() { -// $("input[name='province']").keydown(function(e){ -// if(e.keyCode == 13 && $("#search_school_result_list").css('display') == 'block'){ -// str = $("#search_school_result_list").children().eq(0).attr('onclick').match(/\(.*\)/)[0] -// -// str = str.replace(/\(/,'').replace(/\)/,''); -// arr = str.split(','); -// id = arr[1].replace(/\'/,'') -// name = arr.replace(/\'/,'') -// changeValue(name,id); -// return false; -// } -// }); + $("#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='province']").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 = '' + schoolsResult[i].school.name + '
'; + $("#search_school_result_list").append(link); + } + } else { + + } + } + }); + } + + } + }); //查询学校 $("input[name='province']").on('input', function (e) { throttle(shcool_search_fn,window,e); @@ -568,20 +590,25 @@ } function shcool_search_fn(e){ - $("input[name='occupation']").val(''); //一旦有输入就清空id。 - if($(e.target).val().trim() == lastSearchCondition && $(e.target).val().trim() != ''){ + + 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, + url: '<%= url_for(:controller => 'school',:action => 'on_search') %>' + '?name=' + e.target.value+'&page='+page, type: 'post', success: function (data) { - if(data.length != undefined && data.length != 0) { + schoolsResult = data.schools; + count = data.count; + maxPage = count % 100 + 1; //最大页码值 + if(schoolsResult.length != undefined && schoolsResult.length != 0) { var i = 0; $("#search_school_result_list").html(''); - for (; i < data.length; i++) { - link = '' + data[i].school.name + '
'; + for (; i < schoolsResult.length; i++) { + link = '' + schoolsResult[i].school.name + '
'; $("#search_school_result_list").append(link); } $("#search_school_result_list").css('left', $(e.target).offset().left); @@ -590,7 +617,7 @@ $("#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; - $("#hint").html('找到了' + data.length + '个包含"' + str + '"的高校'); + $("#hint").html('找到了' + count + '个包含"' + str + '"的高校'); $("#hint").show(); }else{ $("#hint").hide(); @@ -610,45 +637,46 @@ $("#search_school_result_list").hide(); $("#hint").hide(); } - }) - $("input[name='province']").on('focus', function (e) { - if($(e.target).val() == ''){ // - return; - } - if( $("input[name='occupation']").val() != ''){ //如果已经有id了。肯定存在,不用去找了。 - return; - } - $.ajax({ - url: '<%= url_for(:controller => 'school',:action => 'on_search') %>' + '?name=' + e.target.value, - type: 'post', - success: function (data) { - if(data.length != undefined && data.length != 0) { - var i = 0; - $("#search_school_result_list").html(''); - for (; i < data.length; i++) { - link = '' + data[i].school.name + '
'; - $("#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 + 28); - $("#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; - $("#hint").html('找到了' + data.length + '个包含"' + str + '"的高校'); - $("#hint").show(); - } else { - $("#hint").hide(); - } - }else { - $("#search_school_result_list").html(''); - str = e.target.value.length > 4 ? e.target.value.substr(0, 4)+"..." : e.target.value; - $("#hint").html('没有找到包含"'+str+'"的高校,创建高校'); - $("#hint").show(); - } - } - }); }); +// $("input[name='province']").on('focus', function (e) { +// if($(e.target).val() == ''){ // +// return; +// } +// if( $("input[name='occupation']").val() != ''){ //如果已经有id了。肯定存在,不用去找了。 +// return; +// } +// +// $.ajax({ +// url: '<%#= url_for(:controller => 'school',:action => 'on_search') %>' + '?name=' + e.target.value, +// type: 'post', +// success: function (data) { +// if(data.length != undefined && data.length != 0) { +// var i = 0; +// $("#search_school_result_list").html(''); +// for (; i < data.length; i++) { +// link = '' + data[i].school.name + '
'; +// $("#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 + 28); +// $("#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; +// $("#hint").html('找到了' + data.length + '个包含"' + str + '"的高校'); +// $("#hint").show(); +// } else { +// $("#hint").hide(); +// } +// }else { +// $("#search_school_result_list").html(''); +// str = e.target.value.length > 4 ? e.target.value.substr(0, 4)+"..." : e.target.value; +// $("#hint").html('没有找到包含"'+str+'"的高校,创建高校'); +// $("#hint").show(); +// } +// } +// }); +// }); // $("#province").leanModal({top: 100, closeButton: ".modal_close"}); From b3cd3c48d2b50ddb2d9cdd35c9a1e02f4ef56890 Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 20 Oct 2015 10:11:43 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=A7=81=E6=9C=89?= =?UTF-8?q?=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/files/_course_list.html.erb | 2 +- public/stylesheets/courses.css | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/views/files/_course_list.html.erb b/app/views/files/_course_list.html.erb index 3c6d545db..4cc249c20 100644 --- a/app/views/files/_course_list.html.erb +++ b/app/views/files/_course_list.html.erb @@ -39,7 +39,7 @@ <% else %> - 私有 + 私有 <% end %> diff --git a/public/stylesheets/courses.css b/public/stylesheets/courses.css index 2fb7ec9c9..db02a0292 100644 --- a/public/stylesheets/courses.css +++ b/public/stylesheets/courses.css @@ -292,6 +292,7 @@ a.re_open{display:block; width:46px; border:1px solid #64bdd9; color:#64bdd9; a:hover.re_open{ background:#64bdd9; color:#fff; text-decoration:none;} a.re_de{ color:#6883b6; margin-left:15px;} .re_con_box{ border-bottom:1px dashed #dadada; padding-bottom:10px; margin-bottom:10px;} +span.re_open{display:block; width:46px; border:1px solid #64bdd9; color:#64bdd9; margin-left:10px;padding:1px 5px;text-align: center} /* 作业列表 */ From f59593cc1c4ce15520729cd8ea2752fe4ee729c4 Mon Sep 17 00:00:00 2001 From: Tim Date: Tue, 20 Oct 2015 10:22:47 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E5=AD=A6=E6=A0=A1=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=A0=B7=E5=BC=8F=E6=9B=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/school/upload_logo.html.erb | 2 +- public/stylesheets/application.css | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/views/school/upload_logo.html.erb b/app/views/school/upload_logo.html.erb index 96b577f46..01071fb81 100644 --- a/app/views/school/upload_logo.html.erb +++ b/app/views/school/upload_logo.html.erb @@ -61,7 +61,7 @@ function showPreview(source) {
- + <%#= submit_tag('提交',:class=>'mr5') %> <%#= submit_tag('取消') %> diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index 6c6227ed4..dbc91353b 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -12,8 +12,8 @@ li{list-style-type:none;} /*Tim 151019*/ .schoolName {border:1px solid #dddddd; outline: none; width: 180px; height: 22px;} .provinceSelect {border: 1px solid #dddddd; outline: none; color: #888888;} -.submit_btn {background-color: #269ac9; color: #ffffff; padding: 2px 5px; border: none; border-radius: 3px; cursor: pointer;} -.submit_btn:hover {background-color:#297fb8;} +.submit_btn_s {background-color: #269ac9; color: #ffffff; padding: 2px 5px; border: none; border-radius: 3px; cursor: pointer;} +.submit_btn_s:hover {background-color:#297fb8;} .cancel_btn {background-color: #c1c1c1; color: #ffffff; padding: 2px 5px; border: none; border-radius: 3px; cursor: pointer;} .cancel_btn:hover {background-color:#656565; } /*huang*/