mirror of
https://github.com/silverstripe/silverstripe-reports
synced 2024-10-22 11:05:53 +02:00
BUG: Context menu too long (Fixes #811)
Added javascript to add and remove classes on context sub menus, to allow for multi column layout.
This commit is contained in:
parent
f937b95eaf
commit
a2a4957fa5
@ -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');
|
||||||
|
Loading…
Reference in New Issue
Block a user