phpMv
-UI toolkit 2.4.12
jQuery, jQuery UI, Twitter Bootstrap and Semantic-UI library for php & php MVC Frameworks
Loading...
Searching...
No Matches
tplCheckedList.php
Go to the documentation of this file.
1
<?php
2
return
'
3
var deferredEach=function (arr, batchSize) {
4
var deferred = $.Deferred();var index = 0;
5
function chunk () {var lastIndex = Math.min(index + batchSize, arr.length);
6
for(;index<lastIndex;index++){deferred.notify(index, arr[index]);}
7
if (index >= arr.length) {deferred.resolve();} else {setTimeout(chunk, 0);}
8
};
9
setTimeout(chunk, 0);return deferred.promise();
10
};
11
$("%identifier% .master")
12
.checkbox({
13
onChecked: function() {if($(this).closest(".loading").length==0 && !$(this).hasClass("_notAllChecked")){$(this).closest(".checkbox").siblings(".list").find(".checkbox").checkbox("check");}},
14
onUnchecked: function() {if($(this).closest(".loading").length==0){$(this).closest(".checkbox").siblings(".list").find(".checkbox").checkbox("uncheck");}}
15
})
16
;
17
$("%identifier% .list .child.checkbox")
18
.checkbox({
19
fireOnInit : %fireOnInit%,
20
onChange : function() {
21
var $listGroup = $(this).closest(".list"),
22
$parentCheckbox = $listGroup.closest(".item").children(".checkbox"),
23
$checkbox = $listGroup.find(".checkbox"),
24
allChecked = true,
25
allUnchecked = true;
26
$listGroup.closest(".segment").addClass("loading");
27
deferredEach($checkbox,5).progress(function(index, item){
28
if( $(item).checkbox("is checked") ) {
29
allUnchecked = false;
30
}
31
else {
32
allChecked = false;
33
}
34
if(!allUnchecked && !allChecked) return;
35
}).done(function(){
36
$listGroup.closest(".segment.loading").removeClass("loading");
37
if(allChecked) {
38
$parentCheckbox.checkbox("set checked");
39
}
40
else if(allUnchecked) {
41
if(!$parentCheckbox.children("input").first().hasClass("_notAllChecked")){
42
$parentCheckbox.checkbox("set unchecked");
43
}
44
}
45
else {
46
$parentCheckbox.checkbox("set indeterminate");
47
}
48
%onChange%
49
});
50
}
51
})
52
;'
;
Ajax
semantic
components
jsTemplates
tplCheckedList.php
Generated on Sun Dec 10 2023 16:15:59 for
phpMv-UI
by
doxygen
1.9.8