summaryrefslogtreecommitdiffstats
path: root/plugins/slick.cellcopymanager.js
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/slick.cellcopymanager.js')
-rw-r--r--plugins/slick.cellcopymanager.js144
1 files changed, 72 insertions, 72 deletions
diff --git a/plugins/slick.cellcopymanager.js b/plugins/slick.cellcopymanager.js
index 2b283f0..1d9c613 100644
--- a/plugins/slick.cellcopymanager.js
+++ b/plugins/slick.cellcopymanager.js
@@ -1,86 +1,86 @@
-(function($) {
- // register namespace
- $.extend(true, window, {
- "Slick": {
- "CellCopyManager": CellCopyManager
- }
- });
-
-
- function CellCopyManager() {
- var _grid;
- var _self = this;
- var _copiedRanges;
+(function ($) {
+ // register namespace
+ $.extend(true, window, {
+ "Slick":{
+ "CellCopyManager":CellCopyManager
+ }
+ });
- function init(grid) {
- _grid = grid;
- _grid.onKeyDown.subscribe(handleKeyDown);
- }
- function destroy() {
- _grid.onKeyDown.unsubscribe(handleKeyDown);
- }
+ function CellCopyManager() {
+ var _grid;
+ var _self = this;
+ var _copiedRanges;
- function handleKeyDown(e, args) {
- var ranges;
- if (!_grid.getEditorLock().isActive()) {
- if (e.which == $.ui.keyCode.ESCAPE) {
- if (_copiedRanges) {
- e.preventDefault();
- clearCopySelection();
- _self.onCopyCancelled.notify({ranges:_copiedRanges});
- _copiedRanges = null;
- }
- }
+ function init(grid) {
+ _grid = grid;
+ _grid.onKeyDown.subscribe(handleKeyDown);
+ }
- if (e.which == 67 && (e.ctrlKey || e.metaKey)) {
- ranges = _grid.getSelectionModel().getSelectedRanges();
- if (ranges.length != 0) {
- e.preventDefault();
- _copiedRanges = ranges;
- markCopySelection(ranges);
- _self.onCopyCells.notify({ranges:ranges});
- }
- }
+ function destroy() {
+ _grid.onKeyDown.unsubscribe(handleKeyDown);
+ }
- if (e.which == 86 && (e.ctrlKey || e.metaKey)) {
- if (_copiedRanges) {
- e.preventDefault();
- clearCopySelection();
- ranges = _grid.getSelectionModel().getSelectedRanges();
- _self.onPasteCells.notify({from:_copiedRanges, to:ranges});
- _copiedRanges = null;
- }
- }
- }
+ function handleKeyDown(e, args) {
+ var ranges;
+ if (!_grid.getEditorLock().isActive()) {
+ if (e.which == $.ui.keyCode.ESCAPE) {
+ if (_copiedRanges) {
+ e.preventDefault();
+ clearCopySelection();
+ _self.onCopyCancelled.notify({ranges:_copiedRanges});
+ _copiedRanges = null;
+ }
}
- function markCopySelection(ranges) {
- var columns = _grid.getColumns();
- var hash = {};
- for (var i = 0; i < ranges.length; i++) {
- for (var j = ranges[i].fromRow; j <= ranges[i].toRow; j++) {
- hash[j] = {};
- for (var k = ranges[i].fromCell; k <= ranges[i].toCell; k++) {
- hash[j][columns[k].id] = "copied";
- }
- }
- }
- _grid.setCellCssStyles("copy-manager", hash);
+ if (e.which == 67 && (e.ctrlKey || e.metaKey)) {
+ ranges = _grid.getSelectionModel().getSelectedRanges();
+ if (ranges.length != 0) {
+ e.preventDefault();
+ _copiedRanges = ranges;
+ markCopySelection(ranges);
+ _self.onCopyCells.notify({ranges:ranges});
+ }
}
- function clearCopySelection() {
- _grid.removeCellCssStyles("copy-manager");
+ if (e.which == 86 && (e.ctrlKey || e.metaKey)) {
+ if (_copiedRanges) {
+ e.preventDefault();
+ clearCopySelection();
+ ranges = _grid.getSelectionModel().getSelectedRanges();
+ _self.onPasteCells.notify({from:_copiedRanges, to:ranges});
+ _copiedRanges = null;
+ }
}
+ }
+ }
- $.extend(this, {
- "init": init,
- "destroy": destroy,
- "clearCopySelection": clearCopySelection,
+ function markCopySelection(ranges) {
+ var columns = _grid.getColumns();
+ var hash = {};
+ for (var i = 0; i < ranges.length; i++) {
+ for (var j = ranges[i].fromRow; j <= ranges[i].toRow; j++) {
+ hash[j] = {};
+ for (var k = ranges[i].fromCell; k <= ranges[i].toCell; k++) {
+ hash[j][columns[k].id] = "copied";
+ }
+ }
+ }
+ _grid.setCellCssStyles("copy-manager", hash);
+ }
- "onCopyCells": new Slick.Event(),
- "onCopyCancelled": new Slick.Event(),
- "onPasteCells": new Slick.Event()
- });
+ function clearCopySelection() {
+ _grid.removeCellCssStyles("copy-manager");
}
+
+ $.extend(this, {
+ "init":init,
+ "destroy":destroy,
+ "clearCopySelection":clearCopySelection,
+
+ "onCopyCells":new Slick.Event(),
+ "onCopyCancelled":new Slick.Event(),
+ "onPasteCells":new Slick.Event()
+ });
+ }
})(jQuery); \ No newline at end of file