diff --git a/app/controllers/forums_controller.rb b/app/controllers/forums_controller.rb index f3ebfad88..3b8b4b928 100644 --- a/app/controllers/forums_controller.rb +++ b/app/controllers/forums_controller.rb @@ -166,10 +166,10 @@ class ForumsController < ApplicationController def search_forum # @forums = paginateHelper Forum.where("name LIKE '%#{params[:name]}%'") - name = params[:name] - (redirect_to forums_path, :notice => l(:label_sumbit_empty);return) if name.blank? + q = "%#{params[:name].strip}%" + (redirect_to forums_path, :notice => l(:label_sumbit_empty);return) if params[:name].blank? @offset, @limit = api_offset_and_limit({:limit => 10}) - @forums_all = Forum.where("name LIKE '%#{params[:name]}%'") + @forums_all = Forum.where("name LIKE ?", q) @forums_count = @forums_all.count @forums_pages = Paginator.new @forums_count, @limit, params['page'] @@ -185,11 +185,13 @@ class ForumsController < ApplicationController end def search_memo + q = "%#{params[:name].strip}%" + limit = PageLimit @memo = Memo.new @offset, @limit = api_offset_and_limit({:limit => limit}) @forum = Forum.find(params[:id]) - @memos_all = @forum.topics.where("subject LIKE '%#{params[:name]}%'") + @memos_all = @forum.topics.where("subject LIKE ?", q) @topic_count = @memos_all.count @topic_pages = Paginator.new @topic_count, @limit, params['page'] diff --git a/app/controllers/school_controller.rb b/app/controllers/school_controller.rb index c8b495fe2..3fb42b64d 100644 --- a/app/controllers/school_controller.rb +++ b/app/controllers/school_controller.rb @@ -98,10 +98,11 @@ class SchoolController < ApplicationController end def search_school + q = "%#{params[:key_word].strip}%" if params[:province].nil? or params[:province] == "0" - @school = School.where("name LIKE '%"+params[:key_word]+"%'"); + @school = School.where("name LIKE ?", q); else - @school = School.where("province = ? AND name LIKE '%"+params[:key_word]+"%'", params[:province]); + @school = School.where("province = ? AND name LIKE ?", params[:province], q); end options = "" @school.each do |s| diff --git a/app/controllers/stores_controller.rb b/app/controllers/stores_controller.rb index fd0d3cf53..f34e72402 100644 --- a/app/controllers/stores_controller.rb +++ b/app/controllers/stores_controller.rb @@ -5,10 +5,10 @@ class StoresController < ApplicationController layout 'base_stores' def search - name = params[:name] ||= '' - (redirect_to stores_path, :notice => l(:label_sumbit_empty);return) if name.blank? + q = "%#{params[:name].strip}%" + (redirect_to stores_path, :notice => l(:label_sumbit_empty);return) if params[:name].blank? - result = find_public_attache name + result = find_public_attache q @searched_attach = paginateHelper result @result_all_count = result.count; end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index c9dc4fa26..e6bbf6ed6 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1396,7 +1396,7 @@ module ApplicationHelper # Returns the javascript tags that are included in the html layout head def javascript_heads - tags = javascript_include_tag('jquery-1.8.3-ui-1.9.2-ujs-2.0.3', 'application') + tags = javascript_include_tag('jquery-1.8.3-ui-1.9.2-ujs-2.0.3', 'application', 'jquery.colorbox-min') unless User.current.pref.warn_on_leaving_unsaved == '0' tags << "\n".html_safe + javascript_tag("$(window).load(function(){ warnLeavingUnsaved('#{escape_javascript l(:text_warn_on_leaving_unsaved)}'); });") end diff --git a/app/views/stores/search.html.erb b/app/views/stores/search.html.erb index f65f04648..b75656f18 100644 --- a/app/views/stores/search.html.erb +++ b/app/views/stores/search.html.erb @@ -79,7 +79,7 @@ } } $(document).ready(function($) { - $('.cb span').highlight('<%=params[:name]%>'); + $('.cb span').highlight('<%="#{params[:name].strip}"%>'); $('.a_download_icon').each(function(){ $(this).mouseenter(function(event) { diff --git a/public/images/colorbox/border1.png b/public/images/colorbox/border1.png new file mode 100644 index 000000000..0ddc70405 Binary files /dev/null and b/public/images/colorbox/border1.png differ diff --git a/public/images/colorbox/border2.png b/public/images/colorbox/border2.png new file mode 100644 index 000000000..aa62a0b72 Binary files /dev/null and b/public/images/colorbox/border2.png differ diff --git a/public/images/colorbox/loading.gif b/public/images/colorbox/loading.gif new file mode 100644 index 000000000..602ce3c3a Binary files /dev/null and b/public/images/colorbox/loading.gif differ diff --git a/public/javascripts/application.js b/public/javascripts/application.js index 81160fa93..9bba6cbbd 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -622,3 +622,14 @@ $(document).ready(setupAjaxIndicator); $(document).ready(hideOnLoad); $(document).ready(addFormObserversForDoubleSubmit); +function img_thumbnails() { + $('.thumbnails a').colorbox({rel:'nofollow'}); + $('.attachments').find('a').each(function(index, element) { + var href_value = $(element).attr('href'); + if (/\.(jpg|png|gif|bmp)$/.test(href_value)) { + $(element).colorbox({rel:'nofollow'}); + } + + }); +} +$(document).ready(img_thumbnails); diff --git a/public/javascripts/jquery.colorbox-min.js b/public/javascripts/jquery.colorbox-min.js new file mode 100644 index 000000000..f563217f0 --- /dev/null +++ b/public/javascripts/jquery.colorbox-min.js @@ -0,0 +1,7 @@ +/*! + Colorbox v1.5.10 - 2014-06-26 + jQuery lightbox and modal window plugin + (c) 2014 Jack Moore - http://www.jacklmoore.com/colorbox + license: http://www.opensource.org/licenses/mit-license.php +*/ +(function(t,e,i){function n(i,n,o){var r=e.createElement(i);return n&&(r.id=Z+n),o&&(r.style.cssText=o),t(r)}function o(){return i.innerHeight?i.innerHeight:t(i).height()}function r(e,i){i!==Object(i)&&(i={}),this.cache={},this.el=e,this.value=function(e){var n;return void 0===this.cache[e]&&(n=t(this.el).attr("data-cbox-"+e),void 0!==n?this.cache[e]=n:void 0!==i[e]?this.cache[e]=i[e]:void 0!==X[e]&&(this.cache[e]=X[e])),this.cache[e]},this.get=function(e){var i=this.value(e);return t.isFunction(i)?i.call(this.el,this):i}}function h(t){var e=W.length,i=(z+t)%e;return 0>i?e+i:i}function a(t,e){return Math.round((/%/.test(t)?("x"===e?E.width():o())/100:1)*parseInt(t,10))}function s(t,e){return t.get("photo")||t.get("photoRegex").test(e)}function l(t,e){return t.get("retinaUrl")&&i.devicePixelRatio>1?e.replace(t.get("photoRegex"),t.get("retinaSuffix")):e}function d(t){"contains"in y[0]&&!y[0].contains(t.target)&&t.target!==v[0]&&(t.stopPropagation(),y.focus())}function c(t){c.str!==t&&(y.add(v).removeClass(c.str).addClass(t),c.str=t)}function g(e){z=0,e&&e!==!1&&"nofollow"!==e?(W=t("."+te).filter(function(){var i=t.data(this,Y),n=new r(this,i);return n.get("rel")===e}),z=W.index(_.el),-1===z&&(W=W.add(_.el),z=W.length-1)):W=t(_.el)}function u(i){t(e).trigger(i),ae.triggerHandler(i)}function f(i){var o;if(!G){if(o=t(i).data(Y),_=new r(i,o),g(_.get("rel")),!$){$=q=!0,c(_.get("className")),y.css({visibility:"hidden",display:"block",opacity:""}),L=n(se,"LoadedContent","width:0; height:0; overflow:hidden; visibility:hidden"),b.css({width:"",height:""}).append(L),D=T.height()+k.height()+b.outerHeight(!0)-b.height(),j=C.width()+H.width()+b.outerWidth(!0)-b.width(),A=L.outerHeight(!0),N=L.outerWidth(!0);var h=a(_.get("initialWidth"),"x"),s=a(_.get("initialHeight"),"y"),l=_.get("maxWidth"),f=_.get("maxHeight");_.w=(l!==!1?Math.min(h,a(l,"x")):h)-N-j,_.h=(f!==!1?Math.min(s,a(f,"y")):s)-A-D,L.css({width:"",height:_.h}),J.position(),u(ee),_.get("onOpen"),O.add(I).hide(),y.focus(),_.get("trapFocus")&&e.addEventListener&&(e.addEventListener("focus",d,!0),ae.one(re,function(){e.removeEventListener("focus",d,!0)})),_.get("returnFocus")&&ae.one(re,function(){t(_.el).focus()})}v.css({opacity:parseFloat(_.get("opacity"))||"",cursor:_.get("overlayClose")?"pointer":"",visibility:"visible"}).show(),_.get("closeButton")?B.html(_.get("close")).appendTo(b):B.appendTo("
"),w()}}function p(){!y&&e.body&&(V=!1,E=t(i),y=n(se).attr({id:Y,"class":t.support.opacity===!1?Z+"IE":"",role:"dialog",tabindex:"-1"}).hide(),v=n(se,"Overlay").hide(),S=t([n(se,"LoadingOverlay")[0],n(se,"LoadingGraphic")[0]]),x=n(se,"Wrapper"),b=n(se,"Content").append(I=n(se,"Title"),R=n(se,"Current"),P=t('