Skip to content

Commit

Permalink
MINOR Moving Tree.js entwine rules into namespace (wasn't applying mu…
Browse files Browse the repository at this point in the history
…ltiple/draggable toggles because of that)
  • Loading branch information
chillu committed Mar 6, 2012
1 parent 755a9c3 commit 0c6bc2f
Showing 1 changed file with 67 additions and 65 deletions.
132 changes: 67 additions & 65 deletions admin/javascript/LeftAndMain.Tree.js
Expand Up @@ -254,75 +254,77 @@
}
}

},
onunmatch: function() {

}
});
});

$('.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({

/**
* Function: setEnabled
*
* Parameters:
* (bool)
*/
setEnabled: function(bool) {
this.toggleClass('disabled', !(bool));
},
$('.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');});
}
});

/**
* 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] : '';
},
$('.cms-tree li').entwine({

/**
* 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');
}
});

/**
* 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');
}
$('.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');
}
});
});

}(jQuery));

0 comments on commit 0c6bc2f

Please sign in to comment.