Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ module.exports = {
'indent': ['error', 2],
'max-len': ['error', 180],
'no-trailing-spaces': 'error',
'prefer-const': 0
'prefer-const': 0,
'@typescript-eslint/explicit-function-return-type': 0
}
};
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"dragstop",
"dropover",
"droppable",
"gridster",
"gsresize",
"gsresizestop",
"jqueryui",
Expand Down
7 changes: 5 additions & 2 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,11 @@ module.exports = function(config) {
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
'src/gridstack.js': ['coverage'],
'src/gridstack.jQueryUI.js': ['coverage']
'src/gridstack-dragdrop-plugin.ts': ['coverage'],
'src/gridstack.engine.ts': ['coverage'],
'src/gridstack.ts': ['coverage'],
'src/jqueryui-gridstack-dragdrop-plugin.ts': ['coverage'],
'src/utils.ts': ['coverage']
},


Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"scripts": {
"build": "yarn --no-progress && rm -rf dist/* && webpack && grunt && doctoc ./README.md && doctoc ./doc/README.md && doctoc ./doc/CHANGES.md",
"web": "rm -rf dist/* && webpack",
"test": "yarn lint && karma start karma.conf.js",
"test": "karma start karma.conf.js",
"test2": "yarn lint && karma start karma.conf.js",
"lint": "tsc --noEmit && eslint src/*.ts",
"reset": "rm -rf dist node_modules",
"prepublishOnly": "yarn build"
Expand Down Expand Up @@ -43,7 +44,7 @@
"homepage": "http://gridstack.github.io/gridstack.js/",
"dependencies": {},
"devDependencies": {
"@types/jquery": "^3.3.32",
"@types/jquery": "^3.3.33",
"@types/jqueryui": "^1.12.10",
"@typescript-eslint/eslint-plugin": "^2.23.0",
"@typescript-eslint/parser": "^2.23.0",
Expand Down
44 changes: 22 additions & 22 deletions spec/gridstack-engine-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,28 +24,28 @@ describe('gridstack engine', function() {
});
});

describe('test _prepareNode', function() {
describe('test prepareNode', function() {
var engine;

beforeAll(function() {
engine = new GridStack.Engine(12);
});

it('should prepare a node', function() {
expect(engine._prepareNode({}, false)).toEqual(jasmine.objectContaining({x: 0, y: 0, width: 1, height: 1}));
expect(engine._prepareNode({x: 10}, false)).toEqual(jasmine.objectContaining({x: 10, y: 0, width: 1, height: 1}));
expect(engine._prepareNode({x: -10}, false)).toEqual(jasmine.objectContaining({x: 0, y: 0, width: 1, height: 1}));
expect(engine._prepareNode({y: 10}, false)).toEqual(jasmine.objectContaining({x: 0, y: 10, width: 1, height: 1}));
expect(engine._prepareNode({y: -10}, false)).toEqual(jasmine.objectContaining({x: 0, y: 0, width: 1, height: 1}));
expect(engine._prepareNode({width: 3}, false)).toEqual(jasmine.objectContaining({x: 0, y: 0, width: 3, height: 1}));
expect(engine._prepareNode({width: 100}, false)).toEqual(jasmine.objectContaining({x: 0, y: 0, width: 12, height: 1}));
expect(engine._prepareNode({width: 0}, false)).toEqual(jasmine.objectContaining({x: 0, y: 0, width: 1, height: 1}));
expect(engine._prepareNode({width: -190}, false)).toEqual(jasmine.objectContaining({x: 0, y: 0, width: 1, height: 1}));
expect(engine._prepareNode({height: 3}, false)).toEqual(jasmine.objectContaining({x: 0, y: 0, width: 1, height: 3}));
expect(engine._prepareNode({height: 0}, false)).toEqual(jasmine.objectContaining({x: 0, y: 0, width: 1, height: 1}));
expect(engine._prepareNode({height: -10}, false)).toEqual(jasmine.objectContaining({x: 0, y: 0, width: 1, height: 1}));
expect(engine._prepareNode({x: 4, width: 10}, false)).toEqual(jasmine.objectContaining({x: 2, y: 0, width: 10, height: 1}));
expect(engine._prepareNode({x: 4, width: 10}, true)).toEqual(jasmine.objectContaining({x: 4, y: 0, width: 8, height: 1}));
expect(engine.prepareNode({}, false)).toEqual(jasmine.objectContaining({x: 0, y: 0, width: 1, height: 1}));
expect(engine.prepareNode({x: 10}, false)).toEqual(jasmine.objectContaining({x: 10, y: 0, width: 1, height: 1}));
expect(engine.prepareNode({x: -10}, false)).toEqual(jasmine.objectContaining({x: 0, y: 0, width: 1, height: 1}));
expect(engine.prepareNode({y: 10}, false)).toEqual(jasmine.objectContaining({x: 0, y: 10, width: 1, height: 1}));
expect(engine.prepareNode({y: -10}, false)).toEqual(jasmine.objectContaining({x: 0, y: 0, width: 1, height: 1}));
expect(engine.prepareNode({width: 3}, false)).toEqual(jasmine.objectContaining({x: 0, y: 0, width: 3, height: 1}));
expect(engine.prepareNode({width: 100}, false)).toEqual(jasmine.objectContaining({x: 0, y: 0, width: 12, height: 1}));
expect(engine.prepareNode({width: 0}, false)).toEqual(jasmine.objectContaining({x: 0, y: 0, width: 1, height: 1}));
expect(engine.prepareNode({width: -190}, false)).toEqual(jasmine.objectContaining({x: 0, y: 0, width: 1, height: 1}));
expect(engine.prepareNode({height: 3}, false)).toEqual(jasmine.objectContaining({x: 0, y: 0, width: 1, height: 3}));
expect(engine.prepareNode({height: 0}, false)).toEqual(jasmine.objectContaining({x: 0, y: 0, width: 1, height: 1}));
expect(engine.prepareNode({height: -10}, false)).toEqual(jasmine.objectContaining({x: 0, y: 0, width: 1, height: 1}));
expect(engine.prepareNode({x: 4, width: 10}, false)).toEqual(jasmine.objectContaining({x: 2, y: 0, width: 10, height: 1}));
expect(engine.prepareNode({x: 4, width: 10}, true)).toEqual(jasmine.objectContaining({x: 4, y: 0, width: 8, height: 1}));
});
});

Expand All @@ -55,7 +55,7 @@ describe('gridstack engine', function() {
beforeAll(function() {
engine = new GridStack.Engine(12, null, true);
engine.nodes = [
engine._prepareNode({x: 3, y: 2, width: 3, height: 2})
engine.prepareNode({x: 3, y: 2, width: 3, height: 2})
];
});

Expand All @@ -76,9 +76,9 @@ describe('gridstack engine', function() {
beforeAll(function() {
engine = new GridStack.Engine(12, null, true);
engine.nodes = [
engine._prepareNode({x: 0, y: 0, width: 1, height: 1, idx: 1, _dirty: true}),
engine._prepareNode({x: 3, y: 2, width: 3, height: 2, idx: 2, _dirty: true}),
engine._prepareNode({x: 3, y: 7, width: 3, height: 2, idx: 3})
engine.prepareNode({x: 0, y: 0, width: 1, height: 1, idx: 1, _dirty: true}),
engine.prepareNode({x: 3, y: 2, width: 3, height: 2, idx: 2, _dirty: true}),
engine.prepareNode({x: 3, y: 7, width: 3, height: 2, idx: 3})
];
});

Expand Down Expand Up @@ -167,9 +167,9 @@ describe('gridstack engine', function() {
engine = new GridStack.Engine(12, spy.callback, true);

engine.nodes = [
engine._prepareNode({x: 0, y: 0, width: 1, height: 1, idx: 1, _dirty: true}),
engine._prepareNode({x: 3, y: 2, width: 3, height: 2, idx: 2, _dirty: true}),
engine._prepareNode({x: 3, y: 7, width: 3, height: 2, idx: 3})
engine.prepareNode({x: 0, y: 0, width: 1, height: 1, idx: 1, _dirty: true}),
engine.prepareNode({x: 3, y: 2, width: 3, height: 2, idx: 2, _dirty: true}),
engine.prepareNode({x: 3, y: 7, width: 3, height: 2, idx: 3})
];
});

Expand Down
8 changes: 5 additions & 3 deletions src/gridstack-dragdrop-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
* (c) 2014-2020 Alain Dumesny, Dylan Weiss, Pavel Reznikov
* gridstack.js may be freely distributed under the MIT license.
*/
/* eslint-disable @typescript-eslint/no-unused-vars */

import { GridStack } from './gridstack';
import { GridItemHTMLElement } from './types';

/** drag&drop options currently called from the main code, but others can be passed in grid options */
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export type DDOpts = 'enable' | 'disable' | 'destroy' | 'option' | {} | any;
export type DDKey = 'minWidth' | 'minHeight' | string;

Expand All @@ -18,9 +20,9 @@ export type DDKey = 'minWidth' | 'minHeight' | string;
*/
export class GridStackDragDropPlugin {
protected grid: GridStack;
static registeredPlugins = [];
static registerPlugin(pluginClass) {
static registeredPlugins: typeof GridStackDragDropPlugin[] = [];

static registerPlugin(pluginClass: typeof GridStackDragDropPlugin) {
GridStackDragDropPlugin.registeredPlugins.push(pluginClass);
}

Expand Down
Loading