Skip to content

Commit

Permalink
TS: clone grid option
Browse files Browse the repository at this point in the history
fix gridstack#1261
* also fixed karma-typescript to get line number again
  • Loading branch information
adumesny committed Apr 16, 2020
1 parent ab27114 commit 5b7f023
Show file tree
Hide file tree
Showing 4 changed files with 374 additions and 364 deletions.
1 change: 1 addition & 0 deletions doc/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Change log
- fix [1229](https://github.com/gridstack/gridstack.js/issues/1229) `staticGrid` no longer disable oneColumnMode
- fix [1195](https://github.com/gridstack/gridstack.js/issues/1195) options broken with ember hash helper - thanks [@btecu](https://github.com/btecu)
- fix [1250](https://github.com/gridstack/gridstack.js/issues/1250) don't remove item from another grid
- fix [1261](https://github.com/gridstack/gridstack.js/issues/1261) `init()` clones passed options so second doesn't affect first one

## 1.1.1 (2020-03-17)

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
"karma-chrome-launcher": "^3.1.0",
"karma-cli": "^2.0.0",
"karma-jasmine": "^3.1.1",
"karma-typescript": "^5.0.1",
"karma-typescript": "4.1.1",
"node-sass": "^4.13.1",
"puppeteer": "^2.1.1",
"serve-static": "^1.14.1",
Expand Down
30 changes: 13 additions & 17 deletions src/gridstack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export class GridStack {
return null;
}
if (!el.gridstack) {
el.gridstack = new GridStack(el, options);
el.gridstack = new GridStack(el, Utils.clone(options));
}
return el.gridstack
}
Expand Down Expand Up @@ -152,14 +152,11 @@ export class GridStack {
obsoleteAttr(this.el, 'data-gs-height', 'data-gs-max-row', 'v0.5.3');
obsoleteAttr(this.el, 'data-gs-current-height', 'data-gs-current-row', 'v1.0.0');

opts.itemClass = opts.itemClass || 'grid-stack-item';

// if row property exists, replace minRow and maxRow instead
if (opts.row) {
opts.minRow = opts.maxRow = opts.row;
delete opts.row;
}

let rowAttr = Utils.toNumber(el.getAttribute('data-gs-row'));

// elements attributes override any passed options (like CSS style) - merge the two together
Expand All @@ -180,29 +177,28 @@ export class GridStack {
staticGrid: false,
_class: 'grid-stack-instance-' + (Math.random() * 10000).toFixed(0),
animate: Utils.toBool(el.getAttribute('data-gs-animate')) || false,
alwaysShowResizeHandle: opts.alwaysShowResizeHandle || false,
resizable: Utils.defaults(opts.resizable || {}, {
alwaysShowResizeHandle: false,
resizable: {
autoHide: !(opts.alwaysShowResizeHandle || false),
handles: 'se'
}),
draggable: Utils.defaults(opts.draggable || {}, {
handle: (opts.handleClass ? '.' + opts.handleClass : (opts.handle ? opts.handle : '')) ||
'.grid-stack-item-content',
},
draggable: {
handle: (opts.handleClass ? '.' + opts.handleClass : (opts.handle ? opts.handle : '')) || '.grid-stack-item-content',
scroll: false,
appendTo: 'body'
}),
disableDrag: opts.disableDrag || false,
disableResize: opts.disableResize || false,
},
disableDrag: false,
disableResize: false,
rtl: 'auto',
removable: false,
removableOptions: Utils.defaults(opts.removableOptions || {}, {
removableOptions: {
accept: '.' + opts.itemClass
}),
},
removeTimeout: 2000,
verticalMarginUnit: 'px',
cellHeightUnit: 'px',
disableOneColumnMode: opts.disableOneColumnMode || false,
oneColumnModeDomSort: opts.oneColumnModeDomSort
disableOneColumnMode: false,
oneColumnModeDomSort: false
};

this.opts = Utils.defaults(opts, defaults);
Expand Down
Loading

0 comments on commit 5b7f023

Please sign in to comment.