Merge branch 'context-menu' of https://github.com/adrexia/silverstripe-cms into adrexia-context-menu

This commit is contained in:
Ingo Schommer 2013-08-20 14:47:40 +02:00
commit 88081d5333

View File

@ -2,6 +2,40 @@
$.entwine('ss.tree', function($){ $.entwine('ss.tree', function($){
$('.cms-tree').entwine({ $('.cms-tree').entwine({
onadd: function(){
var self = this;
$(document).on('context_show.vakata', function(){
self.adjustContextClass(this);
});
this._super();
},
/*
* Add and remove classes from context menus to allow for
* adjusting the display
*/
adjustContextClass: function(){
var menus = $('#vakata-contextmenu').find("ul ul");
menus.each(function(i){
var col = "1",
count = $(menus[i]).find('li').length;
//Assign columns to menus over 10 items long
if(count > 20){
col = "3";
}else if(count > 10){
col = "2";
}
$(menus[i]).addClass('col-' + col).removeClass('right');
//Remove "right" class that jstree adds on mouseenter
$(menus[i]).find('li').on("mouseenter", function (e) {
$(this).parent('ul').removeClass("right");
});
});
},
getTreeConfig: function() { getTreeConfig: function() {
var self = this, config = this._super(), hints = this.getHints(); var self = this, config = this._super(), hints = this.getHints();
config.plugins.push('contextmenu'); config.plugins.push('contextmenu');