Compare commits
2 Commits
release-0.
...
develop
| Author | SHA1 | Date | |
|---|---|---|---|
| 21cd43c4cb | |||
| 49e8206aff |
@@ -1,22 +1,22 @@
|
|||||||
/**
|
/**
|
||||||
* Sihnon Framework JS Library
|
* Sihnon Framework JS Library
|
||||||
*
|
*
|
||||||
* Written by Ben Roberts
|
* Written by Ben Roberts
|
||||||
* Homepage: https://benroberts.net/projects/sihnon-framework/
|
* Homepage: https://benroberts.net/projects/sihnon-framework/
|
||||||
* Code: https://github.com/optiz0r/sihnon-js-lib/
|
* Code: https://github.com/optiz0r/sihnon-js-lib/
|
||||||
*
|
*
|
||||||
* Dependencies:
|
* Dependencies:
|
||||||
* - Bootstrap-*.js
|
* - Bootstrap-*.js
|
||||||
*
|
*
|
||||||
* Released under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License
|
* Released under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License
|
||||||
* http://creativecommons.org/licenses/by-nc-sa/3.0/
|
* http://creativecommons.org/licenses/by-nc-sa/3.0/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sihnon Framework object
|
* Sihnon Framework object
|
||||||
*
|
*
|
||||||
* Entry point for all base framework code
|
* Entry point for all base framework code
|
||||||
*/
|
*/
|
||||||
var sf = {
|
var sf = {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -176,6 +176,7 @@ var sf = {
|
|||||||
*/
|
*/
|
||||||
init: function() {
|
init: function() {
|
||||||
sf.ui.dialog.init();
|
sf.ui.dialog.init();
|
||||||
|
sf.ui.selectall.init();
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -341,6 +342,38 @@ var sf = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Submodule for handling select-all checkbox groups
|
||||||
|
*/
|
||||||
|
selectall: {
|
||||||
|
init: function() {
|
||||||
|
// Enable select all/none for checkboxes
|
||||||
|
$('input[type=checkbox].select-all').click(sf.ui.selectall.updateChildren);
|
||||||
|
|
||||||
|
// Enable update of the select-all checkbox as the children are manually changed
|
||||||
|
$('input[type=checkbox].select-all').each(function() {
|
||||||
|
$('input[type=checkbox][data-select-all="' + $(this).attr('id') + '"]').click(sf.ui.selectall.updateParent);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
updateChildren: function(parent_id, children) {
|
||||||
|
$('input[type=checkbox][data-select-all="'+$(this).attr('id')+'"]')
|
||||||
|
.attr('checked', $(this).attr('checked') == 'checked')
|
||||||
|
.trigger('change');
|
||||||
|
},
|
||||||
|
|
||||||
|
updateParent: function() {
|
||||||
|
var parent = $('#' + $(this).attr('data-select-all'));
|
||||||
|
var children = $('input[type=checkbox][data-select-all="' + parent.attr('id') + '"]');
|
||||||
|
|
||||||
|
if (children.filter(':checked').length != children.length) {
|
||||||
|
parent.attr('checked', false);
|
||||||
|
} else if (children.not(':checked').length == 0) {
|
||||||
|
parent.attr('checked', true);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user