Current Path : C:/Users/Mahmood/Desktop/moodle/lib/amd/build/ |
Current File : C:/Users/Mahmood/Desktop/moodle/lib/amd/build/checkbox-toggleall.min.js |
define ("core/checkbox-toggleall",["jquery","core/pubsub"],function(a,b){var c=!1,d={checkboxToggled:"core/checkbox-toggleall:checkboxToggled"},e=function(a,b,c){if(c){return a.find("[data-action=\"toggle\"][data-togglegroup=\""+b+"\"]")}else{return a.find("[data-action=\"toggle\"][data-togglegroup^=\""+b+"\"]")}},f=function(a,b){return e(a,b,!1).filter("[data-toggle=\"slave\"]")},g=function(a,b,c){return e(a,b,c).filter("[data-toggle=\"master\"]")},h=function(a,b){return e(a,b,!0).filter("[data-toggle=\"action\"]")},i=function(b){var c=b.data.root,d=a(b.target),e=d.data("togglegroup"),f;if(d.is(":checkbox")){f=d.is(":checked")}else{f=1===d.data("checkall")}j(c,e,f)},j=function(a,c,e){var g=f(a,c),h=g.filter(":checked");m(a,c,e,!1);g.prop("checked",e);g.trigger("change");b.publish(d.checkboxToggled,{root:a,toggleGroupName:c,slaves:g,checkedSlaves:h,anyChecked:e})},k=function(c){var e=c.data.root,g=a(c.target),h=g.data("togglegroup").split(" "),i=[],j="";h.forEach(function(a){j+=" "+a;i.push(j.trim())});i.forEach(function(a){var c=f(e,a),g=c.filter(":checked"),h=c.length===g.length;m(e,a,h,!0);l(e,a,!g.length);b.publish(d.checkboxToggled,{root:e,toggleGroupName:a,slaves:c,checkedSlaves:g,anyChecked:!!g.length})})},l=function(a,b,c){h(a,b).prop("disabled",c)},m=function(b,c,d,e){var f=g(b,c,e);f.prop("checked",d);f.each(function(c,e){e=a(e);var f;if(d){f=e.data("toggle-deselectall")}else{f=e.data("toggle-selectall")}if(e.is(":checkbox")){var g=b.find("[for=\""+e.attr("id")+"\"]");if(g.length){if(g.html()!==f){g.html(f)}}}else{e.text(f);e.data("checkall",d?0:1)}})},n=function(){if(!c){c=!0;var b=a(document.body);b.on("click","[data-action=\"toggle\"][data-toggle=\"master\"]",{root:b},i);b.on("change","[data-action=\"toggle\"][data-toggle=\"slave\"]",{root:b},k)}};return{init:function init(){n()},events:d,setGroupState:function setGroupState(b,c,d){b=a(b);m(b,c,d,!0);j(b,c,d)},updateSlavesFromMasterState:function updateSlavesFromMasterState(b,c){b=a(b);var d=g(b,c,!1),e;if(d.is(":checkbox")){e=d.is(":checked")}else{e=1===d.data("checkall")}j(b,c,e)}}}); //# sourceMappingURL=checkbox-toggleall.min.js.map