Files
Disco/Disco.Web/ClientSource/Scripts/Modules/Disco-jQueryExtensions.min.js
T
Gary Sharp 9baca7f633 Javascript bundling updated
Using VS extension: 'Bundler & Minifier'
2016-09-29 18:34:06 +10:00

1 line
1.3 KiB
JavaScript

(function(n){var t={init:function(i){return i=n.extend({parentSelector:"tr"},i),this.each(function(){var u=n(this),r,e,o;if(u.data("checkboxBulkSelect_parentSelector",i.parentSelector),r=u.closest(i.parentSelector).find('input[type="checkbox"]'),r.length>0){function s(){return r.prop("checked",!0),f(),!1}function h(){return r.prop("checked",!1),f(),!1}function f(){t.update.apply(u,[r,i.parentSelector,e,o])}e=n("<a>").addClass("selectAll").attr("href","#").text("ALL").click(s);o=n("<a>").addClass("selectNone").attr("href","#").text("NONE").click(h);u.append(n("<span>").text("Select: "),e,n("<span>").text(" | "),o);r.click(f);f()}})},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.prop("disabled",!0),u.prop("disabled",!1)):f.length==0?(u.prop("disabled",!0),r.prop("disabled",!1)):(r.prop("disabled",!1),u.prop("disabled",!1))})}};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);