diff options
author | mleibman <michael.leibman@gmail.com> | 2010-11-27 17:23:59 -0800 |
---|---|---|
committer | mleibman <michael.leibman@gmail.com> | 2010-11-27 17:23:59 -0800 |
commit | 4e6859b47e2064b6a9e16f868509336ea64069bd (patch) | |
tree | 21e73735f9d7b1171cf7da8546846e70f22464b7 /slick.grid.js | |
parent | ef9f69c9576a373702fea66202cca1193e5c5f84 (diff) | |
download | SlickGrid-4e6859b47e2064b6a9e16f868509336ea64069bd.zip SlickGrid-4e6859b47e2064b6a9e16f868509336ea64069bd.tar.gz SlickGrid-4e6859b47e2064b6a9e16f868509336ea64069bd.tar.bz2 |
Added CellRangeDecorator and refactored CellRangeSelector to use it.
Added onHeaderClick event.
Added onMouseEnter & onMouseLeave events.
Extracted auto tooltips into a separate plugin - AutoTooltips.
Diffstat (limited to 'slick.grid.js')
-rw-r--r-- | slick.grid.js | 46 |
1 files changed, 18 insertions, 28 deletions
diff --git a/slick.grid.js b/slick.grid.js index 8a5a0af..b49fc79 100644 --- a/slick.grid.js +++ b/slick.grid.js @@ -76,8 +76,6 @@ if (typeof Slick === "undefined") { showSecondaryHeaderRow: false, secondaryHeaderRowHeight: 25, syncColumnCellResize: false, - enableAutoTooltips: true, - toolTipMaxLength: null, formatterFactory: null, editorFactory: null, cellFlashingCssClass: "flashing", @@ -249,11 +247,13 @@ if (typeof Slick === "undefined") { .bind("click.slickgrid", handleClick) .bind("dblclick.slickgrid", handleDblClick) .bind("contextmenu.slickgrid", handleContextMenu) - .bind("mouseover.slickgrid", handleHover) .bind("draginit", handleDragInit) .bind("dragstart", handleDragStart) .bind("drag", handleDrag) .bind("dragend", handleDragEnd); + + $canvas.delegate(".slick-cell", "mouseenter", handleMouseEnter); + $canvas.delegate(".slick-cell", "mouseleave", handleMouseLeave); } function registerPlugin(plugin) { @@ -852,8 +852,7 @@ if (typeof Slick === "undefined") { function setData(newData,scrollToTop) { invalidateAllRows(); - data = newData; - gridData = data; + gridData = newData; if (scrollToTop) scrollTo(0); } @@ -1524,35 +1523,23 @@ if (typeof Slick === "undefined") { } function handleHeaderContextMenu(e) { - var selectedElement = $(e.target).closest(".slick-header-column", ".slick-header-columns"); - self.onHeaderContextMenu.notify(e, { - column: columns[self.getColumnIndex(selectedElement.data("fieldId"))] - }); + var $header = $(e.target).closest(".slick-header-column", ".slick-header-columns"); + var column = $header && columns[self.getColumnIndex($header.data("fieldId"))]; + self.onHeaderContextMenu.notify(e, {column: column}); } function handleHeaderClick(e) { - var $col = $(e.target).closest(".slick-header-column"); - if ($col.length ==0) { return; } - var column = columns[getSiblingIndex($col[0])]; + var $header = $(e.target).closest(".slick-header-column", ".slick-header-columns"); + var column = $header && columns[self.getColumnIndex($header.data("fieldId"))]; + self.onHeaderClick.notify(e, {column: column}); + } - if (self.onHeaderClick && getEditorLock().commitCurrentEdit()) { - e.preventDefault(); - self.onHeaderClick(e, column); - } + function handleMouseEnter(e) { + self.onMouseEnter.notify(e,{}); } - function handleHover(e) { - if (!options.enableAutoTooltips) return; - var $cell = $(e.target).closest(".slick-cell",$canvas); - if ($cell.length) { - if ($cell.innerWidth() < $cell[0].scrollWidth) { - var text = $.trim($cell.text()); - $cell.attr("title", (options.toolTipMaxLength && text.length > options.toolTipMaxLength) ? text.substr(0, options.toolTipMaxLength - 3) + "..." : text); - } - else { - $cell.attr("title",""); - } - } + function handleMouseLeave(e) { + self.onMouseLeave.notify(e,{}); } function cellExists(row,cell) { @@ -2164,6 +2151,9 @@ if (typeof Slick === "undefined") { // Events "onSort": new Slick.Event(), "onHeaderContextMenu": new Slick.Event(), + "onHeaderClick": new Slick.Event(), + "onMouseEnter": new Slick.Event(), + "onMouseLeave": new Slick.Event(), "onClick": new Slick.Event(), "onDblClick": new Slick.Event(), "onContextMenu": new Slick.Event(), |