slickgrid
Advanced tools
Comparing version 2.3.9 to 2.3.10
@@ -0,1 +1,3 @@ | ||
'use strict'; | ||
(function ($) { | ||
@@ -17,7 +19,7 @@ function SlickColumnPicker(columns, grid, options) { | ||
$menu = $("<div class='slick-columnpicker' style='display:none' />").appendTo(document.body); | ||
$close = $("<button type='button' class='close' data-dismiss='slick-columnpicker' aria-label='Close'><span class='close' aria-hidden='true'>×</span></button>").appendTo($menu); | ||
var $close = $("<button type='button' class='close' data-dismiss='slick-columnpicker' aria-label='Close'><span class='close' aria-hidden='true'>×</span></button>").appendTo($menu); | ||
// user could pass a title on top of the columns list | ||
if(options.columnPickerTitle) { | ||
$title = $("<div class='title'/>").append(options.columnPickerTitle); | ||
var $title = $("<div class='title'/>").append(options.columnPickerTitle); | ||
$title.appendTo($menu); | ||
@@ -24,0 +26,0 @@ } |
@@ -52,2 +52,8 @@ /*** | ||
* | ||
* onMenuClose: Fired when the menu is closing. | ||
* Event args: | ||
* grid: Reference to the grid. | ||
* column: Column definition. | ||
* menu: Menu options. Note that you can change the menu items here. | ||
* | ||
* onCommand: Fired on menu item click for buttons with 'command' specified. | ||
@@ -71,2 +77,4 @@ * Event args: | ||
'use strict'; | ||
(function ($) { | ||
@@ -84,2 +92,3 @@ // register namespace | ||
var _grid = grid; | ||
var _isMenuOpen = false; | ||
var _options = options; | ||
@@ -93,3 +102,3 @@ var _self = this; | ||
menuWidth: 18, | ||
resizeOnShowHeaderRow: true | ||
resizeOnShowHeaderRow: false | ||
}; | ||
@@ -99,3 +108,3 @@ | ||
var gridMenuWidth = (_options.gridMenu && _options.gridMenu.menuWidth) || _defaults.menuWidth; | ||
$header = $('.slick-header'); | ||
var $header = $('.slick-header'); | ||
$header.attr('style', 'width: calc(100% - ' + gridMenuWidth +'px)'); | ||
@@ -106,7 +115,7 @@ | ||
if(enableResizeHeaderRow) { | ||
$headerrow = $('.slick-headerrow'); | ||
var $headerrow = $('.slick-headerrow'); | ||
$headerrow.attr('style', 'width: calc(100% - ' + gridMenuWidth +'px)'); | ||
} | ||
$button = $('<button class="slick-gridmenu-button"/>'); | ||
var $button = $('<button class="slick-gridmenu-button"/>'); | ||
if (_options.gridMenu && _options.gridMenu.iconCssClass) { | ||
@@ -116,3 +125,3 @@ $button.addClass(_options.gridMenu.iconCssClass); | ||
var iconImage = (_options.gridMenu && _options.gridMenu.iconImage) ? _options.gridMenu.iconImage :"../images/drag-handle.png"; | ||
$btnImage = $('<img src="' + iconImage + '"/>'); | ||
var $btnImage = $('<img src="' + iconImage + '"/>'); | ||
$btnImage.appendTo($button); | ||
@@ -123,5 +132,5 @@ } | ||
$menu = $('<div class="slick-gridmenu" style="display: none" />').appendTo(document.body); | ||
$close = $('<button type="button" class="close" data-dismiss="slick-gridmenu" aria-label="Close"><span class="close" aria-hidden="true">×</span></button>').appendTo($menu); | ||
var $close = $('<button type="button" class="close" data-dismiss="slick-gridmenu" aria-label="Close"><span class="close" aria-hidden="true">×</span></button>').appendTo($menu); | ||
$customMenu = $('<div class="slick-gridmenu-custom" />'); | ||
var $customMenu = $('<div class="slick-gridmenu-custom" />'); | ||
$customMenu.appendTo($menu); | ||
@@ -131,3 +140,3 @@ | ||
if(_options.gridMenu && _options.gridMenu.customTitle) { | ||
$title = $('<div class="title"/>').append(_options.gridMenu.customTitle); | ||
var $title = $('<div class="title"/>').append(_options.gridMenu.customTitle); | ||
$title.appendTo($customMenu); | ||
@@ -189,3 +198,3 @@ } | ||
$content = $("<span class='slick-gridmenu-content'></span>") | ||
var $content = $("<span class='slick-gridmenu-content'></span>") | ||
.text(item.title) | ||
@@ -203,3 +212,3 @@ .appendTo($li); | ||
if(_options.gridMenu && _options.gridMenu.columnTitle) { | ||
$title = $('<div class="title"/>').append(_options.gridMenu.columnTitle); | ||
var $title = $('<div class="title"/>').append(_options.gridMenu.columnTitle); | ||
$title.appendTo($menu); | ||
@@ -279,4 +288,6 @@ } | ||
function handleBodyMouseDown(e) { | ||
if (($menu && $menu[0] != e.target && !$.contains($menu[0], e.target)) || e.target.className == "close") { | ||
hideMenu(); | ||
if (($menu && $menu[0] != e.target && !$.contains($menu[0], e.target) && _isMenuOpen) || e.target.className == "close") { | ||
hideMenu(e); | ||
} else { | ||
_isMenuOpen = true; | ||
} | ||
@@ -296,3 +307,3 @@ } | ||
if(!leaveOpen) { | ||
hideMenu(); | ||
hideMenu(e); | ||
} | ||
@@ -313,5 +324,13 @@ | ||
function hideMenu() { | ||
function hideMenu(e) { | ||
if ($menu) { | ||
$menu.hide(_options.fadeSpeed); | ||
_isMenuOpen = false; | ||
if (_self.onMenuClose.notify({ | ||
"grid": _grid, | ||
"menu": $menu | ||
}, e, _self) == false) { | ||
return; | ||
} | ||
} | ||
@@ -391,2 +410,3 @@ } | ||
"onBeforeMenuShow": new Slick.Event(), | ||
"onMenuClose": new Slick.Event(), | ||
"onCommand": new Slick.Event() | ||
@@ -393,0 +413,0 @@ }); |
{ | ||
"name": "slickgrid", | ||
"version": "2.3.9", | ||
"version": "2.3.10", | ||
"description": "A lightning fast JavaScript grid/spreadsheet", | ||
@@ -5,0 +5,0 @@ "main": "slick.core.js", |
@@ -963,2 +963,56 @@ (function ($) { | ||
function syncGridSelection(grid, preserveHidden, preserveHiddenOnSelectionChange) { | ||
var dv = this; | ||
var inHandler; | ||
var selectedRowIds = dv.mapRowsToIds(grid.getSelectedRows()); | ||
var onSelectedRowIdsChanged = new Slick.Event(); | ||
function setSelectedRowIds(rowIds) { | ||
if (selectedRowIds.join(",") == rowIds.join(",")) { | ||
return; | ||
} | ||
selectedRowIds = rowIds; | ||
onSelectedRowIdsChanged.notify({ | ||
"grid": grid, | ||
"ids": selectedRowIds, | ||
"dataView": dv | ||
}, new Slick.EventData(), dv); | ||
} | ||
function update() { | ||
if (selectedRowIds.length > 0) { | ||
inHandler = true; | ||
var selectedRows = dv.mapIdsToRows(selectedRowIds); | ||
if (!preserveHidden) { | ||
setSelectedRowIds(dv.mapRowsToIds(selectedRows)); | ||
} | ||
grid.setSelectedRows(selectedRows); | ||
inHandler = false; | ||
} | ||
} | ||
grid.onSelectedRowsChanged.subscribe(function(e, args) { | ||
if (inHandler) { return; } | ||
var newSelectedRowIds = dv.mapRowsToIds(grid.getSelectedRows()); | ||
if (!preserveHiddenOnSelectionChange || !grid.getOptions().multiSelect) { | ||
setSelectedRowIds(newSelectedRowIds); | ||
} else { | ||
// keep the ones that are hidden | ||
var existing = $.grep(selectedRowIds, function(id) { return dv.getRowById(id) === undefined; }); | ||
// add the newly selected ones | ||
setSelectedRowIds(existing.concat(newSelectedRowIds)); | ||
} | ||
}); | ||
dv.onRowsChanged.subscribe(update); | ||
dv.onRowCountChanged.subscribe(update); | ||
return onSelectedRowIdsChanged; | ||
} | ||
// extend the functionality of syncGridSelection. This is an object that should be newed into existence. | ||
function gridSelectionExtender(grid, preserveHidden, preserveHiddenOnSelectionChange) { | ||
var self = this; | ||
@@ -965,0 +1019,0 @@ var inHandler; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3713447
87088