X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=third-party%2Fslickgrid-2.1%2Fplugins%2Fslick.cellrangedecorator.js;fp=third-party%2Fslickgrid-2.1%2Fplugins%2Fslick.cellrangedecorator.js;h=a511a59d6a1bd77f25a5c25a03a1f287ae9ef61d;hb=e3614e2c58f507c272b61cc169400a101277ee1b;hp=0000000000000000000000000000000000000000;hpb=f26eeb7c431cecfbd3ba6cba4d5dab6eeccc2753;p=unfold.git diff --git a/third-party/slickgrid-2.1/plugins/slick.cellrangedecorator.js b/third-party/slickgrid-2.1/plugins/slick.cellrangedecorator.js new file mode 100644 index 00000000..a511a59d --- /dev/null +++ b/third-party/slickgrid-2.1/plugins/slick.cellrangedecorator.js @@ -0,0 +1,64 @@ +(function ($) { + // register namespace + $.extend(true, window, { + "Slick": { + "CellRangeDecorator": CellRangeDecorator + } + }); + + /*** + * Displays an overlay on top of a given cell range. + * + * TODO: + * Currently, it blocks mouse events to DOM nodes behind it. + * Use FF and WebKit-specific "pointer-events" CSS style, or some kind of event forwarding. + * Could also construct the borders separately using 4 individual DIVs. + * + * @param {Grid} grid + * @param {Object} options + */ + function CellRangeDecorator(grid, options) { + var _elem; + var _defaults = { + selectionCss: { + "zIndex": "9999", + "border": "2px dashed red" + } + }; + + options = $.extend(true, {}, _defaults, options); + + + function show(range) { + if (!_elem) { + _elem = $("
", {css: options.selectionCss}) + .css("position", "absolute") + .appendTo(grid.getCanvasNode()); + } + + var from = grid.getCellNodeBox(range.fromRow, range.fromCell); + var to = grid.getCellNodeBox(range.toRow, range.toCell); + + _elem.css({ + top: from.top - 1, + left: from.left - 1, + height: to.bottom - from.top - 2, + width: to.right - from.left - 2 + }); + + return _elem; + } + + function hide() { + if (_elem) { + _elem.remove(); + _elem = null; + } + } + + $.extend(this, { + "show": show, + "hide": hide + }); + } +})(jQuery); \ No newline at end of file