mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
MINOR Moving Tree.js entwine rules into namespace (wasn't applying multiple/draggable toggles because of that)
This commit is contained in:
parent
755a9c398a
commit
0c6bc2f7a1
@ -254,75 +254,77 @@
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
onunmatch: function() {
|
||||
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('.cms-tree.multiple').entwine({
|
||||
onmatch: function() {
|
||||
this._super();
|
||||
|
||||
$('.cms-tree.multiple').entwine({
|
||||
onmatch: function() {
|
||||
this._super();
|
||||
this.jstree('show_checkboxes');
|
||||
},
|
||||
onunmatch: function() {
|
||||
this._super();
|
||||
this.jstree('uncheck_all');
|
||||
this.jstree('hide_checkboxes');
|
||||
},
|
||||
/**
|
||||
* Function: getSelectedIDs
|
||||
*
|
||||
* Returns:
|
||||
* (Array)
|
||||
*/
|
||||
getSelectedIDs: function() {
|
||||
return $.map($(this).jstree('get_checked'), function(el, i) {return $(el).data('id');});
|
||||
}
|
||||
});
|
||||
|
||||
$('.cms-tree li').entwine({
|
||||
|
||||
this.jstree('show_checkboxes');
|
||||
},
|
||||
onunmatch: function() {
|
||||
this._super();
|
||||
/**
|
||||
* Function: setEnabled
|
||||
*
|
||||
* Parameters:
|
||||
* (bool)
|
||||
*/
|
||||
setEnabled: function(bool) {
|
||||
this.toggleClass('disabled', !(bool));
|
||||
},
|
||||
|
||||
this.jstree('uncheck_all');
|
||||
this.jstree('hide_checkboxes');
|
||||
},
|
||||
/**
|
||||
* Function: getSelectedIDs
|
||||
*
|
||||
* Returns:
|
||||
* (Array)
|
||||
*/
|
||||
getSelectedIDs: function() {
|
||||
return $.map($(this).jstree('get_checked'), function(el, i) {return $(el).data('id');});
|
||||
}
|
||||
});
|
||||
|
||||
$('.cms-tree li').entwine({
|
||||
/**
|
||||
* Function: getClassname
|
||||
*
|
||||
* Returns PHP class for this element. Useful to check business rules like valid drag'n'drop targets.
|
||||
*/
|
||||
getClassname: function() {
|
||||
var matches = this.attr('class').match(/class-([^\s]*)/i);
|
||||
return matches ? matches[1] : '';
|
||||
},
|
||||
|
||||
/**
|
||||
* Function: getID
|
||||
*
|
||||
* Returns:
|
||||
* (Number)
|
||||
*/
|
||||
getID: function() {
|
||||
return this.data('id');
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Function: setEnabled
|
||||
*
|
||||
* Parameters:
|
||||
* (bool)
|
||||
*/
|
||||
setEnabled: function(bool) {
|
||||
this.toggleClass('disabled', !(bool));
|
||||
},
|
||||
|
||||
/**
|
||||
* Function: getClassname
|
||||
*
|
||||
* Returns PHP class for this element. Useful to check business rules like valid drag'n'drop targets.
|
||||
*/
|
||||
getClassname: function() {
|
||||
var matches = this.attr('class').match(/class-([^\s]*)/i);
|
||||
return matches ? matches[1] : '';
|
||||
},
|
||||
|
||||
/**
|
||||
* Function: getID
|
||||
*
|
||||
* Returns:
|
||||
* (Number)
|
||||
*/
|
||||
getID: function() {
|
||||
return this.data('id');
|
||||
}
|
||||
$('.cms-tree-view-modes input.view-mode').entwine({
|
||||
onmatch: function() {
|
||||
// set active by default
|
||||
this.trigger('click');
|
||||
this._super();
|
||||
},
|
||||
onclick: function(e) {
|
||||
$('.cms-tree')
|
||||
.toggleClass('draggable', $(e.target).val() == 'draggable')
|
||||
.toggleClass('multiple', $(e.target).val() == 'multiselect');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('.cms-tree-view-modes input.view-mode').entwine({
|
||||
onmatch: function() {
|
||||
// set active by default
|
||||
this.trigger('click');
|
||||
this._super();
|
||||
},
|
||||
onclick: function(e) {
|
||||
$('.cms-tree').toggleClass('draggable', $(e.target).val() == 'draggable');
|
||||
}
|
||||
});
|
||||
|
||||
}(jQuery));
|
Loading…
Reference in New Issue
Block a user