Stickit refactoring for node group checkboxes

Change-Id: I97c8566fda7d22d19cf89628fc1d5cab593e8060
This commit is contained in:
Julia Aranovich 2014-03-13 17:20:33 +04:00
parent 7c16388b3c
commit c5e0945157
2 changed files with 17 additions and 21 deletions

View File

@ -8,7 +8,7 @@
"lodash": "1.1.1",
"autoNumeric": "http://github.com/BobKnothe/autoNumeric/zipball/1.9.12",
"jquery.timeout": "http://jquery-timeout.googlecode.com/files/jquery.timeout-1.1.0.js",
"backbone.stickit": "https://raw.github.com/NYTimes/backbone.stickit/7437202ec91863aa29a6ad31b0bd00c6b130f506/backbone.stickit.js",
"backbone.stickit": "https://raw.github.com/NYTimes/backbone.stickit/0.7.0/backbone.stickit.js",
"i18next": "1.7.1",
"backbone-deep-model": "0.10.4",
"less": "1.5.1"

View File

@ -536,22 +536,21 @@ function(utils, models, commonViews, dialogViews, nodesManagementPanelTemplate,
selectAllBindings: {
'input[name=select-nodes-common]': {
observe: 'checked',
stickitChange: true,
onSet: 'selectNodes',
attributes: [{
name: 'disabled',
observe: 'disabled'
}]
}
},
selectNodes: function(model, value, options) {
if (options.stickitChange) {
_.each(this.subViews, function(nodeGroup) {
if (!nodeGroup.selectAllCheckbox.get('disabled')) {
nodeGroup.selectAllCheckbox.set('checked', value);
}
});
_.invoke(this.filteredNodes.where({disabled: false}), 'set', {checked: value});
}
selectNodes: function(value) {
_.each(this.subViews, function(nodeGroup) {
if (!nodeGroup.selectAllCheckbox.get('disabled')) {
nodeGroup.selectAllCheckbox.set('checked', value);
}
});
_.invoke(this.filteredNodes.where({disabled: false}), 'set', {checked: value});
return value;
},
hideSummaryPanel: function(e) {
if (!(e && $(e.target).closest(this.$('.node-list-name')).length)) {
@ -611,7 +610,6 @@ function(utils, models, commonViews, dialogViews, nodesManagementPanelTemplate,
checked: false,
disabled: false
});
this.selectAllCheckbox.on('change:checked', this.selectNodes, this);
},
renderNodeGroups: function(nodeGroups) {
this.$('.nodes').html('');
@ -650,20 +648,19 @@ function(utils, models, commonViews, dialogViews, nodesManagementPanelTemplate,
selectAllBindings: {
'input[name=select-node-group]': {
observe: 'checked',
stickitChange: true,
onSet: 'selectNodes',
attributes: [{
name: 'disabled',
observe: 'disabled'
}]
}
},
selectNodes: function(model, value, options) {
if (options.stickitChange) {
_.each(this.nodes.where({disabled: false}), function(node) {
node.set('checked', value);
});
this.nodeList.calculateSelectAllCheckedState();
}
selectNodes: function(value) {
_.each(this.nodes.where({disabled: false}), function(node) {
node.set('checked', value);
});
this.nodeList.calculateSelectAllCheckedState();
return value;
},
calculateSelectAllCheckedState: function() {
var availableNodes = this.nodes.filter(function(node) {return node.isSelectable();});
@ -680,7 +677,6 @@ function(utils, models, commonViews, dialogViews, nodesManagementPanelTemplate,
checked: false,
disabled: false
});
this.selectAllCheckbox.on('change:checked', this.selectNodes, this);
this.selectAllCheckbox.on('change:disabled', this.nodeList.calculateSelectAllDisabledState, this.nodeList);
this.nodes.on('change:checked', this.calculateSelectAllCheckedState, this);
},