Files
Disco/Disco.Web/ClientSource/Scripts/Modules/Disco-jQueryExtensions.min.js
T
2013-02-28 17:15:46 +11:00

2 lines
1.4 KiB
JavaScript

(function(n){var t={init:function(i){return i=n.extend({parentSelector:"tr"},i),this.each(function(){var u=n(this),r,f,e;if(u.data("checkboxBulkSelect_parentSelector",i.parentSelector),r=u.closest(i.parentSelector).find('input[type="checkbox"]'),r.length>0){f=n("<a>").addClass("selectAll").attr("href","#").text("ALL").click(s),e=n("<a>").addClass("selectNone").attr("href","#").text("NONE").click(h),u.append(n("<span>").text("Select: "),f,n("<span>").text(" | "),e),r.click(o),o();function s(){return r.attr("checked","checked"),o(),!1}function h(){return r.removeAttr("checked"),o(),!1}function o(){t.update.apply(u,[r,i.parentSelector,f,e])}}})},update:function(t,i,r,u){return this.each(function(){$this=n(this),i||(i=$this.data("checkboxBulkSelect_parentSelector")),t||(t=$this.closest(i).find('input[type="checkbox"]')),r||(r=$this.find("a.selectAll").first()),u||(u=$this.find("a.selectNone").first());var f=t.filter(":checked");t.length==f.length?(r.attr("disabled","disabled"),u.removeAttr("disabled")):f.length==0?(u.attr("disabled","disabled"),r.removeAttr("disabled")):(r.removeAttr("disabled"),u.removeAttr("disabled"))})}};n.fn.checkboxBulkSelect=function(i){if(t[i])return t[i].apply(this,Array.prototype.slice(arguments,1));if(typeof i!="object"&&i)n.error("Method "+i+" does not exist on jQuery.checkboxBulkSelect");else return t.init.apply(this,arguments)}})(jQuery);
//@ sourceMappingURL=Disco-jQueryExtensions.min.js.map