Compare commits
11 Commits
821c9bc32c
...
develop
| Author | SHA1 | Date | |
|---|---|---|---|
| 21cd43c4cb | |||
| 49e8206aff | |||
| 680fab2835 | |||
| fc455ae0bb | |||
| ccda58557a | |||
| 411a8e95ad | |||
| e11e4f872d | |||
| ac593ec377 | |||
| 0499e7ecaa | |||
| 42cfd88a24 | |||
| 16b5798dc3 |
@@ -19,6 +19,12 @@
|
||||
*/
|
||||
var sf = {
|
||||
|
||||
/**
|
||||
* Library version
|
||||
*
|
||||
*/
|
||||
version: '0.1.0',
|
||||
|
||||
/**
|
||||
* Initialises the library
|
||||
*
|
||||
@@ -35,7 +41,7 @@ var sf = {
|
||||
];
|
||||
|
||||
for (var module in modules) {
|
||||
sf[module].init();
|
||||
sf[modules[module]].init();
|
||||
}
|
||||
|
||||
},
|
||||
@@ -170,6 +176,7 @@ var sf = {
|
||||
*/
|
||||
init: function() {
|
||||
sf.ui.dialog.init();
|
||||
sf.ui.selectall.init();
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -182,7 +189,7 @@ var sf = {
|
||||
*/
|
||||
init: function() {
|
||||
// Permanently configure the X to close the dialog
|
||||
$("#dialog-header-close").click(sf.dialog.close);
|
||||
$("#dialog-header-close").click(sf.ui.dialog.close);
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -335,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);
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -365,8 +404,7 @@ var sf = {
|
||||
* Initialise module
|
||||
*/
|
||||
init: function() {
|
||||
// Update the content of the page on first load
|
||||
sf.page.updateEvents($('#page_content'));
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -461,6 +499,10 @@ var sf = {
|
||||
*/
|
||||
callbacks: {
|
||||
|
||||
'close-dialog': function(params) {
|
||||
sf.ui.dialog.close();
|
||||
},
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -478,16 +520,15 @@ var sf = {
|
||||
*
|
||||
* @param names Names of the action(s) to execute
|
||||
* @param params Object containing action specific parameters
|
||||
* @returns bool
|
||||
*/
|
||||
trigger: function(names, params) {
|
||||
if ( ! names instanceof Array) {
|
||||
if ( ! (names instanceof Array)) {
|
||||
names = [names];
|
||||
}
|
||||
|
||||
for (var name in names) {
|
||||
if (sf.actions.callbacks[name]) {
|
||||
return sf.actions.callbacks[name](params);
|
||||
if (sf.actions.callbacks[names[name]]) {
|
||||
sf.actions.callbacks[names[name]](params);
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -534,4 +575,4 @@ var sf = {
|
||||
};
|
||||
|
||||
// Execute the initialisation code as soon as the DOM is ready.
|
||||
$('document').ready(sb.init);
|
||||
$('document').ready(sf.init);
|
||||
|
||||
Reference in New Issue
Block a user