3 $.extend(true, window, {
5 "CellCopyManager": CellCopyManager
10 function CellCopyManager() {
17 _grid.onKeyDown.subscribe(handleKeyDown);
21 _grid.onKeyDown.unsubscribe(handleKeyDown);
24 function handleKeyDown(e, args) {
26 if (!_grid.getEditorLock().isActive()) {
27 if (e.which == $.ui.keyCode.ESCAPE) {
31 _self.onCopyCancelled.notify({ranges: _copiedRanges});
36 if (e.which == 67 && (e.ctrlKey || e.metaKey)) {
37 ranges = _grid.getSelectionModel().getSelectedRanges();
38 if (ranges.length != 0) {
40 _copiedRanges = ranges;
41 markCopySelection(ranges);
42 _self.onCopyCells.notify({ranges: ranges});
46 if (e.which == 86 && (e.ctrlKey || e.metaKey)) {
50 ranges = _grid.getSelectionModel().getSelectedRanges();
51 _self.onPasteCells.notify({from: _copiedRanges, to: ranges});
58 function markCopySelection(ranges) {
59 var columns = _grid.getColumns();
61 for (var i = 0; i < ranges.length; i++) {
62 for (var j = ranges[i].fromRow; j <= ranges[i].toRow; j++) {
64 for (var k = ranges[i].fromCell; k <= ranges[i].toCell; k++) {
65 hash[j][columns[k].id] = "copied";
69 _grid.setCellCssStyles("copy-manager", hash);
72 function clearCopySelection() {
73 _grid.removeCellCssStyles("copy-manager");
79 "clearCopySelection": clearCopySelection,
81 "onCopyCells": new Slick.Event(),
82 "onCopyCancelled": new Slick.Event(),
83 "onPasteCells": new Slick.Event()