Skip to content

Commit

Permalink
#2836 developing of headerMenu extension - solution for column type
Browse files Browse the repository at this point in the history
  • Loading branch information
Alice Trofimova committed Dec 4, 2015
1 parent 520e4d5 commit f254bef
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 40 deletions.
3 changes: 0 additions & 3 deletions core/src/main/web/app/styles/vendor_overrides.scss
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,6 @@ tbody tr {
}

td {
&.highlight {
background-color: #99CCFF !important;
}
&.selected {
background-color: #aab7d1;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -893,10 +893,17 @@
}
},
{
title: 'Format',
action: null,
items: []
},
name: function(el) {
var container = el.closest('.bko-header-menu');
var colIdx = container.data('columnIndex');
var typeId = scope.actualtype[colIdx - 1];

return (scope.types[typeId]) ? "Type: " + scope.types[typeId] : null;
},
title: null,
action: null
}
/*
{
title: 'Alignment',
action: null,
Expand Down Expand Up @@ -924,7 +931,7 @@
action: function() {}
}
]
}
}*/
]
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ var HeaderMenu = function(dt, options) {
dt: new DataTable.Api(dt)
};

this.c = options; //$.extend(true, {}, HeaderMenu.defaults, options);
this.c = options;

this.dom = {
container: null,
Expand All @@ -47,18 +47,6 @@ HeaderMenu.prototype = {
this._appendMenuContainer();
this._buildMenuData(headerLayout);

var header = dt.table().header();

$(header).on('mouseenter', 'th', function() {
//column hightlight
var colIdx = $(this).data('columnIndex');

$(dt.cells().nodes()).removeClass('highlight');
$(dt.column(colIdx).nodes()).addClass('highlight');
}).on('mouseleave', 'th', function() {
$(dt.cells().nodes()).removeClass('highlight');
});

$(document.body).bind('mousedown', function(e) {
var $container = that.dom.container;

Expand Down Expand Up @@ -160,7 +148,7 @@ HeaderMenu.prototype = {

/**
* @param oItems {object}
* @param container {node} should be <ul> dropdown-menu container?
* @param container {node} should be <ul> dropdown-menu container
*/
_buildMenuItems: function (oItems, container)
{
Expand All @@ -172,13 +160,18 @@ HeaderMenu.prototype = {
for (var i = 0, ien = oItems.length; i < ien; i++) {
var oItem = oItems[i];
var hasSubitems = $.isArray(oItem.items) && oItem.items.length;
var altTitle = null;

if (oItem.name && typeof oItem.name == 'function') {
var altTitle = oItem.name(that.dom.container);
}

var $li = $('<li/>', {'class': hasSubitems ? 'dropdown-submenu' : ''});
var $item = $('<a/>')
.attr('href', '#')
.attr('tabindex', '-1')
.attr('id', 'dt-select-all')
.text(oItem.title)
.text((oItem.title || altTitle))
.data('action', oItem.action || '')
.bind('click', function(e) {
that._handleItemClick($(this));
Expand Down Expand Up @@ -215,23 +208,6 @@ HeaderMenu.prototype = {
}
};

HeaderMenu.defaults = {
dom: {
container: {
tag: 'ul',
class: 'dropdown-menu',
attrs: {
'role': 'menu'
}
}
},
toAdd: [
{
parent: 'Format'
}
]
};

$.fn.dataTable.HeaderMenu = HeaderMenu;
$.fn.DataTable.HeaderMenu = HeaderMenu;

Expand Down

0 comments on commit f254bef

Please sign in to comment.