From 96e4fb792d72e3f7df04654f3f9b834c8785dff8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Inga=20Br=C5=ABnava?= Date: Wed, 10 Feb 2016 21:01:36 +0100 Subject: [PATCH 01/35] Added refresh_nodes --- src/gridstack.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/gridstack.js b/src/gridstack.js index c5ff56570..36ae029a7 100644 --- a/src/gridstack.js +++ b/src/gridstack.js @@ -976,6 +976,14 @@ } }; + GridStack.prototype.refresh_nodes = function() { + var that = this; + this.remove_all(false); + this.container.find('.' + this.opts.item_class).each(function(k, node){ + that._prepare_element(node); + }); + }; + scope.GridStackUI = GridStack; scope.GridStackUI.Utils = Utils; From dee18f2e2a77d4b5bab73ca78e670a9980f8fbd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Inga=20Br=C5=ABnava?= Date: Thu, 11 Feb 2016 12:15:18 +0100 Subject: [PATCH 02/35] Added where_will_be_placed --- src/gridstack.js | 51 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/src/gridstack.js b/src/gridstack.js index 36ae029a7..0f7284cd4 100644 --- a/src/gridstack.js +++ b/src/gridstack.js @@ -984,6 +984,57 @@ }); }; + GridStack.prototype.where_will_be_placed = function(node) { + var offset = this.container.offset(), + position = this.container.position(), + nodeOffset = node.offset(); + + // offset relative to gridstack container itself + nodeOffset = { + left: nodeOffset.left - offset.left + position.left, + top: nodeOffset.top - offset.top + position.top + }; + + var cell = this.get_cell_from_pixel(nodeOffset); + + // if size defined on node, use that + var size = { + width: node.attr('data-width') || 1, + height: node.attr('data-height') || 1 + }; + + var isInsideGrid = cell.x >= 0 && cell.x < this.opts.width && cell.y >= 0 && cell.y < this.opts.height; + var isAreaEmpty = this.is_area_empty(cell.x, cell.y, size.width, size.height); + + if (!isInsideGrid) { + return false; + } + + if (!isAreaEmpty) { + // try with 1:1 size if this doesn't fit + if (size.width > 1 || size.height > 1) { + size = { + width: 1, + height: 1 + }; + isAreaEmpty = this.is_area_empty(cell.x, cell.y, size.width, size.height); + + if (!isAreaEmpty) { + return false; + } + } else { + return false; + } + } + + return { + x: cell.x, + y: cell.y, + width: size.width, + height: size.height + }; + }; + scope.GridStackUI = GridStack; scope.GridStackUI.Utils = Utils; From c8bfc3f348079358cc3f4a82558a90a730164109 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Inga=20Br=C5=ABnava?= Date: Thu, 11 Feb 2016 17:37:38 +0100 Subject: [PATCH 03/35] Don't trigger one-column when under 768px --- src/gridstack.css | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gridstack.css b/src/gridstack.css index 319d58a75..7f1baccc7 100644 --- a/src/gridstack.css +++ b/src/gridstack.css @@ -301,7 +301,7 @@ -o-transform: rotate(180deg); transform: rotate(180deg); } -*/ + @media (max-width: 768px) { .grid-stack-item { position: relative !important; @@ -318,3 +318,4 @@ height: auto !important; } } +*/ From 8a3cfabd245e1af9cdb325ed89675bc9326d93c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Inga=20Br=C5=ABnava?= Date: Fri, 12 Feb 2016 11:31:53 +0100 Subject: [PATCH 04/35] Fix initial container size with set height when no items present --- src/gridstack.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/gridstack.js b/src/gridstack.js index 0f7284cd4..20ce70698 100644 --- a/src/gridstack.js +++ b/src/gridstack.js @@ -472,9 +472,11 @@ '
' + '
').hide(); - this.container.height( - this.grid.get_grid_height() * (this.opts.cell_height + this.opts.vertical_margin) - - this.opts.vertical_margin); + var gridHeight = this.grid.get_grid_height(); + if (!gridHeight) { + gridHeight = this.opts.height; + } + this.container.height(gridHeight * (this.opts.cell_height + this.opts.vertical_margin) - this.opts.vertical_margin); this.on_resize_handler = function() { if (self._is_one_column_mode()) { From 93ec295d3f8065e78130a9f84405399ae6b3d044 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Inga=20Br=C5=ABnava?= Date: Fri, 12 Feb 2016 20:36:48 +0100 Subject: [PATCH 05/35] Fix height on empty set-column float grid --- src/gridstack.js | 86 +++++++++++++++++++++++++----------------------- 1 file changed, 44 insertions(+), 42 deletions(-) diff --git a/src/gridstack.js b/src/gridstack.js index 20ce70698..8f9bce3c8 100644 --- a/src/gridstack.js +++ b/src/gridstack.js @@ -472,11 +472,7 @@ '
' + '
').hide(); - var gridHeight = this.grid.get_grid_height(); - if (!gridHeight) { - gridHeight = this.opts.height; - } - this.container.height(gridHeight * (this.opts.cell_height + this.opts.vertical_margin) - this.opts.vertical_margin); + this.container.height(this._calculate_container_height()); this.on_resize_handler = function() { if (self._is_one_column_mode()) { @@ -594,13 +590,19 @@ } }; + GridStack.prototype._calculate_container_height = function() { + var gridHeight = this.grid.get_grid_height(); + if (!gridHeight) { + gridHeight = this.opts.height; + } + return gridHeight * (this.opts.cell_height + this.opts.vertical_margin) - this.opts.vertical_margin; + }; + GridStack.prototype._update_container_height = function() { if (this.grid._update_counter) { return; } - this.container.height( - this.grid.get_grid_height() * (this.opts.cell_height + this.opts.vertical_margin) - - this.opts.vertical_margin); + this.container.height(this._calculate_container_height()); }; GridStack.prototype._is_one_column_mode = function() { @@ -840,39 +842,39 @@ return this; }; - GridStack.prototype.min_height = function (el, val) { - el = $(el); - el.each(function (index, el) { - el = $(el); - var node = el.data('_gridstack_node'); - if (typeof node == 'undefined' || node == null) { - return; - } - - if(!isNaN(val)){ - node.min_height = (val || false); - el.attr('data-gs-min-height', val); - } - }); - return this; - }; - - GridStack.prototype.min_width = function (el, val) { - el = $(el); - el.each(function (index, el) { - el = $(el); - var node = el.data('_gridstack_node'); - if (typeof node == 'undefined' || node == null) { - return; - } - - if(!isNaN(val)){ - node.min_width = (val || false); - el.attr('data-gs-min-width', val); - } - }); - return this; - }; + GridStack.prototype.min_height = function (el, val) { + el = $(el); + el.each(function (index, el) { + el = $(el); + var node = el.data('_gridstack_node'); + if (typeof node == 'undefined' || node == null) { + return; + } + + if(!isNaN(val)){ + node.min_height = (val || false); + el.attr('data-gs-min-height', val); + } + }); + return this; + }; + + GridStack.prototype.min_width = function (el, val) { + el = $(el); + el.each(function (index, el) { + el = $(el); + var node = el.data('_gridstack_node'); + if (typeof node == 'undefined' || node == null) { + return; + } + + if(!isNaN(val)){ + node.min_width = (val || false); + el.attr('data-gs-min-width', val); + } + }); + return this; + }; GridStack.prototype._update_element = function(el, callback) { el = $(el).first(); @@ -931,7 +933,7 @@ if (val == this.opts.cell_height) return; this.opts.cell_height = val || this.opts.cell_height; - this._update_styles(); + this._update_styles(this.opts.height); }; GridStack.prototype.cell_width = function() { From 4f74f0d5793cb1346562ca0d086a803e699e0a86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Inga=20Br=C5=ABnava?= Date: Tue, 16 Feb 2016 07:29:48 +0100 Subject: [PATCH 06/35] Fixes & updates --- src/gridstack.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/gridstack.js b/src/gridstack.js index 7b6917dd1..6f0b4cf1d 100644 --- a/src/gridstack.js +++ b/src/gridstack.js @@ -449,7 +449,7 @@ max_height = Math.max(max_height, n.y + n.height); } }); - self._update_styles(max_height + 10); + self._update_styles(self.opts.height || (max_height + 10)); }, this.opts.float, this.opts.height); if (this.opts.auto) { @@ -475,6 +475,9 @@ this.container.height(this._calculate_container_height()); + // setting styles also for empty grids + this._update_styles(); + this.on_resize_handler = function() { if (self._is_one_column_mode()) { if (one_column_mode) @@ -555,7 +558,7 @@ var prefix = '.' + this.opts._class + ' .' + this.opts.item_class; if (typeof max_height == 'undefined') { - max_height = this._styles._max; + max_height = this._styles._max || this.opts.height; this._init_styles(); this._update_container_height(); } @@ -800,7 +803,7 @@ el.each(function(index, el) { el = $(el); var node = el.data('_gridstack_node'); - if (typeof node == 'undefined' || node == null) { + if (typeof node == 'undefined' || node == null || self.opts.static_grid) { return; } @@ -821,7 +824,7 @@ el.each(function(index, el) { el = $(el); var node = el.data('_gridstack_node'); - if (typeof node == 'undefined' || node == null) { + if (typeof node == 'undefined' || node == null || self.opts.static_grid) { return; } @@ -956,7 +959,7 @@ if (val == this.opts.cell_height) return; this.opts.cell_height = val || this.opts.cell_height; - this._update_styles(this.opts.height); + this._update_styles(); }; GridStack.prototype.cell_width = function() { @@ -1007,7 +1010,8 @@ var that = this; this.remove_all(false); this.container.find('.' + this.opts.item_class).each(function(k, node){ - that._prepare_element(node); + $(node).off('dragstart dragstop drag resizestart resizestop resize'); + that.make_widget(node); }); }; From 0537e97121ad1d20db0b5deadb70ae8838c884d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Inga=20Br=C5=ABnava?= Date: Tue, 16 Feb 2016 14:38:11 +0100 Subject: [PATCH 07/35] Simplify. --- src/gridstack.js | 59 +++++++++++------------------------------------- 1 file changed, 13 insertions(+), 46 deletions(-) diff --git a/src/gridstack.js b/src/gridstack.js index 6f0b4cf1d..c857bd0d1 100644 --- a/src/gridstack.js +++ b/src/gridstack.js @@ -115,11 +115,16 @@ } }; - GridStackEngine.prototype.is_area_empty = function(x, y, width, height) { + GridStackEngine.prototype.what_is_here = function(x, y, width, height) { var nn = {x: x || 0, y: y || 0, width: width || 1, height: height || 1}; var collision_node = _.find(this.nodes, _.bind(function(n) { return Utils.is_intercepted(n, nn); }, this)); + return collision_node; + }; + + GridStackEngine.prototype.is_area_empty = function(x, y, width, height) { + var collision_node = this.what_is_here(x, y, width, height); return collision_node == null; }; @@ -277,6 +282,9 @@ }; GridStackEngine.prototype.remove_node = function(node) { + if (!node) { + return; + } node._id = null; this.nodes = _.without(this.nodes, node); this._pack_nodes(); @@ -747,10 +755,7 @@ if (typeof height != 'undefined') el.attr('data-gs-height', height); if (typeof auto_position != 'undefined') el.attr('data-gs-auto-position', auto_position ? 'yes' : null); this.container.append(el); - this._prepare_element(el); - this._update_container_height(); - this._trigger_change_event(true); - + this.make_widget(el); return el; }; @@ -1015,10 +1020,9 @@ }); }; - GridStack.prototype.where_will_be_placed = function(node) { + GridStack.prototype.get_cell_from_absolute_pixel = function(nodeOffset) { var offset = this.container.offset(), - position = this.container.position(), - nodeOffset = node.offset(); + position = this.container.position(); // offset relative to gridstack container itself nodeOffset = { @@ -1026,44 +1030,7 @@ top: nodeOffset.top - offset.top + position.top }; - var cell = this.get_cell_from_pixel(nodeOffset); - - // if size defined on node, use that - var size = { - width: node.attr('data-width') || 1, - height: node.attr('data-height') || 1 - }; - - var isInsideGrid = cell.x >= 0 && cell.x < this.opts.width && cell.y >= 0 && cell.y < this.opts.height; - var isAreaEmpty = this.is_area_empty(cell.x, cell.y, size.width, size.height); - - if (!isInsideGrid) { - return false; - } - - if (!isAreaEmpty) { - // try with 1:1 size if this doesn't fit - if (size.width > 1 || size.height > 1) { - size = { - width: 1, - height: 1 - }; - isAreaEmpty = this.is_area_empty(cell.x, cell.y, size.width, size.height); - - if (!isAreaEmpty) { - return false; - } - } else { - return false; - } - } - - return { - x: cell.x, - y: cell.y, - width: size.width, - height: size.height - }; + return this.get_cell_from_pixel(nodeOffset); }; scope.GridStackUI = GridStack; From 2f9f3e29676bbd2900313160b2707ca0fa98dd41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Inga=20Br=C5=ABnava?= Date: Wed, 17 Feb 2016 07:01:48 +0100 Subject: [PATCH 08/35] Don't trigger dragstart function if it's not on the specified drag handle --- src/gridstack.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/gridstack.js b/src/gridstack.js index c857bd0d1..61c893f8a 100644 --- a/src/gridstack.js +++ b/src/gridstack.js @@ -668,6 +668,12 @@ }; var on_start_moving = function(event, ui) { + if (self.opts.draggable.handle && event.type === 'dragstart') { + // if handle specified, don't allow drag from anywhere else + if (!$(event.originalEvent.target).closest(self.opts.draggable.handle).length) { + return false; + } + } self.container.append(self.placeholder); var o = $(this); self.grid.clean_nodes(); From 05805ebc76a540112af129d9bea04354fa647d61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Inga=20Br=C5=ABnava?= Date: Thu, 24 Nov 2016 10:02:46 +0100 Subject: [PATCH 09/35] Revert "Merge remote-tracking branch 'troolee/master'" This reverts commit 6c886e893c987bb31a9c9c455d42b0b3035486bc, reversing changes made to 2f9f3e29676bbd2900313160b2707ca0fa98dd41. --- .bithoundrc | 15 - .gitignore | 3 - .jscsrc | 19 - .travis.yml | 31 - Gruntfile.js | 90 +- LICENSE | 3 +- README.md | 524 ++++--- bower.json | 8 +- demo/anijs.html | 89 -- demo/float.html | 19 +- demo/index.html | 20 - demo/knockout.html | 28 +- demo/knockout2.html | 28 +- demo/nested.html | 12 +- demo/responsive.html | 122 -- demo/rtl.html | 121 -- demo/serialization.html | 44 +- demo/two.html | 79 +- dist/gridstack.all.js | 41 - dist/gridstack.css | 81 +- dist/gridstack.jQueryUI.js | 97 -- dist/gridstack.jQueryUI.min.js | 13 - dist/gridstack.js | 1619 ++++++---------------- dist/gridstack.min.css | 2 +- dist/gridstack.min.js | 30 +- dist/gridstack.min.map | 2 +- doc/FAQ.md | 51 - doc/README.md | 474 ------- karma.conf.js | 81 -- package.json | 34 +- protractor.conf.js | 12 - spec/e2e/gridstack-spec.js | 24 - spec/e2e/html/gridstack-with-height.html | 73 - spec/gridstack-engine-spec.js | 311 ----- spec/gridstack-spec.js | 1269 ----------------- spec/utils-spec.js | 109 -- src/gridstack.jQueryUI.js | 97 -- src/gridstack.js | 1591 ++++++--------------- src/gridstack.scss | 71 +- 39 files changed, 1423 insertions(+), 5914 deletions(-) delete mode 100644 .bithoundrc delete mode 100644 .jscsrc delete mode 100644 .travis.yml mode change 100644 => 100755 Gruntfile.js delete mode 100644 demo/anijs.html delete mode 100644 demo/index.html delete mode 100644 demo/responsive.html delete mode 100644 demo/rtl.html delete mode 100644 dist/gridstack.all.js delete mode 100644 dist/gridstack.jQueryUI.js delete mode 100644 dist/gridstack.jQueryUI.min.js mode change 100644 => 100755 dist/gridstack.js delete mode 100644 doc/FAQ.md delete mode 100644 doc/README.md delete mode 100644 karma.conf.js mode change 100644 => 100755 package.json delete mode 100644 protractor.conf.js delete mode 100644 spec/e2e/gridstack-spec.js delete mode 100644 spec/e2e/html/gridstack-with-height.html delete mode 100644 spec/gridstack-engine-spec.js delete mode 100644 spec/gridstack-spec.js delete mode 100644 spec/utils-spec.js delete mode 100644 src/gridstack.jQueryUI.js diff --git a/.bithoundrc b/.bithoundrc deleted file mode 100644 index ba1b6655d..000000000 --- a/.bithoundrc +++ /dev/null @@ -1,15 +0,0 @@ -{ - "ignore": [ - "dist/**", - "**/node_modules/**", - "**/bower_components/**", - "**/demo/**", - "**/coverage/**" - ], - "test": [ - "**/spec/**" - ], - "critics": { - "lint": "jshint" - } -} \ No newline at end of file diff --git a/.gitignore b/.gitignore index 95ec03ef6..3c3629e64 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1 @@ node_modules -bower_components -coverage -*.log diff --git a/.jscsrc b/.jscsrc deleted file mode 100644 index 78a426e4c..000000000 --- a/.jscsrc +++ /dev/null @@ -1,19 +0,0 @@ -{ - "preset": "node-style-guide", - "validateIndentation": 4, - "maximumLineLength": 120, - "jsDoc": { - "checkAnnotations": { - "preset": "jsdoc3", - "extra": { - "preserve": true - } - } - }, - "requireCamelCaseOrUpperCaseIdentifiers": true, - "validateLineBreaks": false, - "requireTrailingComma": false, - "disallowTrailingWhitespace": true, - "requireCapitalizedComments": false, - "excludeFiles": ["dist/*.js", "demo/*", "spec/*"] -} diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index f8cde4730..000000000 --- a/.travis.yml +++ /dev/null @@ -1,31 +0,0 @@ -language: node_js -node_js: -- 5.7.0 -env: -- CXX=g++-4.8 -addons: - apt: - sources: - - ubuntu-toolchain-r-test - packages: - - g++-4.8 -before_install: -- npm install -g protractor -install: -- npm install -g npm@2 -- npm install -g grunt-cli -- npm install -g bower -- bower install -- npm install -- ./node_modules/protractor/bin/webdriver-manager update --standalone -before_script: -- export CHROME_BIN=chromium-browser -- export DISPLAY=:99.0 -- sh -e /etc/init.d/xvfb start -script: -- npm run build -- npm test -- grunt e2e-test -notifications: - slack: - secure: iGLGsYyVIyKVpVVCskGh/zc6Pkqe0D7jpUtbywSbnq6l5seE6bvBVqm0F2FSCIN+AIC+qal2mPEWysDVsLACm5tTEeA8NfL8dmCrAKbiFbi+gHl4mnHHCHl7ii/7UkoIIXNc5UXbgMSXRS5l8UcsSDlN8VxC5zWstbJvjeYIvbA= diff --git a/Gruntfile.js b/Gruntfile.js old mode 100644 new mode 100755 index 77f58d42e..f9cc45288 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1,16 +1,9 @@ -// jscs:disable requireCamelCaseOrUpperCaseIdentifiers -module.exports = function(grunt) { +module.exports = function (grunt) { grunt.loadNpmTasks('grunt-sass'); grunt.loadNpmTasks('grunt-contrib-cssmin'); grunt.loadNpmTasks('grunt-contrib-copy'); grunt.loadNpmTasks('grunt-contrib-uglify'); grunt.loadNpmTasks('grunt-doctoc'); - grunt.loadNpmTasks('grunt-contrib-jshint'); - grunt.loadNpmTasks('grunt-jscs'); - grunt.loadNpmTasks('grunt-contrib-watch'); - grunt.loadNpmTasks('grunt-protractor-runner'); - grunt.loadNpmTasks('grunt-contrib-connect'); - grunt.loadNpmTasks('grunt-protractor-webdriver'); grunt.initConfig({ sass: { @@ -37,8 +30,7 @@ module.exports = function(grunt) { copy: { dist: { files: { - 'dist/gridstack.js': ['src/gridstack.js'], - 'dist/gridstack.jQueryUI.js': ['src/gridstack.jQueryUI.js'], + 'dist/gridstack.js': ['src/gridstack.js'] } } }, @@ -46,14 +38,11 @@ module.exports = function(grunt) { uglify: { options: { sourceMap: true, - sourceMapName: 'dist/gridstack.min.map', - preserveComments: 'some' + sourceMapName: 'dist/gridstack.min.map' }, dist: { files: { - 'dist/gridstack.min.js': ['src/gridstack.js'], - 'dist/gridstack.jQueryUI.min.js': ['src/gridstack.jQueryUI.js'], - 'dist/gridstack.all.js': ['src/gridstack.js', 'src/gridstack.jQueryUI.js'] + 'dist/gridstack.min.js': ['src/gridstack.js'] } } }, @@ -63,77 +52,10 @@ module.exports = function(grunt) { removeAd: false }, readme: { - options: { - target: './README.md' - } - }, - doc: { - options: { - target: './doc/README.md' - } - }, - faq: { - options: { - target: './doc/FAQ.md' - } - }, - }, - - jshint: { - all: ['src/*.js'] - }, - - jscs: { - all: ['*.js', 'src/*.js', ], - }, - - watch: { - scripts: { - files: ['src/*.js'], - tasks: ['uglify', 'copy'], - options: { - }, - }, - styles: { - files: ['src/*.scss'], - tasks: ['sass', 'cssmin'], - options: { - }, - }, - docs: { - files: ['README.md', 'doc/README.md', 'doc/FAQ.md'], - tasks: ['doctoc'], - options: { - }, - }, - }, - - protractor: { - options: { - configFile: 'protractor.conf.js', - }, - all: {} - }, - - connect: { - all: { - options: { - port: 8080, - hostname: 'localhost', - base: '.', - }, - }, - }, - - protractor_webdriver: { - all: { - options: { - command: 'webdriver-manager start', - } + target: "./README.md" } } }); - grunt.registerTask('default', ['sass', 'cssmin', 'jshint', 'jscs', 'copy', 'uglify', 'doctoc']); - grunt.registerTask('e2e-test', ['connect', 'protractor_webdriver', 'protractor']); + grunt.registerTask('default', ['sass', 'cssmin', 'copy', 'uglify', 'doctoc']); }; diff --git a/LICENSE b/LICENSE index f337ebad1..bf1cc110e 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2014-2016 Pavel Reznikov, Dylan Weiss +Copyright (c) 2014-2016 Pavel Reznikov Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -19,3 +19,4 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + diff --git a/README.md b/README.md index bd409d011..cb3ec4dac 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,11 @@ gridstack.js ============ -[![Build Status](https://travis-ci.org/troolee/gridstack.js.svg?branch=master)](https://travis-ci.org/troolee/gridstack.js) -[![Coverage Status](https://coveralls.io/repos/github/troolee/gridstack.js/badge.svg?branch=master)](https://coveralls.io/github/troolee/gridstack.js?branch=master) -[![Dependency Status](https://david-dm.org/troolee/gridstack.js.svg)](https://david-dm.org/troolee/gridstack.js) -[![devDependency Status](https://david-dm.org/troolee/gridstack.js/dev-status.svg)](https://david-dm.org/troolee/gridstack.js#info=devDependencies) -[![Stories in Ready](https://badge.waffle.io/troolee/gridstack.js.png?label=ready&title=Ready)](http://waffle.io/troolee/gridstack.js) - gridstack.js is a jQuery plugin for widget layout. This is drag-and-drop multi-column grid. It allows you to build -draggable responsive bootstrap v3 friendly layouts. It also works great with [knockout.js](http://knockoutjs.com), [angular.js](https://angularjs.org) and touch devices. +draggable responsive bootstrap v3 friendly layouts. It also works great with [knockout.js](http://knockoutjs.com) and +touch devices. -Inspired by [gridster.js](https://github.com/ducksboard/gridster.js). Built with love. +Inspired by [gridster.js](http://gridster.net). Built with love. Join gridstack.js on Slack: https://gridstackjs.troolee.com @@ -23,13 +18,45 @@ Join gridstack.js on Slack: https://gridstackjs.troolee.com - [Demo](#demo) - [Usage](#usage) - [Requirements](#requirements) - - [Using gridstack.js with jQuery UI](#using-gridstackjs-with-jquery-ui) - - [Install](#install) - [Basic usage](#basic-usage) - - [Migrating to v0.3.0](#migrating-to-v030) - - [Migrating to v0.2.5](#migrating-to-v025) - - [API Documentation](#api-documentation) - - [Questions and Answers](#questions-and-answers) + - [Options](#options) + - [Grid attributes](#grid-attributes) + - [Item attributes](#item-attributes) + - [Events](#events) + - [onchange(items)](#onchangeitems) + - [ondragstart(event, ui)](#ondragstartevent-ui) + - [ondragstop(event, ui)](#ondragstopevent-ui) + - [onresizestart(event, ui)](#onresizestartevent-ui) + - [onresizestop(event, ui)](#onresizestopevent-ui) + - [disable(event)](#disableevent) + - [enable(event)](#enableevent) + - [API](#api) + - [add_widget(el, x, y, width, height, auto_position)](#add_widgetel-x-y-width-height-auto_position) + - [make_widget(el)](#make_widgetel) + - [batch_update()](#batch_update) + - [cell_height()](#cell_height) + - [cell_height(val)](#cell_heightval) + - [cell_width()](#cell_width) + - [commit()](#commit) + - [destroy()](#destroy) + - [disable()](#disable) + - [enable()](#enable) + - [get_cell_from_pixel(position)](#get_cell_from_pixelposition) + - [is_area_empty(x, y, width, height)](#is_area_emptyx-y-width-height) + - [locked(el, val)](#lockedel-val) + - [min_width(el, val)](#min_widthel-val) + - [min_height(el, val)](#min_heightel-val) + - [movable(el, val)](#movableel-val) + - [move(el, x, y)](#moveel-x-y) + - [remove_widget(el, detach_node)](#remove_widgetel-detach_node) + - [remove_all()](#remove_all) + - [resize(el, width, height)](#resizeel-width-height) + - [resizable(el, val)](#resizableel-val) + - [set_static(static_value)](#set_staticstatic_value) + - [update(el, x, y, width, height)](#updateel-x-y-width-height) + - [will_it_fit(x, y, width, height, auto_position)](#will_it_fitx-y-width-height-auto_position) + - [Utils](#utils) + - [GridStackUI.Utils.sort(nodes[, dir[, width]])](#gridstackuiutilssortnodes-dir-width) - [Touch devices support](#touch-devices-support) - [Use with knockout.js](#use-with-knockoutjs) - [Use with angular.js](#use-with-angularjs) @@ -41,16 +68,9 @@ Join gridstack.js on Slack: https://gridstackjs.troolee.com - [Load grid from array](#load-grid-from-array) - [Override resizable/draggable options](#override-resizabledraggable-options) - [IE8 support](#ie8-support) - - [Use with require.js](#use-with-requirejs) - [Nested grids](#nested-grids) - - [Resizing active grid](#resizing-active-grid) - - [Using AniJS](#using-anijs) -- [The Team](#the-team) - [Changes](#changes) - - [v0.3.0-dev (Development Version)](#v030-dev-development-version) - - [v0.2.6 (2016-08-17)](#v026-2016-08-17) - - [v0.2.5 (2016-03-02)](#v025-2016-03-02) - - [v0.2.4 (2016-02-15)](#v024-2016-02-15) + - [v0.2.4 (development version)](#v024-development-version) - [v0.2.3 (2015-06-23)](#v023-2015-06-23) - [v0.2.2 (2014-12-23)](#v022-2014-12-23) - [v0.2.1 (2014-12-09)](#v021-2014-12-09) @@ -64,7 +84,7 @@ Join gridstack.js on Slack: https://gridstackjs.troolee.com Demo ==== -Please visit http://troolee.github.io/gridstack.js/ for demo. Or check out [these example](http://troolee.github.io/gridstack.js/demo/). +Please visit http://troolee.github.io/gridstack.js/ for demo. Usage @@ -72,46 +92,13 @@ Usage ## Requirements -* [lodash.js](https://lodash.com) (>= 3.5.0, full build) -* [jQuery](http://jquery.com) (>= 3.1.0) - -Note: You can still use [underscore.js](http://underscorejs.org) (>= 1.7.0) instead of lodash.js - -#### Using gridstack.js with jQuery UI - -* [jQuery UI](http://jqueryui.com) (>= 1.12.0). Minimum required components: Core, Widget, Mouse, Draggable, Resizable +* [lodash.js](https://lodash.com) (>= 3.5.0) +* [jQuery](http://jquery.com) (>= 1.11.0) +* [jQuery UI](http://jqueryui.com) (>= 1.11.0). Minimum required components: Core, Widget, Mouse, Draggable, Resizable +* (Optional) [knockout.js](http://knockoutjs.com) (>= 3.2.0) * (Optional) [jquery-ui-touch-punch](https://github.com/furf/jquery-ui-touch-punch) for touch-based devices support -## Install - -```html - - - -``` - -* Using CDN: - -```html - - -``` - -* Using bower: - -```bash -$ bower install gridstack -``` - -* Using npm: - -[![NPM version](https://img.shields.io/npm/v/gridstack.svg)](https://www.npmjs.com/package/gridstack) - -```bash -$ npm install gridstack -``` - -You can download files from `dist` directory as well. +Note: You can still use [underscore.js](http://underscorejs.org) (>= 1.7.0) instead of lodash.js ## Basic usage @@ -132,49 +119,329 @@ You can download files from `dist` directory as well. ``` -## Migrating to v0.3.0 +## Options + +- `always_show_resize_handle` - if `true` the resizing handles are shown even if the user is not hovering over the widget + (default: `false`) +- `animate` - turns animation on (default: `false`) +- `auto` - if `false` gridstack will not initialize existing items (default: `true`) +- `cell_height` - one cell height (default: `60`) +- `draggable` - allows to override jQuery UI draggable options. (default: `{handle: '.grid-stack-item-content', scroll: true, appendTo: 'body'}`) +- `handle` - draggable handle selector (default: `'.grid-stack-item-content'`) +- `handle_class` - draggable handle class (e.g. `'grid-stack-item-content'`). If set `handle` is ignored (default: `null`) +- `height` - maximum rows amount. Default is `0` which means no maximum rows +- `float` - enable floating widgets (default: `false`) See [example](http://troolee.github.io/gridstack.js/demo/float.html) +- `item_class` - widget class (default: `'grid-stack-item'`) +- `min_width` - minimal width. If window width is less, grid will be shown in one-column mode. You need also update your css file (`@media (max-width: 768px) {...}`) with corresponding value (default: `768`) +- `placeholder_class` - class for placeholder (default: `'grid-stack-placeholder'`) +- `placeholder_text` - placeholder default content (default: `''`) +- `resizable` - allows to override jQuery UI resizable options. (default: `{autoHide: true, handles: 'se'}`) +- `static_grid` - makes grid static (default `false`). If true widgets are not movable/resizable. You don't even need jQueryUI draggable/resizable. A CSS class `grid-stack-static` is also added to the container. +- `vertical_margin` - vertical gap size (default: `20`) +- `width` - amount of columns (default: `12`) + +## Grid attributes + +- `data-gs-animate` - turns animation on +- `data-gs-width` - amount of columns +- `data-gs-height` - maximum rows amount. Default is `0` which means no maximum rows. + +## Item attributes + +- `data-gs-x`, `data-gs-y` - element position +- `data-gs-width`, `data-gs-height` - element size +- `data-gs-max-width`, `data-gs-min-width`, `data-gs-max-height`, `data-gs-min-height` - element constraints +- `data-gs-no-resize` - disable element resizing +- `data-gs-no-move` - disable element moving +- `data-gs-auto-position` - tells to ignore `data-gs-x` and `data-gs-y` attributes and to place element to the first + available position +- `data-gs-locked` - the widget will be locked. It means another widget wouldn't be able to move it during dragging or resizing. +The widget can still be dragged or resized. You need to add `data-gs-no-resize` and `data-gs-no-move` attributes +to completely lock the widget. + +## Events + +### onchange(items) + +Occurs when adding/removing widgets or existing widgets change their position/size -As of v0.3.0, gridstack introduces a new plugin system. The drag'n'drop functionality has been modified to take advantage of this system. Because of this, and to avoid dependency on core code from jQuery UI, the plugin was functionality was moved to a separate file. +```javascript +var serialize_widget_map = function (items) { + console.log(items); +}; + +$('.grid-stack').on('change', function (e, items) { + serialize_widget_map(items); +}); +``` -To ensure gridstack continues to work, either include the additional `gridstack.jQueryUI.js` file into your HTML or use `gridstack.all.js`: +### ondragstart(event, ui) -```html - - +```javascript +$('.grid-stack').on('dragstart', function (event, ui) { + var grid = this; + var element = event.target; +}); ``` -or +### ondragstop(event, ui) -```html - +```javascript +$('.grid-stack').on('dragstop', function (event, ui) { + var grid = this; + var element = event.target; +}); +``` + +### onresizestart(event, ui) + +```javascript +$('.grid-stack').on('resizestart', function (event, ui) { + var grid = this; + var element = event.target; +}); +``` + +### onresizestop(event, ui) + +```javascript +$('.grid-stack').on('resizestop', function (event, ui) { + var grid = this; + var element = event.target; +}); +``` + +### disable(event) + +```javascipt +$('.grid-stack').on('disable', function(event) { + var grid = event.target; +}); +``` + +### enable(event) + +```javascipt +$('.grid-stack').on('enable', function(event) { + var grid = event.target; +}); ``` -We're working on implementing support for other drag'n'drop libraries through the new plugin system. +## API + +### add_widget(el, x, y, width, height, auto_position) + +Creates new widget and returns it. + +Parameters: -## Migrating to v0.2.5 +- `el` - widget to add +- `x`, `y`, `width`, `height` - widget position/dimensions (Optional) +- `auto_position` - if `true` then `x`, `y` parameters will be ignored and widget will be places on the first available +position + +Widget will be always placed even if result height is more than actual grid height. You need to use `will_it_fit` method +before calling `add_widget` for additional check. + +```javascript +$('.grid-stack').gridstack(); + +var grid = $('.grid-stack').data('gridstack'); +grid.add_widget(el, 0, 0, 3, 2, true); +``` + +### make_widget(el) + +If you add elements to your gridstack container by hand, you have to tell gridstack afterwards to make them widgets. If you want gridstack to add the elements for you, use `add_widget` instead. +Makes the given element a widget and returns it. + +Parameters: + +- `el` - element to convert to a widget + +```javascript +$('.grid-stack').gridstack(); + +$('.grid-stack').append('
') +var grid = $('.grid-stack').data('gridstack'); +grid.make_widget('gsi-1'); +``` + +### batch_update() + +Initailizes batch updates. You will see no changes until `commit` method is called. + +### cell_height() + +Gets current cell height. + +### cell_height(val) + +Update current cell height. This method rebuilds an internal CSS stylesheet. Note: You can expect performance issues if +call this method too often. + +```javascript +grid.cell_height(grid.cell_width() * 1.2); +``` -As of v0.2.5 all methods and parameters are in camel case to respect [JavaScript Style Guide and Coding Conventions](http://www.w3schools.com/js/js_conventions.asp). -All old methods and parameters are marked as deprecated and still available but a warning will be displayed in js console. They will be available until v1.0 -when they will be completely removed. +### cell_width() -## API Documentation +Gets current cell width. -Please check out `doc/README.md` for more information about gridstack.js API. +### commit() -## Questions and Answers +Finishes batch updates. Updates DOM nodes. You must call it after `batch_update`. -Please feel free to as a questions here in issues, using [Stackoverflow](http://stackoverflow.com/search?q=gridstack) or [Slack chat](https://gridstackjs.troolee.com). -We will glad to answer and help you as soon as we can. +### destroy() -Also please check our FAQ `doc/FAQ.md` before asking in case the answer is already there. +Destroys a grid instance. + +### disable() + +Disables widgets moving/resizing. This is a shortcut for: + +```javascript +grid.movable('.grid-stack-item', false); +grid.resizable('.grid-stack-item', false); +``` + +### enable() + +Enables widgets moving/resizing. This is a shortcut for: + +```javascript +grid.movable('.grid-stack-item', true); +grid.resizable('.grid-stack-item', true); +``` + +### get_cell_from_pixel(position) + +Get the position of the cell under a pixel on screen. + +Parameters : + +- `position` - the position of the pixel to resolve in absolute coordinates, as an object with `top` and `left`properties + +Returns an object with properties `x` and `y` i.e. the column and row in the grid. + +### is_area_empty(x, y, width, height) + +Checks if specified area is empty. + +### locked(el, val) + +Locks/unlocks widget. + +- `el` - widget to modify. +- `val` - if `true` widget will be locked. + +### min_width(el, val) + +Set the minWidth for a widget. + +- `el` - widget to modify. +- `val` - A numeric value of the number of columns + +### min_height(el, val) + +Set the minHeight for a widget. + +- `el` - widget to modify. +- `val` - A numeric value of the number of rows + +### movable(el, val) + +Enables/Disables moving. + +- `el` - widget to modify +- `val` - if `true` widget will be draggable. + +### move(el, x, y) + +Changes widget position + +Parameters: + +- `el` - widget to move +- `x`, `y` - new position. If value is `null` or `undefined` it will be ignored. + +### remove_widget(el, detach_node) + +Removes widget from the grid. + +Parameters: + +- `el` - widget to remove. +- `detach_node` - if `false` DOM node won't be removed from the tree (Optional. Default `true`). + +### remove_all() + +Removes all widgets from the grid. + +### resize(el, width, height) + +Changes widget size + +Parameters: + +- `el` - widget to resize +- `width`, `height` - new dimensions. If value is `null` or `undefined` it will be ignored. + +### resizable(el, val) + +Enables/Disables resizing. + +- `el` - widget to modify +- `val` - if `true` widget will be resizable. + +### set_static(static_value) + +Toggle the grid static state. Also toggle the `grid-stack-static` class. + +- `static_value` - if `true` the grid become static. + +### update(el, x, y, width, height) + +Parameters: + +- `el` - widget to move +- `x`, `y` - new position. If value is `null` or `undefined` it will be ignored. +- `width`, `height` - new dimensions. If value is `null` or `undefined` it will be ignored. + +Updates widget position/size. + +### will_it_fit(x, y, width, height, auto_position) + +Returns `true` if the `height` of the grid will be less the vertical constraint. Always returns `true` if grid doesn't +have `height` constraint. + +```javascript +if (grid.will_it_fit(new_node.x, new_node.y, new_node.width, new_node.height, true)) { + grid.add_widget(new_node.el, new_node.x, new_node.y, new_node.width, new_node.height, true); +} +else { + alert('Not enough free space to place the widget'); +} +``` + + +## Utils + +### GridStackUI.Utils.sort(nodes[, dir[, width]]) + +Sorts array of nodes + +- `nodes` - array to sort +- `dir` - `1` for asc, `-1` for desc (optional) +- `width` - width of the grid. If `undefined` the width will be calculated automatically (optional). ## Touch devices support @@ -190,19 +457,17 @@ working on touch-based devices. ``` -Also `alwaysShowResizeHandle` option may be useful: +Also `always_show_resize_handle` option may be useful: ```javascript $(function () { var options = { - alwaysShowResizeHandle: /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) + always_show_resize_handle: /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) }; $('.grid-stack').gridstack(options); }); ``` -If you're still experiencing issues on touch devices please check [#444](https://github.com/troolee/gridstack.js/issues/444) - ## Use with knockout.js ```javascript @@ -222,9 +487,9 @@ ko.components.register('dashboard-grid', { } var item = _.find(items, function (i) { return i.nodeType == 1 }); - grid.addWidget(item); + grid.add_widget(item); ko.utils.domNodeDisposal.addDisposeCallback(item, function () { - grid.removeWidget(item); + grid.remove_widget(item); }); }; }; @@ -235,7 +500,7 @@ ko.components.register('dashboard-grid', { template: [ '
', - '
', + '
', '
...
', '
', '
' @@ -268,11 +533,11 @@ See examples: [example 1](http://troolee.github.io/gridstack.js/demo/knockout.ht **Notes:** It's very important to exclude training spaces after widget template: -```javascript +``` template: [ '
', - '
', + '
', ' ....', '
', // <-- NO SPACE **AFTER**
'
' // <-- NO SPACE **BEFORE**
@@ -400,10 +665,10 @@ var serialization = [ serialization = GridStackUI.Utils.sort(serialization); var grid = $('.grid-stack').data('gridstack'); -grid.removeAll(); +grid.remove_all(); _.each(serialization, function (node) { - grid.addWidget($('
'), + grid.add_widget($('
'), node.x, node.y, node.width, node.height); }); ``` @@ -472,12 +737,6 @@ for i in range(N): There are at least two more issues with gridstack in IE8 with jQueryUI resizable (it seems it doesn't work) and droppable. If you have any suggestions about support of IE8 you are welcome here: https://github.com/troolee/gridstack.js/issues/76 -## Use with require.js - -If you're using require.js and a single file jQueryUI please check out this -[Stackoverflow question](http://stackoverflow.com/questions/35582945/redundant-dependencies-with-requirejs) to get it -working properly. - ## Nested grids @@ -486,77 +745,16 @@ during initialization. See example: [Nested grid demo](http://troolee.github.io/gridstack.js/demo/nested.html) -## Resizing active grid - -Resizing on-the-fly is possible, though experimental. This may be used to make gridstack responsive. gridstack will change the total number of columns and will attempt to update the width and x values of each widget to be more logical. -See example: [Responsive grid demo](http://troolee.github.io/gridstack.js/demo/responsive.html) - -## Using AniJS - -Using AniJS with gridstack is a breeze. In the following example, a listener is added that gets triggered by a widget being added. -See widgets wiggle! [AniJS demo](http://troolee.github.io/gridstack.js/demo/anijs.html) - -The Team -======== - -gridstack.js is currently maintained by [Pavel Reznikov](https://github.com/troolee), [Dylan Weiss](https://github.com/radiolips) -and [Kevin Dietrich](https://github.com/kdietrich). And we appreciate [all contributors](https://github.com/troolee/gridstack.js/graphs/contributors) -for help. - - Changes ======= -#### v0.3.0-dev (Development Version) - -- add oneColumnModeClass option to grid. -- remove 768px CSS styles, moved to grid-stack-one-column-mode class. -- add max-width override on grid-stck-one-column-mode ([#462](https://github.com/troolee/gridstack.js/issues/462)). -- add internal function`isNodeChangedPosition`, minor optimization to move/drag. -- drag'n'drop plugin system. Move jQuery UI dependencies to separate plugin file. - -#### v0.2.6 (2016-08-17) - -- update requirements to the latest versions of jQuery (v3.1.0+) and jquery-ui (v1.12.0+). -- fix jQuery `size()` ([#486](https://github.com/troolee/gridstack.js/issues/486)). -- update `destroy([detachGrid])` call ([#422](https://github.com/troolee/gridstack.js/issues/422)). -- don't mutate options when calling `draggable` and `resizable`. ([#505](https://github.com/troolee/gridstack.js/issues/505)). -- update _notify to allow detach ([#411](https://github.com/troolee/gridstack.js/issues/411)). -- fix code that checks for jquery-ui ([#481](https://github.com/troolee/gridstack.js/issues/481)). -- fix `cellWidth` calculation on empty grid - -#### v0.2.5 (2016-03-02) - -- update names to respect js naming convention. -- `cellHeight` and `verticalMargin` can now be string (e.g. '3em', '20px') (Thanks to @jlowcs). -- add `maxWidth`/`maxHeight` methods. -- add `enableMove`/`enableResize` methods. -- fix window resize issue #331. -- add options `disableDrag` and `disableResize`. -- fix `batchUpdate`/`commit` (Thank to @radiolips) -- remove dependency of FontAwesome -- RTL support -- `'auto'` value for `cellHeight` option -- fix `setStatic` method -- add `setAnimation` method to API -- add `setGridWidth` method ([#227](https://github.com/troolee/gridstack.js/issues/227)) -- add `removable`/`removeTimeout` *(experimental)* -- add `detachGrid` parameter to `destroy` method ([#216](https://github.com/troolee/gridstack.js/issues/216)) (thanks @jhpedemonte) -- add `useOffset` parameter to `getCellFromPixel` method ([#237](https://github.com/troolee/gridstack.js/issues/237)) -- add `minWidth`, `maxWidth`, `minHeight`, `maxHeight`, `id` parameters to `addWidget` ([#188](https://github.com/troolee/gridstack.js/issues/188)) -- add `added` and `removed` events for when a widget is added or removed, respectively. ([#54](https://github.com/troolee/gridstack.js/issues/54)) -- add `acceptWidgets` parameter. Widgets can now be draggable between grids or from outside *(experimental)* - -#### v0.2.4 (2016-02-15) +#### v0.2.4 (development version) - fix closure compiler/linter warnings - add `static_grid` option. - add `min_width`/`min_height` methods (Thanks to @cvillemure) - add `destroy` method (Thanks to @zspitzer) - add `placeholder_text` option (Thanks to @slauyama) -- add `handle_class` option. -- add `make_widget` method. -- lodash v 4.x support (Thanks to @andrewr88) #### v0.2.3 (2015-06-23) @@ -615,7 +813,7 @@ License The MIT License (MIT) -Copyright (c) 2014-2016 Pavel Reznikov, Dylan Weiss +Copyright (c) 2014-2016 Pavel Reznikov Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/bower.json b/bower.json index 37e390b63..4428d538a 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "gridstack", - "version": "0.3.0-dev", + "version": "0.2.3", "homepage": "https://github.com/troolee/gridstack.js", "authors": [ "Pavel Reznikov " @@ -14,9 +14,9 @@ "amd" ], "dependencies": { - "lodash": ">= 4.14.2", - "jquery": ">= 3.1.0", - "jquery-ui": ">= 1.12.0" + "lodash": ">= 3.5.0", + "jquery": ">= 1.11.0", + "jquery-ui": ">= 1.11.0" }, "keywords": [ "gridstack", diff --git a/demo/anijs.html b/demo/anijs.html deleted file mode 100644 index 6d66b428c..000000000 --- a/demo/anijs.html +++ /dev/null @@ -1,89 +0,0 @@ - - - - - - - - - Codestin Search App - - - - - - - - - - - - - - - - -
-

AniJS demo

- - - -
-

Widget added

-
- -
- -
-
-
- - - - - \ No newline at end of file diff --git a/demo/float.html b/demo/float.html index e1a968db8..638ec2a74 100644 --- a/demo/float.html +++ b/demo/float.html @@ -10,15 +10,15 @@ Codestin Search App - + + - - - - + + + + - - - -
-
-
-
-
-
-

Responsive grid demo

- -
- Number of Columns: -
- -
- -
-
-
- - - - - diff --git a/demo/rtl.html b/demo/rtl.html deleted file mode 100644 index 0f27dafd0..000000000 --- a/demo/rtl.html +++ /dev/null @@ -1,121 +0,0 @@ - - - - - - - - - Codestin Search App - - - - - - - - - - - - - - - -
-

RTL Demo

- -
- -
- -
- -
-
- - - - - diff --git a/demo/serialization.html b/demo/serialization.html index a58e847c1..06ddbc620 100644 --- a/demo/serialization.html +++ b/demo/serialization.html @@ -10,15 +10,15 @@ Codestin Search App - + + - - - - + + + + -

Two grids demo

-
-
- -
-
-
-
-
-
-
@@ -107,15 +58,10 @@

Two grids demo

$(function () { var options = { width: 6, - float: false, - removable: '.trash', - removeTimeout: 100, - acceptWidgets: '.grid-stack-item' + float: true }; $('#grid1').gridstack(options); - $('#grid2').gridstack(_.defaults({ - float: true - }, options)); + $('#grid2').gridstack(options); var items = [ {x: 0, y: 0, width: 2, height: 2}, @@ -129,17 +75,10 @@

Two grids demo

var grid = $(this).data('gridstack'); _.each(items, function (node) { - grid.addWidget($('
'), + grid.add_widget($('
'), node.x, node.y, node.width, node.height); }, this); }); - - $('.sidebar .grid-stack-item').draggable({ - revert: 'invalid', - handle: '.grid-stack-item-content', - scroll: false, - appendTo: 'body' - }); }); diff --git a/dist/gridstack.all.js b/dist/gridstack.all.js deleted file mode 100644 index d8165226b..000000000 --- a/dist/gridstack.all.js +++ /dev/null @@ -1,41 +0,0 @@ -/** - * gridstack.js 0.3.0-dev - * http://troolee.github.io/gridstack.js/ - * (c) 2014-2016 Pavel Reznikov, Dylan Weiss - * gridstack.js may be freely distributed under the MIT license. - * @preserve -*/ -!function(a){if("function"==typeof define&&define.amd)define(["jquery","lodash"],a);else if("undefined"!=typeof exports){try{jQuery=require("jquery")}catch(a){}try{_=require("lodash")}catch(a){}a(jQuery,_)}else a(jQuery,_)}(function(a,b){ -// jscs:enable requireCamelCaseOrUpperCaseIdentifiers -/** - * @class GridStackDragDropPlugin - * Base class for drag'n'drop plugin. - */ -function c(a){this.grid=a}var d=window,e=function(a,b,c){var d=function(){return console.warn("gridstack.js: Function `"+b+"` is deprecated as of v0.2.5 and has been replaced with `"+c+"`. It will be **completely** removed in v1.0."),a.apply(this,arguments)};return d.prototype=a.prototype,d},f=function(a,b){console.warn("gridstack.js: Option `"+a+"` is deprecated as of v0.2.5 and has been replaced with `"+b+"`. It will be **completely** removed in v1.0.")},g={isIntercepted:function(a,b){return!(a.x+a.width<=b.x||b.x+b.width<=a.x||a.y+a.height<=b.y||b.y+b.height<=a.y)},sort:function(a,c,d){return d=d||b.chain(a).map(function(a){return a.x+a.width}).max().value(),c=c!=-1?1:-1,b.sortBy(a,function(a){return c*(a.x+a.y*d)})},createStylesheet:function(a){var b=document.createElement("style");return b.setAttribute("type","text/css"),b.setAttribute("data-gs-style-id",a),b.styleSheet?b.styleSheet.cssText="":b.appendChild(document.createTextNode("")),document.getElementsByTagName("head")[0].appendChild(b),b.sheet},removeStylesheet:function(b){a("STYLE[data-gs-style-id="+b+"]").remove()},insertCSSRule:function(a,b,c,d){"function"==typeof a.insertRule?a.insertRule(b+"{"+c+"}",d):"function"==typeof a.addRule&&a.addRule(b,c,d)},toBool:function(a){return"boolean"==typeof a?a:"string"==typeof a?(a=a.toLowerCase(),!(""===a||"no"==a||"false"==a||"0"==a)):Boolean(a)},_collisionNodeCheck:function(a){return a!=this.node&&g.isIntercepted(a,this.nn)},_didCollide:function(a){return g.isIntercepted({x:this.n.x,y:this.newY,width:this.n.width,height:this.n.height},a)},_isAddNodeIntercepted:function(a){return g.isIntercepted({x:this.x,y:this.y,width:this.node.width,height:this.node.height},a)},parseHeight:function(a){var c=a,d="px";if(c&&b.isString(c)){var e=c.match(/^(-[0-9]+\.[0-9]+|[0-9]*\.[0-9]+|-[0-9]+|[0-9]+)(px|em|rem|vh|vw)?$/);if(!e)throw new Error("Invalid height");d=e[2]||"px",c=parseFloat(e[1])}return{height:c,unit:d}}}; -// jscs:disable requireCamelCaseOrUpperCaseIdentifiers -g.is_intercepted=e(g.isIntercepted,"is_intercepted","isIntercepted"),g.create_stylesheet=e(g.createStylesheet,"create_stylesheet","createStylesheet"),g.remove_stylesheet=e(g.removeStylesheet,"remove_stylesheet","removeStylesheet"),g.insert_css_rule=e(g.insertCSSRule,"insert_css_rule","insertCSSRule"),c.registeredPlugins=[],c.registerPlugin=function(a){c.registeredPlugins.push(a)},c.prototype.resizable=function(a,b){return this},c.prototype.draggable=function(a,b){return this},c.prototype.droppable=function(a,b){return this},c.prototype.isDroppable=function(a){return!1},c.prototype.on=function(a,b,c){return this};var h=0,i=function(a,b,c,d,e){this.width=a,this.float=c||!1,this.height=d||0,this.nodes=e||[],this.onchange=b||function(){},this._updateCounter=0,this._float=this.float,this._addedNodes=[],this._removedNodes=[]};i.prototype.batchUpdate=function(){this._updateCounter=1,this.float=!0},i.prototype.commit=function(){0!==this._updateCounter&&(this._updateCounter=0,this.float=this._float,this._packNodes(),this._notify())}, -// For Meteor support: https://github.com/troolee/gridstack.js/pull/272 -i.prototype.getNodeDataByDOMEl=function(a){return b.find(this.nodes,function(b){return a.get(0)===b.el.get(0)})},i.prototype._fixCollisions=function(a){this._sortNodes(-1);var c=a,d=Boolean(b.find(this.nodes,function(a){return a.locked}));for(this.float||d||(c={x:0,y:a.y,width:this.width,height:a.height});;){var e=b.find(this.nodes,b.bind(g._collisionNodeCheck,{node:a,nn:c}));if("undefined"==typeof e)return;this.moveNode(e,e.x,a.y+a.height,e.width,e.height,!0)}},i.prototype.isAreaEmpty=function(a,c,d,e){var f={x:a||0,y:c||0,width:d||1,height:e||1},h=b.find(this.nodes,b.bind(function(a){return g.isIntercepted(a,f)},this));return null===h||"undefined"==typeof h},i.prototype._sortNodes=function(a){this.nodes=g.sort(this.nodes,a,this.width)},i.prototype._packNodes=function(){this._sortNodes(),this.float?b.each(this.nodes,b.bind(function(a,c){if(!a._updating&&"undefined"!=typeof a._origY&&a.y!=a._origY)for(var d=a.y;d>=a._origY;){var e=b.chain(this.nodes).find(b.bind(g._didCollide,{n:a,newY:d})).value();e||(a._dirty=!0,a.y=d),--d}},this)):b.each(this.nodes,b.bind(function(a,c){if(!a.locked)for(;a.y>0;){var d=a.y-1,e=0===c;if(c>0){var f=b.chain(this.nodes).take(c).find(b.bind(g._didCollide,{n:a,newY:d})).value();e="undefined"==typeof f}if(!e)break;a._dirty=a.y!=d,a.y=d}},this))},i.prototype._prepareNode=function(a,c){return a=b.defaults(a||{},{width:1,height:1,x:0,y:0}),a.x=parseInt(""+a.x),a.y=parseInt(""+a.y),a.width=parseInt(""+a.width),a.height=parseInt(""+a.height),a.autoPosition=a.autoPosition||!1,a.noResize=a.noResize||!1,a.noMove=a.noMove||!1,a.width>this.width?a.width=this.width:a.width<1&&(a.width=1),a.height<1&&(a.height=1),a.x<0&&(a.x=0),a.x+a.width>this.width&&(c?a.width=this.width-a.x:a.x=this.width-a.width),a.y<0&&(a.y=0),a},i.prototype._notify=function(){var a=Array.prototype.slice.call(arguments,0);if(a[0]="undefined"==typeof a[0]?[]:[a[0]],a[1]="undefined"==typeof a[1]||a[1],!this._updateCounter){var b=a[0].concat(this.getDirtyNodes());this.onchange(b,a[1])}},i.prototype.cleanNodes=function(){this._updateCounter||b.each(this.nodes,function(a){a._dirty=!1})},i.prototype.getDirtyNodes=function(){return b.filter(this.nodes,function(a){return a._dirty})},i.prototype.addNode=function(a,c){if(a=this._prepareNode(a),"undefined"!=typeof a.maxWidth&&(a.width=Math.min(a.width,a.maxWidth)),"undefined"!=typeof a.maxHeight&&(a.height=Math.min(a.height,a.maxHeight)),"undefined"!=typeof a.minWidth&&(a.width=Math.max(a.width,a.minWidth)),"undefined"!=typeof a.minHeight&&(a.height=Math.max(a.height,a.minHeight)),a._id=++h,a._dirty=!0,a.autoPosition){this._sortNodes();for(var d=0;;++d){var e=d%this.width,f=Math.floor(d/this.width);if(!(e+a.width>this.width||b.find(this.nodes,b.bind(g._isAddNodeIntercepted,{x:e,y:f,node:a})))){a.x=e,a.y=f;break}}}return this.nodes.push(a),"undefined"!=typeof c&&c&&this._addedNodes.push(b.clone(a)),this._fixCollisions(a),this._packNodes(),this._notify(),a},i.prototype.removeNode=function(a,c){c="undefined"==typeof c||c,this._removedNodes.push(b.clone(a)),a._id=null,this.nodes=b.without(this.nodes,a),this._packNodes(),this._notify(a,c)},i.prototype.canMoveNode=function(c,d,e,f,g){if(!this.isNodeChangedPosition(c,d,e,f,g))return!1;var h=Boolean(b.find(this.nodes,function(a){return a.locked}));if(!this.height&&!h)return!0;var j,k=new i(this.width,null,this.float,0,b.map(this.nodes,function(b){return b==c?j=a.extend({},b):a.extend({},b)}));if("undefined"==typeof j)return!0;k.moveNode(j,d,e,f,g);var l=!0;return h&&(l&=!Boolean(b.find(k.nodes,function(a){return a!=j&&Boolean(a.locked)&&Boolean(a._dirty)}))),this.height&&(l&=k.getGridHeight()<=this.height),l},i.prototype.canBePlacedWithRespectToHeight=function(c){if(!this.height)return!0;var d=new i(this.width,null,this.float,0,b.map(this.nodes,function(b){return a.extend({},b)}));return d.addNode(c),d.getGridHeight()<=this.height},i.prototype.isNodeChangedPosition=function(a,b,c,d,e){return"number"!=typeof b&&(b=a.x),"number"!=typeof c&&(c=a.y),"number"!=typeof d&&(d=a.width),"number"!=typeof e&&(e=a.height),"undefined"!=typeof a.maxWidth&&(d=Math.min(d,a.maxWidth)),"undefined"!=typeof a.maxHeight&&(e=Math.min(e,a.maxHeight)),"undefined"!=typeof a.minWidth&&(d=Math.max(d,a.minWidth)),"undefined"!=typeof a.minHeight&&(e=Math.max(e,a.minHeight)),a.x!=b||a.y!=c||a.width!=d||a.height!=e},i.prototype.moveNode=function(a,b,c,d,e,f){if(!this.isNodeChangedPosition(a,b,c,d,e))return a;if("number"!=typeof b&&(b=a.x),"number"!=typeof c&&(c=a.y),"number"!=typeof d&&(d=a.width),"number"!=typeof e&&(e=a.height),"undefined"!=typeof a.maxWidth&&(d=Math.min(d,a.maxWidth)),"undefined"!=typeof a.maxHeight&&(e=Math.min(e,a.maxHeight)),"undefined"!=typeof a.minWidth&&(d=Math.max(d,a.minWidth)),"undefined"!=typeof a.minHeight&&(e=Math.max(e,a.minHeight)),a.x==b&&a.y==c&&a.width==d&&a.height==e)return a;var g=a.width!=d;return a._dirty=!0,a.x=b,a.y=c,a.width=d,a.height=e,a.lastTriedX=b,a.lastTriedY=c,a.lastTriedWidth=d,a.lastTriedHeight=e,a=this._prepareNode(a,g),this._fixCollisions(a),f||(this._packNodes(),this._notify()),a},i.prototype.getGridHeight=function(){return b.reduce(this.nodes,function(a,b){return Math.max(a,b.y+b.height)},0)},i.prototype.beginUpdate=function(a){b.each(this.nodes,function(a){a._origY=a.y}),a._updating=!0},i.prototype.endUpdate=function(){b.each(this.nodes,function(a){a._origY=a.y});var a=b.find(this.nodes,function(a){return a._updating});a&&(a._updating=!1)};var j=function(d,e){var g,h,j=this;e=e||{},this.container=a(d), -// jscs:disable requireCamelCaseOrUpperCaseIdentifiers -"undefined"!=typeof e.handle_class&&(e.handleClass=e.handle_class,f("handle_class","handleClass")),"undefined"!=typeof e.item_class&&(e.itemClass=e.item_class,f("item_class","itemClass")),"undefined"!=typeof e.placeholder_class&&(e.placeholderClass=e.placeholder_class,f("placeholder_class","placeholderClass")),"undefined"!=typeof e.placeholder_text&&(e.placeholderText=e.placeholder_text,f("placeholder_text","placeholderText")),"undefined"!=typeof e.cell_height&&(e.cellHeight=e.cell_height,f("cell_height","cellHeight")),"undefined"!=typeof e.vertical_margin&&(e.verticalMargin=e.vertical_margin,f("vertical_margin","verticalMargin")),"undefined"!=typeof e.min_width&&(e.minWidth=e.min_width,f("min_width","minWidth")),"undefined"!=typeof e.static_grid&&(e.staticGrid=e.static_grid,f("static_grid","staticGrid")),"undefined"!=typeof e.is_nested&&(e.isNested=e.is_nested,f("is_nested","isNested")),"undefined"!=typeof e.always_show_resize_handle&&(e.alwaysShowResizeHandle=e.always_show_resize_handle,f("always_show_resize_handle","alwaysShowResizeHandle")), -// jscs:enable requireCamelCaseOrUpperCaseIdentifiers -e.itemClass=e.itemClass||"grid-stack-item";var k=this.container.closest("."+e.itemClass).length>0;if(this.opts=b.defaults(e||{},{width:parseInt(this.container.attr("data-gs-width"))||12,height:parseInt(this.container.attr("data-gs-height"))||0,itemClass:"grid-stack-item",placeholderClass:"grid-stack-placeholder",placeholderText:"",handle:".grid-stack-item-content",handleClass:null,cellHeight:60,verticalMargin:20,auto:!0,minWidth:768,float:!1,staticGrid:!1,_class:"grid-stack-instance-"+(1e4*Math.random()).toFixed(0),animate:Boolean(this.container.attr("data-gs-animate"))||!1,alwaysShowResizeHandle:e.alwaysShowResizeHandle||!1,resizable:b.defaults(e.resizable||{},{autoHide:!e.alwaysShowResizeHandle,handles:"se"}),draggable:b.defaults(e.draggable||{},{handle:(e.handleClass?"."+e.handleClass:e.handle?e.handle:"")||".grid-stack-item-content",scroll:!1,appendTo:"body"}),disableDrag:e.disableDrag||!1,disableResize:e.disableResize||!1,rtl:"auto",removable:!1,removeTimeout:2e3,verticalMarginUnit:"px",cellHeightUnit:"px",oneColumnModeClass:e.oneColumnModeClass||"grid-stack-one-column-mode",ddPlugin:null}),this.opts.ddPlugin===!1?this.opts.ddPlugin=c:null===this.opts.ddPlugin&&(this.opts.ddPlugin=b.first(c.registeredPlugins)||c),this.dd=new this.opts.ddPlugin(this),"auto"===this.opts.rtl&&(this.opts.rtl="rtl"===this.container.css("direction")),this.opts.rtl&&this.container.addClass("grid-stack-rtl"),this.opts.isNested=k,h="auto"===this.opts.cellHeight,h?j.cellHeight(j.cellWidth(),!0):this.cellHeight(this.opts.cellHeight,!0),this.verticalMargin(this.opts.verticalMargin,!0),this.container.addClass(this.opts._class),this._setStaticClass(),k&&this.container.addClass("grid-stack-nested"),this._initStyles(),this.grid=new i(this.opts.width,function(a,c){c="undefined"==typeof c||c;var d=0;b.each(a,function(a){c&&null===a._id?a.el&&a.el.remove():(a.el.attr("data-gs-x",a.x).attr("data-gs-y",a.y).attr("data-gs-width",a.width).attr("data-gs-height",a.height),d=Math.max(d,a.y+a.height))}),j._updateStyles(d+10)},this.opts.float,this.opts.height),this.opts.auto){var l=[],m=this;this.container.children("."+this.opts.itemClass+":not(."+this.opts.placeholderClass+")").each(function(b,c){c=a(c),l.push({el:c,i:parseInt(c.attr("data-gs-x"))+parseInt(c.attr("data-gs-y"))*m.opts.width})}),b.chain(l).sortBy(function(a){return a.i}).each(function(a){j._prepareElement(a.el)}).value()}if(this.setAnimation(this.opts.animate),this.placeholder=a('
'+this.opts.placeholderText+"
").hide(),this._updateContainerHeight(),this._updateHeightsOnResize=b.throttle(function(){j.cellHeight(j.cellWidth(),!1)},100),this.onResizeHandler=function(){if(h&&j._updateHeightsOnResize(),j._isOneColumnMode()){if(g)return;j.container.addClass(j.opts.oneColumnModeClass),g=!0,j.grid._sortNodes(),b.each(j.grid.nodes,function(a){j.container.append(a.el),j.opts.staticGrid||((a.noMove||j.opts.disableDrag)&&j.dd.draggable(a.el,"disable"),(a.noResize||j.opts.disableResize)&&j.dd.resizable(a.el,"disable"),a.el.trigger("resize"))})}else{if(!g)return;if(j.container.removeClass(j.opts.oneColumnModeClass),g=!1,j.opts.staticGrid)return;b.each(j.grid.nodes,function(a){a.noMove||j.opts.disableDrag||j.dd.draggable(a.el,"enable"),a.noResize||j.opts.disableResize||j.dd.resizable(a.el,"enable"),a.el.trigger("resize")})}},a(window).resize(this.onResizeHandler),this.onResizeHandler(),!j.opts.staticGrid&&"string"==typeof j.opts.removable){var n=a(j.opts.removable);this.dd.isDroppable(n)||this.dd.droppable(n,{accept:"."+j.opts.itemClass}),this.dd.on(n,"dropover",function(b,c){var d=a(c.draggable),e=d.data("_gridstack_node");e._grid===j&&j._setupRemovingTimeout(d)}).on(n,"dropout",function(b,c){var d=a(c.draggable),e=d.data("_gridstack_node");e._grid===j&&j._clearRemovingTimeout(d)})}if(!j.opts.staticGrid&&j.opts.acceptWidgets){var o=null,p=function(a,b){var c=o,d=c.data("_gridstack_node"),e=j.getCellFromPixel(b.offset,!0),f=Math.max(0,e.x),g=Math.max(0,e.y);if(d._added){if(!j.grid.canMoveNode(d,f,g))return;j.grid.moveNode(d,f,g),j._updateContainerHeight()}else d._added=!0,d.el=c,d.x=f,d.y=g,j.grid.cleanNodes(),j.grid.beginUpdate(d),j.grid.addNode(d),j.container.append(j.placeholder),j.placeholder.attr("data-gs-x",d.x).attr("data-gs-y",d.y).attr("data-gs-width",d.width).attr("data-gs-height",d.height).show(),d.el=j.placeholder,d._beforeDragX=d.x,d._beforeDragY=d.y,j._updateContainerHeight()};this.dd.droppable(j.container,{accept:function(b){b=a(b);var c=b.data("_gridstack_node");return(!c||c._grid!==j)&&b.is(j.opts.acceptWidgets===!0?".grid-stack-item":j.opts.acceptWidgets)}}).on(j.container,"dropover",function(b,c){var d=(j.container.offset(),a(c.draggable)),e=j.cellWidth(),f=j.cellHeight(),g=d.data("_gridstack_node"),h=g?g.width:Math.ceil(d.outerWidth()/e),i=g?g.height:Math.ceil(d.outerHeight()/f);o=d;var k=j.grid._prepareNode({width:h,height:i,_added:!1,_temporary:!0});d.data("_gridstack_node",k),d.data("_gridstack_node_orig",g),d.on("drag",p)}).on(j.container,"dropout",function(b,c){var d=a(c.draggable);d.unbind("drag",p);var e=d.data("_gridstack_node");e.el=null,j.grid.removeNode(e),j.placeholder.detach(),j._updateContainerHeight(),d.data("_gridstack_node",d.data("_gridstack_node_orig"))}).on(j.container,"drop",function(b,c){j.placeholder.detach();var d=a(c.draggable).data("_gridstack_node");d._grid=j;var e=a(c.draggable).clone(!1);e.data("_gridstack_node",d),a(c.draggable).remove(),d.el=e,j.placeholder.hide(),e.attr("data-gs-x",d.x).attr("data-gs-y",d.y).attr("data-gs-width",d.width).attr("data-gs-height",d.height).addClass(j.opts.itemClass).removeAttr("style").enableSelection().removeData("draggable").removeClass("ui-draggable ui-draggable-dragging ui-draggable-disabled").unbind("drag",p),j.container.append(e),j._prepareElementsByNode(e,d),j._updateContainerHeight(),j._triggerChangeEvent(),j.grid.endUpdate()})}}; -// jscs:disable requireCamelCaseOrUpperCaseIdentifiers -// jscs:enable requireCamelCaseOrUpperCaseIdentifiers -return j.prototype._triggerChangeEvent=function(a){var b=this.grid.getDirtyNodes(),c=!1,d=[];b&&b.length&&(d.push(b),c=!0),(c||a===!0)&&this.container.trigger("change",d)},j.prototype._triggerAddEvent=function(){this.grid._addedNodes&&this.grid._addedNodes.length>0&&(this.container.trigger("added",[b.map(this.grid._addedNodes,b.clone)]),this.grid._addedNodes=[])},j.prototype._triggerRemoveEvent=function(){this.grid._removedNodes&&this.grid._removedNodes.length>0&&(this.container.trigger("removed",[b.map(this.grid._removedNodes,b.clone)]),this.grid._removedNodes=[])},j.prototype._initStyles=function(){this._stylesId&&g.removeStylesheet(this._stylesId),this._stylesId="gridstack-style-"+(1e5*Math.random()).toFixed(),this._styles=g.createStylesheet(this._stylesId),null!==this._styles&&(this._styles._max=0)},j.prototype._updateStyles=function(a){if(null!==this._styles&&"undefined"!=typeof this._styles){var b,c="."+this.opts._class+" ."+this.opts.itemClass,d=this;if("undefined"==typeof a&&(a=this._styles._max,this._initStyles(),this._updateContainerHeight()),this.opts.cellHeight&&!(0!==this._styles._max&&a<=this._styles._max)&&(b=this.opts.verticalMargin&&this.opts.cellHeightUnit!==this.opts.verticalMarginUnit?function(a,b){return a&&b?"calc("+(d.opts.cellHeight*a+d.opts.cellHeightUnit)+" + "+(d.opts.verticalMargin*b+d.opts.verticalMarginUnit)+")":d.opts.cellHeight*a+d.opts.verticalMargin*b+d.opts.cellHeightUnit}:function(a,b){return d.opts.cellHeight*a+d.opts.verticalMargin*b+d.opts.cellHeightUnit},0===this._styles._max&&g.insertCSSRule(this._styles,c,"min-height: "+b(1,0)+";",0),a>this._styles._max)){for(var e=this._styles._max;e=f.grid.width||k<0?(f.opts.removable===!0&&f._setupRemovingTimeout(b),j=c._beforeDragX,k=c._beforeDragY,f.placeholder.detach(),f.placeholder.hide(),f.grid.removeNode(c),f._updateContainerHeight(),c._temporaryRemoved=!0):(f._clearRemovingTimeout(b),c._temporaryRemoved&&(f.grid.addNode(c),f.placeholder.attr("data-gs-x",j).attr("data-gs-y",k).attr("data-gs-width",h).attr("data-gs-height",i).show(),f.container.append(f.placeholder),c.el=f.placeholder,c._temporaryRemoved=!1));else if("resize"==a.type&&j<0)return; -// width and height are undefined if not resizing -var l="undefined"!=typeof h?h:c.lastTriedWidth,m="undefined"!=typeof i?i:c.lastTriedHeight;!f.grid.canMoveNode(c,j,k,h,i)||c.lastTriedX===j&&c.lastTriedY===k&&c.lastTriedWidth===l&&c.lastTriedHeight===m||(c.lastTriedX=j,c.lastTriedY=k,c.lastTriedWidth=h,c.lastTriedHeight=i,f.grid.moveNode(c,j,k,h,i),f._updateContainerHeight())},h=function(g,h){f.container.append(f.placeholder);var i=a(this);f.grid.cleanNodes(),f.grid.beginUpdate(c),d=f.cellWidth();var j=Math.ceil(i.outerHeight()/i.attr("data-gs-height"));e=f.container.height()/parseInt(f.container.attr("data-gs-current-height")),f.placeholder.attr("data-gs-x",i.attr("data-gs-x")).attr("data-gs-y",i.attr("data-gs-y")).attr("data-gs-width",i.attr("data-gs-width")).attr("data-gs-height",i.attr("data-gs-height")).show(),c.el=f.placeholder,c._beforeDragX=c.x,c._beforeDragY=c.y,f.dd.resizable(b,"option","minWidth",d*(c.minWidth||1)),f.dd.resizable(b,"option","minHeight",j*(c.minHeight||1)),"resizestart"==g.type&&i.find(".grid-stack-item").trigger("resizestart")},i=function(d,e){var g=a(this);if(g.data("_gridstack_node")){var h=!1;f.placeholder.detach(),c.el=g,f.placeholder.hide(),c._isAboutToRemove?(h=!0,b.removeData("_gridstack_node"),b.remove()):(f._clearRemovingTimeout(b),c._temporaryRemoved?(g.attr("data-gs-x",c._beforeDragX).attr("data-gs-y",c._beforeDragY).attr("data-gs-width",c.width).attr("data-gs-height",c.height).removeAttr("style"),c.x=c._beforeDragX,c.y=c._beforeDragY,f.grid.addNode(c)):g.attr("data-gs-x",c.x).attr("data-gs-y",c.y).attr("data-gs-width",c.width).attr("data-gs-height",c.height).removeAttr("style")),f._updateContainerHeight(),f._triggerChangeEvent(h),f.grid.endUpdate();var i=g.find(".grid-stack");i.length&&"resizestop"==d.type&&(i.each(function(b,c){a(c).data("gridstack").onResizeHandler()}),g.find(".grid-stack-item").trigger("resizestop"))}};this.dd.draggable(b,{start:h,stop:i,drag:g}).resizable(b,{start:h,stop:i,resize:g}),(c.noMove||this._isOneColumnMode()||this.opts.disableDrag)&&this.dd.draggable(b,"disable"),(c.noResize||this._isOneColumnMode()||this.opts.disableResize)&&this.dd.resizable(b,"disable"),b.attr("data-gs-locked",c.locked?"yes":null)}},j.prototype._prepareElement=function(b,c){c="undefined"!=typeof c&&c;var d=this;b=a(b),b.addClass(this.opts.itemClass);var e=d.grid.addNode({x:b.attr("data-gs-x"),y:b.attr("data-gs-y"),width:b.attr("data-gs-width"),height:b.attr("data-gs-height"),maxWidth:b.attr("data-gs-max-width"),minWidth:b.attr("data-gs-min-width"),maxHeight:b.attr("data-gs-max-height"),minHeight:b.attr("data-gs-min-height"),autoPosition:g.toBool(b.attr("data-gs-auto-position")),noResize:g.toBool(b.attr("data-gs-no-resize")),noMove:g.toBool(b.attr("data-gs-no-move")),locked:g.toBool(b.attr("data-gs-locked")),el:b,id:b.attr("data-gs-id"),_grid:d},c);b.data("_gridstack_node",e),this._prepareElementsByNode(b,e)},j.prototype.setAnimation=function(a){a?this.container.addClass("grid-stack-animate"):this.container.removeClass("grid-stack-animate")},j.prototype.addWidget=function(b,c,d,e,f,g,h,i,j,k,l){return b=a(b),"undefined"!=typeof c&&b.attr("data-gs-x",c),"undefined"!=typeof d&&b.attr("data-gs-y",d),"undefined"!=typeof e&&b.attr("data-gs-width",e),"undefined"!=typeof f&&b.attr("data-gs-height",f),"undefined"!=typeof g&&b.attr("data-gs-auto-position",g?"yes":null),"undefined"!=typeof h&&b.attr("data-gs-min-width",h),"undefined"!=typeof i&&b.attr("data-gs-max-width",i),"undefined"!=typeof j&&b.attr("data-gs-min-height",j),"undefined"!=typeof k&&b.attr("data-gs-max-height",k),"undefined"!=typeof l&&b.attr("data-gs-id",l),this.container.append(b),this._prepareElement(b,!0),this._triggerAddEvent(),this._updateContainerHeight(),this._triggerChangeEvent(!0),b},j.prototype.makeWidget=function(b){return b=a(b),this._prepareElement(b,!0),this._triggerAddEvent(),this._updateContainerHeight(),this._triggerChangeEvent(!0),b},j.prototype.willItFit=function(a,b,c,d,e){var f={x:a,y:b,width:c,height:d,autoPosition:e};return this.grid.canBePlacedWithRespectToHeight(f)},j.prototype.removeWidget=function(b,c){c="undefined"==typeof c||c,b=a(b);var d=b.data("_gridstack_node"); -// For Meteor support: https://github.com/troolee/gridstack.js/pull/272 -d||(d=this.grid.getNodeDataByDOMEl(b)),this.grid.removeNode(d,c),b.removeData("_gridstack_node"),this._updateContainerHeight(),c&&b.remove(),this._triggerChangeEvent(!0),this._triggerRemoveEvent()},j.prototype.removeAll=function(a){b.each(this.grid.nodes,b.bind(function(b){this.removeWidget(b.el,a)},this)),this.grid.nodes=[],this._updateContainerHeight()},j.prototype.destroy=function(b){a(window).off("resize",this.onResizeHandler),this.disable(),"undefined"==typeof b||b?this.container.remove():(this.removeAll(!1),this.container.removeData("gridstack")),g.removeStylesheet(this._stylesId),this.grid&&(this.grid=null)},j.prototype.resizable=function(b,c){var d=this;return b=a(b),b.each(function(b,e){e=a(e);var f=e.data("_gridstack_node");"undefined"!=typeof f&&null!==f&&"undefined"!=typeof a.ui&&(f.noResize=!c,f.noResize||d._isOneColumnMode()?d.dd.resizable(e,"disable"):d.dd.resizable(e,"enable"))}),this},j.prototype.movable=function(b,c){var d=this;return b=a(b),b.each(function(b,e){e=a(e);var f=e.data("_gridstack_node");"undefined"!=typeof f&&null!==f&&"undefined"!=typeof a.ui&&(f.noMove=!c,f.noMove||d._isOneColumnMode()?(d.dd.draggable(e,"disable"),e.removeClass("ui-draggable-handle")):(d.dd.draggable(e,"enable"),e.addClass("ui-draggable-handle")))}),this},j.prototype.enableMove=function(a,b){this.movable(this.container.children("."+this.opts.itemClass),a),b&&(this.opts.disableDrag=!a)},j.prototype.enableResize=function(a,b){this.resizable(this.container.children("."+this.opts.itemClass),a),b&&(this.opts.disableResize=!a)},j.prototype.disable=function(){this.movable(this.container.children("."+this.opts.itemClass),!1),this.resizable(this.container.children("."+this.opts.itemClass),!1),this.container.trigger("disable")},j.prototype.enable=function(){this.movable(this.container.children("."+this.opts.itemClass),!0),this.resizable(this.container.children("."+this.opts.itemClass),!0),this.container.trigger("enable")},j.prototype.locked=function(b,c){return b=a(b),b.each(function(b,d){d=a(d);var e=d.data("_gridstack_node");"undefined"!=typeof e&&null!==e&&(e.locked=c||!1,d.attr("data-gs-locked",e.locked?"yes":null))}),this},j.prototype.maxHeight=function(b,c){return b=a(b),b.each(function(b,d){d=a(d);var e=d.data("_gridstack_node");"undefined"!=typeof e&&null!==e&&(isNaN(c)||(e.maxHeight=c||!1,d.attr("data-gs-max-height",c)))}),this},j.prototype.minHeight=function(b,c){return b=a(b),b.each(function(b,d){d=a(d);var e=d.data("_gridstack_node");"undefined"!=typeof e&&null!==e&&(isNaN(c)||(e.minHeight=c||!1,d.attr("data-gs-min-height",c)))}),this},j.prototype.maxWidth=function(b,c){return b=a(b),b.each(function(b,d){d=a(d);var e=d.data("_gridstack_node");"undefined"!=typeof e&&null!==e&&(isNaN(c)||(e.maxWidth=c||!1,d.attr("data-gs-max-width",c)))}),this},j.prototype.minWidth=function(b,c){return b=a(b),b.each(function(b,d){d=a(d);var e=d.data("_gridstack_node");"undefined"!=typeof e&&null!==e&&(isNaN(c)||(e.minWidth=c||!1,d.attr("data-gs-min-width",c)))}),this},j.prototype._updateElement=function(b,c){b=a(b).first();var d=b.data("_gridstack_node");if("undefined"!=typeof d&&null!==d){var e=this;e.grid.cleanNodes(),e.grid.beginUpdate(d),c.call(this,b,d),e._updateContainerHeight(),e._triggerChangeEvent(),e.grid.endUpdate()}},j.prototype.resize=function(a,b,c){this._updateElement(a,function(a,d){b=null!==b&&"undefined"!=typeof b?b:d.width,c=null!==c&&"undefined"!=typeof c?c:d.height,this.grid.moveNode(d,d.x,d.y,b,c)})},j.prototype.move=function(a,b,c){this._updateElement(a,function(a,d){b=null!==b&&"undefined"!=typeof b?b:d.x,c=null!==c&&"undefined"!=typeof c?c:d.y,this.grid.moveNode(d,b,c,d.width,d.height)})},j.prototype.update=function(a,b,c,d,e){this._updateElement(a,function(a,f){b=null!==b&&"undefined"!=typeof b?b:f.x,c=null!==c&&"undefined"!=typeof c?c:f.y,d=null!==d&&"undefined"!=typeof d?d:f.width,e=null!==e&&"undefined"!=typeof e?e:f.height,this.grid.moveNode(f,b,c,d,e)})},j.prototype.verticalMargin=function(a,b){if("undefined"==typeof a)return this.opts.verticalMargin;var c=g.parseHeight(a);this.opts.verticalMarginUnit===c.unit&&this.opts.height===c.height||(this.opts.verticalMarginUnit=c.unit,this.opts.verticalMargin=c.height,b||this._updateStyles())},j.prototype.cellHeight=function(a,b){if("undefined"==typeof a){if(this.opts.cellHeight)return this.opts.cellHeight;var c=this.container.children("."+this.opts.itemClass).first();return Math.ceil(c.outerHeight()/c.attr("data-gs-height"))}var d=g.parseHeight(a);this.opts.cellHeightUnit===d.heightUnit&&this.opts.height===d.height||(this.opts.cellHeightUnit=d.unit,this.opts.cellHeight=d.height,b||this._updateStyles())},j.prototype.cellWidth=function(){return Math.round(this.container.outerWidth()/this.opts.width)},j.prototype.getCellFromPixel=function(a,b){var c="undefined"!=typeof b&&b?this.container.offset():this.container.position(),d=a.left-c.left,e=a.top-c.top,f=Math.floor(this.container.width()/this.opts.width),g=Math.floor(this.container.height()/parseInt(this.container.attr("data-gs-current-height")));return{x:Math.floor(d/f),y:Math.floor(e/g)}},j.prototype.batchUpdate=function(){this.grid.batchUpdate()},j.prototype.commit=function(){this.grid.commit(),this._updateContainerHeight()},j.prototype.isAreaEmpty=function(a,b,c,d){return this.grid.isAreaEmpty(a,b,c,d)},j.prototype.setStatic=function(a){this.opts.staticGrid=a===!0,this.enableMove(!a),this.enableResize(!a),this._setStaticClass()},j.prototype._setStaticClass=function(){var a="grid-stack-static";this.opts.staticGrid===!0?this.container.addClass(a):this.container.removeClass(a)},j.prototype._updateNodeWidths=function(a,b){this.grid._sortNodes(),this.grid.batchUpdate();for(var c={},d=0;d .grid-stack-item { - direction: rtl; -} - .grid-stack .grid-stack-placeholder > .placeholder-content { border: 1px dashed lightgray; margin: 0; @@ -72,22 +64,29 @@ .grid-stack > .grid-stack-item > .ui-resizable-se, .grid-stack > .grid-stack-item > .ui-resizable-sw { - background-image: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iaXNvLTg4NTktMSI/Pgo8IS0tIEdlbmVyYXRvcjogQWRvYmUgSWxsdXN0cmF0b3IgMTYuMC4wLCBTVkcgRXhwb3J0IFBsdWctSW4gLiBTVkcgVmVyc2lvbjogNi4wMCBCdWlsZCAwKSAgLS0+CjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+CjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgdmVyc2lvbj0iMS4xIiBpZD0iQ2FwYV8xIiB4PSIwcHgiIHk9IjBweCIgd2lkdGg9IjE2cHgiIGhlaWdodD0iMTZweCIgdmlld0JveD0iMCAwIDUxMS42MjYgNTExLjYyNyIgc3R5bGU9ImVuYWJsZS1iYWNrZ3JvdW5kOm5ldyAwIDAgNTExLjYyNiA1MTEuNjI3OyIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSI+CjxnPgoJPHBhdGggZD0iTTMyOC45MDYsNDAxLjk5NGgtMzYuNTUzVjEwOS42MzZoMzYuNTUzYzQuOTQ4LDAsOS4yMzYtMS44MDksMTIuODQ3LTUuNDI2YzMuNjEzLTMuNjE1LDUuNDIxLTcuODk4LDUuNDIxLTEyLjg0NSAgIGMwLTQuOTQ5LTEuODAxLTkuMjMxLTUuNDI4LTEyLjg1MWwtNzMuMDg3LTczLjA5QzI2NS4wNDQsMS44MDksMjYwLjc2LDAsMjU1LjgxMywwYy00Ljk0OCwwLTkuMjI5LDEuODA5LTEyLjg0Nyw1LjQyNCAgIGwtNzMuMDg4LDczLjA5Yy0zLjYxOCwzLjYxOS01LjQyNCw3LjkwMi01LjQyNCwxMi44NTFjMCw0Ljk0NiwxLjgwNyw5LjIyOSw1LjQyNCwxMi44NDVjMy42MTksMy42MTcsNy45MDEsNS40MjYsMTIuODUsNS40MjYgICBoMzYuNTQ1djI5Mi4zNThoLTM2LjU0MmMtNC45NTIsMC05LjIzNSwxLjgwOC0xMi44NSw1LjQyMWMtMy42MTcsMy42MjEtNS40MjQsNy45MDUtNS40MjQsMTIuODU0ICAgYzAsNC45NDUsMS44MDcsOS4yMjcsNS40MjQsMTIuODQ3bDczLjA4OSw3My4wODhjMy42MTcsMy42MTcsNy44OTgsNS40MjQsMTIuODQ3LDUuNDI0YzQuOTUsMCw5LjIzNC0xLjgwNywxMi44NDktNS40MjQgICBsNzMuMDg3LTczLjA4OGMzLjYxMy0zLjYyLDUuNDIxLTcuOTAxLDUuNDIxLTEyLjg0N2MwLTQuOTQ4LTEuODA4LTkuMjMyLTUuNDIxLTEyLjg1NCAgIEMzMzguMTQyLDQwMy44MDIsMzMzLjg1Nyw0MDEuOTk0LDMyOC45MDYsNDAxLjk5NHoiIGZpbGw9IiM2NjY2NjYiLz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8L3N2Zz4K); - background-repeat: no-repeat; - background-position: center; - -webkit-transform: rotate(45deg); - -moz-transform: rotate(45deg); - -ms-transform: rotate(45deg); - -o-transform: rotate(45deg); - transform: rotate(45deg); + text-align: right; + color: gray; + padding: 2px 3px 0 0; + margin: 0; + font: normal normal normal 10px/1 FontAwesome; + font-size: inherit; + text-rendering: auto; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +.grid-stack > .grid-stack-item > .ui-resizable-se::before, +.grid-stack > .grid-stack-item > .ui-resizable-sw::before { + content: "\f065"; } .grid-stack > .grid-stack-item > .ui-resizable-se { - -webkit-transform: rotate(-45deg); - -moz-transform: rotate(-45deg); - -ms-transform: rotate(-45deg); - -o-transform: rotate(-45deg); - transform: rotate(-45deg); + display: inline-block; + -webkit-transform: rotate(90deg); + -moz-transform: rotate(90deg); + -ms-transform: rotate(90deg); + -o-transform: rotate(90deg); + transform: rotate(90deg); } .grid-stack > .grid-stack-item > .ui-resizable-nw { @@ -154,10 +153,6 @@ bottom: 15px; } -.grid-stack > .grid-stack-item.ui-draggable-dragging > .ui-resizable-handle { - display: none !important; -} - .grid-stack > .grid-stack-item[data-gs-width='1'] { width: 8.3333333333%; } @@ -369,19 +364,25 @@ transition: left 0s, top 0s, height 0s, width 0s; } -.grid-stack.grid-stack-one-column-mode { - height: auto !important; -} - -.grid-stack.grid-stack-one-column-mode > .grid-stack-item { - position: relative !important; - width: auto !important; - left: 0 !important; - top: auto !important; - margin-bottom: 20px; - max-width: none !important; -} - -.grid-stack.grid-stack-one-column-mode > .grid-stack-item > .ui-resizable-handle { - display: none; +/** Uncomment this to show bottom-left resize handle **/ +/* +.grid-stack > .grid-stack-item > .ui-resizable-sw { + display: inline-block; + @include vendor(transform, rotate(180deg)); +} +*/ +@media (max-width: 768px) { + .grid-stack-item { + position: relative !important; + width: auto !important; + left: 0 !important; + top: auto !important; + margin-bottom: 20px; + } + .grid-stack-item .ui-resizable-handle { + display: none; + } + .grid-stack { + height: auto !important; + } } diff --git a/dist/gridstack.jQueryUI.js b/dist/gridstack.jQueryUI.js deleted file mode 100644 index c5d493615..000000000 --- a/dist/gridstack.jQueryUI.js +++ /dev/null @@ -1,97 +0,0 @@ -/** - * gridstack.js 0.3.0-dev - * http://troolee.github.io/gridstack.js/ - * (c) 2014-2016 Pavel Reznikov, Dylan Weiss - * gridstack.js may be freely distributed under the MIT license. - * @preserve -*/ -(function(factory) { - if (typeof define === 'function' && define.amd) { - define(['jquery', 'lodash', 'gridstack', 'jquery-ui/data', 'jquery-ui/disable-selection', 'jquery-ui/focusable', - 'jquery-ui/form', 'jquery-ui/ie', 'jquery-ui/keycode', 'jquery-ui/labels', 'jquery-ui/jquery-1-7', - 'jquery-ui/plugin', 'jquery-ui/safe-active-element', 'jquery-ui/safe-blur', 'jquery-ui/scroll-parent', - 'jquery-ui/tabbable', 'jquery-ui/unique-id', 'jquery-ui/version', 'jquery-ui/widget', - 'jquery-ui/widgets/mouse', 'jquery-ui/widgets/draggable', 'jquery-ui/widgets/droppable', - 'jquery-ui/widgets/resizable'], factory); - } else if (typeof exports !== 'undefined') { - try { jQuery = require('jquery'); } catch (e) {} - try { _ = require('lodash'); } catch (e) {} - try { GridStackUI = require('gridstack'); } catch (e) {} - factory(jQuery, _, GridStackUI); - } else { - factory(jQuery, _, GridStackUI); - } -})(function($, _, GridStackUI) { - - var scope = window; - - /** - * @class JQueryUIGridStackDragDropPlugin - * jQuery UI implementation of drag'n'drop gridstack plugin. - */ - function JQueryUIGridStackDragDropPlugin(grid) { - GridStackUI.GridStackDragDropPlugin.call(this, grid); - } - - GridStackUI.GridStackDragDropPlugin.registerPlugin(JQueryUIGridStackDragDropPlugin); - - JQueryUIGridStackDragDropPlugin.prototype = Object.create(GridStackUI.GridStackDragDropPlugin.prototype); - JQueryUIGridStackDragDropPlugin.prototype.constructor = JQueryUIGridStackDragDropPlugin; - - JQueryUIGridStackDragDropPlugin.prototype.resizable = function(el, opts) { - el = $(el); - if (opts === 'disable' || opts === 'enable') { - el.resizable(opts); - } else if (opts === 'option') { - var key = arguments[2]; - var value = arguments[3]; - el.resizable(opts, key, value); - } else { - el.resizable(_.extend({}, this.grid.opts.resizable, { - start: opts.start || function() {}, - stop: opts.stop || function() {}, - resize: opts.resize || function() {} - })); - } - return this; - }; - - JQueryUIGridStackDragDropPlugin.prototype.draggable = function(el, opts) { - el = $(el); - if (opts === 'disable' || opts === 'enable') { - el.draggable(opts); - } else { - el.draggable(_.extend({}, this.grid.opts.draggable, { - containment: this.grid.opts.isNested ? this.grid.container.parent() : null, - start: opts.start || function() {}, - stop: opts.stop || function() {}, - drag: opts.drag || function() {} - })); - } - return this; - }; - - JQueryUIGridStackDragDropPlugin.prototype.droppable = function(el, opts) { - el = $(el); - if (opts === 'disable' || opts === 'enable') { - el.droppable(opts); - } else { - el.droppable({ - accept: opts.accept - }); - } - return this; - }; - - JQueryUIGridStackDragDropPlugin.prototype.isDroppable = function(el, opts) { - el = $(el); - return Boolean(el.data('droppable')); - }; - - JQueryUIGridStackDragDropPlugin.prototype.on = function(el, eventName, callback) { - $(el).on(eventName, callback); - return this; - }; - - return JQueryUIGridStackDragDropPlugin; -}); diff --git a/dist/gridstack.jQueryUI.min.js b/dist/gridstack.jQueryUI.min.js deleted file mode 100644 index c8a02504f..000000000 --- a/dist/gridstack.jQueryUI.min.js +++ /dev/null @@ -1,13 +0,0 @@ -/** - * gridstack.js 0.3.0-dev - * http://troolee.github.io/gridstack.js/ - * (c) 2014-2016 Pavel Reznikov, Dylan Weiss - * gridstack.js may be freely distributed under the MIT license. - * @preserve -*/ -!function(a){if("function"==typeof define&&define.amd)define(["jquery","lodash","gridstack","jquery-ui/data","jquery-ui/disable-selection","jquery-ui/focusable","jquery-ui/form","jquery-ui/ie","jquery-ui/keycode","jquery-ui/labels","jquery-ui/jquery-1-7","jquery-ui/plugin","jquery-ui/safe-active-element","jquery-ui/safe-blur","jquery-ui/scroll-parent","jquery-ui/tabbable","jquery-ui/unique-id","jquery-ui/version","jquery-ui/widget","jquery-ui/widgets/mouse","jquery-ui/widgets/draggable","jquery-ui/widgets/droppable","jquery-ui/widgets/resizable"],a);else if("undefined"!=typeof exports){try{jQuery=require("jquery")}catch(a){}try{_=require("lodash")}catch(a){}try{GridStackUI=require("gridstack")}catch(a){}a(jQuery,_,GridStackUI)}else a(jQuery,_,GridStackUI)}(function(a,b,c){/** - * @class JQueryUIGridStackDragDropPlugin - * jQuery UI implementation of drag'n'drop gridstack plugin. - */ -function d(a){c.GridStackDragDropPlugin.call(this,a)}window;return c.GridStackDragDropPlugin.registerPlugin(d),d.prototype=Object.create(c.GridStackDragDropPlugin.prototype),d.prototype.constructor=d,d.prototype.resizable=function(c,d){if(c=a(c),"disable"===d||"enable"===d)c.resizable(d);else if("option"===d){var e=arguments[2],f=arguments[3];c.resizable(d,e,f)}else c.resizable(b.extend({},this.grid.opts.resizable,{start:d.start||function(){},stop:d.stop||function(){},resize:d.resize||function(){}}));return this},d.prototype.draggable=function(c,d){return c=a(c),"disable"===d||"enable"===d?c.draggable(d):c.draggable(b.extend({},this.grid.opts.draggable,{containment:this.grid.opts.isNested?this.grid.container.parent():null,start:d.start||function(){},stop:d.stop||function(){},drag:d.drag||function(){}})),this},d.prototype.droppable=function(b,c){return b=a(b),"disable"===c||"enable"===c?b.droppable(c):b.droppable({accept:c.accept}),this},d.prototype.isDroppable=function(b,c){return b=a(b),Boolean(b.data("droppable"))},d.prototype.on=function(b,c,d){return a(b).on(c,d),this},d}); -//# sourceMappingURL=gridstack.min.map \ No newline at end of file diff --git a/dist/gridstack.js b/dist/gridstack.js old mode 100644 new mode 100755 index 39d250ac2..b187f0629 --- a/dist/gridstack.js +++ b/dist/gridstack.js @@ -1,42 +1,27 @@ -/** - * gridstack.js 0.3.0-dev - * http://troolee.github.io/gridstack.js/ - * (c) 2014-2016 Pavel Reznikov, Dylan Weiss - * gridstack.js may be freely distributed under the MIT license. - * @preserve -*/ +// gridstack.js 0.2.4-dev +// http://troolee.github.io/gridstack.js/ +// (c) 2014-2016 Pavel Reznikov +// gridstack.js may be freely distributed under the MIT license. + (function(factory) { if (typeof define === 'function' && define.amd) { - define(['jquery', 'lodash'], factory); - } else if (typeof exports !== 'undefined') { - try { jQuery = require('jquery'); } catch (e) {} - try { _ = require('lodash'); } catch (e) {} - factory(jQuery, _); - } else { + define(['jquery', 'lodash', 'jquery-ui/core', 'jquery-ui/widget', 'jquery-ui/mouse', 'jquery-ui/draggable', + 'jquery-ui/resizable'], factory); + } + else if (typeof exports !== 'undefined') { + try { jQuery = require('jquery'); } catch(e) {} + try { _ = require('lodash'); } catch(e) {} + factory(jQuery, _); + } + else { factory(jQuery, _); } })(function($, _) { var scope = window; - var obsolete = function(f, oldName, newName) { - var wrapper = function() { - console.warn('gridstack.js: Function `' + oldName + '` is deprecated as of v0.2.5 and has been replaced ' + - 'with `' + newName + '`. It will be **completely** removed in v1.0.'); - return f.apply(this, arguments); - }; - wrapper.prototype = f.prototype; - - return wrapper; - }; - - var obsoleteOpts = function(oldName, newName) { - console.warn('gridstack.js: Option `' + oldName + '` is deprecated as of v0.2.5 and has been replaced with `' + - newName + '`. It will be **completely** removed in v1.0.'); - }; - var Utils = { - isIntercepted: function(a, b) { + is_intercepted: function(a, b) { return !(a.x + a.width <= b.x || b.x + b.width <= a.x || a.y + a.height <= b.y || b.y + b.height <= a.y); }, @@ -46,244 +31,170 @@ return _.sortBy(nodes, function(n) { return dir * (n.x + n.y * width); }); }, - createStylesheet: function(id) { + create_stylesheet: function(id) { var style = document.createElement('style'); style.setAttribute('type', 'text/css'); - style.setAttribute('data-gs-style-id', id); + style.setAttribute('data-gs-id', id); if (style.styleSheet) { style.styleSheet.cssText = ''; - } else { + } + else { style.appendChild(document.createTextNode('')); } document.getElementsByTagName('head')[0].appendChild(style); return style.sheet; }, - - removeStylesheet: function(id) { - $('STYLE[data-gs-style-id=' + id + ']').remove(); + remove_stylesheet: function(id) { + $("STYLE[data-gs-id=" + id +"]").remove(); }, - - insertCSSRule: function(sheet, selector, rules, index) { + insert_css_rule: function(sheet, selector, rules, index) { if (typeof sheet.insertRule === 'function') { sheet.insertRule(selector + '{' + rules + '}', index); - } else if (typeof sheet.addRule === 'function') { + } + else if (typeof sheet.addRule === 'function') { sheet.addRule(selector, rules, index); } }, toBool: function(v) { - if (typeof v == 'boolean') { + if (typeof v == 'boolean') return v; - } if (typeof v == 'string') { v = v.toLowerCase(); - return !(v === '' || v == 'no' || v == 'false' || v == '0'); + return !(v == '' || v == 'no' || v == 'false' || v == '0'); } return Boolean(v); - }, - - _collisionNodeCheck: function(n) { - return n != this.node && Utils.isIntercepted(n, this.nn); - }, - - _didCollide: function(bn) { - return Utils.isIntercepted({x: this.n.x, y: this.newY, width: this.n.width, height: this.n.height}, bn); - }, - - _isAddNodeIntercepted: function(n) { - return Utils.isIntercepted({x: this.x, y: this.y, width: this.node.width, height: this.node.height}, n); - }, - - parseHeight: function(val) { - var height = val; - var heightUnit = 'px'; - if (height && _.isString(height)) { - var match = height.match(/^(-[0-9]+\.[0-9]+|[0-9]*\.[0-9]+|-[0-9]+|[0-9]+)(px|em|rem|vh|vw)?$/); - if (!match) { - throw new Error('Invalid height'); - } - heightUnit = match[2] || 'px'; - height = parseFloat(match[1]); - } - return {height: height, unit: heightUnit}; } }; - // jscs:disable requireCamelCaseOrUpperCaseIdentifiers - Utils.is_intercepted = obsolete(Utils.isIntercepted, 'is_intercepted', 'isIntercepted'); - - Utils.create_stylesheet = obsolete(Utils.createStylesheet, 'create_stylesheet', 'createStylesheet'); - - Utils.remove_stylesheet = obsolete(Utils.removeStylesheet, 'remove_stylesheet', 'removeStylesheet'); - - Utils.insert_css_rule = obsolete(Utils.insertCSSRule, 'insert_css_rule', 'insertCSSRule'); - // jscs:enable requireCamelCaseOrUpperCaseIdentifiers - - /** - * @class GridStackDragDropPlugin - * Base class for drag'n'drop plugin. - */ - function GridStackDragDropPlugin(grid) { - this.grid = grid; - } - - GridStackDragDropPlugin.registeredPlugins = []; - - GridStackDragDropPlugin.registerPlugin = function(pluginClass) { - GridStackDragDropPlugin.registeredPlugins.push(pluginClass); - }; - - GridStackDragDropPlugin.prototype.resizable = function(el, opts) { - return this; - }; + var id_seq = 0; - GridStackDragDropPlugin.prototype.draggable = function(el, opts) { - return this; - }; - - GridStackDragDropPlugin.prototype.droppable = function(el, opts) { - return this; - }; - - GridStackDragDropPlugin.prototype.isDroppable = function(el) { - return false; - }; - - GridStackDragDropPlugin.prototype.on = function(el, eventName, callback) { - return this; - }; - - - var idSeq = 0; - - var GridStackEngine = function(width, onchange, floatMode, height, items) { + var GridStackEngine = function(width, onchange, float_mode, height, items) { this.width = width; - this.float = floatMode || false; + this['float'] = float_mode || false; this.height = height || 0; this.nodes = items || []; this.onchange = onchange || function() {}; - this._updateCounter = 0; - this._float = this.float; - - this._addedNodes = []; - this._removedNodes = []; + this._update_counter = 0; + this._float = this['float']; }; - GridStackEngine.prototype.batchUpdate = function() { - this._updateCounter = 1; + GridStackEngine.prototype.batch_update = function() { + this._update_counter = 1; this.float = true; }; GridStackEngine.prototype.commit = function() { - if (this._updateCounter !== 0) { - this._updateCounter = 0; + this._update_counter = 0; + if (this._update_counter == 0) { this.float = this._float; - this._packNodes(); + this._pack_nodes(); this._notify(); } }; - // For Meteor support: https://github.com/troolee/gridstack.js/pull/272 - GridStackEngine.prototype.getNodeDataByDOMEl = function(el) { - return _.find(this.nodes, function(n) { return el.get(0) === n.el.get(0); }); - }; + GridStackEngine.prototype._fix_collisions = function(node) { + this._sort_nodes(-1); - GridStackEngine.prototype._fixCollisions = function(node) { - var self = this; - this._sortNodes(-1); - - var nn = node; - var hasLocked = Boolean(_.find(this.nodes, function(n) { return n.locked; })); - if (!this.float && !hasLocked) { + var nn = node, has_locked = Boolean(_.find(this.nodes, function(n) { return n.locked })); + if (!this.float && !has_locked) { nn = {x: 0, y: node.y, width: this.width, height: node.height}; } + while (true) { - var collisionNode = _.find(this.nodes, _.bind(Utils._collisionNodeCheck, {node: node, nn: nn})); - if (typeof collisionNode == 'undefined') { + var collision_node = _.find(this.nodes, _.bind(function(n) { + return n != node && Utils.is_intercepted(n, nn); + }, this)); + if (typeof collision_node == 'undefined') { return; } - this.moveNode(collisionNode, collisionNode.x, node.y + node.height, - collisionNode.width, collisionNode.height, true); + this.move_node(collision_node, collision_node.x, node.y + node.height, + collision_node.width, collision_node.height, true); } }; - GridStackEngine.prototype.isAreaEmpty = function(x, y, width, height) { + GridStackEngine.prototype.is_area_empty = function(x, y, width, height) { var nn = {x: x || 0, y: y || 0, width: width || 1, height: height || 1}; - var collisionNode = _.find(this.nodes, _.bind(function(n) { - return Utils.isIntercepted(n, nn); + var collision_node = _.find(this.nodes, _.bind(function(n) { + return Utils.is_intercepted(n, nn); }, this)); - return collisionNode === null || typeof collisionNode === 'undefined'; + return collision_node == null; }; - GridStackEngine.prototype._sortNodes = function(dir) { + GridStackEngine.prototype._sort_nodes = function(dir) { this.nodes = Utils.sort(this.nodes, dir, this.width); }; - GridStackEngine.prototype._packNodes = function() { - this._sortNodes(); + GridStackEngine.prototype._pack_nodes = function() { + this._sort_nodes(); if (this.float) { _.each(this.nodes, _.bind(function(n, i) { - if (n._updating || typeof n._origY == 'undefined' || n.y == n._origY) { + if (n._updating || typeof n._orig_y == 'undefined' || n.y == n._orig_y) return; - } - var newY = n.y; - while (newY >= n._origY) { - var collisionNode = _.chain(this.nodes) - .find(_.bind(Utils._didCollide, {n: n, newY: newY})) + var new_y = n.y; + while (new_y >= n._orig_y) { + var collision_node = _.chain(this.nodes) + .find(function(bn) { + return n != bn && + Utils.is_intercepted({x: n.x, y: new_y, width: n.width, height: n.height}, bn); + }) .value(); - if (!collisionNode) { + if (!collision_node) { n._dirty = true; - n.y = newY; + n.y = new_y; } - --newY; + --new_y; } }, this)); - } else { + } + else { _.each(this.nodes, _.bind(function(n, i) { - if (n.locked) { + if (n.locked) return; - } while (n.y > 0) { - var newY = n.y - 1; - var canBeMoved = i === 0; + var new_y = n.y - 1; + var can_be_moved = i == 0; if (i > 0) { - var collisionNode = _.chain(this.nodes) + var collision_node = _.chain(this.nodes) .take(i) - .find(_.bind(Utils._didCollide, {n: n, newY: newY})) + .find(function(bn) { + return Utils.is_intercepted({x: n.x, y: new_y, width: n.width, height: n.height}, bn); + }) .value(); - canBeMoved = typeof collisionNode == 'undefined'; + can_be_moved = typeof collision_node == 'undefined'; } - if (!canBeMoved) { + if (!can_be_moved) { break; } - n._dirty = n.y != newY; - n.y = newY; + n._dirty = n.y != new_y; + n.y = new_y; } }, this)); } }; - GridStackEngine.prototype._prepareNode = function(node, resizing) { - node = _.defaults(node || {}, {width: 1, height: 1, x: 0, y: 0}); + GridStackEngine.prototype._prepare_node = function(node, resizing) { + node = _.defaults(node || {}, {width: 1, height: 1, x: 0, y: 0 }); node.x = parseInt('' + node.x); node.y = parseInt('' + node.y); node.width = parseInt('' + node.width); node.height = parseInt('' + node.height); - node.autoPosition = node.autoPosition || false; - node.noResize = node.noResize || false; - node.noMove = node.noMove || false; + node.auto_position = node.auto_position || false; + node.no_resize = node.no_resize || false; + node.no_move = node.no_move || false; if (node.width > this.width) { node.width = this.width; - } else if (node.width < 1) { + } + else if (node.width < 1) { node.width = 1; } @@ -298,7 +209,8 @@ if (node.x + node.width > this.width) { if (resizing) { node.width = this.width - node.x; - } else { + } + else { node.x = this.width - node.width; } } @@ -311,48 +223,44 @@ }; GridStackEngine.prototype._notify = function() { - var args = Array.prototype.slice.call(arguments, 0); - args[0] = typeof args[0] === 'undefined' ? [] : [args[0]]; - args[1] = typeof args[1] === 'undefined' ? true : args[1]; - if (this._updateCounter) { + if (this._update_counter) { return; } - var deletedNodes = args[0].concat(this.getDirtyNodes()); - this.onchange(deletedNodes, args[1]); + var deleted_nodes = Array.prototype.slice.call(arguments, 1).concat(this.get_dirty_nodes()); + deleted_nodes = deleted_nodes.concat(this.get_dirty_nodes()); + this.onchange(deleted_nodes); }; - GridStackEngine.prototype.cleanNodes = function() { - if (this._updateCounter) { - return; - } - _.each(this.nodes, function(n) {n._dirty = false; }); + GridStackEngine.prototype.clean_nodes = function() { + _.each(this.nodes, function(n) {n._dirty = false }); }; - GridStackEngine.prototype.getDirtyNodes = function() { + GridStackEngine.prototype.get_dirty_nodes = function() { return _.filter(this.nodes, function(n) { return n._dirty; }); }; - GridStackEngine.prototype.addNode = function(node, triggerAddEvent) { - node = this._prepareNode(node); + GridStackEngine.prototype.add_node = function(node) { + node = this._prepare_node(node); - if (typeof node.maxWidth != 'undefined') { node.width = Math.min(node.width, node.maxWidth); } - if (typeof node.maxHeight != 'undefined') { node.height = Math.min(node.height, node.maxHeight); } - if (typeof node.minWidth != 'undefined') { node.width = Math.max(node.width, node.minWidth); } - if (typeof node.minHeight != 'undefined') { node.height = Math.max(node.height, node.minHeight); } + if (typeof node.max_width != 'undefined') node.width = Math.min(node.width, node.max_width); + if (typeof node.max_height != 'undefined') node.height = Math.min(node.height, node.max_height); + if (typeof node.min_width != 'undefined') node.width = Math.max(node.width, node.min_width); + if (typeof node.min_height != 'undefined') node.height = Math.max(node.height, node.min_height); - node._id = ++idSeq; + node._id = ++id_seq; node._dirty = true; - if (node.autoPosition) { - this._sortNodes(); + if (node.auto_position) { + this._sort_nodes(); for (var i = 0;; ++i) { - var x = i % this.width; - var y = Math.floor(i / this.width); + var x = i % this.width, y = Math.floor(i / this.width); if (x + node.width > this.width) { continue; } - if (!_.find(this.nodes, _.bind(Utils._isAddNodeIntercepted, {x: x, y: y, node: node}))) { + if (!_.find(this.nodes, function(n) { + return Utils.is_intercepted({x: x, y: y, width: node.width, height: node.height}, n); + })) { node.x = x; node.y = y; break; @@ -361,36 +269,27 @@ } this.nodes.push(node); - if (typeof triggerAddEvent != 'undefined' && triggerAddEvent) { - this._addedNodes.push(_.clone(node)); - } - this._fixCollisions(node); - this._packNodes(); + this._fix_collisions(node); + this._pack_nodes(); this._notify(); return node; }; - GridStackEngine.prototype.removeNode = function(node, detachNode) { - detachNode = typeof detachNode === 'undefined' ? true : detachNode; - this._removedNodes.push(_.clone(node)); + GridStackEngine.prototype.remove_node = function(node) { node._id = null; this.nodes = _.without(this.nodes, node); - this._packNodes(); - this._notify(node, detachNode); + this._pack_nodes(); + this._notify(node); }; - GridStackEngine.prototype.canMoveNode = function(node, x, y, width, height) { - if (!this.isNodeChangedPosition(node, x, y, width, height)) { - return false; - } - var hasLocked = Boolean(_.find(this.nodes, function(n) { return n.locked; })); + GridStackEngine.prototype.can_move_node = function(node, x, y, width, height) { + var has_locked = Boolean(_.find(this.nodes, function(n) { return n.locked })); - if (!this.height && !hasLocked) { + if (!this.height && !has_locked) return true; - } - var clonedNode; + var cloned_node; var clone = new GridStackEngine( this.width, null, @@ -398,77 +297,50 @@ 0, _.map(this.nodes, function(n) { if (n == node) { - clonedNode = $.extend({}, n); - return clonedNode; + cloned_node = $.extend({}, n); + return cloned_node; } return $.extend({}, n); })); - if (typeof clonedNode === 'undefined') { - return true; - } - - clone.moveNode(clonedNode, x, y, width, height); + clone.move_node(cloned_node, x, y, width, height); var res = true; - if (hasLocked) { + if (has_locked) res &= !Boolean(_.find(clone.nodes, function(n) { - return n != clonedNode && Boolean(n.locked) && Boolean(n._dirty); + return n != cloned_node && Boolean(n.locked) && Boolean(n._dirty); })); - } - if (this.height) { - res &= clone.getGridHeight() <= this.height; - } + if (this.height) + res &= clone.get_grid_height() <= this.height; return res; }; - GridStackEngine.prototype.canBePlacedWithRespectToHeight = function(node) { - if (!this.height) { + GridStackEngine.prototype.can_be_placed_with_respect_to_height = function(node) { + if (!this.height) return true; - } var clone = new GridStackEngine( this.width, null, this.float, 0, - _.map(this.nodes, function(n) { return $.extend({}, n); })); - clone.addNode(node); - return clone.getGridHeight() <= this.height; - }; - - GridStackEngine.prototype.isNodeChangedPosition = function(node, x, y, width, height) { - if (typeof x != 'number') { x = node.x; } - if (typeof y != 'number') { y = node.y; } - if (typeof width != 'number') { width = node.width; } - if (typeof height != 'number') { height = node.height; } - - if (typeof node.maxWidth != 'undefined') { width = Math.min(width, node.maxWidth); } - if (typeof node.maxHeight != 'undefined') { height = Math.min(height, node.maxHeight); } - if (typeof node.minWidth != 'undefined') { width = Math.max(width, node.minWidth); } - if (typeof node.minHeight != 'undefined') { height = Math.max(height, node.minHeight); } - - if (node.x == x && node.y == y && node.width == width && node.height == height) { - return false; - } - return true; + _.map(this.nodes, function(n) { return $.extend({}, n) })); + clone.add_node(node); + return clone.get_grid_height() <= this.height; }; - GridStackEngine.prototype.moveNode = function(node, x, y, width, height, noPack) { - if (!this.isNodeChangedPosition(node, x, y, width, height)) { - return node; - } - if (typeof x != 'number') { x = node.x; } - if (typeof y != 'number') { y = node.y; } - if (typeof width != 'number') { width = node.width; } - if (typeof height != 'number') { height = node.height; } + GridStackEngine.prototype.move_node = function(node, x, y, width, height, no_pack) { + if (typeof x != 'number') x = node.x; + if (typeof y != 'number') y = node.y; + if (typeof width != 'number') width = node.width; + if (typeof height != 'number') height = node.height; - if (typeof node.maxWidth != 'undefined') { width = Math.min(width, node.maxWidth); } - if (typeof node.maxHeight != 'undefined') { height = Math.min(height, node.maxHeight); } - if (typeof node.minWidth != 'undefined') { width = Math.max(width, node.minWidth); } - if (typeof node.minHeight != 'undefined') { height = Math.max(height, node.minHeight); } + if (typeof node.max_width != 'undefined') width = Math.min(width, node.max_width); + if (typeof node.max_height != 'undefined') height = Math.min(height, node.max_height); + if (typeof node.min_width != 'undefined') width = Math.max(width, node.min_width); + if (typeof node.min_height != 'undefined') height = Math.max(height, node.min_height); if (node.x == x && node.y == y && node.width == width && node.height == height) { return node; @@ -482,35 +354,30 @@ node.width = width; node.height = height; - node.lastTriedX = x; - node.lastTriedY = y; - node.lastTriedWidth = width; - node.lastTriedHeight = height; - - node = this._prepareNode(node, resizing); + node = this._prepare_node(node, resizing); - this._fixCollisions(node); - if (!noPack) { - this._packNodes(); + this._fix_collisions(node); + if (!no_pack) { + this._pack_nodes(); this._notify(); } return node; }; - GridStackEngine.prototype.getGridHeight = function() { + GridStackEngine.prototype.get_grid_height = function() { return _.reduce(this.nodes, function(memo, n) { return Math.max(memo, n.y + n.height); }, 0); }; - GridStackEngine.prototype.beginUpdate = function(node) { + GridStackEngine.prototype.begin_update = function(node) { _.each(this.nodes, function(n) { - n._origY = n.y; + n._orig_y = n.y; }); node._updating = true; }; - GridStackEngine.prototype.endUpdate = function() { + GridStackEngine.prototype.end_update = function() { _.each(this.nodes, function(n) { - n._origY = n.y; + n._orig_y = n.y; }); var n = _.find(this.nodes, function(n) { return n._updating; }); if (n) { @@ -519,158 +386,76 @@ }; var GridStack = function(el, opts) { - var self = this; - var oneColumnMode, isAutoCellHeight; + var self = this, one_column_mode; opts = opts || {}; this.container = $(el); - // jscs:disable requireCamelCaseOrUpperCaseIdentifiers - if (typeof opts.handle_class !== 'undefined') { - opts.handleClass = opts.handle_class; - obsoleteOpts('handle_class', 'handleClass'); - } - if (typeof opts.item_class !== 'undefined') { - opts.itemClass = opts.item_class; - obsoleteOpts('item_class', 'itemClass'); - } - if (typeof opts.placeholder_class !== 'undefined') { - opts.placeholderClass = opts.placeholder_class; - obsoleteOpts('placeholder_class', 'placeholderClass'); - } - if (typeof opts.placeholder_text !== 'undefined') { - opts.placeholderText = opts.placeholder_text; - obsoleteOpts('placeholder_text', 'placeholderText'); - } - if (typeof opts.cell_height !== 'undefined') { - opts.cellHeight = opts.cell_height; - obsoleteOpts('cell_height', 'cellHeight'); - } - if (typeof opts.vertical_margin !== 'undefined') { - opts.verticalMargin = opts.vertical_margin; - obsoleteOpts('vertical_margin', 'verticalMargin'); - } - if (typeof opts.min_width !== 'undefined') { - opts.minWidth = opts.min_width; - obsoleteOpts('min_width', 'minWidth'); - } - if (typeof opts.static_grid !== 'undefined') { - opts.staticGrid = opts.static_grid; - obsoleteOpts('static_grid', 'staticGrid'); - } - if (typeof opts.is_nested !== 'undefined') { - opts.isNested = opts.is_nested; - obsoleteOpts('is_nested', 'isNested'); - } - if (typeof opts.always_show_resize_handle !== 'undefined') { - opts.alwaysShowResizeHandle = opts.always_show_resize_handle; - obsoleteOpts('always_show_resize_handle', 'alwaysShowResizeHandle'); - } - // jscs:enable requireCamelCaseOrUpperCaseIdentifiers - - opts.itemClass = opts.itemClass || 'grid-stack-item'; - var isNested = this.container.closest('.' + opts.itemClass).length > 0; + opts.item_class = opts.item_class || 'grid-stack-item'; + var is_nested = this.container.closest('.' + opts.item_class).size() > 0; this.opts = _.defaults(opts || {}, { width: parseInt(this.container.attr('data-gs-width')) || 12, height: parseInt(this.container.attr('data-gs-height')) || 0, - itemClass: 'grid-stack-item', - placeholderClass: 'grid-stack-placeholder', - placeholderText: '', + item_class: 'grid-stack-item', + placeholder_class: 'grid-stack-placeholder', + placeholder_text: '', handle: '.grid-stack-item-content', - handleClass: null, - cellHeight: 60, - verticalMargin: 20, + handle_class: null, + cell_height: 60, + vertical_margin: 20, auto: true, - minWidth: 768, + min_width: 768, float: false, - staticGrid: false, + static_grid: false, _class: 'grid-stack-instance-' + (Math.random() * 10000).toFixed(0), animate: Boolean(this.container.attr('data-gs-animate')) || false, - alwaysShowResizeHandle: opts.alwaysShowResizeHandle || false, + always_show_resize_handle: opts.always_show_resize_handle || false, resizable: _.defaults(opts.resizable || {}, { - autoHide: !(opts.alwaysShowResizeHandle || false), + autoHide: !(opts.always_show_resize_handle || false), handles: 'se' }), draggable: _.defaults(opts.draggable || {}, { - handle: (opts.handleClass ? '.' + opts.handleClass : (opts.handle ? opts.handle : '')) || - '.grid-stack-item-content', + handle: (opts.handle_class ? '.' + opts.handle_class : (opts.handle ? opts.handle : '')) || '.grid-stack-item-content', scroll: false, appendTo: 'body' - }), - disableDrag: opts.disableDrag || false, - disableResize: opts.disableResize || false, - rtl: 'auto', - removable: false, - removeTimeout: 2000, - verticalMarginUnit: 'px', - cellHeightUnit: 'px', - oneColumnModeClass: opts.oneColumnModeClass || 'grid-stack-one-column-mode', - ddPlugin: null + }) }); - - if (this.opts.ddPlugin === false) { - this.opts.ddPlugin = GridStackDragDropPlugin; - } else if (this.opts.ddPlugin === null) { - this.opts.ddPlugin = _.first(GridStackDragDropPlugin.registeredPlugins) || GridStackDragDropPlugin; - } - - this.dd = new this.opts.ddPlugin(this); - - if (this.opts.rtl === 'auto') { - this.opts.rtl = this.container.css('direction') === 'rtl'; - } - - if (this.opts.rtl) { - this.container.addClass('grid-stack-rtl'); - } - - this.opts.isNested = isNested; - - isAutoCellHeight = this.opts.cellHeight === 'auto'; - if (isAutoCellHeight) { - self.cellHeight(self.cellWidth(), true); - } else { - this.cellHeight(this.opts.cellHeight, true); - } - this.verticalMargin(this.opts.verticalMargin, true); + this.opts.is_nested = is_nested; this.container.addClass(this.opts._class); - this._setStaticClass(); + this._set_static_class(); - if (isNested) { + if (is_nested) { this.container.addClass('grid-stack-nested'); } - this._initStyles(); + this._init_styles(); - this.grid = new GridStackEngine(this.opts.width, function(nodes, detachNode) { - detachNode = typeof detachNode === 'undefined' ? true : detachNode; - var maxHeight = 0; + this.grid = new GridStackEngine(this.opts.width, function(nodes) { + var max_height = 0; _.each(nodes, function(n) { - if (detachNode && n._id === null) { - if (n.el) { - n.el.remove(); - } - } else { + if (n._id == null) { + n.el.remove(); + } + else { n.el .attr('data-gs-x', n.x) .attr('data-gs-y', n.y) .attr('data-gs-width', n.width) .attr('data-gs-height', n.height); - maxHeight = Math.max(maxHeight, n.y + n.height); + max_height = Math.max(max_height, n.y + n.height); } }); - self._updateStyles(maxHeight + 10); + self._update_styles(max_height + 10); }, this.opts.float, this.opts.height); if (this.opts.auto) { var elements = []; var _this = this; - this.container.children('.' + this.opts.itemClass + ':not(.' + this.opts.placeholderClass + ')') - .each(function(index, el) { + this.container.children('.' + this.opts.item_class + ':not(.' + this.opts.placeholder_class + ')').each(function(index, el) { el = $(el); elements.push({ el: el, @@ -678,216 +463,69 @@ }); }); _.chain(elements).sortBy(function(x) { return x.i; }).each(function(i) { - self._prepareElement(i.el); + self._prepare_element(i.el); }).value(); } - this.setAnimation(this.opts.animate); + this.set_animation(this.opts.animate); this.placeholder = $( - '
' + - '
' + this.opts.placeholderText + '
').hide(); + '
' + + '
' + this.opts.placeholder_text + '
').hide(); - this._updateContainerHeight(); + this.container.height( + this.grid.get_grid_height() * (this.opts.cell_height + this.opts.vertical_margin) - + this.opts.vertical_margin); - this._updateHeightsOnResize = _.throttle(function() { - self.cellHeight(self.cellWidth(), false); - }, 100); - - this.onResizeHandler = function() { - if (isAutoCellHeight) { - self._updateHeightsOnResize(); - } - - if (self._isOneColumnMode()) { - if (oneColumnMode) { + this.on_resize_handler = function() { + if (self._is_one_column_mode()) { + if (one_column_mode) return; - } - self.container.addClass(self.opts.oneColumnModeClass); - oneColumnMode = true; - self.grid._sortNodes(); + one_column_mode = true; + + self.grid._sort_nodes(); _.each(self.grid.nodes, function(node) { self.container.append(node.el); - if (self.opts.staticGrid) { + if (self.opts.static_grid) { return; } - if (node.noMove || self.opts.disableDrag) { - self.dd.draggable(node.el, 'disable'); + if (!node.no_move) { + node.el.draggable('disable'); } - if (node.noResize || self.opts.disableResize) { - self.dd.resizable(node.el, 'disable'); + if (!node.no_resize) { + node.el.resizable('disable'); } - - node.el.trigger('resize'); }); - } else { - if (!oneColumnMode) { + } + else { + if (!one_column_mode) return; - } - self.container.removeClass(self.opts.oneColumnModeClass); - oneColumnMode = false; + one_column_mode = false; - if (self.opts.staticGrid) { + if (self.opts.static_grid) { return; } _.each(self.grid.nodes, function(node) { - if (!node.noMove && !self.opts.disableDrag) { - self.dd.draggable(node.el, 'enable'); + if (!node.no_move) { + node.el.draggable('enable'); } - if (!node.noResize && !self.opts.disableResize) { - self.dd.resizable(node.el, 'enable'); + if (!node.no_resize) { + node.el.resizable('enable'); } - - node.el.trigger('resize'); }); } }; - $(window).resize(this.onResizeHandler); - this.onResizeHandler(); - - if (!self.opts.staticGrid && typeof self.opts.removable === 'string') { - var trashZone = $(self.opts.removable); - if (!this.dd.isDroppable(trashZone)) { - this.dd.droppable(trashZone, { - accept: '.' + self.opts.itemClass - }); - } - this.dd - .on(trashZone, 'dropover', function(event, ui) { - var el = $(ui.draggable); - var node = el.data('_gridstack_node'); - if (node._grid !== self) { - return; - } - self._setupRemovingTimeout(el); - }) - .on(trashZone, 'dropout', function(event, ui) { - var el = $(ui.draggable); - var node = el.data('_gridstack_node'); - if (node._grid !== self) { - return; - } - self._clearRemovingTimeout(el); - }); - } - - if (!self.opts.staticGrid && self.opts.acceptWidgets) { - var draggingElement = null; - - var onDrag = function(event, ui) { - var el = draggingElement; - var node = el.data('_gridstack_node'); - var pos = self.getCellFromPixel(ui.offset, true); - var x = Math.max(0, pos.x); - var y = Math.max(0, pos.y); - if (!node._added) { - node._added = true; - - node.el = el; - node.x = x; - node.y = y; - self.grid.cleanNodes(); - self.grid.beginUpdate(node); - self.grid.addNode(node); - - self.container.append(self.placeholder); - self.placeholder - .attr('data-gs-x', node.x) - .attr('data-gs-y', node.y) - .attr('data-gs-width', node.width) - .attr('data-gs-height', node.height) - .show(); - node.el = self.placeholder; - node._beforeDragX = node.x; - node._beforeDragY = node.y; - - self._updateContainerHeight(); - } else { - if (!self.grid.canMoveNode(node, x, y)) { - return; - } - self.grid.moveNode(node, x, y); - self._updateContainerHeight(); - } - }; - - this.dd - .droppable(self.container, { - accept: function(el) { - el = $(el); - var node = el.data('_gridstack_node'); - if (node && node._grid === self) { - return false; - } - return el.is(self.opts.acceptWidgets === true ? '.grid-stack-item' : self.opts.acceptWidgets); - } - }) - .on(self.container, 'dropover', function(event, ui) { - var offset = self.container.offset(); - var el = $(ui.draggable); - var cellWidth = self.cellWidth(); - var cellHeight = self.cellHeight(); - var origNode = el.data('_gridstack_node'); - - var width = origNode ? origNode.width : (Math.ceil(el.outerWidth() / cellWidth)); - var height = origNode ? origNode.height : (Math.ceil(el.outerHeight() / cellHeight)); - - draggingElement = el; - - var node = self.grid._prepareNode({width: width, height: height, _added: false, _temporary: true}); - el.data('_gridstack_node', node); - el.data('_gridstack_node_orig', origNode); - - el.on('drag', onDrag); - }) - .on(self.container, 'dropout', function(event, ui) { - var el = $(ui.draggable); - el.unbind('drag', onDrag); - var node = el.data('_gridstack_node'); - node.el = null; - self.grid.removeNode(node); - self.placeholder.detach(); - self._updateContainerHeight(); - el.data('_gridstack_node', el.data('_gridstack_node_orig')); - }) - .on(self.container, 'drop', function(event, ui) { - self.placeholder.detach(); - - var node = $(ui.draggable).data('_gridstack_node'); - node._grid = self; - var el = $(ui.draggable).clone(false); - el.data('_gridstack_node', node); - $(ui.draggable).remove(); - node.el = el; - self.placeholder.hide(); - el - .attr('data-gs-x', node.x) - .attr('data-gs-y', node.y) - .attr('data-gs-width', node.width) - .attr('data-gs-height', node.height) - .addClass(self.opts.itemClass) - .removeAttr('style') - .enableSelection() - .removeData('draggable') - .removeClass('ui-draggable ui-draggable-dragging ui-draggable-disabled') - .unbind('drag', onDrag); - self.container.append(el); - self._prepareElementsByNode(el, node); - self._updateContainerHeight(); - self._triggerChangeEvent(); - - self.grid.endUpdate(); - }); - } + $(window).resize(this.on_resize_handler); + this.on_resize_handler(); }; - GridStack.prototype._triggerChangeEvent = function(forceTrigger) { - var elements = this.grid.getDirtyNodes(); + GridStack.prototype._trigger_change_event = function(forceTrigger) { + var elements = this.grid.get_dirty_nodes(); var hasChanges = false; var eventParams = []; @@ -901,229 +539,126 @@ } }; - GridStack.prototype._triggerAddEvent = function() { - if (this.grid._addedNodes && this.grid._addedNodes.length > 0) { - this.container.trigger('added', [_.map(this.grid._addedNodes, _.clone)]); - this.grid._addedNodes = []; + GridStack.prototype._init_styles = function() { + if (this._styles_id) { + $('[data-gs-id="' + this._styles_id + '"]').remove(); } - }; - - GridStack.prototype._triggerRemoveEvent = function() { - if (this.grid._removedNodes && this.grid._removedNodes.length > 0) { - this.container.trigger('removed', [_.map(this.grid._removedNodes, _.clone)]); - this.grid._removedNodes = []; - } - }; - - GridStack.prototype._initStyles = function() { - if (this._stylesId) { - Utils.removeStylesheet(this._stylesId); - } - this._stylesId = 'gridstack-style-' + (Math.random() * 100000).toFixed(); - this._styles = Utils.createStylesheet(this._stylesId); - if (this._styles !== null) { + this._styles_id = 'gridstack-style-' + (Math.random() * 100000).toFixed(); + this._styles = Utils.create_stylesheet(this._styles_id); + if (this._styles != null) this._styles._max = 0; - } }; - GridStack.prototype._updateStyles = function(maxHeight) { - if (this._styles === null || typeof this._styles === 'undefined') { + GridStack.prototype._update_styles = function(max_height) { + if (this._styles == null) { return; } - var prefix = '.' + this.opts._class + ' .' + this.opts.itemClass; - var self = this; - var getHeight; - - if (typeof maxHeight == 'undefined') { - maxHeight = this._styles._max; - this._initStyles(); - this._updateContainerHeight(); - } - if (!this.opts.cellHeight) { // The rest will be handled by CSS - return ; - } - if (this._styles._max !== 0 && maxHeight <= this._styles._max) { - return ; - } + var prefix = '.' + this.opts._class + ' .' + this.opts.item_class; - if (!this.opts.verticalMargin || this.opts.cellHeightUnit === this.opts.verticalMarginUnit) { - getHeight = function(nbRows, nbMargins) { - return (self.opts.cellHeight * nbRows + self.opts.verticalMargin * nbMargins) + - self.opts.cellHeightUnit; - }; - } else { - getHeight = function(nbRows, nbMargins) { - if (!nbRows || !nbMargins) { - return (self.opts.cellHeight * nbRows + self.opts.verticalMargin * nbMargins) + - self.opts.cellHeightUnit; - } - return 'calc(' + ((self.opts.cellHeight * nbRows) + self.opts.cellHeightUnit) + ' + ' + - ((self.opts.verticalMargin * nbMargins) + self.opts.verticalMarginUnit) + ')'; - }; + if (typeof max_height == 'undefined') { + max_height = this._styles._max; + this._init_styles(); + this._update_container_height(); } - if (this._styles._max === 0) { - Utils.insertCSSRule(this._styles, prefix, 'min-height: ' + getHeight(1, 0) + ';', 0); + if (this._styles._max == 0) { + Utils.insert_css_rule(this._styles, prefix, 'min-height: ' + (this.opts.cell_height) + 'px;', 0); } - if (maxHeight > this._styles._max) { - for (var i = this._styles._max; i < maxHeight; ++i) { - Utils.insertCSSRule(this._styles, + if (max_height > this._styles._max) { + for (var i = this._styles._max; i < max_height; ++i) { + Utils.insert_css_rule(this._styles, prefix + '[data-gs-height="' + (i + 1) + '"]', - 'height: ' + getHeight(i + 1, i) + ';', + 'height: ' + (this.opts.cell_height * (i + 1) + this.opts.vertical_margin * i) + 'px;', i ); - Utils.insertCSSRule(this._styles, + Utils.insert_css_rule(this._styles, prefix + '[data-gs-min-height="' + (i + 1) + '"]', - 'min-height: ' + getHeight(i + 1, i) + ';', + 'min-height: ' + (this.opts.cell_height * (i + 1) + this.opts.vertical_margin * i) + 'px;', i ); - Utils.insertCSSRule(this._styles, + Utils.insert_css_rule(this._styles, prefix + '[data-gs-max-height="' + (i + 1) + '"]', - 'max-height: ' + getHeight(i + 1, i) + ';', + 'max-height: ' + (this.opts.cell_height * (i + 1) + this.opts.vertical_margin * i) + 'px;', i ); - Utils.insertCSSRule(this._styles, + Utils.insert_css_rule(this._styles, prefix + '[data-gs-y="' + i + '"]', - 'top: ' + getHeight(i, i) + ';', + 'top: ' + (this.opts.cell_height * i + this.opts.vertical_margin * i) + 'px;', i ); } - this._styles._max = maxHeight; + this._styles._max = max_height; } }; - GridStack.prototype._updateContainerHeight = function() { - if (this.grid._updateCounter) { + GridStack.prototype._update_container_height = function() { + if (this.grid._update_counter) { return; } - var height = this.grid.getGridHeight(); - this.container.attr('data-gs-current-height', height); - if (!this.opts.cellHeight) { - return ; - } - if (!this.opts.verticalMargin) { - this.container.css('height', (height * (this.opts.cellHeight)) + this.opts.cellHeightUnit); - } else if (this.opts.cellHeightUnit === this.opts.verticalMarginUnit) { - this.container.css('height', (height * (this.opts.cellHeight + this.opts.verticalMargin) - - this.opts.verticalMargin) + this.opts.cellHeightUnit); - } else { - this.container.css('height', 'calc(' + ((height * (this.opts.cellHeight)) + this.opts.cellHeightUnit) + - ' + ' + ((height * (this.opts.verticalMargin - 1)) + this.opts.verticalMarginUnit) + ')'); - } + this.container.height( + this.grid.get_grid_height() * (this.opts.cell_height + this.opts.vertical_margin) - + this.opts.vertical_margin); }; - GridStack.prototype._isOneColumnMode = function() { + GridStack.prototype._is_one_column_mode = function() { return (window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth) <= - this.opts.minWidth; + this.opts.min_width; }; - GridStack.prototype._setupRemovingTimeout = function(el) { + GridStack.prototype._prepare_element = function(el) { var self = this; - var node = $(el).data('_gridstack_node'); - - if (node._removeTimeout || !self.opts.removable) { - return; - } - node._removeTimeout = setTimeout(function() { - el.addClass('grid-stack-item-removing'); - node._isAboutToRemove = true; - }, self.opts.removeTimeout); - }; + el = $(el); - GridStack.prototype._clearRemovingTimeout = function(el) { - var node = $(el).data('_gridstack_node'); + el.addClass(this.opts.item_class); - if (!node._removeTimeout) { - return; - } - clearTimeout(node._removeTimeout); - node._removeTimeout = null; - el.removeClass('grid-stack-item-removing'); - node._isAboutToRemove = false; - }; + var node = self.grid.add_node({ + x: el.attr('data-gs-x'), + y: el.attr('data-gs-y'), + width: el.attr('data-gs-width'), + height: el.attr('data-gs-height'), + max_width: el.attr('data-gs-max-width'), + min_width: el.attr('data-gs-min-width'), + max_height: el.attr('data-gs-max-height'), + min_height: el.attr('data-gs-min-height'), + auto_position: Utils.toBool(el.attr('data-gs-auto-position')), + no_resize: Utils.toBool(el.attr('data-gs-no-resize')), + no_move: Utils.toBool(el.attr('data-gs-no-move')), + locked: Utils.toBool(el.attr('data-gs-locked')), + el: el + }); + el.data('_gridstack_node', node); - GridStack.prototype._prepareElementsByNode = function(el, node) { - if (typeof $.ui === 'undefined') { + if (self.opts.static_grid) { return; } - var self = this; - var cellWidth; - var cellHeight; + var cell_width, cell_height; - var dragOrResize = function(event, ui) { - var x = Math.round(ui.position.left / cellWidth); - var y = Math.floor((ui.position.top + cellHeight / 2) / cellHeight); - var width; - var height; - - if (event.type != 'drag') { - width = Math.round(ui.size.width / cellWidth); - height = Math.round(ui.size.height / cellHeight); + var drag_or_resize = function(event, ui) { + var x = Math.round(ui.position.left / cell_width), + y = Math.floor((ui.position.top + cell_height / 2) / cell_height), + width, height; + if (event.type != "drag") { + width = Math.round(ui.size.width / cell_width); + height = Math.round(ui.size.height / cell_height); } - if (event.type == 'drag') { - if (x < 0 || x >= self.grid.width || y < 0) { - if (self.opts.removable === true) { - self._setupRemovingTimeout(el); - } - - x = node._beforeDragX; - y = node._beforeDragY; - - self.placeholder.detach(); - self.placeholder.hide(); - self.grid.removeNode(node); - self._updateContainerHeight(); - - node._temporaryRemoved = true; - } else { - self._clearRemovingTimeout(el); - - if (node._temporaryRemoved) { - self.grid.addNode(node); - self.placeholder - .attr('data-gs-x', x) - .attr('data-gs-y', y) - .attr('data-gs-width', width) - .attr('data-gs-height', height) - .show(); - self.container.append(self.placeholder); - node.el = self.placeholder; - node._temporaryRemoved = false; - } - } - } else if (event.type == 'resize') { - if (x < 0) { - return; - } - } - // width and height are undefined if not resizing - var lastTriedWidth = typeof width !== 'undefined' ? width : node.lastTriedWidth; - var lastTriedHeight = typeof height !== 'undefined' ? height : node.lastTriedHeight; - if (!self.grid.canMoveNode(node, x, y, width, height) || - (node.lastTriedX === x && node.lastTriedY === y && - node.lastTriedWidth === lastTriedWidth && node.lastTriedHeight === lastTriedHeight)) { + if (!self.grid.can_move_node(node, x, y, width, height)) { return; } - node.lastTriedX = x; - node.lastTriedY = y; - node.lastTriedWidth = width; - node.lastTriedHeight = height; - self.grid.moveNode(node, x, y, width, height); - self._updateContainerHeight(); + self.grid.move_node(node, x, y, width, height); + self._update_container_height(); }; - var onStartMoving = function(event, ui) { + var on_start_moving = function(event, ui) { self.container.append(self.placeholder); var o = $(this); - self.grid.cleanNodes(); - self.grid.beginUpdate(node); - cellWidth = self.cellWidth(); - var strictCellHeight = Math.ceil(o.outerHeight() / o.attr('data-gs-height')); - cellHeight = self.container.height() / parseInt(self.container.attr('data-gs-current-height')); + self.grid.clean_nodes(); + self.grid.begin_update(node); + cell_width = o.outerWidth() / o.attr('data-gs-width'); + cell_height = self.opts.cell_height + self.opts.vertical_margin; self.placeholder .attr('data-gs-x', o.attr('data-gs-x')) .attr('data-gs-y', o.attr('data-gs-y')) @@ -1131,204 +666,128 @@ .attr('data-gs-height', o.attr('data-gs-height')) .show(); node.el = self.placeholder; - node._beforeDragX = node.x; - node._beforeDragY = node.y; - self.dd.resizable(el, 'option', 'minWidth', cellWidth * (node.minWidth || 1)); - self.dd.resizable(el, 'option', 'minHeight', strictCellHeight * (node.minHeight || 1)); + el.resizable('option', 'minWidth', Math.round(cell_width * (node.min_width || 1))); + el.resizable('option', 'minHeight', self.opts.cell_height * (node.min_height || 1)); if (event.type == 'resizestart') { o.find('.grid-stack-item').trigger('resizestart'); } }; - var onEndMoving = function(event, ui) { - var o = $(this); - if (!o.data('_gridstack_node')) { - return; - } - - var forceNotify = false; + var on_end_moving = function(event, ui) { self.placeholder.detach(); + var o = $(this); node.el = o; self.placeholder.hide(); - - if (node._isAboutToRemove) { - forceNotify = true; - el.removeData('_gridstack_node'); - el.remove(); - } else { - self._clearRemovingTimeout(el); - if (!node._temporaryRemoved) { - o - .attr('data-gs-x', node.x) - .attr('data-gs-y', node.y) - .attr('data-gs-width', node.width) - .attr('data-gs-height', node.height) - .removeAttr('style'); - } else { - o - .attr('data-gs-x', node._beforeDragX) - .attr('data-gs-y', node._beforeDragY) - .attr('data-gs-width', node.width) - .attr('data-gs-height', node.height) - .removeAttr('style'); - node.x = node._beforeDragX; - node.y = node._beforeDragY; - self.grid.addNode(node); - } - } - self._updateContainerHeight(); - self._triggerChangeEvent(forceNotify); - - self.grid.endUpdate(); - - var nestedGrids = o.find('.grid-stack'); - if (nestedGrids.length && event.type == 'resizestop') { - nestedGrids.each(function(index, el) { - $(el).data('gridstack').onResizeHandler(); + o + .attr('data-gs-x', node.x) + .attr('data-gs-y', node.y) + .attr('data-gs-width', node.width) + .attr('data-gs-height', node.height) + .removeAttr('style'); + self._update_container_height(); + self._trigger_change_event(); + + self.grid.end_update(); + + var nested_grids = o.find('.grid-stack'); + if (nested_grids.length && event.type == 'resizestop') { + nested_grids.each(function(index, el) { + $(el).data('gridstack').on_resize_handler(); }); o.find('.grid-stack-item').trigger('resizestop'); } }; - this.dd - .draggable(el, { - start: onStartMoving, - stop: onEndMoving, - drag: dragOrResize - }) - .resizable(el, { - start: onStartMoving, - stop: onEndMoving, - resize: dragOrResize - }); + el + .draggable(_.extend(this.opts.draggable, { + containment: this.opts.is_nested ? this.container.parent() : null + })) + .on('dragstart', on_start_moving) + .on('dragstop', on_end_moving) + .on('drag', drag_or_resize) + .resizable(_.extend(this.opts.resizable, {})) + .on('resizestart', on_start_moving) + .on('resizestop', on_end_moving) + .on('resize', drag_or_resize); - if (node.noMove || this._isOneColumnMode() || this.opts.disableDrag) { - this.dd.draggable(el, 'disable'); + if (node.no_move || this._is_one_column_mode()) { + el.draggable('disable'); } - if (node.noResize || this._isOneColumnMode() || this.opts.disableResize) { - this.dd.resizable(el, 'disable'); + if (node.no_resize || this._is_one_column_mode()) { + el.resizable('disable'); } el.attr('data-gs-locked', node.locked ? 'yes' : null); }; - GridStack.prototype._prepareElement = function(el, triggerAddEvent) { - triggerAddEvent = typeof triggerAddEvent != 'undefined' ? triggerAddEvent : false; - var self = this; - el = $(el); - - el.addClass(this.opts.itemClass); - var node = self.grid.addNode({ - x: el.attr('data-gs-x'), - y: el.attr('data-gs-y'), - width: el.attr('data-gs-width'), - height: el.attr('data-gs-height'), - maxWidth: el.attr('data-gs-max-width'), - minWidth: el.attr('data-gs-min-width'), - maxHeight: el.attr('data-gs-max-height'), - minHeight: el.attr('data-gs-min-height'), - autoPosition: Utils.toBool(el.attr('data-gs-auto-position')), - noResize: Utils.toBool(el.attr('data-gs-no-resize')), - noMove: Utils.toBool(el.attr('data-gs-no-move')), - locked: Utils.toBool(el.attr('data-gs-locked')), - el: el, - id: el.attr('data-gs-id'), - _grid: self - }, triggerAddEvent); - el.data('_gridstack_node', node); - - this._prepareElementsByNode(el, node); - }; - - GridStack.prototype.setAnimation = function(enable) { + GridStack.prototype.set_animation = function(enable) { if (enable) { this.container.addClass('grid-stack-animate'); - } else { + } + else { this.container.removeClass('grid-stack-animate'); } }; - GridStack.prototype.addWidget = function(el, x, y, width, height, autoPosition, minWidth, maxWidth, - minHeight, maxHeight, id) { + GridStack.prototype.add_widget = function(el, x, y, width, height, auto_position) { el = $(el); - if (typeof x != 'undefined') { el.attr('data-gs-x', x); } - if (typeof y != 'undefined') { el.attr('data-gs-y', y); } - if (typeof width != 'undefined') { el.attr('data-gs-width', width); } - if (typeof height != 'undefined') { el.attr('data-gs-height', height); } - if (typeof autoPosition != 'undefined') { el.attr('data-gs-auto-position', autoPosition ? 'yes' : null); } - if (typeof minWidth != 'undefined') { el.attr('data-gs-min-width', minWidth); } - if (typeof maxWidth != 'undefined') { el.attr('data-gs-max-width', maxWidth); } - if (typeof minHeight != 'undefined') { el.attr('data-gs-min-height', minHeight); } - if (typeof maxHeight != 'undefined') { el.attr('data-gs-max-height', maxHeight); } - if (typeof id != 'undefined') { el.attr('data-gs-id', id); } + if (typeof x != 'undefined') el.attr('data-gs-x', x); + if (typeof y != 'undefined') el.attr('data-gs-y', y); + if (typeof width != 'undefined') el.attr('data-gs-width', width); + if (typeof height != 'undefined') el.attr('data-gs-height', height); + if (typeof auto_position != 'undefined') el.attr('data-gs-auto-position', auto_position ? 'yes' : null); this.container.append(el); - this._prepareElement(el, true); - this._triggerAddEvent(); - this._updateContainerHeight(); - this._triggerChangeEvent(true); + this._prepare_element(el); + this._update_container_height(); + this._trigger_change_event(true); return el; }; - GridStack.prototype.makeWidget = function(el) { + GridStack.prototype.make_widget = function(el) { el = $(el); - this._prepareElement(el, true); - this._triggerAddEvent(); - this._updateContainerHeight(); - this._triggerChangeEvent(true); + this._prepare_element(el); + this._update_container_height(); + this._trigger_change_event(true); return el; }; - GridStack.prototype.willItFit = function(x, y, width, height, autoPosition) { - var node = {x: x, y: y, width: width, height: height, autoPosition: autoPosition}; - return this.grid.canBePlacedWithRespectToHeight(node); + GridStack.prototype.will_it_fit = function(x, y, width, height, auto_position) { + var node = {x: x, y: y, width: width, height: height, auto_position: auto_position}; + return this.grid.can_be_placed_with_respect_to_height(node); }; - GridStack.prototype.removeWidget = function(el, detachNode) { - detachNode = typeof detachNode === 'undefined' ? true : detachNode; + GridStack.prototype.remove_widget = function(el, detach_node) { + detach_node = typeof detach_node === 'undefined' ? true : detach_node; el = $(el); var node = el.data('_gridstack_node'); - - // For Meteor support: https://github.com/troolee/gridstack.js/pull/272 - if (!node) { - node = this.grid.getNodeDataByDOMEl(el); - } - - this.grid.removeNode(node, detachNode); + this.grid.remove_node(node); el.removeData('_gridstack_node'); - this._updateContainerHeight(); - if (detachNode) { + this._update_container_height(); + if (detach_node) el.remove(); - } - this._triggerChangeEvent(true); - this._triggerRemoveEvent(); + this._trigger_change_event(true); }; - GridStack.prototype.removeAll = function(detachNode) { + GridStack.prototype.remove_all = function(detach_node) { _.each(this.grid.nodes, _.bind(function(node) { - this.removeWidget(node.el, detachNode); + this.remove_widget(node.el, detach_node); }, this)); this.grid.nodes = []; - this._updateContainerHeight(); + this._update_container_height(); }; - GridStack.prototype.destroy = function(detachGrid) { - $(window).off('resize', this.onResizeHandler); + GridStack.prototype.destroy = function() { + $(window).off("resize", this.on_resize_handler); this.disable(); - if (typeof detachGrid != 'undefined' && !detachGrid) { - this.removeAll(false); - this.container.removeData('gridstack'); - } else { - this.container.remove(); - } - Utils.removeStylesheet(this._stylesId); - if (this.grid) { + this.container.remove(); + Utils.remove_stylesheet(this._styles_id); + if (this.grid) this.grid = null; - } }; GridStack.prototype.resizable = function(el, val) { @@ -1337,15 +796,16 @@ el.each(function(index, el) { el = $(el); var node = el.data('_gridstack_node'); - if (typeof node == 'undefined' || node === null || typeof $.ui === 'undefined') { + if (typeof node == 'undefined' || node == null) { return; } - node.noResize = !(val || false); - if (node.noResize || self._isOneColumnMode()) { - self.dd.resizable(el, 'disable'); - } else { - self.dd.resizable(el, 'enable'); + node.no_resize = !(val || false); + if (node.no_resize || self._is_one_column_mode()) { + el.resizable('disable'); + } + else { + el.resizable('enable'); } }); return this; @@ -1357,45 +817,32 @@ el.each(function(index, el) { el = $(el); var node = el.data('_gridstack_node'); - if (typeof node == 'undefined' || node === null || typeof $.ui === 'undefined') { + if (typeof node == 'undefined' || node == null) { return; } - node.noMove = !(val || false); - if (node.noMove || self._isOneColumnMode()) { - self.dd.draggable(el, 'disable'); + node.no_move = !(val || false); + if (node.no_move || self._is_one_column_mode()) { + el.draggable('disable'); el.removeClass('ui-draggable-handle'); - } else { - self.dd.draggable(el, 'enable'); + } + else { + el.draggable('enable'); el.addClass('ui-draggable-handle'); } }); return this; }; - GridStack.prototype.enableMove = function(doEnable, includeNewWidgets) { - this.movable(this.container.children('.' + this.opts.itemClass), doEnable); - if (includeNewWidgets) { - this.opts.disableDrag = !doEnable; - } - }; - - GridStack.prototype.enableResize = function(doEnable, includeNewWidgets) { - this.resizable(this.container.children('.' + this.opts.itemClass), doEnable); - if (includeNewWidgets) { - this.opts.disableResize = !doEnable; - } - }; - GridStack.prototype.disable = function() { - this.movable(this.container.children('.' + this.opts.itemClass), false); - this.resizable(this.container.children('.' + this.opts.itemClass), false); + this.movable(this.container.children('.' + this.opts.item_class), false); + this.resizable(this.container.children('.' + this.opts.item_class), false); this.container.trigger('disable'); }; GridStack.prototype.enable = function() { - this.movable(this.container.children('.' + this.opts.itemClass), true); - this.resizable(this.container.children('.' + this.opts.itemClass), true); + this.movable(this.container.children('.' + this.opts.item_class), true); + this.resizable(this.container.children('.' + this.opts.item_class), true); this.container.trigger('enable'); }; @@ -1404,7 +851,7 @@ el.each(function(index, el) { el = $(el); var node = el.data('_gridstack_node'); - if (typeof node == 'undefined' || node === null) { + if (typeof node == 'undefined' || node == null) { return; } @@ -1414,322 +861,164 @@ return this; }; - GridStack.prototype.maxHeight = function(el, val) { - el = $(el); - el.each(function(index, el) { - el = $(el); - var node = el.data('_gridstack_node'); - if (typeof node === 'undefined' || node === null) { - return; - } - - if (!isNaN(val)) { - node.maxHeight = (val || false); - el.attr('data-gs-max-height', val); - } - }); - return this; - }; - - GridStack.prototype.minHeight = function(el, val) { - el = $(el); - el.each(function(index, el) { - el = $(el); - var node = el.data('_gridstack_node'); - if (typeof node === 'undefined' || node === null) { - return; - } - - if (!isNaN(val)) { - node.minHeight = (val || false); - el.attr('data-gs-min-height', val); - } - }); - return this; - }; - - GridStack.prototype.maxWidth = function(el, val) { - el = $(el); - el.each(function(index, el) { - el = $(el); - var node = el.data('_gridstack_node'); - if (typeof node === 'undefined' || node === null) { - return; - } - - if (!isNaN(val)) { - node.maxWidth = (val || false); - el.attr('data-gs-max-width', val); - } - }); - return this; - }; - - GridStack.prototype.minWidth = function(el, val) { - el = $(el); - el.each(function(index, el) { - el = $(el); - var node = el.data('_gridstack_node'); - if (typeof node === 'undefined' || node === null) { - return; - } - - if (!isNaN(val)) { - node.minWidth = (val || false); - el.attr('data-gs-min-width', val); - } - }); - return this; - }; - - GridStack.prototype._updateElement = function(el, callback) { + GridStack.prototype.min_height = function (el, val) { + el = $(el); + el.each(function (index, el) { + el = $(el); + var node = el.data('_gridstack_node'); + if (typeof node == 'undefined' || node == null) { + return; + } + + if(!isNaN(val)){ + node.min_height = (val || false); + el.attr('data-gs-min-height', val); + } + }); + return this; + }; + + GridStack.prototype.min_width = function (el, val) { + el = $(el); + el.each(function (index, el) { + el = $(el); + var node = el.data('_gridstack_node'); + if (typeof node == 'undefined' || node == null) { + return; + } + + if(!isNaN(val)){ + node.min_width = (val || false); + el.attr('data-gs-min-width', val); + } + }); + return this; + }; + + GridStack.prototype._update_element = function(el, callback) { el = $(el).first(); var node = el.data('_gridstack_node'); - if (typeof node == 'undefined' || node === null) { + if (typeof node == 'undefined' || node == null) { return; } var self = this; - self.grid.cleanNodes(); - self.grid.beginUpdate(node); + self.grid.clean_nodes(); + self.grid.begin_update(node); callback.call(this, el, node); - self._updateContainerHeight(); - self._triggerChangeEvent(); + self._update_container_height(); + self._trigger_change_event(); - self.grid.endUpdate(); + self.grid.end_update(); }; GridStack.prototype.resize = function(el, width, height) { - this._updateElement(el, function(el, node) { - width = (width !== null && typeof width != 'undefined') ? width : node.width; - height = (height !== null && typeof height != 'undefined') ? height : node.height; + this._update_element(el, function(el, node) { + width = (width != null && typeof width != 'undefined') ? width : node.width; + height = (height != null && typeof height != 'undefined') ? height : node.height; - this.grid.moveNode(node, node.x, node.y, width, height); + this.grid.move_node(node, node.x, node.y, width, height); }); }; GridStack.prototype.move = function(el, x, y) { - this._updateElement(el, function(el, node) { - x = (x !== null && typeof x != 'undefined') ? x : node.x; - y = (y !== null && typeof y != 'undefined') ? y : node.y; + this._update_element(el, function(el, node) { + x = (x != null && typeof x != 'undefined') ? x : node.x; + y = (y != null && typeof y != 'undefined') ? y : node.y; - this.grid.moveNode(node, x, y, node.width, node.height); + this.grid.move_node(node, x, y, node.width, node.height); }); }; GridStack.prototype.update = function(el, x, y, width, height) { - this._updateElement(el, function(el, node) { - x = (x !== null && typeof x != 'undefined') ? x : node.x; - y = (y !== null && typeof y != 'undefined') ? y : node.y; - width = (width !== null && typeof width != 'undefined') ? width : node.width; - height = (height !== null && typeof height != 'undefined') ? height : node.height; + this._update_element(el, function(el, node) { + x = (x != null && typeof x != 'undefined') ? x : node.x; + y = (y != null && typeof y != 'undefined') ? y : node.y; + width = (width != null && typeof width != 'undefined') ? width : node.width; + height = (height != null && typeof height != 'undefined') ? height : node.height; - this.grid.moveNode(node, x, y, width, height); + this.grid.move_node(node, x, y, width, height); }); }; - GridStack.prototype.verticalMargin = function(val, noUpdate) { - if (typeof val == 'undefined') { - return this.opts.verticalMargin; - } - - var heightData = Utils.parseHeight(val); - - if (this.opts.verticalMarginUnit === heightData.unit && this.opts.height === heightData.height) { - return ; - } - this.opts.verticalMarginUnit = heightData.unit; - this.opts.verticalMargin = heightData.height; - - if (!noUpdate) { - this._updateStyles(); - } - }; - - GridStack.prototype.cellHeight = function(val, noUpdate) { + GridStack.prototype.cell_height = function(val) { if (typeof val == 'undefined') { - if (this.opts.cellHeight) { - return this.opts.cellHeight; - } - var o = this.container.children('.' + this.opts.itemClass).first(); - return Math.ceil(o.outerHeight() / o.attr('data-gs-height')); - } - var heightData = Utils.parseHeight(val); - - if (this.opts.cellHeightUnit === heightData.heightUnit && this.opts.height === heightData.height) { - return ; + return this.opts.cell_height; } - this.opts.cellHeightUnit = heightData.unit; - this.opts.cellHeight = heightData.height; - - if (!noUpdate) { - this._updateStyles(); - } - + val = parseInt(val); + if (val == this.opts.cell_height) + return; + this.opts.cell_height = val || this.opts.cell_height; + this._update_styles(); }; - GridStack.prototype.cellWidth = function() { - return Math.round(this.container.outerWidth() / this.opts.width); + GridStack.prototype.cell_width = function() { + var o = this.container.children('.' + this.opts.item_class).first(); + return Math.ceil(o.outerWidth() / o.attr('data-gs-width')); }; - GridStack.prototype.getCellFromPixel = function(position, useOffset) { - var containerPos = (typeof useOffset != 'undefined' && useOffset) ? - this.container.offset() : this.container.position(); + GridStack.prototype.get_cell_from_pixel = function(position) { + var containerPos = this.container.position(); var relativeLeft = position.left - containerPos.left; var relativeTop = position.top - containerPos.top; - var columnWidth = Math.floor(this.container.width() / this.opts.width); - var rowHeight = Math.floor(this.container.height() / parseInt(this.container.attr('data-gs-current-height'))); + var column_width = Math.floor(this.container.width() / this.opts.width); + var row_height = this.opts.cell_height + this.opts.vertical_margin; - return {x: Math.floor(relativeLeft / columnWidth), y: Math.floor(relativeTop / rowHeight)}; + return {x: Math.floor(relativeLeft / column_width), y: Math.floor(relativeTop / row_height)}; }; - GridStack.prototype.batchUpdate = function() { - this.grid.batchUpdate(); + GridStack.prototype.batch_update = function() { + this.grid.batch_update(); }; GridStack.prototype.commit = function() { this.grid.commit(); - this._updateContainerHeight(); + this._update_container_height(); }; - GridStack.prototype.isAreaEmpty = function(x, y, width, height) { - return this.grid.isAreaEmpty(x, y, width, height); + GridStack.prototype.is_area_empty = function(x, y, width, height) { + return this.grid.is_area_empty(x, y, width, height); }; - GridStack.prototype.setStatic = function(staticValue) { - this.opts.staticGrid = (staticValue === true); - this.enableMove(!staticValue); - this.enableResize(!staticValue); - this._setStaticClass(); + GridStack.prototype.set_static = function(static_value) { + this.opts.static_grid = (static_value === true); + this._set_static_class(); }; - GridStack.prototype._setStaticClass = function() { - var staticClassName = 'grid-stack-static'; + GridStack.prototype._set_static_class = function() { + var static_class_name = 'grid-stack-static'; - if (this.opts.staticGrid === true) { - this.container.addClass(staticClassName); + if (this.opts.static_grid === true) { + this.container.addClass(static_class_name); } else { - this.container.removeClass(staticClassName); + this.container.removeClass(static_class_name); } }; - GridStack.prototype._updateNodeWidths = function(oldWidth, newWidth) { - this.grid._sortNodes(); - this.grid.batchUpdate(); - var node = {}; - for (var i = 0; i < this.grid.nodes.length; i++) { - node = this.grid.nodes[i]; - this.update(node.el, Math.round(node.x * newWidth / oldWidth), undefined, - Math.round(node.width * newWidth / oldWidth), undefined); - } - this.grid.commit(); - }; - - GridStack.prototype.setGridWidth = function(gridWidth,doNotPropagate) { - this.container.removeClass('grid-stack-' + this.opts.width); - if (doNotPropagate !== true) { - this._updateNodeWidths(this.opts.width, gridWidth); - } - this.opts.width = gridWidth; - this.grid.width = gridWidth; - this.container.addClass('grid-stack-' + gridWidth); - }; - - // jscs:disable requireCamelCaseOrUpperCaseIdentifiers - GridStackEngine.prototype.batch_update = obsolete(GridStackEngine.prototype.batchUpdate); - GridStackEngine.prototype._fix_collisions = obsolete(GridStackEngine.prototype._fixCollisions, - '_fix_collisions', '_fixCollisions'); - GridStackEngine.prototype.is_area_empty = obsolete(GridStackEngine.prototype.isAreaEmpty, - 'is_area_empty', 'isAreaEmpty'); - GridStackEngine.prototype._sort_nodes = obsolete(GridStackEngine.prototype._sortNodes, - '_sort_nodes', '_sortNodes'); - GridStackEngine.prototype._pack_nodes = obsolete(GridStackEngine.prototype._packNodes, - '_pack_nodes', '_packNodes'); - GridStackEngine.prototype._prepare_node = obsolete(GridStackEngine.prototype._prepareNode, - '_prepare_node', '_prepareNode'); - GridStackEngine.prototype.clean_nodes = obsolete(GridStackEngine.prototype.cleanNodes, - 'clean_nodes', 'cleanNodes'); - GridStackEngine.prototype.get_dirty_nodes = obsolete(GridStackEngine.prototype.getDirtyNodes, - 'get_dirty_nodes', 'getDirtyNodes'); - GridStackEngine.prototype.add_node = obsolete(GridStackEngine.prototype.addNode, - 'add_node', 'addNode, '); - GridStackEngine.prototype.remove_node = obsolete(GridStackEngine.prototype.removeNode, - 'remove_node', 'removeNode'); - GridStackEngine.prototype.can_move_node = obsolete(GridStackEngine.prototype.canMoveNode, - 'can_move_node', 'canMoveNode'); - GridStackEngine.prototype.move_node = obsolete(GridStackEngine.prototype.moveNode, - 'move_node', 'moveNode'); - GridStackEngine.prototype.get_grid_height = obsolete(GridStackEngine.prototype.getGridHeight, - 'get_grid_height', 'getGridHeight'); - GridStackEngine.prototype.begin_update = obsolete(GridStackEngine.prototype.beginUpdate, - 'begin_update', 'beginUpdate'); - GridStackEngine.prototype.end_update = obsolete(GridStackEngine.prototype.endUpdate, - 'end_update', 'endUpdate'); - GridStackEngine.prototype.can_be_placed_with_respect_to_height = - obsolete(GridStackEngine.prototype.canBePlacedWithRespectToHeight, - 'can_be_placed_with_respect_to_height', 'canBePlacedWithRespectToHeight'); - GridStack.prototype._trigger_change_event = obsolete(GridStack.prototype._triggerChangeEvent, - '_trigger_change_event', '_triggerChangeEvent'); - GridStack.prototype._init_styles = obsolete(GridStack.prototype._initStyles, - '_init_styles', '_initStyles'); - GridStack.prototype._update_styles = obsolete(GridStack.prototype._updateStyles, - '_update_styles', '_updateStyles'); - GridStack.prototype._update_container_height = obsolete(GridStack.prototype._updateContainerHeight, - '_update_container_height', '_updateContainerHeight'); - GridStack.prototype._is_one_column_mode = obsolete(GridStack.prototype._isOneColumnMode, - '_is_one_column_mode','_isOneColumnMode'); - GridStack.prototype._prepare_element = obsolete(GridStack.prototype._prepareElement, - '_prepare_element', '_prepareElement'); - GridStack.prototype.set_animation = obsolete(GridStack.prototype.setAnimation, - 'set_animation', 'setAnimation'); - GridStack.prototype.add_widget = obsolete(GridStack.prototype.addWidget, - 'add_widget', 'addWidget'); - GridStack.prototype.make_widget = obsolete(GridStack.prototype.makeWidget, - 'make_widget', 'makeWidget'); - GridStack.prototype.will_it_fit = obsolete(GridStack.prototype.willItFit, - 'will_it_fit', 'willItFit'); - GridStack.prototype.remove_widget = obsolete(GridStack.prototype.removeWidget, - 'remove_widget', 'removeWidget'); - GridStack.prototype.remove_all = obsolete(GridStack.prototype.removeAll, - 'remove_all', 'removeAll'); - GridStack.prototype.min_height = obsolete(GridStack.prototype.minHeight, - 'min_height', 'minHeight'); - GridStack.prototype.min_width = obsolete(GridStack.prototype.minWidth, - 'min_width', 'minWidth'); - GridStack.prototype._update_element = obsolete(GridStack.prototype._updateElement, - '_update_element', '_updateElement'); - GridStack.prototype.cell_height = obsolete(GridStack.prototype.cellHeight, - 'cell_height', 'cellHeight'); - GridStack.prototype.cell_width = obsolete(GridStack.prototype.cellWidth, - 'cell_width', 'cellWidth'); - GridStack.prototype.get_cell_from_pixel = obsolete(GridStack.prototype.getCellFromPixel, - 'get_cell_from_pixel', 'getCellFromPixel'); - GridStack.prototype.batch_update = obsolete(GridStack.prototype.batchUpdate, - 'batch_update', 'batchUpdate'); - GridStack.prototype.is_area_empty = obsolete(GridStack.prototype.isAreaEmpty, - 'is_area_empty', 'isAreaEmpty'); - GridStack.prototype.set_static = obsolete(GridStack.prototype.setStatic, - 'set_static', 'setStatic'); - GridStack.prototype._set_static_class = obsolete(GridStack.prototype._setStaticClass, - '_set_static_class', '_setStaticClass'); - // jscs:enable requireCamelCaseOrUpperCaseIdentifiers - scope.GridStackUI = GridStack; scope.GridStackUI.Utils = Utils; - scope.GridStackUI.Engine = GridStackEngine; - scope.GridStackUI.GridStackDragDropPlugin = GridStackDragDropPlugin; + function event_stop_propagate(event) { + event.stopPropagation(); + } $.fn.gridstack = function(opts) { return this.each(function() { var o = $(this); if (!o.data('gridstack')) { o - .data('gridstack', new GridStack(this, opts)); + .data('gridstack', new GridStack(this, opts)) + .on('dragstart', event_stop_propagate) + .on('dragstop', event_stop_propagate) + .on('drag', event_stop_propagate) + .on('resizestart', event_stop_propagate) + .on('resizestop', event_stop_propagate) + .on('resize', event_stop_propagate) + .on('change', event_stop_propagate); } }); }; diff --git a/dist/gridstack.min.css b/dist/gridstack.min.css index 7a66c58ad..9a0775e65 100644 --- a/dist/gridstack.min.css +++ b/dist/gridstack.min.css @@ -1 +1 @@ -:root .grid-stack-item>.ui-resizable-handle{filter:none}.grid-stack{position:relative}.grid-stack.grid-stack-rtl{direction:ltr}.grid-stack.grid-stack-rtl>.grid-stack-item{direction:rtl}.grid-stack .grid-stack-placeholder>.placeholder-content{border:1px dashed #d3d3d3;margin:0;position:absolute;top:0;left:10px;right:10px;bottom:0;width:auto;z-index:0!important;text-align:center}.grid-stack>.grid-stack-item{min-width:8.3333333333%;position:absolute;padding:0}.grid-stack>.grid-stack-item>.grid-stack-item-content{margin:0;position:absolute;top:0;left:10px;right:10px;bottom:0;width:auto;z-index:0!important;overflow-x:hidden;overflow-y:auto}.grid-stack>.grid-stack-item>.ui-resizable-handle{position:absolute;font-size:.1px;display:block;-ms-touch-action:none;touch-action:none}.grid-stack>.grid-stack-item.ui-resizable-autohide>.ui-resizable-handle,.grid-stack>.grid-stack-item.ui-resizable-disabled>.ui-resizable-handle{display:none}.grid-stack>.grid-stack-item.ui-draggable-dragging,.grid-stack>.grid-stack-item.ui-resizable-resizing{z-index:100}.grid-stack>.grid-stack-item.ui-draggable-dragging>.grid-stack-item-content,.grid-stack>.grid-stack-item.ui-resizable-resizing>.grid-stack-item-content{box-shadow:1px 4px 6px rgba(0,0,0,.2);opacity:.8}.grid-stack>.grid-stack-item>.ui-resizable-se,.grid-stack>.grid-stack-item>.ui-resizable-sw{background-image:url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iaXNvLTg4NTktMSI/Pgo8IS0tIEdlbmVyYXRvcjogQWRvYmUgSWxsdXN0cmF0b3IgMTYuMC4wLCBTVkcgRXhwb3J0IFBsdWctSW4gLiBTVkcgVmVyc2lvbjogNi4wMCBCdWlsZCAwKSAgLS0+CjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0Z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zQuOTUsMCw5LjIzNC0xLjgwNywxMi44NDktNS40MjQgICBsNzMuMDg3LTczLjA4OGMzLjYxMy0zLjYyLDUuNDIxLTcuOTAxLDUuNDIxLTEyLjg0N2MwLTQuOTQ4LTEuODA4LTkuMjMyLTUuNDIxLTEyLjg1NCAgIEMzMzguMTQyLDQwMy44MDIsMzMzLjg1Nyw0MDEuOTk0LDMyOC45MDYsNDAxLjk5NHoiIGZpbGw9IiM2NjY2NjYiLz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8L3N2Zz4K);background-repeat:no-repeat;background-position:center;-webkit-transform:rotate(45deg);-moz-transform:rotate(45deg);-ms-transform:rotate(45deg);-o-transform:rotate(45deg);transform:rotate(45deg)}.grid-stack>.grid-stack-item>.ui-resizable-nw{cursor:nw-resize;width:20px;height:20px;left:10px;top:0}.grid-stack>.grid-stack-item>.ui-resizable-n{cursor:n-resize;height:10px;top:0;left:25px;right:25px}.grid-stack>.grid-stack-item>.ui-resizable-ne{cursor:ne-resize;width:20px;height:20px;right:10px;top:0}.grid-stack>.grid-stack-item>.ui-resizable-e{cursor:e-resize;width:10px;right:10px;top:15px;bottom:15px}.grid-stack>.grid-stack-item>.ui-resizable-se{-webkit-transform:rotate(-45deg);-moz-transform:rotate(-45deg);-ms-transform:rotate(-45deg);-o-transform:rotate(-45deg);transform:rotate(-45deg);cursor:se-resize;width:20px;height:20px;right:10px;bottom:0}.grid-stack>.grid-stack-item>.ui-resizable-s{cursor:s-resize;height:10px;left:25px;bottom:0;right:25px}.grid-stack>.grid-stack-item>.ui-resizable-sw{cursor:sw-resize;width:20px;height:20px;left:10px;bottom:0}.grid-stack>.grid-stack-item>.ui-resizable-w{cursor:w-resize;width:10px;left:10px;top:15px;bottom:15px}.grid-stack>.grid-stack-item.ui-draggable-dragging>.ui-resizable-handle{display:none!important}.grid-stack>.grid-stack-item[data-gs-width='1']{width:8.3333333333%}.grid-stack>.grid-stack-item[data-gs-x='1']{left:8.3333333333%}.grid-stack>.grid-stack-item[data-gs-min-width='1']{min-width:8.3333333333%}.grid-stack>.grid-stack-item[data-gs-max-width='1']{max-width:8.3333333333%}.grid-stack>.grid-stack-item[data-gs-width='2']{width:16.6666666667%}.grid-stack>.grid-stack-item[data-gs-x='2']{left:16.6666666667%}.grid-stack>.grid-stack-item[data-gs-min-width='2']{min-width:16.6666666667%}.grid-stack>.grid-stack-item[data-gs-max-width='2']{max-width:16.6666666667%}.grid-stack>.grid-stack-item[data-gs-width='3']{width:25%}.grid-stack>.grid-stack-item[data-gs-x='3']{left:25%}.grid-stack>.grid-stack-item[data-gs-min-width='3']{min-width:25%}.grid-stack>.grid-stack-item[data-gs-max-width='3']{max-width:25%}.grid-stack>.grid-stack-item[data-gs-width='4']{width:33.3333333333%}.grid-stack>.grid-stack-item[data-gs-x='4']{left:33.3333333333%}.grid-stack>.grid-stack-item[data-gs-min-width='4']{min-width:33.3333333333%}.grid-stack>.grid-stack-item[data-gs-max-width='4']{max-width:33.3333333333%}.grid-stack>.grid-stack-item[data-gs-width='5']{width:41.6666666667%}.grid-stack>.grid-stack-item[data-gs-x='5']{left:41.6666666667%}.grid-stack>.grid-stack-item[data-gs-min-width='5']{min-width:41.6666666667%}.grid-stack>.grid-stack-item[data-gs-max-width='5']{max-width:41.6666666667%}.grid-stack>.grid-stack-item[data-gs-width='6']{width:50%}.grid-stack>.grid-stack-item[data-gs-x='6']{left:50%}.grid-stack>.grid-stack-item[data-gs-min-width='6']{min-width:50%}.grid-stack>.grid-stack-item[data-gs-max-width='6']{max-width:50%}.grid-stack>.grid-stack-item[data-gs-width='7']{width:58.3333333333%}.grid-stack>.grid-stack-item[data-gs-x='7']{left:58.3333333333%}.grid-stack>.grid-stack-item[data-gs-min-width='7']{min-width:58.3333333333%}.grid-stack>.grid-stack-item[data-gs-max-width='7']{max-width:58.3333333333%}.grid-stack>.grid-stack-item[data-gs-width='8']{width:66.6666666667%}.grid-stack>.grid-stack-item[data-gs-x='8']{left:66.6666666667%}.grid-stack>.grid-stack-item[data-gs-min-width='8']{min-width:66.6666666667%}.grid-stack>.grid-stack-item[data-gs-max-width='8']{max-width:66.6666666667%}.grid-stack>.grid-stack-item[data-gs-width='9']{width:75%}.grid-stack>.grid-stack-item[data-gs-x='9']{left:75%}.grid-stack>.grid-stack-item[data-gs-min-width='9']{min-width:75%}.grid-stack>.grid-stack-item[data-gs-max-width='9']{max-width:75%}.grid-stack>.grid-stack-item[data-gs-width='10']{width:83.3333333333%}.grid-stack>.grid-stack-item[data-gs-x='10']{left:83.3333333333%}.grid-stack>.grid-stack-item[data-gs-min-width='10']{min-width:83.3333333333%}.grid-stack>.grid-stack-item[data-gs-max-width='10']{max-width:83.3333333333%}.grid-stack>.grid-stack-item[data-gs-width='11']{width:91.6666666667%}.grid-stack>.grid-stack-item[data-gs-x='11']{left:91.6666666667%}.grid-stack>.grid-stack-item[data-gs-min-width='11']{min-width:91.6666666667%}.grid-stack>.grid-stack-item[data-gs-max-width='11']{max-width:91.6666666667%}.grid-stack>.grid-stack-item[data-gs-width='12']{width:100%}.grid-stack>.grid-stack-item[data-gs-x='12']{left:100%}.grid-stack>.grid-stack-item[data-gs-min-width='12']{min-width:100%}.grid-stack>.grid-stack-item[data-gs-max-width='12']{max-width:100%}.grid-stack.grid-stack-animate,.grid-stack.grid-stack-animate .grid-stack-item{-webkit-transition:left .3s,top .3s,height .3s,width .3s;-moz-transition:left .3s,top .3s,height .3s,width .3s;-ms-transition:left .3s,top .3s,height .3s,width .3s;-o-transition:left .3s,top .3s,height .3s,width .3s;transition:left .3s,top .3s,height .3s,width .3s}.grid-stack.grid-stack-animate .grid-stack-item.grid-stack-placeholder,.grid-stack.grid-stack-animate .grid-stack-item.ui-draggable-dragging,.grid-stack.grid-stack-animate .grid-stack-item.ui-resizable-resizing{-webkit-transition:left 0s,top 0s,height 0s,width 0s;-moz-transition:left 0s,top 0s,height 0s,width 0s;-ms-transition:left 0s,top 0s,height 0s,width 0s;-o-transition:left 0s,top 0s,height 0s,width 0s;transition:left 0s,top 0s,height 0s,width 0s}.grid-stack.grid-stack-one-column-mode{height:auto!important}.grid-stack.grid-stack-one-column-mode>.grid-stack-item{position:relative!important;width:auto!important;left:0!important;top:auto!important;margin-bottom:20px;max-width:none!important}.grid-stack.grid-stack-one-column-mode>.grid-stack-item>.ui-resizable-handle{display:none} \ No newline at end of file +:root .grid-stack-item>.ui-resizable-handle{filter:none}.grid-stack{position:relative}.grid-stack .grid-stack-placeholder>.placeholder-content{border:1px dashed #d3d3d3;margin:0;position:absolute;top:0;left:10px;right:10px;bottom:0;width:auto;z-index:0!important;text-align:center}.grid-stack>.grid-stack-item{min-width:8.3333333333%;position:absolute;padding:0}.grid-stack>.grid-stack-item>.grid-stack-item-content{margin:0;position:absolute;top:0;left:10px;right:10px;bottom:0;width:auto;z-index:0!important;overflow-x:hidden;overflow-y:auto}.grid-stack>.grid-stack-item>.ui-resizable-handle{position:absolute;font-size:.1px;display:block;-ms-touch-action:none;touch-action:none}.grid-stack>.grid-stack-item.ui-resizable-autohide>.ui-resizable-handle,.grid-stack>.grid-stack-item.ui-resizable-disabled>.ui-resizable-handle{display:none}.grid-stack>.grid-stack-item.ui-draggable-dragging,.grid-stack>.grid-stack-item.ui-resizable-resizing{z-index:100}.grid-stack>.grid-stack-item.ui-draggable-dragging>.grid-stack-item-content,.grid-stack>.grid-stack-item.ui-resizable-resizing>.grid-stack-item-content{box-shadow:1px 4px 6px rgba(0,0,0,.2);opacity:.8}.grid-stack>.grid-stack-item>.ui-resizable-se,.grid-stack>.grid-stack-item>.ui-resizable-sw{text-align:right;color:gray;padding:2px 3px 0 0;margin:0;font:normal normal normal 10px/1 FontAwesome;font-size:inherit;text-rendering:auto;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.grid-stack>.grid-stack-item>.ui-resizable-se::before,.grid-stack>.grid-stack-item>.ui-resizable-sw::before{content:"\f065"}.grid-stack>.grid-stack-item>.ui-resizable-nw{cursor:nw-resize;width:20px;height:20px;left:10px;top:0}.grid-stack>.grid-stack-item>.ui-resizable-n{cursor:n-resize;height:10px;top:0;left:25px;right:25px}.grid-stack>.grid-stack-item>.ui-resizable-ne{cursor:ne-resize;width:20px;height:20px;right:10px;top:0}.grid-stack>.grid-stack-item>.ui-resizable-e{cursor:e-resize;width:10px;right:10px;top:15px;bottom:15px}.grid-stack>.grid-stack-item>.ui-resizable-se{display:inline-block;-webkit-transform:rotate(90deg);-moz-transform:rotate(90deg);-ms-transform:rotate(90deg);-o-transform:rotate(90deg);transform:rotate(90deg);cursor:se-resize;width:20px;height:20px;right:10px;bottom:0}.grid-stack>.grid-stack-item>.ui-resizable-s{cursor:s-resize;height:10px;left:25px;bottom:0;right:25px}.grid-stack>.grid-stack-item>.ui-resizable-sw{cursor:sw-resize;width:20px;height:20px;left:10px;bottom:0}.grid-stack>.grid-stack-item>.ui-resizable-w{cursor:w-resize;width:10px;left:10px;top:15px;bottom:15px}.grid-stack>.grid-stack-item[data-gs-width='1']{width:8.3333333333%}.grid-stack>.grid-stack-item[data-gs-x='1']{left:8.3333333333%}.grid-stack>.grid-stack-item[data-gs-min-width='1']{min-width:8.3333333333%}.grid-stack>.grid-stack-item[data-gs-max-width='1']{max-width:8.3333333333%}.grid-stack>.grid-stack-item[data-gs-width='2']{width:16.6666666667%}.grid-stack>.grid-stack-item[data-gs-x='2']{left:16.6666666667%}.grid-stack>.grid-stack-item[data-gs-min-width='2']{min-width:16.6666666667%}.grid-stack>.grid-stack-item[data-gs-max-width='2']{max-width:16.6666666667%}.grid-stack>.grid-stack-item[data-gs-width='3']{width:25%}.grid-stack>.grid-stack-item[data-gs-x='3']{left:25%}.grid-stack>.grid-stack-item[data-gs-min-width='3']{min-width:25%}.grid-stack>.grid-stack-item[data-gs-max-width='3']{max-width:25%}.grid-stack>.grid-stack-item[data-gs-width='4']{width:33.3333333333%}.grid-stack>.grid-stack-item[data-gs-x='4']{left:33.3333333333%}.grid-stack>.grid-stack-item[data-gs-min-width='4']{min-width:33.3333333333%}.grid-stack>.grid-stack-item[data-gs-max-width='4']{max-width:33.3333333333%}.grid-stack>.grid-stack-item[data-gs-width='5']{width:41.6666666667%}.grid-stack>.grid-stack-item[data-gs-x='5']{left:41.6666666667%}.grid-stack>.grid-stack-item[data-gs-min-width='5']{min-width:41.6666666667%}.grid-stack>.grid-stack-item[data-gs-max-width='5']{max-width:41.6666666667%}.grid-stack>.grid-stack-item[data-gs-width='6']{width:50%}.grid-stack>.grid-stack-item[data-gs-x='6']{left:50%}.grid-stack>.grid-stack-item[data-gs-min-width='6']{min-width:50%}.grid-stack>.grid-stack-item[data-gs-max-width='6']{max-width:50%}.grid-stack>.grid-stack-item[data-gs-width='7']{width:58.3333333333%}.grid-stack>.grid-stack-item[data-gs-x='7']{left:58.3333333333%}.grid-stack>.grid-stack-item[data-gs-min-width='7']{min-width:58.3333333333%}.grid-stack>.grid-stack-item[data-gs-max-width='7']{max-width:58.3333333333%}.grid-stack>.grid-stack-item[data-gs-width='8']{width:66.6666666667%}.grid-stack>.grid-stack-item[data-gs-x='8']{left:66.6666666667%}.grid-stack>.grid-stack-item[data-gs-min-width='8']{min-width:66.6666666667%}.grid-stack>.grid-stack-item[data-gs-max-width='8']{max-width:66.6666666667%}.grid-stack>.grid-stack-item[data-gs-width='9']{width:75%}.grid-stack>.grid-stack-item[data-gs-x='9']{left:75%}.grid-stack>.grid-stack-item[data-gs-min-width='9']{min-width:75%}.grid-stack>.grid-stack-item[data-gs-max-width='9']{max-width:75%}.grid-stack>.grid-stack-item[data-gs-width='10']{width:83.3333333333%}.grid-stack>.grid-stack-item[data-gs-x='10']{left:83.3333333333%}.grid-stack>.grid-stack-item[data-gs-min-width='10']{min-width:83.3333333333%}.grid-stack>.grid-stack-item[data-gs-max-width='10']{max-width:83.3333333333%}.grid-stack>.grid-stack-item[data-gs-width='11']{width:91.6666666667%}.grid-stack>.grid-stack-item[data-gs-x='11']{left:91.6666666667%}.grid-stack>.grid-stack-item[data-gs-min-width='11']{min-width:91.6666666667%}.grid-stack>.grid-stack-item[data-gs-max-width='11']{max-width:91.6666666667%}.grid-stack>.grid-stack-item[data-gs-width='12']{width:100%}.grid-stack>.grid-stack-item[data-gs-x='12']{left:100%}.grid-stack>.grid-stack-item[data-gs-min-width='12']{min-width:100%}.grid-stack>.grid-stack-item[data-gs-max-width='12']{max-width:100%}.grid-stack.grid-stack-animate,.grid-stack.grid-stack-animate .grid-stack-item{-webkit-transition:left .3s,top .3s,height .3s,width .3s;-moz-transition:left .3s,top .3s,height .3s,width .3s;-ms-transition:left .3s,top .3s,height .3s,width .3s;-o-transition:left .3s,top .3s,height .3s,width .3s;transition:left .3s,top .3s,height .3s,width .3s}.grid-stack.grid-stack-animate .grid-stack-item.grid-stack-placeholder,.grid-stack.grid-stack-animate .grid-stack-item.ui-draggable-dragging,.grid-stack.grid-stack-animate .grid-stack-item.ui-resizable-resizing{-webkit-transition:left 0s,top 0s,height 0s,width 0s;-moz-transition:left 0s,top 0s,height 0s,width 0s;-ms-transition:left 0s,top 0s,height 0s,width 0s;-o-transition:left 0s,top 0s,height 0s,width 0s;transition:left 0s,top 0s,height 0s,width 0s}@media (max-width:768px){.grid-stack-item{position:relative!important;width:auto!important;left:0!important;top:auto!important;margin-bottom:20px}.grid-stack-item .ui-resizable-handle{display:none}.grid-stack{height:auto!important}} \ No newline at end of file diff --git a/dist/gridstack.min.js b/dist/gridstack.min.js index 8f3dbcbbe..1f63dc1bf 100644 --- a/dist/gridstack.min.js +++ b/dist/gridstack.min.js @@ -1,30 +1,2 @@ -/** - * gridstack.js 0.3.0-dev - * http://troolee.github.io/gridstack.js/ - * (c) 2014-2016 Pavel Reznikov, Dylan Weiss - * gridstack.js may be freely distributed under the MIT license. - * @preserve -*/ -!function(a){if("function"==typeof define&&define.amd)define(["jquery","lodash"],a);else if("undefined"!=typeof exports){try{jQuery=require("jquery")}catch(a){}try{_=require("lodash")}catch(a){}a(jQuery,_)}else a(jQuery,_)}(function(a,b){ -// jscs:enable requireCamelCaseOrUpperCaseIdentifiers -/** - * @class GridStackDragDropPlugin - * Base class for drag'n'drop plugin. - */ -function c(a){this.grid=a}var d=window,e=function(a,b,c){var d=function(){return console.warn("gridstack.js: Function `"+b+"` is deprecated as of v0.2.5 and has been replaced with `"+c+"`. It will be **completely** removed in v1.0."),a.apply(this,arguments)};return d.prototype=a.prototype,d},f=function(a,b){console.warn("gridstack.js: Option `"+a+"` is deprecated as of v0.2.5 and has been replaced with `"+b+"`. It will be **completely** removed in v1.0.")},g={isIntercepted:function(a,b){return!(a.x+a.width<=b.x||b.x+b.width<=a.x||a.y+a.height<=b.y||b.y+b.height<=a.y)},sort:function(a,c,d){return d=d||b.chain(a).map(function(a){return a.x+a.width}).max().value(),c=c!=-1?1:-1,b.sortBy(a,function(a){return c*(a.x+a.y*d)})},createStylesheet:function(a){var b=document.createElement("style");return b.setAttribute("type","text/css"),b.setAttribute("data-gs-style-id",a),b.styleSheet?b.styleSheet.cssText="":b.appendChild(document.createTextNode("")),document.getElementsByTagName("head")[0].appendChild(b),b.sheet},removeStylesheet:function(b){a("STYLE[data-gs-style-id="+b+"]").remove()},insertCSSRule:function(a,b,c,d){"function"==typeof a.insertRule?a.insertRule(b+"{"+c+"}",d):"function"==typeof a.addRule&&a.addRule(b,c,d)},toBool:function(a){return"boolean"==typeof a?a:"string"==typeof a?(a=a.toLowerCase(),!(""===a||"no"==a||"false"==a||"0"==a)):Boolean(a)},_collisionNodeCheck:function(a){return a!=this.node&&g.isIntercepted(a,this.nn)},_didCollide:function(a){return g.isIntercepted({x:this.n.x,y:this.newY,width:this.n.width,height:this.n.height},a)},_isAddNodeIntercepted:function(a){return g.isIntercepted({x:this.x,y:this.y,width:this.node.width,height:this.node.height},a)},parseHeight:function(a){var c=a,d="px";if(c&&b.isString(c)){var e=c.match(/^(-[0-9]+\.[0-9]+|[0-9]*\.[0-9]+|-[0-9]+|[0-9]+)(px|em|rem|vh|vw)?$/);if(!e)throw new Error("Invalid height");d=e[2]||"px",c=parseFloat(e[1])}return{height:c,unit:d}}}; -// jscs:disable requireCamelCaseOrUpperCaseIdentifiers -g.is_intercepted=e(g.isIntercepted,"is_intercepted","isIntercepted"),g.create_stylesheet=e(g.createStylesheet,"create_stylesheet","createStylesheet"),g.remove_stylesheet=e(g.removeStylesheet,"remove_stylesheet","removeStylesheet"),g.insert_css_rule=e(g.insertCSSRule,"insert_css_rule","insertCSSRule"),c.registeredPlugins=[],c.registerPlugin=function(a){c.registeredPlugins.push(a)},c.prototype.resizable=function(a,b){return this},c.prototype.draggable=function(a,b){return this},c.prototype.droppable=function(a,b){return this},c.prototype.isDroppable=function(a){return!1},c.prototype.on=function(a,b,c){return this};var h=0,i=function(a,b,c,d,e){this.width=a,this.float=c||!1,this.height=d||0,this.nodes=e||[],this.onchange=b||function(){},this._updateCounter=0,this._float=this.float,this._addedNodes=[],this._removedNodes=[]};i.prototype.batchUpdate=function(){this._updateCounter=1,this.float=!0},i.prototype.commit=function(){0!==this._updateCounter&&(this._updateCounter=0,this.float=this._float,this._packNodes(),this._notify())}, -// For Meteor support: https://github.com/troolee/gridstack.js/pull/272 -i.prototype.getNodeDataByDOMEl=function(a){return b.find(this.nodes,function(b){return a.get(0)===b.el.get(0)})},i.prototype._fixCollisions=function(a){this._sortNodes(-1);var c=a,d=Boolean(b.find(this.nodes,function(a){return a.locked}));for(this.float||d||(c={x:0,y:a.y,width:this.width,height:a.height});;){var e=b.find(this.nodes,b.bind(g._collisionNodeCheck,{node:a,nn:c}));if("undefined"==typeof e)return;this.moveNode(e,e.x,a.y+a.height,e.width,e.height,!0)}},i.prototype.isAreaEmpty=function(a,c,d,e){var f={x:a||0,y:c||0,width:d||1,height:e||1},h=b.find(this.nodes,b.bind(function(a){return g.isIntercepted(a,f)},this));return null===h||"undefined"==typeof h},i.prototype._sortNodes=function(a){this.nodes=g.sort(this.nodes,a,this.width)},i.prototype._packNodes=function(){this._sortNodes(),this.float?b.each(this.nodes,b.bind(function(a,c){if(!a._updating&&"undefined"!=typeof a._origY&&a.y!=a._origY)for(var d=a.y;d>=a._origY;){var e=b.chain(this.nodes).find(b.bind(g._didCollide,{n:a,newY:d})).value();e||(a._dirty=!0,a.y=d),--d}},this)):b.each(this.nodes,b.bind(function(a,c){if(!a.locked)for(;a.y>0;){var d=a.y-1,e=0===c;if(c>0){var f=b.chain(this.nodes).take(c).find(b.bind(g._didCollide,{n:a,newY:d})).value();e="undefined"==typeof f}if(!e)break;a._dirty=a.y!=d,a.y=d}},this))},i.prototype._prepareNode=function(a,c){return a=b.defaults(a||{},{width:1,height:1,x:0,y:0}),a.x=parseInt(""+a.x),a.y=parseInt(""+a.y),a.width=parseInt(""+a.width),a.height=parseInt(""+a.height),a.autoPosition=a.autoPosition||!1,a.noResize=a.noResize||!1,a.noMove=a.noMove||!1,a.width>this.width?a.width=this.width:a.width<1&&(a.width=1),a.height<1&&(a.height=1),a.x<0&&(a.x=0),a.x+a.width>this.width&&(c?a.width=this.width-a.x:a.x=this.width-a.width),a.y<0&&(a.y=0),a},i.prototype._notify=function(){var a=Array.prototype.slice.call(arguments,0);if(a[0]="undefined"==typeof a[0]?[]:[a[0]],a[1]="undefined"==typeof a[1]||a[1],!this._updateCounter){var b=a[0].concat(this.getDirtyNodes());this.onchange(b,a[1])}},i.prototype.cleanNodes=function(){this._updateCounter||b.each(this.nodes,function(a){a._dirty=!1})},i.prototype.getDirtyNodes=function(){return b.filter(this.nodes,function(a){return a._dirty})},i.prototype.addNode=function(a,c){if(a=this._prepareNode(a),"undefined"!=typeof a.maxWidth&&(a.width=Math.min(a.width,a.maxWidth)),"undefined"!=typeof a.maxHeight&&(a.height=Math.min(a.height,a.maxHeight)),"undefined"!=typeof a.minWidth&&(a.width=Math.max(a.width,a.minWidth)),"undefined"!=typeof a.minHeight&&(a.height=Math.max(a.height,a.minHeight)),a._id=++h,a._dirty=!0,a.autoPosition){this._sortNodes();for(var d=0;;++d){var e=d%this.width,f=Math.floor(d/this.width);if(!(e+a.width>this.width||b.find(this.nodes,b.bind(g._isAddNodeIntercepted,{x:e,y:f,node:a})))){a.x=e,a.y=f;break}}}return this.nodes.push(a),"undefined"!=typeof c&&c&&this._addedNodes.push(b.clone(a)),this._fixCollisions(a),this._packNodes(),this._notify(),a},i.prototype.removeNode=function(a,c){c="undefined"==typeof c||c,this._removedNodes.push(b.clone(a)),a._id=null,this.nodes=b.without(this.nodes,a),this._packNodes(),this._notify(a,c)},i.prototype.canMoveNode=function(c,d,e,f,g){if(!this.isNodeChangedPosition(c,d,e,f,g))return!1;var h=Boolean(b.find(this.nodes,function(a){return a.locked}));if(!this.height&&!h)return!0;var j,k=new i(this.width,null,this.float,0,b.map(this.nodes,function(b){return b==c?j=a.extend({},b):a.extend({},b)}));if("undefined"==typeof j)return!0;k.moveNode(j,d,e,f,g);var l=!0;return h&&(l&=!Boolean(b.find(k.nodes,function(a){return a!=j&&Boolean(a.locked)&&Boolean(a._dirty)}))),this.height&&(l&=k.getGridHeight()<=this.height),l},i.prototype.canBePlacedWithRespectToHeight=function(c){if(!this.height)return!0;var d=new i(this.width,null,this.float,0,b.map(this.nodes,function(b){return a.extend({},b)}));return d.addNode(c),d.getGridHeight()<=this.height},i.prototype.isNodeChangedPosition=function(a,b,c,d,e){return"number"!=typeof b&&(b=a.x),"number"!=typeof c&&(c=a.y),"number"!=typeof d&&(d=a.width),"number"!=typeof e&&(e=a.height),"undefined"!=typeof a.maxWidth&&(d=Math.min(d,a.maxWidth)),"undefined"!=typeof a.maxHeight&&(e=Math.min(e,a.maxHeight)),"undefined"!=typeof a.minWidth&&(d=Math.max(d,a.minWidth)),"undefined"!=typeof a.minHeight&&(e=Math.max(e,a.minHeight)),a.x!=b||a.y!=c||a.width!=d||a.height!=e},i.prototype.moveNode=function(a,b,c,d,e,f){if(!this.isNodeChangedPosition(a,b,c,d,e))return a;if("number"!=typeof b&&(b=a.x),"number"!=typeof c&&(c=a.y),"number"!=typeof d&&(d=a.width),"number"!=typeof e&&(e=a.height),"undefined"!=typeof a.maxWidth&&(d=Math.min(d,a.maxWidth)),"undefined"!=typeof a.maxHeight&&(e=Math.min(e,a.maxHeight)),"undefined"!=typeof a.minWidth&&(d=Math.max(d,a.minWidth)),"undefined"!=typeof a.minHeight&&(e=Math.max(e,a.minHeight)),a.x==b&&a.y==c&&a.width==d&&a.height==e)return a;var g=a.width!=d;return a._dirty=!0,a.x=b,a.y=c,a.width=d,a.height=e,a.lastTriedX=b,a.lastTriedY=c,a.lastTriedWidth=d,a.lastTriedHeight=e,a=this._prepareNode(a,g),this._fixCollisions(a),f||(this._packNodes(),this._notify()),a},i.prototype.getGridHeight=function(){return b.reduce(this.nodes,function(a,b){return Math.max(a,b.y+b.height)},0)},i.prototype.beginUpdate=function(a){b.each(this.nodes,function(a){a._origY=a.y}),a._updating=!0},i.prototype.endUpdate=function(){b.each(this.nodes,function(a){a._origY=a.y});var a=b.find(this.nodes,function(a){return a._updating});a&&(a._updating=!1)};var j=function(d,e){var g,h,j=this;e=e||{},this.container=a(d), -// jscs:disable requireCamelCaseOrUpperCaseIdentifiers -"undefined"!=typeof e.handle_class&&(e.handleClass=e.handle_class,f("handle_class","handleClass")),"undefined"!=typeof e.item_class&&(e.itemClass=e.item_class,f("item_class","itemClass")),"undefined"!=typeof e.placeholder_class&&(e.placeholderClass=e.placeholder_class,f("placeholder_class","placeholderClass")),"undefined"!=typeof e.placeholder_text&&(e.placeholderText=e.placeholder_text,f("placeholder_text","placeholderText")),"undefined"!=typeof e.cell_height&&(e.cellHeight=e.cell_height,f("cell_height","cellHeight")),"undefined"!=typeof e.vertical_margin&&(e.verticalMargin=e.vertical_margin,f("vertical_margin","verticalMargin")),"undefined"!=typeof e.min_width&&(e.minWidth=e.min_width,f("min_width","minWidth")),"undefined"!=typeof e.static_grid&&(e.staticGrid=e.static_grid,f("static_grid","staticGrid")),"undefined"!=typeof e.is_nested&&(e.isNested=e.is_nested,f("is_nested","isNested")),"undefined"!=typeof e.always_show_resize_handle&&(e.alwaysShowResizeHandle=e.always_show_resize_handle,f("always_show_resize_handle","alwaysShowResizeHandle")), -// jscs:enable requireCamelCaseOrUpperCaseIdentifiers -e.itemClass=e.itemClass||"grid-stack-item";var k=this.container.closest("."+e.itemClass).length>0;if(this.opts=b.defaults(e||{},{width:parseInt(this.container.attr("data-gs-width"))||12,height:parseInt(this.container.attr("data-gs-height"))||0,itemClass:"grid-stack-item",placeholderClass:"grid-stack-placeholder",placeholderText:"",handle:".grid-stack-item-content",handleClass:null,cellHeight:60,verticalMargin:20,auto:!0,minWidth:768,float:!1,staticGrid:!1,_class:"grid-stack-instance-"+(1e4*Math.random()).toFixed(0),animate:Boolean(this.container.attr("data-gs-animate"))||!1,alwaysShowResizeHandle:e.alwaysShowResizeHandle||!1,resizable:b.defaults(e.resizable||{},{autoHide:!e.alwaysShowResizeHandle,handles:"se"}),draggable:b.defaults(e.draggable||{},{handle:(e.handleClass?"."+e.handleClass:e.handle?e.handle:"")||".grid-stack-item-content",scroll:!1,appendTo:"body"}),disableDrag:e.disableDrag||!1,disableResize:e.disableResize||!1,rtl:"auto",removable:!1,removeTimeout:2e3,verticalMarginUnit:"px",cellHeightUnit:"px",oneColumnModeClass:e.oneColumnModeClass||"grid-stack-one-column-mode",ddPlugin:null}),this.opts.ddPlugin===!1?this.opts.ddPlugin=c:null===this.opts.ddPlugin&&(this.opts.ddPlugin=b.first(c.registeredPlugins)||c),this.dd=new this.opts.ddPlugin(this),"auto"===this.opts.rtl&&(this.opts.rtl="rtl"===this.container.css("direction")),this.opts.rtl&&this.container.addClass("grid-stack-rtl"),this.opts.isNested=k,h="auto"===this.opts.cellHeight,h?j.cellHeight(j.cellWidth(),!0):this.cellHeight(this.opts.cellHeight,!0),this.verticalMargin(this.opts.verticalMargin,!0),this.container.addClass(this.opts._class),this._setStaticClass(),k&&this.container.addClass("grid-stack-nested"),this._initStyles(),this.grid=new i(this.opts.width,function(a,c){c="undefined"==typeof c||c;var d=0;b.each(a,function(a){c&&null===a._id?a.el&&a.el.remove():(a.el.attr("data-gs-x",a.x).attr("data-gs-y",a.y).attr("data-gs-width",a.width).attr("data-gs-height",a.height),d=Math.max(d,a.y+a.height))}),j._updateStyles(d+10)},this.opts.float,this.opts.height),this.opts.auto){var l=[],m=this;this.container.children("."+this.opts.itemClass+":not(."+this.opts.placeholderClass+")").each(function(b,c){c=a(c),l.push({el:c,i:parseInt(c.attr("data-gs-x"))+parseInt(c.attr("data-gs-y"))*m.opts.width})}),b.chain(l).sortBy(function(a){return a.i}).each(function(a){j._prepareElement(a.el)}).value()}if(this.setAnimation(this.opts.animate),this.placeholder=a('
'+this.opts.placeholderText+"
").hide(),this._updateContainerHeight(),this._updateHeightsOnResize=b.throttle(function(){j.cellHeight(j.cellWidth(),!1)},100),this.onResizeHandler=function(){if(h&&j._updateHeightsOnResize(),j._isOneColumnMode()){if(g)return;j.container.addClass(j.opts.oneColumnModeClass),g=!0,j.grid._sortNodes(),b.each(j.grid.nodes,function(a){j.container.append(a.el),j.opts.staticGrid||((a.noMove||j.opts.disableDrag)&&j.dd.draggable(a.el,"disable"),(a.noResize||j.opts.disableResize)&&j.dd.resizable(a.el,"disable"),a.el.trigger("resize"))})}else{if(!g)return;if(j.container.removeClass(j.opts.oneColumnModeClass),g=!1,j.opts.staticGrid)return;b.each(j.grid.nodes,function(a){a.noMove||j.opts.disableDrag||j.dd.draggable(a.el,"enable"),a.noResize||j.opts.disableResize||j.dd.resizable(a.el,"enable"),a.el.trigger("resize")})}},a(window).resize(this.onResizeHandler),this.onResizeHandler(),!j.opts.staticGrid&&"string"==typeof j.opts.removable){var n=a(j.opts.removable);this.dd.isDroppable(n)||this.dd.droppable(n,{accept:"."+j.opts.itemClass}),this.dd.on(n,"dropover",function(b,c){var d=a(c.draggable),e=d.data("_gridstack_node");e._grid===j&&j._setupRemovingTimeout(d)}).on(n,"dropout",function(b,c){var d=a(c.draggable),e=d.data("_gridstack_node");e._grid===j&&j._clearRemovingTimeout(d)})}if(!j.opts.staticGrid&&j.opts.acceptWidgets){var o=null,p=function(a,b){var c=o,d=c.data("_gridstack_node"),e=j.getCellFromPixel(b.offset,!0),f=Math.max(0,e.x),g=Math.max(0,e.y);if(d._added){if(!j.grid.canMoveNode(d,f,g))return;j.grid.moveNode(d,f,g),j._updateContainerHeight()}else d._added=!0,d.el=c,d.x=f,d.y=g,j.grid.cleanNodes(),j.grid.beginUpdate(d),j.grid.addNode(d),j.container.append(j.placeholder),j.placeholder.attr("data-gs-x",d.x).attr("data-gs-y",d.y).attr("data-gs-width",d.width).attr("data-gs-height",d.height).show(),d.el=j.placeholder,d._beforeDragX=d.x,d._beforeDragY=d.y,j._updateContainerHeight()};this.dd.droppable(j.container,{accept:function(b){b=a(b);var c=b.data("_gridstack_node");return(!c||c._grid!==j)&&b.is(j.opts.acceptWidgets===!0?".grid-stack-item":j.opts.acceptWidgets)}}).on(j.container,"dropover",function(b,c){var d=(j.container.offset(),a(c.draggable)),e=j.cellWidth(),f=j.cellHeight(),g=d.data("_gridstack_node"),h=g?g.width:Math.ceil(d.outerWidth()/e),i=g?g.height:Math.ceil(d.outerHeight()/f);o=d;var k=j.grid._prepareNode({width:h,height:i,_added:!1,_temporary:!0});d.data("_gridstack_node",k),d.data("_gridstack_node_orig",g),d.on("drag",p)}).on(j.container,"dropout",function(b,c){var d=a(c.draggable);d.unbind("drag",p);var e=d.data("_gridstack_node");e.el=null,j.grid.removeNode(e),j.placeholder.detach(),j._updateContainerHeight(),d.data("_gridstack_node",d.data("_gridstack_node_orig"))}).on(j.container,"drop",function(b,c){j.placeholder.detach();var d=a(c.draggable).data("_gridstack_node");d._grid=j;var e=a(c.draggable).clone(!1);e.data("_gridstack_node",d),a(c.draggable).remove(),d.el=e,j.placeholder.hide(),e.attr("data-gs-x",d.x).attr("data-gs-y",d.y).attr("data-gs-width",d.width).attr("data-gs-height",d.height).addClass(j.opts.itemClass).removeAttr("style").enableSelection().removeData("draggable").removeClass("ui-draggable ui-draggable-dragging ui-draggable-disabled").unbind("drag",p),j.container.append(e),j._prepareElementsByNode(e,d),j._updateContainerHeight(),j._triggerChangeEvent(),j.grid.endUpdate()})}}; -// jscs:disable requireCamelCaseOrUpperCaseIdentifiers -// jscs:enable requireCamelCaseOrUpperCaseIdentifiers -return j.prototype._triggerChangeEvent=function(a){var b=this.grid.getDirtyNodes(),c=!1,d=[];b&&b.length&&(d.push(b),c=!0),(c||a===!0)&&this.container.trigger("change",d)},j.prototype._triggerAddEvent=function(){this.grid._addedNodes&&this.grid._addedNodes.length>0&&(this.container.trigger("added",[b.map(this.grid._addedNodes,b.clone)]),this.grid._addedNodes=[])},j.prototype._triggerRemoveEvent=function(){this.grid._removedNodes&&this.grid._removedNodes.length>0&&(this.container.trigger("removed",[b.map(this.grid._removedNodes,b.clone)]),this.grid._removedNodes=[])},j.prototype._initStyles=function(){this._stylesId&&g.removeStylesheet(this._stylesId),this._stylesId="gridstack-style-"+(1e5*Math.random()).toFixed(),this._styles=g.createStylesheet(this._stylesId),null!==this._styles&&(this._styles._max=0)},j.prototype._updateStyles=function(a){if(null!==this._styles&&"undefined"!=typeof this._styles){var b,c="."+this.opts._class+" ."+this.opts.itemClass,d=this;if("undefined"==typeof a&&(a=this._styles._max,this._initStyles(),this._updateContainerHeight()),this.opts.cellHeight&&!(0!==this._styles._max&&a<=this._styles._max)&&(b=this.opts.verticalMargin&&this.opts.cellHeightUnit!==this.opts.verticalMarginUnit?function(a,b){return a&&b?"calc("+(d.opts.cellHeight*a+d.opts.cellHeightUnit)+" + "+(d.opts.verticalMargin*b+d.opts.verticalMarginUnit)+")":d.opts.cellHeight*a+d.opts.verticalMargin*b+d.opts.cellHeightUnit}:function(a,b){return d.opts.cellHeight*a+d.opts.verticalMargin*b+d.opts.cellHeightUnit},0===this._styles._max&&g.insertCSSRule(this._styles,c,"min-height: "+b(1,0)+";",0),a>this._styles._max)){for(var e=this._styles._max;e=f.grid.width||k<0?(f.opts.removable===!0&&f._setupRemovingTimeout(b),j=c._beforeDragX,k=c._beforeDragY,f.placeholder.detach(),f.placeholder.hide(),f.grid.removeNode(c),f._updateContainerHeight(),c._temporaryRemoved=!0):(f._clearRemovingTimeout(b),c._temporaryRemoved&&(f.grid.addNode(c),f.placeholder.attr("data-gs-x",j).attr("data-gs-y",k).attr("data-gs-width",h).attr("data-gs-height",i).show(),f.container.append(f.placeholder),c.el=f.placeholder,c._temporaryRemoved=!1));else if("resize"==a.type&&j<0)return; -// width and height are undefined if not resizing -var l="undefined"!=typeof h?h:c.lastTriedWidth,m="undefined"!=typeof i?i:c.lastTriedHeight;!f.grid.canMoveNode(c,j,k,h,i)||c.lastTriedX===j&&c.lastTriedY===k&&c.lastTriedWidth===l&&c.lastTriedHeight===m||(c.lastTriedX=j,c.lastTriedY=k,c.lastTriedWidth=h,c.lastTriedHeight=i,f.grid.moveNode(c,j,k,h,i),f._updateContainerHeight())},h=function(g,h){f.container.append(f.placeholder);var i=a(this);f.grid.cleanNodes(),f.grid.beginUpdate(c),d=f.cellWidth();var j=Math.ceil(i.outerHeight()/i.attr("data-gs-height"));e=f.container.height()/parseInt(f.container.attr("data-gs-current-height")),f.placeholder.attr("data-gs-x",i.attr("data-gs-x")).attr("data-gs-y",i.attr("data-gs-y")).attr("data-gs-width",i.attr("data-gs-width")).attr("data-gs-height",i.attr("data-gs-height")).show(),c.el=f.placeholder,c._beforeDragX=c.x,c._beforeDragY=c.y,f.dd.resizable(b,"option","minWidth",d*(c.minWidth||1)),f.dd.resizable(b,"option","minHeight",j*(c.minHeight||1)),"resizestart"==g.type&&i.find(".grid-stack-item").trigger("resizestart")},i=function(d,e){var g=a(this);if(g.data("_gridstack_node")){var h=!1;f.placeholder.detach(),c.el=g,f.placeholder.hide(),c._isAboutToRemove?(h=!0,b.removeData("_gridstack_node"),b.remove()):(f._clearRemovingTimeout(b),c._temporaryRemoved?(g.attr("data-gs-x",c._beforeDragX).attr("data-gs-y",c._beforeDragY).attr("data-gs-width",c.width).attr("data-gs-height",c.height).removeAttr("style"),c.x=c._beforeDragX,c.y=c._beforeDragY,f.grid.addNode(c)):g.attr("data-gs-x",c.x).attr("data-gs-y",c.y).attr("data-gs-width",c.width).attr("data-gs-height",c.height).removeAttr("style")),f._updateContainerHeight(),f._triggerChangeEvent(h),f.grid.endUpdate();var i=g.find(".grid-stack");i.length&&"resizestop"==d.type&&(i.each(function(b,c){a(c).data("gridstack").onResizeHandler()}),g.find(".grid-stack-item").trigger("resizestop"))}};this.dd.draggable(b,{start:h,stop:i,drag:g}).resizable(b,{start:h,stop:i,resize:g}),(c.noMove||this._isOneColumnMode()||this.opts.disableDrag)&&this.dd.draggable(b,"disable"),(c.noResize||this._isOneColumnMode()||this.opts.disableResize)&&this.dd.resizable(b,"disable"),b.attr("data-gs-locked",c.locked?"yes":null)}},j.prototype._prepareElement=function(b,c){c="undefined"!=typeof c&&c;var d=this;b=a(b),b.addClass(this.opts.itemClass);var e=d.grid.addNode({x:b.attr("data-gs-x"),y:b.attr("data-gs-y"),width:b.attr("data-gs-width"),height:b.attr("data-gs-height"),maxWidth:b.attr("data-gs-max-width"),minWidth:b.attr("data-gs-min-width"),maxHeight:b.attr("data-gs-max-height"),minHeight:b.attr("data-gs-min-height"),autoPosition:g.toBool(b.attr("data-gs-auto-position")),noResize:g.toBool(b.attr("data-gs-no-resize")),noMove:g.toBool(b.attr("data-gs-no-move")),locked:g.toBool(b.attr("data-gs-locked")),el:b,id:b.attr("data-gs-id"),_grid:d},c);b.data("_gridstack_node",e),this._prepareElementsByNode(b,e)},j.prototype.setAnimation=function(a){a?this.container.addClass("grid-stack-animate"):this.container.removeClass("grid-stack-animate")},j.prototype.addWidget=function(b,c,d,e,f,g,h,i,j,k,l){return b=a(b),"undefined"!=typeof c&&b.attr("data-gs-x",c),"undefined"!=typeof d&&b.attr("data-gs-y",d),"undefined"!=typeof e&&b.attr("data-gs-width",e),"undefined"!=typeof f&&b.attr("data-gs-height",f),"undefined"!=typeof g&&b.attr("data-gs-auto-position",g?"yes":null),"undefined"!=typeof h&&b.attr("data-gs-min-width",h),"undefined"!=typeof i&&b.attr("data-gs-max-width",i),"undefined"!=typeof j&&b.attr("data-gs-min-height",j),"undefined"!=typeof k&&b.attr("data-gs-max-height",k),"undefined"!=typeof l&&b.attr("data-gs-id",l),this.container.append(b),this._prepareElement(b,!0),this._triggerAddEvent(),this._updateContainerHeight(),this._triggerChangeEvent(!0),b},j.prototype.makeWidget=function(b){return b=a(b),this._prepareElement(b,!0),this._triggerAddEvent(),this._updateContainerHeight(),this._triggerChangeEvent(!0),b},j.prototype.willItFit=function(a,b,c,d,e){var f={x:a,y:b,width:c,height:d,autoPosition:e};return this.grid.canBePlacedWithRespectToHeight(f)},j.prototype.removeWidget=function(b,c){c="undefined"==typeof c||c,b=a(b);var d=b.data("_gridstack_node"); -// For Meteor support: https://github.com/troolee/gridstack.js/pull/272 -d||(d=this.grid.getNodeDataByDOMEl(b)),this.grid.removeNode(d,c),b.removeData("_gridstack_node"),this._updateContainerHeight(),c&&b.remove(),this._triggerChangeEvent(!0),this._triggerRemoveEvent()},j.prototype.removeAll=function(a){b.each(this.grid.nodes,b.bind(function(b){this.removeWidget(b.el,a)},this)),this.grid.nodes=[],this._updateContainerHeight()},j.prototype.destroy=function(b){a(window).off("resize",this.onResizeHandler),this.disable(),"undefined"==typeof b||b?this.container.remove():(this.removeAll(!1),this.container.removeData("gridstack")),g.removeStylesheet(this._stylesId),this.grid&&(this.grid=null)},j.prototype.resizable=function(b,c){var d=this;return b=a(b),b.each(function(b,e){e=a(e);var f=e.data("_gridstack_node");"undefined"!=typeof f&&null!==f&&"undefined"!=typeof a.ui&&(f.noResize=!c,f.noResize||d._isOneColumnMode()?d.dd.resizable(e,"disable"):d.dd.resizable(e,"enable"))}),this},j.prototype.movable=function(b,c){var d=this;return b=a(b),b.each(function(b,e){e=a(e);var f=e.data("_gridstack_node");"undefined"!=typeof f&&null!==f&&"undefined"!=typeof a.ui&&(f.noMove=!c,f.noMove||d._isOneColumnMode()?(d.dd.draggable(e,"disable"),e.removeClass("ui-draggable-handle")):(d.dd.draggable(e,"enable"),e.addClass("ui-draggable-handle")))}),this},j.prototype.enableMove=function(a,b){this.movable(this.container.children("."+this.opts.itemClass),a),b&&(this.opts.disableDrag=!a)},j.prototype.enableResize=function(a,b){this.resizable(this.container.children("."+this.opts.itemClass),a),b&&(this.opts.disableResize=!a)},j.prototype.disable=function(){this.movable(this.container.children("."+this.opts.itemClass),!1),this.resizable(this.container.children("."+this.opts.itemClass),!1),this.container.trigger("disable")},j.prototype.enable=function(){this.movable(this.container.children("."+this.opts.itemClass),!0),this.resizable(this.container.children("."+this.opts.itemClass),!0),this.container.trigger("enable")},j.prototype.locked=function(b,c){return b=a(b),b.each(function(b,d){d=a(d);var e=d.data("_gridstack_node");"undefined"!=typeof e&&null!==e&&(e.locked=c||!1,d.attr("data-gs-locked",e.locked?"yes":null))}),this},j.prototype.maxHeight=function(b,c){return b=a(b),b.each(function(b,d){d=a(d);var e=d.data("_gridstack_node");"undefined"!=typeof e&&null!==e&&(isNaN(c)||(e.maxHeight=c||!1,d.attr("data-gs-max-height",c)))}),this},j.prototype.minHeight=function(b,c){return b=a(b),b.each(function(b,d){d=a(d);var e=d.data("_gridstack_node");"undefined"!=typeof e&&null!==e&&(isNaN(c)||(e.minHeight=c||!1,d.attr("data-gs-min-height",c)))}),this},j.prototype.maxWidth=function(b,c){return b=a(b),b.each(function(b,d){d=a(d);var e=d.data("_gridstack_node");"undefined"!=typeof e&&null!==e&&(isNaN(c)||(e.maxWidth=c||!1,d.attr("data-gs-max-width",c)))}),this},j.prototype.minWidth=function(b,c){return b=a(b),b.each(function(b,d){d=a(d);var e=d.data("_gridstack_node");"undefined"!=typeof e&&null!==e&&(isNaN(c)||(e.minWidth=c||!1,d.attr("data-gs-min-width",c)))}),this},j.prototype._updateElement=function(b,c){b=a(b).first();var d=b.data("_gridstack_node");if("undefined"!=typeof d&&null!==d){var e=this;e.grid.cleanNodes(),e.grid.beginUpdate(d),c.call(this,b,d),e._updateContainerHeight(),e._triggerChangeEvent(),e.grid.endUpdate()}},j.prototype.resize=function(a,b,c){this._updateElement(a,function(a,d){b=null!==b&&"undefined"!=typeof b?b:d.width,c=null!==c&&"undefined"!=typeof c?c:d.height,this.grid.moveNode(d,d.x,d.y,b,c)})},j.prototype.move=function(a,b,c){this._updateElement(a,function(a,d){b=null!==b&&"undefined"!=typeof b?b:d.x,c=null!==c&&"undefined"!=typeof c?c:d.y,this.grid.moveNode(d,b,c,d.width,d.height)})},j.prototype.update=function(a,b,c,d,e){this._updateElement(a,function(a,f){b=null!==b&&"undefined"!=typeof b?b:f.x,c=null!==c&&"undefined"!=typeof c?c:f.y,d=null!==d&&"undefined"!=typeof d?d:f.width,e=null!==e&&"undefined"!=typeof e?e:f.height,this.grid.moveNode(f,b,c,d,e)})},j.prototype.verticalMargin=function(a,b){if("undefined"==typeof a)return this.opts.verticalMargin;var c=g.parseHeight(a);this.opts.verticalMarginUnit===c.unit&&this.opts.height===c.height||(this.opts.verticalMarginUnit=c.unit,this.opts.verticalMargin=c.height,b||this._updateStyles())},j.prototype.cellHeight=function(a,b){if("undefined"==typeof a){if(this.opts.cellHeight)return this.opts.cellHeight;var c=this.container.children("."+this.opts.itemClass).first();return Math.ceil(c.outerHeight()/c.attr("data-gs-height"))}var d=g.parseHeight(a);this.opts.cellHeightUnit===d.heightUnit&&this.opts.height===d.height||(this.opts.cellHeightUnit=d.unit,this.opts.cellHeight=d.height,b||this._updateStyles())},j.prototype.cellWidth=function(){return Math.round(this.container.outerWidth()/this.opts.width)},j.prototype.getCellFromPixel=function(a,b){var c="undefined"!=typeof b&&b?this.container.offset():this.container.position(),d=a.left-c.left,e=a.top-c.top,f=Math.floor(this.container.width()/this.opts.width),g=Math.floor(this.container.height()/parseInt(this.container.attr("data-gs-current-height")));return{x:Math.floor(d/f),y:Math.floor(e/g)}},j.prototype.batchUpdate=function(){this.grid.batchUpdate()},j.prototype.commit=function(){this.grid.commit(),this._updateContainerHeight()},j.prototype.isAreaEmpty=function(a,b,c,d){return this.grid.isAreaEmpty(a,b,c,d)},j.prototype.setStatic=function(a){this.opts.staticGrid=a===!0,this.enableMove(!a),this.enableResize(!a),this._setStaticClass()},j.prototype._setStaticClass=function(){var a="grid-stack-static";this.opts.staticGrid===!0?this.container.addClass(a):this.container.removeClass(a)},j.prototype._updateNodeWidths=function(a,b){this.grid._sortNodes(),this.grid.batchUpdate();for(var c={},d=0;d=a._orig_y;){var f=b.chain(this.nodes).find(function(b){return a!=b&&e.is_intercepted({x:a.x,y:d,width:a.width,height:a.height},b)}).value();f||(a._dirty=!0,a.y=d),--d}},this)):b.each(this.nodes,b.bind(function(a,c){if(!a.locked)for(;a.y>0;){var d=a.y-1,f=0==c;if(c>0){var g=b.chain(this.nodes).take(c).find(function(b){return e.is_intercepted({x:a.x,y:d,width:a.width,height:a.height},b)}).value();f="undefined"==typeof g}if(!f)break;a._dirty=a.y!=d,a.y=d}},this))},g.prototype._prepare_node=function(a,c){return a=b.defaults(a||{},{width:1,height:1,x:0,y:0}),a.x=parseInt(""+a.x),a.y=parseInt(""+a.y),a.width=parseInt(""+a.width),a.height=parseInt(""+a.height),a.auto_position=a.auto_position||!1,a.no_resize=a.no_resize||!1,a.no_move=a.no_move||!1,a.width>this.width?a.width=this.width:a.width<1&&(a.width=1),a.height<1&&(a.height=1),a.x<0&&(a.x=0),a.x+a.width>this.width&&(c?a.width=this.width-a.x:a.x=this.width-a.width),a.y<0&&(a.y=0),a},g.prototype._notify=function(){if(!this._update_counter){var a=Array.prototype.slice.call(arguments,1).concat(this.get_dirty_nodes());a=a.concat(this.get_dirty_nodes()),this.onchange(a)}},g.prototype.clean_nodes=function(){b.each(this.nodes,function(a){a._dirty=!1})},g.prototype.get_dirty_nodes=function(){return b.filter(this.nodes,function(a){return a._dirty})},g.prototype.add_node=function(a){if(a=this._prepare_node(a),"undefined"!=typeof a.max_width&&(a.width=Math.min(a.width,a.max_width)),"undefined"!=typeof a.max_height&&(a.height=Math.min(a.height,a.max_height)),"undefined"!=typeof a.min_width&&(a.width=Math.max(a.width,a.min_width)),"undefined"!=typeof a.min_height&&(a.height=Math.max(a.height,a.min_height)),a._id=++f,a._dirty=!0,a.auto_position){this._sort_nodes();for(var c=0;;++c){var d=c%this.width,g=Math.floor(c/this.width);if(!(d+a.width>this.width||b.find(this.nodes,function(b){return e.is_intercepted({x:d,y:g,width:a.width,height:a.height},b)}))){a.x=d,a.y=g;break}}}return this.nodes.push(a),this._fix_collisions(a),this._pack_nodes(),this._notify(),a},g.prototype.remove_node=function(a){a._id=null,this.nodes=b.without(this.nodes,a),this._pack_nodes(),this._notify(a)},g.prototype.can_move_node=function(c,d,e,f,h){var i=Boolean(b.find(this.nodes,function(a){return a.locked}));if(!this.height&&!i)return!0;var j,k=new g(this.width,null,this["float"],0,b.map(this.nodes,function(b){return b==c?j=a.extend({},b):a.extend({},b)}));k.move_node(j,d,e,f,h);var l=!0;return i&&(l&=!Boolean(b.find(k.nodes,function(a){return a!=j&&Boolean(a.locked)&&Boolean(a._dirty)}))),this.height&&(l&=k.get_grid_height()<=this.height),l},g.prototype.can_be_placed_with_respect_to_height=function(c){if(!this.height)return!0;var d=new g(this.width,null,this["float"],0,b.map(this.nodes,function(b){return a.extend({},b)}));return d.add_node(c),d.get_grid_height()<=this.height},g.prototype.move_node=function(a,b,c,d,e,f){if("number"!=typeof b&&(b=a.x),"number"!=typeof c&&(c=a.y),"number"!=typeof d&&(d=a.width),"number"!=typeof e&&(e=a.height),"undefined"!=typeof a.max_width&&(d=Math.min(d,a.max_width)),"undefined"!=typeof a.max_height&&(e=Math.min(e,a.max_height)),"undefined"!=typeof a.min_width&&(d=Math.max(d,a.min_width)),"undefined"!=typeof a.min_height&&(e=Math.max(e,a.min_height)),a.x==b&&a.y==c&&a.width==d&&a.height==e)return a;var g=a.width!=d;return a._dirty=!0,a.x=b,a.y=c,a.width=d,a.height=e,a=this._prepare_node(a,g),this._fix_collisions(a),f||(this._pack_nodes(),this._notify()),a},g.prototype.get_grid_height=function(){return b.reduce(this.nodes,function(a,b){return Math.max(a,b.y+b.height)},0)},g.prototype.begin_update=function(a){b.each(this.nodes,function(a){a._orig_y=a.y}),a._updating=!0},g.prototype.end_update=function(){b.each(this.nodes,function(a){a._orig_y=a.y});var a=b.find(this.nodes,function(a){return a._updating});a&&(a._updating=!1)};var h=function(c,d){var e,f=this;d=d||{},this.container=a(c),d.item_class=d.item_class||"grid-stack-item";var h=this.container.closest("."+d.item_class).size()>0;if(this.opts=b.defaults(d||{},{width:parseInt(this.container.attr("data-gs-width"))||12,height:parseInt(this.container.attr("data-gs-height"))||0,item_class:"grid-stack-item",placeholder_class:"grid-stack-placeholder",placeholder_text:"",handle:".grid-stack-item-content",handle_class:null,cell_height:60,vertical_margin:20,auto:!0,min_width:768,"float":!1,static_grid:!1,_class:"grid-stack-instance-"+(1e4*Math.random()).toFixed(0),animate:Boolean(this.container.attr("data-gs-animate"))||!1,always_show_resize_handle:d.always_show_resize_handle||!1,resizable:b.defaults(d.resizable||{},{autoHide:!d.always_show_resize_handle,handles:"se"}),draggable:b.defaults(d.draggable||{},{handle:(d.handle_class?"."+d.handle_class:d.handle?d.handle:"")||".grid-stack-item-content",scroll:!1,appendTo:"body"})}),this.opts.is_nested=h,this.container.addClass(this.opts._class),this._set_static_class(),h&&this.container.addClass("grid-stack-nested"),this._init_styles(),this.grid=new g(this.opts.width,function(a){var c=0;b.each(a,function(a){null==a._id?a.el.remove():(a.el.attr("data-gs-x",a.x).attr("data-gs-y",a.y).attr("data-gs-width",a.width).attr("data-gs-height",a.height),c=Math.max(c,a.y+a.height))}),f._update_styles(c+10)},this.opts["float"],this.opts.height),this.opts.auto){var i=[],j=this;this.container.children("."+this.opts.item_class+":not(."+this.opts.placeholder_class+")").each(function(b,c){c=a(c),i.push({el:c,i:parseInt(c.attr("data-gs-x"))+parseInt(c.attr("data-gs-y"))*j.opts.width})}),b.chain(i).sortBy(function(a){return a.i}).each(function(a){f._prepare_element(a.el)}).value()}this.set_animation(this.opts.animate),this.placeholder=a('
'+this.opts.placeholder_text+"
").hide(),this.container.height(this.grid.get_grid_height()*(this.opts.cell_height+this.opts.vertical_margin)-this.opts.vertical_margin),this.on_resize_handler=function(){if(f._is_one_column_mode()){if(e)return;e=!0,f.grid._sort_nodes(),b.each(f.grid.nodes,function(a){f.container.append(a.el),f.opts.static_grid||(a.no_move||a.el.draggable("disable"),a.no_resize||a.el.resizable("disable"))})}else{if(!e)return;if(e=!1,f.opts.static_grid)return;b.each(f.grid.nodes,function(a){a.no_move||a.el.draggable("enable"),a.no_resize||a.el.resizable("enable")})}},a(window).resize(this.on_resize_handler),this.on_resize_handler()};return h.prototype._trigger_change_event=function(a){var b=this.grid.get_dirty_nodes(),c=!1,d=[];b&&b.length&&(d.push(b),c=!0),(c||a===!0)&&this.container.trigger("change",d)},h.prototype._init_styles=function(){this._styles_id&&a('[data-gs-id="'+this._styles_id+'"]').remove(),this._styles_id="gridstack-style-"+(1e5*Math.random()).toFixed(),this._styles=e.create_stylesheet(this._styles_id),null!=this._styles&&(this._styles._max=0)},h.prototype._update_styles=function(a){if(null!=this._styles){var b="."+this.opts._class+" ."+this.opts.item_class;if("undefined"==typeof a&&(a=this._styles._max,this._init_styles(),this._update_container_height()),0==this._styles._max&&e.insert_css_rule(this._styles,b,"min-height: "+this.opts.cell_height+"px;",0),a>this._styles._max){for(var c=this._styles._max;a>c;++c)e.insert_css_rule(this._styles,b+'[data-gs-height="'+(c+1)+'"]',"height: "+(this.opts.cell_height*(c+1)+this.opts.vertical_margin*c)+"px;",c),e.insert_css_rule(this._styles,b+'[data-gs-min-height="'+(c+1)+'"]',"min-height: "+(this.opts.cell_height*(c+1)+this.opts.vertical_margin*c)+"px;",c),e.insert_css_rule(this._styles,b+'[data-gs-max-height="'+(c+1)+'"]',"max-height: "+(this.opts.cell_height*(c+1)+this.opts.vertical_margin*c)+"px;",c),e.insert_css_rule(this._styles,b+'[data-gs-y="'+c+'"]',"top: "+(this.opts.cell_height*c+this.opts.vertical_margin*c)+"px;",c);this._styles._max=a}}},h.prototype._update_container_height=function(){this.grid._update_counter||this.container.height(this.grid.get_grid_height()*(this.opts.cell_height+this.opts.vertical_margin)-this.opts.vertical_margin)},h.prototype._is_one_column_mode=function(){return(window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth)<=this.opts.min_width},h.prototype._prepare_element=function(c){var d=this;c=a(c),c.addClass(this.opts.item_class);var f=d.grid.add_node({x:c.attr("data-gs-x"),y:c.attr("data-gs-y"),width:c.attr("data-gs-width"),height:c.attr("data-gs-height"),max_width:c.attr("data-gs-max-width"),min_width:c.attr("data-gs-min-width"),max_height:c.attr("data-gs-max-height"),min_height:c.attr("data-gs-min-height"),auto_position:e.toBool(c.attr("data-gs-auto-position")),no_resize:e.toBool(c.attr("data-gs-no-resize")),no_move:e.toBool(c.attr("data-gs-no-move")),locked:e.toBool(c.attr("data-gs-locked")),el:c});if(c.data("_gridstack_node",f),!d.opts.static_grid){var g,h,i=function(a,b){var c,e,i=Math.round(b.position.left/g),j=Math.floor((b.position.top+h/2)/h);"drag"!=a.type&&(c=Math.round(b.size.width/g),e=Math.round(b.size.height/h)),d.grid.can_move_node(f,i,j,c,e)&&(d.grid.move_node(f,i,j,c,e),d._update_container_height())},j=function(b,e){d.container.append(d.placeholder);var i=a(this);d.grid.clean_nodes(),d.grid.begin_update(f),g=i.outerWidth()/i.attr("data-gs-width"),h=d.opts.cell_height+d.opts.vertical_margin,d.placeholder.attr("data-gs-x",i.attr("data-gs-x")).attr("data-gs-y",i.attr("data-gs-y")).attr("data-gs-width",i.attr("data-gs-width")).attr("data-gs-height",i.attr("data-gs-height")).show(),f.el=d.placeholder,c.resizable("option","minWidth",Math.round(g*(f.min_width||1))),c.resizable("option","minHeight",d.opts.cell_height*(f.min_height||1)),"resizestart"==b.type&&i.find(".grid-stack-item").trigger("resizestart")},k=function(b,c){d.placeholder.detach();var e=a(this);f.el=e,d.placeholder.hide(),e.attr("data-gs-x",f.x).attr("data-gs-y",f.y).attr("data-gs-width",f.width).attr("data-gs-height",f.height).removeAttr("style"),d._update_container_height(),d._trigger_change_event(),d.grid.end_update();var g=e.find(".grid-stack");g.length&&"resizestop"==b.type&&(g.each(function(b,c){a(c).data("gridstack").on_resize_handler()}),e.find(".grid-stack-item").trigger("resizestop"))};c.draggable(b.extend(this.opts.draggable,{containment:this.opts.is_nested?this.container.parent():null})).on("dragstart",j).on("dragstop",k).on("drag",i).resizable(b.extend(this.opts.resizable,{})).on("resizestart",j).on("resizestop",k).on("resize",i),(f.no_move||this._is_one_column_mode())&&c.draggable("disable"),(f.no_resize||this._is_one_column_mode())&&c.resizable("disable"),c.attr("data-gs-locked",f.locked?"yes":null)}},h.prototype.set_animation=function(a){a?this.container.addClass("grid-stack-animate"):this.container.removeClass("grid-stack-animate")},h.prototype.add_widget=function(b,c,d,e,f,g){return b=a(b),"undefined"!=typeof c&&b.attr("data-gs-x",c),"undefined"!=typeof d&&b.attr("data-gs-y",d),"undefined"!=typeof e&&b.attr("data-gs-width",e),"undefined"!=typeof f&&b.attr("data-gs-height",f),"undefined"!=typeof g&&b.attr("data-gs-auto-position",g?"yes":null),this.container.append(b),this._prepare_element(b),this._update_container_height(),this._trigger_change_event(!0),b},h.prototype.make_widget=function(b){return b=a(b),this._prepare_element(b),this._update_container_height(),this._trigger_change_event(!0),b},h.prototype.will_it_fit=function(a,b,c,d,e){var f={x:a,y:b,width:c,height:d,auto_position:e};return this.grid.can_be_placed_with_respect_to_height(f)},h.prototype.remove_widget=function(b,c){c="undefined"==typeof c?!0:c,b=a(b);var d=b.data("_gridstack_node");this.grid.remove_node(d),b.removeData("_gridstack_node"),this._update_container_height(),c&&b.remove(),this._trigger_change_event(!0)},h.prototype.remove_all=function(a){b.each(this.grid.nodes,b.bind(function(b){this.remove_widget(b.el,a)},this)),this.grid.nodes=[],this._update_container_height()},h.prototype.destroy=function(){a(window).off("resize",this.on_resize_handler),this.disable(),this.container.remove(),e.remove_stylesheet(this._styles_id),this.grid&&(this.grid=null)},h.prototype.resizable=function(b,c){var d=this;return b=a(b),b.each(function(b,e){e=a(e);var f=e.data("_gridstack_node");"undefined"!=typeof f&&null!=f&&(f.no_resize=!c,f.no_resize||d._is_one_column_mode()?e.resizable("disable"):e.resizable("enable"))}),this},h.prototype.movable=function(b,c){var d=this;return b=a(b),b.each(function(b,e){e=a(e);var f=e.data("_gridstack_node");"undefined"!=typeof f&&null!=f&&(f.no_move=!c,f.no_move||d._is_one_column_mode()?(e.draggable("disable"),e.removeClass("ui-draggable-handle")):(e.draggable("enable"),e.addClass("ui-draggable-handle")))}),this},h.prototype.disable=function(){this.movable(this.container.children("."+this.opts.item_class),!1),this.resizable(this.container.children("."+this.opts.item_class),!1),this.container.trigger("disable")},h.prototype.enable=function(){this.movable(this.container.children("."+this.opts.item_class),!0),this.resizable(this.container.children("."+this.opts.item_class),!0),this.container.trigger("enable")},h.prototype.locked=function(b,c){return b=a(b),b.each(function(b,d){d=a(d);var e=d.data("_gridstack_node");"undefined"!=typeof e&&null!=e&&(e.locked=c||!1,d.attr("data-gs-locked",e.locked?"yes":null))}),this},h.prototype.min_height=function(b,c){return b=a(b),b.each(function(b,d){d=a(d);var e=d.data("_gridstack_node");"undefined"!=typeof e&&null!=e&&(isNaN(c)||(e.min_height=c||!1,d.attr("data-gs-min-height",c)))}),this},h.prototype.min_width=function(b,c){return b=a(b),b.each(function(b,d){d=a(d);var e=d.data("_gridstack_node");"undefined"!=typeof e&&null!=e&&(isNaN(c)||(e.min_width=c||!1,d.attr("data-gs-min-width",c)))}),this},h.prototype._update_element=function(b,c){b=a(b).first();var d=b.data("_gridstack_node");if("undefined"!=typeof d&&null!=d){var e=this;e.grid.clean_nodes(),e.grid.begin_update(d),c.call(this,b,d),e._update_container_height(),e._trigger_change_event(),e.grid.end_update()}},h.prototype.resize=function(a,b,c){this._update_element(a,function(a,d){b=null!=b&&"undefined"!=typeof b?b:d.width,c=null!=c&&"undefined"!=typeof c?c:d.height,this.grid.move_node(d,d.x,d.y,b,c)})},h.prototype.move=function(a,b,c){this._update_element(a,function(a,d){b=null!=b&&"undefined"!=typeof b?b:d.x,c=null!=c&&"undefined"!=typeof c?c:d.y,this.grid.move_node(d,b,c,d.width,d.height)})},h.prototype.update=function(a,b,c,d,e){this._update_element(a,function(a,f){b=null!=b&&"undefined"!=typeof b?b:f.x,c=null!=c&&"undefined"!=typeof c?c:f.y,d=null!=d&&"undefined"!=typeof d?d:f.width,e=null!=e&&"undefined"!=typeof e?e:f.height,this.grid.move_node(f,b,c,d,e)})},h.prototype.cell_height=function(a){return"undefined"==typeof a?this.opts.cell_height:(a=parseInt(a),void(a!=this.opts.cell_height&&(this.opts.cell_height=a||this.opts.cell_height,this._update_styles())))},h.prototype.cell_width=function(){var a=this.container.children("."+this.opts.item_class).first();return Math.ceil(a.outerWidth()/a.attr("data-gs-width"))},h.prototype.get_cell_from_pixel=function(a){var b=this.container.position(),c=a.left-b.left,d=a.top-b.top,e=Math.floor(this.container.width()/this.opts.width),f=this.opts.cell_height+this.opts.vertical_margin;return{x:Math.floor(c/e),y:Math.floor(d/f)}},h.prototype.batch_update=function(){this.grid.batch_update()},h.prototype.commit=function(){this.grid.commit(),this._update_container_height()},h.prototype.is_area_empty=function(a,b,c,d){return this.grid.is_area_empty(a,b,c,d)},h.prototype.set_static=function(a){this.opts.static_grid=a===!0,this._set_static_class()},h.prototype._set_static_class=function(){var a="grid-stack-static";this.opts.static_grid===!0?this.container.addClass(a):this.container.removeClass(a)},d.GridStackUI=h,d.GridStackUI.Utils=e,a.fn.gridstack=function(b){return this.each(function(){var d=a(this);d.data("gridstack")||d.data("gridstack",new h(this,b)).on("dragstart",c).on("dragstop",c).on("drag",c).on("resizestart",c).on("resizestop",c).on("resize",c).on("change",c)})},d.GridStackUI}); //# sourceMappingURL=gridstack.min.map \ No newline at end of file diff --git a/dist/gridstack.min.map b/dist/gridstack.min.map index ff68a23c5..e3270cbb6 100644 --- a/dist/gridstack.min.map +++ b/dist/gridstack.min.map @@ -1 +1 @@ -{"version":3,"sources":["../src/gridstack.js","../src/gridstack.jQueryUI.js"],"names":["factory","define","amd","exports","jQuery","require","e","_","$","GridStackDragDropPlugin","grid","this","scope","window","obsolete","f","oldName","newName","wrapper","console","warn","apply","arguments","prototype","obsoleteOpts","Utils","isIntercepted","a","b","x","width","y","height","sort","nodes","dir","chain","map","node","max","value","sortBy","n","createStylesheet","id","style","document","createElement","setAttribute","styleSheet","cssText","appendChild","createTextNode","getElementsByTagName","sheet","removeStylesheet","remove","insertCSSRule","selector","rules","index","insertRule","addRule","toBool","v","toLowerCase","Boolean","_collisionNodeCheck","nn","_didCollide","bn","newY","_isAddNodeIntercepted","parseHeight","val","heightUnit","isString","match","Error","parseFloat","unit","is_intercepted","create_stylesheet","remove_stylesheet","insert_css_rule","registeredPlugins","registerPlugin","pluginClass","push","resizable","el","opts","draggable","droppable","isDroppable","on","eventName","callback","idSeq","GridStackEngine","onchange","floatMode","items","float","_updateCounter","_float","_addedNodes","_removedNodes","batchUpdate","commit","_packNodes","_notify","getNodeDataByDOMEl","find","get","_fixCollisions","_sortNodes","hasLocked","locked","collisionNode","bind","moveNode","isAreaEmpty","each","i","_updating","_origY","_dirty","canBeMoved","take","_prepareNode","resizing","defaults","parseInt","autoPosition","noResize","noMove","args","Array","slice","call","deletedNodes","concat","getDirtyNodes","cleanNodes","filter","addNode","triggerAddEvent","maxWidth","Math","min","maxHeight","minWidth","minHeight","_id","floor","clone","removeNode","detachNode","without","canMoveNode","isNodeChangedPosition","clonedNode","extend","res","getGridHeight","canBePlacedWithRespectToHeight","noPack","lastTriedX","lastTriedY","lastTriedWidth","lastTriedHeight","reduce","memo","beginUpdate","endUpdate","GridStack","oneColumnMode","isAutoCellHeight","self","container","handle_class","handleClass","item_class","itemClass","placeholder_class","placeholderClass","placeholder_text","placeholderText","cell_height","cellHeight","vertical_margin","verticalMargin","min_width","static_grid","staticGrid","is_nested","isNested","always_show_resize_handle","alwaysShowResizeHandle","closest","length","attr","handle","auto","_class","random","toFixed","animate","autoHide","handles","scroll","appendTo","disableDrag","disableResize","rtl","removable","removeTimeout","verticalMarginUnit","cellHeightUnit","oneColumnModeClass","ddPlugin","first","dd","css","addClass","cellWidth","_setStaticClass","_initStyles","_updateStyles","elements","_this","children","_prepareElement","setAnimation","placeholder","hide","_updateContainerHeight","_updateHeightsOnResize","throttle","onResizeHandler","_isOneColumnMode","append","trigger","removeClass","resize","trashZone","accept","event","ui","data","_grid","_setupRemovingTimeout","_clearRemovingTimeout","acceptWidgets","draggingElement","onDrag","pos","getCellFromPixel","offset","_added","show","_beforeDragX","_beforeDragY","is","origNode","ceil","outerWidth","outerHeight","_temporary","unbind","detach","removeAttr","enableSelection","removeData","_prepareElementsByNode","_triggerChangeEvent","forceTrigger","hasChanges","eventParams","_triggerAddEvent","_triggerRemoveEvent","_stylesId","_styles","_max","getHeight","prefix","nbRows","nbMargins","innerWidth","documentElement","clientWidth","body","_removeTimeout","setTimeout","_isAboutToRemove","clearTimeout","dragOrResize","round","position","left","top","type","size","_temporaryRemoved","onStartMoving","o","strictCellHeight","onEndMoving","forceNotify","nestedGrids","start","stop","drag","enable","addWidget","makeWidget","willItFit","removeWidget","removeAll","destroy","detachGrid","off","disable","movable","enableMove","doEnable","includeNewWidgets","enableResize","isNaN","_updateElement","move","update","noUpdate","heightData","useOffset","containerPos","relativeLeft","relativeTop","columnWidth","rowHeight","setStatic","staticValue","staticClassName","_updateNodeWidths","oldWidth","newWidth","undefined","setGridWidth","gridWidth","doNotPropagate","batch_update","_fix_collisions","is_area_empty","_sort_nodes","_pack_nodes","_prepare_node","clean_nodes","get_dirty_nodes","add_node","remove_node","can_move_node","move_node","get_grid_height","begin_update","end_update","can_be_placed_with_respect_to_height","_trigger_change_event","_init_styles","_update_styles","_update_container_height","_is_one_column_mode","_prepare_element","set_animation","add_widget","make_widget","will_it_fit","remove_widget","remove_all","min_height","_update_element","cell_width","get_cell_from_pixel","set_static","_set_static_class","GridStackUI","Engine","fn","gridstack","JQueryUIGridStackDragDropPlugin","Object","create","constructor","key","containment","parent"],"mappings":";;;;;;;CAOA,SAAUA,GACN,GAAsB,kBAAXC,SAAyBA,OAAOC,IACvCD,QAAQ,SAAU,UAAWD,OAC1B,IAAuB,mBAAZG,SAAyB,CACvC,IAAMC,OAASC,QAAQ,UAAa,MAAOC,IAC3C,IAAMC,EAAIF,QAAQ,UAAa,MAAOC,IACtCN,EAAQI,OAAQG,OAEhBP,GAAQI,OAAQG,IAErB,SAASC,EAAGD;;;;;;AA4GX,QAASE,GAAwBC,GAC7BC,KAAKD,KAAOA,EA3GhB,GAAIE,GAAQC,OAERC,EAAW,SAASC,EAAGC,EAASC,GAChC,GAAIC,GAAU,WAGV,MAFAC,SAAQC,KAAK,2BAA6BJ,EAAU,4DACzCC,EAAU,iDACdF,EAAEM,MAAMV,KAAMW,WAIzB,OAFAJ,GAAQK,UAAYR,EAAEQ,UAEfL,GAGPM,EAAe,SAASR,EAASC,GACjCE,QAAQC,KAAK,yBAA2BJ,EAAU,4DAC9CC,EAAU,kDAGdQ,GACAC,cAAe,SAASC,EAAGC,GACvB,QAASD,EAAEE,EAAIF,EAAEG,OAASF,EAAEC,GAAKD,EAAEC,EAAID,EAAEE,OAASH,EAAEE,GAAKF,EAAEI,EAAIJ,EAAEK,QAAUJ,EAAEG,GAAKH,EAAEG,EAAIH,EAAEI,QAAUL,EAAEI,IAG1GE,KAAM,SAASC,EAAOC,EAAKL,GAGvB,MAFAA,GAAQA,GAASvB,EAAE6B,MAAMF,GAAOG,IAAI,SAASC,GAAQ,MAAOA,GAAKT,EAAIS,EAAKR,QAAUS,MAAMC,QAC1FL,EAAMA,IAAO,EAAK,GAAI,EACf5B,EAAEkC,OAAOP,EAAO,SAASQ,GAA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AATA,EAAmB,CAC1B,GAAI8S,GAAMnX,UAAU,GAChBkB,EAAQlB,UAAU,EACtBoE,GAAGD,UAAUE,EAAM8S,EAAKjW,OAExBkD,GAAGD,UAAUlF,EAAE4J,UAAWxJ,KAAKD,KAAKiF,KAAKF,WACrC8N,MAAO5N,EAAK4N,OAAS,aACrBC,KAAM7N,EAAK6N,MAAQ,aACnBnE,OAAQ1J,EAAK0J,QAAU,eAG/B,OAAO1O,OAGX0X,EAAgC9W,UAAUqE,UAAY,SAASF,EAAIC,GAY/D,MAXAD,GAAKlF,EAAEkF,GACM,YAATC,GAA+B,WAATA,EACtBD,EAAGE,UAAUD,GAEbD,EAAGE,UAAUrF,EAAE4J,UAAWxJ,KAAKD,KAAKiF,KAAKC,WACrC8S,YAAa/X,KAAKD,KAAKiF,KAAK0G,SAAW1L,KAAKD,KAAK0K,UAAUuN,SAAW,KACtEpF,MAAO5N,EAAK4N,OAAS,aACrBC,KAAM7N,EAAK6N,MAAQ,aACnBC,KAAM9N,EAAK8N,MAAQ,gBAGpB9S,MAGX0X,EAAgC9W,UAAUsE,UAAY,SAASH,EAAIC,GAS/D,MARAD,GAAKlF,EAAEkF,GACM,YAATC,GAA+B,WAATA,EACtBD,EAAGG,UAAUF,GAEbD,EAAGG,WACC0J,OAAQ5J,EAAK4J,SAGd5O,MAGX0X,EAAgC9W,UAAUuE,YAAc,SAASJ,EAAIC,GAEjE,MADAD,GAAKlF,EAAEkF,GACAxB,QAAQwB,EAAGgK,KAAK,eAG3B2I,EAAgC9W,UAAUwE,GAAK,SAASL,EAAIM,EAAWC,GAEnE,MADAzF,GAAEkF,GAAIK,GAAGC,EAAWC,GACbtF,MAGJ0X","file":"gridstack.all.js"} \ No newline at end of file +{"version":3,"sources":["../src/gridstack.js"],"names":["factory","define","amd","exports","jQuery","require","e","_","$","event_stop_propagate","event","stopPropagation","scope","window","Utils","is_intercepted","a","b","x","width","y","height","sort","nodes","dir","chain","map","node","max","value","sortBy","n","create_stylesheet","id","style","document","createElement","setAttribute","styleSheet","cssText","appendChild","createTextNode","getElementsByTagName","sheet","remove_stylesheet","remove","insert_css_rule","selector","rules","index","insertRule","addRule","toBool","v","toLowerCase","Boolean","id_seq","GridStackEngine","onchange","float_mode","items","this","_update_counter","_float","prototype","batch_update","commit","_pack_nodes","_notify","_fix_collisions","_sort_nodes","nn","has_locked","find","locked","collision_node","bind","move_node","is_area_empty","each","i","_updating","_orig_y","new_y","bn","_dirty","can_be_moved","take","_prepare_node","resizing","defaults","parseInt","auto_position","no_resize","no_move","deleted_nodes","Array","slice","call","arguments","concat","get_dirty_nodes","clean_nodes","filter","add_node","max_width","Math","min","max_height","min_width","min_height","_id","floor","push","remove_node","without","can_move_node","cloned_node","clone","extend","res","get_grid_height","can_be_placed_with_respect_to_height","no_pack","reduce","memo","begin_update","end_update","GridStack","el","opts","one_column_mode","self","container","item_class","is_nested","closest","size","attr","placeholder_class","placeholder_text","handle","handle_class","cell_height","vertical_margin","auto","float","static_grid","_class","random","toFixed","animate","always_show_resize_handle","resizable","autoHide","handles","draggable","scroll","appendTo","addClass","_set_static_class","_init_styles","grid","_update_styles","elements","_this","children","_prepare_element","set_animation","placeholder","hide","on_resize_handler","_is_one_column_mode","append","resize","_trigger_change_event","forceTrigger","hasChanges","eventParams","length","trigger","_styles_id","_styles","_max","prefix","_update_container_height","innerWidth","documentElement","clientWidth","body","data","cell_width","drag_or_resize","ui","round","position","left","top","type","on_start_moving","o","outerWidth","show","on_end_moving","detach","removeAttr","nested_grids","containment","parent","on","enable","removeClass","add_widget","make_widget","will_it_fit","remove_widget","detach_node","removeData","remove_all","destroy","off","disable","val","movable","isNaN","_update_element","callback","first","move","update","ceil","get_cell_from_pixel","containerPos","relativeLeft","relativeTop","column_width","row_height","set_static","static_value","static_class_name","GridStackUI","fn","gridstack"],"mappings":"CAKA,SAAUA,GACN,GAAsB,kBAAXC,SAAyBA,OAAOC,IACvCD,QAAQ,SAAU,SAAU,iBAAkB,mBAAoB,kBAAmB,s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MyH,EAAeE,GAAevN,EAAGsF,KAAKM,MAAM0H,EAAcE,KAGpF5G,EAAUhE,UAAUC,aAAe,WAC/BJ,KAAKqG,KAAKjG,gBAGd+D,EAAUhE,UAAUE,OAAS,WACzBL,KAAKqG,KAAKhG,SACVL,KAAK4H,4BAGTzD,EAAUhE,UAAUc,cAAgB,SAAS5D,EAAGE,EAAGD,EAAOE,GACtD,MAAOwC,MAAKqG,KAAKpF,cAAc5D,EAAGE,EAAGD,EAAOE,IAGhD2G,EAAUhE,UAAU6K,WAAa,SAASC,GACtCjL,KAAKqE,KAAKiB,YAAe2F,KAAiB,EAC1CjL,KAAKmG,qBAGThC,EAAUhE,UAAUgG,kBAAoB,WACpC,GAAI+E,GAAoB,mBAEpBlL,MAAKqE,KAAKiB,eAAgB,EAC1BtF,KAAKwE,UAAU0B,SAASgF,GAExBlL,KAAKwE,UAAU8E,YAAY4B,IAInCnO,EAAMoO,YAAchH,EAEpBpH,EAAMoO,YAAYlO,MAAQA,EAK1BN,EAAEyO,GAAGC,UAAY,SAAShH,GACtB,MAAOrE,MAAKkB,KAAK,WACb,GAAIyH,GAAIhM,EAAEqD,KACL2I,GAAEV,KAAK,cACRU,EACKV,KAAK,YAAa,GAAI9D,GAAUnE,KAAMqE,IACtC+E,GAAG,YAAaxM,GAChBwM,GAAG,WAAYxM,GACfwM,GAAG,OAAQxM,GACXwM,GAAG,cAAexM,GAClBwM,GAAG,aAAcxM,GACjBwM,GAAG,SAAUxM,GACbwM,GAAG,SAAUxM,MAKvBG,EAAMoO","file":"gridstack.min.js"} \ No newline at end of file diff --git a/doc/FAQ.md b/doc/FAQ.md deleted file mode 100644 index 2e17c546f..000000000 --- a/doc/FAQ.md +++ /dev/null @@ -1,51 +0,0 @@ -Frequently asked questions -========================== - - - -**Table of Contents** *generated with [DocToc](http://doctoc.herokuapp.com/)* - -- [Gridstack doesn't use bootstrap 3 classes. Why you say it's bootstrap 3 friendly.](#gridstack-doesnt-use-bootstrap-3-classes-why-you-say-its-bootstrap-3-friendly) -- [How can I create a static layout using gridstack.](#how-can-i-create-a-static-layout-using-gridstack) - - - -### Gridstack doesn't use bootstrap 3 classes. Why you say it's bootstrap 3 friendly. - -**Q:** - -Original issue #390: - -> Hi, -> -> Excuse my ignorance but on your site you write "responsive bootstrap v3 friendly layouts" but how? -> -> In none of the examples you actually make use of any bootstrap classes. You add it to head but if you do that with gridster it works exactly the same.. -> -> What does gridstack do different then gridster? -> -> Reason I'm asking is because I have bootstrap HTML templates I want to put them in the grid so users can move it all around .. then when done have a normal html page (without the draggable grid). I thought gridstack would help to do that in favor of gridster but so far I have not seen any difference between the 2.. -> -> Thanks! - -**A:** - -We never declare that gridstack uses bootstrap classes. We say that gridstack could be responsive (widgets are not fixed width) it works well on bootstrap 3 pages with fixed or responsive layout. That's why it says bootstrap 3 friendly. - -It wasn't a goal for gridstack to create bootstrap 3 layouts. It's not a goal now neither. The goal of gridstack is to create dashboard layouts with draggable/resizable widgets. - -Gridstack uses internal grid to implement its logic. DOM nodes are just interpretation of this grid. So we or you probably could create a third party library which exports this internal grid into bootstrap 3/bootstrap 4/absolute divs/whatever layout. But I don't see this as part of gridstack core. As the same as support of angular/knockout/whatever libraries. We're doing all necessary for smooth support but it will never be a part of core. - -The main idea is to build as simple and flexible lib as possible. - - -### How can I create a static layout using gridstack. - -**Q:** - -How can I create a static layout not using jQuery UI, etc. - -**A:** - -The main propose of gridstack is creating dashboards with draggable and/or resizable widgets. You could disable this behavior by setting `static` option. At this point you will probably -still need to include jQuery UI. But we will try to decrease dependency of it in near future. diff --git a/doc/README.md b/doc/README.md deleted file mode 100644 index 3320fdbde..000000000 --- a/doc/README.md +++ /dev/null @@ -1,474 +0,0 @@ -gridstack.js API -================ - - - -**Table of Contents** *generated with [DocToc](http://doctoc.herokuapp.com/)* - -- [Options](#options) -- [Grid attributes](#grid-attributes) -- [Item attributes](#item-attributes) -- [Events](#events) - - [added(event, items)](#addedevent-items) - - [change(event, items)](#changeevent-items) - - [disable(event)](#disableevent) - - [dragstart(event, ui)](#dragstartevent-ui) - - [dragstop(event, ui)](#dragstopevent-ui) - - [enable(event)](#enableevent) - - [removed(event, items)](#removedevent-items) - - [resizestart(event, ui)](#resizestartevent-ui) - - [resizestop(event, ui)](#resizestopevent-ui) -- [API](#api) - - [addWidget(el[, x, y, width, height, autoPosition, minWidth, maxWidth, minHeight, maxHeight, id])](#addwidgetel-x-y-width-height-autoposition-minwidth-maxwidth-minheight-maxheight-id) - - [batchUpdate()](#batchupdate) - - [cellHeight()](#cellheight) - - [cellHeight(val)](#cellheightval) - - [cellWidth()](#cellwidth) - - [commit()](#commit) - - [destroy([detachGrid])](#destroydetachgrid) - - [disable()](#disable) - - [enable()](#enable) - - [enableMove(doEnable, includeNewWidgets)](#enablemovedoenable-includenewwidgets) - - [enableResize(doEnable, includeNewWidgets)](#enableresizedoenable-includenewwidgets) - - [getCellFromPixel(position[, useOffset])](#getcellfrompixelposition-useoffset) - - [isAreaEmpty(x, y, width, height)](#isareaemptyx-y-width-height) - - [locked(el, val)](#lockedel-val) - - [makeWidget(el)](#makewidgetel) - - [maxHeight(el, val)](#maxheightel-val) - - [minHeight(el, val)](#minheightel-val) - - [maxWidth(el, val)](#maxwidthel-val) - - [minWidth(el, val)](#minwidthel-val) - - [movable(el, val)](#movableel-val) - - [move(el, x, y)](#moveel-x-y) - - [removeWidget(el[, detachNode])](#removewidgetel-detachnode) - - [removeAll([detachNode])](#removealldetachnode) - - [resize(el, width, height)](#resizeel-width-height) - - [resizable(el, val)](#resizableel-val) - - [setAnimation(doAnimate)](#setanimationdoanimate) - - [setGridWidth(gridWidth, doNotPropagate)](#setgridwidthgridwidth-donotpropagate) - - [setStatic(staticValue)](#setstaticstaticvalue) - - [update(el, x, y, width, height)](#updateel-x-y-width-height) - - [verticalMargin(value, noUpdate)](#verticalmarginvalue-noupdate) - - [willItFit(x, y, width, height, autoPosition)](#willitfitx-y-width-height-autoposition) -- [Utils](#utils) - - [GridStackUI.Utils.sort(nodes[, dir[, width]])](#gridstackuiutilssortnodes-dir-width) - - - -## Options - -- `acceptWidgets` - if `true` of jquery selector the grid will accept widgets dragged from other grids or from - outside (default: `false`) See [example](http://troolee.github.io/gridstack.js/demo/two.html) -- `alwaysShowResizeHandle` - if `true` the resizing handles are shown even if the user is not hovering over the widget - (default: `false`) -- `animate` - turns animation on (default: `false`) -- `auto` - if `false` gridstack will not initialize existing items (default: `true`) -- `cellHeight` - one cell height (default: `60`). Can be: - - an integer (px) - - a string (ex: '10em', '100px', '10rem') - - 0 or null, in which case the library will not generate styles for rows. Everything must be defined in CSS files. - - `'auto'` - height will be calculated from cell width. -- `ddPlugin` - class that implement drag'n'drop functionallity for gridstack. If `false` grid will be static. (default: `null` - first available plugin will be used) -- `disableDrag` - disallows dragging of widgets (default: `false`). -- `disableResize` - disallows resizing of widgets (default: `false`). -- `draggable` - allows to override jQuery UI draggable options. (default: `{handle: '.grid-stack-item-content', scroll: false, appendTo: 'body'}`) -- `handle` - draggable handle selector (default: `'.grid-stack-item-content'`) -- `handleClass` - draggable handle class (e.g. `'grid-stack-item-content'`). If set `handle` is ignored (default: `null`) -- `height` - maximum rows amount. Default is `0` which means no maximum rows -- `float` - enable floating widgets (default: `false`) See [example](http://troolee.github.io/gridstack.js/demo/float.html) -- `itemClass` - widget class (default: `'grid-stack-item'`) -- `minWidth` - minimal width. If window width is less, grid will be shown in one-column mode (default: `768`) -- `oneColumnModeClass` - class set on grid when in one column mode (default: 'grid-stack-one-column-mode') -- `placeholderClass` - class for placeholder (default: `'grid-stack-placeholder'`) -- `placeholderText` - placeholder default content (default: `''`) -- `resizable` - allows to override jQuery UI resizable options. (default: `{autoHide: true, handles: 'se'}`) -- `removable` - if `true` widgets could be removed by dragging outside of the grid. It could also be a jQuery selector string, in this case widgets will be removed by dropping them there (default: `false`) See [example](http://troolee.github.io/gridstack.js/demo/two.html) -- `removeTimeout` - time in milliseconds before widget is being removed while dragging outside of the grid. (default: `2000`) -- `rtl` - if `true` turns grid to RTL. Possible values are `true`, `false`, `'auto'` (default: `'auto'`) See [example](http://troolee.github.io/gridstack.js/demo/rtl.html) -- `staticGrid` - makes grid static (default `false`). If true widgets are not movable/resizable. You don't even need jQueryUI draggable/resizable. A CSS class `grid-stack-static` is also added to the container. -- `verticalMargin` - vertical gap size (default: `20`). Can be: - - an integer (px) - - a string (ex: '2em', '20px', '2rem') -- `width` - amount of columns (default: `12`) - -## Grid attributes - -- `data-gs-animate` - turns animation on -- `data-gs-width` - amount of columns -- `data-gs-height` - maximum rows amount. Default is `0` which means no maximum rows. -- `data-gs-current-height` - current rows amount. Set by the library only. Can be used by the CSS rules. - -## Item attributes - -- `data-gs-x`, `data-gs-y` - element position -- `data-gs-width`, `data-gs-height` - element size -- `data-gs-max-width`, `data-gs-min-width`, `data-gs-max-height`, `data-gs-min-height` - element constraints -- `data-gs-no-resize` - disable element resizing -- `data-gs-no-move` - disable element moving -- `data-gs-auto-position` - tells to ignore `data-gs-x` and `data-gs-y` attributes and to place element to the first - available position -- `data-gs-locked` - the widget will be locked. It means another widget wouldn't be able to move it during dragging or resizing. -The widget can still be dragged or resized. You need to add `data-gs-no-resize` and `data-gs-no-move` attributes -to completely lock the widget. - -## Events - -### added(event, items) - -```javascript -$('.grid-stack').on('added', function(event, items) { - for (var i = 0; i < items.length; i++) { - console.log('item added'); - console.log(items[i]); - } -}); -``` - -### change(event, items) - -Occurs when adding/removing widgets or existing widgets change their position/size - -```javascript -var serializeWidgetMap = function(items) { - console.log(items); -}; - -$('.grid-stack').on('change', function(event, items) { - serializeWidgetMap(items); -}); -``` - -### disable(event) - -```javascript -$('.grid-stack').on('disable', function(event) { - var grid = event.target; -}); -``` - -### dragstart(event, ui) - -```javascript -$('.grid-stack').on('dragstart', function(event, ui) { - var grid = this; - var element = event.target; -}); -``` - -### dragstop(event, ui) - -```javascript -$('.grid-stack').on('dragstop', function(event, ui) { - var grid = this; - var element = event.target; -}); -``` - -### enable(event) - -```javascript -$('.grid-stack').on('enable', function(event) { - var grid = event.target; -}); -``` - -### removed(event, items) - -```javascript -$('.grid-stack').on('removed', function(event, items) { - for (var i = 0; i < items.length; i++) { - console.log('item removed'); - console.log(items[i]); - } -}); -``` - -### resizestart(event, ui) - -```javascript -$('.grid-stack').on('resizestart', function(event, ui) { - var grid = this; - var element = event.target; -}); -``` - -### resizestop(event, ui) - -```javascript -$('.grid-stack').on('resizestop', function(event, ui) { - var grid = this; - var element = event.target; -}); -``` - -## API - -### addWidget(el[, x, y, width, height, autoPosition, minWidth, maxWidth, minHeight, maxHeight, id]) - -Creates new widget and returns it. - -Parameters: - -- `el` - widget to add -- `x`, `y`, `width`, `height` - widget position/dimensions (optional) -- `autoPosition` - if `true` then `x`, `y` parameters will be ignored and widget will be places on the first available -position (optional) -- `minWidth` minimum width allowed during resize/creation (optional) -- `maxWidth` maximum width allowed during resize/creation (optional) -- `minHeight` minimum height allowed during resize/creation (optional) -- `maxHeight` maximum height allowed during resize/creation (optional) -- `id` value for `data-gs-id` (optional) - -Widget will be always placed even if result height is more than actual grid height. You need to use `willItFit` method -before calling `addWidget` for additional check. - -```javascript -$('.grid-stack').gridstack(); - -var grid = $('.grid-stack').data('gridstack'); -grid.addWidget(el, 0, 0, 3, 2, true); -``` - -### batchUpdate() - -Initailizes batch updates. You will see no changes until `commit` method is called. - -### cellHeight() - -Gets current cell height. - -### cellHeight(val) - -Update current cell height. This method rebuilds an internal CSS stylesheet. Note: You can expect performance issues if -call this method too often. - -```javascript -grid.cellHeight(grid.cellWidth() * 1.2); -``` - -### cellWidth() - -Gets current cell width. - -### commit() - -Finishes batch updates. Updates DOM nodes. You must call it after `batchUpdate`. - -### destroy([detachGrid]) - -Destroys a grid instance. - -Parameters: - -- `detachGrid` - if `false` nodes and grid will not be removed from the DOM (Optional. Default `true`). - -### disable() - -Disables widgets moving/resizing. This is a shortcut for: - -```javascript -grid.movable('.grid-stack-item', false); -grid.resizable('.grid-stack-item', false); -``` - -### enable() - -Enables widgets moving/resizing. This is a shortcut for: - -```javascript -grid.movable('.grid-stack-item', true); -grid.resizable('.grid-stack-item', true); -``` - -### enableMove(doEnable, includeNewWidgets) - -Enables/disables widget moving. `includeNewWidgets` will force new widgets to be draggable as per `doEnable`'s value by changing the `disableDrag` grid option. This is a shortcut for: - -```javascript -grid.movable(this.container.children('.' + this.opts.itemClass), doEnable); -``` - -### enableResize(doEnable, includeNewWidgets) - -Enables/disables widget resizing. `includeNewWidgets` will force new widgets to be resizable as per `doEnable`'s value by changing the `disableResize` grid option. This is a shortcut for: - -```javascript -grid.resizable(this.container.children('.' + this.opts.itemClass), doEnable); -``` - -### getCellFromPixel(position[, useOffset]) - -Get the position of the cell under a pixel on screen. - -Parameters : - -- `position` - the position of the pixel to resolve in absolute coordinates, as an object with `top` and `left` properties -- `useOffset` - if `true`, value will be based on offset vs position (Optional. Default `false`). Useful when grid is within `position: relative` element. - -Returns an object with properties `x` and `y` i.e. the column and row in the grid. - -### isAreaEmpty(x, y, width, height) - -Checks if specified area is empty. - -### locked(el, val) - -Locks/unlocks widget. - -- `el` - widget to modify. -- `val` - if `true` widget will be locked. - -### makeWidget(el) - -If you add elements to your gridstack container by hand, you have to tell gridstack afterwards to make them widgets. If you want gridstack to add the elements for you, use `addWidget` instead. -Makes the given element a widget and returns it. - -Parameters: - -- `el` - element to convert to a widget - -```javascript -$('.grid-stack').gridstack(); - -$('.grid-stack').append('
') -var grid = $('.grid-stack').data('gridstack'); -grid.makeWidget('gsi-1'); -``` - -### maxHeight(el, val) - -Set the `maxHeight` for a widget. - -- `el` - widget to modify. -- `val` - A numeric value of the number of rows - -### minHeight(el, val) - -Set the `minHeight` for a widget. - -- `el` - widget to modify. -- `val` - A numeric value of the number of rows - -### maxWidth(el, val) - -Set the `maxWidth` for a widget. - -- `el` - widget to modify. -- `val` - A numeric value of the number of columns - -### minWidth(el, val) - -Set the `minWidth` for a widget. - -- `el` - widget to modify. -- `val` - A numeric value of the number of columns - -### movable(el, val) - -Enables/Disables moving. - -- `el` - widget to modify -- `val` - if `true` widget will be draggable. - -### move(el, x, y) - -Changes widget position - -Parameters: - -- `el` - widget to move -- `x`, `y` - new position. If value is `null` or `undefined` it will be ignored. - -### removeWidget(el[, detachNode]) - -Removes widget from the grid. - -Parameters: - -- `el` - widget to remove. -- `detachNode` - if `false` node won't be removed from the DOM (Optional. Default `true`). - -### removeAll([detachNode]) - -Removes all widgets from the grid. - -Parameters: - -- `detachNode` - if `false` nodes won't be removed from the DOM (Optional. Default `true`). - -### resize(el, width, height) - -Changes widget size - -Parameters: - -- `el` - widget to resize -- `width`, `height` - new dimensions. If value is `null` or `undefined` it will be ignored. - -### resizable(el, val) - -Enables/Disables resizing. - -- `el` - widget to modify -- `val` - if `true` widget will be resizable. - -### setAnimation(doAnimate) - -Toggle the grid animation state. Toggles the `grid-stack-animate` class. - -- `doAnimate` - if `true` the grid will animate. - -### setGridWidth(gridWidth, doNotPropagate) - -(Experimental) Modify number of columns in the grid. Will attempt to update existing widgets to conform to new number of columns. Requires `gridstack-extra.css` or `gridstack-extra.min.css`. - -- `gridWidth` - Integer between 1 and 12. -- `doNotPropagate` - if true existing widgets will not be updated. - -### setStatic(staticValue) - -Toggle the grid static state. Also toggle the `grid-stack-static` class. - -- `staticValue` - if `true` the grid becomes static. - -### update(el, x, y, width, height) - -Parameters: - -- `el` - widget to move -- `x`, `y` - new position. If value is `null` or `undefined` it will be ignored. -- `width`, `height` - new dimensions. If value is `null` or `undefined` it will be ignored. - -Updates widget position/size. - -### verticalMargin(value, noUpdate) - -Parameters: - -- `value` - new vertical margin value. -- `noUpdate` - if true, styles will not be updated. - -### willItFit(x, y, width, height, autoPosition) - -Returns `true` if the `height` of the grid will be less the vertical constraint. Always returns `true` if grid doesn't -have `height` constraint. - -```javascript -if (grid.willItFit(newNode.x, newNode.y, newNode.width, newNode.height, true)) { - grid.addWidget(newNode.el, newNode.x, newNode.y, newNode.width, newNode.height, true); -} -else { - alert('Not enough free space to place the widget'); -} -``` - - -## Utils - -### GridStackUI.Utils.sort(nodes[, dir[, width]]) - -Sorts array of nodes - -- `nodes` - array to sort -- `dir` - `1` for asc, `-1` for desc (optional) -- `width` - width of the grid. If `undefined` the width will be calculated automatically (optional). diff --git a/karma.conf.js b/karma.conf.js deleted file mode 100644 index 4230ca8a3..000000000 --- a/karma.conf.js +++ /dev/null @@ -1,81 +0,0 @@ -// Karma configuration -// Generated on Thu Feb 18 2016 22:00:23 GMT+0100 (CET) - -module.exports = function(config) { - config.set({ - - // base path that will be used to resolve all patterns (eg. files, exclude) - basePath: '', - - - // frameworks to use - // available frameworks: https://npmjs.org/browse/keyword/karma-adapter - frameworks: ['jasmine'], - - - // list of files / patterns to load in the browser - files: [ - 'bower_components/jquery/dist/jquery.min.js', - 'bower_components/jquery-ui/jquery-ui.min.js', - 'bower_components/lodash/dist/lodash.min.js', - 'src/gridstack.js', - 'src/gridstack.jQueryUI.js', - 'spec/*-spec.js' - ], - - - // list of files to exclude - exclude: [ - ], - - - // 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'], - }, - - - // test results reporter to use - // possible values: 'dots', 'progress' - // available reporters: https://npmjs.org/browse/keyword/karma-reporter - reporters: ['progress', 'coverage', 'coveralls'], - - coverageReporter: { - type: 'lcov', // lcov or lcovonly are required for generating lcov.info files - dir: 'coverage/' - }, - - // web server port - port: 9876, - - - // enable / disable colors in the output (reporters and logs) - colors: true, - - - // level of logging - // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN - // config.LOG_INFO || config.LOG_DEBUG - logLevel: config.LOG_INFO, - - - // enable / disable watching file and executing tests whenever any file changes - autoWatch: true, - - - // start these browsers - // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher - browsers: ['PhantomJS'], - - - // Continuous Integration mode - // if true, Karma captures browsers, runs the tests and exits - singleRun: true, - - // Concurrency level - // how many browser should be started simultaneous - concurrency: Infinity - }); -} diff --git a/package.json b/package.json old mode 100644 new mode 100755 index b203ab8a9..62f5d437f --- a/package.json +++ b/package.json @@ -1,16 +1,12 @@ { "name": "gridstack", - "version": "0.3.0-dev", + "version": "0.2.3", "description": "gridstack.js is a jQuery plugin for widget layout", "main": "dist/gridstack.js", "repository": { "type": "git", "url": "git+https://github.com/troolee/gridstack.js.git" }, - "scripts": { - "build": "grunt", - "test": "karma start karma.conf.js" - }, "keywords": [ "gridstack", "grid", @@ -24,35 +20,11 @@ "url": "https://github.com/troolee/gridstack.js/issues" }, "homepage": "http://troolee.github.io/gridstack.js/", - "dependencies": { - "jquery": "^3.1.0", - "jquery-ui": "^1.12.0", - "lodash": "^4.14.2" - }, "devDependencies": { - "connect": "^3.4.1", - "coveralls": "^2.11.8", - "doctoc": "^1.0.0", "grunt": "^0.4.5", - "grunt-cli": "^1.2.0", - "grunt-contrib-connect": "^0.11.2", "grunt-contrib-copy": "^0.8.2", "grunt-contrib-cssmin": "^0.14.0", - "grunt-contrib-jshint": "^1.0.0", - "grunt-contrib-uglify": "^0.11.1", - "grunt-contrib-watch": "^0.6.1", - "grunt-doctoc": "^0.1.1", - "grunt-jscs": "^2.8.0", - "grunt-protractor-runner": "^3.2.0", - "grunt-protractor-webdriver": "^0.2.5", - "grunt-sass": "^1.1.0", - "jasmine-core": "^2.4.1", - "karma": "^1.1.2", - "karma-coverage": "^1.1.1", - "karma-coveralls": "^1.1.2", - "karma-jasmine": "^1.0.2", - "karma-phantomjs-launcher": "^1.0.0", - "phantomjs-prebuilt": "^2.1.5", - "serve-static": "^1.10.2" + "grunt-contrib-uglify": "^0.10.1", + "grunt-sass": "^1.1.0" } } diff --git a/protractor.conf.js b/protractor.conf.js deleted file mode 100644 index edcc3f40e..000000000 --- a/protractor.conf.js +++ /dev/null @@ -1,12 +0,0 @@ -exports.config = { - seleniumAddress: 'http://localhost:4444/wd/hub', - specs: ['spec/e2e/*-spec.js'], - capabilities: { - browserName: 'firefox', - version: '', - platform: 'ANY', - loggingPrefs: { - browser: 'SEVERE' - } - }, -}; diff --git a/spec/e2e/gridstack-spec.js b/spec/e2e/gridstack-spec.js deleted file mode 100644 index 7f3716658..000000000 --- a/spec/e2e/gridstack-spec.js +++ /dev/null @@ -1,24 +0,0 @@ -describe('gridstack.js with height', function() { - beforeAll(function() { - browser.ignoreSynchronization = true; - }); - - beforeEach(function() { - browser.get('http://localhost:8080/spec/e2e/html/gridstack-with-height.html'); - }); - - it('shouldn\'t throw exeption when dragging widget outside the grid', function() { - var widget = element(by.id('item-1')); - var gridContainer = element(by.id('grid')); - - browser.actions() - .mouseDown(widget, {x: 20, y: 20}) - .mouseMove(gridContainer, {x: 300, y: 20}) - .mouseUp() - .perform(); - - browser.manage().logs().get('browser').then(function(browserLog) { - expect(browserLog.length).toEqual(0); - }); - }); -}); diff --git a/spec/e2e/html/gridstack-with-height.html b/spec/e2e/html/gridstack-with-height.html deleted file mode 100644 index 2f543eba0..000000000 --- a/spec/e2e/html/gridstack-with-height.html +++ /dev/null @@ -1,73 +0,0 @@ - - - - - - - - - Codestin Search App - - - - - - - - - - - - - - -
-

gridstack.js tests

- -
- -
-
-
- - - - - diff --git a/spec/gridstack-engine-spec.js b/spec/gridstack-engine-spec.js deleted file mode 100644 index ef18255a0..000000000 --- a/spec/gridstack-engine-spec.js +++ /dev/null @@ -1,311 +0,0 @@ -describe('gridstack engine', function() { - 'use strict'; - - var e; - var w; - - beforeEach(function() { - w = window; - e = w.GridStackUI.Engine; - }); - - describe('test constructor', function() { - var engine; - - beforeAll(function() { - engine = new GridStackUI.Engine(12); - }); - - it('should be setup properly', function() { - expect(engine.width).toEqual(12); - expect(engine.float).toEqual(false); - expect(engine.height).toEqual(0); - expect(engine.nodes).toEqual([]); - }); - }); - - describe('test _prepareNode', function() { - var engine; - - beforeAll(function() { - engine = new GridStackUI.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})); - }); - }); - - describe('test isAreaEmpty', function() { - var engine; - - beforeAll(function() { - engine = new GridStackUI.Engine(12, null, true); - engine.nodes = [ - engine._prepareNode({x: 3, y: 2, width: 3, height: 2}) - ]; - }); - - it('should be true', function() { - expect(engine.isAreaEmpty(0, 0, 3, 2)).toEqual(true); - expect(engine.isAreaEmpty(3, 4, 3, 2)).toEqual(true); - }); - - it('should be false', function() { - expect(engine.isAreaEmpty(1, 1, 3, 2)).toEqual(false); - expect(engine.isAreaEmpty(2, 3, 3, 2)).toEqual(false); - }); - }); - - describe('test cleanNodes/getDirtyNodes', function() { - var engine; - - beforeAll(function() { - engine = new GridStackUI.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}) - ]; - }); - - beforeEach(function() { - engine._updateCounter = 0; - }); - - it('should return all dirty nodes', function() { - var nodes = engine.getDirtyNodes(); - - expect(nodes.length).toEqual(2); - expect(nodes[0].idx).toEqual(1); - expect(nodes[1].idx).toEqual(2); - }); - - it('should\'n clean nodes if _updateCounter > 0', function() { - engine._updateCounter = 1; - engine.cleanNodes(); - - expect(engine.getDirtyNodes().length).toBeGreaterThan(0); - }); - - it('should clean all dirty nodes', function() { - engine.cleanNodes(); - - expect(engine.getDirtyNodes().length).toEqual(0); - }); - }); - - describe('test batchUpdate/commit', function() { - var engine; - - beforeAll(function() { - engine = new GridStackUI.Engine(12); - }); - - it('should work on not float grids', function() { - expect(engine.float).toEqual(false); - engine.batchUpdate(); - expect(engine._updateCounter).toBeGreaterThan(0); - expect(engine.float).toEqual(true); - engine.commit(); - expect(engine._updateCounter).toEqual(0); - expect(engine.float).toEqual(false); - }); - }); - - describe('test batchUpdate/commit', function() { - var engine; - - beforeAll(function() { - engine = new GridStackUI.Engine(12, null, true); - }); - - it('should work on float grids', function() { - expect(engine.float).toEqual(true); - engine.batchUpdate(); - expect(engine._updateCounter).toBeGreaterThan(0); - expect(engine.float).toEqual(true); - engine.commit(); - expect(engine._updateCounter).toEqual(0); - expect(engine.float).toEqual(true); - }); - }); - - describe('test _notify', function() { - var engine; - var spy; - - beforeEach(function() { - spy = { - callback: function() {} - }; - spyOn(spy, 'callback'); - - engine = new GridStackUI.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}) - ]; - }); - - it('should\'n be called if _updateCounter > 0', function() { - engine._updateCounter = 1; - engine._notify(); - - expect(spy.callback).not.toHaveBeenCalled(); - }); - - it('should by called with dirty nodes', function() { - engine._notify(); - - expect(spy.callback).toHaveBeenCalledWith([ - engine.nodes[0], - engine.nodes[1] - ], true); - }); - - it('should by called with extra passed node to be removed', function() { - var n1 = {idx: -1}; - - engine._notify(n1); - - expect(spy.callback).toHaveBeenCalledWith([ - n1, - engine.nodes[0], - engine.nodes[1] - ], true); - }); - - it('should by called with extra passed node to be removed and should maintain false parameter', function() { - var n1 = {idx: -1}; - - engine._notify(n1, false); - - expect(spy.callback).toHaveBeenCalledWith([ - n1, - engine.nodes[0], - engine.nodes[1] - ], false); - }); - }); - - describe('test _packNodes', function() { - describe('using not float mode', function() { - var engine; - - var findNode = function(engine, id) { - return _.find(engine.nodes, function(i) { return i._id === id; }); - }; - - beforeEach(function() { - engine = new GridStackUI.Engine(12, null, false); - }); - - it('shouldn\'t pack one node with y coord eq 0', function() { - engine.nodes = [ - {x: 0, y: 0, width: 1, height: 1, _id: 1}, - ]; - - engine._packNodes(); - - expect(findNode(engine, 1)).toEqual(jasmine.objectContaining({x: 0, y: 0, width: 1, height: 1})); - expect(findNode(engine, 1)._dirty).toBeFalsy(); - }); - - it('should pack one node correctly', function() { - engine.nodes = [ - {x: 0, y: 1, width: 1, height: 1, _id: 1}, - ]; - - engine._packNodes(); - - expect(findNode(engine, 1)).toEqual(jasmine.objectContaining({x: 0, y: 0, width: 1, height: 1, _dirty: true})); - }); - - it('should pack nodes correctly', function() { - engine.nodes = [ - {x: 0, y: 1, width: 1, height: 1, _id: 1}, - {x: 0, y: 5, width: 1, height: 1, _id: 2}, - ]; - - engine._packNodes(); - - expect(findNode(engine, 1)).toEqual(jasmine.objectContaining({x: 0, y: 0, width: 1, height: 1, _dirty: true})); - expect(findNode(engine, 2)).toEqual(jasmine.objectContaining({x: 0, y: 1, width: 1, height: 1, _dirty: true})); - }); - - it('should pack nodes correctly', function() { - engine.nodes = [ - {x: 0, y: 5, width: 1, height: 1, _id: 1}, - {x: 0, y: 1, width: 1, height: 1, _id: 2}, - ]; - - engine._packNodes(); - - expect(findNode(engine, 2)).toEqual(jasmine.objectContaining({x: 0, y: 0, width: 1, height: 1, _dirty: true})); - expect(findNode(engine, 1)).toEqual(jasmine.objectContaining({x: 0, y: 1, width: 1, height: 1, _dirty: true})); - }); - - it('should respect locked nodes', function() { - engine.nodes = [ - {x: 0, y: 1, width: 1, height: 1, _id: 1, locked: true}, - {x: 0, y: 5, width: 1, height: 1, _id: 2}, - ]; - - engine._packNodes(); - - expect(findNode(engine, 1)).toEqual(jasmine.objectContaining({x: 0, y: 1, width: 1, height: 1})); - expect(findNode(engine, 1)._dirty).toBeFalsy(); - expect(findNode(engine, 2)).toEqual(jasmine.objectContaining({x: 0, y: 2, width: 1, height: 1, _dirty: true})); - }); - }); - }); - - describe('test isNodeChangedPosition', function() { - var engine; - - beforeAll(function() { - engine = new GridStackUI.Engine(12); - }); - - it('should return true for changed x', function() { - var widget = { x: 1, y: 2, width: 3, height: 4 }; - expect(engine.isNodeChangedPosition(widget, 2, 2)).toEqual(true); - }); - - it('should return true for changed y', function() { - var widget = { x: 1, y: 2, width: 3, height: 4 }; - expect(engine.isNodeChangedPosition(widget, 1, 1)).toEqual(true); - }); - - it('should return true for changed width', function() { - var widget = { x: 1, y: 2, width: 3, height: 4 }; - expect(engine.isNodeChangedPosition(widget, 2, 2, 4, 4)).toEqual(true); - }); - - it('should return true for changed height', function() { - var widget = { x: 1, y: 2, width: 3, height: 4 }; - expect(engine.isNodeChangedPosition(widget, 1, 2, 3, 3)).toEqual(true); - }); - - it('should return false for unchanged position', function() { - var widget = { x: 1, y: 2, width: 3, height: 4 }; - expect(engine.isNodeChangedPosition(widget, 1, 2, 3, 4)).toEqual(false); - }); - }); -}); diff --git a/spec/gridstack-spec.js b/spec/gridstack-spec.js deleted file mode 100644 index 0615d791f..000000000 --- a/spec/gridstack-spec.js +++ /dev/null @@ -1,1269 +0,0 @@ -describe('gridstack', function() { - 'use strict'; - - var e; - var w; - var gridstackHTML = - '
' + - '
' + - '
' + - '
' + - '
' + - '
' + - '
' + - '
'; - - beforeEach(function() { - w = window; - e = w.GridStackUI.Engine; - }); - - describe('setup of gridstack', function() { - - it('should exist setup function.', function() { - - expect(e).not.toBeNull(); - expect(typeof e).toBe('function'); - }); - - it('should set default params correctly.', function() { - e.call(w); - expect(w.width).toBeUndefined(); - expect(w.float).toBe(false); - expect(w.height).toEqual(0); - expect(w.nodes).toEqual([]); - expect(typeof w.onchange).toBe('function'); - expect(w._updateCounter).toEqual(0); - expect(w._float).toEqual(w.float); - }); - - it('should set params correctly.', function() { - var fkt = function() { }; - var arr = [1,2,3]; - - e.call(w, 1, fkt, true, 2, arr); - expect(w.width).toEqual(1); - expect(w.float).toBe(true); - expect(w.height).toEqual(2); - expect(w.nodes).toEqual(arr); - expect(w.onchange).toEqual(fkt); - expect(w._updateCounter).toEqual(0); - expect(w._float).toEqual(w.float); - }); - - - }); - - describe('batch update', function() { - - it('should set float and counter when calling batchUpdate.', function() { - e.prototype.batchUpdate.call(w); - expect(w.float).toBe(true); - expect(w._updateCounter).toEqual(1); - }); - - //test commit function - - }); - - describe('sorting of nodes', function() { - - it('should sort ascending with width.', function() { - w.nodes = [{x: 7, y: 0}, {x: 4, y: 4}, {x: 9, y: 0}, {x: 0, y: 1}]; - e.prototype._sortNodes.call(w, 1); - expect(w.nodes).toEqual([{x: 0, y: 1}, {x: 7, y: 0}, {x: 4, y: 4}, {x: 9, y: 0}]); - }); - - it('should sort descending with width.', function() { - w.nodes = [{x: 7, y: 0}, {x: 4, y: 4}, {x: 9, y: 0}, {x: 0, y: 1}]; - e.prototype._sortNodes.call(w, -1); - expect(w.nodes).toEqual([{x: 9, y: 0}, {x: 4, y: 4}, {x: 7, y: 0}, {x: 0, y: 1}]); - }); - - it('should sort ascending without width.', function() { - w.width = false; - w.nodes = [{x: 7, y: 0, width: 1}, {x: 4, y: 4, width: 1}, {x: 9, y: 0, width: 1}, {x: 0, y: 1, width: 1}]; - e.prototype._sortNodes.call(w, 1); - expect(w.nodes).toEqual([{x: 7, y: 0, width: 1}, {x: 9, y: 0, width: 1}, {x: 0, y: 1, width: 1}, {x: 4, y: 4, width: 1}]); - }); - - it('should sort descending without width.', function() { - w.width = false; - w.nodes = [{x: 7, y: 0, width: 1}, {x: 4, y: 4, width: 1}, {x: 9, y: 0, width: 1}, {x: 0, y: 1, width: 1}]; - e.prototype._sortNodes.call(w, -1); - expect(w.nodes).toEqual([{x: 4, y: 4, width: 1}, {x: 0, y: 1, width: 1}, {x: 9, y: 0, width: 1}, {x: 7, y: 0, width: 1}]); - }); - - }); - - describe('grid.setAnimation', function() { - beforeEach(function() { - document.body.insertAdjacentHTML( - 'afterbegin', gridstackHTML); - }); - afterEach(function() { - document.body.removeChild(document.getElementsByClassName('grid-stack')[0]); - }); - it('should add class grid-stack-animate to the container.', function() { - var options = { - cellHeight: 80, - verticalMargin: 10 - }; - $('.grid-stack').gridstack(options); - $('.grid-stack').removeClass('grid-stack-animate'); - var grid = $('.grid-stack').data('gridstack'); - grid.setAnimation(true); - expect($('.grid-stack').hasClass('grid-stack-animate')).toBe(true); - }); - it('should remove class grid-stack-animate from the container.', function() { - var options = { - cellHeight: 80, - verticalMargin: 10 - }; - $('.grid-stack').gridstack(options); - $('.grid-stack').addClass('grid-stack-animate'); - var grid = $('.grid-stack').data('gridstack'); - grid.setAnimation(false); - expect($('.grid-stack').hasClass('grid-stack-animate')).toBe(false); - }); - }); - - describe('grid._setStaticClass', function() { - beforeEach(function() { - document.body.insertAdjacentHTML( - 'afterbegin', gridstackHTML); - }); - afterEach(function() { - document.body.removeChild(document.getElementsByClassName('grid-stack')[0]); - }); - it('should add class grid-stack-static to the container.', function() { - var options = { - cellHeight: 80, - verticalMargin: 10, - staticGrid: true - }; - $('.grid-stack').gridstack(options); - $('.grid-stack').removeClass('grid-stack-static'); - var grid = $('.grid-stack').data('gridstack'); - grid._setStaticClass(); - expect($('.grid-stack').hasClass('grid-stack-static')).toBe(true); - }); - it('should remove class grid-stack-static from the container.', function() { - var options = { - cellHeight: 80, - verticalMargin: 10, - staticGrid: false - }; - $('.grid-stack').gridstack(options); - $('.grid-stack').addClass('grid-stack-static'); - var grid = $('.grid-stack').data('gridstack'); - grid._setStaticClass(); - expect($('.grid-stack').hasClass('grid-stack-static')).toBe(false); - }); - }); - - describe('grid.getCellFromPixel', function() { - beforeEach(function() { - document.body.insertAdjacentHTML( - 'afterbegin', gridstackHTML); - }); - afterEach(function() { - document.body.removeChild(document.getElementsByClassName('grid-stack')[0]); - }); - it('should return {x: 2, y: 1}.', function() { - var options = { - cellHeight: 80, - verticalMargin: 10 - }; - $('.grid-stack').gridstack(options); - var grid = $('.grid-stack').data('gridstack'); - var pixel = {top: 100, left: 72}; - var cell = grid.getCellFromPixel(pixel); - expect(cell.x).toBe(2); - expect(cell.y).toBe(1); - }); - it('should return {x: 2, y: 1}.', function() { - var options = { - cellHeight: 80, - verticalMargin: 10 - }; - $('.grid-stack').gridstack(options); - var grid = $('.grid-stack').data('gridstack'); - var pixel = {top: 100, left: 72}; - var cell = grid.getCellFromPixel(pixel, false); - expect(cell.x).toBe(2); - expect(cell.y).toBe(1); - }); - it('should return {x: 2, y: 1}.', function() { - var options = { - cellHeight: 80, - verticalMargin: 10 - }; - $('.grid-stack').gridstack(options); - var grid = $('.grid-stack').data('gridstack'); - var pixel = {top: 100, left: 72}; - var cell = grid.getCellFromPixel(pixel, true); - expect(cell.x).toBe(2); - expect(cell.y).toBe(1); - }); - }); - - describe('grid.cellWidth', function() { - beforeEach(function() { - document.body.insertAdjacentHTML( - 'afterbegin', gridstackHTML); - }); - afterEach(function() { - document.body.removeChild(document.getElementsByClassName('grid-stack')[0]); - }); - it('should return 1/12th of container width.', function() { - var options = { - cellHeight: 80, - verticalMargin: 10, - width: 12 - }; - $('.grid-stack').gridstack(options); - var grid = $('.grid-stack').data('gridstack'); - var res = Math.round($('.grid-stack').outerWidth() / 12); - expect(grid.cellWidth()).toBe(res); - }); - it('should return 1/10th of container width.', function() { - var options = { - cellHeight: 80, - verticalMargin: 10, - width: 10 - }; - $('.grid-stack').gridstack(options); - var grid = $('.grid-stack').data('gridstack'); - var res = Math.round($('.grid-stack').outerWidth() / 10); - expect(grid.cellWidth()).toBe(res); - }); - }); - - describe('grid.minWidth', function() { - beforeEach(function() { - document.body.insertAdjacentHTML( - 'afterbegin', gridstackHTML); - }); - afterEach(function() { - document.body.removeChild(document.getElementsByClassName('grid-stack')[0]); - }); - it('should set data-gs-min-width to 2.', function() { - var options = { - cellHeight: 80, - verticalMargin: 10 - }; - $('.grid-stack').gridstack(options); - var grid = $('.grid-stack').data('gridstack'); - var items = $('.grid-stack-item'); - for (var i = 0; i < items.length; i++) { - grid.minWidth(items[i], 2); - } - for (var j = 0; j < items.length; j++) { - expect(parseInt($(items[j]).attr('data-gs-min-width'), 10)).toBe(2); - } - }); - }); - - describe('grid.maxWidth', function() { - beforeEach(function() { - document.body.insertAdjacentHTML( - 'afterbegin', gridstackHTML); - }); - afterEach(function() { - document.body.removeChild(document.getElementsByClassName('grid-stack')[0]); - }); - it('should set data-gs-min-width to 2.', function() { - var options = { - cellHeight: 80, - verticalMargin: 10 - }; - $('.grid-stack').gridstack(options); - var grid = $('.grid-stack').data('gridstack'); - var items = $('.grid-stack-item'); - for (var i = 0; i < items.length; i++) { - grid.maxWidth(items[i], 2); - } - for (var j = 0; j < items.length; j++) { - expect(parseInt($(items[j]).attr('data-gs-max-width'), 10)).toBe(2); - } - }); - }); - - describe('grid.minHeight', function() { - beforeEach(function() { - document.body.insertAdjacentHTML( - 'afterbegin', gridstackHTML); - }); - afterEach(function() { - document.body.removeChild(document.getElementsByClassName('grid-stack')[0]); - }); - it('should set data-gs-min-height to 2.', function() { - var options = { - cellHeight: 80, - verticalMargin: 10 - }; - $('.grid-stack').gridstack(options); - var grid = $('.grid-stack').data('gridstack'); - var items = $('.grid-stack-item'); - for (var i = 0; i < items.length; i++) { - grid.minHeight(items[i], 2); - } - for (var j = 0; j < items.length; j++) { - expect(parseInt($(items[j]).attr('data-gs-min-height'), 10)).toBe(2); - } - }); - }); - - describe('grid.maxHeight', function() { - beforeEach(function() { - document.body.insertAdjacentHTML( - 'afterbegin', gridstackHTML); - }); - afterEach(function() { - document.body.removeChild(document.getElementsByClassName('grid-stack')[0]); - }); - it('should set data-gs-min-height to 2.', function() { - var options = { - cellHeight: 80, - verticalMargin: 10 - }; - $('.grid-stack').gridstack(options); - var grid = $('.grid-stack').data('gridstack'); - var items = $('.grid-stack-item'); - for (var i = 0; i < items.length; i++) { - grid.maxHeight(items[i], 2); - } - for (var j = 0; j < items.length; j++) { - expect(parseInt($(items[j]).attr('data-gs-max-height'), 10)).toBe(2); - } - }); - }); - - describe('grid.isAreaEmpty', function() { - beforeEach(function() { - document.body.insertAdjacentHTML( - 'afterbegin', gridstackHTML); - }); - afterEach(function() { - document.body.removeChild(document.getElementsByClassName('grid-stack')[0]); - }); - it('should set return false.', function() { - var options = { - cellHeight: 80, - verticalMargin: 10 - }; - $('.grid-stack').gridstack(options); - var grid = $('.grid-stack').data('gridstack'); - var shouldBeFalse = grid.isAreaEmpty(1, 1, 1, 1); - expect(shouldBeFalse).toBe(false); - }); - it('should set return true.', function() { - var options = { - cellHeight: 80, - verticalMargin: 10 - }; - $('.grid-stack').gridstack(options); - var grid = $('.grid-stack').data('gridstack'); - var shouldBeTrue = grid.isAreaEmpty(5, 5, 1, 1); - expect(shouldBeTrue).toBe(true); - }); - }); - - describe('grid method obsolete warnings', function() { - beforeEach(function() { - document.body.insertAdjacentHTML( - 'afterbegin', gridstackHTML); - }); - afterEach(function() { - document.body.removeChild(document.getElementsByClassName('grid-stack')[0]); - }); - it('should log a warning if set_static is called.', function() { - console.warn = jasmine.createSpy('log'); - var options = { - cellHeight: 80, - verticalMargin: 10 - }; - $('.grid-stack').gridstack(options); - var grid = $('.grid-stack').data('gridstack'); - grid.set_static(true); - expect(console.warn).toHaveBeenCalledWith('gridstack.js: Function `set_static` is deprecated as of v0.2.5 and has been replaced with `setStatic`. It will be **completely** removed in v1.0.'); - }); - it('should log a warning if _set_static_class is called.', function() { - console.warn = jasmine.createSpy('log'); - var options = { - cellHeight: 80, - verticalMargin: 10 - }; - $('.grid-stack').gridstack(options); - var grid = $('.grid-stack').data('gridstack'); - grid._set_static_class(); - expect(console.warn).toHaveBeenCalledWith('gridstack.js: Function `_set_static_class` is deprecated as of v0.2.5 and has been replaced with `_setStaticClass`. It will be **completely** removed in v1.0.'); - }); - it('should log a warning if is_area_empty is called.', function() { - console.warn = jasmine.createSpy('log'); - var options = { - cellHeight: 80, - verticalMargin: 10 - }; - $('.grid-stack').gridstack(options); - var grid = $('.grid-stack').data('gridstack'); - grid.is_area_empty(1, 1, 1, 1); - expect(console.warn).toHaveBeenCalledWith('gridstack.js: Function `is_area_empty` is deprecated as of v0.2.5 and has been replaced with `isAreaEmpty`. It will be **completely** removed in v1.0.'); - }); - it('should log a warning if batch_update is called.', function() { - console.warn = jasmine.createSpy('log'); - var options = { - cellHeight: 80, - verticalMargin: 10 - }; - $('.grid-stack').gridstack(options); - var grid = $('.grid-stack').data('gridstack'); - grid.batch_update(); - expect(console.warn).toHaveBeenCalledWith('gridstack.js: Function `batch_update` is deprecated as of v0.2.5 and has been replaced with `batchUpdate`. It will be **completely** removed in v1.0.'); - }); - it('should log a warning if get_cell_from_pixel is called.', function() { - console.warn = jasmine.createSpy('log'); - var options = { - cellHeight: 80, - verticalMargin: 10 - }; - $('.grid-stack').gridstack(options); - var grid = $('.grid-stack').data('gridstack'); - var pixel = {top: 100, left: 72}; - grid.get_cell_from_pixel(pixel); - expect(console.warn).toHaveBeenCalledWith('gridstack.js: Function `get_cell_from_pixel` is deprecated as of v0.2.5 and has been replaced with `getCellFromPixel`. It will be **completely** removed in v1.0.'); - }); - it('should log a warning if cell_width is called.', function() { - console.warn = jasmine.createSpy('log'); - var options = { - cellHeight: 80, - verticalMargin: 10 - }; - $('.grid-stack').gridstack(options); - var grid = $('.grid-stack').data('gridstack'); - grid.cell_width(); - expect(console.warn).toHaveBeenCalledWith('gridstack.js: Function `cell_width` is deprecated as of v0.2.5 and has been replaced with `cellWidth`. It will be **completely** removed in v1.0.'); - }); - it('should log a warning if cell_height is called.', function() { - console.warn = jasmine.createSpy('log'); - var options = { - cellHeight: 80, - verticalMargin: 10 - }; - $('.grid-stack').gridstack(options); - var grid = $('.grid-stack').data('gridstack'); - grid.cell_height(); - expect(console.warn).toHaveBeenCalledWith('gridstack.js: Function `cell_height` is deprecated as of v0.2.5 and has been replaced with `cellHeight`. It will be **completely** removed in v1.0.'); - }); - it('should log a warning if _update_element is called.', function() { - console.warn = jasmine.createSpy('log'); - var options = { - cellHeight: 80, - verticalMargin: 10 - }; - $('.grid-stack').gridstack(options); - var grid = $('.grid-stack').data('gridstack'); - grid._update_element(); - expect(console.warn).toHaveBeenCalledWith('gridstack.js: Function `_update_element` is deprecated as of v0.2.5 and has been replaced with `_updateElement`. It will be **completely** removed in v1.0.'); - }); - it('should log a warning if min_width is called.', function() { - console.warn = jasmine.createSpy('log'); - var options = { - cellHeight: 80, - verticalMargin: 10 - }; - $('.grid-stack').gridstack(options); - var grid = $('.grid-stack').data('gridstack'); - var items = $('.grid-stack-item'); - for (var i = 0; i < items.length; i++) { - grid.min_width(items[i], 2); - } - expect(console.warn).toHaveBeenCalledWith('gridstack.js: Function `min_width` is deprecated as of v0.2.5 and has been replaced with `minWidth`. It will be **completely** removed in v1.0.'); - }); - it('should log a warning if min_height is called.', function() { - console.warn = jasmine.createSpy('log'); - var options = { - cellHeight: 80, - verticalMargin: 10 - }; - $('.grid-stack').gridstack(options); - var grid = $('.grid-stack').data('gridstack'); - var items = $('.grid-stack-item'); - for (var i = 0; i < items.length; i++) { - grid.min_height(items[i], 2); - } - expect(console.warn).toHaveBeenCalledWith('gridstack.js: Function `min_height` is deprecated as of v0.2.5 and has been replaced with `minHeight`. It will be **completely** removed in v1.0.'); - }); - it('should log a warning if remove_all is called.', function() { - console.warn = jasmine.createSpy('log'); - var options = { - cellHeight: 80, - verticalMargin: 10 - }; - $('.grid-stack').gridstack(options); - var grid = $('.grid-stack').data('gridstack'); - grid.remove_all(); - expect(console.warn).toHaveBeenCalledWith('gridstack.js: Function `remove_all` is deprecated as of v0.2.5 and has been replaced with `removeAll`. It will be **completely** removed in v1.0.'); - }); - it('should log a warning if remove_widget is called.', function() { - console.warn = jasmine.createSpy('log'); - var options = { - cellHeight: 80, - verticalMargin: 10 - }; - $('.grid-stack').gridstack(options); - var grid = $('.grid-stack').data('gridstack'); - var items = $('.grid-stack-item'); - for (var i = 0; i < items.length; i++) { - grid.remove_widget(items[i]); - } - expect(console.warn).toHaveBeenCalledWith('gridstack.js: Function `remove_widget` is deprecated as of v0.2.5 and has been replaced with `removeWidget`. It will be **completely** removed in v1.0.'); - }); - it('should log a warning if will_it_fit is called.', function() { - console.warn = jasmine.createSpy('log'); - var options = { - cellHeight: 80, - verticalMargin: 10 - }; - $('.grid-stack').gridstack(options); - var grid = $('.grid-stack').data('gridstack'); - grid.will_it_fit(0, 0, 1, 1, false); - expect(console.warn).toHaveBeenCalledWith('gridstack.js: Function `will_it_fit` is deprecated as of v0.2.5 and has been replaced with `willItFit`. It will be **completely** removed in v1.0.'); - }); - it('should log a warning if make_widget is called.', function() { - console.warn = jasmine.createSpy('log'); - var options = { - cellHeight: 80, - verticalMargin: 10 - }; - $('.grid-stack').gridstack(options); - var grid = $('.grid-stack').data('gridstack'); - var items = $('.grid-stack-item'); - for (var i = 0; i < items.length; i++) { - grid.make_widget(items[i]); - } - expect(console.warn).toHaveBeenCalledWith('gridstack.js: Function `make_widget` is deprecated as of v0.2.5 and has been replaced with `makeWidget`. It will be **completely** removed in v1.0.'); - }); - it('should log a warning if add_widget is called.', function() { - console.warn = jasmine.createSpy('log'); - var options = { - cellHeight: 80, - verticalMargin: 10 - }; - $('.grid-stack').gridstack(options); - var grid = $('.grid-stack').data('gridstack'); - var items = $('.grid-stack-item'); - for (var i = 0; i < items.length; i++) { - grid.add_widget(items[i]); - } - expect(console.warn).toHaveBeenCalledWith('gridstack.js: Function `add_widget` is deprecated as of v0.2.5 and has been replaced with `addWidget`. It will be **completely** removed in v1.0.'); - }); - it('should log a warning if set_animation is called.', function() { - console.warn = jasmine.createSpy('log'); - var options = { - cellHeight: 80, - verticalMargin: 10 - }; - $('.grid-stack').gridstack(options); - var grid = $('.grid-stack').data('gridstack'); - grid.set_animation(true); - expect(console.warn).toHaveBeenCalledWith('gridstack.js: Function `set_animation` is deprecated as of v0.2.5 and has been replaced with `setAnimation`. It will be **completely** removed in v1.0.'); - }); - it('should log a warning if _prepare_element is called.', function() { - console.warn = jasmine.createSpy('log'); - var options = { - cellHeight: 80, - verticalMargin: 10 - }; - $('.grid-stack').gridstack(options); - var grid = $('.grid-stack').data('gridstack'); - var items = $('.grid-stack-item'); - for (var i = 0; i < items.length; i++) { - grid._prepare_element(items[i]); - } - expect(console.warn).toHaveBeenCalledWith('gridstack.js: Function `_prepare_element` is deprecated as of v0.2.5 and has been replaced with `_prepareElement`. It will be **completely** removed in v1.0.'); - }); - it('should log a warning if _is_one_column_mode is called.', function() { - console.warn = jasmine.createSpy('log'); - var options = { - cellHeight: 80, - verticalMargin: 10 - }; - $('.grid-stack').gridstack(options); - var grid = $('.grid-stack').data('gridstack'); - grid._is_one_column_mode(); - expect(console.warn).toHaveBeenCalledWith('gridstack.js: Function `_is_one_column_mode` is deprecated as of v0.2.5 and has been replaced with `_isOneColumnMode`. It will be **completely** removed in v1.0.'); - }); - it('should log a warning if _update_container_height is called.', function() { - console.warn = jasmine.createSpy('log'); - var options = { - cellHeight: 80, - verticalMargin: 10 - }; - $('.grid-stack').gridstack(options); - var grid = $('.grid-stack').data('gridstack'); - grid._update_container_height(); - expect(console.warn).toHaveBeenCalledWith('gridstack.js: Function `_update_container_height` is deprecated as of v0.2.5 and has been replaced with `_updateContainerHeight`. It will be **completely** removed in v1.0.'); - }); - it('should log a warning if _update_styles is called.', function() { - console.warn = jasmine.createSpy('log'); - var options = { - cellHeight: 80, - verticalMargin: 10 - }; - $('.grid-stack').gridstack(options); - var grid = $('.grid-stack').data('gridstack'); - grid._update_styles(); - expect(console.warn).toHaveBeenCalledWith('gridstack.js: Function `_update_styles` is deprecated as of v0.2.5 and has been replaced with `_updateStyles`. It will be **completely** removed in v1.0.'); - }); - it('should log a warning if _init_styles is called.', function() { - console.warn = jasmine.createSpy('log'); - var options = { - cellHeight: 80, - verticalMargin: 10 - }; - $('.grid-stack').gridstack(options); - var grid = $('.grid-stack').data('gridstack'); - grid._init_styles(); - expect(console.warn).toHaveBeenCalledWith('gridstack.js: Function `_init_styles` is deprecated as of v0.2.5 and has been replaced with `_initStyles`. It will be **completely** removed in v1.0.'); - }); - it('should log a warning if _trigger_change_event is called.', function() { - console.warn = jasmine.createSpy('log'); - var options = { - cellHeight: 80, - verticalMargin: 10 - }; - $('.grid-stack').gridstack(options); - var grid = $('.grid-stack').data('gridstack'); - grid._trigger_change_event(); - expect(console.warn).toHaveBeenCalledWith('gridstack.js: Function `_trigger_change_event` is deprecated as of v0.2.5 and has been replaced with `_triggerChangeEvent`. It will be **completely** removed in v1.0.'); - }); - }); - - describe('grid opts obsolete warnings', function() { - beforeEach(function() { - document.body.insertAdjacentHTML( - 'afterbegin', gridstackHTML); - }); - afterEach(function() { - document.body.removeChild(document.getElementsByClassName('grid-stack')[0]); - }); - it('should log a warning if handle_class is set.', function() { - console.warn = jasmine.createSpy('log'); - var options = { - cellHeight: 80, - verticalMargin: 10, - handle_class: 'grid-stack-header' - - }; - $('.grid-stack').gridstack(options); - var grid = $('.grid-stack').data('gridstack'); - expect(console.warn).toHaveBeenCalledWith('gridstack.js: Option `handle_class` is deprecated as of v0.2.5 and has been replaced with `handleClass`. It will be **completely** removed in v1.0.'); - }); - it('should log a warning if item_class is set.', function() { - console.warn = jasmine.createSpy('log'); - var options = { - cellHeight: 80, - verticalMargin: 10, - item_class: 'grid-stack-item' - - }; - $('.grid-stack').gridstack(options); - var grid = $('.grid-stack').data('gridstack'); - expect(console.warn).toHaveBeenCalledWith('gridstack.js: Option `item_class` is deprecated as of v0.2.5 and has been replaced with `itemClass`. It will be **completely** removed in v1.0.'); - }); - it('should log a warning if placeholder_class is set.', function() { - console.warn = jasmine.createSpy('log'); - var options = { - cellHeight: 80, - verticalMargin: 10, - placeholder_class: 'grid-stack-placeholder' - - }; - $('.grid-stack').gridstack(options); - var grid = $('.grid-stack').data('gridstack'); - expect(console.warn).toHaveBeenCalledWith('gridstack.js: Option `placeholder_class` is deprecated as of v0.2.5 and has been replaced with `placeholderClass`. It will be **completely** removed in v1.0.'); - }); - it('should log a warning if placeholder_text is set.', function() { - console.warn = jasmine.createSpy('log'); - var options = { - cellHeight: 80, - verticalMargin: 10, - placeholder_text: 'placeholder' - - }; - $('.grid-stack').gridstack(options); - var grid = $('.grid-stack').data('gridstack'); - expect(console.warn).toHaveBeenCalledWith('gridstack.js: Option `placeholder_text` is deprecated as of v0.2.5 and has been replaced with `placeholderText`. It will be **completely** removed in v1.0.'); - }); - it('should log a warning if cell_height is set.', function() { - console.warn = jasmine.createSpy('log'); - var options = { - cell_height: 80, - verticalMargin: 10 - - }; - $('.grid-stack').gridstack(options); - var grid = $('.grid-stack').data('gridstack'); - expect(console.warn).toHaveBeenCalledWith('gridstack.js: Option `cell_height` is deprecated as of v0.2.5 and has been replaced with `cellHeight`. It will be **completely** removed in v1.0.'); - }); - it('should log a warning if vertical_margin is set.', function() { - console.warn = jasmine.createSpy('log'); - var options = { - cellHeight: 80, - vertical_margin: 10 - - }; - $('.grid-stack').gridstack(options); - var grid = $('.grid-stack').data('gridstack'); - expect(console.warn).toHaveBeenCalledWith('gridstack.js: Option `vertical_margin` is deprecated as of v0.2.5 and has been replaced with `verticalMargin`. It will be **completely** removed in v1.0.'); - }); - it('should log a warning if min_width is set.', function() { - console.warn = jasmine.createSpy('log'); - var options = { - cellHeight: 80, - verticalMargin: 10, - min_width: 2 - - }; - $('.grid-stack').gridstack(options); - var grid = $('.grid-stack').data('gridstack'); - expect(console.warn).toHaveBeenCalledWith('gridstack.js: Option `min_width` is deprecated as of v0.2.5 and has been replaced with `minWidth`. It will be **completely** removed in v1.0.'); - }); - it('should log a warning if static_grid is set.', function() { - console.warn = jasmine.createSpy('log'); - var options = { - cellHeight: 80, - verticalMargin: 10, - static_grid: false - - }; - $('.grid-stack').gridstack(options); - var grid = $('.grid-stack').data('gridstack'); - expect(console.warn).toHaveBeenCalledWith('gridstack.js: Option `static_grid` is deprecated as of v0.2.5 and has been replaced with `staticGrid`. It will be **completely** removed in v1.0.'); - }); - it('should log a warning if is_nested is set.', function() { - console.warn = jasmine.createSpy('log'); - var options = { - cellHeight: 80, - verticalMargin: 10, - is_nested: false - - }; - $('.grid-stack').gridstack(options); - var grid = $('.grid-stack').data('gridstack'); - expect(console.warn).toHaveBeenCalledWith('gridstack.js: Option `is_nested` is deprecated as of v0.2.5 and has been replaced with `isNested`. It will be **completely** removed in v1.0.'); - }); - it('should log a warning if always_show_resize_handle is set.', function() { - console.warn = jasmine.createSpy('log'); - var options = { - cellHeight: 80, - verticalMargin: 10, - always_show_resize_handle: false - - }; - $('.grid-stack').gridstack(options); - var grid = $('.grid-stack').data('gridstack'); - expect(console.warn).toHaveBeenCalledWith('gridstack.js: Option `always_show_resize_handle` is deprecated as of v0.2.5 and has been replaced with `alwaysShowResizeHandle`. It will be **completely** removed in v1.0.'); - }); - }); - - describe('grid method _packNodes with float', function() { - beforeEach(function() { - document.body.insertAdjacentHTML( - 'afterbegin', gridstackHTML); - }); - afterEach(function() { - document.body.removeChild(document.getElementsByClassName('grid-stack')[0]); - }); - it('should allow same x, y coordinates for widgets.', function() { - var options = { - cellHeight: 80, - verticalMargin: 10, - float: true - }; - $('.grid-stack').gridstack(options); - var grid = $('.grid-stack').data('gridstack'); - var items = $('.grid-stack-item'); - var $el; - var $oldEl; - for (var i = 0; i < items.length; i++) { - $el = $(grid.addWidget(items[i])); - $oldEl = $(items[i]); - expect(parseInt($oldEl.attr('data-gs-x'), 10)).toBe(parseInt($el.attr('data-gs-x'), 10)); - expect(parseInt($oldEl.attr('data-gs-y'), 10)).toBe(parseInt($el.attr('data-gs-y'), 10)); - } - }); - it('should not allow same x, y coordinates for widgets.', function() { - var options = { - cellHeight: 80, - verticalMargin: 10 - }; - $('.grid-stack').gridstack(options); - var grid = $('.grid-stack').data('gridstack'); - var items = $('.grid-stack-item'); - var $el; - var $oldEl; - var newY; - var oldY; - for (var i = 0; i < items.length; i++) { - $oldEl = $.extend(true, {}, $(items[i])); - newY = parseInt($oldEl.attr('data-gs-y'), 10) + 5; - $oldEl.attr('data-gs-y', newY); - $el = $(grid.addWidget($oldEl)); - expect(parseInt($el.attr('data-gs-y'), 10)).not.toBe(newY); - } - }); - }); - - describe('grid method addWidget with all parameters', function() { - beforeEach(function() { - document.body.insertAdjacentHTML( - 'afterbegin', gridstackHTML); - }); - afterEach(function() { - document.body.removeChild(document.getElementsByClassName('grid-stack')[0]); - }); - it('should allow same x, y coordinates for widgets.', function() { - var options = { - cellHeight: 80, - verticalMargin: 10, - float: true - }; - $('.grid-stack').gridstack(options); - var grid = $('.grid-stack').data('gridstack'); - var widgetHTML = - '
' + - '
' + - '
'; - var widget = grid.addWidget(widgetHTML, 6, 7, 2, 3, false, 1, 4, 2, 5, 'coolWidget'); - var $widget = $(widget); - expect(parseInt($widget.attr('data-gs-x'), 10)).toBe(6); - expect(parseInt($widget.attr('data-gs-y'), 10)).toBe(7); - expect(parseInt($widget.attr('data-gs-width'), 10)).toBe(2); - expect(parseInt($widget.attr('data-gs-height'), 10)).toBe(3); - expect($widget.attr('data-gs-auto-position')).toBe(undefined); - expect(parseInt($widget.attr('data-gs-min-width'), 10)).toBe(1); - expect(parseInt($widget.attr('data-gs-max-width'), 10)).toBe(4); - expect(parseInt($widget.attr('data-gs-min-height'), 10)).toBe(2); - expect(parseInt($widget.attr('data-gs-max-height'), 10)).toBe(5); - expect($widget.attr('data-gs-id')).toBe('coolWidget'); - }); - }); - - describe('grid method addWidget with autoPosition true', function() { - beforeEach(function() { - document.body.insertAdjacentHTML( - 'afterbegin', gridstackHTML); - }); - afterEach(function() { - document.body.removeChild(document.getElementsByClassName('grid-stack')[0]); - }); - it('should change x, y coordinates for widgets.', function() { - var options = { - cellHeight: 80, - verticalMargin: 10 - }; - $('.grid-stack').gridstack(options); - var grid = $('.grid-stack').data('gridstack'); - var widgetHTML = - '
' + - '
' + - '
'; - var widget = grid.addWidget(widgetHTML, 9, 7, 2, 3, true); - var $widget = $(widget); - expect(parseInt($widget.attr('data-gs-x'), 10)).not.toBe(6); - expect(parseInt($widget.attr('data-gs-y'), 10)).not.toBe(7); - }); - }); - - describe('grid.destroy', function() { - beforeEach(function() { - document.body.insertAdjacentHTML( - 'afterbegin', gridstackHTML); - }); - afterEach(function() { - //document.body.removeChild(document.getElementsByClassName('grid-stack')[0]); - }); - it('should cleanup gridstack', function() { - var options = { - cellHeight: 80, - verticalMargin: 10 - }; - $('.grid-stack').gridstack(options); - var grid = $('.grid-stack').data('gridstack'); - grid.destroy(); - expect($('.grid-stack').length).toBe(0); - expect(grid.grid).toBe(null); - }); - it('should cleanup gridstack but leave elements', function() { - var options = { - cellHeight: 80, - verticalMargin: 10 - }; - $('.grid-stack').gridstack(options); - var grid = $('.grid-stack').data('gridstack'); - grid.destroy(false); - expect($('.grid-stack').length).toBe(1); - expect($('.grid-stack-item').length).toBe(2); - expect(grid.grid).toBe(null); - grid.destroy(); - }); - }); - - describe('grid.resize', function() { - beforeEach(function() { - document.body.insertAdjacentHTML( - 'afterbegin', gridstackHTML); - }); - afterEach(function() { - document.body.removeChild(document.getElementsByClassName('grid-stack')[0]); - }); - it('should resize widget', function() { - var options = { - cellHeight: 80, - verticalMargin: 10 - }; - $('.grid-stack').gridstack(options); - var grid = $('.grid-stack').data('gridstack'); - var items = $('.grid-stack-item'); - grid.resize(items[0], 5, 5); - expect(parseInt($(items[0]).attr('data-gs-width'), 10)).toBe(5); - expect(parseInt($(items[0]).attr('data-gs-height'), 10)).toBe(5); - }); - }); - - describe('grid.move', function() { - beforeEach(function() { - document.body.insertAdjacentHTML( - 'afterbegin', gridstackHTML); - }); - afterEach(function() { - document.body.removeChild(document.getElementsByClassName('grid-stack')[0]); - }); - it('should move widget', function() { - var options = { - cellHeight: 80, - verticalMargin: 10, - float: true - }; - $('.grid-stack').gridstack(options); - var grid = $('.grid-stack').data('gridstack'); - var items = $('.grid-stack-item'); - grid.move(items[0], 5, 5); - expect(parseInt($(items[0]).attr('data-gs-x'), 10)).toBe(5); - expect(parseInt($(items[0]).attr('data-gs-y'), 10)).toBe(5); - }); - }); - - describe('grid.moveNode', function() { - beforeEach(function() { - document.body.insertAdjacentHTML( - 'afterbegin', gridstackHTML); - }); - afterEach(function() { - document.body.removeChild(document.getElementsByClassName('grid-stack')[0]); - }); - it('should do nothing and return node', function() { - var options = { - cellHeight: 80, - verticalMargin: 10 - }; - $('.grid-stack').gridstack(options); - var grid = $('.grid-stack').data('gridstack'); - var items = $('.grid-stack-item'); - grid._updateElement(items[0], function(el, node) { - var newNode = grid.grid.moveNode(node); - expect(newNode).toBe(node); - }); - }); - it('should do nothing and return node', function() { - var options = { - cellHeight: 80, - verticalMargin: 10 - }; - $('.grid-stack').gridstack(options); - var grid = $('.grid-stack').data('gridstack'); - var items = $('.grid-stack-item'); - grid.minWidth(items[0], 1); - grid.maxWidth(items[0], 2); - grid.minHeight(items[0], 1); - grid.maxHeight(items[0], 2); - grid._updateElement(items[0], function(el, node) { - var newNode = grid.grid.moveNode(node); - expect(newNode).toBe(node); - }); - }); - }); - - describe('grid.update', function() { - beforeEach(function() { - document.body.insertAdjacentHTML( - 'afterbegin', gridstackHTML); - }); - afterEach(function() { - document.body.removeChild(document.getElementsByClassName('grid-stack')[0]); - }); - it('should move and resize widget', function() { - var options = { - cellHeight: 80, - verticalMargin: 10, - float: true - }; - $('.grid-stack').gridstack(options); - var grid = $('.grid-stack').data('gridstack'); - var items = $('.grid-stack-item'); - grid.update(items[0], 5, 5, 5 ,5); - expect(parseInt($(items[0]).attr('data-gs-width'), 10)).toBe(5); - expect(parseInt($(items[0]).attr('data-gs-height'), 10)).toBe(5); - expect(parseInt($(items[0]).attr('data-gs-x'), 10)).toBe(5); - expect(parseInt($(items[0]).attr('data-gs-y'), 10)).toBe(5); - }); - }); - - describe('grid.verticalMargin', function() { - beforeEach(function() { - document.body.insertAdjacentHTML( - 'afterbegin', gridstackHTML); - }); - afterEach(function() { - document.body.removeChild(document.getElementsByClassName('grid-stack')[0]); - }); - it('should return verticalMargin', function() { - var options = { - cellHeight: 80, - verticalMargin: 10 - }; - $('.grid-stack').gridstack(options); - var grid = $('.grid-stack').data('gridstack'); - var vm = grid.verticalMargin(); - expect(vm).toBe(10); - }); - it('should return update verticalMargin', function() { - var options = { - cellHeight: 80, - verticalMargin: 10 - }; - $('.grid-stack').gridstack(options); - var grid = $('.grid-stack').data('gridstack'); - grid.verticalMargin(11); - expect(grid.verticalMargin()).toBe(11); - }); - it('should do nothing', function() { - var options = { - cellHeight: 80, - verticalMargin: 10 - }; - $('.grid-stack').gridstack(options); - var grid = $('.grid-stack').data('gridstack'); - var vm = grid.verticalMargin(10); - expect(grid.verticalMargin()).toBe(10); - }); - it('should do nothing', function() { - var options = { - cellHeight: 80, - verticalMargin: 10, - height: 10 - }; - $('.grid-stack').gridstack(options); - var grid = $('.grid-stack').data('gridstack'); - var vm = grid.verticalMargin(10); - expect(grid.verticalMargin()).toBe(10); - }); - it('should not update styles', function() { - var options = { - cellHeight: 80, - verticalMargin: 10 - }; - $('.grid-stack').gridstack(options); - var grid = $('.grid-stack').data('gridstack'); - - spyOn(grid, '_updateStyles'); - grid.verticalMargin(11, true); - expect(grid._updateStyles).not.toHaveBeenCalled(); - }); - }); - - describe('grid.opts.rtl', function() { - beforeEach(function() { - document.body.insertAdjacentHTML( - 'afterbegin', gridstackHTML); - }); - afterEach(function() { - document.body.removeChild(document.getElementsByClassName('grid-stack')[0]); - }); - it('should add grid-stack-rtl class', function() { - var options = { - cellHeight: 80, - verticalMargin: 10, - rtl: true - }; - $('.grid-stack').gridstack(options); - expect($('.grid-stack').hasClass('grid-stack-rtl')).toBe(true); - }); - it('should not add grid-stack-rtl class', function() { - var options = { - cellHeight: 80, - verticalMargin: 10 - }; - $('.grid-stack').gridstack(options); - expect($('.grid-stack').hasClass('grid-stack-rtl')).toBe(false); - }); - }); - - describe('grid.enableMove', function() { - beforeEach(function() { - document.body.insertAdjacentHTML( - 'afterbegin', gridstackHTML); - }); - afterEach(function() { - document.body.removeChild(document.getElementsByClassName('grid-stack')[0]); - }); - it('should enable move', function() { - var options = { - cellHeight: 80, - verticalMargin: 10, - minWidth: 1, - disableDrag: true - }; - $('.grid-stack').gridstack(options); - var grid = $('.grid-stack').data('gridstack'); - var items = $('.grid-stack-item'); - expect(grid.opts.disableDrag).toBe(true); - grid.enableMove(true, true); - for (var i = 0; i < items.length; i++) { - expect($(items[i]).hasClass('ui-draggable-handle')).toBe(true); - } - expect(grid.opts.disableDrag).toBe(false); - }); - it('should disable move', function() { - var options = { - cellHeight: 80, - verticalMargin: 10, - minWidth: 1 - }; - $('.grid-stack').gridstack(options); - var grid = $('.grid-stack').data('gridstack'); - var items = $('.grid-stack-item'); - grid.enableMove(false); - for (var i = 0; i < items.length; i++) { - expect($(items[i]).hasClass('ui-draggable-handle')).toBe(false); - } - expect(grid.opts.disableDrag).toBe(false); - }); - }); - - describe('grid.enableResize', function() { - beforeEach(function() { - document.body.insertAdjacentHTML( - 'afterbegin', gridstackHTML); - }); - afterEach(function() { - document.body.removeChild(document.getElementsByClassName('grid-stack')[0]); - }); - it('should enable resize', function() { - var options = { - cellHeight: 80, - verticalMargin: 10, - minWidth: 1, - disableResize: true - }; - $('.grid-stack').gridstack(options); - var grid = $('.grid-stack').data('gridstack'); - var items = $('.grid-stack-item'); - expect(grid.opts.disableResize).toBe(true); - grid.enableResize(true, true); - for (var i = 0; i < items.length; i++) { - expect(($(items[i]).resizable('option','disabled'))).toBe(false); - } - expect(grid.opts.disableResize).toBe(false); - }); - it('should disable resize', function() { - var options = { - cellHeight: 80, - verticalMargin: 10, - minWidth: 1 - }; - $('.grid-stack').gridstack(options); - var grid = $('.grid-stack').data('gridstack'); - var items = $('.grid-stack-item'); - grid.enableResize(false); - for (var i = 0; i < items.length; i++) { - expect(($(items[i]).resizable('option','disabled'))).toBe(true); - } - expect(grid.opts.disableResize).toBe(false); - }); - }); - - describe('grid.enable', function() { - beforeEach(function() { - document.body.insertAdjacentHTML( - 'afterbegin', gridstackHTML); - }); - afterEach(function() { - document.body.removeChild(document.getElementsByClassName('grid-stack')[0]); - }); - it('should enable movable and resizable', function() { - var options = { - cellHeight: 80, - verticalMargin: 10, - minWidth: 1 - }; - $('.grid-stack').gridstack(options); - var grid = $('.grid-stack').data('gridstack'); - var items = $('.grid-stack-item'); - grid.enableResize(false); - grid.enableMove(false); - for (var i = 0; i < items.length; i++) { - expect($(items[i]).hasClass('ui-draggable-handle')).toBe(false); - expect(($(items[i]).resizable('option','disabled'))).toBe(true); - } - grid.enable(); - for (var j = 0; j < items.length; j++) { - expect($(items[j]).hasClass('ui-draggable-handle')).toBe(true); - expect(($(items[j]).resizable('option','disabled'))).toBe(false); - } - }); - }); - - describe('grid.enable', function() { - beforeEach(function() { - document.body.insertAdjacentHTML( - 'afterbegin', gridstackHTML); - }); - afterEach(function() { - document.body.removeChild(document.getElementsByClassName('grid-stack')[0]); - }); - it('should lock widgets', function() { - var options = { - cellHeight: 80, - verticalMargin: 10 - }; - $('.grid-stack').gridstack(options); - var grid = $('.grid-stack').data('gridstack'); - var items = $('.grid-stack-item'); - for (var i = 0; i < items.length; i++) { - grid.locked(items[i], true); - expect($(items[i]).attr('data-gs-locked')).toBe('yes'); - } - }); - it('should unlock widgets', function() { - var options = { - cellHeight: 80, - verticalMargin: 10 - }; - $('.grid-stack').gridstack(options); - var grid = $('.grid-stack').data('gridstack'); - var items = $('.grid-stack-item'); - for (var i = 0; i < items.length; i++) { - grid.locked(items[i], false); - expect($(items[i]).attr('data-gs-locked')).toBe(undefined); - } - }); - }); -}); diff --git a/spec/utils-spec.js b/spec/utils-spec.js deleted file mode 100644 index 0a92c9253..000000000 --- a/spec/utils-spec.js +++ /dev/null @@ -1,109 +0,0 @@ -describe('gridstack utils', function() { - 'use strict'; - - var utils; - - beforeEach(function() { - utils = window.GridStackUI.Utils; - }); - - describe('setup of utils', function() { - - it('should set gridstack utils.', function() { - expect(utils).not.toBeNull(); - expect(typeof utils).toBe('object'); - }); - - }); - - describe('test toBool', function() { - - it('should return booleans.', function() { - expect(utils.toBool(true)).toEqual(true); - expect(utils.toBool(false)).toEqual(false); - }); - - it('should work with integer.', function() { - expect(utils.toBool(1)).toEqual(true); - expect(utils.toBool(0)).toEqual(false); - }); - - it('should work with Strings.', function() { - expect(utils.toBool('')).toEqual(false); - expect(utils.toBool('0')).toEqual(false); - expect(utils.toBool('no')).toEqual(false); - expect(utils.toBool('false')).toEqual(false); - expect(utils.toBool('yes')).toEqual(true); - expect(utils.toBool('yadda')).toEqual(true); - }); - - }); - - describe('test isIntercepted', function() { - var src = {x: 3, y: 2, width: 3, height: 2}; - - it('should intercept.', function() { - expect(utils.isIntercepted(src, {x: 0, y: 0, width: 4, height: 3})).toEqual(true); - expect(utils.isIntercepted(src, {x: 0, y: 0, width: 40, height: 30})).toEqual(true); - expect(utils.isIntercepted(src, {x: 3, y: 2, width: 3, height: 2})).toEqual(true); - expect(utils.isIntercepted(src, {x: 5, y: 3, width: 3, height: 2})).toEqual(true); - }); - - it('shouldn\'t intercept.', function() { - expect(utils.isIntercepted(src, {x: 0, y: 0, width: 3, height: 2})).toEqual(false); - expect(utils.isIntercepted(src, {x: 0, y: 0, width: 13, height: 2})).toEqual(false); - expect(utils.isIntercepted(src, {x: 1, y: 4, width: 13, height: 2})).toEqual(false); - expect(utils.isIntercepted(src, {x: 0, y: 3, width: 3, height: 2})).toEqual(false); - expect(utils.isIntercepted(src, {x: 6, y: 3, width: 3, height: 2})).toEqual(false); - }); - }); - - describe('test createStylesheet/removeStylesheet', function() { - - it('should create/remove style DOM', function() { - var _id = 'test-123'; - - utils.createStylesheet(_id); - - var style = $('STYLE[data-gs-style-id=' + _id + ']'); - - expect(style.length).toEqual(1); - expect(style.prop('tagName')).toEqual('STYLE'); - - utils.removeStylesheet(_id) - - style = $('STYLE[data-gs-style-id=' + _id + ']'); - - expect(style.length).toEqual(0); - }); - - }); - - describe('test parseHeight', function() { - - it('should parse height value', function() { - expect(utils.parseHeight(12)).toEqual(jasmine.objectContaining({height: 12, unit: 'px'})); - expect(utils.parseHeight('12px')).toEqual(jasmine.objectContaining({height: 12, unit: 'px'})); - expect(utils.parseHeight('12.3px')).toEqual(jasmine.objectContaining({height: 12.3, unit: 'px'})); - expect(utils.parseHeight('12.3em')).toEqual(jasmine.objectContaining({height: 12.3, unit: 'em'})); - expect(utils.parseHeight('12.3rem')).toEqual(jasmine.objectContaining({height: 12.3, unit: 'rem'})); - expect(utils.parseHeight('12.3vh')).toEqual(jasmine.objectContaining({height: 12.3, unit: 'vh'})); - expect(utils.parseHeight('12.3vw')).toEqual(jasmine.objectContaining({height: 12.3, unit: 'vw'})); - expect(utils.parseHeight('12.5')).toEqual(jasmine.objectContaining({height: 12.5, unit: 'px'})); - expect(function() { utils.parseHeight('12.5 df'); }).toThrowError('Invalid height'); - - }); - - it('should parse negative height value', function() { - expect(utils.parseHeight(-12)).toEqual(jasmine.objectContaining({height: -12, unit: 'px'})); - expect(utils.parseHeight('-12px')).toEqual(jasmine.objectContaining({height: -12, unit: 'px'})); - expect(utils.parseHeight('-12.3px')).toEqual(jasmine.objectContaining({height: -12.3, unit: 'px'})); - expect(utils.parseHeight('-12.3em')).toEqual(jasmine.objectContaining({height: -12.3, unit: 'em'})); - expect(utils.parseHeight('-12.3rem')).toEqual(jasmine.objectContaining({height: -12.3, unit: 'rem'})); - expect(utils.parseHeight('-12.3vh')).toEqual(jasmine.objectContaining({height: -12.3, unit: 'vh'})); - expect(utils.parseHeight('-12.3vw')).toEqual(jasmine.objectContaining({height: -12.3, unit: 'vw'})); - expect(utils.parseHeight('-12.5')).toEqual(jasmine.objectContaining({height: -12.5, unit: 'px'})); - expect(function() { utils.parseHeight('-12.5 df'); }).toThrowError('Invalid height'); - }); - }); -}); diff --git a/src/gridstack.jQueryUI.js b/src/gridstack.jQueryUI.js deleted file mode 100644 index c5d493615..000000000 --- a/src/gridstack.jQueryUI.js +++ /dev/null @@ -1,97 +0,0 @@ -/** - * gridstack.js 0.3.0-dev - * http://troolee.github.io/gridstack.js/ - * (c) 2014-2016 Pavel Reznikov, Dylan Weiss - * gridstack.js may be freely distributed under the MIT license. - * @preserve -*/ -(function(factory) { - if (typeof define === 'function' && define.amd) { - define(['jquery', 'lodash', 'gridstack', 'jquery-ui/data', 'jquery-ui/disable-selection', 'jquery-ui/focusable', - 'jquery-ui/form', 'jquery-ui/ie', 'jquery-ui/keycode', 'jquery-ui/labels', 'jquery-ui/jquery-1-7', - 'jquery-ui/plugin', 'jquery-ui/safe-active-element', 'jquery-ui/safe-blur', 'jquery-ui/scroll-parent', - 'jquery-ui/tabbable', 'jquery-ui/unique-id', 'jquery-ui/version', 'jquery-ui/widget', - 'jquery-ui/widgets/mouse', 'jquery-ui/widgets/draggable', 'jquery-ui/widgets/droppable', - 'jquery-ui/widgets/resizable'], factory); - } else if (typeof exports !== 'undefined') { - try { jQuery = require('jquery'); } catch (e) {} - try { _ = require('lodash'); } catch (e) {} - try { GridStackUI = require('gridstack'); } catch (e) {} - factory(jQuery, _, GridStackUI); - } else { - factory(jQuery, _, GridStackUI); - } -})(function($, _, GridStackUI) { - - var scope = window; - - /** - * @class JQueryUIGridStackDragDropPlugin - * jQuery UI implementation of drag'n'drop gridstack plugin. - */ - function JQueryUIGridStackDragDropPlugin(grid) { - GridStackUI.GridStackDragDropPlugin.call(this, grid); - } - - GridStackUI.GridStackDragDropPlugin.registerPlugin(JQueryUIGridStackDragDropPlugin); - - JQueryUIGridStackDragDropPlugin.prototype = Object.create(GridStackUI.GridStackDragDropPlugin.prototype); - JQueryUIGridStackDragDropPlugin.prototype.constructor = JQueryUIGridStackDragDropPlugin; - - JQueryUIGridStackDragDropPlugin.prototype.resizable = function(el, opts) { - el = $(el); - if (opts === 'disable' || opts === 'enable') { - el.resizable(opts); - } else if (opts === 'option') { - var key = arguments[2]; - var value = arguments[3]; - el.resizable(opts, key, value); - } else { - el.resizable(_.extend({}, this.grid.opts.resizable, { - start: opts.start || function() {}, - stop: opts.stop || function() {}, - resize: opts.resize || function() {} - })); - } - return this; - }; - - JQueryUIGridStackDragDropPlugin.prototype.draggable = function(el, opts) { - el = $(el); - if (opts === 'disable' || opts === 'enable') { - el.draggable(opts); - } else { - el.draggable(_.extend({}, this.grid.opts.draggable, { - containment: this.grid.opts.isNested ? this.grid.container.parent() : null, - start: opts.start || function() {}, - stop: opts.stop || function() {}, - drag: opts.drag || function() {} - })); - } - return this; - }; - - JQueryUIGridStackDragDropPlugin.prototype.droppable = function(el, opts) { - el = $(el); - if (opts === 'disable' || opts === 'enable') { - el.droppable(opts); - } else { - el.droppable({ - accept: opts.accept - }); - } - return this; - }; - - JQueryUIGridStackDragDropPlugin.prototype.isDroppable = function(el, opts) { - el = $(el); - return Boolean(el.data('droppable')); - }; - - JQueryUIGridStackDragDropPlugin.prototype.on = function(el, eventName, callback) { - $(el).on(eventName, callback); - return this; - }; - - return JQueryUIGridStackDragDropPlugin; -}); diff --git a/src/gridstack.js b/src/gridstack.js index b48eb853a..61c893f8a 100644 --- a/src/gridstack.js +++ b/src/gridstack.js @@ -1,42 +1,27 @@ -/** - * gridstack.js 0.3.0-dev - * http://troolee.github.io/gridstack.js/ - * (c) 2014-2016 Pavel Reznikov, Dylan Weiss - * gridstack.js may be freely distributed under the MIT license. - * @preserve -*/ +// gridstack.js 0.2.4-dev +// http://troolee.github.io/gridstack.js/ +// (c) 2014-2016 Pavel Reznikov +// gridstack.js may be freely distributed under the MIT license. + (function(factory) { if (typeof define === 'function' && define.amd) { - define(['jquery', 'lodash'], factory); - } else if (typeof exports !== 'undefined') { - try { jQuery = require('jquery'); } catch (e) {} - try { _ = require('lodash'); } catch (e) {} - factory(jQuery, _); - } else { + define(['jquery', 'lodash', 'jquery-ui/core', 'jquery-ui/widget', 'jquery-ui/mouse', 'jquery-ui/draggable', + 'jquery-ui/resizable'], factory); + } + else if (typeof exports !== 'undefined') { + try { jQuery = require('jquery'); } catch(e) {} + try { _ = require('lodash'); } catch(e) {} + factory(jQuery, _); + } + else { factory(jQuery, _); } })(function($, _) { var scope = window; - var obsolete = function(f, oldName, newName) { - var wrapper = function() { - console.warn('gridstack.js: Function `' + oldName + '` is deprecated as of v0.2.5 and has been replaced ' + - 'with `' + newName + '`. It will be **completely** removed in v1.0.'); - return f.apply(this, arguments); - }; - wrapper.prototype = f.prototype; - - return wrapper; - }; - - var obsoleteOpts = function(oldName, newName) { - console.warn('gridstack.js: Option `' + oldName + '` is deprecated as of v0.2.5 and has been replaced with `' + - newName + '`. It will be **completely** removed in v1.0.'); - }; - var Utils = { - isIntercepted: function(a, b) { + is_intercepted: function(a, b) { return !(a.x + a.width <= b.x || b.x + b.width <= a.x || a.y + a.height <= b.y || b.y + b.height <= a.y); }, @@ -46,249 +31,175 @@ return _.sortBy(nodes, function(n) { return dir * (n.x + n.y * width); }); }, - createStylesheet: function(id) { + create_stylesheet: function(id) { var style = document.createElement('style'); style.setAttribute('type', 'text/css'); - style.setAttribute('data-gs-style-id', id); + style.setAttribute('data-gs-id', id); if (style.styleSheet) { style.styleSheet.cssText = ''; - } else { + } + else { style.appendChild(document.createTextNode('')); } document.getElementsByTagName('head')[0].appendChild(style); return style.sheet; }, - - removeStylesheet: function(id) { - $('STYLE[data-gs-style-id=' + id + ']').remove(); + remove_stylesheet: function(id) { + $("STYLE[data-gs-id=" + id +"]").remove(); }, - - insertCSSRule: function(sheet, selector, rules, index) { + insert_css_rule: function(sheet, selector, rules, index) { if (typeof sheet.insertRule === 'function') { sheet.insertRule(selector + '{' + rules + '}', index); - } else if (typeof sheet.addRule === 'function') { + } + else if (typeof sheet.addRule === 'function') { sheet.addRule(selector, rules, index); } }, toBool: function(v) { - if (typeof v == 'boolean') { + if (typeof v == 'boolean') return v; - } if (typeof v == 'string') { v = v.toLowerCase(); - return !(v === '' || v == 'no' || v == 'false' || v == '0'); + return !(v == '' || v == 'no' || v == 'false' || v == '0'); } return Boolean(v); - }, - - _collisionNodeCheck: function(n) { - return n != this.node && Utils.isIntercepted(n, this.nn); - }, - - _didCollide: function(bn) { - return Utils.isIntercepted({x: this.n.x, y: this.newY, width: this.n.width, height: this.n.height}, bn); - }, - - _isAddNodeIntercepted: function(n) { - return Utils.isIntercepted({x: this.x, y: this.y, width: this.node.width, height: this.node.height}, n); - }, - - parseHeight: function(val) { - var height = val; - var heightUnit = 'px'; - if (height && _.isString(height)) { - var match = height.match(/^(-[0-9]+\.[0-9]+|[0-9]*\.[0-9]+|-[0-9]+|[0-9]+)(px|em|rem|vh|vw)?$/); - if (!match) { - throw new Error('Invalid height'); - } - heightUnit = match[2] || 'px'; - height = parseFloat(match[1]); - } - return {height: height, unit: heightUnit}; } }; - // jscs:disable requireCamelCaseOrUpperCaseIdentifiers - Utils.is_intercepted = obsolete(Utils.isIntercepted, 'is_intercepted', 'isIntercepted'); - - Utils.create_stylesheet = obsolete(Utils.createStylesheet, 'create_stylesheet', 'createStylesheet'); - - Utils.remove_stylesheet = obsolete(Utils.removeStylesheet, 'remove_stylesheet', 'removeStylesheet'); - - Utils.insert_css_rule = obsolete(Utils.insertCSSRule, 'insert_css_rule', 'insertCSSRule'); - // jscs:enable requireCamelCaseOrUpperCaseIdentifiers - - /** - * @class GridStackDragDropPlugin - * Base class for drag'n'drop plugin. - */ - function GridStackDragDropPlugin(grid) { - this.grid = grid; - } - - GridStackDragDropPlugin.registeredPlugins = []; - - GridStackDragDropPlugin.registerPlugin = function(pluginClass) { - GridStackDragDropPlugin.registeredPlugins.push(pluginClass); - }; - - GridStackDragDropPlugin.prototype.resizable = function(el, opts) { - return this; - }; - - GridStackDragDropPlugin.prototype.draggable = function(el, opts) { - return this; - }; - - GridStackDragDropPlugin.prototype.droppable = function(el, opts) { - return this; - }; - - GridStackDragDropPlugin.prototype.isDroppable = function(el) { - return false; - }; - - GridStackDragDropPlugin.prototype.on = function(el, eventName, callback) { - return this; - }; - - - var idSeq = 0; + var id_seq = 0; - var GridStackEngine = function(width, onchange, floatMode, height, items) { + var GridStackEngine = function(width, onchange, float_mode, height, items) { this.width = width; - this.float = floatMode || false; + this['float'] = float_mode || false; this.height = height || 0; this.nodes = items || []; this.onchange = onchange || function() {}; - this._updateCounter = 0; - this._float = this.float; - - this._addedNodes = []; - this._removedNodes = []; + this._update_counter = 0; + this._float = this['float']; }; - GridStackEngine.prototype.batchUpdate = function() { - this._updateCounter = 1; + GridStackEngine.prototype.batch_update = function() { + this._update_counter = 1; this.float = true; }; GridStackEngine.prototype.commit = function() { - if (this._updateCounter !== 0) { - this._updateCounter = 0; + this._update_counter = 0; + if (this._update_counter == 0) { this.float = this._float; - this._packNodes(); + this._pack_nodes(); this._notify(); } }; - // For Meteor support: https://github.com/troolee/gridstack.js/pull/272 - GridStackEngine.prototype.getNodeDataByDOMEl = function(el) { - return _.find(this.nodes, function(n) { return el.get(0) === n.el.get(0); }); - }; - - GridStackEngine.prototype._fixCollisions = function(node) { - var self = this; - this._sortNodes(-1); + GridStackEngine.prototype._fix_collisions = function(node) { + this._sort_nodes(-1); - var nn = node; - var hasLocked = Boolean(_.find(this.nodes, function(n) { return n.locked; })); - if (!this.float && !hasLocked) { + var nn = node, has_locked = Boolean(_.find(this.nodes, function(n) { return n.locked })); + if (!this.float && !has_locked) { nn = {x: 0, y: node.y, width: this.width, height: node.height}; } + while (true) { - var collisionNode = _.find(this.nodes, _.bind(Utils._collisionNodeCheck, {node: node, nn: nn})); - if (typeof collisionNode == 'undefined') { + var collision_node = _.find(this.nodes, _.bind(function(n) { + return n != node && Utils.is_intercepted(n, nn); + }, this)); + if (typeof collision_node == 'undefined') { return; } - this.moveNode(collisionNode, collisionNode.x, node.y + node.height, - collisionNode.width, collisionNode.height, true); + this.move_node(collision_node, collision_node.x, node.y + node.height, + collision_node.width, collision_node.height, true); } }; - GridStackEngine.prototype.whatIsHere = function(x, y, width, height) { - var nn = {x: x || 0, y: y || 0, width: width || 1, height: height || 1}; - var collisionNode = _.find(this.nodes, _.bind(function(n) { - return Utils.isIntercepted(n, nn); + GridStackEngine.prototype.what_is_here = function(x, y, width, height) { + var nn = {x: x || 0, y: y || 0, width: width || 1, height: height || 1}; + var collision_node = _.find(this.nodes, _.bind(function(n) { + return Utils.is_intercepted(n, nn); }, this)); - return collisionNode; + return collision_node; }; - GridStackEngine.prototype.isAreaEmpty = function(x, y, width, height) { - var collisionNode = this.whatIsHere(x, y, width, height); - return collisionNode === null || typeof collisionNode === 'undefined'; + GridStackEngine.prototype.is_area_empty = function(x, y, width, height) { + var collision_node = this.what_is_here(x, y, width, height); + return collision_node == null; }; - GridStackEngine.prototype._sortNodes = function(dir) { + GridStackEngine.prototype._sort_nodes = function(dir) { this.nodes = Utils.sort(this.nodes, dir, this.width); }; - GridStackEngine.prototype._packNodes = function() { - this._sortNodes(); + GridStackEngine.prototype._pack_nodes = function() { + this._sort_nodes(); if (this.float) { _.each(this.nodes, _.bind(function(n, i) { - if (n._updating || typeof n._origY == 'undefined' || n.y == n._origY) { + if (n._updating || typeof n._orig_y == 'undefined' || n.y == n._orig_y) return; - } - var newY = n.y; - while (newY >= n._origY) { - var collisionNode = _.chain(this.nodes) - .find(_.bind(Utils._didCollide, {n: n, newY: newY})) + var new_y = n.y; + while (new_y >= n._orig_y) { + var collision_node = _.chain(this.nodes) + .find(function(bn) { + return n != bn && + Utils.is_intercepted({x: n.x, y: new_y, width: n.width, height: n.height}, bn); + }) .value(); - if (!collisionNode) { + if (!collision_node) { n._dirty = true; - n.y = newY; + n.y = new_y; } - --newY; + --new_y; } }, this)); - } else { + } + else { _.each(this.nodes, _.bind(function(n, i) { - if (n.locked) { + if (n.locked) return; - } while (n.y > 0) { - var newY = n.y - 1; - var canBeMoved = i === 0; + var new_y = n.y - 1; + var can_be_moved = i == 0; if (i > 0) { - var collisionNode = _.chain(this.nodes) + var collision_node = _.chain(this.nodes) .take(i) - .find(_.bind(Utils._didCollide, {n: n, newY: newY})) + .find(function(bn) { + return Utils.is_intercepted({x: n.x, y: new_y, width: n.width, height: n.height}, bn); + }) .value(); - canBeMoved = typeof collisionNode == 'undefined'; + can_be_moved = typeof collision_node == 'undefined'; } - if (!canBeMoved) { + if (!can_be_moved) { break; } - n._dirty = n.y != newY; - n.y = newY; + n._dirty = n.y != new_y; + n.y = new_y; } }, this)); } }; - GridStackEngine.prototype._prepareNode = function(node, resizing) { - node = _.defaults(node || {}, {width: 1, height: 1, x: 0, y: 0}); + GridStackEngine.prototype._prepare_node = function(node, resizing) { + node = _.defaults(node || {}, {width: 1, height: 1, x: 0, y: 0 }); node.x = parseInt('' + node.x); node.y = parseInt('' + node.y); node.width = parseInt('' + node.width); node.height = parseInt('' + node.height); - node.autoPosition = node.autoPosition || false; - node.noResize = node.noResize || false; - node.noMove = node.noMove || false; + node.auto_position = node.auto_position || false; + node.no_resize = node.no_resize || false; + node.no_move = node.no_move || false; if (node.width > this.width) { node.width = this.width; - } else if (node.width < 1) { + } + else if (node.width < 1) { node.width = 1; } @@ -303,7 +214,8 @@ if (node.x + node.width > this.width) { if (resizing) { node.width = this.width - node.x; - } else { + } + else { node.x = this.width - node.width; } } @@ -316,48 +228,44 @@ }; GridStackEngine.prototype._notify = function() { - var args = Array.prototype.slice.call(arguments, 0); - args[0] = typeof args[0] === 'undefined' ? [] : [args[0]]; - args[1] = typeof args[1] === 'undefined' ? true : args[1]; - if (this._updateCounter) { + if (this._update_counter) { return; } - var deletedNodes = args[0].concat(this.getDirtyNodes()); - this.onchange(deletedNodes, args[1]); + var deleted_nodes = Array.prototype.slice.call(arguments, 1).concat(this.get_dirty_nodes()); + deleted_nodes = deleted_nodes.concat(this.get_dirty_nodes()); + this.onchange(deleted_nodes); }; - GridStackEngine.prototype.cleanNodes = function() { - if (this._updateCounter) { - return; - } - _.each(this.nodes, function(n) {n._dirty = false; }); + GridStackEngine.prototype.clean_nodes = function() { + _.each(this.nodes, function(n) {n._dirty = false }); }; - GridStackEngine.prototype.getDirtyNodes = function() { + GridStackEngine.prototype.get_dirty_nodes = function() { return _.filter(this.nodes, function(n) { return n._dirty; }); }; - GridStackEngine.prototype.addNode = function(node, triggerAddEvent) { - node = this._prepareNode(node); + GridStackEngine.prototype.add_node = function(node) { + node = this._prepare_node(node); - if (typeof node.maxWidth != 'undefined') { node.width = Math.min(node.width, node.maxWidth); } - if (typeof node.maxHeight != 'undefined') { node.height = Math.min(node.height, node.maxHeight); } - if (typeof node.minWidth != 'undefined') { node.width = Math.max(node.width, node.minWidth); } - if (typeof node.minHeight != 'undefined') { node.height = Math.max(node.height, node.minHeight); } + if (typeof node.max_width != 'undefined') node.width = Math.min(node.width, node.max_width); + if (typeof node.max_height != 'undefined') node.height = Math.min(node.height, node.max_height); + if (typeof node.min_width != 'undefined') node.width = Math.max(node.width, node.min_width); + if (typeof node.min_height != 'undefined') node.height = Math.max(node.height, node.min_height); - node._id = ++idSeq; + node._id = ++id_seq; node._dirty = true; - if (node.autoPosition) { - this._sortNodes(); + if (node.auto_position) { + this._sort_nodes(); for (var i = 0;; ++i) { - var x = i % this.width; - var y = Math.floor(i / this.width); + var x = i % this.width, y = Math.floor(i / this.width); if (x + node.width > this.width) { continue; } - if (!_.find(this.nodes, _.bind(Utils._isAddNodeIntercepted, {x: x, y: y, node: node}))) { + if (!_.find(this.nodes, function(n) { + return Utils.is_intercepted({x: x, y: y, width: node.width, height: node.height}, n); + })) { node.x = x; node.y = y; break; @@ -366,37 +274,30 @@ } this.nodes.push(node); - if (typeof triggerAddEvent != 'undefined' && triggerAddEvent) { - this._addedNodes.push(_.clone(node)); - } - this._fixCollisions(node); - this._packNodes(); + this._fix_collisions(node); + this._pack_nodes(); this._notify(); return node; }; - GridStackEngine.prototype.removeNode = function(node, detachNode) { + GridStackEngine.prototype.remove_node = function(node) { if (!node) { return; } node._id = null; this.nodes = _.without(this.nodes, node); - this._packNodes(); - this._notify(node, detachNode); + this._pack_nodes(); + this._notify(node); }; - GridStackEngine.prototype.canMoveNode = function(node, x, y, width, height) { - if (!this.isNodeChangedPosition(node, x, y, width, height)) { - return false; - } - var hasLocked = Boolean(_.find(this.nodes, function(n) { return n.locked; })); + GridStackEngine.prototype.can_move_node = function(node, x, y, width, height) { + var has_locked = Boolean(_.find(this.nodes, function(n) { return n.locked })); - if (!this.height && !hasLocked) { + if (!this.height && !has_locked) return true; - } - var clonedNode; + var cloned_node; var clone = new GridStackEngine( this.width, null, @@ -404,77 +305,50 @@ 0, _.map(this.nodes, function(n) { if (n == node) { - clonedNode = $.extend({}, n); - return clonedNode; + cloned_node = $.extend({}, n); + return cloned_node; } return $.extend({}, n); })); - if (typeof clonedNode === 'undefined') { - return true; - } - - clone.moveNode(clonedNode, x, y, width, height); + clone.move_node(cloned_node, x, y, width, height); var res = true; - if (hasLocked) { + if (has_locked) res &= !Boolean(_.find(clone.nodes, function(n) { - return n != clonedNode && Boolean(n.locked) && Boolean(n._dirty); + return n != cloned_node && Boolean(n.locked) && Boolean(n._dirty); })); - } - if (this.height) { - res &= clone.getGridHeight() <= this.height; - } + if (this.height) + res &= clone.get_grid_height() <= this.height; return res; }; - GridStackEngine.prototype.canBePlacedWithRespectToHeight = function(node) { - if (!this.height) { + GridStackEngine.prototype.can_be_placed_with_respect_to_height = function(node) { + if (!this.height) return true; - } var clone = new GridStackEngine( this.width, null, this.float, 0, - _.map(this.nodes, function(n) { return $.extend({}, n); })); - clone.addNode(node); - return clone.getGridHeight() <= this.height; + _.map(this.nodes, function(n) { return $.extend({}, n) })); + clone.add_node(node); + return clone.get_grid_height() <= this.height; }; - GridStackEngine.prototype.isNodeChangedPosition = function(node, x, y, width, height) { - if (typeof x != 'number') { x = node.x; } - if (typeof y != 'number') { y = node.y; } - if (typeof width != 'number') { width = node.width; } - if (typeof height != 'number') { height = node.height; } - - if (typeof node.maxWidth != 'undefined') { width = Math.min(width, node.maxWidth); } - if (typeof node.maxHeight != 'undefined') { height = Math.min(height, node.maxHeight); } - if (typeof node.minWidth != 'undefined') { width = Math.max(width, node.minWidth); } - if (typeof node.minHeight != 'undefined') { height = Math.max(height, node.minHeight); } - - if (node.x == x && node.y == y && node.width == width && node.height == height) { - return false; - } - return true; - }; - - GridStackEngine.prototype.moveNode = function(node, x, y, width, height, noPack) { - if (!this.isNodeChangedPosition(node, x, y, width, height)) { - return node; - } - if (typeof x != 'number') { x = node.x; } - if (typeof y != 'number') { y = node.y; } - if (typeof width != 'number') { width = node.width; } - if (typeof height != 'number') { height = node.height; } + GridStackEngine.prototype.move_node = function(node, x, y, width, height, no_pack) { + if (typeof x != 'number') x = node.x; + if (typeof y != 'number') y = node.y; + if (typeof width != 'number') width = node.width; + if (typeof height != 'number') height = node.height; - if (typeof node.maxWidth != 'undefined') { width = Math.min(width, node.maxWidth); } - if (typeof node.maxHeight != 'undefined') { height = Math.min(height, node.maxHeight); } - if (typeof node.minWidth != 'undefined') { width = Math.max(width, node.minWidth); } - if (typeof node.minHeight != 'undefined') { height = Math.max(height, node.minHeight); } + if (typeof node.max_width != 'undefined') width = Math.min(width, node.max_width); + if (typeof node.max_height != 'undefined') height = Math.min(height, node.max_height); + if (typeof node.min_width != 'undefined') width = Math.max(width, node.min_width); + if (typeof node.min_height != 'undefined') height = Math.max(height, node.min_height); if (node.x == x && node.y == y && node.width == width && node.height == height) { return node; @@ -488,35 +362,30 @@ node.width = width; node.height = height; - node.lastTriedX = x; - node.lastTriedY = y; - node.lastTriedWidth = width; - node.lastTriedHeight = height; - - node = this._prepareNode(node, resizing); + node = this._prepare_node(node, resizing); - this._fixCollisions(node); - if (!noPack) { - this._packNodes(); + this._fix_collisions(node); + if (!no_pack) { + this._pack_nodes(); this._notify(); } return node; }; - GridStackEngine.prototype.getGridHeight = function() { + GridStackEngine.prototype.get_grid_height = function() { return _.reduce(this.nodes, function(memo, n) { return Math.max(memo, n.y + n.height); }, 0); }; - GridStackEngine.prototype.beginUpdate = function(node) { + GridStackEngine.prototype.begin_update = function(node) { _.each(this.nodes, function(n) { - n._origY = n.y; + n._orig_y = n.y; }); node._updating = true; }; - GridStackEngine.prototype.endUpdate = function() { + GridStackEngine.prototype.end_update = function() { _.each(this.nodes, function(n) { - n._origY = n.y; + n._orig_y = n.y; }); var n = _.find(this.nodes, function(n) { return n._updating; }); if (n) { @@ -525,158 +394,76 @@ }; var GridStack = function(el, opts) { - var self = this; - var oneColumnMode, isAutoCellHeight; + var self = this, one_column_mode; opts = opts || {}; this.container = $(el); - // jscs:disable requireCamelCaseOrUpperCaseIdentifiers - if (typeof opts.handle_class !== 'undefined') { - opts.handleClass = opts.handle_class; - obsoleteOpts('handle_class', 'handleClass'); - } - if (typeof opts.item_class !== 'undefined') { - opts.itemClass = opts.item_class; - obsoleteOpts('item_class', 'itemClass'); - } - if (typeof opts.placeholder_class !== 'undefined') { - opts.placeholderClass = opts.placeholder_class; - obsoleteOpts('placeholder_class', 'placeholderClass'); - } - if (typeof opts.placeholder_text !== 'undefined') { - opts.placeholderText = opts.placeholder_text; - obsoleteOpts('placeholder_text', 'placeholderText'); - } - if (typeof opts.cell_height !== 'undefined') { - opts.cellHeight = opts.cell_height; - obsoleteOpts('cell_height', 'cellHeight'); - } - if (typeof opts.vertical_margin !== 'undefined') { - opts.verticalMargin = opts.vertical_margin; - obsoleteOpts('vertical_margin', 'verticalMargin'); - } - if (typeof opts.min_width !== 'undefined') { - opts.minWidth = opts.min_width; - obsoleteOpts('min_width', 'minWidth'); - } - if (typeof opts.static_grid !== 'undefined') { - opts.staticGrid = opts.static_grid; - obsoleteOpts('static_grid', 'staticGrid'); - } - if (typeof opts.is_nested !== 'undefined') { - opts.isNested = opts.is_nested; - obsoleteOpts('is_nested', 'isNested'); - } - if (typeof opts.always_show_resize_handle !== 'undefined') { - opts.alwaysShowResizeHandle = opts.always_show_resize_handle; - obsoleteOpts('always_show_resize_handle', 'alwaysShowResizeHandle'); - } - // jscs:enable requireCamelCaseOrUpperCaseIdentifiers - - opts.itemClass = opts.itemClass || 'grid-stack-item'; - var isNested = this.container.closest('.' + opts.itemClass).length > 0; + opts.item_class = opts.item_class || 'grid-stack-item'; + var is_nested = this.container.closest('.' + opts.item_class).size() > 0; this.opts = _.defaults(opts || {}, { width: parseInt(this.container.attr('data-gs-width')) || 12, height: parseInt(this.container.attr('data-gs-height')) || 0, - itemClass: 'grid-stack-item', - placeholderClass: 'grid-stack-placeholder', - placeholderText: '', + item_class: 'grid-stack-item', + placeholder_class: 'grid-stack-placeholder', + placeholder_text: '', handle: '.grid-stack-item-content', - handleClass: null, - cellHeight: 60, - verticalMargin: 20, + handle_class: null, + cell_height: 60, + vertical_margin: 20, auto: true, - minWidth: 768, + min_width: 768, float: false, - staticGrid: false, + static_grid: false, _class: 'grid-stack-instance-' + (Math.random() * 10000).toFixed(0), animate: Boolean(this.container.attr('data-gs-animate')) || false, - alwaysShowResizeHandle: opts.alwaysShowResizeHandle || false, + always_show_resize_handle: opts.always_show_resize_handle || false, resizable: _.defaults(opts.resizable || {}, { - autoHide: !(opts.alwaysShowResizeHandle || false), + autoHide: !(opts.always_show_resize_handle || false), handles: 'se' }), draggable: _.defaults(opts.draggable || {}, { - handle: (opts.handleClass ? '.' + opts.handleClass : (opts.handle ? opts.handle : '')) || - '.grid-stack-item-content', + handle: (opts.handle_class ? '.' + opts.handle_class : (opts.handle ? opts.handle : '')) || '.grid-stack-item-content', scroll: false, appendTo: 'body' - }), - disableDrag: opts.disableDrag || false, - disableResize: opts.disableResize || false, - rtl: 'auto', - removable: false, - removeTimeout: 2000, - verticalMarginUnit: 'px', - cellHeightUnit: 'px', - oneColumnModeClass: opts.oneColumnModeClass || 'grid-stack-one-column-mode', - ddPlugin: null + }) }); - - if (this.opts.ddPlugin === false) { - this.opts.ddPlugin = GridStackDragDropPlugin; - } else if (this.opts.ddPlugin === null) { - this.opts.ddPlugin = _.first(GridStackDragDropPlugin.registeredPlugins) || GridStackDragDropPlugin; - } - - this.dd = new this.opts.ddPlugin(this); - - if (this.opts.rtl === 'auto') { - this.opts.rtl = this.container.css('direction') === 'rtl'; - } - - if (this.opts.rtl) { - this.container.addClass('grid-stack-rtl'); - } - - this.opts.isNested = isNested; - - isAutoCellHeight = this.opts.cellHeight === 'auto'; - if (isAutoCellHeight) { - self.cellHeight(self.cellWidth(), true); - } else { - this.cellHeight(this.opts.cellHeight, true); - } - this.verticalMargin(this.opts.verticalMargin, true); + this.opts.is_nested = is_nested; this.container.addClass(this.opts._class); - this._setStaticClass(); + this._set_static_class(); - if (isNested) { + if (is_nested) { this.container.addClass('grid-stack-nested'); } - this._initStyles(); + this._init_styles(); - this.grid = new GridStackEngine(this.opts.width, function(nodes, detachNode) { - detachNode = typeof detachNode === 'undefined' ? true : detachNode; - var maxHeight = 0; + this.grid = new GridStackEngine(this.opts.width, function(nodes) { + var max_height = 0; _.each(nodes, function(n) { - if (detachNode && n._id === null) { - if (n.el) { - n.el.remove(); - } - } else { + if (n._id == null) { + n.el.remove(); + } + else { n.el .attr('data-gs-x', n.x) .attr('data-gs-y', n.y) .attr('data-gs-width', n.width) .attr('data-gs-height', n.height); - maxHeight = Math.max(maxHeight, n.y + n.height); + max_height = Math.max(max_height, n.y + n.height); } }); - self._updateStyles(self.opts.height || (max_height + 10)); + self._update_styles(self.opts.height || (max_height + 10)); }, this.opts.float, this.opts.height); if (this.opts.auto) { var elements = []; var _this = this; - this.container.children('.' + this.opts.itemClass + ':not(.' + this.opts.placeholderClass + ')') - .each(function(index, el) { + this.container.children('.' + this.opts.item_class + ':not(.' + this.opts.placeholder_class + ')').each(function(index, el) { el = $(el); elements.push({ el: el, @@ -684,219 +471,70 @@ }); }); _.chain(elements).sortBy(function(x) { return x.i; }).each(function(i) { - self._prepareElement(i.el); + self._prepare_element(i.el); }).value(); } - this.setAnimation(this.opts.animate); + this.set_animation(this.opts.animate); this.placeholder = $( - '
' + - '
' + this.opts.placeholderText + '
').hide(); + '
' + + '
' + this.opts.placeholder_text + '
').hide(); - this._updateContainerHeight(); + this.container.height(this._calculate_container_height()); // setting styles also for empty grids - this._updateStyles(); + this._update_styles(); - this._updateHeightsOnResize = _.throttle(function() { - self.cellHeight(self.cellWidth(), false); - }, 100); - - this.onResizeHandler = function() { - if (isAutoCellHeight) { - self._updateHeightsOnResize(); - } - - if (self._isOneColumnMode()) { - if (oneColumnMode) { + this.on_resize_handler = function() { + if (self._is_one_column_mode()) { + if (one_column_mode) return; - } - self.container.addClass(self.opts.oneColumnModeClass); - oneColumnMode = true; - self.grid._sortNodes(); + one_column_mode = true; + + self.grid._sort_nodes(); _.each(self.grid.nodes, function(node) { self.container.append(node.el); - if (self.opts.staticGrid) { + if (self.opts.static_grid) { return; } - if (node.noMove || self.opts.disableDrag) { - self.dd.draggable(node.el, 'disable'); + if (!node.no_move) { + node.el.draggable('disable'); } - if (node.noResize || self.opts.disableResize) { - self.dd.resizable(node.el, 'disable'); + if (!node.no_resize) { + node.el.resizable('disable'); } - - node.el.trigger('resize'); }); - } else { - if (!oneColumnMode) { + } + else { + if (!one_column_mode) return; - } - self.container.removeClass(self.opts.oneColumnModeClass); - oneColumnMode = false; + one_column_mode = false; - if (self.opts.staticGrid) { + if (self.opts.static_grid) { return; } _.each(self.grid.nodes, function(node) { - if (!node.noMove && !self.opts.disableDrag) { - self.dd.draggable(node.el, 'enable'); + if (!node.no_move) { + node.el.draggable('enable'); } - if (!node.noResize && !self.opts.disableResize) { - self.dd.resizable(node.el, 'enable'); + if (!node.no_resize) { + node.el.resizable('enable'); } - - node.el.trigger('resize'); }); } }; - $(window).resize(this.onResizeHandler); - this.onResizeHandler(); - - if (!self.opts.staticGrid && typeof self.opts.removable === 'string') { - var trashZone = $(self.opts.removable); - if (!this.dd.isDroppable(trashZone)) { - this.dd.droppable(trashZone, { - accept: '.' + self.opts.itemClass - }); - } - this.dd - .on(trashZone, 'dropover', function(event, ui) { - var el = $(ui.draggable); - var node = el.data('_gridstack_node'); - if (node._grid !== self) { - return; - } - self._setupRemovingTimeout(el); - }) - .on(trashZone, 'dropout', function(event, ui) { - var el = $(ui.draggable); - var node = el.data('_gridstack_node'); - if (node._grid !== self) { - return; - } - self._clearRemovingTimeout(el); - }); - } - - if (!self.opts.staticGrid && self.opts.acceptWidgets) { - var draggingElement = null; - - var onDrag = function(event, ui) { - var el = draggingElement; - var node = el.data('_gridstack_node'); - var pos = self.getCellFromPixel(ui.offset, true); - var x = Math.max(0, pos.x); - var y = Math.max(0, pos.y); - if (!node._added) { - node._added = true; - - node.el = el; - node.x = x; - node.y = y; - self.grid.cleanNodes(); - self.grid.beginUpdate(node); - self.grid.addNode(node); - - self.container.append(self.placeholder); - self.placeholder - .attr('data-gs-x', node.x) - .attr('data-gs-y', node.y) - .attr('data-gs-width', node.width) - .attr('data-gs-height', node.height) - .show(); - node.el = self.placeholder; - node._beforeDragX = node.x; - node._beforeDragY = node.y; - - self._updateContainerHeight(); - } else { - if (!self.grid.canMoveNode(node, x, y)) { - return; - } - self.grid.moveNode(node, x, y); - self._updateContainerHeight(); - } - }; - - this.dd - .droppable(self.container, { - accept: function(el) { - el = $(el); - var node = el.data('_gridstack_node'); - if (node && node._grid === self) { - return false; - } - return el.is(self.opts.acceptWidgets === true ? '.grid-stack-item' : self.opts.acceptWidgets); - } - }) - .on(self.container, 'dropover', function(event, ui) { - var offset = self.container.offset(); - var el = $(ui.draggable); - var cellWidth = self.cellWidth(); - var cellHeight = self.cellHeight(); - var origNode = el.data('_gridstack_node'); - - var width = origNode ? origNode.width : (Math.ceil(el.outerWidth() / cellWidth)); - var height = origNode ? origNode.height : (Math.ceil(el.outerHeight() / cellHeight)); - - draggingElement = el; - - var node = self.grid._prepareNode({width: width, height: height, _added: false, _temporary: true}); - el.data('_gridstack_node', node); - el.data('_gridstack_node_orig', origNode); - - el.on('drag', onDrag); - }) - .on(self.container, 'dropout', function(event, ui) { - var el = $(ui.draggable); - el.unbind('drag', onDrag); - var node = el.data('_gridstack_node'); - node.el = null; - self.grid.removeNode(node); - self.placeholder.detach(); - self._updateContainerHeight(); - el.data('_gridstack_node', el.data('_gridstack_node_orig')); - }) - .on(self.container, 'drop', function(event, ui) { - self.placeholder.detach(); - - var node = $(ui.draggable).data('_gridstack_node'); - node._grid = self; - var el = $(ui.draggable).clone(false); - el.data('_gridstack_node', node); - $(ui.draggable).remove(); - node.el = el; - self.placeholder.hide(); - el - .attr('data-gs-x', node.x) - .attr('data-gs-y', node.y) - .attr('data-gs-width', node.width) - .attr('data-gs-height', node.height) - .addClass(self.opts.itemClass) - .removeAttr('style') - .enableSelection() - .removeData('draggable') - .removeClass('ui-draggable ui-draggable-dragging ui-draggable-disabled') - .unbind('drag', onDrag); - self.container.append(el); - self._prepareElementsByNode(el, node); - self._updateContainerHeight(); - self._triggerChangeEvent(); - - self.grid.endUpdate(); - }); - } + $(window).resize(this.on_resize_handler); + this.on_resize_handler(); }; - GridStack.prototype._triggerChangeEvent = function(forceTrigger) { - var elements = this.grid.getDirtyNodes(); + GridStack.prototype._trigger_change_event = function(forceTrigger) { + var elements = this.grid.get_dirty_nodes(); var hasChanges = false; var eventParams = []; @@ -910,237 +548,138 @@ } }; - GridStack.prototype._triggerAddEvent = function() { - if (this.grid._addedNodes && this.grid._addedNodes.length > 0) { - this.container.trigger('added', [_.map(this.grid._addedNodes, _.clone)]); - this.grid._addedNodes = []; - } - }; - - GridStack.prototype._triggerRemoveEvent = function() { - if (this.grid._removedNodes && this.grid._removedNodes.length > 0) { - this.container.trigger('removed', [_.map(this.grid._removedNodes, _.clone)]); - this.grid._removedNodes = []; + GridStack.prototype._init_styles = function() { + if (this._styles_id) { + $('[data-gs-id="' + this._styles_id + '"]').remove(); } - }; - - GridStack.prototype._initStyles = function() { - if (this._stylesId) { - Utils.removeStylesheet(this._stylesId); - } - this._stylesId = 'gridstack-style-' + (Math.random() * 100000).toFixed(); - this._styles = Utils.createStylesheet(this._stylesId); - if (this._styles !== null) { + this._styles_id = 'gridstack-style-' + (Math.random() * 100000).toFixed(); + this._styles = Utils.create_stylesheet(this._styles_id); + if (this._styles != null) this._styles._max = 0; - } }; - GridStack.prototype._updateStyles = function(maxHeight) { - if (this._styles === null || typeof this._styles === 'undefined') { + GridStack.prototype._update_styles = function(max_height) { + if (this._styles == null) { return; } - var prefix = '.' + this.opts._class + ' .' + this.opts.itemClass; - var self = this; - var getHeight; - - if (typeof maxHeight == 'undefined') { - maxHeight = this._styles._max || this.opts.height;; - this._initStyles(); - this._updateContainerHeight(); - } - if (!this.opts.cellHeight) { // The rest will be handled by CSS - return ; - } - if (this._styles._max !== 0 && maxHeight <= this._styles._max) { - return ; - } + var prefix = '.' + this.opts._class + ' .' + this.opts.item_class; - if (!this.opts.verticalMargin || this.opts.cellHeightUnit === this.opts.verticalMarginUnit) { - getHeight = function(nbRows, nbMargins) { - return (self.opts.cellHeight * nbRows + self.opts.verticalMargin * nbMargins) + - self.opts.cellHeightUnit; - }; - } else { - getHeight = function(nbRows, nbMargins) { - if (!nbRows || !nbMargins) { - return (self.opts.cellHeight * nbRows + self.opts.verticalMargin * nbMargins) + - self.opts.cellHeightUnit; - } - return 'calc(' + ((self.opts.cellHeight * nbRows) + self.opts.cellHeightUnit) + ' + ' + - ((self.opts.verticalMargin * nbMargins) + self.opts.verticalMarginUnit) + ')'; - }; + if (typeof max_height == 'undefined') { + max_height = this._styles._max || this.opts.height; + this._init_styles(); + this._update_container_height(); } - if (this._styles._max === 0) { - Utils.insertCSSRule(this._styles, prefix, 'min-height: ' + getHeight(1, 0) + ';', 0); + if (this._styles._max == 0) { + Utils.insert_css_rule(this._styles, prefix, 'min-height: ' + (this.opts.cell_height) + 'px;', 0); } - if (maxHeight > this._styles._max) { - for (var i = this._styles._max; i < maxHeight; ++i) { - Utils.insertCSSRule(this._styles, + if (max_height > this._styles._max) { + for (var i = this._styles._max; i < max_height; ++i) { + Utils.insert_css_rule(this._styles, prefix + '[data-gs-height="' + (i + 1) + '"]', - 'height: ' + getHeight(i + 1, i) + ';', + 'height: ' + (this.opts.cell_height * (i + 1) + this.opts.vertical_margin * i) + 'px;', i ); - Utils.insertCSSRule(this._styles, + Utils.insert_css_rule(this._styles, prefix + '[data-gs-min-height="' + (i + 1) + '"]', - 'min-height: ' + getHeight(i + 1, i) + ';', + 'min-height: ' + (this.opts.cell_height * (i + 1) + this.opts.vertical_margin * i) + 'px;', i ); - Utils.insertCSSRule(this._styles, + Utils.insert_css_rule(this._styles, prefix + '[data-gs-max-height="' + (i + 1) + '"]', - 'max-height: ' + getHeight(i + 1, i) + ';', + 'max-height: ' + (this.opts.cell_height * (i + 1) + this.opts.vertical_margin * i) + 'px;', i ); - Utils.insertCSSRule(this._styles, + Utils.insert_css_rule(this._styles, prefix + '[data-gs-y="' + i + '"]', - 'top: ' + getHeight(i, i) + ';', + 'top: ' + (this.opts.cell_height * i + this.opts.vertical_margin * i) + 'px;', i ); } - this._styles._max = maxHeight; + this._styles._max = max_height; } }; - GridStack.prototype._updateContainerHeight = function() { - if (this.grid._updateCounter) { - return; + GridStack.prototype._calculate_container_height = function() { + var gridHeight = this.grid.get_grid_height(); + if (!gridHeight) { + gridHeight = this.opts.height; } - var height = this.grid.getGridHeight(); - this.container.attr('data-gs-current-height', height); - if (!this.opts.cellHeight) { - return ; - } - if (!this.opts.verticalMargin) { - this.container.css('height', (height * (this.opts.cellHeight)) + this.opts.cellHeightUnit); - } else if (this.opts.cellHeightUnit === this.opts.verticalMarginUnit) { - this.container.css('height', (height * (this.opts.cellHeight + this.opts.verticalMargin) - - this.opts.verticalMargin) + this.opts.cellHeightUnit); - } else { - this.container.css('height', 'calc(' + ((height * (this.opts.cellHeight)) + this.opts.cellHeightUnit) + - ' + ' + ((height * (this.opts.verticalMargin - 1)) + this.opts.verticalMarginUnit) + ')'); + return gridHeight * (this.opts.cell_height + this.opts.vertical_margin) - this.opts.vertical_margin; + }; + + GridStack.prototype._update_container_height = function() { + if (this.grid._update_counter) { + return; } + this.container.height(this._calculate_container_height()); }; - GridStack.prototype._isOneColumnMode = function() { + GridStack.prototype._is_one_column_mode = function() { return (window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth) <= - this.opts.minWidth; + this.opts.min_width; }; - GridStack.prototype._setupRemovingTimeout = function(el) { + GridStack.prototype._prepare_element = function(el) { var self = this; - var node = $(el).data('_gridstack_node'); - - if (node._removeTimeout || !self.opts.removable) { - return; - } - node._removeTimeout = setTimeout(function() { - el.addClass('grid-stack-item-removing'); - node._isAboutToRemove = true; - }, self.opts.removeTimeout); - }; + el = $(el); - GridStack.prototype._clearRemovingTimeout = function(el) { - var node = $(el).data('_gridstack_node'); + el.addClass(this.opts.item_class); - if (!node._removeTimeout) { - return; - } - clearTimeout(node._removeTimeout); - node._removeTimeout = null; - el.removeClass('grid-stack-item-removing'); - node._isAboutToRemove = false; - }; + var node = self.grid.add_node({ + x: el.attr('data-gs-x'), + y: el.attr('data-gs-y'), + width: el.attr('data-gs-width'), + height: el.attr('data-gs-height'), + max_width: el.attr('data-gs-max-width'), + min_width: el.attr('data-gs-min-width'), + max_height: el.attr('data-gs-max-height'), + min_height: el.attr('data-gs-min-height'), + auto_position: Utils.toBool(el.attr('data-gs-auto-position')), + no_resize: Utils.toBool(el.attr('data-gs-no-resize')), + no_move: Utils.toBool(el.attr('data-gs-no-move')), + locked: Utils.toBool(el.attr('data-gs-locked')), + el: el + }); + el.data('_gridstack_node', node); - GridStack.prototype._prepareElementsByNode = function(el, node) { - if (typeof $.ui === 'undefined') { + if (self.opts.static_grid) { return; } - var self = this; - var cellWidth; - var cellHeight; + var cell_width, cell_height; - var dragOrResize = function(event, ui) { - var x = Math.round(ui.position.left / cellWidth); - var y = Math.floor((ui.position.top + cellHeight / 2) / cellHeight); - var width; - var height; - - if (event.type != 'drag') { - width = Math.round(ui.size.width / cellWidth); - height = Math.round(ui.size.height / cellHeight); + var drag_or_resize = function(event, ui) { + var x = Math.round(ui.position.left / cell_width), + y = Math.floor((ui.position.top + cell_height / 2) / cell_height), + width, height; + if (event.type != "drag") { + width = Math.round(ui.size.width / cell_width); + height = Math.round(ui.size.height / cell_height); } - if (event.type == 'drag') { - if (x < 0 || x >= self.grid.width || y < 0) { - if (self.opts.removable === true) { - self._setupRemovingTimeout(el); - } - - x = node._beforeDragX; - y = node._beforeDragY; - - self.placeholder.detach(); - self.placeholder.hide(); - self.grid.removeNode(node); - self._updateContainerHeight(); - - node._temporaryRemoved = true; - } else { - self._clearRemovingTimeout(el); - - if (node._temporaryRemoved) { - self.grid.addNode(node); - self.placeholder - .attr('data-gs-x', x) - .attr('data-gs-y', y) - .attr('data-gs-width', width) - .attr('data-gs-height', height) - .show(); - self.container.append(self.placeholder); - node.el = self.placeholder; - node._temporaryRemoved = false; - } - } - } else if (event.type == 'resize') { - if (x < 0) { - return; - } - } - // width and height are undefined if not resizing - var lastTriedWidth = typeof width !== 'undefined' ? width : node.lastTriedWidth; - var lastTriedHeight = typeof height !== 'undefined' ? height : node.lastTriedHeight; - if (!self.grid.canMoveNode(node, x, y, width, height) || - (node.lastTriedX === x && node.lastTriedY === y && - node.lastTriedWidth === lastTriedWidth && node.lastTriedHeight === lastTriedHeight)) { + if (!self.grid.can_move_node(node, x, y, width, height)) { return; } - node.lastTriedX = x; - node.lastTriedY = y; - node.lastTriedWidth = width; - node.lastTriedHeight = height; - self.grid.moveNode(node, x, y, width, height); - self._updateContainerHeight(); + self.grid.move_node(node, x, y, width, height); + self._update_container_height(); }; - var onStartMoving = function(event, ui) { - - if (self.opts.draggable.handle && event.type === 'dragstart') { + var on_start_moving = function(event, ui) { + if (self.opts.draggable.handle && event.type === 'dragstart') { // if handle specified, don't allow drag from anywhere else if (!$(event.originalEvent.target).closest(self.opts.draggable.handle).length) { return false; } } - self.container.append(self.placeholder); var o = $(this); - self.grid.cleanNodes(); - self.grid.beginUpdate(node); - cellWidth = self.cellWidth(); - var strictCellHeight = Math.ceil(o.outerHeight() / o.attr('data-gs-height')); - cellHeight = self.container.height() / parseInt(self.container.attr('data-gs-current-height')); + self.grid.clean_nodes(); + self.grid.begin_update(node); + cell_width = o.outerWidth() / o.attr('data-gs-width'); + cell_height = self.opts.cell_height + self.opts.vertical_margin; self.placeholder .attr('data-gs-x', o.attr('data-gs-x')) .attr('data-gs-y', o.attr('data-gs-y')) @@ -1148,202 +687,125 @@ .attr('data-gs-height', o.attr('data-gs-height')) .show(); node.el = self.placeholder; - node._beforeDragX = node.x; - node._beforeDragY = node.y; - self.dd.resizable(el, 'option', 'minWidth', cellWidth * (node.minWidth || 1)); - self.dd.resizable(el, 'option', 'minHeight', strictCellHeight * (node.minHeight || 1)); + el.resizable('option', 'minWidth', Math.round(cell_width * (node.min_width || 1))); + el.resizable('option', 'minHeight', self.opts.cell_height * (node.min_height || 1)); if (event.type == 'resizestart') { o.find('.grid-stack-item').trigger('resizestart'); } }; - var onEndMoving = function(event, ui) { - var o = $(this); - if (!o.data('_gridstack_node')) { - return; - } - - var forceNotify = false; + var on_end_moving = function(event, ui) { self.placeholder.detach(); + var o = $(this); node.el = o; self.placeholder.hide(); - - if (node._isAboutToRemove) { - forceNotify = true; - el.removeData('_gridstack_node'); - el.remove(); - } else { - self._clearRemovingTimeout(el); - if (!node._temporaryRemoved) { - o - .attr('data-gs-x', node.x) - .attr('data-gs-y', node.y) - .attr('data-gs-width', node.width) - .attr('data-gs-height', node.height) - .removeAttr('style'); - } else { - o - .attr('data-gs-x', node._beforeDragX) - .attr('data-gs-y', node._beforeDragY) - .attr('data-gs-width', node.width) - .attr('data-gs-height', node.height) - .removeAttr('style'); - node.x = node._beforeDragX; - node.y = node._beforeDragY; - self.grid.addNode(node); - } - } - self._updateContainerHeight(); - self._triggerChangeEvent(forceNotify); - - self.grid.endUpdate(); - - var nestedGrids = o.find('.grid-stack'); - if (nestedGrids.length && event.type == 'resizestop') { - nestedGrids.each(function(index, el) { - $(el).data('gridstack').onResizeHandler(); + o + .attr('data-gs-x', node.x) + .attr('data-gs-y', node.y) + .attr('data-gs-width', node.width) + .attr('data-gs-height', node.height) + .removeAttr('style'); + self._update_container_height(); + self._trigger_change_event(); + + self.grid.end_update(); + + var nested_grids = o.find('.grid-stack'); + if (nested_grids.length && event.type == 'resizestop') { + nested_grids.each(function(index, el) { + $(el).data('gridstack').on_resize_handler(); }); o.find('.grid-stack-item').trigger('resizestop'); } }; - this.dd - .draggable(el, { - start: onStartMoving, - stop: onEndMoving, - drag: dragOrResize - }) - .resizable(el, { - start: onStartMoving, - stop: onEndMoving, - resize: dragOrResize - }); + el + .draggable(_.extend(this.opts.draggable, { + containment: this.opts.is_nested ? this.container.parent() : null + })) + .on('dragstart', on_start_moving) + .on('dragstop', on_end_moving) + .on('drag', drag_or_resize) + .resizable(_.extend(this.opts.resizable, {})) + .on('resizestart', on_start_moving) + .on('resizestop', on_end_moving) + .on('resize', drag_or_resize); - if (node.noMove || this._isOneColumnMode() || this.opts.disableDrag) { - this.dd.draggable(el, 'disable'); + if (node.no_move || this._is_one_column_mode()) { + el.draggable('disable'); } - if (node.noResize || this._isOneColumnMode() || this.opts.disableResize) { - this.dd.resizable(el, 'disable'); + if (node.no_resize || this._is_one_column_mode()) { + el.resizable('disable'); } el.attr('data-gs-locked', node.locked ? 'yes' : null); }; - GridStack.prototype._prepareElement = function(el, triggerAddEvent) { - triggerAddEvent = typeof triggerAddEvent != 'undefined' ? triggerAddEvent : false; - var self = this; - el = $(el); - - el.addClass(this.opts.itemClass); - var node = self.grid.addNode({ - x: el.attr('data-gs-x'), - y: el.attr('data-gs-y'), - width: el.attr('data-gs-width'), - height: el.attr('data-gs-height'), - maxWidth: el.attr('data-gs-max-width'), - minWidth: el.attr('data-gs-min-width'), - maxHeight: el.attr('data-gs-max-height'), - minHeight: el.attr('data-gs-min-height'), - autoPosition: Utils.toBool(el.attr('data-gs-auto-position')), - noResize: Utils.toBool(el.attr('data-gs-no-resize')), - noMove: Utils.toBool(el.attr('data-gs-no-move')), - locked: Utils.toBool(el.attr('data-gs-locked')), - el: el, - id: el.attr('data-gs-id'), - _grid: self - }, triggerAddEvent); - el.data('_gridstack_node', node); - - this._prepareElementsByNode(el, node); - }; - - GridStack.prototype.setAnimation = function(enable) { + GridStack.prototype.set_animation = function(enable) { if (enable) { this.container.addClass('grid-stack-animate'); - } else { + } + else { this.container.removeClass('grid-stack-animate'); } }; - GridStack.prototype.addWidget = function(el, x, y, width, height, autoPosition, minWidth, maxWidth, - minHeight, maxHeight, id) { + GridStack.prototype.add_widget = function(el, x, y, width, height, auto_position) { el = $(el); - if (typeof x != 'undefined') { el.attr('data-gs-x', x); } - if (typeof y != 'undefined') { el.attr('data-gs-y', y); } - if (typeof width != 'undefined') { el.attr('data-gs-width', width); } - if (typeof height != 'undefined') { el.attr('data-gs-height', height); } - if (typeof autoPosition != 'undefined') { el.attr('data-gs-auto-position', autoPosition ? 'yes' : null); } - if (typeof minWidth != 'undefined') { el.attr('data-gs-min-width', minWidth); } - if (typeof maxWidth != 'undefined') { el.attr('data-gs-max-width', maxWidth); } - if (typeof minHeight != 'undefined') { el.attr('data-gs-min-height', minHeight); } - if (typeof maxHeight != 'undefined') { el.attr('data-gs-max-height', maxHeight); } - if (typeof id != 'undefined') { el.attr('data-gs-id', id); } + if (typeof x != 'undefined') el.attr('data-gs-x', x); + if (typeof y != 'undefined') el.attr('data-gs-y', y); + if (typeof width != 'undefined') el.attr('data-gs-width', width); + if (typeof height != 'undefined') el.attr('data-gs-height', height); + if (typeof auto_position != 'undefined') el.attr('data-gs-auto-position', auto_position ? 'yes' : null); this.container.append(el); - this.make_widget(el); - return el; }; - GridStack.prototype.makeWidget = function(el) { + GridStack.prototype.make_widget = function(el) { el = $(el); - this._prepareElement(el, true); - this._triggerAddEvent(); - this._updateContainerHeight(); - this._triggerChangeEvent(true); + this._prepare_element(el); + this._update_container_height(); + this._trigger_change_event(true); return el; }; - GridStack.prototype.willItFit = function(x, y, width, height, autoPosition) { - var node = {x: x, y: y, width: width, height: height, autoPosition: autoPosition}; - return this.grid.canBePlacedWithRespectToHeight(node); + GridStack.prototype.will_it_fit = function(x, y, width, height, auto_position) { + var node = {x: x, y: y, width: width, height: height, auto_position: auto_position}; + return this.grid.can_be_placed_with_respect_to_height(node); }; - GridStack.prototype.removeWidget = function(el, detachNode) { - detachNode = typeof detachNode === 'undefined' ? true : detachNode; + GridStack.prototype.remove_widget = function(el, detach_node) { + detach_node = typeof detach_node === 'undefined' ? true : detach_node; el = $(el); var node = el.data('_gridstack_node'); - - // For Meteor support: https://github.com/troolee/gridstack.js/pull/272 - if (!node) { - node = this.grid.getNodeDataByDOMEl(el); - } - - this.grid.removeNode(node, detachNode); + this.grid.remove_node(node); el.removeData('_gridstack_node'); - this._updateContainerHeight(); - if (detachNode) { + this._update_container_height(); + if (detach_node) el.remove(); - } - this._triggerChangeEvent(true); - this._triggerRemoveEvent(); + this._trigger_change_event(true); }; - GridStack.prototype.removeAll = function(detachNode) { + GridStack.prototype.remove_all = function(detach_node) { _.each(this.grid.nodes, _.bind(function(node) { - this.removeWidget(node.el, detachNode); + this.remove_widget(node.el, detach_node); }, this)); this.grid.nodes = []; - this._updateContainerHeight(); + this._update_container_height(); }; - GridStack.prototype.destroy = function(detachGrid) { - $(window).off('resize', this.onResizeHandler); + GridStack.prototype.destroy = function() { + $(window).off("resize", this.on_resize_handler); this.disable(); - if (typeof detachGrid != 'undefined' && !detachGrid) { - this.removeAll(false); - this.container.removeData('gridstack'); - } else { - this.container.remove(); - } - Utils.removeStylesheet(this._stylesId); - if (this.grid) { + this.container.remove(); + Utils.remove_stylesheet(this._styles_id); + if (this.grid) this.grid = null; - } }; GridStack.prototype.resizable = function(el, val) { @@ -1352,15 +814,16 @@ el.each(function(index, el) { el = $(el); var node = el.data('_gridstack_node'); - if (typeof node == 'undefined' || node === null || typeof $.ui === 'undefined' || self.opts.static_grid) { + if (typeof node == 'undefined' || node == null || self.opts.static_grid) { return; } - node.noResize = !(val || false); - if (node.noResize || self._isOneColumnMode()) { - self.dd.resizable(el, 'disable'); - } else { - self.dd.resizable(el, 'enable'); + node.no_resize = !(val || false); + if (node.no_resize || self._is_one_column_mode()) { + el.resizable('disable'); + } + else { + el.resizable('enable'); } }); return this; @@ -1372,45 +835,32 @@ el.each(function(index, el) { el = $(el); var node = el.data('_gridstack_node'); - if (typeof node == 'undefined' || node === null || typeof $.ui === 'undefined' || self.opts.static_grid) { + if (typeof node == 'undefined' || node == null || self.opts.static_grid) { return; } - node.noMove = !(val || false); - if (node.noMove || self._isOneColumnMode()) { - self.dd.draggable(el, 'disable'); + node.no_move = !(val || false); + if (node.no_move || self._is_one_column_mode()) { + el.draggable('disable'); el.removeClass('ui-draggable-handle'); - } else { - self.dd.draggable(el, 'enable'); + } + else { + el.draggable('enable'); el.addClass('ui-draggable-handle'); } }); return this; }; - GridStack.prototype.enableMove = function(doEnable, includeNewWidgets) { - this.movable(this.container.children('.' + this.opts.itemClass), doEnable); - if (includeNewWidgets) { - this.opts.disableDrag = !doEnable; - } - }; - - GridStack.prototype.enableResize = function(doEnable, includeNewWidgets) { - this.resizable(this.container.children('.' + this.opts.itemClass), doEnable); - if (includeNewWidgets) { - this.opts.disableResize = !doEnable; - } - }; - GridStack.prototype.disable = function() { - this.movable(this.container.children('.' + this.opts.itemClass), false); - this.resizable(this.container.children('.' + this.opts.itemClass), false); + this.movable(this.container.children('.' + this.opts.item_class), false); + this.resizable(this.container.children('.' + this.opts.item_class), false); this.container.trigger('disable'); }; GridStack.prototype.enable = function() { - this.movable(this.container.children('.' + this.opts.itemClass), true); - this.resizable(this.container.children('.' + this.opts.itemClass), true); + this.movable(this.container.children('.' + this.opts.item_class), true); + this.resizable(this.container.children('.' + this.opts.item_class), true); this.container.trigger('enable'); }; @@ -1419,7 +869,7 @@ el.each(function(index, el) { el = $(el); var node = el.data('_gridstack_node'); - if (typeof node == 'undefined' || node === null) { + if (typeof node == 'undefined' || node == null) { return; } @@ -1429,220 +879,154 @@ return this; }; - GridStack.prototype.maxHeight = function(el, val) { + GridStack.prototype.min_height = function (el, val) { el = $(el); - el.each(function(index, el) { + el.each(function (index, el) { el = $(el); var node = el.data('_gridstack_node'); - if (typeof node === 'undefined' || node === null) { + if (typeof node == 'undefined' || node == null) { return; } - if (!isNaN(val)) { - node.maxHeight = (val || false); - el.attr('data-gs-max-height', val); - } - }); - return this; - }; - - GridStack.prototype.minHeight = function(el, val) { - el = $(el); - el.each(function(index, el) { - el = $(el); - var node = el.data('_gridstack_node'); - if (typeof node === 'undefined' || node === null) { - return; - } - - if (!isNaN(val)) { - node.minHeight = (val || false); + if(!isNaN(val)){ + node.min_height = (val || false); el.attr('data-gs-min-height', val); } }); return this; }; - GridStack.prototype.maxWidth = function(el, val) { + GridStack.prototype.min_width = function (el, val) { el = $(el); - el.each(function(index, el) { + el.each(function (index, el) { el = $(el); var node = el.data('_gridstack_node'); - if (typeof node === 'undefined' || node === null) { + if (typeof node == 'undefined' || node == null) { return; } - if (!isNaN(val)) { - node.maxWidth = (val || false); - el.attr('data-gs-max-width', val); - } - }); - return this; - }; - - GridStack.prototype.minWidth = function(el, val) { - el = $(el); - el.each(function(index, el) { - el = $(el); - var node = el.data('_gridstack_node'); - if (typeof node === 'undefined' || node === null) { - return; - } - - if (!isNaN(val)) { - node.minWidth = (val || false); + if(!isNaN(val)){ + node.min_width = (val || false); el.attr('data-gs-min-width', val); } }); return this; }; - GridStack.prototype._updateElement = function(el, callback) { - + GridStack.prototype._update_element = function(el, callback) { el = $(el).first(); var node = el.data('_gridstack_node'); - if (typeof node == 'undefined' || node === null) { + if (typeof node == 'undefined' || node == null) { return; } var self = this; - self.grid.cleanNodes(); - self.grid.beginUpdate(node); + self.grid.clean_nodes(); + self.grid.begin_update(node); callback.call(this, el, node); - self._updateContainerHeight(); - self._triggerChangeEvent(); + self._update_container_height(); + self._trigger_change_event(); - self.grid.endUpdate(); + self.grid.end_update(); }; GridStack.prototype.resize = function(el, width, height) { - this._updateElement(el, function(el, node) { - width = (width !== null && typeof width != 'undefined') ? width : node.width; - height = (height !== null && typeof height != 'undefined') ? height : node.height; + this._update_element(el, function(el, node) { + width = (width != null && typeof width != 'undefined') ? width : node.width; + height = (height != null && typeof height != 'undefined') ? height : node.height; - this.grid.moveNode(node, node.x, node.y, width, height); + this.grid.move_node(node, node.x, node.y, width, height); }); }; GridStack.prototype.move = function(el, x, y) { - this._updateElement(el, function(el, node) { - x = (x !== null && typeof x != 'undefined') ? x : node.x; - y = (y !== null && typeof y != 'undefined') ? y : node.y; + this._update_element(el, function(el, node) { + x = (x != null && typeof x != 'undefined') ? x : node.x; + y = (y != null && typeof y != 'undefined') ? y : node.y; - this.grid.moveNode(node, x, y, node.width, node.height); + this.grid.move_node(node, x, y, node.width, node.height); }); }; GridStack.prototype.update = function(el, x, y, width, height) { - this._updateElement(el, function(el, node) { - x = (x !== null && typeof x != 'undefined') ? x : node.x; - y = (y !== null && typeof y != 'undefined') ? y : node.y; - width = (width !== null && typeof width != 'undefined') ? width : node.width; - height = (height !== null && typeof height != 'undefined') ? height : node.height; + this._update_element(el, function(el, node) { + x = (x != null && typeof x != 'undefined') ? x : node.x; + y = (y != null && typeof y != 'undefined') ? y : node.y; + width = (width != null && typeof width != 'undefined') ? width : node.width; + height = (height != null && typeof height != 'undefined') ? height : node.height; - this.grid.moveNode(node, x, y, width, height); + this.grid.move_node(node, x, y, width, height); }); }; - GridStack.prototype.verticalMargin = function(val, noUpdate) { - if (typeof val == 'undefined') { - return this.opts.verticalMargin; - } - - var heightData = Utils.parseHeight(val); - - if (this.opts.verticalMarginUnit === heightData.unit && this.opts.height === heightData.height) { - return ; - } - this.opts.verticalMarginUnit = heightData.unit; - this.opts.verticalMargin = heightData.height; - - if (!noUpdate) { - this._updateStyles(); - } - }; - - GridStack.prototype.cellHeight = function(val, noUpdate) { + GridStack.prototype.cell_height = function(val) { if (typeof val == 'undefined') { - if (this.opts.cellHeight) { - return this.opts.cellHeight; - } - var o = this.container.children('.' + this.opts.itemClass).first(); - return Math.ceil(o.outerHeight() / o.attr('data-gs-height')); + return this.opts.cell_height; } - var heightData = Utils.parseHeight(val); - - if (this.opts.cellHeightUnit === heightData.heightUnit && this.opts.height === heightData.height) { - return ; - } - this.opts.cellHeightUnit = heightData.unit; - this.opts.cellHeight = heightData.height; - - if (!noUpdate) { - this._updateStyles(); - } - + val = parseInt(val); + if (val == this.opts.cell_height) + return; + this.opts.cell_height = val || this.opts.cell_height; + this._update_styles(); }; - GridStack.prototype.cellWidth = function() { - return Math.round(this.container.outerWidth() / this.opts.width); + GridStack.prototype.cell_width = function() { + var o = this.container.children('.' + this.opts.item_class).first(); + return Math.ceil(o.outerWidth() / o.attr('data-gs-width')); }; - GridStack.prototype.getCellFromPixel = function(position, useOffset) { - var containerPos = (typeof useOffset != 'undefined' && useOffset) ? - this.container.offset() : this.container.position(); + GridStack.prototype.get_cell_from_pixel = function(position) { + var containerPos = this.container.position(); var relativeLeft = position.left - containerPos.left; var relativeTop = position.top - containerPos.top; - var columnWidth = Math.floor(this.container.width() / this.opts.width); - var rowHeight = Math.floor(this.container.height() / parseInt(this.container.attr('data-gs-current-height'))); + var column_width = Math.floor(this.container.width() / this.opts.width); + var row_height = this.opts.cell_height + this.opts.vertical_margin; - return {x: Math.floor(relativeLeft / columnWidth), y: Math.floor(relativeTop / rowHeight)}; + return {x: Math.floor(relativeLeft / column_width), y: Math.floor(relativeTop / row_height)}; }; - GridStack.prototype.batchUpdate = function() { - this.grid.batchUpdate(); + GridStack.prototype.batch_update = function() { + this.grid.batch_update(); }; GridStack.prototype.commit = function() { this.grid.commit(); - this._updateContainerHeight(); + this._update_container_height(); }; - GridStack.prototype.isAreaEmpty = function(x, y, width, height) { - return this.grid.isAreaEmpty(x, y, width, height); + GridStack.prototype.is_area_empty = function(x, y, width, height) { + return this.grid.is_area_empty(x, y, width, height); }; - GridStack.prototype.setStatic = function(staticValue) { - this.opts.staticGrid = (staticValue === true); - this.enableMove(!staticValue); - this.enableResize(!staticValue); - this._setStaticClass(); + GridStack.prototype.set_static = function(static_value) { + this.opts.static_grid = (static_value === true); + this._set_static_class(); }; - GridStack.prototype._setStaticClass = function() { - var staticClassName = 'grid-stack-static'; + GridStack.prototype._set_static_class = function() { + var static_class_name = 'grid-stack-static'; - if (this.opts.staticGrid === true) { - this.container.addClass(staticClassName); + if (this.opts.static_grid === true) { + this.container.addClass(static_class_name); } else { - this.container.removeClass(staticClassName); + this.container.removeClass(static_class_name); } }; - GridStack.prototype.refreshNodes = function() { + GridStack.prototype.refresh_nodes = function() { var that = this; - this.removeAll(false); + this.remove_all(false); this.container.find('.' + this.opts.item_class).each(function(k, node){ $(node).off('dragstart dragstop drag resizestart resizestop resize'); that.make_widget(node); }); }; - GridStack.prototype.getCellFromAbsolutePixel = function(nodeOffset) { + GridStack.prototype.get_cell_from_absolute_pixel = function(nodeOffset) { var offset = this.container.offset(), position = this.container.position(); @@ -1652,122 +1036,29 @@ top: nodeOffset.top - offset.top + position.top }; - return this.getCellFromPixel(nodeOffset); + return this.get_cell_from_pixel(nodeOffset); }; - GridStack.prototype._updateNodeWidths = function(oldWidth, newWidth) { - this.grid._sortNodes(); - this.grid.batchUpdate(); - var node = {}; - for (var i = 0; i < this.grid.nodes.length; i++) { - node = this.grid.nodes[i]; - this.update(node.el, Math.round(node.x * newWidth / oldWidth), undefined, - Math.round(node.width * newWidth / oldWidth), undefined); - } - this.grid.commit(); - }; - - GridStack.prototype.setGridWidth = function(gridWidth,doNotPropagate) { - this.container.removeClass('grid-stack-' + this.opts.width); - if (doNotPropagate !== true) { - this._updateNodeWidths(this.opts.width, gridWidth); - } - this.opts.width = gridWidth; - this.grid.width = gridWidth; - this.container.addClass('grid-stack-' + gridWidth); - }; - - // jscs:disable requireCamelCaseOrUpperCaseIdentifiers - GridStackEngine.prototype.batch_update = obsolete(GridStackEngine.prototype.batchUpdate); - GridStackEngine.prototype._fix_collisions = obsolete(GridStackEngine.prototype._fixCollisions, - '_fix_collisions', '_fixCollisions'); - GridStackEngine.prototype.is_area_empty = obsolete(GridStackEngine.prototype.isAreaEmpty, - 'is_area_empty', 'isAreaEmpty'); - GridStackEngine.prototype._sort_nodes = obsolete(GridStackEngine.prototype._sortNodes, - '_sort_nodes', '_sortNodes'); - GridStackEngine.prototype._pack_nodes = obsolete(GridStackEngine.prototype._packNodes, - '_pack_nodes', '_packNodes'); - GridStackEngine.prototype._prepare_node = obsolete(GridStackEngine.prototype._prepareNode, - '_prepare_node', '_prepareNode'); - GridStackEngine.prototype.clean_nodes = obsolete(GridStackEngine.prototype.cleanNodes, - 'clean_nodes', 'cleanNodes'); - GridStackEngine.prototype.get_dirty_nodes = obsolete(GridStackEngine.prototype.getDirtyNodes, - 'get_dirty_nodes', 'getDirtyNodes'); - GridStackEngine.prototype.add_node = obsolete(GridStackEngine.prototype.addNode, - 'add_node', 'addNode, '); - GridStackEngine.prototype.remove_node = obsolete(GridStackEngine.prototype.removeNode, - 'remove_node', 'removeNode'); - GridStackEngine.prototype.can_move_node = obsolete(GridStackEngine.prototype.canMoveNode, - 'can_move_node', 'canMoveNode'); - GridStackEngine.prototype.move_node = obsolete(GridStackEngine.prototype.moveNode, - 'move_node', 'moveNode'); - GridStackEngine.prototype.get_grid_height = obsolete(GridStackEngine.prototype.getGridHeight, - 'get_grid_height', 'getGridHeight'); - GridStackEngine.prototype.begin_update = obsolete(GridStackEngine.prototype.beginUpdate, - 'begin_update', 'beginUpdate'); - GridStackEngine.prototype.end_update = obsolete(GridStackEngine.prototype.endUpdate, - 'end_update', 'endUpdate'); - GridStackEngine.prototype.can_be_placed_with_respect_to_height = - obsolete(GridStackEngine.prototype.canBePlacedWithRespectToHeight, - 'can_be_placed_with_respect_to_height', 'canBePlacedWithRespectToHeight'); - GridStack.prototype._trigger_change_event = obsolete(GridStack.prototype._triggerChangeEvent, - '_trigger_change_event', '_triggerChangeEvent'); - GridStack.prototype._init_styles = obsolete(GridStack.prototype._initStyles, - '_init_styles', '_initStyles'); - GridStack.prototype._update_styles = obsolete(GridStack.prototype._updateStyles, - '_update_styles', '_updateStyles'); - GridStack.prototype._update_container_height = obsolete(GridStack.prototype._updateContainerHeight, - '_update_container_height', '_updateContainerHeight'); - GridStack.prototype._is_one_column_mode = obsolete(GridStack.prototype._isOneColumnMode, - '_is_one_column_mode','_isOneColumnMode'); - GridStack.prototype._prepare_element = obsolete(GridStack.prototype._prepareElement, - '_prepare_element', '_prepareElement'); - GridStack.prototype.set_animation = obsolete(GridStack.prototype.setAnimation, - 'set_animation', 'setAnimation'); - GridStack.prototype.add_widget = obsolete(GridStack.prototype.addWidget, - 'add_widget', 'addWidget'); - GridStack.prototype.make_widget = obsolete(GridStack.prototype.makeWidget, - 'make_widget', 'makeWidget'); - GridStack.prototype.will_it_fit = obsolete(GridStack.prototype.willItFit, - 'will_it_fit', 'willItFit'); - GridStack.prototype.remove_widget = obsolete(GridStack.prototype.removeWidget, - 'remove_widget', 'removeWidget'); - GridStack.prototype.remove_all = obsolete(GridStack.prototype.removeAll, - 'remove_all', 'removeAll'); - GridStack.prototype.min_height = obsolete(GridStack.prototype.minHeight, - 'min_height', 'minHeight'); - GridStack.prototype.min_width = obsolete(GridStack.prototype.minWidth, - 'min_width', 'minWidth'); - GridStack.prototype._update_element = obsolete(GridStack.prototype._updateElement, - '_update_element', '_updateElement'); - GridStack.prototype.cell_height = obsolete(GridStack.prototype.cellHeight, - 'cell_height', 'cellHeight'); - GridStack.prototype.cell_width = obsolete(GridStack.prototype.cellWidth, - 'cell_width', 'cellWidth'); - GridStack.prototype.get_cell_from_pixel = obsolete(GridStack.prototype.getCellFromPixel, - 'get_cell_from_pixel', 'getCellFromPixel'); - GridStack.prototype.batch_update = obsolete(GridStack.prototype.batchUpdate, - 'batch_update', 'batchUpdate'); - GridStack.prototype.is_area_empty = obsolete(GridStack.prototype.isAreaEmpty, - 'is_area_empty', 'isAreaEmpty'); - GridStack.prototype.set_static = obsolete(GridStack.prototype.setStatic, - 'set_static', 'setStatic'); - GridStack.prototype._set_static_class = obsolete(GridStack.prototype._setStaticClass, - '_set_static_class', '_setStaticClass'); - // jscs:enable requireCamelCaseOrUpperCaseIdentifiers - scope.GridStackUI = GridStack; scope.GridStackUI.Utils = Utils; - scope.GridStackUI.Engine = GridStackEngine; - scope.GridStackUI.GridStackDragDropPlugin = GridStackDragDropPlugin; + function event_stop_propagate(event) { + event.stopPropagation(); + } $.fn.gridstack = function(opts) { return this.each(function() { var o = $(this); if (!o.data('gridstack')) { o - .data('gridstack', new GridStack(this, opts)); + .data('gridstack', new GridStack(this, opts)) + .on('dragstart', event_stop_propagate) + .on('dragstop', event_stop_propagate) + .on('drag', event_stop_propagate) + .on('resizestart', event_stop_propagate) + .on('resizestop', event_stop_propagate) + .on('resize', event_stop_propagate) + .on('change', event_stop_propagate); } }); }; diff --git a/src/gridstack.scss b/src/gridstack.scss index dbd6bfaa9..46fa37a6b 100644 --- a/src/gridstack.scss +++ b/src/gridstack.scss @@ -16,14 +16,6 @@ $animation_speed: .3s !default; .grid-stack { position: relative; - &.grid-stack-rtl { - direction: ltr; - - > .grid-stack-item { - direction: rtl; - } - } - .grid-stack-placeholder > .placeholder-content { border: 1px dashed lightgray; margin: 0; @@ -79,17 +71,26 @@ $animation_speed: .3s !default; > .ui-resizable-se, > .ui-resizable-sw { - background-image: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iaXNvLTg4NTktMSI/Pgo8IS0tIEdlbmVyYXRvcjogQWRvYmUgSWxsdXN0cmF0b3IgMTYuMC4wLCBTVkcgRXhwb3J0IFBsdWctSW4gLiBTVkcgVmVyc2lvbjogNi4wMCBCdWlsZCAwKSAgLS0+CjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTi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3bDczLjA4OSw3My4wODhjMy42MTcsMy42MTcsNy44OTgsNS40MjQsMTIuODQ3LDUuNDI0YzQuOTUsMCw5LjIzNC0xLjgwNywxMi44NDktNS40MjQgICBsNzMuMDg3LTczLjA4OGMzLjYxMy0zLjYyLDUuNDIxLTcuOTAxLDUuNDIxLTEyLjg0N2MwLTQuOTQ4LTEuODA4LTkuMjMyLTUuNDIxLTEyLjg1NCAgIEMzMzguMTQyLDQwMy44MDIsMzMzLjg1Nyw0MDEuOTk0LDMyOC45MDYsNDAxLjk5NHoiIGZpbGw9IiM2NjY2NjYiLz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8L3N2Zz4K); - background-repeat: no-repeat; - background-position: center; - @include vendor(transform, rotate(45deg)); + text-align: right; + color: gray; + + padding: 2px 3px 0 0; + margin: 0; + + font: normal normal normal 10px/1 FontAwesome; + font-size: inherit; + text-rendering: auto; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + + &::before { content: "\f065"; } } > .ui-resizable-se { - @include vendor(transform, rotate(-45deg)); + display: inline-block; + @include vendor(transform, rotate(90deg)); } - > .ui-resizable-nw { cursor: nw-resize; width: 20px; height: 20px; left: 10px; top: 0; } > .ui-resizable-n { cursor: n-resize; height: 10px; top: 0; left: 25px; right: 25px; } > .ui-resizable-ne { cursor: ne-resize; width: 20px; height: 20px; right: 10px; top: 0; } @@ -99,12 +100,6 @@ $animation_speed: .3s !default; > .ui-resizable-sw { cursor: sw-resize; width: 20px; height: 20px; left: 10px; bottom: 0; } > .ui-resizable-w { cursor: w-resize; width: 10px; left: $horizontal_padding / 2; top: 15px; bottom: 15px; } - &.ui-draggable-dragging { - &> .ui-resizable-handle { - display: none !important; - } - } - @for $i from 1 through $gridstack-columns { &[data-gs-width='#{$i}'] { width: (100% / $gridstack-columns) * $i; } &[data-gs-x='#{$i}'] { left: (100% / $gridstack-columns) * $i; } @@ -123,18 +118,26 @@ $animation_speed: .3s !default; &.grid-stack-animate .grid-stack-item.grid-stack-placeholder{ @include vendor(transition, left .0s, top .0s, height .0s, width .0s); } - - &.grid-stack-one-column-mode { - height: auto !important; - &> .grid-stack-item { - position: relative !important; - width: auto !important; - left: 0 !important; - top: auto !important; - margin-bottom: $vertical_padding; - max-width: none !important; - - &> .ui-resizable-handle { display: none; } - } - } +} + +/** Uncomment this to show bottom-left resize handle **/ +/* +.grid-stack > .grid-stack-item > .ui-resizable-sw { + display: inline-block; + @include vendor(transform, rotate(180deg)); +} +*/ + +@media (max-width: 768px) { + .grid-stack-item { + position: relative !important; + width: auto !important; + left: 0 !important; + top: auto !important; + margin-bottom: $vertical_padding; + + .ui-resizable-handle { display: none; } + } + + .grid-stack { height: auto !important; } } From 7d3b49cb16c377c2e269b68ddc6080ad2081a384 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Inga=20Br=C5=ABnava?= Date: Thu, 24 Nov 2016 10:10:36 +0100 Subject: [PATCH 10/35] Revert "Revert "Merge remote-tracking branch 'troolee/master'"" This reverts commit 05805ebc76a540112af129d9bea04354fa647d61. --- .bithoundrc | 15 + .gitignore | 3 + .jscsrc | 19 + .travis.yml | 31 + Gruntfile.js | 90 +- LICENSE | 3 +- README.md | 524 +++---- bower.json | 8 +- demo/anijs.html | 89 ++ demo/float.html | 19 +- demo/index.html | 20 + demo/knockout.html | 28 +- demo/knockout2.html | 28 +- demo/nested.html | 12 +- demo/responsive.html | 122 ++ demo/rtl.html | 121 ++ demo/serialization.html | 44 +- demo/two.html | 79 +- dist/gridstack.all.js | 41 + dist/gridstack.css | 81 +- dist/gridstack.jQueryUI.js | 97 ++ dist/gridstack.jQueryUI.min.js | 13 + dist/gridstack.js | 1619 ++++++++++++++++------ dist/gridstack.min.css | 2 +- dist/gridstack.min.js | 30 +- dist/gridstack.min.map | 2 +- doc/FAQ.md | 51 + doc/README.md | 474 +++++++ karma.conf.js | 81 ++ package.json | 34 +- protractor.conf.js | 12 + spec/e2e/gridstack-spec.js | 24 + spec/e2e/html/gridstack-with-height.html | 73 + spec/gridstack-engine-spec.js | 311 +++++ spec/gridstack-spec.js | 1269 +++++++++++++++++ spec/utils-spec.js | 109 ++ src/gridstack.jQueryUI.js | 97 ++ src/gridstack.js | 1591 +++++++++++++++------ src/gridstack.scss | 71 +- 39 files changed, 5914 insertions(+), 1423 deletions(-) create mode 100644 .bithoundrc create mode 100644 .jscsrc create mode 100644 .travis.yml mode change 100755 => 100644 Gruntfile.js create mode 100644 demo/anijs.html create mode 100644 demo/index.html create mode 100644 demo/responsive.html create mode 100644 demo/rtl.html create mode 100644 dist/gridstack.all.js create mode 100644 dist/gridstack.jQueryUI.js create mode 100644 dist/gridstack.jQueryUI.min.js mode change 100755 => 100644 dist/gridstack.js create mode 100644 doc/FAQ.md create mode 100644 doc/README.md create mode 100644 karma.conf.js mode change 100755 => 100644 package.json create mode 100644 protractor.conf.js create mode 100644 spec/e2e/gridstack-spec.js create mode 100644 spec/e2e/html/gridstack-with-height.html create mode 100644 spec/gridstack-engine-spec.js create mode 100644 spec/gridstack-spec.js create mode 100644 spec/utils-spec.js create mode 100644 src/gridstack.jQueryUI.js diff --git a/.bithoundrc b/.bithoundrc new file mode 100644 index 000000000..ba1b6655d --- /dev/null +++ b/.bithoundrc @@ -0,0 +1,15 @@ +{ + "ignore": [ + "dist/**", + "**/node_modules/**", + "**/bower_components/**", + "**/demo/**", + "**/coverage/**" + ], + "test": [ + "**/spec/**" + ], + "critics": { + "lint": "jshint" + } +} \ No newline at end of file diff --git a/.gitignore b/.gitignore index 3c3629e64..95ec03ef6 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,4 @@ node_modules +bower_components +coverage +*.log diff --git a/.jscsrc b/.jscsrc new file mode 100644 index 000000000..78a426e4c --- /dev/null +++ b/.jscsrc @@ -0,0 +1,19 @@ +{ + "preset": "node-style-guide", + "validateIndentation": 4, + "maximumLineLength": 120, + "jsDoc": { + "checkAnnotations": { + "preset": "jsdoc3", + "extra": { + "preserve": true + } + } + }, + "requireCamelCaseOrUpperCaseIdentifiers": true, + "validateLineBreaks": false, + "requireTrailingComma": false, + "disallowTrailingWhitespace": true, + "requireCapitalizedComments": false, + "excludeFiles": ["dist/*.js", "demo/*", "spec/*"] +} diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 000000000..f8cde4730 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,31 @@ +language: node_js +node_js: +- 5.7.0 +env: +- CXX=g++-4.8 +addons: + apt: + sources: + - ubuntu-toolchain-r-test + packages: + - g++-4.8 +before_install: +- npm install -g protractor +install: +- npm install -g npm@2 +- npm install -g grunt-cli +- npm install -g bower +- bower install +- npm install +- ./node_modules/protractor/bin/webdriver-manager update --standalone +before_script: +- export CHROME_BIN=chromium-browser +- export DISPLAY=:99.0 +- sh -e /etc/init.d/xvfb start +script: +- npm run build +- npm test +- grunt e2e-test +notifications: + slack: + secure: iGLGsYyVIyKVpVVCskGh/zc6Pkqe0D7jpUtbywSbnq6l5seE6bvBVqm0F2FSCIN+AIC+qal2mPEWysDVsLACm5tTEeA8NfL8dmCrAKbiFbi+gHl4mnHHCHl7ii/7UkoIIXNc5UXbgMSXRS5l8UcsSDlN8VxC5zWstbJvjeYIvbA= diff --git a/Gruntfile.js b/Gruntfile.js old mode 100755 new mode 100644 index f9cc45288..77f58d42e --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1,9 +1,16 @@ -module.exports = function (grunt) { +// jscs:disable requireCamelCaseOrUpperCaseIdentifiers +module.exports = function(grunt) { grunt.loadNpmTasks('grunt-sass'); grunt.loadNpmTasks('grunt-contrib-cssmin'); grunt.loadNpmTasks('grunt-contrib-copy'); grunt.loadNpmTasks('grunt-contrib-uglify'); grunt.loadNpmTasks('grunt-doctoc'); + grunt.loadNpmTasks('grunt-contrib-jshint'); + grunt.loadNpmTasks('grunt-jscs'); + grunt.loadNpmTasks('grunt-contrib-watch'); + grunt.loadNpmTasks('grunt-protractor-runner'); + grunt.loadNpmTasks('grunt-contrib-connect'); + grunt.loadNpmTasks('grunt-protractor-webdriver'); grunt.initConfig({ sass: { @@ -30,7 +37,8 @@ module.exports = function (grunt) { copy: { dist: { files: { - 'dist/gridstack.js': ['src/gridstack.js'] + 'dist/gridstack.js': ['src/gridstack.js'], + 'dist/gridstack.jQueryUI.js': ['src/gridstack.jQueryUI.js'], } } }, @@ -38,11 +46,14 @@ module.exports = function (grunt) { uglify: { options: { sourceMap: true, - sourceMapName: 'dist/gridstack.min.map' + sourceMapName: 'dist/gridstack.min.map', + preserveComments: 'some' }, dist: { files: { - 'dist/gridstack.min.js': ['src/gridstack.js'] + 'dist/gridstack.min.js': ['src/gridstack.js'], + 'dist/gridstack.jQueryUI.min.js': ['src/gridstack.jQueryUI.js'], + 'dist/gridstack.all.js': ['src/gridstack.js', 'src/gridstack.jQueryUI.js'] } } }, @@ -52,10 +63,77 @@ module.exports = function (grunt) { removeAd: false }, readme: { - target: "./README.md" + options: { + target: './README.md' + } + }, + doc: { + options: { + target: './doc/README.md' + } + }, + faq: { + options: { + target: './doc/FAQ.md' + } + }, + }, + + jshint: { + all: ['src/*.js'] + }, + + jscs: { + all: ['*.js', 'src/*.js', ], + }, + + watch: { + scripts: { + files: ['src/*.js'], + tasks: ['uglify', 'copy'], + options: { + }, + }, + styles: { + files: ['src/*.scss'], + tasks: ['sass', 'cssmin'], + options: { + }, + }, + docs: { + files: ['README.md', 'doc/README.md', 'doc/FAQ.md'], + tasks: ['doctoc'], + options: { + }, + }, + }, + + protractor: { + options: { + configFile: 'protractor.conf.js', + }, + all: {} + }, + + connect: { + all: { + options: { + port: 8080, + hostname: 'localhost', + base: '.', + }, + }, + }, + + protractor_webdriver: { + all: { + options: { + command: 'webdriver-manager start', + } } } }); - grunt.registerTask('default', ['sass', 'cssmin', 'copy', 'uglify', 'doctoc']); + grunt.registerTask('default', ['sass', 'cssmin', 'jshint', 'jscs', 'copy', 'uglify', 'doctoc']); + grunt.registerTask('e2e-test', ['connect', 'protractor_webdriver', 'protractor']); }; diff --git a/LICENSE b/LICENSE index bf1cc110e..f337ebad1 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2014-2016 Pavel Reznikov +Copyright (c) 2014-2016 Pavel Reznikov, Dylan Weiss Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -19,4 +19,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - diff --git a/README.md b/README.md index cb3ec4dac..bd409d011 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,16 @@ gridstack.js ============ +[![Build Status](https://travis-ci.org/troolee/gridstack.js.svg?branch=master)](https://travis-ci.org/troolee/gridstack.js) +[![Coverage Status](https://coveralls.io/repos/github/troolee/gridstack.js/badge.svg?branch=master)](https://coveralls.io/github/troolee/gridstack.js?branch=master) +[![Dependency Status](https://david-dm.org/troolee/gridstack.js.svg)](https://david-dm.org/troolee/gridstack.js) +[![devDependency Status](https://david-dm.org/troolee/gridstack.js/dev-status.svg)](https://david-dm.org/troolee/gridstack.js#info=devDependencies) +[![Stories in Ready](https://badge.waffle.io/troolee/gridstack.js.png?label=ready&title=Ready)](http://waffle.io/troolee/gridstack.js) + gridstack.js is a jQuery plugin for widget layout. This is drag-and-drop multi-column grid. It allows you to build -draggable responsive bootstrap v3 friendly layouts. It also works great with [knockout.js](http://knockoutjs.com) and -touch devices. +draggable responsive bootstrap v3 friendly layouts. It also works great with [knockout.js](http://knockoutjs.com), [angular.js](https://angularjs.org) and touch devices. -Inspired by [gridster.js](http://gridster.net). Built with love. +Inspired by [gridster.js](https://github.com/ducksboard/gridster.js). Built with love. Join gridstack.js on Slack: https://gridstackjs.troolee.com @@ -18,45 +23,13 @@ Join gridstack.js on Slack: https://gridstackjs.troolee.com - [Demo](#demo) - [Usage](#usage) - [Requirements](#requirements) + - [Using gridstack.js with jQuery UI](#using-gridstackjs-with-jquery-ui) + - [Install](#install) - [Basic usage](#basic-usage) - - [Options](#options) - - [Grid attributes](#grid-attributes) - - [Item attributes](#item-attributes) - - [Events](#events) - - [onchange(items)](#onchangeitems) - - [ondragstart(event, ui)](#ondragstartevent-ui) - - [ondragstop(event, ui)](#ondragstopevent-ui) - - [onresizestart(event, ui)](#onresizestartevent-ui) - - [onresizestop(event, ui)](#onresizestopevent-ui) - - [disable(event)](#disableevent) - - [enable(event)](#enableevent) - - [API](#api) - - [add_widget(el, x, y, width, height, auto_position)](#add_widgetel-x-y-width-height-auto_position) - - [make_widget(el)](#make_widgetel) - - [batch_update()](#batch_update) - - [cell_height()](#cell_height) - - [cell_height(val)](#cell_heightval) - - [cell_width()](#cell_width) - - [commit()](#commit) - - [destroy()](#destroy) - - [disable()](#disable) - - [enable()](#enable) - - [get_cell_from_pixel(position)](#get_cell_from_pixelposition) - - [is_area_empty(x, y, width, height)](#is_area_emptyx-y-width-height) - - [locked(el, val)](#lockedel-val) - - [min_width(el, val)](#min_widthel-val) - - [min_height(el, val)](#min_heightel-val) - - [movable(el, val)](#movableel-val) - - [move(el, x, y)](#moveel-x-y) - - [remove_widget(el, detach_node)](#remove_widgetel-detach_node) - - [remove_all()](#remove_all) - - [resize(el, width, height)](#resizeel-width-height) - - [resizable(el, val)](#resizableel-val) - - [set_static(static_value)](#set_staticstatic_value) - - [update(el, x, y, width, height)](#updateel-x-y-width-height) - - [will_it_fit(x, y, width, height, auto_position)](#will_it_fitx-y-width-height-auto_position) - - [Utils](#utils) - - [GridStackUI.Utils.sort(nodes[, dir[, width]])](#gridstackuiutilssortnodes-dir-width) + - [Migrating to v0.3.0](#migrating-to-v030) + - [Migrating to v0.2.5](#migrating-to-v025) + - [API Documentation](#api-documentation) + - [Questions and Answers](#questions-and-answers) - [Touch devices support](#touch-devices-support) - [Use with knockout.js](#use-with-knockoutjs) - [Use with angular.js](#use-with-angularjs) @@ -68,9 +41,16 @@ Join gridstack.js on Slack: https://gridstackjs.troolee.com - [Load grid from array](#load-grid-from-array) - [Override resizable/draggable options](#override-resizabledraggable-options) - [IE8 support](#ie8-support) + - [Use with require.js](#use-with-requirejs) - [Nested grids](#nested-grids) + - [Resizing active grid](#resizing-active-grid) + - [Using AniJS](#using-anijs) +- [The Team](#the-team) - [Changes](#changes) - - [v0.2.4 (development version)](#v024-development-version) + - [v0.3.0-dev (Development Version)](#v030-dev-development-version) + - [v0.2.6 (2016-08-17)](#v026-2016-08-17) + - [v0.2.5 (2016-03-02)](#v025-2016-03-02) + - [v0.2.4 (2016-02-15)](#v024-2016-02-15) - [v0.2.3 (2015-06-23)](#v023-2015-06-23) - [v0.2.2 (2014-12-23)](#v022-2014-12-23) - [v0.2.1 (2014-12-09)](#v021-2014-12-09) @@ -84,7 +64,7 @@ Join gridstack.js on Slack: https://gridstackjs.troolee.com Demo ==== -Please visit http://troolee.github.io/gridstack.js/ for demo. +Please visit http://troolee.github.io/gridstack.js/ for demo. Or check out [these example](http://troolee.github.io/gridstack.js/demo/). Usage @@ -92,14 +72,47 @@ Usage ## Requirements -* [lodash.js](https://lodash.com) (>= 3.5.0) -* [jQuery](http://jquery.com) (>= 1.11.0) -* [jQuery UI](http://jqueryui.com) (>= 1.11.0). Minimum required components: Core, Widget, Mouse, Draggable, Resizable -* (Optional) [knockout.js](http://knockoutjs.com) (>= 3.2.0) -* (Optional) [jquery-ui-touch-punch](https://github.com/furf/jquery-ui-touch-punch) for touch-based devices support +* [lodash.js](https://lodash.com) (>= 3.5.0, full build) +* [jQuery](http://jquery.com) (>= 3.1.0) Note: You can still use [underscore.js](http://underscorejs.org) (>= 1.7.0) instead of lodash.js +#### Using gridstack.js with jQuery UI + +* [jQuery UI](http://jqueryui.com) (>= 1.12.0). Minimum required components: Core, Widget, Mouse, Draggable, Resizable +* (Optional) [jquery-ui-touch-punch](https://github.com/furf/jquery-ui-touch-punch) for touch-based devices support + +## Install + +```html + + + +``` + +* Using CDN: + +```html + + +``` + +* Using bower: + +```bash +$ bower install gridstack +``` + +* Using npm: + +[![NPM version](https://img.shields.io/npm/v/gridstack.svg)](https://www.npmjs.com/package/gridstack) + +```bash +$ npm install gridstack +``` + +You can download files from `dist` directory as well. + ## Basic usage ```html @@ -119,329 +132,49 @@ Note: You can still use [underscore.js](http://underscorejs.org) (>= 1.7.0) inst ``` -## Options - -- `always_show_resize_handle` - if `true` the resizing handles are shown even if the user is not hovering over the widget - (default: `false`) -- `animate` - turns animation on (default: `false`) -- `auto` - if `false` gridstack will not initialize existing items (default: `true`) -- `cell_height` - one cell height (default: `60`) -- `draggable` - allows to override jQuery UI draggable options. (default: `{handle: '.grid-stack-item-content', scroll: true, appendTo: 'body'}`) -- `handle` - draggable handle selector (default: `'.grid-stack-item-content'`) -- `handle_class` - draggable handle class (e.g. `'grid-stack-item-content'`). If set `handle` is ignored (default: `null`) -- `height` - maximum rows amount. Default is `0` which means no maximum rows -- `float` - enable floating widgets (default: `false`) See [example](http://troolee.github.io/gridstack.js/demo/float.html) -- `item_class` - widget class (default: `'grid-stack-item'`) -- `min_width` - minimal width. If window width is less, grid will be shown in one-column mode. You need also update your css file (`@media (max-width: 768px) {...}`) with corresponding value (default: `768`) -- `placeholder_class` - class for placeholder (default: `'grid-stack-placeholder'`) -- `placeholder_text` - placeholder default content (default: `''`) -- `resizable` - allows to override jQuery UI resizable options. (default: `{autoHide: true, handles: 'se'}`) -- `static_grid` - makes grid static (default `false`). If true widgets are not movable/resizable. You don't even need jQueryUI draggable/resizable. A CSS class `grid-stack-static` is also added to the container. -- `vertical_margin` - vertical gap size (default: `20`) -- `width` - amount of columns (default: `12`) - -## Grid attributes - -- `data-gs-animate` - turns animation on -- `data-gs-width` - amount of columns -- `data-gs-height` - maximum rows amount. Default is `0` which means no maximum rows. - -## Item attributes - -- `data-gs-x`, `data-gs-y` - element position -- `data-gs-width`, `data-gs-height` - element size -- `data-gs-max-width`, `data-gs-min-width`, `data-gs-max-height`, `data-gs-min-height` - element constraints -- `data-gs-no-resize` - disable element resizing -- `data-gs-no-move` - disable element moving -- `data-gs-auto-position` - tells to ignore `data-gs-x` and `data-gs-y` attributes and to place element to the first - available position -- `data-gs-locked` - the widget will be locked. It means another widget wouldn't be able to move it during dragging or resizing. -The widget can still be dragged or resized. You need to add `data-gs-no-resize` and `data-gs-no-move` attributes -to completely lock the widget. - -## Events - -### onchange(items) - -Occurs when adding/removing widgets or existing widgets change their position/size - -```javascript -var serialize_widget_map = function (items) { - console.log(items); -}; - -$('.grid-stack').on('change', function (e, items) { - serialize_widget_map(items); -}); -``` - -### ondragstart(event, ui) - -```javascript -$('.grid-stack').on('dragstart', function (event, ui) { - var grid = this; - var element = event.target; -}); -``` - -### ondragstop(event, ui) - -```javascript -$('.grid-stack').on('dragstop', function (event, ui) { - var grid = this; - var element = event.target; -}); -``` - -### onresizestart(event, ui) - -```javascript -$('.grid-stack').on('resizestart', function (event, ui) { - var grid = this; - var element = event.target; -}); -``` - -### onresizestop(event, ui) - -```javascript -$('.grid-stack').on('resizestop', function (event, ui) { - var grid = this; - var element = event.target; -}); -``` - -### disable(event) - -```javascipt -$('.grid-stack').on('disable', function(event) { - var grid = event.target; -}); -``` - -### enable(event) - -```javascipt -$('.grid-stack').on('enable', function(event) { - var grid = event.target; -}); -``` - -## API - -### add_widget(el, x, y, width, height, auto_position) - -Creates new widget and returns it. - -Parameters: - -- `el` - widget to add -- `x`, `y`, `width`, `height` - widget position/dimensions (Optional) -- `auto_position` - if `true` then `x`, `y` parameters will be ignored and widget will be places on the first available -position - -Widget will be always placed even if result height is more than actual grid height. You need to use `will_it_fit` method -before calling `add_widget` for additional check. - -```javascript -$('.grid-stack').gridstack(); - -var grid = $('.grid-stack').data('gridstack'); -grid.add_widget(el, 0, 0, 3, 2, true); -``` - -### make_widget(el) - -If you add elements to your gridstack container by hand, you have to tell gridstack afterwards to make them widgets. If you want gridstack to add the elements for you, use `add_widget` instead. -Makes the given element a widget and returns it. - -Parameters: - -- `el` - element to convert to a widget - -```javascript -$('.grid-stack').gridstack(); - -$('.grid-stack').append('
') -var grid = $('.grid-stack').data('gridstack'); -grid.make_widget('gsi-1'); -``` - -### batch_update() - -Initailizes batch updates. You will see no changes until `commit` method is called. - -### cell_height() +## Migrating to v0.3.0 -Gets current cell height. +As of v0.3.0, gridstack introduces a new plugin system. The drag'n'drop functionality has been modified to take advantage of this system. Because of this, and to avoid dependency on core code from jQuery UI, the plugin was functionality was moved to a separate file. -### cell_height(val) +To ensure gridstack continues to work, either include the additional `gridstack.jQueryUI.js` file into your HTML or use `gridstack.all.js`: -Update current cell height. This method rebuilds an internal CSS stylesheet. Note: You can expect performance issues if -call this method too often. - -```javascript -grid.cell_height(grid.cell_width() * 1.2); -``` - -### cell_width() - -Gets current cell width. - -### commit() - -Finishes batch updates. Updates DOM nodes. You must call it after `batch_update`. - -### destroy() - -Destroys a grid instance. - -### disable() - -Disables widgets moving/resizing. This is a shortcut for: - -```javascript -grid.movable('.grid-stack-item', false); -grid.resizable('.grid-stack-item', false); +```html + + ``` -### enable() +or -Enables widgets moving/resizing. This is a shortcut for: - -```javascript -grid.movable('.grid-stack-item', true); -grid.resizable('.grid-stack-item', true); +```html + ``` -### get_cell_from_pixel(position) - -Get the position of the cell under a pixel on screen. - -Parameters : - -- `position` - the position of the pixel to resolve in absolute coordinates, as an object with `top` and `left`properties - -Returns an object with properties `x` and `y` i.e. the column and row in the grid. - -### is_area_empty(x, y, width, height) - -Checks if specified area is empty. - -### locked(el, val) - -Locks/unlocks widget. - -- `el` - widget to modify. -- `val` - if `true` widget will be locked. - -### min_width(el, val) - -Set the minWidth for a widget. - -- `el` - widget to modify. -- `val` - A numeric value of the number of columns - -### min_height(el, val) - -Set the minHeight for a widget. - -- `el` - widget to modify. -- `val` - A numeric value of the number of rows - -### movable(el, val) - -Enables/Disables moving. - -- `el` - widget to modify -- `val` - if `true` widget will be draggable. - -### move(el, x, y) - -Changes widget position - -Parameters: +We're working on implementing support for other drag'n'drop libraries through the new plugin system. -- `el` - widget to move -- `x`, `y` - new position. If value is `null` or `undefined` it will be ignored. +## Migrating to v0.2.5 -### remove_widget(el, detach_node) +As of v0.2.5 all methods and parameters are in camel case to respect [JavaScript Style Guide and Coding Conventions](http://www.w3schools.com/js/js_conventions.asp). +All old methods and parameters are marked as deprecated and still available but a warning will be displayed in js console. They will be available until v1.0 +when they will be completely removed. -Removes widget from the grid. +## API Documentation -Parameters: +Please check out `doc/README.md` for more information about gridstack.js API. -- `el` - widget to remove. -- `detach_node` - if `false` DOM node won't be removed from the tree (Optional. Default `true`). +## Questions and Answers -### remove_all() +Please feel free to as a questions here in issues, using [Stackoverflow](http://stackoverflow.com/search?q=gridstack) or [Slack chat](https://gridstackjs.troolee.com). +We will glad to answer and help you as soon as we can. -Removes all widgets from the grid. - -### resize(el, width, height) - -Changes widget size - -Parameters: - -- `el` - widget to resize -- `width`, `height` - new dimensions. If value is `null` or `undefined` it will be ignored. - -### resizable(el, val) - -Enables/Disables resizing. - -- `el` - widget to modify -- `val` - if `true` widget will be resizable. - -### set_static(static_value) - -Toggle the grid static state. Also toggle the `grid-stack-static` class. - -- `static_value` - if `true` the grid become static. - -### update(el, x, y, width, height) - -Parameters: - -- `el` - widget to move -- `x`, `y` - new position. If value is `null` or `undefined` it will be ignored. -- `width`, `height` - new dimensions. If value is `null` or `undefined` it will be ignored. - -Updates widget position/size. - -### will_it_fit(x, y, width, height, auto_position) - -Returns `true` if the `height` of the grid will be less the vertical constraint. Always returns `true` if grid doesn't -have `height` constraint. - -```javascript -if (grid.will_it_fit(new_node.x, new_node.y, new_node.width, new_node.height, true)) { - grid.add_widget(new_node.el, new_node.x, new_node.y, new_node.width, new_node.height, true); -} -else { - alert('Not enough free space to place the widget'); -} -``` - - -## Utils - -### GridStackUI.Utils.sort(nodes[, dir[, width]]) - -Sorts array of nodes - -- `nodes` - array to sort -- `dir` - `1` for asc, `-1` for desc (optional) -- `width` - width of the grid. If `undefined` the width will be calculated automatically (optional). +Also please check our FAQ `doc/FAQ.md` before asking in case the answer is already there. ## Touch devices support @@ -457,17 +190,19 @@ working on touch-based devices. ``` -Also `always_show_resize_handle` option may be useful: +Also `alwaysShowResizeHandle` option may be useful: ```javascript $(function () { var options = { - always_show_resize_handle: /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) + alwaysShowResizeHandle: /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) }; $('.grid-stack').gridstack(options); }); ``` +If you're still experiencing issues on touch devices please check [#444](https://github.com/troolee/gridstack.js/issues/444) + ## Use with knockout.js ```javascript @@ -487,9 +222,9 @@ ko.components.register('dashboard-grid', { } var item = _.find(items, function (i) { return i.nodeType == 1 }); - grid.add_widget(item); + grid.addWidget(item); ko.utils.domNodeDisposal.addDisposeCallback(item, function () { - grid.remove_widget(item); + grid.removeWidget(item); }); }; }; @@ -500,7 +235,7 @@ ko.components.register('dashboard-grid', { template: [ '
', - '
', + '
', '
...
', '
', '
' @@ -533,11 +268,11 @@ See examples: [example 1](http://troolee.github.io/gridstack.js/demo/knockout.ht **Notes:** It's very important to exclude training spaces after widget template: -``` +```javascript template: [ '
', - '
', + '
', ' ....', '
', // <-- NO SPACE **AFTER**
'
' // <-- NO SPACE **BEFORE**
@@ -665,10 +400,10 @@ var serialization = [ serialization = GridStackUI.Utils.sort(serialization); var grid = $('.grid-stack').data('gridstack'); -grid.remove_all(); +grid.removeAll(); _.each(serialization, function (node) { - grid.add_widget($('
'), + grid.addWidget($('
'), node.x, node.y, node.width, node.height); }); ``` @@ -737,6 +472,12 @@ for i in range(N): There are at least two more issues with gridstack in IE8 with jQueryUI resizable (it seems it doesn't work) and droppable. If you have any suggestions about support of IE8 you are welcome here: https://github.com/troolee/gridstack.js/issues/76 +## Use with require.js + +If you're using require.js and a single file jQueryUI please check out this +[Stackoverflow question](http://stackoverflow.com/questions/35582945/redundant-dependencies-with-requirejs) to get it +working properly. + ## Nested grids @@ -745,16 +486,77 @@ during initialization. See example: [Nested grid demo](http://troolee.github.io/gridstack.js/demo/nested.html) +## Resizing active grid + +Resizing on-the-fly is possible, though experimental. This may be used to make gridstack responsive. gridstack will change the total number of columns and will attempt to update the width and x values of each widget to be more logical. +See example: [Responsive grid demo](http://troolee.github.io/gridstack.js/demo/responsive.html) + +## Using AniJS + +Using AniJS with gridstack is a breeze. In the following example, a listener is added that gets triggered by a widget being added. +See widgets wiggle! [AniJS demo](http://troolee.github.io/gridstack.js/demo/anijs.html) + +The Team +======== + +gridstack.js is currently maintained by [Pavel Reznikov](https://github.com/troolee), [Dylan Weiss](https://github.com/radiolips) +and [Kevin Dietrich](https://github.com/kdietrich). And we appreciate [all contributors](https://github.com/troolee/gridstack.js/graphs/contributors) +for help. + + Changes ======= -#### v0.2.4 (development version) +#### v0.3.0-dev (Development Version) + +- add oneColumnModeClass option to grid. +- remove 768px CSS styles, moved to grid-stack-one-column-mode class. +- add max-width override on grid-stck-one-column-mode ([#462](https://github.com/troolee/gridstack.js/issues/462)). +- add internal function`isNodeChangedPosition`, minor optimization to move/drag. +- drag'n'drop plugin system. Move jQuery UI dependencies to separate plugin file. + +#### v0.2.6 (2016-08-17) + +- update requirements to the latest versions of jQuery (v3.1.0+) and jquery-ui (v1.12.0+). +- fix jQuery `size()` ([#486](https://github.com/troolee/gridstack.js/issues/486)). +- update `destroy([detachGrid])` call ([#422](https://github.com/troolee/gridstack.js/issues/422)). +- don't mutate options when calling `draggable` and `resizable`. ([#505](https://github.com/troolee/gridstack.js/issues/505)). +- update _notify to allow detach ([#411](https://github.com/troolee/gridstack.js/issues/411)). +- fix code that checks for jquery-ui ([#481](https://github.com/troolee/gridstack.js/issues/481)). +- fix `cellWidth` calculation on empty grid + +#### v0.2.5 (2016-03-02) + +- update names to respect js naming convention. +- `cellHeight` and `verticalMargin` can now be string (e.g. '3em', '20px') (Thanks to @jlowcs). +- add `maxWidth`/`maxHeight` methods. +- add `enableMove`/`enableResize` methods. +- fix window resize issue #331. +- add options `disableDrag` and `disableResize`. +- fix `batchUpdate`/`commit` (Thank to @radiolips) +- remove dependency of FontAwesome +- RTL support +- `'auto'` value for `cellHeight` option +- fix `setStatic` method +- add `setAnimation` method to API +- add `setGridWidth` method ([#227](https://github.com/troolee/gridstack.js/issues/227)) +- add `removable`/`removeTimeout` *(experimental)* +- add `detachGrid` parameter to `destroy` method ([#216](https://github.com/troolee/gridstack.js/issues/216)) (thanks @jhpedemonte) +- add `useOffset` parameter to `getCellFromPixel` method ([#237](https://github.com/troolee/gridstack.js/issues/237)) +- add `minWidth`, `maxWidth`, `minHeight`, `maxHeight`, `id` parameters to `addWidget` ([#188](https://github.com/troolee/gridstack.js/issues/188)) +- add `added` and `removed` events for when a widget is added or removed, respectively. ([#54](https://github.com/troolee/gridstack.js/issues/54)) +- add `acceptWidgets` parameter. Widgets can now be draggable between grids or from outside *(experimental)* + +#### v0.2.4 (2016-02-15) - fix closure compiler/linter warnings - add `static_grid` option. - add `min_width`/`min_height` methods (Thanks to @cvillemure) - add `destroy` method (Thanks to @zspitzer) - add `placeholder_text` option (Thanks to @slauyama) +- add `handle_class` option. +- add `make_widget` method. +- lodash v 4.x support (Thanks to @andrewr88) #### v0.2.3 (2015-06-23) @@ -813,7 +615,7 @@ License The MIT License (MIT) -Copyright (c) 2014-2016 Pavel Reznikov +Copyright (c) 2014-2016 Pavel Reznikov, Dylan Weiss Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/bower.json b/bower.json index 4428d538a..37e390b63 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "gridstack", - "version": "0.2.3", + "version": "0.3.0-dev", "homepage": "https://github.com/troolee/gridstack.js", "authors": [ "Pavel Reznikov " @@ -14,9 +14,9 @@ "amd" ], "dependencies": { - "lodash": ">= 3.5.0", - "jquery": ">= 1.11.0", - "jquery-ui": ">= 1.11.0" + "lodash": ">= 4.14.2", + "jquery": ">= 3.1.0", + "jquery-ui": ">= 1.12.0" }, "keywords": [ "gridstack", diff --git a/demo/anijs.html b/demo/anijs.html new file mode 100644 index 000000000..6d66b428c --- /dev/null +++ b/demo/anijs.html @@ -0,0 +1,89 @@ + + + + + + + + + Codestin Search App + + + + + + + + + + + + + + + + +
+

AniJS demo

+ + + +
+

Widget added

+
+ +
+ +
+
+
+ + + + + \ No newline at end of file diff --git a/demo/float.html b/demo/float.html index 638ec2a74..e1a968db8 100644 --- a/demo/float.html +++ b/demo/float.html @@ -10,15 +10,15 @@ Codestin Search App - - + - - - - + + + + + + + +
+
+
+
+
+
+

Responsive grid demo

+ +
+ Number of Columns: +
+ +
+ +
+
+
+ + + + + diff --git a/demo/rtl.html b/demo/rtl.html new file mode 100644 index 000000000..0f27dafd0 --- /dev/null +++ b/demo/rtl.html @@ -0,0 +1,121 @@ + + + + + + + + + Codestin Search App + + + + + + + + + + + + + + + +
+

RTL Demo

+ +
+ +
+ +
+ +
+
+ + + + + diff --git a/demo/serialization.html b/demo/serialization.html index 06ddbc620..a58e847c1 100644 --- a/demo/serialization.html +++ b/demo/serialization.html @@ -10,15 +10,15 @@ Codestin Search App - - + - - - - + + + + +

Two grids demo

+
+
+ +
+
+
+
+
+
+
@@ -58,10 +107,15 @@

Two grids demo

$(function () { var options = { width: 6, - float: true + float: false, + removable: '.trash', + removeTimeout: 100, + acceptWidgets: '.grid-stack-item' }; $('#grid1').gridstack(options); - $('#grid2').gridstack(options); + $('#grid2').gridstack(_.defaults({ + float: true + }, options)); var items = [ {x: 0, y: 0, width: 2, height: 2}, @@ -75,10 +129,17 @@

Two grids demo

var grid = $(this).data('gridstack'); _.each(items, function (node) { - grid.add_widget($('
'), + grid.addWidget($('
'), node.x, node.y, node.width, node.height); }, this); }); + + $('.sidebar .grid-stack-item').draggable({ + revert: 'invalid', + handle: '.grid-stack-item-content', + scroll: false, + appendTo: 'body' + }); }); diff --git a/dist/gridstack.all.js b/dist/gridstack.all.js new file mode 100644 index 000000000..d8165226b --- /dev/null +++ b/dist/gridstack.all.js @@ -0,0 +1,41 @@ +/** + * gridstack.js 0.3.0-dev + * http://troolee.github.io/gridstack.js/ + * (c) 2014-2016 Pavel Reznikov, Dylan Weiss + * gridstack.js may be freely distributed under the MIT license. + * @preserve +*/ +!function(a){if("function"==typeof define&&define.amd)define(["jquery","lodash"],a);else if("undefined"!=typeof exports){try{jQuery=require("jquery")}catch(a){}try{_=require("lodash")}catch(a){}a(jQuery,_)}else a(jQuery,_)}(function(a,b){ +// jscs:enable requireCamelCaseOrUpperCaseIdentifiers +/** + * @class GridStackDragDropPlugin + * Base class for drag'n'drop plugin. + */ +function c(a){this.grid=a}var d=window,e=function(a,b,c){var d=function(){return console.warn("gridstack.js: Function `"+b+"` is deprecated as of v0.2.5 and has been replaced with `"+c+"`. It will be **completely** removed in v1.0."),a.apply(this,arguments)};return d.prototype=a.prototype,d},f=function(a,b){console.warn("gridstack.js: Option `"+a+"` is deprecated as of v0.2.5 and has been replaced with `"+b+"`. It will be **completely** removed in v1.0.")},g={isIntercepted:function(a,b){return!(a.x+a.width<=b.x||b.x+b.width<=a.x||a.y+a.height<=b.y||b.y+b.height<=a.y)},sort:function(a,c,d){return d=d||b.chain(a).map(function(a){return a.x+a.width}).max().value(),c=c!=-1?1:-1,b.sortBy(a,function(a){return c*(a.x+a.y*d)})},createStylesheet:function(a){var b=document.createElement("style");return b.setAttribute("type","text/css"),b.setAttribute("data-gs-style-id",a),b.styleSheet?b.styleSheet.cssText="":b.appendChild(document.createTextNode("")),document.getElementsByTagName("head")[0].appendChild(b),b.sheet},removeStylesheet:function(b){a("STYLE[data-gs-style-id="+b+"]").remove()},insertCSSRule:function(a,b,c,d){"function"==typeof a.insertRule?a.insertRule(b+"{"+c+"}",d):"function"==typeof a.addRule&&a.addRule(b,c,d)},toBool:function(a){return"boolean"==typeof a?a:"string"==typeof a?(a=a.toLowerCase(),!(""===a||"no"==a||"false"==a||"0"==a)):Boolean(a)},_collisionNodeCheck:function(a){return a!=this.node&&g.isIntercepted(a,this.nn)},_didCollide:function(a){return g.isIntercepted({x:this.n.x,y:this.newY,width:this.n.width,height:this.n.height},a)},_isAddNodeIntercepted:function(a){return g.isIntercepted({x:this.x,y:this.y,width:this.node.width,height:this.node.height},a)},parseHeight:function(a){var c=a,d="px";if(c&&b.isString(c)){var e=c.match(/^(-[0-9]+\.[0-9]+|[0-9]*\.[0-9]+|-[0-9]+|[0-9]+)(px|em|rem|vh|vw)?$/);if(!e)throw new Error("Invalid height");d=e[2]||"px",c=parseFloat(e[1])}return{height:c,unit:d}}}; +// jscs:disable requireCamelCaseOrUpperCaseIdentifiers +g.is_intercepted=e(g.isIntercepted,"is_intercepted","isIntercepted"),g.create_stylesheet=e(g.createStylesheet,"create_stylesheet","createStylesheet"),g.remove_stylesheet=e(g.removeStylesheet,"remove_stylesheet","removeStylesheet"),g.insert_css_rule=e(g.insertCSSRule,"insert_css_rule","insertCSSRule"),c.registeredPlugins=[],c.registerPlugin=function(a){c.registeredPlugins.push(a)},c.prototype.resizable=function(a,b){return this},c.prototype.draggable=function(a,b){return this},c.prototype.droppable=function(a,b){return this},c.prototype.isDroppable=function(a){return!1},c.prototype.on=function(a,b,c){return this};var h=0,i=function(a,b,c,d,e){this.width=a,this.float=c||!1,this.height=d||0,this.nodes=e||[],this.onchange=b||function(){},this._updateCounter=0,this._float=this.float,this._addedNodes=[],this._removedNodes=[]};i.prototype.batchUpdate=function(){this._updateCounter=1,this.float=!0},i.prototype.commit=function(){0!==this._updateCounter&&(this._updateCounter=0,this.float=this._float,this._packNodes(),this._notify())}, +// For Meteor support: https://github.com/troolee/gridstack.js/pull/272 +i.prototype.getNodeDataByDOMEl=function(a){return b.find(this.nodes,function(b){return a.get(0)===b.el.get(0)})},i.prototype._fixCollisions=function(a){this._sortNodes(-1);var c=a,d=Boolean(b.find(this.nodes,function(a){return a.locked}));for(this.float||d||(c={x:0,y:a.y,width:this.width,height:a.height});;){var e=b.find(this.nodes,b.bind(g._collisionNodeCheck,{node:a,nn:c}));if("undefined"==typeof e)return;this.moveNode(e,e.x,a.y+a.height,e.width,e.height,!0)}},i.prototype.isAreaEmpty=function(a,c,d,e){var f={x:a||0,y:c||0,width:d||1,height:e||1},h=b.find(this.nodes,b.bind(function(a){return g.isIntercepted(a,f)},this));return null===h||"undefined"==typeof h},i.prototype._sortNodes=function(a){this.nodes=g.sort(this.nodes,a,this.width)},i.prototype._packNodes=function(){this._sortNodes(),this.float?b.each(this.nodes,b.bind(function(a,c){if(!a._updating&&"undefined"!=typeof a._origY&&a.y!=a._origY)for(var d=a.y;d>=a._origY;){var e=b.chain(this.nodes).find(b.bind(g._didCollide,{n:a,newY:d})).value();e||(a._dirty=!0,a.y=d),--d}},this)):b.each(this.nodes,b.bind(function(a,c){if(!a.locked)for(;a.y>0;){var d=a.y-1,e=0===c;if(c>0){var f=b.chain(this.nodes).take(c).find(b.bind(g._didCollide,{n:a,newY:d})).value();e="undefined"==typeof f}if(!e)break;a._dirty=a.y!=d,a.y=d}},this))},i.prototype._prepareNode=function(a,c){return a=b.defaults(a||{},{width:1,height:1,x:0,y:0}),a.x=parseInt(""+a.x),a.y=parseInt(""+a.y),a.width=parseInt(""+a.width),a.height=parseInt(""+a.height),a.autoPosition=a.autoPosition||!1,a.noResize=a.noResize||!1,a.noMove=a.noMove||!1,a.width>this.width?a.width=this.width:a.width<1&&(a.width=1),a.height<1&&(a.height=1),a.x<0&&(a.x=0),a.x+a.width>this.width&&(c?a.width=this.width-a.x:a.x=this.width-a.width),a.y<0&&(a.y=0),a},i.prototype._notify=function(){var a=Array.prototype.slice.call(arguments,0);if(a[0]="undefined"==typeof a[0]?[]:[a[0]],a[1]="undefined"==typeof a[1]||a[1],!this._updateCounter){var b=a[0].concat(this.getDirtyNodes());this.onchange(b,a[1])}},i.prototype.cleanNodes=function(){this._updateCounter||b.each(this.nodes,function(a){a._dirty=!1})},i.prototype.getDirtyNodes=function(){return b.filter(this.nodes,function(a){return a._dirty})},i.prototype.addNode=function(a,c){if(a=this._prepareNode(a),"undefined"!=typeof a.maxWidth&&(a.width=Math.min(a.width,a.maxWidth)),"undefined"!=typeof a.maxHeight&&(a.height=Math.min(a.height,a.maxHeight)),"undefined"!=typeof a.minWidth&&(a.width=Math.max(a.width,a.minWidth)),"undefined"!=typeof a.minHeight&&(a.height=Math.max(a.height,a.minHeight)),a._id=++h,a._dirty=!0,a.autoPosition){this._sortNodes();for(var d=0;;++d){var e=d%this.width,f=Math.floor(d/this.width);if(!(e+a.width>this.width||b.find(this.nodes,b.bind(g._isAddNodeIntercepted,{x:e,y:f,node:a})))){a.x=e,a.y=f;break}}}return this.nodes.push(a),"undefined"!=typeof c&&c&&this._addedNodes.push(b.clone(a)),this._fixCollisions(a),this._packNodes(),this._notify(),a},i.prototype.removeNode=function(a,c){c="undefined"==typeof c||c,this._removedNodes.push(b.clone(a)),a._id=null,this.nodes=b.without(this.nodes,a),this._packNodes(),this._notify(a,c)},i.prototype.canMoveNode=function(c,d,e,f,g){if(!this.isNodeChangedPosition(c,d,e,f,g))return!1;var h=Boolean(b.find(this.nodes,function(a){return a.locked}));if(!this.height&&!h)return!0;var j,k=new i(this.width,null,this.float,0,b.map(this.nodes,function(b){return b==c?j=a.extend({},b):a.extend({},b)}));if("undefined"==typeof j)return!0;k.moveNode(j,d,e,f,g);var l=!0;return h&&(l&=!Boolean(b.find(k.nodes,function(a){return a!=j&&Boolean(a.locked)&&Boolean(a._dirty)}))),this.height&&(l&=k.getGridHeight()<=this.height),l},i.prototype.canBePlacedWithRespectToHeight=function(c){if(!this.height)return!0;var d=new i(this.width,null,this.float,0,b.map(this.nodes,function(b){return a.extend({},b)}));return d.addNode(c),d.getGridHeight()<=this.height},i.prototype.isNodeChangedPosition=function(a,b,c,d,e){return"number"!=typeof b&&(b=a.x),"number"!=typeof c&&(c=a.y),"number"!=typeof d&&(d=a.width),"number"!=typeof e&&(e=a.height),"undefined"!=typeof a.maxWidth&&(d=Math.min(d,a.maxWidth)),"undefined"!=typeof a.maxHeight&&(e=Math.min(e,a.maxHeight)),"undefined"!=typeof a.minWidth&&(d=Math.max(d,a.minWidth)),"undefined"!=typeof a.minHeight&&(e=Math.max(e,a.minHeight)),a.x!=b||a.y!=c||a.width!=d||a.height!=e},i.prototype.moveNode=function(a,b,c,d,e,f){if(!this.isNodeChangedPosition(a,b,c,d,e))return a;if("number"!=typeof b&&(b=a.x),"number"!=typeof c&&(c=a.y),"number"!=typeof d&&(d=a.width),"number"!=typeof e&&(e=a.height),"undefined"!=typeof a.maxWidth&&(d=Math.min(d,a.maxWidth)),"undefined"!=typeof a.maxHeight&&(e=Math.min(e,a.maxHeight)),"undefined"!=typeof a.minWidth&&(d=Math.max(d,a.minWidth)),"undefined"!=typeof a.minHeight&&(e=Math.max(e,a.minHeight)),a.x==b&&a.y==c&&a.width==d&&a.height==e)return a;var g=a.width!=d;return a._dirty=!0,a.x=b,a.y=c,a.width=d,a.height=e,a.lastTriedX=b,a.lastTriedY=c,a.lastTriedWidth=d,a.lastTriedHeight=e,a=this._prepareNode(a,g),this._fixCollisions(a),f||(this._packNodes(),this._notify()),a},i.prototype.getGridHeight=function(){return b.reduce(this.nodes,function(a,b){return Math.max(a,b.y+b.height)},0)},i.prototype.beginUpdate=function(a){b.each(this.nodes,function(a){a._origY=a.y}),a._updating=!0},i.prototype.endUpdate=function(){b.each(this.nodes,function(a){a._origY=a.y});var a=b.find(this.nodes,function(a){return a._updating});a&&(a._updating=!1)};var j=function(d,e){var g,h,j=this;e=e||{},this.container=a(d), +// jscs:disable requireCamelCaseOrUpperCaseIdentifiers +"undefined"!=typeof e.handle_class&&(e.handleClass=e.handle_class,f("handle_class","handleClass")),"undefined"!=typeof e.item_class&&(e.itemClass=e.item_class,f("item_class","itemClass")),"undefined"!=typeof e.placeholder_class&&(e.placeholderClass=e.placeholder_class,f("placeholder_class","placeholderClass")),"undefined"!=typeof e.placeholder_text&&(e.placeholderText=e.placeholder_text,f("placeholder_text","placeholderText")),"undefined"!=typeof e.cell_height&&(e.cellHeight=e.cell_height,f("cell_height","cellHeight")),"undefined"!=typeof e.vertical_margin&&(e.verticalMargin=e.vertical_margin,f("vertical_margin","verticalMargin")),"undefined"!=typeof e.min_width&&(e.minWidth=e.min_width,f("min_width","minWidth")),"undefined"!=typeof e.static_grid&&(e.staticGrid=e.static_grid,f("static_grid","staticGrid")),"undefined"!=typeof e.is_nested&&(e.isNested=e.is_nested,f("is_nested","isNested")),"undefined"!=typeof e.always_show_resize_handle&&(e.alwaysShowResizeHandle=e.always_show_resize_handle,f("always_show_resize_handle","alwaysShowResizeHandle")), +// jscs:enable requireCamelCaseOrUpperCaseIdentifiers +e.itemClass=e.itemClass||"grid-stack-item";var k=this.container.closest("."+e.itemClass).length>0;if(this.opts=b.defaults(e||{},{width:parseInt(this.container.attr("data-gs-width"))||12,height:parseInt(this.container.attr("data-gs-height"))||0,itemClass:"grid-stack-item",placeholderClass:"grid-stack-placeholder",placeholderText:"",handle:".grid-stack-item-content",handleClass:null,cellHeight:60,verticalMargin:20,auto:!0,minWidth:768,float:!1,staticGrid:!1,_class:"grid-stack-instance-"+(1e4*Math.random()).toFixed(0),animate:Boolean(this.container.attr("data-gs-animate"))||!1,alwaysShowResizeHandle:e.alwaysShowResizeHandle||!1,resizable:b.defaults(e.resizable||{},{autoHide:!e.alwaysShowResizeHandle,handles:"se"}),draggable:b.defaults(e.draggable||{},{handle:(e.handleClass?"."+e.handleClass:e.handle?e.handle:"")||".grid-stack-item-content",scroll:!1,appendTo:"body"}),disableDrag:e.disableDrag||!1,disableResize:e.disableResize||!1,rtl:"auto",removable:!1,removeTimeout:2e3,verticalMarginUnit:"px",cellHeightUnit:"px",oneColumnModeClass:e.oneColumnModeClass||"grid-stack-one-column-mode",ddPlugin:null}),this.opts.ddPlugin===!1?this.opts.ddPlugin=c:null===this.opts.ddPlugin&&(this.opts.ddPlugin=b.first(c.registeredPlugins)||c),this.dd=new this.opts.ddPlugin(this),"auto"===this.opts.rtl&&(this.opts.rtl="rtl"===this.container.css("direction")),this.opts.rtl&&this.container.addClass("grid-stack-rtl"),this.opts.isNested=k,h="auto"===this.opts.cellHeight,h?j.cellHeight(j.cellWidth(),!0):this.cellHeight(this.opts.cellHeight,!0),this.verticalMargin(this.opts.verticalMargin,!0),this.container.addClass(this.opts._class),this._setStaticClass(),k&&this.container.addClass("grid-stack-nested"),this._initStyles(),this.grid=new i(this.opts.width,function(a,c){c="undefined"==typeof c||c;var d=0;b.each(a,function(a){c&&null===a._id?a.el&&a.el.remove():(a.el.attr("data-gs-x",a.x).attr("data-gs-y",a.y).attr("data-gs-width",a.width).attr("data-gs-height",a.height),d=Math.max(d,a.y+a.height))}),j._updateStyles(d+10)},this.opts.float,this.opts.height),this.opts.auto){var l=[],m=this;this.container.children("."+this.opts.itemClass+":not(."+this.opts.placeholderClass+")").each(function(b,c){c=a(c),l.push({el:c,i:parseInt(c.attr("data-gs-x"))+parseInt(c.attr("data-gs-y"))*m.opts.width})}),b.chain(l).sortBy(function(a){return a.i}).each(function(a){j._prepareElement(a.el)}).value()}if(this.setAnimation(this.opts.animate),this.placeholder=a('
'+this.opts.placeholderText+"
").hide(),this._updateContainerHeight(),this._updateHeightsOnResize=b.throttle(function(){j.cellHeight(j.cellWidth(),!1)},100),this.onResizeHandler=function(){if(h&&j._updateHeightsOnResize(),j._isOneColumnMode()){if(g)return;j.container.addClass(j.opts.oneColumnModeClass),g=!0,j.grid._sortNodes(),b.each(j.grid.nodes,function(a){j.container.append(a.el),j.opts.staticGrid||((a.noMove||j.opts.disableDrag)&&j.dd.draggable(a.el,"disable"),(a.noResize||j.opts.disableResize)&&j.dd.resizable(a.el,"disable"),a.el.trigger("resize"))})}else{if(!g)return;if(j.container.removeClass(j.opts.oneColumnModeClass),g=!1,j.opts.staticGrid)return;b.each(j.grid.nodes,function(a){a.noMove||j.opts.disableDrag||j.dd.draggable(a.el,"enable"),a.noResize||j.opts.disableResize||j.dd.resizable(a.el,"enable"),a.el.trigger("resize")})}},a(window).resize(this.onResizeHandler),this.onResizeHandler(),!j.opts.staticGrid&&"string"==typeof j.opts.removable){var n=a(j.opts.removable);this.dd.isDroppable(n)||this.dd.droppable(n,{accept:"."+j.opts.itemClass}),this.dd.on(n,"dropover",function(b,c){var d=a(c.draggable),e=d.data("_gridstack_node");e._grid===j&&j._setupRemovingTimeout(d)}).on(n,"dropout",function(b,c){var d=a(c.draggable),e=d.data("_gridstack_node");e._grid===j&&j._clearRemovingTimeout(d)})}if(!j.opts.staticGrid&&j.opts.acceptWidgets){var o=null,p=function(a,b){var c=o,d=c.data("_gridstack_node"),e=j.getCellFromPixel(b.offset,!0),f=Math.max(0,e.x),g=Math.max(0,e.y);if(d._added){if(!j.grid.canMoveNode(d,f,g))return;j.grid.moveNode(d,f,g),j._updateContainerHeight()}else d._added=!0,d.el=c,d.x=f,d.y=g,j.grid.cleanNodes(),j.grid.beginUpdate(d),j.grid.addNode(d),j.container.append(j.placeholder),j.placeholder.attr("data-gs-x",d.x).attr("data-gs-y",d.y).attr("data-gs-width",d.width).attr("data-gs-height",d.height).show(),d.el=j.placeholder,d._beforeDragX=d.x,d._beforeDragY=d.y,j._updateContainerHeight()};this.dd.droppable(j.container,{accept:function(b){b=a(b);var c=b.data("_gridstack_node");return(!c||c._grid!==j)&&b.is(j.opts.acceptWidgets===!0?".grid-stack-item":j.opts.acceptWidgets)}}).on(j.container,"dropover",function(b,c){var d=(j.container.offset(),a(c.draggable)),e=j.cellWidth(),f=j.cellHeight(),g=d.data("_gridstack_node"),h=g?g.width:Math.ceil(d.outerWidth()/e),i=g?g.height:Math.ceil(d.outerHeight()/f);o=d;var k=j.grid._prepareNode({width:h,height:i,_added:!1,_temporary:!0});d.data("_gridstack_node",k),d.data("_gridstack_node_orig",g),d.on("drag",p)}).on(j.container,"dropout",function(b,c){var d=a(c.draggable);d.unbind("drag",p);var e=d.data("_gridstack_node");e.el=null,j.grid.removeNode(e),j.placeholder.detach(),j._updateContainerHeight(),d.data("_gridstack_node",d.data("_gridstack_node_orig"))}).on(j.container,"drop",function(b,c){j.placeholder.detach();var d=a(c.draggable).data("_gridstack_node");d._grid=j;var e=a(c.draggable).clone(!1);e.data("_gridstack_node",d),a(c.draggable).remove(),d.el=e,j.placeholder.hide(),e.attr("data-gs-x",d.x).attr("data-gs-y",d.y).attr("data-gs-width",d.width).attr("data-gs-height",d.height).addClass(j.opts.itemClass).removeAttr("style").enableSelection().removeData("draggable").removeClass("ui-draggable ui-draggable-dragging ui-draggable-disabled").unbind("drag",p),j.container.append(e),j._prepareElementsByNode(e,d),j._updateContainerHeight(),j._triggerChangeEvent(),j.grid.endUpdate()})}}; +// jscs:disable requireCamelCaseOrUpperCaseIdentifiers +// jscs:enable requireCamelCaseOrUpperCaseIdentifiers +return j.prototype._triggerChangeEvent=function(a){var b=this.grid.getDirtyNodes(),c=!1,d=[];b&&b.length&&(d.push(b),c=!0),(c||a===!0)&&this.container.trigger("change",d)},j.prototype._triggerAddEvent=function(){this.grid._addedNodes&&this.grid._addedNodes.length>0&&(this.container.trigger("added",[b.map(this.grid._addedNodes,b.clone)]),this.grid._addedNodes=[])},j.prototype._triggerRemoveEvent=function(){this.grid._removedNodes&&this.grid._removedNodes.length>0&&(this.container.trigger("removed",[b.map(this.grid._removedNodes,b.clone)]),this.grid._removedNodes=[])},j.prototype._initStyles=function(){this._stylesId&&g.removeStylesheet(this._stylesId),this._stylesId="gridstack-style-"+(1e5*Math.random()).toFixed(),this._styles=g.createStylesheet(this._stylesId),null!==this._styles&&(this._styles._max=0)},j.prototype._updateStyles=function(a){if(null!==this._styles&&"undefined"!=typeof this._styles){var b,c="."+this.opts._class+" ."+this.opts.itemClass,d=this;if("undefined"==typeof a&&(a=this._styles._max,this._initStyles(),this._updateContainerHeight()),this.opts.cellHeight&&!(0!==this._styles._max&&a<=this._styles._max)&&(b=this.opts.verticalMargin&&this.opts.cellHeightUnit!==this.opts.verticalMarginUnit?function(a,b){return a&&b?"calc("+(d.opts.cellHeight*a+d.opts.cellHeightUnit)+" + "+(d.opts.verticalMargin*b+d.opts.verticalMarginUnit)+")":d.opts.cellHeight*a+d.opts.verticalMargin*b+d.opts.cellHeightUnit}:function(a,b){return d.opts.cellHeight*a+d.opts.verticalMargin*b+d.opts.cellHeightUnit},0===this._styles._max&&g.insertCSSRule(this._styles,c,"min-height: "+b(1,0)+";",0),a>this._styles._max)){for(var e=this._styles._max;e=f.grid.width||k<0?(f.opts.removable===!0&&f._setupRemovingTimeout(b),j=c._beforeDragX,k=c._beforeDragY,f.placeholder.detach(),f.placeholder.hide(),f.grid.removeNode(c),f._updateContainerHeight(),c._temporaryRemoved=!0):(f._clearRemovingTimeout(b),c._temporaryRemoved&&(f.grid.addNode(c),f.placeholder.attr("data-gs-x",j).attr("data-gs-y",k).attr("data-gs-width",h).attr("data-gs-height",i).show(),f.container.append(f.placeholder),c.el=f.placeholder,c._temporaryRemoved=!1));else if("resize"==a.type&&j<0)return; +// width and height are undefined if not resizing +var l="undefined"!=typeof h?h:c.lastTriedWidth,m="undefined"!=typeof i?i:c.lastTriedHeight;!f.grid.canMoveNode(c,j,k,h,i)||c.lastTriedX===j&&c.lastTriedY===k&&c.lastTriedWidth===l&&c.lastTriedHeight===m||(c.lastTriedX=j,c.lastTriedY=k,c.lastTriedWidth=h,c.lastTriedHeight=i,f.grid.moveNode(c,j,k,h,i),f._updateContainerHeight())},h=function(g,h){f.container.append(f.placeholder);var i=a(this);f.grid.cleanNodes(),f.grid.beginUpdate(c),d=f.cellWidth();var j=Math.ceil(i.outerHeight()/i.attr("data-gs-height"));e=f.container.height()/parseInt(f.container.attr("data-gs-current-height")),f.placeholder.attr("data-gs-x",i.attr("data-gs-x")).attr("data-gs-y",i.attr("data-gs-y")).attr("data-gs-width",i.attr("data-gs-width")).attr("data-gs-height",i.attr("data-gs-height")).show(),c.el=f.placeholder,c._beforeDragX=c.x,c._beforeDragY=c.y,f.dd.resizable(b,"option","minWidth",d*(c.minWidth||1)),f.dd.resizable(b,"option","minHeight",j*(c.minHeight||1)),"resizestart"==g.type&&i.find(".grid-stack-item").trigger("resizestart")},i=function(d,e){var g=a(this);if(g.data("_gridstack_node")){var h=!1;f.placeholder.detach(),c.el=g,f.placeholder.hide(),c._isAboutToRemove?(h=!0,b.removeData("_gridstack_node"),b.remove()):(f._clearRemovingTimeout(b),c._temporaryRemoved?(g.attr("data-gs-x",c._beforeDragX).attr("data-gs-y",c._beforeDragY).attr("data-gs-width",c.width).attr("data-gs-height",c.height).removeAttr("style"),c.x=c._beforeDragX,c.y=c._beforeDragY,f.grid.addNode(c)):g.attr("data-gs-x",c.x).attr("data-gs-y",c.y).attr("data-gs-width",c.width).attr("data-gs-height",c.height).removeAttr("style")),f._updateContainerHeight(),f._triggerChangeEvent(h),f.grid.endUpdate();var i=g.find(".grid-stack");i.length&&"resizestop"==d.type&&(i.each(function(b,c){a(c).data("gridstack").onResizeHandler()}),g.find(".grid-stack-item").trigger("resizestop"))}};this.dd.draggable(b,{start:h,stop:i,drag:g}).resizable(b,{start:h,stop:i,resize:g}),(c.noMove||this._isOneColumnMode()||this.opts.disableDrag)&&this.dd.draggable(b,"disable"),(c.noResize||this._isOneColumnMode()||this.opts.disableResize)&&this.dd.resizable(b,"disable"),b.attr("data-gs-locked",c.locked?"yes":null)}},j.prototype._prepareElement=function(b,c){c="undefined"!=typeof c&&c;var d=this;b=a(b),b.addClass(this.opts.itemClass);var e=d.grid.addNode({x:b.attr("data-gs-x"),y:b.attr("data-gs-y"),width:b.attr("data-gs-width"),height:b.attr("data-gs-height"),maxWidth:b.attr("data-gs-max-width"),minWidth:b.attr("data-gs-min-width"),maxHeight:b.attr("data-gs-max-height"),minHeight:b.attr("data-gs-min-height"),autoPosition:g.toBool(b.attr("data-gs-auto-position")),noResize:g.toBool(b.attr("data-gs-no-resize")),noMove:g.toBool(b.attr("data-gs-no-move")),locked:g.toBool(b.attr("data-gs-locked")),el:b,id:b.attr("data-gs-id"),_grid:d},c);b.data("_gridstack_node",e),this._prepareElementsByNode(b,e)},j.prototype.setAnimation=function(a){a?this.container.addClass("grid-stack-animate"):this.container.removeClass("grid-stack-animate")},j.prototype.addWidget=function(b,c,d,e,f,g,h,i,j,k,l){return b=a(b),"undefined"!=typeof c&&b.attr("data-gs-x",c),"undefined"!=typeof d&&b.attr("data-gs-y",d),"undefined"!=typeof e&&b.attr("data-gs-width",e),"undefined"!=typeof f&&b.attr("data-gs-height",f),"undefined"!=typeof g&&b.attr("data-gs-auto-position",g?"yes":null),"undefined"!=typeof h&&b.attr("data-gs-min-width",h),"undefined"!=typeof i&&b.attr("data-gs-max-width",i),"undefined"!=typeof j&&b.attr("data-gs-min-height",j),"undefined"!=typeof k&&b.attr("data-gs-max-height",k),"undefined"!=typeof l&&b.attr("data-gs-id",l),this.container.append(b),this._prepareElement(b,!0),this._triggerAddEvent(),this._updateContainerHeight(),this._triggerChangeEvent(!0),b},j.prototype.makeWidget=function(b){return b=a(b),this._prepareElement(b,!0),this._triggerAddEvent(),this._updateContainerHeight(),this._triggerChangeEvent(!0),b},j.prototype.willItFit=function(a,b,c,d,e){var f={x:a,y:b,width:c,height:d,autoPosition:e};return this.grid.canBePlacedWithRespectToHeight(f)},j.prototype.removeWidget=function(b,c){c="undefined"==typeof c||c,b=a(b);var d=b.data("_gridstack_node"); +// For Meteor support: https://github.com/troolee/gridstack.js/pull/272 +d||(d=this.grid.getNodeDataByDOMEl(b)),this.grid.removeNode(d,c),b.removeData("_gridstack_node"),this._updateContainerHeight(),c&&b.remove(),this._triggerChangeEvent(!0),this._triggerRemoveEvent()},j.prototype.removeAll=function(a){b.each(this.grid.nodes,b.bind(function(b){this.removeWidget(b.el,a)},this)),this.grid.nodes=[],this._updateContainerHeight()},j.prototype.destroy=function(b){a(window).off("resize",this.onResizeHandler),this.disable(),"undefined"==typeof b||b?this.container.remove():(this.removeAll(!1),this.container.removeData("gridstack")),g.removeStylesheet(this._stylesId),this.grid&&(this.grid=null)},j.prototype.resizable=function(b,c){var d=this;return b=a(b),b.each(function(b,e){e=a(e);var f=e.data("_gridstack_node");"undefined"!=typeof f&&null!==f&&"undefined"!=typeof a.ui&&(f.noResize=!c,f.noResize||d._isOneColumnMode()?d.dd.resizable(e,"disable"):d.dd.resizable(e,"enable"))}),this},j.prototype.movable=function(b,c){var d=this;return b=a(b),b.each(function(b,e){e=a(e);var f=e.data("_gridstack_node");"undefined"!=typeof f&&null!==f&&"undefined"!=typeof a.ui&&(f.noMove=!c,f.noMove||d._isOneColumnMode()?(d.dd.draggable(e,"disable"),e.removeClass("ui-draggable-handle")):(d.dd.draggable(e,"enable"),e.addClass("ui-draggable-handle")))}),this},j.prototype.enableMove=function(a,b){this.movable(this.container.children("."+this.opts.itemClass),a),b&&(this.opts.disableDrag=!a)},j.prototype.enableResize=function(a,b){this.resizable(this.container.children("."+this.opts.itemClass),a),b&&(this.opts.disableResize=!a)},j.prototype.disable=function(){this.movable(this.container.children("."+this.opts.itemClass),!1),this.resizable(this.container.children("."+this.opts.itemClass),!1),this.container.trigger("disable")},j.prototype.enable=function(){this.movable(this.container.children("."+this.opts.itemClass),!0),this.resizable(this.container.children("."+this.opts.itemClass),!0),this.container.trigger("enable")},j.prototype.locked=function(b,c){return b=a(b),b.each(function(b,d){d=a(d);var e=d.data("_gridstack_node");"undefined"!=typeof e&&null!==e&&(e.locked=c||!1,d.attr("data-gs-locked",e.locked?"yes":null))}),this},j.prototype.maxHeight=function(b,c){return b=a(b),b.each(function(b,d){d=a(d);var e=d.data("_gridstack_node");"undefined"!=typeof e&&null!==e&&(isNaN(c)||(e.maxHeight=c||!1,d.attr("data-gs-max-height",c)))}),this},j.prototype.minHeight=function(b,c){return b=a(b),b.each(function(b,d){d=a(d);var e=d.data("_gridstack_node");"undefined"!=typeof e&&null!==e&&(isNaN(c)||(e.minHeight=c||!1,d.attr("data-gs-min-height",c)))}),this},j.prototype.maxWidth=function(b,c){return b=a(b),b.each(function(b,d){d=a(d);var e=d.data("_gridstack_node");"undefined"!=typeof e&&null!==e&&(isNaN(c)||(e.maxWidth=c||!1,d.attr("data-gs-max-width",c)))}),this},j.prototype.minWidth=function(b,c){return b=a(b),b.each(function(b,d){d=a(d);var e=d.data("_gridstack_node");"undefined"!=typeof e&&null!==e&&(isNaN(c)||(e.minWidth=c||!1,d.attr("data-gs-min-width",c)))}),this},j.prototype._updateElement=function(b,c){b=a(b).first();var d=b.data("_gridstack_node");if("undefined"!=typeof d&&null!==d){var e=this;e.grid.cleanNodes(),e.grid.beginUpdate(d),c.call(this,b,d),e._updateContainerHeight(),e._triggerChangeEvent(),e.grid.endUpdate()}},j.prototype.resize=function(a,b,c){this._updateElement(a,function(a,d){b=null!==b&&"undefined"!=typeof b?b:d.width,c=null!==c&&"undefined"!=typeof c?c:d.height,this.grid.moveNode(d,d.x,d.y,b,c)})},j.prototype.move=function(a,b,c){this._updateElement(a,function(a,d){b=null!==b&&"undefined"!=typeof b?b:d.x,c=null!==c&&"undefined"!=typeof c?c:d.y,this.grid.moveNode(d,b,c,d.width,d.height)})},j.prototype.update=function(a,b,c,d,e){this._updateElement(a,function(a,f){b=null!==b&&"undefined"!=typeof b?b:f.x,c=null!==c&&"undefined"!=typeof c?c:f.y,d=null!==d&&"undefined"!=typeof d?d:f.width,e=null!==e&&"undefined"!=typeof e?e:f.height,this.grid.moveNode(f,b,c,d,e)})},j.prototype.verticalMargin=function(a,b){if("undefined"==typeof a)return this.opts.verticalMargin;var c=g.parseHeight(a);this.opts.verticalMarginUnit===c.unit&&this.opts.height===c.height||(this.opts.verticalMarginUnit=c.unit,this.opts.verticalMargin=c.height,b||this._updateStyles())},j.prototype.cellHeight=function(a,b){if("undefined"==typeof a){if(this.opts.cellHeight)return this.opts.cellHeight;var c=this.container.children("."+this.opts.itemClass).first();return Math.ceil(c.outerHeight()/c.attr("data-gs-height"))}var d=g.parseHeight(a);this.opts.cellHeightUnit===d.heightUnit&&this.opts.height===d.height||(this.opts.cellHeightUnit=d.unit,this.opts.cellHeight=d.height,b||this._updateStyles())},j.prototype.cellWidth=function(){return Math.round(this.container.outerWidth()/this.opts.width)},j.prototype.getCellFromPixel=function(a,b){var c="undefined"!=typeof b&&b?this.container.offset():this.container.position(),d=a.left-c.left,e=a.top-c.top,f=Math.floor(this.container.width()/this.opts.width),g=Math.floor(this.container.height()/parseInt(this.container.attr("data-gs-current-height")));return{x:Math.floor(d/f),y:Math.floor(e/g)}},j.prototype.batchUpdate=function(){this.grid.batchUpdate()},j.prototype.commit=function(){this.grid.commit(),this._updateContainerHeight()},j.prototype.isAreaEmpty=function(a,b,c,d){return this.grid.isAreaEmpty(a,b,c,d)},j.prototype.setStatic=function(a){this.opts.staticGrid=a===!0,this.enableMove(!a),this.enableResize(!a),this._setStaticClass()},j.prototype._setStaticClass=function(){var a="grid-stack-static";this.opts.staticGrid===!0?this.container.addClass(a):this.container.removeClass(a)},j.prototype._updateNodeWidths=function(a,b){this.grid._sortNodes(),this.grid.batchUpdate();for(var c={},d=0;d .grid-stack-item { + direction: rtl; +} + .grid-stack .grid-stack-placeholder > .placeholder-content { border: 1px dashed lightgray; margin: 0; @@ -64,29 +72,22 @@ .grid-stack > .grid-stack-item > .ui-resizable-se, .grid-stack > .grid-stack-item > .ui-resizable-sw { - text-align: right; - color: gray; - padding: 2px 3px 0 0; - margin: 0; - font: normal normal normal 10px/1 FontAwesome; - font-size: inherit; - text-rendering: auto; - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; -} - -.grid-stack > .grid-stack-item > .ui-resizable-se::before, -.grid-stack > .grid-stack-item > .ui-resizable-sw::before { - content: "\f065"; + background-image: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS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jQyNCwxMi44NDVjMy42MTksMy42MTcsNy45MDEsNS40MjYsMTIuODUsNS40MjYgICBoMzYuNTQ1djI5Mi4zNThoLTM2LjU0MmMtNC45NTIsMC05LjIzNSwxLjgwOC0xMi44NSw1LjQyMWMtMy42MTcsMy42MjEtNS40MjQsNy45MDUtNS40MjQsMTIuODU0ICAgYzAsNC45NDUsMS44MDcsOS4yMjcsNS40MjQsMTIuODQ3bDczLjA4OSw3My4wODhjMy42MTcsMy42MTcsNy44OTgsNS40MjQsMTIuODQ3LDUuNDI0YzQuOTUsMCw5LjIzNC0xLjgwNywxMi44NDktNS40MjQgICBsNzMuMDg3LTczLjA4OGMzLjYxMy0zLjYyLDUuNDIxLTcuOTAxLDUuNDIxLTEyLjg0N2MwLTQuOTQ4LTEuODA4LTkuMjMyLTUuNDIxLTEyLjg1NCAgIEMzMzguMTQyLDQwMy44MDIsMzMzLjg1Nyw0MDEuOTk0LDMyOC45MDYsNDAxLjk5NHoiIGZpbGw9IiM2NjY2NjYiLz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8L3N2Zz4K); + background-repeat: no-repeat; + background-position: center; + -webkit-transform: rotate(45deg); + -moz-transform: rotate(45deg); + -ms-transform: rotate(45deg); + -o-transform: rotate(45deg); + transform: rotate(45deg); } .grid-stack > .grid-stack-item > .ui-resizable-se { - display: inline-block; - -webkit-transform: rotate(90deg); - -moz-transform: rotate(90deg); - -ms-transform: rotate(90deg); - -o-transform: rotate(90deg); - transform: rotate(90deg); + -webkit-transform: rotate(-45deg); + -moz-transform: rotate(-45deg); + -ms-transform: rotate(-45deg); + -o-transform: rotate(-45deg); + transform: rotate(-45deg); } .grid-stack > .grid-stack-item > .ui-resizable-nw { @@ -153,6 +154,10 @@ bottom: 15px; } +.grid-stack > .grid-stack-item.ui-draggable-dragging > .ui-resizable-handle { + display: none !important; +} + .grid-stack > .grid-stack-item[data-gs-width='1'] { width: 8.3333333333%; } @@ -364,25 +369,19 @@ transition: left 0s, top 0s, height 0s, width 0s; } -/** Uncomment this to show bottom-left resize handle **/ -/* -.grid-stack > .grid-stack-item > .ui-resizable-sw { - display: inline-block; - @include vendor(transform, rotate(180deg)); -} -*/ -@media (max-width: 768px) { - .grid-stack-item { - position: relative !important; - width: auto !important; - left: 0 !important; - top: auto !important; - margin-bottom: 20px; - } - .grid-stack-item .ui-resizable-handle { - display: none; - } - .grid-stack { - height: auto !important; - } +.grid-stack.grid-stack-one-column-mode { + height: auto !important; +} + +.grid-stack.grid-stack-one-column-mode > .grid-stack-item { + position: relative !important; + width: auto !important; + left: 0 !important; + top: auto !important; + margin-bottom: 20px; + max-width: none !important; +} + +.grid-stack.grid-stack-one-column-mode > .grid-stack-item > .ui-resizable-handle { + display: none; } diff --git a/dist/gridstack.jQueryUI.js b/dist/gridstack.jQueryUI.js new file mode 100644 index 000000000..c5d493615 --- /dev/null +++ b/dist/gridstack.jQueryUI.js @@ -0,0 +1,97 @@ +/** + * gridstack.js 0.3.0-dev + * http://troolee.github.io/gridstack.js/ + * (c) 2014-2016 Pavel Reznikov, Dylan Weiss + * gridstack.js may be freely distributed under the MIT license. + * @preserve +*/ +(function(factory) { + if (typeof define === 'function' && define.amd) { + define(['jquery', 'lodash', 'gridstack', 'jquery-ui/data', 'jquery-ui/disable-selection', 'jquery-ui/focusable', + 'jquery-ui/form', 'jquery-ui/ie', 'jquery-ui/keycode', 'jquery-ui/labels', 'jquery-ui/jquery-1-7', + 'jquery-ui/plugin', 'jquery-ui/safe-active-element', 'jquery-ui/safe-blur', 'jquery-ui/scroll-parent', + 'jquery-ui/tabbable', 'jquery-ui/unique-id', 'jquery-ui/version', 'jquery-ui/widget', + 'jquery-ui/widgets/mouse', 'jquery-ui/widgets/draggable', 'jquery-ui/widgets/droppable', + 'jquery-ui/widgets/resizable'], factory); + } else if (typeof exports !== 'undefined') { + try { jQuery = require('jquery'); } catch (e) {} + try { _ = require('lodash'); } catch (e) {} + try { GridStackUI = require('gridstack'); } catch (e) {} + factory(jQuery, _, GridStackUI); + } else { + factory(jQuery, _, GridStackUI); + } +})(function($, _, GridStackUI) { + + var scope = window; + + /** + * @class JQueryUIGridStackDragDropPlugin + * jQuery UI implementation of drag'n'drop gridstack plugin. + */ + function JQueryUIGridStackDragDropPlugin(grid) { + GridStackUI.GridStackDragDropPlugin.call(this, grid); + } + + GridStackUI.GridStackDragDropPlugin.registerPlugin(JQueryUIGridStackDragDropPlugin); + + JQueryUIGridStackDragDropPlugin.prototype = Object.create(GridStackUI.GridStackDragDropPlugin.prototype); + JQueryUIGridStackDragDropPlugin.prototype.constructor = JQueryUIGridStackDragDropPlugin; + + JQueryUIGridStackDragDropPlugin.prototype.resizable = function(el, opts) { + el = $(el); + if (opts === 'disable' || opts === 'enable') { + el.resizable(opts); + } else if (opts === 'option') { + var key = arguments[2]; + var value = arguments[3]; + el.resizable(opts, key, value); + } else { + el.resizable(_.extend({}, this.grid.opts.resizable, { + start: opts.start || function() {}, + stop: opts.stop || function() {}, + resize: opts.resize || function() {} + })); + } + return this; + }; + + JQueryUIGridStackDragDropPlugin.prototype.draggable = function(el, opts) { + el = $(el); + if (opts === 'disable' || opts === 'enable') { + el.draggable(opts); + } else { + el.draggable(_.extend({}, this.grid.opts.draggable, { + containment: this.grid.opts.isNested ? this.grid.container.parent() : null, + start: opts.start || function() {}, + stop: opts.stop || function() {}, + drag: opts.drag || function() {} + })); + } + return this; + }; + + JQueryUIGridStackDragDropPlugin.prototype.droppable = function(el, opts) { + el = $(el); + if (opts === 'disable' || opts === 'enable') { + el.droppable(opts); + } else { + el.droppable({ + accept: opts.accept + }); + } + return this; + }; + + JQueryUIGridStackDragDropPlugin.prototype.isDroppable = function(el, opts) { + el = $(el); + return Boolean(el.data('droppable')); + }; + + JQueryUIGridStackDragDropPlugin.prototype.on = function(el, eventName, callback) { + $(el).on(eventName, callback); + return this; + }; + + return JQueryUIGridStackDragDropPlugin; +}); diff --git a/dist/gridstack.jQueryUI.min.js b/dist/gridstack.jQueryUI.min.js new file mode 100644 index 000000000..c8a02504f --- /dev/null +++ b/dist/gridstack.jQueryUI.min.js @@ -0,0 +1,13 @@ +/** + * gridstack.js 0.3.0-dev + * http://troolee.github.io/gridstack.js/ + * (c) 2014-2016 Pavel Reznikov, Dylan Weiss + * gridstack.js may be freely distributed under the MIT license. + * @preserve +*/ +!function(a){if("function"==typeof define&&define.amd)define(["jquery","lodash","gridstack","jquery-ui/data","jquery-ui/disable-selection","jquery-ui/focusable","jquery-ui/form","jquery-ui/ie","jquery-ui/keycode","jquery-ui/labels","jquery-ui/jquery-1-7","jquery-ui/plugin","jquery-ui/safe-active-element","jquery-ui/safe-blur","jquery-ui/scroll-parent","jquery-ui/tabbable","jquery-ui/unique-id","jquery-ui/version","jquery-ui/widget","jquery-ui/widgets/mouse","jquery-ui/widgets/draggable","jquery-ui/widgets/droppable","jquery-ui/widgets/resizable"],a);else if("undefined"!=typeof exports){try{jQuery=require("jquery")}catch(a){}try{_=require("lodash")}catch(a){}try{GridStackUI=require("gridstack")}catch(a){}a(jQuery,_,GridStackUI)}else a(jQuery,_,GridStackUI)}(function(a,b,c){/** + * @class JQueryUIGridStackDragDropPlugin + * jQuery UI implementation of drag'n'drop gridstack plugin. + */ +function d(a){c.GridStackDragDropPlugin.call(this,a)}window;return c.GridStackDragDropPlugin.registerPlugin(d),d.prototype=Object.create(c.GridStackDragDropPlugin.prototype),d.prototype.constructor=d,d.prototype.resizable=function(c,d){if(c=a(c),"disable"===d||"enable"===d)c.resizable(d);else if("option"===d){var e=arguments[2],f=arguments[3];c.resizable(d,e,f)}else c.resizable(b.extend({},this.grid.opts.resizable,{start:d.start||function(){},stop:d.stop||function(){},resize:d.resize||function(){}}));return this},d.prototype.draggable=function(c,d){return c=a(c),"disable"===d||"enable"===d?c.draggable(d):c.draggable(b.extend({},this.grid.opts.draggable,{containment:this.grid.opts.isNested?this.grid.container.parent():null,start:d.start||function(){},stop:d.stop||function(){},drag:d.drag||function(){}})),this},d.prototype.droppable=function(b,c){return b=a(b),"disable"===c||"enable"===c?b.droppable(c):b.droppable({accept:c.accept}),this},d.prototype.isDroppable=function(b,c){return b=a(b),Boolean(b.data("droppable"))},d.prototype.on=function(b,c,d){return a(b).on(c,d),this},d}); +//# sourceMappingURL=gridstack.min.map \ No newline at end of file diff --git a/dist/gridstack.js b/dist/gridstack.js old mode 100755 new mode 100644 index b187f0629..39d250ac2 --- a/dist/gridstack.js +++ b/dist/gridstack.js @@ -1,27 +1,42 @@ -// gridstack.js 0.2.4-dev -// http://troolee.github.io/gridstack.js/ -// (c) 2014-2016 Pavel Reznikov -// gridstack.js may be freely distributed under the MIT license. - +/** + * gridstack.js 0.3.0-dev + * http://troolee.github.io/gridstack.js/ + * (c) 2014-2016 Pavel Reznikov, Dylan Weiss + * gridstack.js may be freely distributed under the MIT license. + * @preserve +*/ (function(factory) { if (typeof define === 'function' && define.amd) { - define(['jquery', 'lodash', 'jquery-ui/core', 'jquery-ui/widget', 'jquery-ui/mouse', 'jquery-ui/draggable', - 'jquery-ui/resizable'], factory); - } - else if (typeof exports !== 'undefined') { - try { jQuery = require('jquery'); } catch(e) {} - try { _ = require('lodash'); } catch(e) {} - factory(jQuery, _); - } - else { + define(['jquery', 'lodash'], factory); + } else if (typeof exports !== 'undefined') { + try { jQuery = require('jquery'); } catch (e) {} + try { _ = require('lodash'); } catch (e) {} + factory(jQuery, _); + } else { factory(jQuery, _); } })(function($, _) { var scope = window; + var obsolete = function(f, oldName, newName) { + var wrapper = function() { + console.warn('gridstack.js: Function `' + oldName + '` is deprecated as of v0.2.5 and has been replaced ' + + 'with `' + newName + '`. It will be **completely** removed in v1.0.'); + return f.apply(this, arguments); + }; + wrapper.prototype = f.prototype; + + return wrapper; + }; + + var obsoleteOpts = function(oldName, newName) { + console.warn('gridstack.js: Option `' + oldName + '` is deprecated as of v0.2.5 and has been replaced with `' + + newName + '`. It will be **completely** removed in v1.0.'); + }; + var Utils = { - is_intercepted: function(a, b) { + isIntercepted: function(a, b) { return !(a.x + a.width <= b.x || b.x + b.width <= a.x || a.y + a.height <= b.y || b.y + b.height <= a.y); }, @@ -31,170 +46,244 @@ return _.sortBy(nodes, function(n) { return dir * (n.x + n.y * width); }); }, - create_stylesheet: function(id) { + createStylesheet: function(id) { var style = document.createElement('style'); style.setAttribute('type', 'text/css'); - style.setAttribute('data-gs-id', id); + style.setAttribute('data-gs-style-id', id); if (style.styleSheet) { style.styleSheet.cssText = ''; - } - else { + } else { style.appendChild(document.createTextNode('')); } document.getElementsByTagName('head')[0].appendChild(style); return style.sheet; }, - remove_stylesheet: function(id) { - $("STYLE[data-gs-id=" + id +"]").remove(); + + removeStylesheet: function(id) { + $('STYLE[data-gs-style-id=' + id + ']').remove(); }, - insert_css_rule: function(sheet, selector, rules, index) { + + insertCSSRule: function(sheet, selector, rules, index) { if (typeof sheet.insertRule === 'function') { sheet.insertRule(selector + '{' + rules + '}', index); - } - else if (typeof sheet.addRule === 'function') { + } else if (typeof sheet.addRule === 'function') { sheet.addRule(selector, rules, index); } }, toBool: function(v) { - if (typeof v == 'boolean') + if (typeof v == 'boolean') { return v; + } if (typeof v == 'string') { v = v.toLowerCase(); - return !(v == '' || v == 'no' || v == 'false' || v == '0'); + return !(v === '' || v == 'no' || v == 'false' || v == '0'); } return Boolean(v); + }, + + _collisionNodeCheck: function(n) { + return n != this.node && Utils.isIntercepted(n, this.nn); + }, + + _didCollide: function(bn) { + return Utils.isIntercepted({x: this.n.x, y: this.newY, width: this.n.width, height: this.n.height}, bn); + }, + + _isAddNodeIntercepted: function(n) { + return Utils.isIntercepted({x: this.x, y: this.y, width: this.node.width, height: this.node.height}, n); + }, + + parseHeight: function(val) { + var height = val; + var heightUnit = 'px'; + if (height && _.isString(height)) { + var match = height.match(/^(-[0-9]+\.[0-9]+|[0-9]*\.[0-9]+|-[0-9]+|[0-9]+)(px|em|rem|vh|vw)?$/); + if (!match) { + throw new Error('Invalid height'); + } + heightUnit = match[2] || 'px'; + height = parseFloat(match[1]); + } + return {height: height, unit: heightUnit}; } }; - var id_seq = 0; + // jscs:disable requireCamelCaseOrUpperCaseIdentifiers + Utils.is_intercepted = obsolete(Utils.isIntercepted, 'is_intercepted', 'isIntercepted'); + + Utils.create_stylesheet = obsolete(Utils.createStylesheet, 'create_stylesheet', 'createStylesheet'); + + Utils.remove_stylesheet = obsolete(Utils.removeStylesheet, 'remove_stylesheet', 'removeStylesheet'); + + Utils.insert_css_rule = obsolete(Utils.insertCSSRule, 'insert_css_rule', 'insertCSSRule'); + // jscs:enable requireCamelCaseOrUpperCaseIdentifiers + + /** + * @class GridStackDragDropPlugin + * Base class for drag'n'drop plugin. + */ + function GridStackDragDropPlugin(grid) { + this.grid = grid; + } + + GridStackDragDropPlugin.registeredPlugins = []; + + GridStackDragDropPlugin.registerPlugin = function(pluginClass) { + GridStackDragDropPlugin.registeredPlugins.push(pluginClass); + }; + + GridStackDragDropPlugin.prototype.resizable = function(el, opts) { + return this; + }; - var GridStackEngine = function(width, onchange, float_mode, height, items) { + GridStackDragDropPlugin.prototype.draggable = function(el, opts) { + return this; + }; + + GridStackDragDropPlugin.prototype.droppable = function(el, opts) { + return this; + }; + + GridStackDragDropPlugin.prototype.isDroppable = function(el) { + return false; + }; + + GridStackDragDropPlugin.prototype.on = function(el, eventName, callback) { + return this; + }; + + + var idSeq = 0; + + var GridStackEngine = function(width, onchange, floatMode, height, items) { this.width = width; - this['float'] = float_mode || false; + this.float = floatMode || false; this.height = height || 0; this.nodes = items || []; this.onchange = onchange || function() {}; - this._update_counter = 0; - this._float = this['float']; + this._updateCounter = 0; + this._float = this.float; + + this._addedNodes = []; + this._removedNodes = []; }; - GridStackEngine.prototype.batch_update = function() { - this._update_counter = 1; + GridStackEngine.prototype.batchUpdate = function() { + this._updateCounter = 1; this.float = true; }; GridStackEngine.prototype.commit = function() { - this._update_counter = 0; - if (this._update_counter == 0) { + if (this._updateCounter !== 0) { + this._updateCounter = 0; this.float = this._float; - this._pack_nodes(); + this._packNodes(); this._notify(); } }; - GridStackEngine.prototype._fix_collisions = function(node) { - this._sort_nodes(-1); + // For Meteor support: https://github.com/troolee/gridstack.js/pull/272 + GridStackEngine.prototype.getNodeDataByDOMEl = function(el) { + return _.find(this.nodes, function(n) { return el.get(0) === n.el.get(0); }); + }; - var nn = node, has_locked = Boolean(_.find(this.nodes, function(n) { return n.locked })); - if (!this.float && !has_locked) { + GridStackEngine.prototype._fixCollisions = function(node) { + var self = this; + this._sortNodes(-1); + + var nn = node; + var hasLocked = Boolean(_.find(this.nodes, function(n) { return n.locked; })); + if (!this.float && !hasLocked) { nn = {x: 0, y: node.y, width: this.width, height: node.height}; } - while (true) { - var collision_node = _.find(this.nodes, _.bind(function(n) { - return n != node && Utils.is_intercepted(n, nn); - }, this)); - if (typeof collision_node == 'undefined') { + var collisionNode = _.find(this.nodes, _.bind(Utils._collisionNodeCheck, {node: node, nn: nn})); + if (typeof collisionNode == 'undefined') { return; } - this.move_node(collision_node, collision_node.x, node.y + node.height, - collision_node.width, collision_node.height, true); + this.moveNode(collisionNode, collisionNode.x, node.y + node.height, + collisionNode.width, collisionNode.height, true); } }; - GridStackEngine.prototype.is_area_empty = function(x, y, width, height) { + GridStackEngine.prototype.isAreaEmpty = function(x, y, width, height) { var nn = {x: x || 0, y: y || 0, width: width || 1, height: height || 1}; - var collision_node = _.find(this.nodes, _.bind(function(n) { - return Utils.is_intercepted(n, nn); + var collisionNode = _.find(this.nodes, _.bind(function(n) { + return Utils.isIntercepted(n, nn); }, this)); - return collision_node == null; + return collisionNode === null || typeof collisionNode === 'undefined'; }; - GridStackEngine.prototype._sort_nodes = function(dir) { + GridStackEngine.prototype._sortNodes = function(dir) { this.nodes = Utils.sort(this.nodes, dir, this.width); }; - GridStackEngine.prototype._pack_nodes = function() { - this._sort_nodes(); + GridStackEngine.prototype._packNodes = function() { + this._sortNodes(); if (this.float) { _.each(this.nodes, _.bind(function(n, i) { - if (n._updating || typeof n._orig_y == 'undefined' || n.y == n._orig_y) + if (n._updating || typeof n._origY == 'undefined' || n.y == n._origY) { return; + } - var new_y = n.y; - while (new_y >= n._orig_y) { - var collision_node = _.chain(this.nodes) - .find(function(bn) { - return n != bn && - Utils.is_intercepted({x: n.x, y: new_y, width: n.width, height: n.height}, bn); - }) + var newY = n.y; + while (newY >= n._origY) { + var collisionNode = _.chain(this.nodes) + .find(_.bind(Utils._didCollide, {n: n, newY: newY})) .value(); - if (!collision_node) { + if (!collisionNode) { n._dirty = true; - n.y = new_y; + n.y = newY; } - --new_y; + --newY; } }, this)); - } - else { + } else { _.each(this.nodes, _.bind(function(n, i) { - if (n.locked) + if (n.locked) { return; + } while (n.y > 0) { - var new_y = n.y - 1; - var can_be_moved = i == 0; + var newY = n.y - 1; + var canBeMoved = i === 0; if (i > 0) { - var collision_node = _.chain(this.nodes) + var collisionNode = _.chain(this.nodes) .take(i) - .find(function(bn) { - return Utils.is_intercepted({x: n.x, y: new_y, width: n.width, height: n.height}, bn); - }) + .find(_.bind(Utils._didCollide, {n: n, newY: newY})) .value(); - can_be_moved = typeof collision_node == 'undefined'; + canBeMoved = typeof collisionNode == 'undefined'; } - if (!can_be_moved) { + if (!canBeMoved) { break; } - n._dirty = n.y != new_y; - n.y = new_y; + n._dirty = n.y != newY; + n.y = newY; } }, this)); } }; - GridStackEngine.prototype._prepare_node = function(node, resizing) { - node = _.defaults(node || {}, {width: 1, height: 1, x: 0, y: 0 }); + GridStackEngine.prototype._prepareNode = function(node, resizing) { + node = _.defaults(node || {}, {width: 1, height: 1, x: 0, y: 0}); node.x = parseInt('' + node.x); node.y = parseInt('' + node.y); node.width = parseInt('' + node.width); node.height = parseInt('' + node.height); - node.auto_position = node.auto_position || false; - node.no_resize = node.no_resize || false; - node.no_move = node.no_move || false; + node.autoPosition = node.autoPosition || false; + node.noResize = node.noResize || false; + node.noMove = node.noMove || false; if (node.width > this.width) { node.width = this.width; - } - else if (node.width < 1) { + } else if (node.width < 1) { node.width = 1; } @@ -209,8 +298,7 @@ if (node.x + node.width > this.width) { if (resizing) { node.width = this.width - node.x; - } - else { + } else { node.x = this.width - node.width; } } @@ -223,44 +311,48 @@ }; GridStackEngine.prototype._notify = function() { - if (this._update_counter) { + var args = Array.prototype.slice.call(arguments, 0); + args[0] = typeof args[0] === 'undefined' ? [] : [args[0]]; + args[1] = typeof args[1] === 'undefined' ? true : args[1]; + if (this._updateCounter) { return; } - var deleted_nodes = Array.prototype.slice.call(arguments, 1).concat(this.get_dirty_nodes()); - deleted_nodes = deleted_nodes.concat(this.get_dirty_nodes()); - this.onchange(deleted_nodes); + var deletedNodes = args[0].concat(this.getDirtyNodes()); + this.onchange(deletedNodes, args[1]); }; - GridStackEngine.prototype.clean_nodes = function() { - _.each(this.nodes, function(n) {n._dirty = false }); + GridStackEngine.prototype.cleanNodes = function() { + if (this._updateCounter) { + return; + } + _.each(this.nodes, function(n) {n._dirty = false; }); }; - GridStackEngine.prototype.get_dirty_nodes = function() { + GridStackEngine.prototype.getDirtyNodes = function() { return _.filter(this.nodes, function(n) { return n._dirty; }); }; - GridStackEngine.prototype.add_node = function(node) { - node = this._prepare_node(node); + GridStackEngine.prototype.addNode = function(node, triggerAddEvent) { + node = this._prepareNode(node); - if (typeof node.max_width != 'undefined') node.width = Math.min(node.width, node.max_width); - if (typeof node.max_height != 'undefined') node.height = Math.min(node.height, node.max_height); - if (typeof node.min_width != 'undefined') node.width = Math.max(node.width, node.min_width); - if (typeof node.min_height != 'undefined') node.height = Math.max(node.height, node.min_height); + if (typeof node.maxWidth != 'undefined') { node.width = Math.min(node.width, node.maxWidth); } + if (typeof node.maxHeight != 'undefined') { node.height = Math.min(node.height, node.maxHeight); } + if (typeof node.minWidth != 'undefined') { node.width = Math.max(node.width, node.minWidth); } + if (typeof node.minHeight != 'undefined') { node.height = Math.max(node.height, node.minHeight); } - node._id = ++id_seq; + node._id = ++idSeq; node._dirty = true; - if (node.auto_position) { - this._sort_nodes(); + if (node.autoPosition) { + this._sortNodes(); for (var i = 0;; ++i) { - var x = i % this.width, y = Math.floor(i / this.width); + var x = i % this.width; + var y = Math.floor(i / this.width); if (x + node.width > this.width) { continue; } - if (!_.find(this.nodes, function(n) { - return Utils.is_intercepted({x: x, y: y, width: node.width, height: node.height}, n); - })) { + if (!_.find(this.nodes, _.bind(Utils._isAddNodeIntercepted, {x: x, y: y, node: node}))) { node.x = x; node.y = y; break; @@ -269,27 +361,36 @@ } this.nodes.push(node); + if (typeof triggerAddEvent != 'undefined' && triggerAddEvent) { + this._addedNodes.push(_.clone(node)); + } - this._fix_collisions(node); - this._pack_nodes(); + this._fixCollisions(node); + this._packNodes(); this._notify(); return node; }; - GridStackEngine.prototype.remove_node = function(node) { + GridStackEngine.prototype.removeNode = function(node, detachNode) { + detachNode = typeof detachNode === 'undefined' ? true : detachNode; + this._removedNodes.push(_.clone(node)); node._id = null; this.nodes = _.without(this.nodes, node); - this._pack_nodes(); - this._notify(node); + this._packNodes(); + this._notify(node, detachNode); }; - GridStackEngine.prototype.can_move_node = function(node, x, y, width, height) { - var has_locked = Boolean(_.find(this.nodes, function(n) { return n.locked })); + GridStackEngine.prototype.canMoveNode = function(node, x, y, width, height) { + if (!this.isNodeChangedPosition(node, x, y, width, height)) { + return false; + } + var hasLocked = Boolean(_.find(this.nodes, function(n) { return n.locked; })); - if (!this.height && !has_locked) + if (!this.height && !hasLocked) { return true; + } - var cloned_node; + var clonedNode; var clone = new GridStackEngine( this.width, null, @@ -297,50 +398,77 @@ 0, _.map(this.nodes, function(n) { if (n == node) { - cloned_node = $.extend({}, n); - return cloned_node; + clonedNode = $.extend({}, n); + return clonedNode; } return $.extend({}, n); })); - clone.move_node(cloned_node, x, y, width, height); + if (typeof clonedNode === 'undefined') { + return true; + } + + clone.moveNode(clonedNode, x, y, width, height); var res = true; - if (has_locked) + if (hasLocked) { res &= !Boolean(_.find(clone.nodes, function(n) { - return n != cloned_node && Boolean(n.locked) && Boolean(n._dirty); + return n != clonedNode && Boolean(n.locked) && Boolean(n._dirty); })); - if (this.height) - res &= clone.get_grid_height() <= this.height; + } + if (this.height) { + res &= clone.getGridHeight() <= this.height; + } return res; }; - GridStackEngine.prototype.can_be_placed_with_respect_to_height = function(node) { - if (!this.height) + GridStackEngine.prototype.canBePlacedWithRespectToHeight = function(node) { + if (!this.height) { return true; + } var clone = new GridStackEngine( this.width, null, this.float, 0, - _.map(this.nodes, function(n) { return $.extend({}, n) })); - clone.add_node(node); - return clone.get_grid_height() <= this.height; + _.map(this.nodes, function(n) { return $.extend({}, n); })); + clone.addNode(node); + return clone.getGridHeight() <= this.height; + }; + + GridStackEngine.prototype.isNodeChangedPosition = function(node, x, y, width, height) { + if (typeof x != 'number') { x = node.x; } + if (typeof y != 'number') { y = node.y; } + if (typeof width != 'number') { width = node.width; } + if (typeof height != 'number') { height = node.height; } + + if (typeof node.maxWidth != 'undefined') { width = Math.min(width, node.maxWidth); } + if (typeof node.maxHeight != 'undefined') { height = Math.min(height, node.maxHeight); } + if (typeof node.minWidth != 'undefined') { width = Math.max(width, node.minWidth); } + if (typeof node.minHeight != 'undefined') { height = Math.max(height, node.minHeight); } + + if (node.x == x && node.y == y && node.width == width && node.height == height) { + return false; + } + return true; }; - GridStackEngine.prototype.move_node = function(node, x, y, width, height, no_pack) { - if (typeof x != 'number') x = node.x; - if (typeof y != 'number') y = node.y; - if (typeof width != 'number') width = node.width; - if (typeof height != 'number') height = node.height; + GridStackEngine.prototype.moveNode = function(node, x, y, width, height, noPack) { + if (!this.isNodeChangedPosition(node, x, y, width, height)) { + return node; + } + if (typeof x != 'number') { x = node.x; } + if (typeof y != 'number') { y = node.y; } + if (typeof width != 'number') { width = node.width; } + if (typeof height != 'number') { height = node.height; } - if (typeof node.max_width != 'undefined') width = Math.min(width, node.max_width); - if (typeof node.max_height != 'undefined') height = Math.min(height, node.max_height); - if (typeof node.min_width != 'undefined') width = Math.max(width, node.min_width); - if (typeof node.min_height != 'undefined') height = Math.max(height, node.min_height); + if (typeof node.maxWidth != 'undefined') { width = Math.min(width, node.maxWidth); } + if (typeof node.maxHeight != 'undefined') { height = Math.min(height, node.maxHeight); } + if (typeof node.minWidth != 'undefined') { width = Math.max(width, node.minWidth); } + if (typeof node.minHeight != 'undefined') { height = Math.max(height, node.minHeight); } if (node.x == x && node.y == y && node.width == width && node.height == height) { return node; @@ -354,30 +482,35 @@ node.width = width; node.height = height; - node = this._prepare_node(node, resizing); + node.lastTriedX = x; + node.lastTriedY = y; + node.lastTriedWidth = width; + node.lastTriedHeight = height; + + node = this._prepareNode(node, resizing); - this._fix_collisions(node); - if (!no_pack) { - this._pack_nodes(); + this._fixCollisions(node); + if (!noPack) { + this._packNodes(); this._notify(); } return node; }; - GridStackEngine.prototype.get_grid_height = function() { + GridStackEngine.prototype.getGridHeight = function() { return _.reduce(this.nodes, function(memo, n) { return Math.max(memo, n.y + n.height); }, 0); }; - GridStackEngine.prototype.begin_update = function(node) { + GridStackEngine.prototype.beginUpdate = function(node) { _.each(this.nodes, function(n) { - n._orig_y = n.y; + n._origY = n.y; }); node._updating = true; }; - GridStackEngine.prototype.end_update = function() { + GridStackEngine.prototype.endUpdate = function() { _.each(this.nodes, function(n) { - n._orig_y = n.y; + n._origY = n.y; }); var n = _.find(this.nodes, function(n) { return n._updating; }); if (n) { @@ -386,76 +519,158 @@ }; var GridStack = function(el, opts) { - var self = this, one_column_mode; + var self = this; + var oneColumnMode, isAutoCellHeight; opts = opts || {}; this.container = $(el); - opts.item_class = opts.item_class || 'grid-stack-item'; - var is_nested = this.container.closest('.' + opts.item_class).size() > 0; + // jscs:disable requireCamelCaseOrUpperCaseIdentifiers + if (typeof opts.handle_class !== 'undefined') { + opts.handleClass = opts.handle_class; + obsoleteOpts('handle_class', 'handleClass'); + } + if (typeof opts.item_class !== 'undefined') { + opts.itemClass = opts.item_class; + obsoleteOpts('item_class', 'itemClass'); + } + if (typeof opts.placeholder_class !== 'undefined') { + opts.placeholderClass = opts.placeholder_class; + obsoleteOpts('placeholder_class', 'placeholderClass'); + } + if (typeof opts.placeholder_text !== 'undefined') { + opts.placeholderText = opts.placeholder_text; + obsoleteOpts('placeholder_text', 'placeholderText'); + } + if (typeof opts.cell_height !== 'undefined') { + opts.cellHeight = opts.cell_height; + obsoleteOpts('cell_height', 'cellHeight'); + } + if (typeof opts.vertical_margin !== 'undefined') { + opts.verticalMargin = opts.vertical_margin; + obsoleteOpts('vertical_margin', 'verticalMargin'); + } + if (typeof opts.min_width !== 'undefined') { + opts.minWidth = opts.min_width; + obsoleteOpts('min_width', 'minWidth'); + } + if (typeof opts.static_grid !== 'undefined') { + opts.staticGrid = opts.static_grid; + obsoleteOpts('static_grid', 'staticGrid'); + } + if (typeof opts.is_nested !== 'undefined') { + opts.isNested = opts.is_nested; + obsoleteOpts('is_nested', 'isNested'); + } + if (typeof opts.always_show_resize_handle !== 'undefined') { + opts.alwaysShowResizeHandle = opts.always_show_resize_handle; + obsoleteOpts('always_show_resize_handle', 'alwaysShowResizeHandle'); + } + // jscs:enable requireCamelCaseOrUpperCaseIdentifiers + + opts.itemClass = opts.itemClass || 'grid-stack-item'; + var isNested = this.container.closest('.' + opts.itemClass).length > 0; this.opts = _.defaults(opts || {}, { width: parseInt(this.container.attr('data-gs-width')) || 12, height: parseInt(this.container.attr('data-gs-height')) || 0, - item_class: 'grid-stack-item', - placeholder_class: 'grid-stack-placeholder', - placeholder_text: '', + itemClass: 'grid-stack-item', + placeholderClass: 'grid-stack-placeholder', + placeholderText: '', handle: '.grid-stack-item-content', - handle_class: null, - cell_height: 60, - vertical_margin: 20, + handleClass: null, + cellHeight: 60, + verticalMargin: 20, auto: true, - min_width: 768, + minWidth: 768, float: false, - static_grid: false, + staticGrid: false, _class: 'grid-stack-instance-' + (Math.random() * 10000).toFixed(0), animate: Boolean(this.container.attr('data-gs-animate')) || false, - always_show_resize_handle: opts.always_show_resize_handle || false, + alwaysShowResizeHandle: opts.alwaysShowResizeHandle || false, resizable: _.defaults(opts.resizable || {}, { - autoHide: !(opts.always_show_resize_handle || false), + autoHide: !(opts.alwaysShowResizeHandle || false), handles: 'se' }), draggable: _.defaults(opts.draggable || {}, { - handle: (opts.handle_class ? '.' + opts.handle_class : (opts.handle ? opts.handle : '')) || '.grid-stack-item-content', + 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, + rtl: 'auto', + removable: false, + removeTimeout: 2000, + verticalMarginUnit: 'px', + cellHeightUnit: 'px', + oneColumnModeClass: opts.oneColumnModeClass || 'grid-stack-one-column-mode', + ddPlugin: null }); - this.opts.is_nested = is_nested; + + if (this.opts.ddPlugin === false) { + this.opts.ddPlugin = GridStackDragDropPlugin; + } else if (this.opts.ddPlugin === null) { + this.opts.ddPlugin = _.first(GridStackDragDropPlugin.registeredPlugins) || GridStackDragDropPlugin; + } + + this.dd = new this.opts.ddPlugin(this); + + if (this.opts.rtl === 'auto') { + this.opts.rtl = this.container.css('direction') === 'rtl'; + } + + if (this.opts.rtl) { + this.container.addClass('grid-stack-rtl'); + } + + this.opts.isNested = isNested; + + isAutoCellHeight = this.opts.cellHeight === 'auto'; + if (isAutoCellHeight) { + self.cellHeight(self.cellWidth(), true); + } else { + this.cellHeight(this.opts.cellHeight, true); + } + this.verticalMargin(this.opts.verticalMargin, true); this.container.addClass(this.opts._class); - this._set_static_class(); + this._setStaticClass(); - if (is_nested) { + if (isNested) { this.container.addClass('grid-stack-nested'); } - this._init_styles(); + this._initStyles(); - this.grid = new GridStackEngine(this.opts.width, function(nodes) { - var max_height = 0; + this.grid = new GridStackEngine(this.opts.width, function(nodes, detachNode) { + detachNode = typeof detachNode === 'undefined' ? true : detachNode; + var maxHeight = 0; _.each(nodes, function(n) { - if (n._id == null) { - n.el.remove(); - } - else { + if (detachNode && n._id === null) { + if (n.el) { + n.el.remove(); + } + } else { n.el .attr('data-gs-x', n.x) .attr('data-gs-y', n.y) .attr('data-gs-width', n.width) .attr('data-gs-height', n.height); - max_height = Math.max(max_height, n.y + n.height); + maxHeight = Math.max(maxHeight, n.y + n.height); } }); - self._update_styles(max_height + 10); + self._updateStyles(maxHeight + 10); }, this.opts.float, this.opts.height); if (this.opts.auto) { var elements = []; var _this = this; - this.container.children('.' + this.opts.item_class + ':not(.' + this.opts.placeholder_class + ')').each(function(index, el) { + this.container.children('.' + this.opts.itemClass + ':not(.' + this.opts.placeholderClass + ')') + .each(function(index, el) { el = $(el); elements.push({ el: el, @@ -463,69 +678,216 @@ }); }); _.chain(elements).sortBy(function(x) { return x.i; }).each(function(i) { - self._prepare_element(i.el); + self._prepareElement(i.el); }).value(); } - this.set_animation(this.opts.animate); + this.setAnimation(this.opts.animate); this.placeholder = $( - '
' + - '
' + this.opts.placeholder_text + '
').hide(); + '
' + + '
' + this.opts.placeholderText + '
').hide(); - this.container.height( - this.grid.get_grid_height() * (this.opts.cell_height + this.opts.vertical_margin) - - this.opts.vertical_margin); + this._updateContainerHeight(); - this.on_resize_handler = function() { - if (self._is_one_column_mode()) { - if (one_column_mode) - return; + this._updateHeightsOnResize = _.throttle(function() { + self.cellHeight(self.cellWidth(), false); + }, 100); - one_column_mode = true; + this.onResizeHandler = function() { + if (isAutoCellHeight) { + self._updateHeightsOnResize(); + } - self.grid._sort_nodes(); + if (self._isOneColumnMode()) { + if (oneColumnMode) { + return; + } + self.container.addClass(self.opts.oneColumnModeClass); + oneColumnMode = true; + + self.grid._sortNodes(); _.each(self.grid.nodes, function(node) { self.container.append(node.el); - if (self.opts.static_grid) { + if (self.opts.staticGrid) { return; } - if (!node.no_move) { - node.el.draggable('disable'); + if (node.noMove || self.opts.disableDrag) { + self.dd.draggable(node.el, 'disable'); } - if (!node.no_resize) { - node.el.resizable('disable'); + if (node.noResize || self.opts.disableResize) { + self.dd.resizable(node.el, 'disable'); } + + node.el.trigger('resize'); }); - } - else { - if (!one_column_mode) + } else { + if (!oneColumnMode) { return; + } - one_column_mode = false; + self.container.removeClass(self.opts.oneColumnModeClass); + oneColumnMode = false; - if (self.opts.static_grid) { + if (self.opts.staticGrid) { return; } _.each(self.grid.nodes, function(node) { - if (!node.no_move) { - node.el.draggable('enable'); + if (!node.noMove && !self.opts.disableDrag) { + self.dd.draggable(node.el, 'enable'); } - if (!node.no_resize) { - node.el.resizable('enable'); + if (!node.noResize && !self.opts.disableResize) { + self.dd.resizable(node.el, 'enable'); } + + node.el.trigger('resize'); }); } }; - $(window).resize(this.on_resize_handler); - this.on_resize_handler(); + $(window).resize(this.onResizeHandler); + this.onResizeHandler(); + + if (!self.opts.staticGrid && typeof self.opts.removable === 'string') { + var trashZone = $(self.opts.removable); + if (!this.dd.isDroppable(trashZone)) { + this.dd.droppable(trashZone, { + accept: '.' + self.opts.itemClass + }); + } + this.dd + .on(trashZone, 'dropover', function(event, ui) { + var el = $(ui.draggable); + var node = el.data('_gridstack_node'); + if (node._grid !== self) { + return; + } + self._setupRemovingTimeout(el); + }) + .on(trashZone, 'dropout', function(event, ui) { + var el = $(ui.draggable); + var node = el.data('_gridstack_node'); + if (node._grid !== self) { + return; + } + self._clearRemovingTimeout(el); + }); + } + + if (!self.opts.staticGrid && self.opts.acceptWidgets) { + var draggingElement = null; + + var onDrag = function(event, ui) { + var el = draggingElement; + var node = el.data('_gridstack_node'); + var pos = self.getCellFromPixel(ui.offset, true); + var x = Math.max(0, pos.x); + var y = Math.max(0, pos.y); + if (!node._added) { + node._added = true; + + node.el = el; + node.x = x; + node.y = y; + self.grid.cleanNodes(); + self.grid.beginUpdate(node); + self.grid.addNode(node); + + self.container.append(self.placeholder); + self.placeholder + .attr('data-gs-x', node.x) + .attr('data-gs-y', node.y) + .attr('data-gs-width', node.width) + .attr('data-gs-height', node.height) + .show(); + node.el = self.placeholder; + node._beforeDragX = node.x; + node._beforeDragY = node.y; + + self._updateContainerHeight(); + } else { + if (!self.grid.canMoveNode(node, x, y)) { + return; + } + self.grid.moveNode(node, x, y); + self._updateContainerHeight(); + } + }; + + this.dd + .droppable(self.container, { + accept: function(el) { + el = $(el); + var node = el.data('_gridstack_node'); + if (node && node._grid === self) { + return false; + } + return el.is(self.opts.acceptWidgets === true ? '.grid-stack-item' : self.opts.acceptWidgets); + } + }) + .on(self.container, 'dropover', function(event, ui) { + var offset = self.container.offset(); + var el = $(ui.draggable); + var cellWidth = self.cellWidth(); + var cellHeight = self.cellHeight(); + var origNode = el.data('_gridstack_node'); + + var width = origNode ? origNode.width : (Math.ceil(el.outerWidth() / cellWidth)); + var height = origNode ? origNode.height : (Math.ceil(el.outerHeight() / cellHeight)); + + draggingElement = el; + + var node = self.grid._prepareNode({width: width, height: height, _added: false, _temporary: true}); + el.data('_gridstack_node', node); + el.data('_gridstack_node_orig', origNode); + + el.on('drag', onDrag); + }) + .on(self.container, 'dropout', function(event, ui) { + var el = $(ui.draggable); + el.unbind('drag', onDrag); + var node = el.data('_gridstack_node'); + node.el = null; + self.grid.removeNode(node); + self.placeholder.detach(); + self._updateContainerHeight(); + el.data('_gridstack_node', el.data('_gridstack_node_orig')); + }) + .on(self.container, 'drop', function(event, ui) { + self.placeholder.detach(); + + var node = $(ui.draggable).data('_gridstack_node'); + node._grid = self; + var el = $(ui.draggable).clone(false); + el.data('_gridstack_node', node); + $(ui.draggable).remove(); + node.el = el; + self.placeholder.hide(); + el + .attr('data-gs-x', node.x) + .attr('data-gs-y', node.y) + .attr('data-gs-width', node.width) + .attr('data-gs-height', node.height) + .addClass(self.opts.itemClass) + .removeAttr('style') + .enableSelection() + .removeData('draggable') + .removeClass('ui-draggable ui-draggable-dragging ui-draggable-disabled') + .unbind('drag', onDrag); + self.container.append(el); + self._prepareElementsByNode(el, node); + self._updateContainerHeight(); + self._triggerChangeEvent(); + + self.grid.endUpdate(); + }); + } }; - GridStack.prototype._trigger_change_event = function(forceTrigger) { - var elements = this.grid.get_dirty_nodes(); + GridStack.prototype._triggerChangeEvent = function(forceTrigger) { + var elements = this.grid.getDirtyNodes(); var hasChanges = false; var eventParams = []; @@ -539,126 +901,229 @@ } }; - GridStack.prototype._init_styles = function() { - if (this._styles_id) { - $('[data-gs-id="' + this._styles_id + '"]').remove(); + GridStack.prototype._triggerAddEvent = function() { + if (this.grid._addedNodes && this.grid._addedNodes.length > 0) { + this.container.trigger('added', [_.map(this.grid._addedNodes, _.clone)]); + this.grid._addedNodes = []; } - this._styles_id = 'gridstack-style-' + (Math.random() * 100000).toFixed(); - this._styles = Utils.create_stylesheet(this._styles_id); - if (this._styles != null) + }; + + GridStack.prototype._triggerRemoveEvent = function() { + if (this.grid._removedNodes && this.grid._removedNodes.length > 0) { + this.container.trigger('removed', [_.map(this.grid._removedNodes, _.clone)]); + this.grid._removedNodes = []; + } + }; + + GridStack.prototype._initStyles = function() { + if (this._stylesId) { + Utils.removeStylesheet(this._stylesId); + } + this._stylesId = 'gridstack-style-' + (Math.random() * 100000).toFixed(); + this._styles = Utils.createStylesheet(this._stylesId); + if (this._styles !== null) { this._styles._max = 0; + } }; - GridStack.prototype._update_styles = function(max_height) { - if (this._styles == null) { + GridStack.prototype._updateStyles = function(maxHeight) { + if (this._styles === null || typeof this._styles === 'undefined') { return; } - var prefix = '.' + this.opts._class + ' .' + this.opts.item_class; + var prefix = '.' + this.opts._class + ' .' + this.opts.itemClass; + var self = this; + var getHeight; + + if (typeof maxHeight == 'undefined') { + maxHeight = this._styles._max; + this._initStyles(); + this._updateContainerHeight(); + } + if (!this.opts.cellHeight) { // The rest will be handled by CSS + return ; + } + if (this._styles._max !== 0 && maxHeight <= this._styles._max) { + return ; + } - if (typeof max_height == 'undefined') { - max_height = this._styles._max; - this._init_styles(); - this._update_container_height(); + if (!this.opts.verticalMargin || this.opts.cellHeightUnit === this.opts.verticalMarginUnit) { + getHeight = function(nbRows, nbMargins) { + return (self.opts.cellHeight * nbRows + self.opts.verticalMargin * nbMargins) + + self.opts.cellHeightUnit; + }; + } else { + getHeight = function(nbRows, nbMargins) { + if (!nbRows || !nbMargins) { + return (self.opts.cellHeight * nbRows + self.opts.verticalMargin * nbMargins) + + self.opts.cellHeightUnit; + } + return 'calc(' + ((self.opts.cellHeight * nbRows) + self.opts.cellHeightUnit) + ' + ' + + ((self.opts.verticalMargin * nbMargins) + self.opts.verticalMarginUnit) + ')'; + }; } - if (this._styles._max == 0) { - Utils.insert_css_rule(this._styles, prefix, 'min-height: ' + (this.opts.cell_height) + 'px;', 0); + if (this._styles._max === 0) { + Utils.insertCSSRule(this._styles, prefix, 'min-height: ' + getHeight(1, 0) + ';', 0); } - if (max_height > this._styles._max) { - for (var i = this._styles._max; i < max_height; ++i) { - Utils.insert_css_rule(this._styles, + if (maxHeight > this._styles._max) { + for (var i = this._styles._max; i < maxHeight; ++i) { + Utils.insertCSSRule(this._styles, prefix + '[data-gs-height="' + (i + 1) + '"]', - 'height: ' + (this.opts.cell_height * (i + 1) + this.opts.vertical_margin * i) + 'px;', + 'height: ' + getHeight(i + 1, i) + ';', i ); - Utils.insert_css_rule(this._styles, + Utils.insertCSSRule(this._styles, prefix + '[data-gs-min-height="' + (i + 1) + '"]', - 'min-height: ' + (this.opts.cell_height * (i + 1) + this.opts.vertical_margin * i) + 'px;', + 'min-height: ' + getHeight(i + 1, i) + ';', i ); - Utils.insert_css_rule(this._styles, + Utils.insertCSSRule(this._styles, prefix + '[data-gs-max-height="' + (i + 1) + '"]', - 'max-height: ' + (this.opts.cell_height * (i + 1) + this.opts.vertical_margin * i) + 'px;', + 'max-height: ' + getHeight(i + 1, i) + ';', i ); - Utils.insert_css_rule(this._styles, + Utils.insertCSSRule(this._styles, prefix + '[data-gs-y="' + i + '"]', - 'top: ' + (this.opts.cell_height * i + this.opts.vertical_margin * i) + 'px;', + 'top: ' + getHeight(i, i) + ';', i ); } - this._styles._max = max_height; + this._styles._max = maxHeight; } }; - GridStack.prototype._update_container_height = function() { - if (this.grid._update_counter) { + GridStack.prototype._updateContainerHeight = function() { + if (this.grid._updateCounter) { return; } - this.container.height( - this.grid.get_grid_height() * (this.opts.cell_height + this.opts.vertical_margin) - - this.opts.vertical_margin); + var height = this.grid.getGridHeight(); + this.container.attr('data-gs-current-height', height); + if (!this.opts.cellHeight) { + return ; + } + if (!this.opts.verticalMargin) { + this.container.css('height', (height * (this.opts.cellHeight)) + this.opts.cellHeightUnit); + } else if (this.opts.cellHeightUnit === this.opts.verticalMarginUnit) { + this.container.css('height', (height * (this.opts.cellHeight + this.opts.verticalMargin) - + this.opts.verticalMargin) + this.opts.cellHeightUnit); + } else { + this.container.css('height', 'calc(' + ((height * (this.opts.cellHeight)) + this.opts.cellHeightUnit) + + ' + ' + ((height * (this.opts.verticalMargin - 1)) + this.opts.verticalMarginUnit) + ')'); + } }; - GridStack.prototype._is_one_column_mode = function() { + GridStack.prototype._isOneColumnMode = function() { return (window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth) <= - this.opts.min_width; + this.opts.minWidth; }; - GridStack.prototype._prepare_element = function(el) { + GridStack.prototype._setupRemovingTimeout = function(el) { var self = this; - el = $(el); + var node = $(el).data('_gridstack_node'); - el.addClass(this.opts.item_class); + if (node._removeTimeout || !self.opts.removable) { + return; + } + node._removeTimeout = setTimeout(function() { + el.addClass('grid-stack-item-removing'); + node._isAboutToRemove = true; + }, self.opts.removeTimeout); + }; - var node = self.grid.add_node({ - x: el.attr('data-gs-x'), - y: el.attr('data-gs-y'), - width: el.attr('data-gs-width'), - height: el.attr('data-gs-height'), - max_width: el.attr('data-gs-max-width'), - min_width: el.attr('data-gs-min-width'), - max_height: el.attr('data-gs-max-height'), - min_height: el.attr('data-gs-min-height'), - auto_position: Utils.toBool(el.attr('data-gs-auto-position')), - no_resize: Utils.toBool(el.attr('data-gs-no-resize')), - no_move: Utils.toBool(el.attr('data-gs-no-move')), - locked: Utils.toBool(el.attr('data-gs-locked')), - el: el - }); - el.data('_gridstack_node', node); + GridStack.prototype._clearRemovingTimeout = function(el) { + var node = $(el).data('_gridstack_node'); - if (self.opts.static_grid) { + if (!node._removeTimeout) { return; } + clearTimeout(node._removeTimeout); + node._removeTimeout = null; + el.removeClass('grid-stack-item-removing'); + node._isAboutToRemove = false; + }; + + GridStack.prototype._prepareElementsByNode = function(el, node) { + if (typeof $.ui === 'undefined') { + return; + } + var self = this; - var cell_width, cell_height; + var cellWidth; + var cellHeight; - var drag_or_resize = function(event, ui) { - var x = Math.round(ui.position.left / cell_width), - y = Math.floor((ui.position.top + cell_height / 2) / cell_height), - width, height; - if (event.type != "drag") { - width = Math.round(ui.size.width / cell_width); - height = Math.round(ui.size.height / cell_height); + var dragOrResize = function(event, ui) { + var x = Math.round(ui.position.left / cellWidth); + var y = Math.floor((ui.position.top + cellHeight / 2) / cellHeight); + var width; + var height; + + if (event.type != 'drag') { + width = Math.round(ui.size.width / cellWidth); + height = Math.round(ui.size.height / cellHeight); } - if (!self.grid.can_move_node(node, x, y, width, height)) { + if (event.type == 'drag') { + if (x < 0 || x >= self.grid.width || y < 0) { + if (self.opts.removable === true) { + self._setupRemovingTimeout(el); + } + + x = node._beforeDragX; + y = node._beforeDragY; + + self.placeholder.detach(); + self.placeholder.hide(); + self.grid.removeNode(node); + self._updateContainerHeight(); + + node._temporaryRemoved = true; + } else { + self._clearRemovingTimeout(el); + + if (node._temporaryRemoved) { + self.grid.addNode(node); + self.placeholder + .attr('data-gs-x', x) + .attr('data-gs-y', y) + .attr('data-gs-width', width) + .attr('data-gs-height', height) + .show(); + self.container.append(self.placeholder); + node.el = self.placeholder; + node._temporaryRemoved = false; + } + } + } else if (event.type == 'resize') { + if (x < 0) { + return; + } + } + // width and height are undefined if not resizing + var lastTriedWidth = typeof width !== 'undefined' ? width : node.lastTriedWidth; + var lastTriedHeight = typeof height !== 'undefined' ? height : node.lastTriedHeight; + if (!self.grid.canMoveNode(node, x, y, width, height) || + (node.lastTriedX === x && node.lastTriedY === y && + node.lastTriedWidth === lastTriedWidth && node.lastTriedHeight === lastTriedHeight)) { return; } - self.grid.move_node(node, x, y, width, height); - self._update_container_height(); + node.lastTriedX = x; + node.lastTriedY = y; + node.lastTriedWidth = width; + node.lastTriedHeight = height; + self.grid.moveNode(node, x, y, width, height); + self._updateContainerHeight(); }; - var on_start_moving = function(event, ui) { + var onStartMoving = function(event, ui) { self.container.append(self.placeholder); var o = $(this); - self.grid.clean_nodes(); - self.grid.begin_update(node); - cell_width = o.outerWidth() / o.attr('data-gs-width'); - cell_height = self.opts.cell_height + self.opts.vertical_margin; + self.grid.cleanNodes(); + self.grid.beginUpdate(node); + cellWidth = self.cellWidth(); + var strictCellHeight = Math.ceil(o.outerHeight() / o.attr('data-gs-height')); + cellHeight = self.container.height() / parseInt(self.container.attr('data-gs-current-height')); self.placeholder .attr('data-gs-x', o.attr('data-gs-x')) .attr('data-gs-y', o.attr('data-gs-y')) @@ -666,128 +1131,204 @@ .attr('data-gs-height', o.attr('data-gs-height')) .show(); node.el = self.placeholder; + node._beforeDragX = node.x; + node._beforeDragY = node.y; - el.resizable('option', 'minWidth', Math.round(cell_width * (node.min_width || 1))); - el.resizable('option', 'minHeight', self.opts.cell_height * (node.min_height || 1)); + self.dd.resizable(el, 'option', 'minWidth', cellWidth * (node.minWidth || 1)); + self.dd.resizable(el, 'option', 'minHeight', strictCellHeight * (node.minHeight || 1)); if (event.type == 'resizestart') { o.find('.grid-stack-item').trigger('resizestart'); } }; - var on_end_moving = function(event, ui) { - self.placeholder.detach(); + var onEndMoving = function(event, ui) { var o = $(this); + if (!o.data('_gridstack_node')) { + return; + } + + var forceNotify = false; + self.placeholder.detach(); node.el = o; self.placeholder.hide(); - o - .attr('data-gs-x', node.x) - .attr('data-gs-y', node.y) - .attr('data-gs-width', node.width) - .attr('data-gs-height', node.height) - .removeAttr('style'); - self._update_container_height(); - self._trigger_change_event(); - - self.grid.end_update(); - - var nested_grids = o.find('.grid-stack'); - if (nested_grids.length && event.type == 'resizestop') { - nested_grids.each(function(index, el) { - $(el).data('gridstack').on_resize_handler(); + + if (node._isAboutToRemove) { + forceNotify = true; + el.removeData('_gridstack_node'); + el.remove(); + } else { + self._clearRemovingTimeout(el); + if (!node._temporaryRemoved) { + o + .attr('data-gs-x', node.x) + .attr('data-gs-y', node.y) + .attr('data-gs-width', node.width) + .attr('data-gs-height', node.height) + .removeAttr('style'); + } else { + o + .attr('data-gs-x', node._beforeDragX) + .attr('data-gs-y', node._beforeDragY) + .attr('data-gs-width', node.width) + .attr('data-gs-height', node.height) + .removeAttr('style'); + node.x = node._beforeDragX; + node.y = node._beforeDragY; + self.grid.addNode(node); + } + } + self._updateContainerHeight(); + self._triggerChangeEvent(forceNotify); + + self.grid.endUpdate(); + + var nestedGrids = o.find('.grid-stack'); + if (nestedGrids.length && event.type == 'resizestop') { + nestedGrids.each(function(index, el) { + $(el).data('gridstack').onResizeHandler(); }); o.find('.grid-stack-item').trigger('resizestop'); } }; - el - .draggable(_.extend(this.opts.draggable, { - containment: this.opts.is_nested ? this.container.parent() : null - })) - .on('dragstart', on_start_moving) - .on('dragstop', on_end_moving) - .on('drag', drag_or_resize) - .resizable(_.extend(this.opts.resizable, {})) - .on('resizestart', on_start_moving) - .on('resizestop', on_end_moving) - .on('resize', drag_or_resize); + this.dd + .draggable(el, { + start: onStartMoving, + stop: onEndMoving, + drag: dragOrResize + }) + .resizable(el, { + start: onStartMoving, + stop: onEndMoving, + resize: dragOrResize + }); - if (node.no_move || this._is_one_column_mode()) { - el.draggable('disable'); + if (node.noMove || this._isOneColumnMode() || this.opts.disableDrag) { + this.dd.draggable(el, 'disable'); } - if (node.no_resize || this._is_one_column_mode()) { - el.resizable('disable'); + if (node.noResize || this._isOneColumnMode() || this.opts.disableResize) { + this.dd.resizable(el, 'disable'); } el.attr('data-gs-locked', node.locked ? 'yes' : null); }; - GridStack.prototype.set_animation = function(enable) { + GridStack.prototype._prepareElement = function(el, triggerAddEvent) { + triggerAddEvent = typeof triggerAddEvent != 'undefined' ? triggerAddEvent : false; + var self = this; + el = $(el); + + el.addClass(this.opts.itemClass); + var node = self.grid.addNode({ + x: el.attr('data-gs-x'), + y: el.attr('data-gs-y'), + width: el.attr('data-gs-width'), + height: el.attr('data-gs-height'), + maxWidth: el.attr('data-gs-max-width'), + minWidth: el.attr('data-gs-min-width'), + maxHeight: el.attr('data-gs-max-height'), + minHeight: el.attr('data-gs-min-height'), + autoPosition: Utils.toBool(el.attr('data-gs-auto-position')), + noResize: Utils.toBool(el.attr('data-gs-no-resize')), + noMove: Utils.toBool(el.attr('data-gs-no-move')), + locked: Utils.toBool(el.attr('data-gs-locked')), + el: el, + id: el.attr('data-gs-id'), + _grid: self + }, triggerAddEvent); + el.data('_gridstack_node', node); + + this._prepareElementsByNode(el, node); + }; + + GridStack.prototype.setAnimation = function(enable) { if (enable) { this.container.addClass('grid-stack-animate'); - } - else { + } else { this.container.removeClass('grid-stack-animate'); } }; - GridStack.prototype.add_widget = function(el, x, y, width, height, auto_position) { + GridStack.prototype.addWidget = function(el, x, y, width, height, autoPosition, minWidth, maxWidth, + minHeight, maxHeight, id) { el = $(el); - if (typeof x != 'undefined') el.attr('data-gs-x', x); - if (typeof y != 'undefined') el.attr('data-gs-y', y); - if (typeof width != 'undefined') el.attr('data-gs-width', width); - if (typeof height != 'undefined') el.attr('data-gs-height', height); - if (typeof auto_position != 'undefined') el.attr('data-gs-auto-position', auto_position ? 'yes' : null); + if (typeof x != 'undefined') { el.attr('data-gs-x', x); } + if (typeof y != 'undefined') { el.attr('data-gs-y', y); } + if (typeof width != 'undefined') { el.attr('data-gs-width', width); } + if (typeof height != 'undefined') { el.attr('data-gs-height', height); } + if (typeof autoPosition != 'undefined') { el.attr('data-gs-auto-position', autoPosition ? 'yes' : null); } + if (typeof minWidth != 'undefined') { el.attr('data-gs-min-width', minWidth); } + if (typeof maxWidth != 'undefined') { el.attr('data-gs-max-width', maxWidth); } + if (typeof minHeight != 'undefined') { el.attr('data-gs-min-height', minHeight); } + if (typeof maxHeight != 'undefined') { el.attr('data-gs-max-height', maxHeight); } + if (typeof id != 'undefined') { el.attr('data-gs-id', id); } this.container.append(el); - this._prepare_element(el); - this._update_container_height(); - this._trigger_change_event(true); + this._prepareElement(el, true); + this._triggerAddEvent(); + this._updateContainerHeight(); + this._triggerChangeEvent(true); return el; }; - GridStack.prototype.make_widget = function(el) { + GridStack.prototype.makeWidget = function(el) { el = $(el); - this._prepare_element(el); - this._update_container_height(); - this._trigger_change_event(true); + this._prepareElement(el, true); + this._triggerAddEvent(); + this._updateContainerHeight(); + this._triggerChangeEvent(true); return el; }; - GridStack.prototype.will_it_fit = function(x, y, width, height, auto_position) { - var node = {x: x, y: y, width: width, height: height, auto_position: auto_position}; - return this.grid.can_be_placed_with_respect_to_height(node); + GridStack.prototype.willItFit = function(x, y, width, height, autoPosition) { + var node = {x: x, y: y, width: width, height: height, autoPosition: autoPosition}; + return this.grid.canBePlacedWithRespectToHeight(node); }; - GridStack.prototype.remove_widget = function(el, detach_node) { - detach_node = typeof detach_node === 'undefined' ? true : detach_node; + GridStack.prototype.removeWidget = function(el, detachNode) { + detachNode = typeof detachNode === 'undefined' ? true : detachNode; el = $(el); var node = el.data('_gridstack_node'); - this.grid.remove_node(node); + + // For Meteor support: https://github.com/troolee/gridstack.js/pull/272 + if (!node) { + node = this.grid.getNodeDataByDOMEl(el); + } + + this.grid.removeNode(node, detachNode); el.removeData('_gridstack_node'); - this._update_container_height(); - if (detach_node) + this._updateContainerHeight(); + if (detachNode) { el.remove(); - this._trigger_change_event(true); + } + this._triggerChangeEvent(true); + this._triggerRemoveEvent(); }; - GridStack.prototype.remove_all = function(detach_node) { + GridStack.prototype.removeAll = function(detachNode) { _.each(this.grid.nodes, _.bind(function(node) { - this.remove_widget(node.el, detach_node); + this.removeWidget(node.el, detachNode); }, this)); this.grid.nodes = []; - this._update_container_height(); + this._updateContainerHeight(); }; - GridStack.prototype.destroy = function() { - $(window).off("resize", this.on_resize_handler); + GridStack.prototype.destroy = function(detachGrid) { + $(window).off('resize', this.onResizeHandler); this.disable(); - this.container.remove(); - Utils.remove_stylesheet(this._styles_id); - if (this.grid) + if (typeof detachGrid != 'undefined' && !detachGrid) { + this.removeAll(false); + this.container.removeData('gridstack'); + } else { + this.container.remove(); + } + Utils.removeStylesheet(this._stylesId); + if (this.grid) { this.grid = null; + } }; GridStack.prototype.resizable = function(el, val) { @@ -796,16 +1337,15 @@ el.each(function(index, el) { el = $(el); var node = el.data('_gridstack_node'); - if (typeof node == 'undefined' || node == null) { + if (typeof node == 'undefined' || node === null || typeof $.ui === 'undefined') { return; } - node.no_resize = !(val || false); - if (node.no_resize || self._is_one_column_mode()) { - el.resizable('disable'); - } - else { - el.resizable('enable'); + node.noResize = !(val || false); + if (node.noResize || self._isOneColumnMode()) { + self.dd.resizable(el, 'disable'); + } else { + self.dd.resizable(el, 'enable'); } }); return this; @@ -817,32 +1357,45 @@ el.each(function(index, el) { el = $(el); var node = el.data('_gridstack_node'); - if (typeof node == 'undefined' || node == null) { + if (typeof node == 'undefined' || node === null || typeof $.ui === 'undefined') { return; } - node.no_move = !(val || false); - if (node.no_move || self._is_one_column_mode()) { - el.draggable('disable'); + node.noMove = !(val || false); + if (node.noMove || self._isOneColumnMode()) { + self.dd.draggable(el, 'disable'); el.removeClass('ui-draggable-handle'); - } - else { - el.draggable('enable'); + } else { + self.dd.draggable(el, 'enable'); el.addClass('ui-draggable-handle'); } }); return this; }; + GridStack.prototype.enableMove = function(doEnable, includeNewWidgets) { + this.movable(this.container.children('.' + this.opts.itemClass), doEnable); + if (includeNewWidgets) { + this.opts.disableDrag = !doEnable; + } + }; + + GridStack.prototype.enableResize = function(doEnable, includeNewWidgets) { + this.resizable(this.container.children('.' + this.opts.itemClass), doEnable); + if (includeNewWidgets) { + this.opts.disableResize = !doEnable; + } + }; + GridStack.prototype.disable = function() { - this.movable(this.container.children('.' + this.opts.item_class), false); - this.resizable(this.container.children('.' + this.opts.item_class), false); + this.movable(this.container.children('.' + this.opts.itemClass), false); + this.resizable(this.container.children('.' + this.opts.itemClass), false); this.container.trigger('disable'); }; GridStack.prototype.enable = function() { - this.movable(this.container.children('.' + this.opts.item_class), true); - this.resizable(this.container.children('.' + this.opts.item_class), true); + this.movable(this.container.children('.' + this.opts.itemClass), true); + this.resizable(this.container.children('.' + this.opts.itemClass), true); this.container.trigger('enable'); }; @@ -851,7 +1404,7 @@ el.each(function(index, el) { el = $(el); var node = el.data('_gridstack_node'); - if (typeof node == 'undefined' || node == null) { + if (typeof node == 'undefined' || node === null) { return; } @@ -861,164 +1414,322 @@ return this; }; - GridStack.prototype.min_height = function (el, val) { - el = $(el); - el.each(function (index, el) { - el = $(el); - var node = el.data('_gridstack_node'); - if (typeof node == 'undefined' || node == null) { - return; - } - - if(!isNaN(val)){ - node.min_height = (val || false); - el.attr('data-gs-min-height', val); - } - }); - return this; - }; - - GridStack.prototype.min_width = function (el, val) { - el = $(el); - el.each(function (index, el) { - el = $(el); - var node = el.data('_gridstack_node'); - if (typeof node == 'undefined' || node == null) { - return; - } - - if(!isNaN(val)){ - node.min_width = (val || false); - el.attr('data-gs-min-width', val); - } - }); - return this; - }; - - GridStack.prototype._update_element = function(el, callback) { + GridStack.prototype.maxHeight = function(el, val) { + el = $(el); + el.each(function(index, el) { + el = $(el); + var node = el.data('_gridstack_node'); + if (typeof node === 'undefined' || node === null) { + return; + } + + if (!isNaN(val)) { + node.maxHeight = (val || false); + el.attr('data-gs-max-height', val); + } + }); + return this; + }; + + GridStack.prototype.minHeight = function(el, val) { + el = $(el); + el.each(function(index, el) { + el = $(el); + var node = el.data('_gridstack_node'); + if (typeof node === 'undefined' || node === null) { + return; + } + + if (!isNaN(val)) { + node.minHeight = (val || false); + el.attr('data-gs-min-height', val); + } + }); + return this; + }; + + GridStack.prototype.maxWidth = function(el, val) { + el = $(el); + el.each(function(index, el) { + el = $(el); + var node = el.data('_gridstack_node'); + if (typeof node === 'undefined' || node === null) { + return; + } + + if (!isNaN(val)) { + node.maxWidth = (val || false); + el.attr('data-gs-max-width', val); + } + }); + return this; + }; + + GridStack.prototype.minWidth = function(el, val) { + el = $(el); + el.each(function(index, el) { + el = $(el); + var node = el.data('_gridstack_node'); + if (typeof node === 'undefined' || node === null) { + return; + } + + if (!isNaN(val)) { + node.minWidth = (val || false); + el.attr('data-gs-min-width', val); + } + }); + return this; + }; + + GridStack.prototype._updateElement = function(el, callback) { el = $(el).first(); var node = el.data('_gridstack_node'); - if (typeof node == 'undefined' || node == null) { + if (typeof node == 'undefined' || node === null) { return; } var self = this; - self.grid.clean_nodes(); - self.grid.begin_update(node); + self.grid.cleanNodes(); + self.grid.beginUpdate(node); callback.call(this, el, node); - self._update_container_height(); - self._trigger_change_event(); + self._updateContainerHeight(); + self._triggerChangeEvent(); - self.grid.end_update(); + self.grid.endUpdate(); }; GridStack.prototype.resize = function(el, width, height) { - this._update_element(el, function(el, node) { - width = (width != null && typeof width != 'undefined') ? width : node.width; - height = (height != null && typeof height != 'undefined') ? height : node.height; + this._updateElement(el, function(el, node) { + width = (width !== null && typeof width != 'undefined') ? width : node.width; + height = (height !== null && typeof height != 'undefined') ? height : node.height; - this.grid.move_node(node, node.x, node.y, width, height); + this.grid.moveNode(node, node.x, node.y, width, height); }); }; GridStack.prototype.move = function(el, x, y) { - this._update_element(el, function(el, node) { - x = (x != null && typeof x != 'undefined') ? x : node.x; - y = (y != null && typeof y != 'undefined') ? y : node.y; + this._updateElement(el, function(el, node) { + x = (x !== null && typeof x != 'undefined') ? x : node.x; + y = (y !== null && typeof y != 'undefined') ? y : node.y; - this.grid.move_node(node, x, y, node.width, node.height); + this.grid.moveNode(node, x, y, node.width, node.height); }); }; GridStack.prototype.update = function(el, x, y, width, height) { - this._update_element(el, function(el, node) { - x = (x != null && typeof x != 'undefined') ? x : node.x; - y = (y != null && typeof y != 'undefined') ? y : node.y; - width = (width != null && typeof width != 'undefined') ? width : node.width; - height = (height != null && typeof height != 'undefined') ? height : node.height; + this._updateElement(el, function(el, node) { + x = (x !== null && typeof x != 'undefined') ? x : node.x; + y = (y !== null && typeof y != 'undefined') ? y : node.y; + width = (width !== null && typeof width != 'undefined') ? width : node.width; + height = (height !== null && typeof height != 'undefined') ? height : node.height; - this.grid.move_node(node, x, y, width, height); + this.grid.moveNode(node, x, y, width, height); }); }; - GridStack.prototype.cell_height = function(val) { + GridStack.prototype.verticalMargin = function(val, noUpdate) { if (typeof val == 'undefined') { - return this.opts.cell_height; + return this.opts.verticalMargin; } - val = parseInt(val); - if (val == this.opts.cell_height) - return; - this.opts.cell_height = val || this.opts.cell_height; - this._update_styles(); + + var heightData = Utils.parseHeight(val); + + if (this.opts.verticalMarginUnit === heightData.unit && this.opts.height === heightData.height) { + return ; + } + this.opts.verticalMarginUnit = heightData.unit; + this.opts.verticalMargin = heightData.height; + + if (!noUpdate) { + this._updateStyles(); + } + }; + + GridStack.prototype.cellHeight = function(val, noUpdate) { + if (typeof val == 'undefined') { + if (this.opts.cellHeight) { + return this.opts.cellHeight; + } + var o = this.container.children('.' + this.opts.itemClass).first(); + return Math.ceil(o.outerHeight() / o.attr('data-gs-height')); + } + var heightData = Utils.parseHeight(val); + + if (this.opts.cellHeightUnit === heightData.heightUnit && this.opts.height === heightData.height) { + return ; + } + this.opts.cellHeightUnit = heightData.unit; + this.opts.cellHeight = heightData.height; + + if (!noUpdate) { + this._updateStyles(); + } + }; - GridStack.prototype.cell_width = function() { - var o = this.container.children('.' + this.opts.item_class).first(); - return Math.ceil(o.outerWidth() / o.attr('data-gs-width')); + GridStack.prototype.cellWidth = function() { + return Math.round(this.container.outerWidth() / this.opts.width); }; - GridStack.prototype.get_cell_from_pixel = function(position) { - var containerPos = this.container.position(); + GridStack.prototype.getCellFromPixel = function(position, useOffset) { + var containerPos = (typeof useOffset != 'undefined' && useOffset) ? + this.container.offset() : this.container.position(); var relativeLeft = position.left - containerPos.left; var relativeTop = position.top - containerPos.top; - var column_width = Math.floor(this.container.width() / this.opts.width); - var row_height = this.opts.cell_height + this.opts.vertical_margin; + var columnWidth = Math.floor(this.container.width() / this.opts.width); + var rowHeight = Math.floor(this.container.height() / parseInt(this.container.attr('data-gs-current-height'))); - return {x: Math.floor(relativeLeft / column_width), y: Math.floor(relativeTop / row_height)}; + return {x: Math.floor(relativeLeft / columnWidth), y: Math.floor(relativeTop / rowHeight)}; }; - GridStack.prototype.batch_update = function() { - this.grid.batch_update(); + GridStack.prototype.batchUpdate = function() { + this.grid.batchUpdate(); }; GridStack.prototype.commit = function() { this.grid.commit(); - this._update_container_height(); + this._updateContainerHeight(); }; - GridStack.prototype.is_area_empty = function(x, y, width, height) { - return this.grid.is_area_empty(x, y, width, height); + GridStack.prototype.isAreaEmpty = function(x, y, width, height) { + return this.grid.isAreaEmpty(x, y, width, height); }; - GridStack.prototype.set_static = function(static_value) { - this.opts.static_grid = (static_value === true); - this._set_static_class(); + GridStack.prototype.setStatic = function(staticValue) { + this.opts.staticGrid = (staticValue === true); + this.enableMove(!staticValue); + this.enableResize(!staticValue); + this._setStaticClass(); }; - GridStack.prototype._set_static_class = function() { - var static_class_name = 'grid-stack-static'; + GridStack.prototype._setStaticClass = function() { + var staticClassName = 'grid-stack-static'; - if (this.opts.static_grid === true) { - this.container.addClass(static_class_name); + if (this.opts.staticGrid === true) { + this.container.addClass(staticClassName); } else { - this.container.removeClass(static_class_name); + this.container.removeClass(staticClassName); } }; + GridStack.prototype._updateNodeWidths = function(oldWidth, newWidth) { + this.grid._sortNodes(); + this.grid.batchUpdate(); + var node = {}; + for (var i = 0; i < this.grid.nodes.length; i++) { + node = this.grid.nodes[i]; + this.update(node.el, Math.round(node.x * newWidth / oldWidth), undefined, + Math.round(node.width * newWidth / oldWidth), undefined); + } + this.grid.commit(); + }; + + GridStack.prototype.setGridWidth = function(gridWidth,doNotPropagate) { + this.container.removeClass('grid-stack-' + this.opts.width); + if (doNotPropagate !== true) { + this._updateNodeWidths(this.opts.width, gridWidth); + } + this.opts.width = gridWidth; + this.grid.width = gridWidth; + this.container.addClass('grid-stack-' + gridWidth); + }; + + // jscs:disable requireCamelCaseOrUpperCaseIdentifiers + GridStackEngine.prototype.batch_update = obsolete(GridStackEngine.prototype.batchUpdate); + GridStackEngine.prototype._fix_collisions = obsolete(GridStackEngine.prototype._fixCollisions, + '_fix_collisions', '_fixCollisions'); + GridStackEngine.prototype.is_area_empty = obsolete(GridStackEngine.prototype.isAreaEmpty, + 'is_area_empty', 'isAreaEmpty'); + GridStackEngine.prototype._sort_nodes = obsolete(GridStackEngine.prototype._sortNodes, + '_sort_nodes', '_sortNodes'); + GridStackEngine.prototype._pack_nodes = obsolete(GridStackEngine.prototype._packNodes, + '_pack_nodes', '_packNodes'); + GridStackEngine.prototype._prepare_node = obsolete(GridStackEngine.prototype._prepareNode, + '_prepare_node', '_prepareNode'); + GridStackEngine.prototype.clean_nodes = obsolete(GridStackEngine.prototype.cleanNodes, + 'clean_nodes', 'cleanNodes'); + GridStackEngine.prototype.get_dirty_nodes = obsolete(GridStackEngine.prototype.getDirtyNodes, + 'get_dirty_nodes', 'getDirtyNodes'); + GridStackEngine.prototype.add_node = obsolete(GridStackEngine.prototype.addNode, + 'add_node', 'addNode, '); + GridStackEngine.prototype.remove_node = obsolete(GridStackEngine.prototype.removeNode, + 'remove_node', 'removeNode'); + GridStackEngine.prototype.can_move_node = obsolete(GridStackEngine.prototype.canMoveNode, + 'can_move_node', 'canMoveNode'); + GridStackEngine.prototype.move_node = obsolete(GridStackEngine.prototype.moveNode, + 'move_node', 'moveNode'); + GridStackEngine.prototype.get_grid_height = obsolete(GridStackEngine.prototype.getGridHeight, + 'get_grid_height', 'getGridHeight'); + GridStackEngine.prototype.begin_update = obsolete(GridStackEngine.prototype.beginUpdate, + 'begin_update', 'beginUpdate'); + GridStackEngine.prototype.end_update = obsolete(GridStackEngine.prototype.endUpdate, + 'end_update', 'endUpdate'); + GridStackEngine.prototype.can_be_placed_with_respect_to_height = + obsolete(GridStackEngine.prototype.canBePlacedWithRespectToHeight, + 'can_be_placed_with_respect_to_height', 'canBePlacedWithRespectToHeight'); + GridStack.prototype._trigger_change_event = obsolete(GridStack.prototype._triggerChangeEvent, + '_trigger_change_event', '_triggerChangeEvent'); + GridStack.prototype._init_styles = obsolete(GridStack.prototype._initStyles, + '_init_styles', '_initStyles'); + GridStack.prototype._update_styles = obsolete(GridStack.prototype._updateStyles, + '_update_styles', '_updateStyles'); + GridStack.prototype._update_container_height = obsolete(GridStack.prototype._updateContainerHeight, + '_update_container_height', '_updateContainerHeight'); + GridStack.prototype._is_one_column_mode = obsolete(GridStack.prototype._isOneColumnMode, + '_is_one_column_mode','_isOneColumnMode'); + GridStack.prototype._prepare_element = obsolete(GridStack.prototype._prepareElement, + '_prepare_element', '_prepareElement'); + GridStack.prototype.set_animation = obsolete(GridStack.prototype.setAnimation, + 'set_animation', 'setAnimation'); + GridStack.prototype.add_widget = obsolete(GridStack.prototype.addWidget, + 'add_widget', 'addWidget'); + GridStack.prototype.make_widget = obsolete(GridStack.prototype.makeWidget, + 'make_widget', 'makeWidget'); + GridStack.prototype.will_it_fit = obsolete(GridStack.prototype.willItFit, + 'will_it_fit', 'willItFit'); + GridStack.prototype.remove_widget = obsolete(GridStack.prototype.removeWidget, + 'remove_widget', 'removeWidget'); + GridStack.prototype.remove_all = obsolete(GridStack.prototype.removeAll, + 'remove_all', 'removeAll'); + GridStack.prototype.min_height = obsolete(GridStack.prototype.minHeight, + 'min_height', 'minHeight'); + GridStack.prototype.min_width = obsolete(GridStack.prototype.minWidth, + 'min_width', 'minWidth'); + GridStack.prototype._update_element = obsolete(GridStack.prototype._updateElement, + '_update_element', '_updateElement'); + GridStack.prototype.cell_height = obsolete(GridStack.prototype.cellHeight, + 'cell_height', 'cellHeight'); + GridStack.prototype.cell_width = obsolete(GridStack.prototype.cellWidth, + 'cell_width', 'cellWidth'); + GridStack.prototype.get_cell_from_pixel = obsolete(GridStack.prototype.getCellFromPixel, + 'get_cell_from_pixel', 'getCellFromPixel'); + GridStack.prototype.batch_update = obsolete(GridStack.prototype.batchUpdate, + 'batch_update', 'batchUpdate'); + GridStack.prototype.is_area_empty = obsolete(GridStack.prototype.isAreaEmpty, + 'is_area_empty', 'isAreaEmpty'); + GridStack.prototype.set_static = obsolete(GridStack.prototype.setStatic, + 'set_static', 'setStatic'); + GridStack.prototype._set_static_class = obsolete(GridStack.prototype._setStaticClass, + '_set_static_class', '_setStaticClass'); + // jscs:enable requireCamelCaseOrUpperCaseIdentifiers + scope.GridStackUI = GridStack; scope.GridStackUI.Utils = Utils; + scope.GridStackUI.Engine = GridStackEngine; + scope.GridStackUI.GridStackDragDropPlugin = GridStackDragDropPlugin; - function event_stop_propagate(event) { - event.stopPropagation(); - } $.fn.gridstack = function(opts) { return this.each(function() { var o = $(this); if (!o.data('gridstack')) { o - .data('gridstack', new GridStack(this, opts)) - .on('dragstart', event_stop_propagate) - .on('dragstop', event_stop_propagate) - .on('drag', event_stop_propagate) - .on('resizestart', event_stop_propagate) - .on('resizestop', event_stop_propagate) - .on('resize', event_stop_propagate) - .on('change', event_stop_propagate); + .data('gridstack', new GridStack(this, opts)); } }); }; diff --git a/dist/gridstack.min.css b/dist/gridstack.min.css index 9a0775e65..7a66c58ad 100644 --- a/dist/gridstack.min.css +++ b/dist/gridstack.min.css @@ -1 +1 @@ -:root .grid-stack-item>.ui-resizable-handle{filter:none}.grid-stack{position:relative}.grid-stack .grid-stack-placeholder>.placeholder-content{border:1px dashed #d3d3d3;margin:0;position:absolute;top:0;left:10px;right:10px;bottom:0;width:auto;z-index:0!important;text-align:center}.grid-stack>.grid-stack-item{min-width:8.3333333333%;position:absolute;padding:0}.grid-stack>.grid-stack-item>.grid-stack-item-content{margin:0;position:absolute;top:0;left:10px;right:10px;bottom:0;width:auto;z-index:0!important;overflow-x:hidden;overflow-y:auto}.grid-stack>.grid-stack-item>.ui-resizable-handle{position:absolute;font-size:.1px;display:block;-ms-touch-action:none;touch-action:none}.grid-stack>.grid-stack-item.ui-resizable-autohide>.ui-resizable-handle,.grid-stack>.grid-stack-item.ui-resizable-disabled>.ui-resizable-handle{display:none}.grid-stack>.grid-stack-item.ui-draggable-dragging,.grid-stack>.grid-stack-item.ui-resizable-resizing{z-index:100}.grid-stack>.grid-stack-item.ui-draggable-dragging>.grid-stack-item-content,.grid-stack>.grid-stack-item.ui-resizable-resizing>.grid-stack-item-content{box-shadow:1px 4px 6px rgba(0,0,0,.2);opacity:.8}.grid-stack>.grid-stack-item>.ui-resizable-se,.grid-stack>.grid-stack-item>.ui-resizable-sw{text-align:right;color:gray;padding:2px 3px 0 0;margin:0;font:normal normal normal 10px/1 FontAwesome;font-size:inherit;text-rendering:auto;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.grid-stack>.grid-stack-item>.ui-resizable-se::before,.grid-stack>.grid-stack-item>.ui-resizable-sw::before{content:"\f065"}.grid-stack>.grid-stack-item>.ui-resizable-nw{cursor:nw-resize;width:20px;height:20px;left:10px;top:0}.grid-stack>.grid-stack-item>.ui-resizable-n{cursor:n-resize;height:10px;top:0;left:25px;right:25px}.grid-stack>.grid-stack-item>.ui-resizable-ne{cursor:ne-resize;width:20px;height:20px;right:10px;top:0}.grid-stack>.grid-stack-item>.ui-resizable-e{cursor:e-resize;width:10px;right:10px;top:15px;bottom:15px}.grid-stack>.grid-stack-item>.ui-resizable-se{display:inline-block;-webkit-transform:rotate(90deg);-moz-transform:rotate(90deg);-ms-transform:rotate(90deg);-o-transform:rotate(90deg);transform:rotate(90deg);cursor:se-resize;width:20px;height:20px;right:10px;bottom:0}.grid-stack>.grid-stack-item>.ui-resizable-s{cursor:s-resize;height:10px;left:25px;bottom:0;right:25px}.grid-stack>.grid-stack-item>.ui-resizable-sw{cursor:sw-resize;width:20px;height:20px;left:10px;bottom:0}.grid-stack>.grid-stack-item>.ui-resizable-w{cursor:w-resize;width:10px;left:10px;top:15px;bottom:15px}.grid-stack>.grid-stack-item[data-gs-width='1']{width:8.3333333333%}.grid-stack>.grid-stack-item[data-gs-x='1']{left:8.3333333333%}.grid-stack>.grid-stack-item[data-gs-min-width='1']{min-width:8.3333333333%}.grid-stack>.grid-stack-item[data-gs-max-width='1']{max-width:8.3333333333%}.grid-stack>.grid-stack-item[data-gs-width='2']{width:16.6666666667%}.grid-stack>.grid-stack-item[data-gs-x='2']{left:16.6666666667%}.grid-stack>.grid-stack-item[data-gs-min-width='2']{min-width:16.6666666667%}.grid-stack>.grid-stack-item[data-gs-max-width='2']{max-width:16.6666666667%}.grid-stack>.grid-stack-item[data-gs-width='3']{width:25%}.grid-stack>.grid-stack-item[data-gs-x='3']{left:25%}.grid-stack>.grid-stack-item[data-gs-min-width='3']{min-width:25%}.grid-stack>.grid-stack-item[data-gs-max-width='3']{max-width:25%}.grid-stack>.grid-stack-item[data-gs-width='4']{width:33.3333333333%}.grid-stack>.grid-stack-item[data-gs-x='4']{left:33.3333333333%}.grid-stack>.grid-stack-item[data-gs-min-width='4']{min-width:33.3333333333%}.grid-stack>.grid-stack-item[data-gs-max-width='4']{max-width:33.3333333333%}.grid-stack>.grid-stack-item[data-gs-width='5']{width:41.6666666667%}.grid-stack>.grid-stack-item[data-gs-x='5']{left:41.6666666667%}.grid-stack>.grid-stack-item[data-gs-min-width='5']{min-width:41.6666666667%}.grid-stack>.grid-stack-item[data-gs-max-width='5']{max-width:41.6666666667%}.grid-stack>.grid-stack-item[data-gs-width='6']{width:50%}.grid-stack>.grid-stack-item[data-gs-x='6']{left:50%}.grid-stack>.grid-stack-item[data-gs-min-width='6']{min-width:50%}.grid-stack>.grid-stack-item[data-gs-max-width='6']{max-width:50%}.grid-stack>.grid-stack-item[data-gs-width='7']{width:58.3333333333%}.grid-stack>.grid-stack-item[data-gs-x='7']{left:58.3333333333%}.grid-stack>.grid-stack-item[data-gs-min-width='7']{min-width:58.3333333333%}.grid-stack>.grid-stack-item[data-gs-max-width='7']{max-width:58.3333333333%}.grid-stack>.grid-stack-item[data-gs-width='8']{width:66.6666666667%}.grid-stack>.grid-stack-item[data-gs-x='8']{left:66.6666666667%}.grid-stack>.grid-stack-item[data-gs-min-width='8']{min-width:66.6666666667%}.grid-stack>.grid-stack-item[data-gs-max-width='8']{max-width:66.6666666667%}.grid-stack>.grid-stack-item[data-gs-width='9']{width:75%}.grid-stack>.grid-stack-item[data-gs-x='9']{left:75%}.grid-stack>.grid-stack-item[data-gs-min-width='9']{min-width:75%}.grid-stack>.grid-stack-item[data-gs-max-width='9']{max-width:75%}.grid-stack>.grid-stack-item[data-gs-width='10']{width:83.3333333333%}.grid-stack>.grid-stack-item[data-gs-x='10']{left:83.3333333333%}.grid-stack>.grid-stack-item[data-gs-min-width='10']{min-width:83.3333333333%}.grid-stack>.grid-stack-item[data-gs-max-width='10']{max-width:83.3333333333%}.grid-stack>.grid-stack-item[data-gs-width='11']{width:91.6666666667%}.grid-stack>.grid-stack-item[data-gs-x='11']{left:91.6666666667%}.grid-stack>.grid-stack-item[data-gs-min-width='11']{min-width:91.6666666667%}.grid-stack>.grid-stack-item[data-gs-max-width='11']{max-width:91.6666666667%}.grid-stack>.grid-stack-item[data-gs-width='12']{width:100%}.grid-stack>.grid-stack-item[data-gs-x='12']{left:100%}.grid-stack>.grid-stack-item[data-gs-min-width='12']{min-width:100%}.grid-stack>.grid-stack-item[data-gs-max-width='12']{max-width:100%}.grid-stack.grid-stack-animate,.grid-stack.grid-stack-animate .grid-stack-item{-webkit-transition:left .3s,top .3s,height .3s,width .3s;-moz-transition:left .3s,top .3s,height .3s,width .3s;-ms-transition:left .3s,top .3s,height .3s,width .3s;-o-transition:left .3s,top .3s,height .3s,width .3s;transition:left .3s,top .3s,height .3s,width .3s}.grid-stack.grid-stack-animate .grid-stack-item.grid-stack-placeholder,.grid-stack.grid-stack-animate .grid-stack-item.ui-draggable-dragging,.grid-stack.grid-stack-animate .grid-stack-item.ui-resizable-resizing{-webkit-transition:left 0s,top 0s,height 0s,width 0s;-moz-transition:left 0s,top 0s,height 0s,width 0s;-ms-transition:left 0s,top 0s,height 0s,width 0s;-o-transition:left 0s,top 0s,height 0s,width 0s;transition:left 0s,top 0s,height 0s,width 0s}@media (max-width:768px){.grid-stack-item{position:relative!important;width:auto!important;left:0!important;top:auto!important;margin-bottom:20px}.grid-stack-item .ui-resizable-handle{display:none}.grid-stack{height:auto!important}} \ No newline at end of file +:root .grid-stack-item>.ui-resizable-handle{filter:none}.grid-stack{position:relative}.grid-stack.grid-stack-rtl{direction:ltr}.grid-stack.grid-stack-rtl>.grid-stack-item{direction:rtl}.grid-stack .grid-stack-placeholder>.placeholder-content{border:1px dashed #d3d3d3;margin:0;position:absolute;top:0;left:10px;right:10px;bottom:0;width:auto;z-index:0!important;text-align:center}.grid-stack>.grid-stack-item{min-width:8.3333333333%;position:absolute;padding:0}.grid-stack>.grid-stack-item>.grid-stack-item-content{margin:0;position:absolute;top:0;left:10px;right:10px;bottom:0;width:auto;z-index:0!important;overflow-x:hidden;overflow-y:auto}.grid-stack>.grid-stack-item>.ui-resizable-handle{position:absolute;font-size:.1px;display:block;-ms-touch-action:none;touch-action:none}.grid-stack>.grid-stack-item.ui-resizable-autohide>.ui-resizable-handle,.grid-stack>.grid-stack-item.ui-resizable-disabled>.ui-resizable-handle{display:none}.grid-stack>.grid-stack-item.ui-draggable-dragging,.grid-stack>.grid-stack-item.ui-resizable-resizing{z-index:100}.grid-stack>.grid-stack-item.ui-draggable-dragging>.grid-stack-item-content,.grid-stack>.grid-stack-item.ui-resizable-resizing>.grid-stack-item-content{box-shadow:1px 4px 6px rgba(0,0,0,.2);opacity:.8}.grid-stack>.grid-stack-item>.ui-resizable-se,.grid-stack>.grid-stack-item>.ui-resizable-sw{background-image:url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iaXNvLTg4NTktMSI/Pgo8IS0tIEdlbmVyYXRvcjogQWRvYmUgSWxsdXN0cmF0b3IgMTYuMC4wLCBTVkcgRXhwb3J0IFBsdWctSW4gLiBTVkcgVmVyc2lvbjogNi4wMCBCdWlsZCAwKSAgLS0+CjwhRE9DVFlQRSBzdmcg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zAsNC45NDUsMS44MDcsOS4yMjcsNS40MjQsMTIuODQ3bDczLjA4OSw3My4wODhjMy42MTcsMy42MTcsNy44OTgsNS40MjQsMTIuODQ3LDUuNDI0YzQuOTUsMCw5LjIzNC0xLjgwNywxMi44NDktNS40MjQgICBsNzMuMDg3LTczLjA4OGMzLjYxMy0zLjYyLDUuNDIxLTcuOTAxLDUuNDIxLTEyLjg0N2MwLTQuOTQ4LTEuODA4LTkuMjMyLTUuNDIxLTEyLjg1NCAgIEMzMzguMTQyLDQwMy44MDIsMzMzLjg1Nyw0MDEuOTk0LDMyOC45MDYsNDAxLjk5NHoiIGZpbGw9IiM2NjY2NjYiLz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8L3N2Zz4K);background-repeat:no-repeat;background-position:center;-webkit-transform:rotate(45deg);-moz-transform:rotate(45deg);-ms-transform:rotate(45deg);-o-transform:rotate(45deg);transform:rotate(45deg)}.grid-stack>.grid-stack-item>.ui-resizable-nw{cursor:nw-resize;width:20px;height:20px;left:10px;top:0}.grid-stack>.grid-stack-item>.ui-resizable-n{cursor:n-resize;height:10px;top:0;left:25px;right:25px}.grid-stack>.grid-stack-item>.ui-resizable-ne{cursor:ne-resize;width:20px;height:20px;right:10px;top:0}.grid-stack>.grid-stack-item>.ui-resizable-e{cursor:e-resize;width:10px;right:10px;top:15px;bottom:15px}.grid-stack>.grid-stack-item>.ui-resizable-se{-webkit-transform:rotate(-45deg);-moz-transform:rotate(-45deg);-ms-transform:rotate(-45deg);-o-transform:rotate(-45deg);transform:rotate(-45deg);cursor:se-resize;width:20px;height:20px;right:10px;bottom:0}.grid-stack>.grid-stack-item>.ui-resizable-s{cursor:s-resize;height:10px;left:25px;bottom:0;right:25px}.grid-stack>.grid-stack-item>.ui-resizable-sw{cursor:sw-resize;width:20px;height:20px;left:10px;bottom:0}.grid-stack>.grid-stack-item>.ui-resizable-w{cursor:w-resize;width:10px;left:10px;top:15px;bottom:15px}.grid-stack>.grid-stack-item.ui-draggable-dragging>.ui-resizable-handle{display:none!important}.grid-stack>.grid-stack-item[data-gs-width='1']{width:8.3333333333%}.grid-stack>.grid-stack-item[data-gs-x='1']{left:8.3333333333%}.grid-stack>.grid-stack-item[data-gs-min-width='1']{min-width:8.3333333333%}.grid-stack>.grid-stack-item[data-gs-max-width='1']{max-width:8.3333333333%}.grid-stack>.grid-stack-item[data-gs-width='2']{width:16.6666666667%}.grid-stack>.grid-stack-item[data-gs-x='2']{left:16.6666666667%}.grid-stack>.grid-stack-item[data-gs-min-width='2']{min-width:16.6666666667%}.grid-stack>.grid-stack-item[data-gs-max-width='2']{max-width:16.6666666667%}.grid-stack>.grid-stack-item[data-gs-width='3']{width:25%}.grid-stack>.grid-stack-item[data-gs-x='3']{left:25%}.grid-stack>.grid-stack-item[data-gs-min-width='3']{min-width:25%}.grid-stack>.grid-stack-item[data-gs-max-width='3']{max-width:25%}.grid-stack>.grid-stack-item[data-gs-width='4']{width:33.3333333333%}.grid-stack>.grid-stack-item[data-gs-x='4']{left:33.3333333333%}.grid-stack>.grid-stack-item[data-gs-min-width='4']{min-width:33.3333333333%}.grid-stack>.grid-stack-item[data-gs-max-width='4']{max-width:33.3333333333%}.grid-stack>.grid-stack-item[data-gs-width='5']{width:41.6666666667%}.grid-stack>.grid-stack-item[data-gs-x='5']{left:41.6666666667%}.grid-stack>.grid-stack-item[data-gs-min-width='5']{min-width:41.6666666667%}.grid-stack>.grid-stack-item[data-gs-max-width='5']{max-width:41.6666666667%}.grid-stack>.grid-stack-item[data-gs-width='6']{width:50%}.grid-stack>.grid-stack-item[data-gs-x='6']{left:50%}.grid-stack>.grid-stack-item[data-gs-min-width='6']{min-width:50%}.grid-stack>.grid-stack-item[data-gs-max-width='6']{max-width:50%}.grid-stack>.grid-stack-item[data-gs-width='7']{width:58.3333333333%}.grid-stack>.grid-stack-item[data-gs-x='7']{left:58.3333333333%}.grid-stack>.grid-stack-item[data-gs-min-width='7']{min-width:58.3333333333%}.grid-stack>.grid-stack-item[data-gs-max-width='7']{max-width:58.3333333333%}.grid-stack>.grid-stack-item[data-gs-width='8']{width:66.6666666667%}.grid-stack>.grid-stack-item[data-gs-x='8']{left:66.6666666667%}.grid-stack>.grid-stack-item[data-gs-min-width='8']{min-width:66.6666666667%}.grid-stack>.grid-stack-item[data-gs-max-width='8']{max-width:66.6666666667%}.grid-stack>.grid-stack-item[data-gs-width='9']{width:75%}.grid-stack>.grid-stack-item[data-gs-x='9']{left:75%}.grid-stack>.grid-stack-item[data-gs-min-width='9']{min-width:75%}.grid-stack>.grid-stack-item[data-gs-max-width='9']{max-width:75%}.grid-stack>.grid-stack-item[data-gs-width='10']{width:83.3333333333%}.grid-stack>.grid-stack-item[data-gs-x='10']{left:83.3333333333%}.grid-stack>.grid-stack-item[data-gs-min-width='10']{min-width:83.3333333333%}.grid-stack>.grid-stack-item[data-gs-max-width='10']{max-width:83.3333333333%}.grid-stack>.grid-stack-item[data-gs-width='11']{width:91.6666666667%}.grid-stack>.grid-stack-item[data-gs-x='11']{left:91.6666666667%}.grid-stack>.grid-stack-item[data-gs-min-width='11']{min-width:91.6666666667%}.grid-stack>.grid-stack-item[data-gs-max-width='11']{max-width:91.6666666667%}.grid-stack>.grid-stack-item[data-gs-width='12']{width:100%}.grid-stack>.grid-stack-item[data-gs-x='12']{left:100%}.grid-stack>.grid-stack-item[data-gs-min-width='12']{min-width:100%}.grid-stack>.grid-stack-item[data-gs-max-width='12']{max-width:100%}.grid-stack.grid-stack-animate,.grid-stack.grid-stack-animate .grid-stack-item{-webkit-transition:left .3s,top .3s,height .3s,width .3s;-moz-transition:left .3s,top .3s,height .3s,width .3s;-ms-transition:left .3s,top .3s,height .3s,width .3s;-o-transition:left .3s,top .3s,height .3s,width .3s;transition:left .3s,top .3s,height .3s,width .3s}.grid-stack.grid-stack-animate .grid-stack-item.grid-stack-placeholder,.grid-stack.grid-stack-animate .grid-stack-item.ui-draggable-dragging,.grid-stack.grid-stack-animate .grid-stack-item.ui-resizable-resizing{-webkit-transition:left 0s,top 0s,height 0s,width 0s;-moz-transition:left 0s,top 0s,height 0s,width 0s;-ms-transition:left 0s,top 0s,height 0s,width 0s;-o-transition:left 0s,top 0s,height 0s,width 0s;transition:left 0s,top 0s,height 0s,width 0s}.grid-stack.grid-stack-one-column-mode{height:auto!important}.grid-stack.grid-stack-one-column-mode>.grid-stack-item{position:relative!important;width:auto!important;left:0!important;top:auto!important;margin-bottom:20px;max-width:none!important}.grid-stack.grid-stack-one-column-mode>.grid-stack-item>.ui-resizable-handle{display:none} \ No newline at end of file diff --git a/dist/gridstack.min.js b/dist/gridstack.min.js index 1f63dc1bf..8f3dbcbbe 100644 --- a/dist/gridstack.min.js +++ b/dist/gridstack.min.js @@ -1,2 +1,30 @@ -!function(a){if("function"==typeof define&&define.amd)define(["jquery","lodash","jquery-ui/core","jquery-ui/widget","jquery-ui/mouse","jquery-ui/draggable","jquery-ui/resizable"],a);else if("undefined"!=typeof exports){try{jQuery=require("jquery")}catch(b){}try{_=require("lodash")}catch(b){}a(jQuery,_)}else a(jQuery,_)}(function(a,b){function c(a){a.stopPropagation()}var d=window,e={is_intercepted:function(a,b){return!(a.x+a.width<=b.x||b.x+b.width<=a.x||a.y+a.height<=b.y||b.y+b.height<=a.y)},sort:function(a,c,d){return d=d||b.chain(a).map(function(a){return a.x+a.width}).max().value(),c=-1!=c?1:-1,b.sortBy(a,function(a){return c*(a.x+a.y*d)})},create_stylesheet:function(a){var b=document.createElement("style");return b.setAttribute("type","text/css"),b.setAttribute("data-gs-id",a),b.styleSheet?b.styleSheet.cssText="":b.appendChild(document.createTextNode("")),document.getElementsByTagName("head")[0].appendChild(b),b.sheet},remove_stylesheet:function(b){a("STYLE[data-gs-id="+b+"]").remove()},insert_css_rule:function(a,b,c,d){"function"==typeof a.insertRule?a.insertRule(b+"{"+c+"}",d):"function"==typeof a.addRule&&a.addRule(b,c,d)},toBool:function(a){return"boolean"==typeof a?a:"string"==typeof a?(a=a.toLowerCase(),!(""==a||"no"==a||"false"==a||"0"==a)):Boolean(a)}},f=0,g=function(a,b,c,d,e){this.width=a,this["float"]=c||!1,this.height=d||0,this.nodes=e||[],this.onchange=b||function(){},this._update_counter=0,this._float=this["float"]};g.prototype.batch_update=function(){this._update_counter=1,this["float"]=!0},g.prototype.commit=function(){this._update_counter=0,0==this._update_counter&&(this["float"]=this._float,this._pack_nodes(),this._notify())},g.prototype._fix_collisions=function(a){this._sort_nodes(-1);var c=a,d=Boolean(b.find(this.nodes,function(a){return a.locked}));for(this["float"]||d||(c={x:0,y:a.y,width:this.width,height:a.height});;){var f=b.find(this.nodes,b.bind(function(b){return b!=a&&e.is_intercepted(b,c)},this));if("undefined"==typeof f)return;this.move_node(f,f.x,a.y+a.height,f.width,f.height,!0)}},g.prototype.is_area_empty=function(a,c,d,f){var g={x:a||0,y:c||0,width:d||1,height:f||1},h=b.find(this.nodes,b.bind(function(a){return e.is_intercepted(a,g)},this));return null==h},g.prototype._sort_nodes=function(a){this.nodes=e.sort(this.nodes,a,this.width)},g.prototype._pack_nodes=function(){this._sort_nodes(),this["float"]?b.each(this.nodes,b.bind(function(a,c){if(!a._updating&&"undefined"!=typeof a._orig_y&&a.y!=a._orig_y)for(var d=a.y;d>=a._orig_y;){var f=b.chain(this.nodes).find(function(b){return a!=b&&e.is_intercepted({x:a.x,y:d,width:a.width,height:a.height},b)}).value();f||(a._dirty=!0,a.y=d),--d}},this)):b.each(this.nodes,b.bind(function(a,c){if(!a.locked)for(;a.y>0;){var d=a.y-1,f=0==c;if(c>0){var g=b.chain(this.nodes).take(c).find(function(b){return e.is_intercepted({x:a.x,y:d,width:a.width,height:a.height},b)}).value();f="undefined"==typeof g}if(!f)break;a._dirty=a.y!=d,a.y=d}},this))},g.prototype._prepare_node=function(a,c){return a=b.defaults(a||{},{width:1,height:1,x:0,y:0}),a.x=parseInt(""+a.x),a.y=parseInt(""+a.y),a.width=parseInt(""+a.width),a.height=parseInt(""+a.height),a.auto_position=a.auto_position||!1,a.no_resize=a.no_resize||!1,a.no_move=a.no_move||!1,a.width>this.width?a.width=this.width:a.width<1&&(a.width=1),a.height<1&&(a.height=1),a.x<0&&(a.x=0),a.x+a.width>this.width&&(c?a.width=this.width-a.x:a.x=this.width-a.width),a.y<0&&(a.y=0),a},g.prototype._notify=function(){if(!this._update_counter){var a=Array.prototype.slice.call(arguments,1).concat(this.get_dirty_nodes());a=a.concat(this.get_dirty_nodes()),this.onchange(a)}},g.prototype.clean_nodes=function(){b.each(this.nodes,function(a){a._dirty=!1})},g.prototype.get_dirty_nodes=function(){return b.filter(this.nodes,function(a){return a._dirty})},g.prototype.add_node=function(a){if(a=this._prepare_node(a),"undefined"!=typeof a.max_width&&(a.width=Math.min(a.width,a.max_width)),"undefined"!=typeof a.max_height&&(a.height=Math.min(a.height,a.max_height)),"undefined"!=typeof a.min_width&&(a.width=Math.max(a.width,a.min_width)),"undefined"!=typeof a.min_height&&(a.height=Math.max(a.height,a.min_height)),a._id=++f,a._dirty=!0,a.auto_position){this._sort_nodes();for(var c=0;;++c){var d=c%this.width,g=Math.floor(c/this.width);if(!(d+a.width>this.width||b.find(this.nodes,function(b){return e.is_intercepted({x:d,y:g,width:a.width,height:a.height},b)}))){a.x=d,a.y=g;break}}}return this.nodes.push(a),this._fix_collisions(a),this._pack_nodes(),this._notify(),a},g.prototype.remove_node=function(a){a._id=null,this.nodes=b.without(this.nodes,a),this._pack_nodes(),this._notify(a)},g.prototype.can_move_node=function(c,d,e,f,h){var i=Boolean(b.find(this.nodes,function(a){return a.locked}));if(!this.height&&!i)return!0;var j,k=new g(this.width,null,this["float"],0,b.map(this.nodes,function(b){return b==c?j=a.extend({},b):a.extend({},b)}));k.move_node(j,d,e,f,h);var l=!0;return i&&(l&=!Boolean(b.find(k.nodes,function(a){return a!=j&&Boolean(a.locked)&&Boolean(a._dirty)}))),this.height&&(l&=k.get_grid_height()<=this.height),l},g.prototype.can_be_placed_with_respect_to_height=function(c){if(!this.height)return!0;var d=new g(this.width,null,this["float"],0,b.map(this.nodes,function(b){return a.extend({},b)}));return d.add_node(c),d.get_grid_height()<=this.height},g.prototype.move_node=function(a,b,c,d,e,f){if("number"!=typeof b&&(b=a.x),"number"!=typeof c&&(c=a.y),"number"!=typeof d&&(d=a.width),"number"!=typeof e&&(e=a.height),"undefined"!=typeof a.max_width&&(d=Math.min(d,a.max_width)),"undefined"!=typeof a.max_height&&(e=Math.min(e,a.max_height)),"undefined"!=typeof a.min_width&&(d=Math.max(d,a.min_width)),"undefined"!=typeof a.min_height&&(e=Math.max(e,a.min_height)),a.x==b&&a.y==c&&a.width==d&&a.height==e)return a;var g=a.width!=d;return a._dirty=!0,a.x=b,a.y=c,a.width=d,a.height=e,a=this._prepare_node(a,g),this._fix_collisions(a),f||(this._pack_nodes(),this._notify()),a},g.prototype.get_grid_height=function(){return b.reduce(this.nodes,function(a,b){return Math.max(a,b.y+b.height)},0)},g.prototype.begin_update=function(a){b.each(this.nodes,function(a){a._orig_y=a.y}),a._updating=!0},g.prototype.end_update=function(){b.each(this.nodes,function(a){a._orig_y=a.y});var a=b.find(this.nodes,function(a){return a._updating});a&&(a._updating=!1)};var h=function(c,d){var e,f=this;d=d||{},this.container=a(c),d.item_class=d.item_class||"grid-stack-item";var h=this.container.closest("."+d.item_class).size()>0;if(this.opts=b.defaults(d||{},{width:parseInt(this.container.attr("data-gs-width"))||12,height:parseInt(this.container.attr("data-gs-height"))||0,item_class:"grid-stack-item",placeholder_class:"grid-stack-placeholder",placeholder_text:"",handle:".grid-stack-item-content",handle_class:null,cell_height:60,vertical_margin:20,auto:!0,min_width:768,"float":!1,static_grid:!1,_class:"grid-stack-instance-"+(1e4*Math.random()).toFixed(0),animate:Boolean(this.container.attr("data-gs-animate"))||!1,always_show_resize_handle:d.always_show_resize_handle||!1,resizable:b.defaults(d.resizable||{},{autoHide:!d.always_show_resize_handle,handles:"se"}),draggable:b.defaults(d.draggable||{},{handle:(d.handle_class?"."+d.handle_class:d.handle?d.handle:"")||".grid-stack-item-content",scroll:!1,appendTo:"body"})}),this.opts.is_nested=h,this.container.addClass(this.opts._class),this._set_static_class(),h&&this.container.addClass("grid-stack-nested"),this._init_styles(),this.grid=new g(this.opts.width,function(a){var c=0;b.each(a,function(a){null==a._id?a.el.remove():(a.el.attr("data-gs-x",a.x).attr("data-gs-y",a.y).attr("data-gs-width",a.width).attr("data-gs-height",a.height),c=Math.max(c,a.y+a.height))}),f._update_styles(c+10)},this.opts["float"],this.opts.height),this.opts.auto){var i=[],j=this;this.container.children("."+this.opts.item_class+":not(."+this.opts.placeholder_class+")").each(function(b,c){c=a(c),i.push({el:c,i:parseInt(c.attr("data-gs-x"))+parseInt(c.attr("data-gs-y"))*j.opts.width})}),b.chain(i).sortBy(function(a){return a.i}).each(function(a){f._prepare_element(a.el)}).value()}this.set_animation(this.opts.animate),this.placeholder=a('
'+this.opts.placeholder_text+"
").hide(),this.container.height(this.grid.get_grid_height()*(this.opts.cell_height+this.opts.vertical_margin)-this.opts.vertical_margin),this.on_resize_handler=function(){if(f._is_one_column_mode()){if(e)return;e=!0,f.grid._sort_nodes(),b.each(f.grid.nodes,function(a){f.container.append(a.el),f.opts.static_grid||(a.no_move||a.el.draggable("disable"),a.no_resize||a.el.resizable("disable"))})}else{if(!e)return;if(e=!1,f.opts.static_grid)return;b.each(f.grid.nodes,function(a){a.no_move||a.el.draggable("enable"),a.no_resize||a.el.resizable("enable")})}},a(window).resize(this.on_resize_handler),this.on_resize_handler()};return h.prototype._trigger_change_event=function(a){var b=this.grid.get_dirty_nodes(),c=!1,d=[];b&&b.length&&(d.push(b),c=!0),(c||a===!0)&&this.container.trigger("change",d)},h.prototype._init_styles=function(){this._styles_id&&a('[data-gs-id="'+this._styles_id+'"]').remove(),this._styles_id="gridstack-style-"+(1e5*Math.random()).toFixed(),this._styles=e.create_stylesheet(this._styles_id),null!=this._styles&&(this._styles._max=0)},h.prototype._update_styles=function(a){if(null!=this._styles){var b="."+this.opts._class+" ."+this.opts.item_class;if("undefined"==typeof a&&(a=this._styles._max,this._init_styles(),this._update_container_height()),0==this._styles._max&&e.insert_css_rule(this._styles,b,"min-height: "+this.opts.cell_height+"px;",0),a>this._styles._max){for(var c=this._styles._max;a>c;++c)e.insert_css_rule(this._styles,b+'[data-gs-height="'+(c+1)+'"]',"height: "+(this.opts.cell_height*(c+1)+this.opts.vertical_margin*c)+"px;",c),e.insert_css_rule(this._styles,b+'[data-gs-min-height="'+(c+1)+'"]',"min-height: "+(this.opts.cell_height*(c+1)+this.opts.vertical_margin*c)+"px;",c),e.insert_css_rule(this._styles,b+'[data-gs-max-height="'+(c+1)+'"]',"max-height: "+(this.opts.cell_height*(c+1)+this.opts.vertical_margin*c)+"px;",c),e.insert_css_rule(this._styles,b+'[data-gs-y="'+c+'"]',"top: "+(this.opts.cell_height*c+this.opts.vertical_margin*c)+"px;",c);this._styles._max=a}}},h.prototype._update_container_height=function(){this.grid._update_counter||this.container.height(this.grid.get_grid_height()*(this.opts.cell_height+this.opts.vertical_margin)-this.opts.vertical_margin)},h.prototype._is_one_column_mode=function(){return(window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth)<=this.opts.min_width},h.prototype._prepare_element=function(c){var d=this;c=a(c),c.addClass(this.opts.item_class);var f=d.grid.add_node({x:c.attr("data-gs-x"),y:c.attr("data-gs-y"),width:c.attr("data-gs-width"),height:c.attr("data-gs-height"),max_width:c.attr("data-gs-max-width"),min_width:c.attr("data-gs-min-width"),max_height:c.attr("data-gs-max-height"),min_height:c.attr("data-gs-min-height"),auto_position:e.toBool(c.attr("data-gs-auto-position")),no_resize:e.toBool(c.attr("data-gs-no-resize")),no_move:e.toBool(c.attr("data-gs-no-move")),locked:e.toBool(c.attr("data-gs-locked")),el:c});if(c.data("_gridstack_node",f),!d.opts.static_grid){var g,h,i=function(a,b){var c,e,i=Math.round(b.position.left/g),j=Math.floor((b.position.top+h/2)/h);"drag"!=a.type&&(c=Math.round(b.size.width/g),e=Math.round(b.size.height/h)),d.grid.can_move_node(f,i,j,c,e)&&(d.grid.move_node(f,i,j,c,e),d._update_container_height())},j=function(b,e){d.container.append(d.placeholder);var i=a(this);d.grid.clean_nodes(),d.grid.begin_update(f),g=i.outerWidth()/i.attr("data-gs-width"),h=d.opts.cell_height+d.opts.vertical_margin,d.placeholder.attr("data-gs-x",i.attr("data-gs-x")).attr("data-gs-y",i.attr("data-gs-y")).attr("data-gs-width",i.attr("data-gs-width")).attr("data-gs-height",i.attr("data-gs-height")).show(),f.el=d.placeholder,c.resizable("option","minWidth",Math.round(g*(f.min_width||1))),c.resizable("option","minHeight",d.opts.cell_height*(f.min_height||1)),"resizestart"==b.type&&i.find(".grid-stack-item").trigger("resizestart")},k=function(b,c){d.placeholder.detach();var e=a(this);f.el=e,d.placeholder.hide(),e.attr("data-gs-x",f.x).attr("data-gs-y",f.y).attr("data-gs-width",f.width).attr("data-gs-height",f.height).removeAttr("style"),d._update_container_height(),d._trigger_change_event(),d.grid.end_update();var g=e.find(".grid-stack");g.length&&"resizestop"==b.type&&(g.each(function(b,c){a(c).data("gridstack").on_resize_handler()}),e.find(".grid-stack-item").trigger("resizestop"))};c.draggable(b.extend(this.opts.draggable,{containment:this.opts.is_nested?this.container.parent():null})).on("dragstart",j).on("dragstop",k).on("drag",i).resizable(b.extend(this.opts.resizable,{})).on("resizestart",j).on("resizestop",k).on("resize",i),(f.no_move||this._is_one_column_mode())&&c.draggable("disable"),(f.no_resize||this._is_one_column_mode())&&c.resizable("disable"),c.attr("data-gs-locked",f.locked?"yes":null)}},h.prototype.set_animation=function(a){a?this.container.addClass("grid-stack-animate"):this.container.removeClass("grid-stack-animate")},h.prototype.add_widget=function(b,c,d,e,f,g){return b=a(b),"undefined"!=typeof c&&b.attr("data-gs-x",c),"undefined"!=typeof d&&b.attr("data-gs-y",d),"undefined"!=typeof e&&b.attr("data-gs-width",e),"undefined"!=typeof f&&b.attr("data-gs-height",f),"undefined"!=typeof g&&b.attr("data-gs-auto-position",g?"yes":null),this.container.append(b),this._prepare_element(b),this._update_container_height(),this._trigger_change_event(!0),b},h.prototype.make_widget=function(b){return b=a(b),this._prepare_element(b),this._update_container_height(),this._trigger_change_event(!0),b},h.prototype.will_it_fit=function(a,b,c,d,e){var f={x:a,y:b,width:c,height:d,auto_position:e};return this.grid.can_be_placed_with_respect_to_height(f)},h.prototype.remove_widget=function(b,c){c="undefined"==typeof c?!0:c,b=a(b);var d=b.data("_gridstack_node");this.grid.remove_node(d),b.removeData("_gridstack_node"),this._update_container_height(),c&&b.remove(),this._trigger_change_event(!0)},h.prototype.remove_all=function(a){b.each(this.grid.nodes,b.bind(function(b){this.remove_widget(b.el,a)},this)),this.grid.nodes=[],this._update_container_height()},h.prototype.destroy=function(){a(window).off("resize",this.on_resize_handler),this.disable(),this.container.remove(),e.remove_stylesheet(this._styles_id),this.grid&&(this.grid=null)},h.prototype.resizable=function(b,c){var d=this;return b=a(b),b.each(function(b,e){e=a(e);var f=e.data("_gridstack_node");"undefined"!=typeof f&&null!=f&&(f.no_resize=!c,f.no_resize||d._is_one_column_mode()?e.resizable("disable"):e.resizable("enable"))}),this},h.prototype.movable=function(b,c){var d=this;return b=a(b),b.each(function(b,e){e=a(e);var f=e.data("_gridstack_node");"undefined"!=typeof f&&null!=f&&(f.no_move=!c,f.no_move||d._is_one_column_mode()?(e.draggable("disable"),e.removeClass("ui-draggable-handle")):(e.draggable("enable"),e.addClass("ui-draggable-handle")))}),this},h.prototype.disable=function(){this.movable(this.container.children("."+this.opts.item_class),!1),this.resizable(this.container.children("."+this.opts.item_class),!1),this.container.trigger("disable")},h.prototype.enable=function(){this.movable(this.container.children("."+this.opts.item_class),!0),this.resizable(this.container.children("."+this.opts.item_class),!0),this.container.trigger("enable")},h.prototype.locked=function(b,c){return b=a(b),b.each(function(b,d){d=a(d);var e=d.data("_gridstack_node");"undefined"!=typeof e&&null!=e&&(e.locked=c||!1,d.attr("data-gs-locked",e.locked?"yes":null))}),this},h.prototype.min_height=function(b,c){return b=a(b),b.each(function(b,d){d=a(d);var e=d.data("_gridstack_node");"undefined"!=typeof e&&null!=e&&(isNaN(c)||(e.min_height=c||!1,d.attr("data-gs-min-height",c)))}),this},h.prototype.min_width=function(b,c){return b=a(b),b.each(function(b,d){d=a(d);var e=d.data("_gridstack_node");"undefined"!=typeof e&&null!=e&&(isNaN(c)||(e.min_width=c||!1,d.attr("data-gs-min-width",c)))}),this},h.prototype._update_element=function(b,c){b=a(b).first();var d=b.data("_gridstack_node");if("undefined"!=typeof d&&null!=d){var e=this;e.grid.clean_nodes(),e.grid.begin_update(d),c.call(this,b,d),e._update_container_height(),e._trigger_change_event(),e.grid.end_update()}},h.prototype.resize=function(a,b,c){this._update_element(a,function(a,d){b=null!=b&&"undefined"!=typeof b?b:d.width,c=null!=c&&"undefined"!=typeof c?c:d.height,this.grid.move_node(d,d.x,d.y,b,c)})},h.prototype.move=function(a,b,c){this._update_element(a,function(a,d){b=null!=b&&"undefined"!=typeof b?b:d.x,c=null!=c&&"undefined"!=typeof c?c:d.y,this.grid.move_node(d,b,c,d.width,d.height)})},h.prototype.update=function(a,b,c,d,e){this._update_element(a,function(a,f){b=null!=b&&"undefined"!=typeof b?b:f.x,c=null!=c&&"undefined"!=typeof c?c:f.y,d=null!=d&&"undefined"!=typeof d?d:f.width,e=null!=e&&"undefined"!=typeof e?e:f.height,this.grid.move_node(f,b,c,d,e)})},h.prototype.cell_height=function(a){return"undefined"==typeof a?this.opts.cell_height:(a=parseInt(a),void(a!=this.opts.cell_height&&(this.opts.cell_height=a||this.opts.cell_height,this._update_styles())))},h.prototype.cell_width=function(){var a=this.container.children("."+this.opts.item_class).first();return Math.ceil(a.outerWidth()/a.attr("data-gs-width"))},h.prototype.get_cell_from_pixel=function(a){var b=this.container.position(),c=a.left-b.left,d=a.top-b.top,e=Math.floor(this.container.width()/this.opts.width),f=this.opts.cell_height+this.opts.vertical_margin;return{x:Math.floor(c/e),y:Math.floor(d/f)}},h.prototype.batch_update=function(){this.grid.batch_update()},h.prototype.commit=function(){this.grid.commit(),this._update_container_height()},h.prototype.is_area_empty=function(a,b,c,d){return this.grid.is_area_empty(a,b,c,d)},h.prototype.set_static=function(a){this.opts.static_grid=a===!0,this._set_static_class()},h.prototype._set_static_class=function(){var a="grid-stack-static";this.opts.static_grid===!0?this.container.addClass(a):this.container.removeClass(a)},d.GridStackUI=h,d.GridStackUI.Utils=e,a.fn.gridstack=function(b){return this.each(function(){var d=a(this);d.data("gridstack")||d.data("gridstack",new h(this,b)).on("dragstart",c).on("dragstop",c).on("drag",c).on("resizestart",c).on("resizestop",c).on("resize",c).on("change",c)})},d.GridStackUI}); +/** + * gridstack.js 0.3.0-dev + * http://troolee.github.io/gridstack.js/ + * (c) 2014-2016 Pavel Reznikov, Dylan Weiss + * gridstack.js may be freely distributed under the MIT license. + * @preserve +*/ +!function(a){if("function"==typeof define&&define.amd)define(["jquery","lodash"],a);else if("undefined"!=typeof exports){try{jQuery=require("jquery")}catch(a){}try{_=require("lodash")}catch(a){}a(jQuery,_)}else a(jQuery,_)}(function(a,b){ +// jscs:enable requireCamelCaseOrUpperCaseIdentifiers +/** + * @class GridStackDragDropPlugin + * Base class for drag'n'drop plugin. + */ +function c(a){this.grid=a}var d=window,e=function(a,b,c){var d=function(){return console.warn("gridstack.js: Function `"+b+"` is deprecated as of v0.2.5 and has been replaced with `"+c+"`. It will be **completely** removed in v1.0."),a.apply(this,arguments)};return d.prototype=a.prototype,d},f=function(a,b){console.warn("gridstack.js: Option `"+a+"` is deprecated as of v0.2.5 and has been replaced with `"+b+"`. It will be **completely** removed in v1.0.")},g={isIntercepted:function(a,b){return!(a.x+a.width<=b.x||b.x+b.width<=a.x||a.y+a.height<=b.y||b.y+b.height<=a.y)},sort:function(a,c,d){return d=d||b.chain(a).map(function(a){return a.x+a.width}).max().value(),c=c!=-1?1:-1,b.sortBy(a,function(a){return c*(a.x+a.y*d)})},createStylesheet:function(a){var b=document.createElement("style");return b.setAttribute("type","text/css"),b.setAttribute("data-gs-style-id",a),b.styleSheet?b.styleSheet.cssText="":b.appendChild(document.createTextNode("")),document.getElementsByTagName("head")[0].appendChild(b),b.sheet},removeStylesheet:function(b){a("STYLE[data-gs-style-id="+b+"]").remove()},insertCSSRule:function(a,b,c,d){"function"==typeof a.insertRule?a.insertRule(b+"{"+c+"}",d):"function"==typeof a.addRule&&a.addRule(b,c,d)},toBool:function(a){return"boolean"==typeof a?a:"string"==typeof a?(a=a.toLowerCase(),!(""===a||"no"==a||"false"==a||"0"==a)):Boolean(a)},_collisionNodeCheck:function(a){return a!=this.node&&g.isIntercepted(a,this.nn)},_didCollide:function(a){return g.isIntercepted({x:this.n.x,y:this.newY,width:this.n.width,height:this.n.height},a)},_isAddNodeIntercepted:function(a){return g.isIntercepted({x:this.x,y:this.y,width:this.node.width,height:this.node.height},a)},parseHeight:function(a){var c=a,d="px";if(c&&b.isString(c)){var e=c.match(/^(-[0-9]+\.[0-9]+|[0-9]*\.[0-9]+|-[0-9]+|[0-9]+)(px|em|rem|vh|vw)?$/);if(!e)throw new Error("Invalid height");d=e[2]||"px",c=parseFloat(e[1])}return{height:c,unit:d}}}; +// jscs:disable requireCamelCaseOrUpperCaseIdentifiers +g.is_intercepted=e(g.isIntercepted,"is_intercepted","isIntercepted"),g.create_stylesheet=e(g.createStylesheet,"create_stylesheet","createStylesheet"),g.remove_stylesheet=e(g.removeStylesheet,"remove_stylesheet","removeStylesheet"),g.insert_css_rule=e(g.insertCSSRule,"insert_css_rule","insertCSSRule"),c.registeredPlugins=[],c.registerPlugin=function(a){c.registeredPlugins.push(a)},c.prototype.resizable=function(a,b){return this},c.prototype.draggable=function(a,b){return this},c.prototype.droppable=function(a,b){return this},c.prototype.isDroppable=function(a){return!1},c.prototype.on=function(a,b,c){return this};var h=0,i=function(a,b,c,d,e){this.width=a,this.float=c||!1,this.height=d||0,this.nodes=e||[],this.onchange=b||function(){},this._updateCounter=0,this._float=this.float,this._addedNodes=[],this._removedNodes=[]};i.prototype.batchUpdate=function(){this._updateCounter=1,this.float=!0},i.prototype.commit=function(){0!==this._updateCounter&&(this._updateCounter=0,this.float=this._float,this._packNodes(),this._notify())}, +// For Meteor support: https://github.com/troolee/gridstack.js/pull/272 +i.prototype.getNodeDataByDOMEl=function(a){return b.find(this.nodes,function(b){return a.get(0)===b.el.get(0)})},i.prototype._fixCollisions=function(a){this._sortNodes(-1);var c=a,d=Boolean(b.find(this.nodes,function(a){return a.locked}));for(this.float||d||(c={x:0,y:a.y,width:this.width,height:a.height});;){var e=b.find(this.nodes,b.bind(g._collisionNodeCheck,{node:a,nn:c}));if("undefined"==typeof e)return;this.moveNode(e,e.x,a.y+a.height,e.width,e.height,!0)}},i.prototype.isAreaEmpty=function(a,c,d,e){var f={x:a||0,y:c||0,width:d||1,height:e||1},h=b.find(this.nodes,b.bind(function(a){return g.isIntercepted(a,f)},this));return null===h||"undefined"==typeof h},i.prototype._sortNodes=function(a){this.nodes=g.sort(this.nodes,a,this.width)},i.prototype._packNodes=function(){this._sortNodes(),this.float?b.each(this.nodes,b.bind(function(a,c){if(!a._updating&&"undefined"!=typeof a._origY&&a.y!=a._origY)for(var d=a.y;d>=a._origY;){var e=b.chain(this.nodes).find(b.bind(g._didCollide,{n:a,newY:d})).value();e||(a._dirty=!0,a.y=d),--d}},this)):b.each(this.nodes,b.bind(function(a,c){if(!a.locked)for(;a.y>0;){var d=a.y-1,e=0===c;if(c>0){var f=b.chain(this.nodes).take(c).find(b.bind(g._didCollide,{n:a,newY:d})).value();e="undefined"==typeof f}if(!e)break;a._dirty=a.y!=d,a.y=d}},this))},i.prototype._prepareNode=function(a,c){return a=b.defaults(a||{},{width:1,height:1,x:0,y:0}),a.x=parseInt(""+a.x),a.y=parseInt(""+a.y),a.width=parseInt(""+a.width),a.height=parseInt(""+a.height),a.autoPosition=a.autoPosition||!1,a.noResize=a.noResize||!1,a.noMove=a.noMove||!1,a.width>this.width?a.width=this.width:a.width<1&&(a.width=1),a.height<1&&(a.height=1),a.x<0&&(a.x=0),a.x+a.width>this.width&&(c?a.width=this.width-a.x:a.x=this.width-a.width),a.y<0&&(a.y=0),a},i.prototype._notify=function(){var a=Array.prototype.slice.call(arguments,0);if(a[0]="undefined"==typeof a[0]?[]:[a[0]],a[1]="undefined"==typeof a[1]||a[1],!this._updateCounter){var b=a[0].concat(this.getDirtyNodes());this.onchange(b,a[1])}},i.prototype.cleanNodes=function(){this._updateCounter||b.each(this.nodes,function(a){a._dirty=!1})},i.prototype.getDirtyNodes=function(){return b.filter(this.nodes,function(a){return a._dirty})},i.prototype.addNode=function(a,c){if(a=this._prepareNode(a),"undefined"!=typeof a.maxWidth&&(a.width=Math.min(a.width,a.maxWidth)),"undefined"!=typeof a.maxHeight&&(a.height=Math.min(a.height,a.maxHeight)),"undefined"!=typeof a.minWidth&&(a.width=Math.max(a.width,a.minWidth)),"undefined"!=typeof a.minHeight&&(a.height=Math.max(a.height,a.minHeight)),a._id=++h,a._dirty=!0,a.autoPosition){this._sortNodes();for(var d=0;;++d){var e=d%this.width,f=Math.floor(d/this.width);if(!(e+a.width>this.width||b.find(this.nodes,b.bind(g._isAddNodeIntercepted,{x:e,y:f,node:a})))){a.x=e,a.y=f;break}}}return this.nodes.push(a),"undefined"!=typeof c&&c&&this._addedNodes.push(b.clone(a)),this._fixCollisions(a),this._packNodes(),this._notify(),a},i.prototype.removeNode=function(a,c){c="undefined"==typeof c||c,this._removedNodes.push(b.clone(a)),a._id=null,this.nodes=b.without(this.nodes,a),this._packNodes(),this._notify(a,c)},i.prototype.canMoveNode=function(c,d,e,f,g){if(!this.isNodeChangedPosition(c,d,e,f,g))return!1;var h=Boolean(b.find(this.nodes,function(a){return a.locked}));if(!this.height&&!h)return!0;var j,k=new i(this.width,null,this.float,0,b.map(this.nodes,function(b){return b==c?j=a.extend({},b):a.extend({},b)}));if("undefined"==typeof j)return!0;k.moveNode(j,d,e,f,g);var l=!0;return h&&(l&=!Boolean(b.find(k.nodes,function(a){return a!=j&&Boolean(a.locked)&&Boolean(a._dirty)}))),this.height&&(l&=k.getGridHeight()<=this.height),l},i.prototype.canBePlacedWithRespectToHeight=function(c){if(!this.height)return!0;var d=new i(this.width,null,this.float,0,b.map(this.nodes,function(b){return a.extend({},b)}));return d.addNode(c),d.getGridHeight()<=this.height},i.prototype.isNodeChangedPosition=function(a,b,c,d,e){return"number"!=typeof b&&(b=a.x),"number"!=typeof c&&(c=a.y),"number"!=typeof d&&(d=a.width),"number"!=typeof e&&(e=a.height),"undefined"!=typeof a.maxWidth&&(d=Math.min(d,a.maxWidth)),"undefined"!=typeof a.maxHeight&&(e=Math.min(e,a.maxHeight)),"undefined"!=typeof a.minWidth&&(d=Math.max(d,a.minWidth)),"undefined"!=typeof a.minHeight&&(e=Math.max(e,a.minHeight)),a.x!=b||a.y!=c||a.width!=d||a.height!=e},i.prototype.moveNode=function(a,b,c,d,e,f){if(!this.isNodeChangedPosition(a,b,c,d,e))return a;if("number"!=typeof b&&(b=a.x),"number"!=typeof c&&(c=a.y),"number"!=typeof d&&(d=a.width),"number"!=typeof e&&(e=a.height),"undefined"!=typeof a.maxWidth&&(d=Math.min(d,a.maxWidth)),"undefined"!=typeof a.maxHeight&&(e=Math.min(e,a.maxHeight)),"undefined"!=typeof a.minWidth&&(d=Math.max(d,a.minWidth)),"undefined"!=typeof a.minHeight&&(e=Math.max(e,a.minHeight)),a.x==b&&a.y==c&&a.width==d&&a.height==e)return a;var g=a.width!=d;return a._dirty=!0,a.x=b,a.y=c,a.width=d,a.height=e,a.lastTriedX=b,a.lastTriedY=c,a.lastTriedWidth=d,a.lastTriedHeight=e,a=this._prepareNode(a,g),this._fixCollisions(a),f||(this._packNodes(),this._notify()),a},i.prototype.getGridHeight=function(){return b.reduce(this.nodes,function(a,b){return Math.max(a,b.y+b.height)},0)},i.prototype.beginUpdate=function(a){b.each(this.nodes,function(a){a._origY=a.y}),a._updating=!0},i.prototype.endUpdate=function(){b.each(this.nodes,function(a){a._origY=a.y});var a=b.find(this.nodes,function(a){return a._updating});a&&(a._updating=!1)};var j=function(d,e){var g,h,j=this;e=e||{},this.container=a(d), +// jscs:disable requireCamelCaseOrUpperCaseIdentifiers +"undefined"!=typeof e.handle_class&&(e.handleClass=e.handle_class,f("handle_class","handleClass")),"undefined"!=typeof e.item_class&&(e.itemClass=e.item_class,f("item_class","itemClass")),"undefined"!=typeof e.placeholder_class&&(e.placeholderClass=e.placeholder_class,f("placeholder_class","placeholderClass")),"undefined"!=typeof e.placeholder_text&&(e.placeholderText=e.placeholder_text,f("placeholder_text","placeholderText")),"undefined"!=typeof e.cell_height&&(e.cellHeight=e.cell_height,f("cell_height","cellHeight")),"undefined"!=typeof e.vertical_margin&&(e.verticalMargin=e.vertical_margin,f("vertical_margin","verticalMargin")),"undefined"!=typeof e.min_width&&(e.minWidth=e.min_width,f("min_width","minWidth")),"undefined"!=typeof e.static_grid&&(e.staticGrid=e.static_grid,f("static_grid","staticGrid")),"undefined"!=typeof e.is_nested&&(e.isNested=e.is_nested,f("is_nested","isNested")),"undefined"!=typeof e.always_show_resize_handle&&(e.alwaysShowResizeHandle=e.always_show_resize_handle,f("always_show_resize_handle","alwaysShowResizeHandle")), +// jscs:enable requireCamelCaseOrUpperCaseIdentifiers +e.itemClass=e.itemClass||"grid-stack-item";var k=this.container.closest("."+e.itemClass).length>0;if(this.opts=b.defaults(e||{},{width:parseInt(this.container.attr("data-gs-width"))||12,height:parseInt(this.container.attr("data-gs-height"))||0,itemClass:"grid-stack-item",placeholderClass:"grid-stack-placeholder",placeholderText:"",handle:".grid-stack-item-content",handleClass:null,cellHeight:60,verticalMargin:20,auto:!0,minWidth:768,float:!1,staticGrid:!1,_class:"grid-stack-instance-"+(1e4*Math.random()).toFixed(0),animate:Boolean(this.container.attr("data-gs-animate"))||!1,alwaysShowResizeHandle:e.alwaysShowResizeHandle||!1,resizable:b.defaults(e.resizable||{},{autoHide:!e.alwaysShowResizeHandle,handles:"se"}),draggable:b.defaults(e.draggable||{},{handle:(e.handleClass?"."+e.handleClass:e.handle?e.handle:"")||".grid-stack-item-content",scroll:!1,appendTo:"body"}),disableDrag:e.disableDrag||!1,disableResize:e.disableResize||!1,rtl:"auto",removable:!1,removeTimeout:2e3,verticalMarginUnit:"px",cellHeightUnit:"px",oneColumnModeClass:e.oneColumnModeClass||"grid-stack-one-column-mode",ddPlugin:null}),this.opts.ddPlugin===!1?this.opts.ddPlugin=c:null===this.opts.ddPlugin&&(this.opts.ddPlugin=b.first(c.registeredPlugins)||c),this.dd=new this.opts.ddPlugin(this),"auto"===this.opts.rtl&&(this.opts.rtl="rtl"===this.container.css("direction")),this.opts.rtl&&this.container.addClass("grid-stack-rtl"),this.opts.isNested=k,h="auto"===this.opts.cellHeight,h?j.cellHeight(j.cellWidth(),!0):this.cellHeight(this.opts.cellHeight,!0),this.verticalMargin(this.opts.verticalMargin,!0),this.container.addClass(this.opts._class),this._setStaticClass(),k&&this.container.addClass("grid-stack-nested"),this._initStyles(),this.grid=new i(this.opts.width,function(a,c){c="undefined"==typeof c||c;var d=0;b.each(a,function(a){c&&null===a._id?a.el&&a.el.remove():(a.el.attr("data-gs-x",a.x).attr("data-gs-y",a.y).attr("data-gs-width",a.width).attr("data-gs-height",a.height),d=Math.max(d,a.y+a.height))}),j._updateStyles(d+10)},this.opts.float,this.opts.height),this.opts.auto){var l=[],m=this;this.container.children("."+this.opts.itemClass+":not(."+this.opts.placeholderClass+")").each(function(b,c){c=a(c),l.push({el:c,i:parseInt(c.attr("data-gs-x"))+parseInt(c.attr("data-gs-y"))*m.opts.width})}),b.chain(l).sortBy(function(a){return a.i}).each(function(a){j._prepareElement(a.el)}).value()}if(this.setAnimation(this.opts.animate),this.placeholder=a('
'+this.opts.placeholderText+"
").hide(),this._updateContainerHeight(),this._updateHeightsOnResize=b.throttle(function(){j.cellHeight(j.cellWidth(),!1)},100),this.onResizeHandler=function(){if(h&&j._updateHeightsOnResize(),j._isOneColumnMode()){if(g)return;j.container.addClass(j.opts.oneColumnModeClass),g=!0,j.grid._sortNodes(),b.each(j.grid.nodes,function(a){j.container.append(a.el),j.opts.staticGrid||((a.noMove||j.opts.disableDrag)&&j.dd.draggable(a.el,"disable"),(a.noResize||j.opts.disableResize)&&j.dd.resizable(a.el,"disable"),a.el.trigger("resize"))})}else{if(!g)return;if(j.container.removeClass(j.opts.oneColumnModeClass),g=!1,j.opts.staticGrid)return;b.each(j.grid.nodes,function(a){a.noMove||j.opts.disableDrag||j.dd.draggable(a.el,"enable"),a.noResize||j.opts.disableResize||j.dd.resizable(a.el,"enable"),a.el.trigger("resize")})}},a(window).resize(this.onResizeHandler),this.onResizeHandler(),!j.opts.staticGrid&&"string"==typeof j.opts.removable){var n=a(j.opts.removable);this.dd.isDroppable(n)||this.dd.droppable(n,{accept:"."+j.opts.itemClass}),this.dd.on(n,"dropover",function(b,c){var d=a(c.draggable),e=d.data("_gridstack_node");e._grid===j&&j._setupRemovingTimeout(d)}).on(n,"dropout",function(b,c){var d=a(c.draggable),e=d.data("_gridstack_node");e._grid===j&&j._clearRemovingTimeout(d)})}if(!j.opts.staticGrid&&j.opts.acceptWidgets){var o=null,p=function(a,b){var c=o,d=c.data("_gridstack_node"),e=j.getCellFromPixel(b.offset,!0),f=Math.max(0,e.x),g=Math.max(0,e.y);if(d._added){if(!j.grid.canMoveNode(d,f,g))return;j.grid.moveNode(d,f,g),j._updateContainerHeight()}else d._added=!0,d.el=c,d.x=f,d.y=g,j.grid.cleanNodes(),j.grid.beginUpdate(d),j.grid.addNode(d),j.container.append(j.placeholder),j.placeholder.attr("data-gs-x",d.x).attr("data-gs-y",d.y).attr("data-gs-width",d.width).attr("data-gs-height",d.height).show(),d.el=j.placeholder,d._beforeDragX=d.x,d._beforeDragY=d.y,j._updateContainerHeight()};this.dd.droppable(j.container,{accept:function(b){b=a(b);var c=b.data("_gridstack_node");return(!c||c._grid!==j)&&b.is(j.opts.acceptWidgets===!0?".grid-stack-item":j.opts.acceptWidgets)}}).on(j.container,"dropover",function(b,c){var d=(j.container.offset(),a(c.draggable)),e=j.cellWidth(),f=j.cellHeight(),g=d.data("_gridstack_node"),h=g?g.width:Math.ceil(d.outerWidth()/e),i=g?g.height:Math.ceil(d.outerHeight()/f);o=d;var k=j.grid._prepareNode({width:h,height:i,_added:!1,_temporary:!0});d.data("_gridstack_node",k),d.data("_gridstack_node_orig",g),d.on("drag",p)}).on(j.container,"dropout",function(b,c){var d=a(c.draggable);d.unbind("drag",p);var e=d.data("_gridstack_node");e.el=null,j.grid.removeNode(e),j.placeholder.detach(),j._updateContainerHeight(),d.data("_gridstack_node",d.data("_gridstack_node_orig"))}).on(j.container,"drop",function(b,c){j.placeholder.detach();var d=a(c.draggable).data("_gridstack_node");d._grid=j;var e=a(c.draggable).clone(!1);e.data("_gridstack_node",d),a(c.draggable).remove(),d.el=e,j.placeholder.hide(),e.attr("data-gs-x",d.x).attr("data-gs-y",d.y).attr("data-gs-width",d.width).attr("data-gs-height",d.height).addClass(j.opts.itemClass).removeAttr("style").enableSelection().removeData("draggable").removeClass("ui-draggable ui-draggable-dragging ui-draggable-disabled").unbind("drag",p),j.container.append(e),j._prepareElementsByNode(e,d),j._updateContainerHeight(),j._triggerChangeEvent(),j.grid.endUpdate()})}}; +// jscs:disable requireCamelCaseOrUpperCaseIdentifiers +// jscs:enable requireCamelCaseOrUpperCaseIdentifiers +return j.prototype._triggerChangeEvent=function(a){var b=this.grid.getDirtyNodes(),c=!1,d=[];b&&b.length&&(d.push(b),c=!0),(c||a===!0)&&this.container.trigger("change",d)},j.prototype._triggerAddEvent=function(){this.grid._addedNodes&&this.grid._addedNodes.length>0&&(this.container.trigger("added",[b.map(this.grid._addedNodes,b.clone)]),this.grid._addedNodes=[])},j.prototype._triggerRemoveEvent=function(){this.grid._removedNodes&&this.grid._removedNodes.length>0&&(this.container.trigger("removed",[b.map(this.grid._removedNodes,b.clone)]),this.grid._removedNodes=[])},j.prototype._initStyles=function(){this._stylesId&&g.removeStylesheet(this._stylesId),this._stylesId="gridstack-style-"+(1e5*Math.random()).toFixed(),this._styles=g.createStylesheet(this._stylesId),null!==this._styles&&(this._styles._max=0)},j.prototype._updateStyles=function(a){if(null!==this._styles&&"undefined"!=typeof this._styles){var b,c="."+this.opts._class+" ."+this.opts.itemClass,d=this;if("undefined"==typeof a&&(a=this._styles._max,this._initStyles(),this._updateContainerHeight()),this.opts.cellHeight&&!(0!==this._styles._max&&a<=this._styles._max)&&(b=this.opts.verticalMargin&&this.opts.cellHeightUnit!==this.opts.verticalMarginUnit?function(a,b){return a&&b?"calc("+(d.opts.cellHeight*a+d.opts.cellHeightUnit)+" + "+(d.opts.verticalMargin*b+d.opts.verticalMarginUnit)+")":d.opts.cellHeight*a+d.opts.verticalMargin*b+d.opts.cellHeightUnit}:function(a,b){return d.opts.cellHeight*a+d.opts.verticalMargin*b+d.opts.cellHeightUnit},0===this._styles._max&&g.insertCSSRule(this._styles,c,"min-height: "+b(1,0)+";",0),a>this._styles._max)){for(var e=this._styles._max;e=f.grid.width||k<0?(f.opts.removable===!0&&f._setupRemovingTimeout(b),j=c._beforeDragX,k=c._beforeDragY,f.placeholder.detach(),f.placeholder.hide(),f.grid.removeNode(c),f._updateContainerHeight(),c._temporaryRemoved=!0):(f._clearRemovingTimeout(b),c._temporaryRemoved&&(f.grid.addNode(c),f.placeholder.attr("data-gs-x",j).attr("data-gs-y",k).attr("data-gs-width",h).attr("data-gs-height",i).show(),f.container.append(f.placeholder),c.el=f.placeholder,c._temporaryRemoved=!1));else if("resize"==a.type&&j<0)return; +// width and height are undefined if not resizing +var l="undefined"!=typeof h?h:c.lastTriedWidth,m="undefined"!=typeof i?i:c.lastTriedHeight;!f.grid.canMoveNode(c,j,k,h,i)||c.lastTriedX===j&&c.lastTriedY===k&&c.lastTriedWidth===l&&c.lastTriedHeight===m||(c.lastTriedX=j,c.lastTriedY=k,c.lastTriedWidth=h,c.lastTriedHeight=i,f.grid.moveNode(c,j,k,h,i),f._updateContainerHeight())},h=function(g,h){f.container.append(f.placeholder);var i=a(this);f.grid.cleanNodes(),f.grid.beginUpdate(c),d=f.cellWidth();var j=Math.ceil(i.outerHeight()/i.attr("data-gs-height"));e=f.container.height()/parseInt(f.container.attr("data-gs-current-height")),f.placeholder.attr("data-gs-x",i.attr("data-gs-x")).attr("data-gs-y",i.attr("data-gs-y")).attr("data-gs-width",i.attr("data-gs-width")).attr("data-gs-height",i.attr("data-gs-height")).show(),c.el=f.placeholder,c._beforeDragX=c.x,c._beforeDragY=c.y,f.dd.resizable(b,"option","minWidth",d*(c.minWidth||1)),f.dd.resizable(b,"option","minHeight",j*(c.minHeight||1)),"resizestart"==g.type&&i.find(".grid-stack-item").trigger("resizestart")},i=function(d,e){var g=a(this);if(g.data("_gridstack_node")){var h=!1;f.placeholder.detach(),c.el=g,f.placeholder.hide(),c._isAboutToRemove?(h=!0,b.removeData("_gridstack_node"),b.remove()):(f._clearRemovingTimeout(b),c._temporaryRemoved?(g.attr("data-gs-x",c._beforeDragX).attr("data-gs-y",c._beforeDragY).attr("data-gs-width",c.width).attr("data-gs-height",c.height).removeAttr("style"),c.x=c._beforeDragX,c.y=c._beforeDragY,f.grid.addNode(c)):g.attr("data-gs-x",c.x).attr("data-gs-y",c.y).attr("data-gs-width",c.width).attr("data-gs-height",c.height).removeAttr("style")),f._updateContainerHeight(),f._triggerChangeEvent(h),f.grid.endUpdate();var i=g.find(".grid-stack");i.length&&"resizestop"==d.type&&(i.each(function(b,c){a(c).data("gridstack").onResizeHandler()}),g.find(".grid-stack-item").trigger("resizestop"))}};this.dd.draggable(b,{start:h,stop:i,drag:g}).resizable(b,{start:h,stop:i,resize:g}),(c.noMove||this._isOneColumnMode()||this.opts.disableDrag)&&this.dd.draggable(b,"disable"),(c.noResize||this._isOneColumnMode()||this.opts.disableResize)&&this.dd.resizable(b,"disable"),b.attr("data-gs-locked",c.locked?"yes":null)}},j.prototype._prepareElement=function(b,c){c="undefined"!=typeof c&&c;var d=this;b=a(b),b.addClass(this.opts.itemClass);var e=d.grid.addNode({x:b.attr("data-gs-x"),y:b.attr("data-gs-y"),width:b.attr("data-gs-width"),height:b.attr("data-gs-height"),maxWidth:b.attr("data-gs-max-width"),minWidth:b.attr("data-gs-min-width"),maxHeight:b.attr("data-gs-max-height"),minHeight:b.attr("data-gs-min-height"),autoPosition:g.toBool(b.attr("data-gs-auto-position")),noResize:g.toBool(b.attr("data-gs-no-resize")),noMove:g.toBool(b.attr("data-gs-no-move")),locked:g.toBool(b.attr("data-gs-locked")),el:b,id:b.attr("data-gs-id"),_grid:d},c);b.data("_gridstack_node",e),this._prepareElementsByNode(b,e)},j.prototype.setAnimation=function(a){a?this.container.addClass("grid-stack-animate"):this.container.removeClass("grid-stack-animate")},j.prototype.addWidget=function(b,c,d,e,f,g,h,i,j,k,l){return b=a(b),"undefined"!=typeof c&&b.attr("data-gs-x",c),"undefined"!=typeof d&&b.attr("data-gs-y",d),"undefined"!=typeof e&&b.attr("data-gs-width",e),"undefined"!=typeof f&&b.attr("data-gs-height",f),"undefined"!=typeof g&&b.attr("data-gs-auto-position",g?"yes":null),"undefined"!=typeof h&&b.attr("data-gs-min-width",h),"undefined"!=typeof i&&b.attr("data-gs-max-width",i),"undefined"!=typeof j&&b.attr("data-gs-min-height",j),"undefined"!=typeof k&&b.attr("data-gs-max-height",k),"undefined"!=typeof l&&b.attr("data-gs-id",l),this.container.append(b),this._prepareElement(b,!0),this._triggerAddEvent(),this._updateContainerHeight(),this._triggerChangeEvent(!0),b},j.prototype.makeWidget=function(b){return b=a(b),this._prepareElement(b,!0),this._triggerAddEvent(),this._updateContainerHeight(),this._triggerChangeEvent(!0),b},j.prototype.willItFit=function(a,b,c,d,e){var f={x:a,y:b,width:c,height:d,autoPosition:e};return this.grid.canBePlacedWithRespectToHeight(f)},j.prototype.removeWidget=function(b,c){c="undefined"==typeof c||c,b=a(b);var d=b.data("_gridstack_node"); +// For Meteor support: https://github.com/troolee/gridstack.js/pull/272 +d||(d=this.grid.getNodeDataByDOMEl(b)),this.grid.removeNode(d,c),b.removeData("_gridstack_node"),this._updateContainerHeight(),c&&b.remove(),this._triggerChangeEvent(!0),this._triggerRemoveEvent()},j.prototype.removeAll=function(a){b.each(this.grid.nodes,b.bind(function(b){this.removeWidget(b.el,a)},this)),this.grid.nodes=[],this._updateContainerHeight()},j.prototype.destroy=function(b){a(window).off("resize",this.onResizeHandler),this.disable(),"undefined"==typeof b||b?this.container.remove():(this.removeAll(!1),this.container.removeData("gridstack")),g.removeStylesheet(this._stylesId),this.grid&&(this.grid=null)},j.prototype.resizable=function(b,c){var d=this;return b=a(b),b.each(function(b,e){e=a(e);var f=e.data("_gridstack_node");"undefined"!=typeof f&&null!==f&&"undefined"!=typeof a.ui&&(f.noResize=!c,f.noResize||d._isOneColumnMode()?d.dd.resizable(e,"disable"):d.dd.resizable(e,"enable"))}),this},j.prototype.movable=function(b,c){var d=this;return b=a(b),b.each(function(b,e){e=a(e);var f=e.data("_gridstack_node");"undefined"!=typeof f&&null!==f&&"undefined"!=typeof a.ui&&(f.noMove=!c,f.noMove||d._isOneColumnMode()?(d.dd.draggable(e,"disable"),e.removeClass("ui-draggable-handle")):(d.dd.draggable(e,"enable"),e.addClass("ui-draggable-handle")))}),this},j.prototype.enableMove=function(a,b){this.movable(this.container.children("."+this.opts.itemClass),a),b&&(this.opts.disableDrag=!a)},j.prototype.enableResize=function(a,b){this.resizable(this.container.children("."+this.opts.itemClass),a),b&&(this.opts.disableResize=!a)},j.prototype.disable=function(){this.movable(this.container.children("."+this.opts.itemClass),!1),this.resizable(this.container.children("."+this.opts.itemClass),!1),this.container.trigger("disable")},j.prototype.enable=function(){this.movable(this.container.children("."+this.opts.itemClass),!0),this.resizable(this.container.children("."+this.opts.itemClass),!0),this.container.trigger("enable")},j.prototype.locked=function(b,c){return b=a(b),b.each(function(b,d){d=a(d);var e=d.data("_gridstack_node");"undefined"!=typeof e&&null!==e&&(e.locked=c||!1,d.attr("data-gs-locked",e.locked?"yes":null))}),this},j.prototype.maxHeight=function(b,c){return b=a(b),b.each(function(b,d){d=a(d);var e=d.data("_gridstack_node");"undefined"!=typeof e&&null!==e&&(isNaN(c)||(e.maxHeight=c||!1,d.attr("data-gs-max-height",c)))}),this},j.prototype.minHeight=function(b,c){return b=a(b),b.each(function(b,d){d=a(d);var e=d.data("_gridstack_node");"undefined"!=typeof e&&null!==e&&(isNaN(c)||(e.minHeight=c||!1,d.attr("data-gs-min-height",c)))}),this},j.prototype.maxWidth=function(b,c){return b=a(b),b.each(function(b,d){d=a(d);var e=d.data("_gridstack_node");"undefined"!=typeof e&&null!==e&&(isNaN(c)||(e.maxWidth=c||!1,d.attr("data-gs-max-width",c)))}),this},j.prototype.minWidth=function(b,c){return b=a(b),b.each(function(b,d){d=a(d);var e=d.data("_gridstack_node");"undefined"!=typeof e&&null!==e&&(isNaN(c)||(e.minWidth=c||!1,d.attr("data-gs-min-width",c)))}),this},j.prototype._updateElement=function(b,c){b=a(b).first();var d=b.data("_gridstack_node");if("undefined"!=typeof d&&null!==d){var e=this;e.grid.cleanNodes(),e.grid.beginUpdate(d),c.call(this,b,d),e._updateContainerHeight(),e._triggerChangeEvent(),e.grid.endUpdate()}},j.prototype.resize=function(a,b,c){this._updateElement(a,function(a,d){b=null!==b&&"undefined"!=typeof b?b:d.width,c=null!==c&&"undefined"!=typeof c?c:d.height,this.grid.moveNode(d,d.x,d.y,b,c)})},j.prototype.move=function(a,b,c){this._updateElement(a,function(a,d){b=null!==b&&"undefined"!=typeof b?b:d.x,c=null!==c&&"undefined"!=typeof c?c:d.y,this.grid.moveNode(d,b,c,d.width,d.height)})},j.prototype.update=function(a,b,c,d,e){this._updateElement(a,function(a,f){b=null!==b&&"undefined"!=typeof b?b:f.x,c=null!==c&&"undefined"!=typeof c?c:f.y,d=null!==d&&"undefined"!=typeof d?d:f.width,e=null!==e&&"undefined"!=typeof e?e:f.height,this.grid.moveNode(f,b,c,d,e)})},j.prototype.verticalMargin=function(a,b){if("undefined"==typeof a)return this.opts.verticalMargin;var c=g.parseHeight(a);this.opts.verticalMarginUnit===c.unit&&this.opts.height===c.height||(this.opts.verticalMarginUnit=c.unit,this.opts.verticalMargin=c.height,b||this._updateStyles())},j.prototype.cellHeight=function(a,b){if("undefined"==typeof a){if(this.opts.cellHeight)return this.opts.cellHeight;var c=this.container.children("."+this.opts.itemClass).first();return Math.ceil(c.outerHeight()/c.attr("data-gs-height"))}var d=g.parseHeight(a);this.opts.cellHeightUnit===d.heightUnit&&this.opts.height===d.height||(this.opts.cellHeightUnit=d.unit,this.opts.cellHeight=d.height,b||this._updateStyles())},j.prototype.cellWidth=function(){return Math.round(this.container.outerWidth()/this.opts.width)},j.prototype.getCellFromPixel=function(a,b){var c="undefined"!=typeof b&&b?this.container.offset():this.container.position(),d=a.left-c.left,e=a.top-c.top,f=Math.floor(this.container.width()/this.opts.width),g=Math.floor(this.container.height()/parseInt(this.container.attr("data-gs-current-height")));return{x:Math.floor(d/f),y:Math.floor(e/g)}},j.prototype.batchUpdate=function(){this.grid.batchUpdate()},j.prototype.commit=function(){this.grid.commit(),this._updateContainerHeight()},j.prototype.isAreaEmpty=function(a,b,c,d){return this.grid.isAreaEmpty(a,b,c,d)},j.prototype.setStatic=function(a){this.opts.staticGrid=a===!0,this.enableMove(!a),this.enableResize(!a),this._setStaticClass()},j.prototype._setStaticClass=function(){var a="grid-stack-static";this.opts.staticGrid===!0?this.container.addClass(a):this.container.removeClass(a)},j.prototype._updateNodeWidths=function(a,b){this.grid._sortNodes(),this.grid.batchUpdate();for(var c={},d=0;d + +**Table of Contents** *generated with [DocToc](http://doctoc.herokuapp.com/)* + +- [Gridstack doesn't use bootstrap 3 classes. Why you say it's bootstrap 3 friendly.](#gridstack-doesnt-use-bootstrap-3-classes-why-you-say-its-bootstrap-3-friendly) +- [How can I create a static layout using gridstack.](#how-can-i-create-a-static-layout-using-gridstack) + + + +### Gridstack doesn't use bootstrap 3 classes. Why you say it's bootstrap 3 friendly. + +**Q:** + +Original issue #390: + +> Hi, +> +> Excuse my ignorance but on your site you write "responsive bootstrap v3 friendly layouts" but how? +> +> In none of the examples you actually make use of any bootstrap classes. You add it to head but if you do that with gridster it works exactly the same.. +> +> What does gridstack do different then gridster? +> +> Reason I'm asking is because I have bootstrap HTML templates I want to put them in the grid so users can move it all around .. then when done have a normal html page (without the draggable grid). I thought gridstack would help to do that in favor of gridster but so far I have not seen any difference between the 2.. +> +> Thanks! + +**A:** + +We never declare that gridstack uses bootstrap classes. We say that gridstack could be responsive (widgets are not fixed width) it works well on bootstrap 3 pages with fixed or responsive layout. That's why it says bootstrap 3 friendly. + +It wasn't a goal for gridstack to create bootstrap 3 layouts. It's not a goal now neither. The goal of gridstack is to create dashboard layouts with draggable/resizable widgets. + +Gridstack uses internal grid to implement its logic. DOM nodes are just interpretation of this grid. So we or you probably could create a third party library which exports this internal grid into bootstrap 3/bootstrap 4/absolute divs/whatever layout. But I don't see this as part of gridstack core. As the same as support of angular/knockout/whatever libraries. We're doing all necessary for smooth support but it will never be a part of core. + +The main idea is to build as simple and flexible lib as possible. + + +### How can I create a static layout using gridstack. + +**Q:** + +How can I create a static layout not using jQuery UI, etc. + +**A:** + +The main propose of gridstack is creating dashboards with draggable and/or resizable widgets. You could disable this behavior by setting `static` option. At this point you will probably +still need to include jQuery UI. But we will try to decrease dependency of it in near future. diff --git a/doc/README.md b/doc/README.md new file mode 100644 index 000000000..3320fdbde --- /dev/null +++ b/doc/README.md @@ -0,0 +1,474 @@ +gridstack.js API +================ + + + +**Table of Contents** *generated with [DocToc](http://doctoc.herokuapp.com/)* + +- [Options](#options) +- [Grid attributes](#grid-attributes) +- [Item attributes](#item-attributes) +- [Events](#events) + - [added(event, items)](#addedevent-items) + - [change(event, items)](#changeevent-items) + - [disable(event)](#disableevent) + - [dragstart(event, ui)](#dragstartevent-ui) + - [dragstop(event, ui)](#dragstopevent-ui) + - [enable(event)](#enableevent) + - [removed(event, items)](#removedevent-items) + - [resizestart(event, ui)](#resizestartevent-ui) + - [resizestop(event, ui)](#resizestopevent-ui) +- [API](#api) + - [addWidget(el[, x, y, width, height, autoPosition, minWidth, maxWidth, minHeight, maxHeight, id])](#addwidgetel-x-y-width-height-autoposition-minwidth-maxwidth-minheight-maxheight-id) + - [batchUpdate()](#batchupdate) + - [cellHeight()](#cellheight) + - [cellHeight(val)](#cellheightval) + - [cellWidth()](#cellwidth) + - [commit()](#commit) + - [destroy([detachGrid])](#destroydetachgrid) + - [disable()](#disable) + - [enable()](#enable) + - [enableMove(doEnable, includeNewWidgets)](#enablemovedoenable-includenewwidgets) + - [enableResize(doEnable, includeNewWidgets)](#enableresizedoenable-includenewwidgets) + - [getCellFromPixel(position[, useOffset])](#getcellfrompixelposition-useoffset) + - [isAreaEmpty(x, y, width, height)](#isareaemptyx-y-width-height) + - [locked(el, val)](#lockedel-val) + - [makeWidget(el)](#makewidgetel) + - [maxHeight(el, val)](#maxheightel-val) + - [minHeight(el, val)](#minheightel-val) + - [maxWidth(el, val)](#maxwidthel-val) + - [minWidth(el, val)](#minwidthel-val) + - [movable(el, val)](#movableel-val) + - [move(el, x, y)](#moveel-x-y) + - [removeWidget(el[, detachNode])](#removewidgetel-detachnode) + - [removeAll([detachNode])](#removealldetachnode) + - [resize(el, width, height)](#resizeel-width-height) + - [resizable(el, val)](#resizableel-val) + - [setAnimation(doAnimate)](#setanimationdoanimate) + - [setGridWidth(gridWidth, doNotPropagate)](#setgridwidthgridwidth-donotpropagate) + - [setStatic(staticValue)](#setstaticstaticvalue) + - [update(el, x, y, width, height)](#updateel-x-y-width-height) + - [verticalMargin(value, noUpdate)](#verticalmarginvalue-noupdate) + - [willItFit(x, y, width, height, autoPosition)](#willitfitx-y-width-height-autoposition) +- [Utils](#utils) + - [GridStackUI.Utils.sort(nodes[, dir[, width]])](#gridstackuiutilssortnodes-dir-width) + + + +## Options + +- `acceptWidgets` - if `true` of jquery selector the grid will accept widgets dragged from other grids or from + outside (default: `false`) See [example](http://troolee.github.io/gridstack.js/demo/two.html) +- `alwaysShowResizeHandle` - if `true` the resizing handles are shown even if the user is not hovering over the widget + (default: `false`) +- `animate` - turns animation on (default: `false`) +- `auto` - if `false` gridstack will not initialize existing items (default: `true`) +- `cellHeight` - one cell height (default: `60`). Can be: + - an integer (px) + - a string (ex: '10em', '100px', '10rem') + - 0 or null, in which case the library will not generate styles for rows. Everything must be defined in CSS files. + - `'auto'` - height will be calculated from cell width. +- `ddPlugin` - class that implement drag'n'drop functionallity for gridstack. If `false` grid will be static. (default: `null` - first available plugin will be used) +- `disableDrag` - disallows dragging of widgets (default: `false`). +- `disableResize` - disallows resizing of widgets (default: `false`). +- `draggable` - allows to override jQuery UI draggable options. (default: `{handle: '.grid-stack-item-content', scroll: false, appendTo: 'body'}`) +- `handle` - draggable handle selector (default: `'.grid-stack-item-content'`) +- `handleClass` - draggable handle class (e.g. `'grid-stack-item-content'`). If set `handle` is ignored (default: `null`) +- `height` - maximum rows amount. Default is `0` which means no maximum rows +- `float` - enable floating widgets (default: `false`) See [example](http://troolee.github.io/gridstack.js/demo/float.html) +- `itemClass` - widget class (default: `'grid-stack-item'`) +- `minWidth` - minimal width. If window width is less, grid will be shown in one-column mode (default: `768`) +- `oneColumnModeClass` - class set on grid when in one column mode (default: 'grid-stack-one-column-mode') +- `placeholderClass` - class for placeholder (default: `'grid-stack-placeholder'`) +- `placeholderText` - placeholder default content (default: `''`) +- `resizable` - allows to override jQuery UI resizable options. (default: `{autoHide: true, handles: 'se'}`) +- `removable` - if `true` widgets could be removed by dragging outside of the grid. It could also be a jQuery selector string, in this case widgets will be removed by dropping them there (default: `false`) See [example](http://troolee.github.io/gridstack.js/demo/two.html) +- `removeTimeout` - time in milliseconds before widget is being removed while dragging outside of the grid. (default: `2000`) +- `rtl` - if `true` turns grid to RTL. Possible values are `true`, `false`, `'auto'` (default: `'auto'`) See [example](http://troolee.github.io/gridstack.js/demo/rtl.html) +- `staticGrid` - makes grid static (default `false`). If true widgets are not movable/resizable. You don't even need jQueryUI draggable/resizable. A CSS class `grid-stack-static` is also added to the container. +- `verticalMargin` - vertical gap size (default: `20`). Can be: + - an integer (px) + - a string (ex: '2em', '20px', '2rem') +- `width` - amount of columns (default: `12`) + +## Grid attributes + +- `data-gs-animate` - turns animation on +- `data-gs-width` - amount of columns +- `data-gs-height` - maximum rows amount. Default is `0` which means no maximum rows. +- `data-gs-current-height` - current rows amount. Set by the library only. Can be used by the CSS rules. + +## Item attributes + +- `data-gs-x`, `data-gs-y` - element position +- `data-gs-width`, `data-gs-height` - element size +- `data-gs-max-width`, `data-gs-min-width`, `data-gs-max-height`, `data-gs-min-height` - element constraints +- `data-gs-no-resize` - disable element resizing +- `data-gs-no-move` - disable element moving +- `data-gs-auto-position` - tells to ignore `data-gs-x` and `data-gs-y` attributes and to place element to the first + available position +- `data-gs-locked` - the widget will be locked. It means another widget wouldn't be able to move it during dragging or resizing. +The widget can still be dragged or resized. You need to add `data-gs-no-resize` and `data-gs-no-move` attributes +to completely lock the widget. + +## Events + +### added(event, items) + +```javascript +$('.grid-stack').on('added', function(event, items) { + for (var i = 0; i < items.length; i++) { + console.log('item added'); + console.log(items[i]); + } +}); +``` + +### change(event, items) + +Occurs when adding/removing widgets or existing widgets change their position/size + +```javascript +var serializeWidgetMap = function(items) { + console.log(items); +}; + +$('.grid-stack').on('change', function(event, items) { + serializeWidgetMap(items); +}); +``` + +### disable(event) + +```javascript +$('.grid-stack').on('disable', function(event) { + var grid = event.target; +}); +``` + +### dragstart(event, ui) + +```javascript +$('.grid-stack').on('dragstart', function(event, ui) { + var grid = this; + var element = event.target; +}); +``` + +### dragstop(event, ui) + +```javascript +$('.grid-stack').on('dragstop', function(event, ui) { + var grid = this; + var element = event.target; +}); +``` + +### enable(event) + +```javascript +$('.grid-stack').on('enable', function(event) { + var grid = event.target; +}); +``` + +### removed(event, items) + +```javascript +$('.grid-stack').on('removed', function(event, items) { + for (var i = 0; i < items.length; i++) { + console.log('item removed'); + console.log(items[i]); + } +}); +``` + +### resizestart(event, ui) + +```javascript +$('.grid-stack').on('resizestart', function(event, ui) { + var grid = this; + var element = event.target; +}); +``` + +### resizestop(event, ui) + +```javascript +$('.grid-stack').on('resizestop', function(event, ui) { + var grid = this; + var element = event.target; +}); +``` + +## API + +### addWidget(el[, x, y, width, height, autoPosition, minWidth, maxWidth, minHeight, maxHeight, id]) + +Creates new widget and returns it. + +Parameters: + +- `el` - widget to add +- `x`, `y`, `width`, `height` - widget position/dimensions (optional) +- `autoPosition` - if `true` then `x`, `y` parameters will be ignored and widget will be places on the first available +position (optional) +- `minWidth` minimum width allowed during resize/creation (optional) +- `maxWidth` maximum width allowed during resize/creation (optional) +- `minHeight` minimum height allowed during resize/creation (optional) +- `maxHeight` maximum height allowed during resize/creation (optional) +- `id` value for `data-gs-id` (optional) + +Widget will be always placed even if result height is more than actual grid height. You need to use `willItFit` method +before calling `addWidget` for additional check. + +```javascript +$('.grid-stack').gridstack(); + +var grid = $('.grid-stack').data('gridstack'); +grid.addWidget(el, 0, 0, 3, 2, true); +``` + +### batchUpdate() + +Initailizes batch updates. You will see no changes until `commit` method is called. + +### cellHeight() + +Gets current cell height. + +### cellHeight(val) + +Update current cell height. This method rebuilds an internal CSS stylesheet. Note: You can expect performance issues if +call this method too often. + +```javascript +grid.cellHeight(grid.cellWidth() * 1.2); +``` + +### cellWidth() + +Gets current cell width. + +### commit() + +Finishes batch updates. Updates DOM nodes. You must call it after `batchUpdate`. + +### destroy([detachGrid]) + +Destroys a grid instance. + +Parameters: + +- `detachGrid` - if `false` nodes and grid will not be removed from the DOM (Optional. Default `true`). + +### disable() + +Disables widgets moving/resizing. This is a shortcut for: + +```javascript +grid.movable('.grid-stack-item', false); +grid.resizable('.grid-stack-item', false); +``` + +### enable() + +Enables widgets moving/resizing. This is a shortcut for: + +```javascript +grid.movable('.grid-stack-item', true); +grid.resizable('.grid-stack-item', true); +``` + +### enableMove(doEnable, includeNewWidgets) + +Enables/disables widget moving. `includeNewWidgets` will force new widgets to be draggable as per `doEnable`'s value by changing the `disableDrag` grid option. This is a shortcut for: + +```javascript +grid.movable(this.container.children('.' + this.opts.itemClass), doEnable); +``` + +### enableResize(doEnable, includeNewWidgets) + +Enables/disables widget resizing. `includeNewWidgets` will force new widgets to be resizable as per `doEnable`'s value by changing the `disableResize` grid option. This is a shortcut for: + +```javascript +grid.resizable(this.container.children('.' + this.opts.itemClass), doEnable); +``` + +### getCellFromPixel(position[, useOffset]) + +Get the position of the cell under a pixel on screen. + +Parameters : + +- `position` - the position of the pixel to resolve in absolute coordinates, as an object with `top` and `left` properties +- `useOffset` - if `true`, value will be based on offset vs position (Optional. Default `false`). Useful when grid is within `position: relative` element. + +Returns an object with properties `x` and `y` i.e. the column and row in the grid. + +### isAreaEmpty(x, y, width, height) + +Checks if specified area is empty. + +### locked(el, val) + +Locks/unlocks widget. + +- `el` - widget to modify. +- `val` - if `true` widget will be locked. + +### makeWidget(el) + +If you add elements to your gridstack container by hand, you have to tell gridstack afterwards to make them widgets. If you want gridstack to add the elements for you, use `addWidget` instead. +Makes the given element a widget and returns it. + +Parameters: + +- `el` - element to convert to a widget + +```javascript +$('.grid-stack').gridstack(); + +$('.grid-stack').append('
') +var grid = $('.grid-stack').data('gridstack'); +grid.makeWidget('gsi-1'); +``` + +### maxHeight(el, val) + +Set the `maxHeight` for a widget. + +- `el` - widget to modify. +- `val` - A numeric value of the number of rows + +### minHeight(el, val) + +Set the `minHeight` for a widget. + +- `el` - widget to modify. +- `val` - A numeric value of the number of rows + +### maxWidth(el, val) + +Set the `maxWidth` for a widget. + +- `el` - widget to modify. +- `val` - A numeric value of the number of columns + +### minWidth(el, val) + +Set the `minWidth` for a widget. + +- `el` - widget to modify. +- `val` - A numeric value of the number of columns + +### movable(el, val) + +Enables/Disables moving. + +- `el` - widget to modify +- `val` - if `true` widget will be draggable. + +### move(el, x, y) + +Changes widget position + +Parameters: + +- `el` - widget to move +- `x`, `y` - new position. If value is `null` or `undefined` it will be ignored. + +### removeWidget(el[, detachNode]) + +Removes widget from the grid. + +Parameters: + +- `el` - widget to remove. +- `detachNode` - if `false` node won't be removed from the DOM (Optional. Default `true`). + +### removeAll([detachNode]) + +Removes all widgets from the grid. + +Parameters: + +- `detachNode` - if `false` nodes won't be removed from the DOM (Optional. Default `true`). + +### resize(el, width, height) + +Changes widget size + +Parameters: + +- `el` - widget to resize +- `width`, `height` - new dimensions. If value is `null` or `undefined` it will be ignored. + +### resizable(el, val) + +Enables/Disables resizing. + +- `el` - widget to modify +- `val` - if `true` widget will be resizable. + +### setAnimation(doAnimate) + +Toggle the grid animation state. Toggles the `grid-stack-animate` class. + +- `doAnimate` - if `true` the grid will animate. + +### setGridWidth(gridWidth, doNotPropagate) + +(Experimental) Modify number of columns in the grid. Will attempt to update existing widgets to conform to new number of columns. Requires `gridstack-extra.css` or `gridstack-extra.min.css`. + +- `gridWidth` - Integer between 1 and 12. +- `doNotPropagate` - if true existing widgets will not be updated. + +### setStatic(staticValue) + +Toggle the grid static state. Also toggle the `grid-stack-static` class. + +- `staticValue` - if `true` the grid becomes static. + +### update(el, x, y, width, height) + +Parameters: + +- `el` - widget to move +- `x`, `y` - new position. If value is `null` or `undefined` it will be ignored. +- `width`, `height` - new dimensions. If value is `null` or `undefined` it will be ignored. + +Updates widget position/size. + +### verticalMargin(value, noUpdate) + +Parameters: + +- `value` - new vertical margin value. +- `noUpdate` - if true, styles will not be updated. + +### willItFit(x, y, width, height, autoPosition) + +Returns `true` if the `height` of the grid will be less the vertical constraint. Always returns `true` if grid doesn't +have `height` constraint. + +```javascript +if (grid.willItFit(newNode.x, newNode.y, newNode.width, newNode.height, true)) { + grid.addWidget(newNode.el, newNode.x, newNode.y, newNode.width, newNode.height, true); +} +else { + alert('Not enough free space to place the widget'); +} +``` + + +## Utils + +### GridStackUI.Utils.sort(nodes[, dir[, width]]) + +Sorts array of nodes + +- `nodes` - array to sort +- `dir` - `1` for asc, `-1` for desc (optional) +- `width` - width of the grid. If `undefined` the width will be calculated automatically (optional). diff --git a/karma.conf.js b/karma.conf.js new file mode 100644 index 000000000..4230ca8a3 --- /dev/null +++ b/karma.conf.js @@ -0,0 +1,81 @@ +// Karma configuration +// Generated on Thu Feb 18 2016 22:00:23 GMT+0100 (CET) + +module.exports = function(config) { + config.set({ + + // base path that will be used to resolve all patterns (eg. files, exclude) + basePath: '', + + + // frameworks to use + // available frameworks: https://npmjs.org/browse/keyword/karma-adapter + frameworks: ['jasmine'], + + + // list of files / patterns to load in the browser + files: [ + 'bower_components/jquery/dist/jquery.min.js', + 'bower_components/jquery-ui/jquery-ui.min.js', + 'bower_components/lodash/dist/lodash.min.js', + 'src/gridstack.js', + 'src/gridstack.jQueryUI.js', + 'spec/*-spec.js' + ], + + + // list of files to exclude + exclude: [ + ], + + + // 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'], + }, + + + // test results reporter to use + // possible values: 'dots', 'progress' + // available reporters: https://npmjs.org/browse/keyword/karma-reporter + reporters: ['progress', 'coverage', 'coveralls'], + + coverageReporter: { + type: 'lcov', // lcov or lcovonly are required for generating lcov.info files + dir: 'coverage/' + }, + + // web server port + port: 9876, + + + // enable / disable colors in the output (reporters and logs) + colors: true, + + + // level of logging + // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN + // config.LOG_INFO || config.LOG_DEBUG + logLevel: config.LOG_INFO, + + + // enable / disable watching file and executing tests whenever any file changes + autoWatch: true, + + + // start these browsers + // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher + browsers: ['PhantomJS'], + + + // Continuous Integration mode + // if true, Karma captures browsers, runs the tests and exits + singleRun: true, + + // Concurrency level + // how many browser should be started simultaneous + concurrency: Infinity + }); +} diff --git a/package.json b/package.json old mode 100755 new mode 100644 index 62f5d437f..b203ab8a9 --- a/package.json +++ b/package.json @@ -1,12 +1,16 @@ { "name": "gridstack", - "version": "0.2.3", + "version": "0.3.0-dev", "description": "gridstack.js is a jQuery plugin for widget layout", "main": "dist/gridstack.js", "repository": { "type": "git", "url": "git+https://github.com/troolee/gridstack.js.git" }, + "scripts": { + "build": "grunt", + "test": "karma start karma.conf.js" + }, "keywords": [ "gridstack", "grid", @@ -20,11 +24,35 @@ "url": "https://github.com/troolee/gridstack.js/issues" }, "homepage": "http://troolee.github.io/gridstack.js/", + "dependencies": { + "jquery": "^3.1.0", + "jquery-ui": "^1.12.0", + "lodash": "^4.14.2" + }, "devDependencies": { + "connect": "^3.4.1", + "coveralls": "^2.11.8", + "doctoc": "^1.0.0", "grunt": "^0.4.5", + "grunt-cli": "^1.2.0", + "grunt-contrib-connect": "^0.11.2", "grunt-contrib-copy": "^0.8.2", "grunt-contrib-cssmin": "^0.14.0", - "grunt-contrib-uglify": "^0.10.1", - "grunt-sass": "^1.1.0" + "grunt-contrib-jshint": "^1.0.0", + "grunt-contrib-uglify": "^0.11.1", + "grunt-contrib-watch": "^0.6.1", + "grunt-doctoc": "^0.1.1", + "grunt-jscs": "^2.8.0", + "grunt-protractor-runner": "^3.2.0", + "grunt-protractor-webdriver": "^0.2.5", + "grunt-sass": "^1.1.0", + "jasmine-core": "^2.4.1", + "karma": "^1.1.2", + "karma-coverage": "^1.1.1", + "karma-coveralls": "^1.1.2", + "karma-jasmine": "^1.0.2", + "karma-phantomjs-launcher": "^1.0.0", + "phantomjs-prebuilt": "^2.1.5", + "serve-static": "^1.10.2" } } diff --git a/protractor.conf.js b/protractor.conf.js new file mode 100644 index 000000000..edcc3f40e --- /dev/null +++ b/protractor.conf.js @@ -0,0 +1,12 @@ +exports.config = { + seleniumAddress: 'http://localhost:4444/wd/hub', + specs: ['spec/e2e/*-spec.js'], + capabilities: { + browserName: 'firefox', + version: '', + platform: 'ANY', + loggingPrefs: { + browser: 'SEVERE' + } + }, +}; diff --git a/spec/e2e/gridstack-spec.js b/spec/e2e/gridstack-spec.js new file mode 100644 index 000000000..7f3716658 --- /dev/null +++ b/spec/e2e/gridstack-spec.js @@ -0,0 +1,24 @@ +describe('gridstack.js with height', function() { + beforeAll(function() { + browser.ignoreSynchronization = true; + }); + + beforeEach(function() { + browser.get('http://localhost:8080/spec/e2e/html/gridstack-with-height.html'); + }); + + it('shouldn\'t throw exeption when dragging widget outside the grid', function() { + var widget = element(by.id('item-1')); + var gridContainer = element(by.id('grid')); + + browser.actions() + .mouseDown(widget, {x: 20, y: 20}) + .mouseMove(gridContainer, {x: 300, y: 20}) + .mouseUp() + .perform(); + + browser.manage().logs().get('browser').then(function(browserLog) { + expect(browserLog.length).toEqual(0); + }); + }); +}); diff --git a/spec/e2e/html/gridstack-with-height.html b/spec/e2e/html/gridstack-with-height.html new file mode 100644 index 000000000..2f543eba0 --- /dev/null +++ b/spec/e2e/html/gridstack-with-height.html @@ -0,0 +1,73 @@ + + + + + + + + + Codestin Search App + + + + + + + + + + + + + + +
+

gridstack.js tests

+ +
+ +
+
+
+ + + + + diff --git a/spec/gridstack-engine-spec.js b/spec/gridstack-engine-spec.js new file mode 100644 index 000000000..ef18255a0 --- /dev/null +++ b/spec/gridstack-engine-spec.js @@ -0,0 +1,311 @@ +describe('gridstack engine', function() { + 'use strict'; + + var e; + var w; + + beforeEach(function() { + w = window; + e = w.GridStackUI.Engine; + }); + + describe('test constructor', function() { + var engine; + + beforeAll(function() { + engine = new GridStackUI.Engine(12); + }); + + it('should be setup properly', function() { + expect(engine.width).toEqual(12); + expect(engine.float).toEqual(false); + expect(engine.height).toEqual(0); + expect(engine.nodes).toEqual([]); + }); + }); + + describe('test _prepareNode', function() { + var engine; + + beforeAll(function() { + engine = new GridStackUI.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})); + }); + }); + + describe('test isAreaEmpty', function() { + var engine; + + beforeAll(function() { + engine = new GridStackUI.Engine(12, null, true); + engine.nodes = [ + engine._prepareNode({x: 3, y: 2, width: 3, height: 2}) + ]; + }); + + it('should be true', function() { + expect(engine.isAreaEmpty(0, 0, 3, 2)).toEqual(true); + expect(engine.isAreaEmpty(3, 4, 3, 2)).toEqual(true); + }); + + it('should be false', function() { + expect(engine.isAreaEmpty(1, 1, 3, 2)).toEqual(false); + expect(engine.isAreaEmpty(2, 3, 3, 2)).toEqual(false); + }); + }); + + describe('test cleanNodes/getDirtyNodes', function() { + var engine; + + beforeAll(function() { + engine = new GridStackUI.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}) + ]; + }); + + beforeEach(function() { + engine._updateCounter = 0; + }); + + it('should return all dirty nodes', function() { + var nodes = engine.getDirtyNodes(); + + expect(nodes.length).toEqual(2); + expect(nodes[0].idx).toEqual(1); + expect(nodes[1].idx).toEqual(2); + }); + + it('should\'n clean nodes if _updateCounter > 0', function() { + engine._updateCounter = 1; + engine.cleanNodes(); + + expect(engine.getDirtyNodes().length).toBeGreaterThan(0); + }); + + it('should clean all dirty nodes', function() { + engine.cleanNodes(); + + expect(engine.getDirtyNodes().length).toEqual(0); + }); + }); + + describe('test batchUpdate/commit', function() { + var engine; + + beforeAll(function() { + engine = new GridStackUI.Engine(12); + }); + + it('should work on not float grids', function() { + expect(engine.float).toEqual(false); + engine.batchUpdate(); + expect(engine._updateCounter).toBeGreaterThan(0); + expect(engine.float).toEqual(true); + engine.commit(); + expect(engine._updateCounter).toEqual(0); + expect(engine.float).toEqual(false); + }); + }); + + describe('test batchUpdate/commit', function() { + var engine; + + beforeAll(function() { + engine = new GridStackUI.Engine(12, null, true); + }); + + it('should work on float grids', function() { + expect(engine.float).toEqual(true); + engine.batchUpdate(); + expect(engine._updateCounter).toBeGreaterThan(0); + expect(engine.float).toEqual(true); + engine.commit(); + expect(engine._updateCounter).toEqual(0); + expect(engine.float).toEqual(true); + }); + }); + + describe('test _notify', function() { + var engine; + var spy; + + beforeEach(function() { + spy = { + callback: function() {} + }; + spyOn(spy, 'callback'); + + engine = new GridStackUI.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}) + ]; + }); + + it('should\'n be called if _updateCounter > 0', function() { + engine._updateCounter = 1; + engine._notify(); + + expect(spy.callback).not.toHaveBeenCalled(); + }); + + it('should by called with dirty nodes', function() { + engine._notify(); + + expect(spy.callback).toHaveBeenCalledWith([ + engine.nodes[0], + engine.nodes[1] + ], true); + }); + + it('should by called with extra passed node to be removed', function() { + var n1 = {idx: -1}; + + engine._notify(n1); + + expect(spy.callback).toHaveBeenCalledWith([ + n1, + engine.nodes[0], + engine.nodes[1] + ], true); + }); + + it('should by called with extra passed node to be removed and should maintain false parameter', function() { + var n1 = {idx: -1}; + + engine._notify(n1, false); + + expect(spy.callback).toHaveBeenCalledWith([ + n1, + engine.nodes[0], + engine.nodes[1] + ], false); + }); + }); + + describe('test _packNodes', function() { + describe('using not float mode', function() { + var engine; + + var findNode = function(engine, id) { + return _.find(engine.nodes, function(i) { return i._id === id; }); + }; + + beforeEach(function() { + engine = new GridStackUI.Engine(12, null, false); + }); + + it('shouldn\'t pack one node with y coord eq 0', function() { + engine.nodes = [ + {x: 0, y: 0, width: 1, height: 1, _id: 1}, + ]; + + engine._packNodes(); + + expect(findNode(engine, 1)).toEqual(jasmine.objectContaining({x: 0, y: 0, width: 1, height: 1})); + expect(findNode(engine, 1)._dirty).toBeFalsy(); + }); + + it('should pack one node correctly', function() { + engine.nodes = [ + {x: 0, y: 1, width: 1, height: 1, _id: 1}, + ]; + + engine._packNodes(); + + expect(findNode(engine, 1)).toEqual(jasmine.objectContaining({x: 0, y: 0, width: 1, height: 1, _dirty: true})); + }); + + it('should pack nodes correctly', function() { + engine.nodes = [ + {x: 0, y: 1, width: 1, height: 1, _id: 1}, + {x: 0, y: 5, width: 1, height: 1, _id: 2}, + ]; + + engine._packNodes(); + + expect(findNode(engine, 1)).toEqual(jasmine.objectContaining({x: 0, y: 0, width: 1, height: 1, _dirty: true})); + expect(findNode(engine, 2)).toEqual(jasmine.objectContaining({x: 0, y: 1, width: 1, height: 1, _dirty: true})); + }); + + it('should pack nodes correctly', function() { + engine.nodes = [ + {x: 0, y: 5, width: 1, height: 1, _id: 1}, + {x: 0, y: 1, width: 1, height: 1, _id: 2}, + ]; + + engine._packNodes(); + + expect(findNode(engine, 2)).toEqual(jasmine.objectContaining({x: 0, y: 0, width: 1, height: 1, _dirty: true})); + expect(findNode(engine, 1)).toEqual(jasmine.objectContaining({x: 0, y: 1, width: 1, height: 1, _dirty: true})); + }); + + it('should respect locked nodes', function() { + engine.nodes = [ + {x: 0, y: 1, width: 1, height: 1, _id: 1, locked: true}, + {x: 0, y: 5, width: 1, height: 1, _id: 2}, + ]; + + engine._packNodes(); + + expect(findNode(engine, 1)).toEqual(jasmine.objectContaining({x: 0, y: 1, width: 1, height: 1})); + expect(findNode(engine, 1)._dirty).toBeFalsy(); + expect(findNode(engine, 2)).toEqual(jasmine.objectContaining({x: 0, y: 2, width: 1, height: 1, _dirty: true})); + }); + }); + }); + + describe('test isNodeChangedPosition', function() { + var engine; + + beforeAll(function() { + engine = new GridStackUI.Engine(12); + }); + + it('should return true for changed x', function() { + var widget = { x: 1, y: 2, width: 3, height: 4 }; + expect(engine.isNodeChangedPosition(widget, 2, 2)).toEqual(true); + }); + + it('should return true for changed y', function() { + var widget = { x: 1, y: 2, width: 3, height: 4 }; + expect(engine.isNodeChangedPosition(widget, 1, 1)).toEqual(true); + }); + + it('should return true for changed width', function() { + var widget = { x: 1, y: 2, width: 3, height: 4 }; + expect(engine.isNodeChangedPosition(widget, 2, 2, 4, 4)).toEqual(true); + }); + + it('should return true for changed height', function() { + var widget = { x: 1, y: 2, width: 3, height: 4 }; + expect(engine.isNodeChangedPosition(widget, 1, 2, 3, 3)).toEqual(true); + }); + + it('should return false for unchanged position', function() { + var widget = { x: 1, y: 2, width: 3, height: 4 }; + expect(engine.isNodeChangedPosition(widget, 1, 2, 3, 4)).toEqual(false); + }); + }); +}); diff --git a/spec/gridstack-spec.js b/spec/gridstack-spec.js new file mode 100644 index 000000000..0615d791f --- /dev/null +++ b/spec/gridstack-spec.js @@ -0,0 +1,1269 @@ +describe('gridstack', function() { + 'use strict'; + + var e; + var w; + var gridstackHTML = + '
' + + '
' + + '
' + + '
' + + '
' + + '
' + + '
' + + '
'; + + beforeEach(function() { + w = window; + e = w.GridStackUI.Engine; + }); + + describe('setup of gridstack', function() { + + it('should exist setup function.', function() { + + expect(e).not.toBeNull(); + expect(typeof e).toBe('function'); + }); + + it('should set default params correctly.', function() { + e.call(w); + expect(w.width).toBeUndefined(); + expect(w.float).toBe(false); + expect(w.height).toEqual(0); + expect(w.nodes).toEqual([]); + expect(typeof w.onchange).toBe('function'); + expect(w._updateCounter).toEqual(0); + expect(w._float).toEqual(w.float); + }); + + it('should set params correctly.', function() { + var fkt = function() { }; + var arr = [1,2,3]; + + e.call(w, 1, fkt, true, 2, arr); + expect(w.width).toEqual(1); + expect(w.float).toBe(true); + expect(w.height).toEqual(2); + expect(w.nodes).toEqual(arr); + expect(w.onchange).toEqual(fkt); + expect(w._updateCounter).toEqual(0); + expect(w._float).toEqual(w.float); + }); + + + }); + + describe('batch update', function() { + + it('should set float and counter when calling batchUpdate.', function() { + e.prototype.batchUpdate.call(w); + expect(w.float).toBe(true); + expect(w._updateCounter).toEqual(1); + }); + + //test commit function + + }); + + describe('sorting of nodes', function() { + + it('should sort ascending with width.', function() { + w.nodes = [{x: 7, y: 0}, {x: 4, y: 4}, {x: 9, y: 0}, {x: 0, y: 1}]; + e.prototype._sortNodes.call(w, 1); + expect(w.nodes).toEqual([{x: 0, y: 1}, {x: 7, y: 0}, {x: 4, y: 4}, {x: 9, y: 0}]); + }); + + it('should sort descending with width.', function() { + w.nodes = [{x: 7, y: 0}, {x: 4, y: 4}, {x: 9, y: 0}, {x: 0, y: 1}]; + e.prototype._sortNodes.call(w, -1); + expect(w.nodes).toEqual([{x: 9, y: 0}, {x: 4, y: 4}, {x: 7, y: 0}, {x: 0, y: 1}]); + }); + + it('should sort ascending without width.', function() { + w.width = false; + w.nodes = [{x: 7, y: 0, width: 1}, {x: 4, y: 4, width: 1}, {x: 9, y: 0, width: 1}, {x: 0, y: 1, width: 1}]; + e.prototype._sortNodes.call(w, 1); + expect(w.nodes).toEqual([{x: 7, y: 0, width: 1}, {x: 9, y: 0, width: 1}, {x: 0, y: 1, width: 1}, {x: 4, y: 4, width: 1}]); + }); + + it('should sort descending without width.', function() { + w.width = false; + w.nodes = [{x: 7, y: 0, width: 1}, {x: 4, y: 4, width: 1}, {x: 9, y: 0, width: 1}, {x: 0, y: 1, width: 1}]; + e.prototype._sortNodes.call(w, -1); + expect(w.nodes).toEqual([{x: 4, y: 4, width: 1}, {x: 0, y: 1, width: 1}, {x: 9, y: 0, width: 1}, {x: 7, y: 0, width: 1}]); + }); + + }); + + describe('grid.setAnimation', function() { + beforeEach(function() { + document.body.insertAdjacentHTML( + 'afterbegin', gridstackHTML); + }); + afterEach(function() { + document.body.removeChild(document.getElementsByClassName('grid-stack')[0]); + }); + it('should add class grid-stack-animate to the container.', function() { + var options = { + cellHeight: 80, + verticalMargin: 10 + }; + $('.grid-stack').gridstack(options); + $('.grid-stack').removeClass('grid-stack-animate'); + var grid = $('.grid-stack').data('gridstack'); + grid.setAnimation(true); + expect($('.grid-stack').hasClass('grid-stack-animate')).toBe(true); + }); + it('should remove class grid-stack-animate from the container.', function() { + var options = { + cellHeight: 80, + verticalMargin: 10 + }; + $('.grid-stack').gridstack(options); + $('.grid-stack').addClass('grid-stack-animate'); + var grid = $('.grid-stack').data('gridstack'); + grid.setAnimation(false); + expect($('.grid-stack').hasClass('grid-stack-animate')).toBe(false); + }); + }); + + describe('grid._setStaticClass', function() { + beforeEach(function() { + document.body.insertAdjacentHTML( + 'afterbegin', gridstackHTML); + }); + afterEach(function() { + document.body.removeChild(document.getElementsByClassName('grid-stack')[0]); + }); + it('should add class grid-stack-static to the container.', function() { + var options = { + cellHeight: 80, + verticalMargin: 10, + staticGrid: true + }; + $('.grid-stack').gridstack(options); + $('.grid-stack').removeClass('grid-stack-static'); + var grid = $('.grid-stack').data('gridstack'); + grid._setStaticClass(); + expect($('.grid-stack').hasClass('grid-stack-static')).toBe(true); + }); + it('should remove class grid-stack-static from the container.', function() { + var options = { + cellHeight: 80, + verticalMargin: 10, + staticGrid: false + }; + $('.grid-stack').gridstack(options); + $('.grid-stack').addClass('grid-stack-static'); + var grid = $('.grid-stack').data('gridstack'); + grid._setStaticClass(); + expect($('.grid-stack').hasClass('grid-stack-static')).toBe(false); + }); + }); + + describe('grid.getCellFromPixel', function() { + beforeEach(function() { + document.body.insertAdjacentHTML( + 'afterbegin', gridstackHTML); + }); + afterEach(function() { + document.body.removeChild(document.getElementsByClassName('grid-stack')[0]); + }); + it('should return {x: 2, y: 1}.', function() { + var options = { + cellHeight: 80, + verticalMargin: 10 + }; + $('.grid-stack').gridstack(options); + var grid = $('.grid-stack').data('gridstack'); + var pixel = {top: 100, left: 72}; + var cell = grid.getCellFromPixel(pixel); + expect(cell.x).toBe(2); + expect(cell.y).toBe(1); + }); + it('should return {x: 2, y: 1}.', function() { + var options = { + cellHeight: 80, + verticalMargin: 10 + }; + $('.grid-stack').gridstack(options); + var grid = $('.grid-stack').data('gridstack'); + var pixel = {top: 100, left: 72}; + var cell = grid.getCellFromPixel(pixel, false); + expect(cell.x).toBe(2); + expect(cell.y).toBe(1); + }); + it('should return {x: 2, y: 1}.', function() { + var options = { + cellHeight: 80, + verticalMargin: 10 + }; + $('.grid-stack').gridstack(options); + var grid = $('.grid-stack').data('gridstack'); + var pixel = {top: 100, left: 72}; + var cell = grid.getCellFromPixel(pixel, true); + expect(cell.x).toBe(2); + expect(cell.y).toBe(1); + }); + }); + + describe('grid.cellWidth', function() { + beforeEach(function() { + document.body.insertAdjacentHTML( + 'afterbegin', gridstackHTML); + }); + afterEach(function() { + document.body.removeChild(document.getElementsByClassName('grid-stack')[0]); + }); + it('should return 1/12th of container width.', function() { + var options = { + cellHeight: 80, + verticalMargin: 10, + width: 12 + }; + $('.grid-stack').gridstack(options); + var grid = $('.grid-stack').data('gridstack'); + var res = Math.round($('.grid-stack').outerWidth() / 12); + expect(grid.cellWidth()).toBe(res); + }); + it('should return 1/10th of container width.', function() { + var options = { + cellHeight: 80, + verticalMargin: 10, + width: 10 + }; + $('.grid-stack').gridstack(options); + var grid = $('.grid-stack').data('gridstack'); + var res = Math.round($('.grid-stack').outerWidth() / 10); + expect(grid.cellWidth()).toBe(res); + }); + }); + + describe('grid.minWidth', function() { + beforeEach(function() { + document.body.insertAdjacentHTML( + 'afterbegin', gridstackHTML); + }); + afterEach(function() { + document.body.removeChild(document.getElementsByClassName('grid-stack')[0]); + }); + it('should set data-gs-min-width to 2.', function() { + var options = { + cellHeight: 80, + verticalMargin: 10 + }; + $('.grid-stack').gridstack(options); + var grid = $('.grid-stack').data('gridstack'); + var items = $('.grid-stack-item'); + for (var i = 0; i < items.length; i++) { + grid.minWidth(items[i], 2); + } + for (var j = 0; j < items.length; j++) { + expect(parseInt($(items[j]).attr('data-gs-min-width'), 10)).toBe(2); + } + }); + }); + + describe('grid.maxWidth', function() { + beforeEach(function() { + document.body.insertAdjacentHTML( + 'afterbegin', gridstackHTML); + }); + afterEach(function() { + document.body.removeChild(document.getElementsByClassName('grid-stack')[0]); + }); + it('should set data-gs-min-width to 2.', function() { + var options = { + cellHeight: 80, + verticalMargin: 10 + }; + $('.grid-stack').gridstack(options); + var grid = $('.grid-stack').data('gridstack'); + var items = $('.grid-stack-item'); + for (var i = 0; i < items.length; i++) { + grid.maxWidth(items[i], 2); + } + for (var j = 0; j < items.length; j++) { + expect(parseInt($(items[j]).attr('data-gs-max-width'), 10)).toBe(2); + } + }); + }); + + describe('grid.minHeight', function() { + beforeEach(function() { + document.body.insertAdjacentHTML( + 'afterbegin', gridstackHTML); + }); + afterEach(function() { + document.body.removeChild(document.getElementsByClassName('grid-stack')[0]); + }); + it('should set data-gs-min-height to 2.', function() { + var options = { + cellHeight: 80, + verticalMargin: 10 + }; + $('.grid-stack').gridstack(options); + var grid = $('.grid-stack').data('gridstack'); + var items = $('.grid-stack-item'); + for (var i = 0; i < items.length; i++) { + grid.minHeight(items[i], 2); + } + for (var j = 0; j < items.length; j++) { + expect(parseInt($(items[j]).attr('data-gs-min-height'), 10)).toBe(2); + } + }); + }); + + describe('grid.maxHeight', function() { + beforeEach(function() { + document.body.insertAdjacentHTML( + 'afterbegin', gridstackHTML); + }); + afterEach(function() { + document.body.removeChild(document.getElementsByClassName('grid-stack')[0]); + }); + it('should set data-gs-min-height to 2.', function() { + var options = { + cellHeight: 80, + verticalMargin: 10 + }; + $('.grid-stack').gridstack(options); + var grid = $('.grid-stack').data('gridstack'); + var items = $('.grid-stack-item'); + for (var i = 0; i < items.length; i++) { + grid.maxHeight(items[i], 2); + } + for (var j = 0; j < items.length; j++) { + expect(parseInt($(items[j]).attr('data-gs-max-height'), 10)).toBe(2); + } + }); + }); + + describe('grid.isAreaEmpty', function() { + beforeEach(function() { + document.body.insertAdjacentHTML( + 'afterbegin', gridstackHTML); + }); + afterEach(function() { + document.body.removeChild(document.getElementsByClassName('grid-stack')[0]); + }); + it('should set return false.', function() { + var options = { + cellHeight: 80, + verticalMargin: 10 + }; + $('.grid-stack').gridstack(options); + var grid = $('.grid-stack').data('gridstack'); + var shouldBeFalse = grid.isAreaEmpty(1, 1, 1, 1); + expect(shouldBeFalse).toBe(false); + }); + it('should set return true.', function() { + var options = { + cellHeight: 80, + verticalMargin: 10 + }; + $('.grid-stack').gridstack(options); + var grid = $('.grid-stack').data('gridstack'); + var shouldBeTrue = grid.isAreaEmpty(5, 5, 1, 1); + expect(shouldBeTrue).toBe(true); + }); + }); + + describe('grid method obsolete warnings', function() { + beforeEach(function() { + document.body.insertAdjacentHTML( + 'afterbegin', gridstackHTML); + }); + afterEach(function() { + document.body.removeChild(document.getElementsByClassName('grid-stack')[0]); + }); + it('should log a warning if set_static is called.', function() { + console.warn = jasmine.createSpy('log'); + var options = { + cellHeight: 80, + verticalMargin: 10 + }; + $('.grid-stack').gridstack(options); + var grid = $('.grid-stack').data('gridstack'); + grid.set_static(true); + expect(console.warn).toHaveBeenCalledWith('gridstack.js: Function `set_static` is deprecated as of v0.2.5 and has been replaced with `setStatic`. It will be **completely** removed in v1.0.'); + }); + it('should log a warning if _set_static_class is called.', function() { + console.warn = jasmine.createSpy('log'); + var options = { + cellHeight: 80, + verticalMargin: 10 + }; + $('.grid-stack').gridstack(options); + var grid = $('.grid-stack').data('gridstack'); + grid._set_static_class(); + expect(console.warn).toHaveBeenCalledWith('gridstack.js: Function `_set_static_class` is deprecated as of v0.2.5 and has been replaced with `_setStaticClass`. It will be **completely** removed in v1.0.'); + }); + it('should log a warning if is_area_empty is called.', function() { + console.warn = jasmine.createSpy('log'); + var options = { + cellHeight: 80, + verticalMargin: 10 + }; + $('.grid-stack').gridstack(options); + var grid = $('.grid-stack').data('gridstack'); + grid.is_area_empty(1, 1, 1, 1); + expect(console.warn).toHaveBeenCalledWith('gridstack.js: Function `is_area_empty` is deprecated as of v0.2.5 and has been replaced with `isAreaEmpty`. It will be **completely** removed in v1.0.'); + }); + it('should log a warning if batch_update is called.', function() { + console.warn = jasmine.createSpy('log'); + var options = { + cellHeight: 80, + verticalMargin: 10 + }; + $('.grid-stack').gridstack(options); + var grid = $('.grid-stack').data('gridstack'); + grid.batch_update(); + expect(console.warn).toHaveBeenCalledWith('gridstack.js: Function `batch_update` is deprecated as of v0.2.5 and has been replaced with `batchUpdate`. It will be **completely** removed in v1.0.'); + }); + it('should log a warning if get_cell_from_pixel is called.', function() { + console.warn = jasmine.createSpy('log'); + var options = { + cellHeight: 80, + verticalMargin: 10 + }; + $('.grid-stack').gridstack(options); + var grid = $('.grid-stack').data('gridstack'); + var pixel = {top: 100, left: 72}; + grid.get_cell_from_pixel(pixel); + expect(console.warn).toHaveBeenCalledWith('gridstack.js: Function `get_cell_from_pixel` is deprecated as of v0.2.5 and has been replaced with `getCellFromPixel`. It will be **completely** removed in v1.0.'); + }); + it('should log a warning if cell_width is called.', function() { + console.warn = jasmine.createSpy('log'); + var options = { + cellHeight: 80, + verticalMargin: 10 + }; + $('.grid-stack').gridstack(options); + var grid = $('.grid-stack').data('gridstack'); + grid.cell_width(); + expect(console.warn).toHaveBeenCalledWith('gridstack.js: Function `cell_width` is deprecated as of v0.2.5 and has been replaced with `cellWidth`. It will be **completely** removed in v1.0.'); + }); + it('should log a warning if cell_height is called.', function() { + console.warn = jasmine.createSpy('log'); + var options = { + cellHeight: 80, + verticalMargin: 10 + }; + $('.grid-stack').gridstack(options); + var grid = $('.grid-stack').data('gridstack'); + grid.cell_height(); + expect(console.warn).toHaveBeenCalledWith('gridstack.js: Function `cell_height` is deprecated as of v0.2.5 and has been replaced with `cellHeight`. It will be **completely** removed in v1.0.'); + }); + it('should log a warning if _update_element is called.', function() { + console.warn = jasmine.createSpy('log'); + var options = { + cellHeight: 80, + verticalMargin: 10 + }; + $('.grid-stack').gridstack(options); + var grid = $('.grid-stack').data('gridstack'); + grid._update_element(); + expect(console.warn).toHaveBeenCalledWith('gridstack.js: Function `_update_element` is deprecated as of v0.2.5 and has been replaced with `_updateElement`. It will be **completely** removed in v1.0.'); + }); + it('should log a warning if min_width is called.', function() { + console.warn = jasmine.createSpy('log'); + var options = { + cellHeight: 80, + verticalMargin: 10 + }; + $('.grid-stack').gridstack(options); + var grid = $('.grid-stack').data('gridstack'); + var items = $('.grid-stack-item'); + for (var i = 0; i < items.length; i++) { + grid.min_width(items[i], 2); + } + expect(console.warn).toHaveBeenCalledWith('gridstack.js: Function `min_width` is deprecated as of v0.2.5 and has been replaced with `minWidth`. It will be **completely** removed in v1.0.'); + }); + it('should log a warning if min_height is called.', function() { + console.warn = jasmine.createSpy('log'); + var options = { + cellHeight: 80, + verticalMargin: 10 + }; + $('.grid-stack').gridstack(options); + var grid = $('.grid-stack').data('gridstack'); + var items = $('.grid-stack-item'); + for (var i = 0; i < items.length; i++) { + grid.min_height(items[i], 2); + } + expect(console.warn).toHaveBeenCalledWith('gridstack.js: Function `min_height` is deprecated as of v0.2.5 and has been replaced with `minHeight`. It will be **completely** removed in v1.0.'); + }); + it('should log a warning if remove_all is called.', function() { + console.warn = jasmine.createSpy('log'); + var options = { + cellHeight: 80, + verticalMargin: 10 + }; + $('.grid-stack').gridstack(options); + var grid = $('.grid-stack').data('gridstack'); + grid.remove_all(); + expect(console.warn).toHaveBeenCalledWith('gridstack.js: Function `remove_all` is deprecated as of v0.2.5 and has been replaced with `removeAll`. It will be **completely** removed in v1.0.'); + }); + it('should log a warning if remove_widget is called.', function() { + console.warn = jasmine.createSpy('log'); + var options = { + cellHeight: 80, + verticalMargin: 10 + }; + $('.grid-stack').gridstack(options); + var grid = $('.grid-stack').data('gridstack'); + var items = $('.grid-stack-item'); + for (var i = 0; i < items.length; i++) { + grid.remove_widget(items[i]); + } + expect(console.warn).toHaveBeenCalledWith('gridstack.js: Function `remove_widget` is deprecated as of v0.2.5 and has been replaced with `removeWidget`. It will be **completely** removed in v1.0.'); + }); + it('should log a warning if will_it_fit is called.', function() { + console.warn = jasmine.createSpy('log'); + var options = { + cellHeight: 80, + verticalMargin: 10 + }; + $('.grid-stack').gridstack(options); + var grid = $('.grid-stack').data('gridstack'); + grid.will_it_fit(0, 0, 1, 1, false); + expect(console.warn).toHaveBeenCalledWith('gridstack.js: Function `will_it_fit` is deprecated as of v0.2.5 and has been replaced with `willItFit`. It will be **completely** removed in v1.0.'); + }); + it('should log a warning if make_widget is called.', function() { + console.warn = jasmine.createSpy('log'); + var options = { + cellHeight: 80, + verticalMargin: 10 + }; + $('.grid-stack').gridstack(options); + var grid = $('.grid-stack').data('gridstack'); + var items = $('.grid-stack-item'); + for (var i = 0; i < items.length; i++) { + grid.make_widget(items[i]); + } + expect(console.warn).toHaveBeenCalledWith('gridstack.js: Function `make_widget` is deprecated as of v0.2.5 and has been replaced with `makeWidget`. It will be **completely** removed in v1.0.'); + }); + it('should log a warning if add_widget is called.', function() { + console.warn = jasmine.createSpy('log'); + var options = { + cellHeight: 80, + verticalMargin: 10 + }; + $('.grid-stack').gridstack(options); + var grid = $('.grid-stack').data('gridstack'); + var items = $('.grid-stack-item'); + for (var i = 0; i < items.length; i++) { + grid.add_widget(items[i]); + } + expect(console.warn).toHaveBeenCalledWith('gridstack.js: Function `add_widget` is deprecated as of v0.2.5 and has been replaced with `addWidget`. It will be **completely** removed in v1.0.'); + }); + it('should log a warning if set_animation is called.', function() { + console.warn = jasmine.createSpy('log'); + var options = { + cellHeight: 80, + verticalMargin: 10 + }; + $('.grid-stack').gridstack(options); + var grid = $('.grid-stack').data('gridstack'); + grid.set_animation(true); + expect(console.warn).toHaveBeenCalledWith('gridstack.js: Function `set_animation` is deprecated as of v0.2.5 and has been replaced with `setAnimation`. It will be **completely** removed in v1.0.'); + }); + it('should log a warning if _prepare_element is called.', function() { + console.warn = jasmine.createSpy('log'); + var options = { + cellHeight: 80, + verticalMargin: 10 + }; + $('.grid-stack').gridstack(options); + var grid = $('.grid-stack').data('gridstack'); + var items = $('.grid-stack-item'); + for (var i = 0; i < items.length; i++) { + grid._prepare_element(items[i]); + } + expect(console.warn).toHaveBeenCalledWith('gridstack.js: Function `_prepare_element` is deprecated as of v0.2.5 and has been replaced with `_prepareElement`. It will be **completely** removed in v1.0.'); + }); + it('should log a warning if _is_one_column_mode is called.', function() { + console.warn = jasmine.createSpy('log'); + var options = { + cellHeight: 80, + verticalMargin: 10 + }; + $('.grid-stack').gridstack(options); + var grid = $('.grid-stack').data('gridstack'); + grid._is_one_column_mode(); + expect(console.warn).toHaveBeenCalledWith('gridstack.js: Function `_is_one_column_mode` is deprecated as of v0.2.5 and has been replaced with `_isOneColumnMode`. It will be **completely** removed in v1.0.'); + }); + it('should log a warning if _update_container_height is called.', function() { + console.warn = jasmine.createSpy('log'); + var options = { + cellHeight: 80, + verticalMargin: 10 + }; + $('.grid-stack').gridstack(options); + var grid = $('.grid-stack').data('gridstack'); + grid._update_container_height(); + expect(console.warn).toHaveBeenCalledWith('gridstack.js: Function `_update_container_height` is deprecated as of v0.2.5 and has been replaced with `_updateContainerHeight`. It will be **completely** removed in v1.0.'); + }); + it('should log a warning if _update_styles is called.', function() { + console.warn = jasmine.createSpy('log'); + var options = { + cellHeight: 80, + verticalMargin: 10 + }; + $('.grid-stack').gridstack(options); + var grid = $('.grid-stack').data('gridstack'); + grid._update_styles(); + expect(console.warn).toHaveBeenCalledWith('gridstack.js: Function `_update_styles` is deprecated as of v0.2.5 and has been replaced with `_updateStyles`. It will be **completely** removed in v1.0.'); + }); + it('should log a warning if _init_styles is called.', function() { + console.warn = jasmine.createSpy('log'); + var options = { + cellHeight: 80, + verticalMargin: 10 + }; + $('.grid-stack').gridstack(options); + var grid = $('.grid-stack').data('gridstack'); + grid._init_styles(); + expect(console.warn).toHaveBeenCalledWith('gridstack.js: Function `_init_styles` is deprecated as of v0.2.5 and has been replaced with `_initStyles`. It will be **completely** removed in v1.0.'); + }); + it('should log a warning if _trigger_change_event is called.', function() { + console.warn = jasmine.createSpy('log'); + var options = { + cellHeight: 80, + verticalMargin: 10 + }; + $('.grid-stack').gridstack(options); + var grid = $('.grid-stack').data('gridstack'); + grid._trigger_change_event(); + expect(console.warn).toHaveBeenCalledWith('gridstack.js: Function `_trigger_change_event` is deprecated as of v0.2.5 and has been replaced with `_triggerChangeEvent`. It will be **completely** removed in v1.0.'); + }); + }); + + describe('grid opts obsolete warnings', function() { + beforeEach(function() { + document.body.insertAdjacentHTML( + 'afterbegin', gridstackHTML); + }); + afterEach(function() { + document.body.removeChild(document.getElementsByClassName('grid-stack')[0]); + }); + it('should log a warning if handle_class is set.', function() { + console.warn = jasmine.createSpy('log'); + var options = { + cellHeight: 80, + verticalMargin: 10, + handle_class: 'grid-stack-header' + + }; + $('.grid-stack').gridstack(options); + var grid = $('.grid-stack').data('gridstack'); + expect(console.warn).toHaveBeenCalledWith('gridstack.js: Option `handle_class` is deprecated as of v0.2.5 and has been replaced with `handleClass`. It will be **completely** removed in v1.0.'); + }); + it('should log a warning if item_class is set.', function() { + console.warn = jasmine.createSpy('log'); + var options = { + cellHeight: 80, + verticalMargin: 10, + item_class: 'grid-stack-item' + + }; + $('.grid-stack').gridstack(options); + var grid = $('.grid-stack').data('gridstack'); + expect(console.warn).toHaveBeenCalledWith('gridstack.js: Option `item_class` is deprecated as of v0.2.5 and has been replaced with `itemClass`. It will be **completely** removed in v1.0.'); + }); + it('should log a warning if placeholder_class is set.', function() { + console.warn = jasmine.createSpy('log'); + var options = { + cellHeight: 80, + verticalMargin: 10, + placeholder_class: 'grid-stack-placeholder' + + }; + $('.grid-stack').gridstack(options); + var grid = $('.grid-stack').data('gridstack'); + expect(console.warn).toHaveBeenCalledWith('gridstack.js: Option `placeholder_class` is deprecated as of v0.2.5 and has been replaced with `placeholderClass`. It will be **completely** removed in v1.0.'); + }); + it('should log a warning if placeholder_text is set.', function() { + console.warn = jasmine.createSpy('log'); + var options = { + cellHeight: 80, + verticalMargin: 10, + placeholder_text: 'placeholder' + + }; + $('.grid-stack').gridstack(options); + var grid = $('.grid-stack').data('gridstack'); + expect(console.warn).toHaveBeenCalledWith('gridstack.js: Option `placeholder_text` is deprecated as of v0.2.5 and has been replaced with `placeholderText`. It will be **completely** removed in v1.0.'); + }); + it('should log a warning if cell_height is set.', function() { + console.warn = jasmine.createSpy('log'); + var options = { + cell_height: 80, + verticalMargin: 10 + + }; + $('.grid-stack').gridstack(options); + var grid = $('.grid-stack').data('gridstack'); + expect(console.warn).toHaveBeenCalledWith('gridstack.js: Option `cell_height` is deprecated as of v0.2.5 and has been replaced with `cellHeight`. It will be **completely** removed in v1.0.'); + }); + it('should log a warning if vertical_margin is set.', function() { + console.warn = jasmine.createSpy('log'); + var options = { + cellHeight: 80, + vertical_margin: 10 + + }; + $('.grid-stack').gridstack(options); + var grid = $('.grid-stack').data('gridstack'); + expect(console.warn).toHaveBeenCalledWith('gridstack.js: Option `vertical_margin` is deprecated as of v0.2.5 and has been replaced with `verticalMargin`. It will be **completely** removed in v1.0.'); + }); + it('should log a warning if min_width is set.', function() { + console.warn = jasmine.createSpy('log'); + var options = { + cellHeight: 80, + verticalMargin: 10, + min_width: 2 + + }; + $('.grid-stack').gridstack(options); + var grid = $('.grid-stack').data('gridstack'); + expect(console.warn).toHaveBeenCalledWith('gridstack.js: Option `min_width` is deprecated as of v0.2.5 and has been replaced with `minWidth`. It will be **completely** removed in v1.0.'); + }); + it('should log a warning if static_grid is set.', function() { + console.warn = jasmine.createSpy('log'); + var options = { + cellHeight: 80, + verticalMargin: 10, + static_grid: false + + }; + $('.grid-stack').gridstack(options); + var grid = $('.grid-stack').data('gridstack'); + expect(console.warn).toHaveBeenCalledWith('gridstack.js: Option `static_grid` is deprecated as of v0.2.5 and has been replaced with `staticGrid`. It will be **completely** removed in v1.0.'); + }); + it('should log a warning if is_nested is set.', function() { + console.warn = jasmine.createSpy('log'); + var options = { + cellHeight: 80, + verticalMargin: 10, + is_nested: false + + }; + $('.grid-stack').gridstack(options); + var grid = $('.grid-stack').data('gridstack'); + expect(console.warn).toHaveBeenCalledWith('gridstack.js: Option `is_nested` is deprecated as of v0.2.5 and has been replaced with `isNested`. It will be **completely** removed in v1.0.'); + }); + it('should log a warning if always_show_resize_handle is set.', function() { + console.warn = jasmine.createSpy('log'); + var options = { + cellHeight: 80, + verticalMargin: 10, + always_show_resize_handle: false + + }; + $('.grid-stack').gridstack(options); + var grid = $('.grid-stack').data('gridstack'); + expect(console.warn).toHaveBeenCalledWith('gridstack.js: Option `always_show_resize_handle` is deprecated as of v0.2.5 and has been replaced with `alwaysShowResizeHandle`. It will be **completely** removed in v1.0.'); + }); + }); + + describe('grid method _packNodes with float', function() { + beforeEach(function() { + document.body.insertAdjacentHTML( + 'afterbegin', gridstackHTML); + }); + afterEach(function() { + document.body.removeChild(document.getElementsByClassName('grid-stack')[0]); + }); + it('should allow same x, y coordinates for widgets.', function() { + var options = { + cellHeight: 80, + verticalMargin: 10, + float: true + }; + $('.grid-stack').gridstack(options); + var grid = $('.grid-stack').data('gridstack'); + var items = $('.grid-stack-item'); + var $el; + var $oldEl; + for (var i = 0; i < items.length; i++) { + $el = $(grid.addWidget(items[i])); + $oldEl = $(items[i]); + expect(parseInt($oldEl.attr('data-gs-x'), 10)).toBe(parseInt($el.attr('data-gs-x'), 10)); + expect(parseInt($oldEl.attr('data-gs-y'), 10)).toBe(parseInt($el.attr('data-gs-y'), 10)); + } + }); + it('should not allow same x, y coordinates for widgets.', function() { + var options = { + cellHeight: 80, + verticalMargin: 10 + }; + $('.grid-stack').gridstack(options); + var grid = $('.grid-stack').data('gridstack'); + var items = $('.grid-stack-item'); + var $el; + var $oldEl; + var newY; + var oldY; + for (var i = 0; i < items.length; i++) { + $oldEl = $.extend(true, {}, $(items[i])); + newY = parseInt($oldEl.attr('data-gs-y'), 10) + 5; + $oldEl.attr('data-gs-y', newY); + $el = $(grid.addWidget($oldEl)); + expect(parseInt($el.attr('data-gs-y'), 10)).not.toBe(newY); + } + }); + }); + + describe('grid method addWidget with all parameters', function() { + beforeEach(function() { + document.body.insertAdjacentHTML( + 'afterbegin', gridstackHTML); + }); + afterEach(function() { + document.body.removeChild(document.getElementsByClassName('grid-stack')[0]); + }); + it('should allow same x, y coordinates for widgets.', function() { + var options = { + cellHeight: 80, + verticalMargin: 10, + float: true + }; + $('.grid-stack').gridstack(options); + var grid = $('.grid-stack').data('gridstack'); + var widgetHTML = + '
' + + '
' + + '
'; + var widget = grid.addWidget(widgetHTML, 6, 7, 2, 3, false, 1, 4, 2, 5, 'coolWidget'); + var $widget = $(widget); + expect(parseInt($widget.attr('data-gs-x'), 10)).toBe(6); + expect(parseInt($widget.attr('data-gs-y'), 10)).toBe(7); + expect(parseInt($widget.attr('data-gs-width'), 10)).toBe(2); + expect(parseInt($widget.attr('data-gs-height'), 10)).toBe(3); + expect($widget.attr('data-gs-auto-position')).toBe(undefined); + expect(parseInt($widget.attr('data-gs-min-width'), 10)).toBe(1); + expect(parseInt($widget.attr('data-gs-max-width'), 10)).toBe(4); + expect(parseInt($widget.attr('data-gs-min-height'), 10)).toBe(2); + expect(parseInt($widget.attr('data-gs-max-height'), 10)).toBe(5); + expect($widget.attr('data-gs-id')).toBe('coolWidget'); + }); + }); + + describe('grid method addWidget with autoPosition true', function() { + beforeEach(function() { + document.body.insertAdjacentHTML( + 'afterbegin', gridstackHTML); + }); + afterEach(function() { + document.body.removeChild(document.getElementsByClassName('grid-stack')[0]); + }); + it('should change x, y coordinates for widgets.', function() { + var options = { + cellHeight: 80, + verticalMargin: 10 + }; + $('.grid-stack').gridstack(options); + var grid = $('.grid-stack').data('gridstack'); + var widgetHTML = + '
' + + '
' + + '
'; + var widget = grid.addWidget(widgetHTML, 9, 7, 2, 3, true); + var $widget = $(widget); + expect(parseInt($widget.attr('data-gs-x'), 10)).not.toBe(6); + expect(parseInt($widget.attr('data-gs-y'), 10)).not.toBe(7); + }); + }); + + describe('grid.destroy', function() { + beforeEach(function() { + document.body.insertAdjacentHTML( + 'afterbegin', gridstackHTML); + }); + afterEach(function() { + //document.body.removeChild(document.getElementsByClassName('grid-stack')[0]); + }); + it('should cleanup gridstack', function() { + var options = { + cellHeight: 80, + verticalMargin: 10 + }; + $('.grid-stack').gridstack(options); + var grid = $('.grid-stack').data('gridstack'); + grid.destroy(); + expect($('.grid-stack').length).toBe(0); + expect(grid.grid).toBe(null); + }); + it('should cleanup gridstack but leave elements', function() { + var options = { + cellHeight: 80, + verticalMargin: 10 + }; + $('.grid-stack').gridstack(options); + var grid = $('.grid-stack').data('gridstack'); + grid.destroy(false); + expect($('.grid-stack').length).toBe(1); + expect($('.grid-stack-item').length).toBe(2); + expect(grid.grid).toBe(null); + grid.destroy(); + }); + }); + + describe('grid.resize', function() { + beforeEach(function() { + document.body.insertAdjacentHTML( + 'afterbegin', gridstackHTML); + }); + afterEach(function() { + document.body.removeChild(document.getElementsByClassName('grid-stack')[0]); + }); + it('should resize widget', function() { + var options = { + cellHeight: 80, + verticalMargin: 10 + }; + $('.grid-stack').gridstack(options); + var grid = $('.grid-stack').data('gridstack'); + var items = $('.grid-stack-item'); + grid.resize(items[0], 5, 5); + expect(parseInt($(items[0]).attr('data-gs-width'), 10)).toBe(5); + expect(parseInt($(items[0]).attr('data-gs-height'), 10)).toBe(5); + }); + }); + + describe('grid.move', function() { + beforeEach(function() { + document.body.insertAdjacentHTML( + 'afterbegin', gridstackHTML); + }); + afterEach(function() { + document.body.removeChild(document.getElementsByClassName('grid-stack')[0]); + }); + it('should move widget', function() { + var options = { + cellHeight: 80, + verticalMargin: 10, + float: true + }; + $('.grid-stack').gridstack(options); + var grid = $('.grid-stack').data('gridstack'); + var items = $('.grid-stack-item'); + grid.move(items[0], 5, 5); + expect(parseInt($(items[0]).attr('data-gs-x'), 10)).toBe(5); + expect(parseInt($(items[0]).attr('data-gs-y'), 10)).toBe(5); + }); + }); + + describe('grid.moveNode', function() { + beforeEach(function() { + document.body.insertAdjacentHTML( + 'afterbegin', gridstackHTML); + }); + afterEach(function() { + document.body.removeChild(document.getElementsByClassName('grid-stack')[0]); + }); + it('should do nothing and return node', function() { + var options = { + cellHeight: 80, + verticalMargin: 10 + }; + $('.grid-stack').gridstack(options); + var grid = $('.grid-stack').data('gridstack'); + var items = $('.grid-stack-item'); + grid._updateElement(items[0], function(el, node) { + var newNode = grid.grid.moveNode(node); + expect(newNode).toBe(node); + }); + }); + it('should do nothing and return node', function() { + var options = { + cellHeight: 80, + verticalMargin: 10 + }; + $('.grid-stack').gridstack(options); + var grid = $('.grid-stack').data('gridstack'); + var items = $('.grid-stack-item'); + grid.minWidth(items[0], 1); + grid.maxWidth(items[0], 2); + grid.minHeight(items[0], 1); + grid.maxHeight(items[0], 2); + grid._updateElement(items[0], function(el, node) { + var newNode = grid.grid.moveNode(node); + expect(newNode).toBe(node); + }); + }); + }); + + describe('grid.update', function() { + beforeEach(function() { + document.body.insertAdjacentHTML( + 'afterbegin', gridstackHTML); + }); + afterEach(function() { + document.body.removeChild(document.getElementsByClassName('grid-stack')[0]); + }); + it('should move and resize widget', function() { + var options = { + cellHeight: 80, + verticalMargin: 10, + float: true + }; + $('.grid-stack').gridstack(options); + var grid = $('.grid-stack').data('gridstack'); + var items = $('.grid-stack-item'); + grid.update(items[0], 5, 5, 5 ,5); + expect(parseInt($(items[0]).attr('data-gs-width'), 10)).toBe(5); + expect(parseInt($(items[0]).attr('data-gs-height'), 10)).toBe(5); + expect(parseInt($(items[0]).attr('data-gs-x'), 10)).toBe(5); + expect(parseInt($(items[0]).attr('data-gs-y'), 10)).toBe(5); + }); + }); + + describe('grid.verticalMargin', function() { + beforeEach(function() { + document.body.insertAdjacentHTML( + 'afterbegin', gridstackHTML); + }); + afterEach(function() { + document.body.removeChild(document.getElementsByClassName('grid-stack')[0]); + }); + it('should return verticalMargin', function() { + var options = { + cellHeight: 80, + verticalMargin: 10 + }; + $('.grid-stack').gridstack(options); + var grid = $('.grid-stack').data('gridstack'); + var vm = grid.verticalMargin(); + expect(vm).toBe(10); + }); + it('should return update verticalMargin', function() { + var options = { + cellHeight: 80, + verticalMargin: 10 + }; + $('.grid-stack').gridstack(options); + var grid = $('.grid-stack').data('gridstack'); + grid.verticalMargin(11); + expect(grid.verticalMargin()).toBe(11); + }); + it('should do nothing', function() { + var options = { + cellHeight: 80, + verticalMargin: 10 + }; + $('.grid-stack').gridstack(options); + var grid = $('.grid-stack').data('gridstack'); + var vm = grid.verticalMargin(10); + expect(grid.verticalMargin()).toBe(10); + }); + it('should do nothing', function() { + var options = { + cellHeight: 80, + verticalMargin: 10, + height: 10 + }; + $('.grid-stack').gridstack(options); + var grid = $('.grid-stack').data('gridstack'); + var vm = grid.verticalMargin(10); + expect(grid.verticalMargin()).toBe(10); + }); + it('should not update styles', function() { + var options = { + cellHeight: 80, + verticalMargin: 10 + }; + $('.grid-stack').gridstack(options); + var grid = $('.grid-stack').data('gridstack'); + + spyOn(grid, '_updateStyles'); + grid.verticalMargin(11, true); + expect(grid._updateStyles).not.toHaveBeenCalled(); + }); + }); + + describe('grid.opts.rtl', function() { + beforeEach(function() { + document.body.insertAdjacentHTML( + 'afterbegin', gridstackHTML); + }); + afterEach(function() { + document.body.removeChild(document.getElementsByClassName('grid-stack')[0]); + }); + it('should add grid-stack-rtl class', function() { + var options = { + cellHeight: 80, + verticalMargin: 10, + rtl: true + }; + $('.grid-stack').gridstack(options); + expect($('.grid-stack').hasClass('grid-stack-rtl')).toBe(true); + }); + it('should not add grid-stack-rtl class', function() { + var options = { + cellHeight: 80, + verticalMargin: 10 + }; + $('.grid-stack').gridstack(options); + expect($('.grid-stack').hasClass('grid-stack-rtl')).toBe(false); + }); + }); + + describe('grid.enableMove', function() { + beforeEach(function() { + document.body.insertAdjacentHTML( + 'afterbegin', gridstackHTML); + }); + afterEach(function() { + document.body.removeChild(document.getElementsByClassName('grid-stack')[0]); + }); + it('should enable move', function() { + var options = { + cellHeight: 80, + verticalMargin: 10, + minWidth: 1, + disableDrag: true + }; + $('.grid-stack').gridstack(options); + var grid = $('.grid-stack').data('gridstack'); + var items = $('.grid-stack-item'); + expect(grid.opts.disableDrag).toBe(true); + grid.enableMove(true, true); + for (var i = 0; i < items.length; i++) { + expect($(items[i]).hasClass('ui-draggable-handle')).toBe(true); + } + expect(grid.opts.disableDrag).toBe(false); + }); + it('should disable move', function() { + var options = { + cellHeight: 80, + verticalMargin: 10, + minWidth: 1 + }; + $('.grid-stack').gridstack(options); + var grid = $('.grid-stack').data('gridstack'); + var items = $('.grid-stack-item'); + grid.enableMove(false); + for (var i = 0; i < items.length; i++) { + expect($(items[i]).hasClass('ui-draggable-handle')).toBe(false); + } + expect(grid.opts.disableDrag).toBe(false); + }); + }); + + describe('grid.enableResize', function() { + beforeEach(function() { + document.body.insertAdjacentHTML( + 'afterbegin', gridstackHTML); + }); + afterEach(function() { + document.body.removeChild(document.getElementsByClassName('grid-stack')[0]); + }); + it('should enable resize', function() { + var options = { + cellHeight: 80, + verticalMargin: 10, + minWidth: 1, + disableResize: true + }; + $('.grid-stack').gridstack(options); + var grid = $('.grid-stack').data('gridstack'); + var items = $('.grid-stack-item'); + expect(grid.opts.disableResize).toBe(true); + grid.enableResize(true, true); + for (var i = 0; i < items.length; i++) { + expect(($(items[i]).resizable('option','disabled'))).toBe(false); + } + expect(grid.opts.disableResize).toBe(false); + }); + it('should disable resize', function() { + var options = { + cellHeight: 80, + verticalMargin: 10, + minWidth: 1 + }; + $('.grid-stack').gridstack(options); + var grid = $('.grid-stack').data('gridstack'); + var items = $('.grid-stack-item'); + grid.enableResize(false); + for (var i = 0; i < items.length; i++) { + expect(($(items[i]).resizable('option','disabled'))).toBe(true); + } + expect(grid.opts.disableResize).toBe(false); + }); + }); + + describe('grid.enable', function() { + beforeEach(function() { + document.body.insertAdjacentHTML( + 'afterbegin', gridstackHTML); + }); + afterEach(function() { + document.body.removeChild(document.getElementsByClassName('grid-stack')[0]); + }); + it('should enable movable and resizable', function() { + var options = { + cellHeight: 80, + verticalMargin: 10, + minWidth: 1 + }; + $('.grid-stack').gridstack(options); + var grid = $('.grid-stack').data('gridstack'); + var items = $('.grid-stack-item'); + grid.enableResize(false); + grid.enableMove(false); + for (var i = 0; i < items.length; i++) { + expect($(items[i]).hasClass('ui-draggable-handle')).toBe(false); + expect(($(items[i]).resizable('option','disabled'))).toBe(true); + } + grid.enable(); + for (var j = 0; j < items.length; j++) { + expect($(items[j]).hasClass('ui-draggable-handle')).toBe(true); + expect(($(items[j]).resizable('option','disabled'))).toBe(false); + } + }); + }); + + describe('grid.enable', function() { + beforeEach(function() { + document.body.insertAdjacentHTML( + 'afterbegin', gridstackHTML); + }); + afterEach(function() { + document.body.removeChild(document.getElementsByClassName('grid-stack')[0]); + }); + it('should lock widgets', function() { + var options = { + cellHeight: 80, + verticalMargin: 10 + }; + $('.grid-stack').gridstack(options); + var grid = $('.grid-stack').data('gridstack'); + var items = $('.grid-stack-item'); + for (var i = 0; i < items.length; i++) { + grid.locked(items[i], true); + expect($(items[i]).attr('data-gs-locked')).toBe('yes'); + } + }); + it('should unlock widgets', function() { + var options = { + cellHeight: 80, + verticalMargin: 10 + }; + $('.grid-stack').gridstack(options); + var grid = $('.grid-stack').data('gridstack'); + var items = $('.grid-stack-item'); + for (var i = 0; i < items.length; i++) { + grid.locked(items[i], false); + expect($(items[i]).attr('data-gs-locked')).toBe(undefined); + } + }); + }); +}); diff --git a/spec/utils-spec.js b/spec/utils-spec.js new file mode 100644 index 000000000..0a92c9253 --- /dev/null +++ b/spec/utils-spec.js @@ -0,0 +1,109 @@ +describe('gridstack utils', function() { + 'use strict'; + + var utils; + + beforeEach(function() { + utils = window.GridStackUI.Utils; + }); + + describe('setup of utils', function() { + + it('should set gridstack utils.', function() { + expect(utils).not.toBeNull(); + expect(typeof utils).toBe('object'); + }); + + }); + + describe('test toBool', function() { + + it('should return booleans.', function() { + expect(utils.toBool(true)).toEqual(true); + expect(utils.toBool(false)).toEqual(false); + }); + + it('should work with integer.', function() { + expect(utils.toBool(1)).toEqual(true); + expect(utils.toBool(0)).toEqual(false); + }); + + it('should work with Strings.', function() { + expect(utils.toBool('')).toEqual(false); + expect(utils.toBool('0')).toEqual(false); + expect(utils.toBool('no')).toEqual(false); + expect(utils.toBool('false')).toEqual(false); + expect(utils.toBool('yes')).toEqual(true); + expect(utils.toBool('yadda')).toEqual(true); + }); + + }); + + describe('test isIntercepted', function() { + var src = {x: 3, y: 2, width: 3, height: 2}; + + it('should intercept.', function() { + expect(utils.isIntercepted(src, {x: 0, y: 0, width: 4, height: 3})).toEqual(true); + expect(utils.isIntercepted(src, {x: 0, y: 0, width: 40, height: 30})).toEqual(true); + expect(utils.isIntercepted(src, {x: 3, y: 2, width: 3, height: 2})).toEqual(true); + expect(utils.isIntercepted(src, {x: 5, y: 3, width: 3, height: 2})).toEqual(true); + }); + + it('shouldn\'t intercept.', function() { + expect(utils.isIntercepted(src, {x: 0, y: 0, width: 3, height: 2})).toEqual(false); + expect(utils.isIntercepted(src, {x: 0, y: 0, width: 13, height: 2})).toEqual(false); + expect(utils.isIntercepted(src, {x: 1, y: 4, width: 13, height: 2})).toEqual(false); + expect(utils.isIntercepted(src, {x: 0, y: 3, width: 3, height: 2})).toEqual(false); + expect(utils.isIntercepted(src, {x: 6, y: 3, width: 3, height: 2})).toEqual(false); + }); + }); + + describe('test createStylesheet/removeStylesheet', function() { + + it('should create/remove style DOM', function() { + var _id = 'test-123'; + + utils.createStylesheet(_id); + + var style = $('STYLE[data-gs-style-id=' + _id + ']'); + + expect(style.length).toEqual(1); + expect(style.prop('tagName')).toEqual('STYLE'); + + utils.removeStylesheet(_id) + + style = $('STYLE[data-gs-style-id=' + _id + ']'); + + expect(style.length).toEqual(0); + }); + + }); + + describe('test parseHeight', function() { + + it('should parse height value', function() { + expect(utils.parseHeight(12)).toEqual(jasmine.objectContaining({height: 12, unit: 'px'})); + expect(utils.parseHeight('12px')).toEqual(jasmine.objectContaining({height: 12, unit: 'px'})); + expect(utils.parseHeight('12.3px')).toEqual(jasmine.objectContaining({height: 12.3, unit: 'px'})); + expect(utils.parseHeight('12.3em')).toEqual(jasmine.objectContaining({height: 12.3, unit: 'em'})); + expect(utils.parseHeight('12.3rem')).toEqual(jasmine.objectContaining({height: 12.3, unit: 'rem'})); + expect(utils.parseHeight('12.3vh')).toEqual(jasmine.objectContaining({height: 12.3, unit: 'vh'})); + expect(utils.parseHeight('12.3vw')).toEqual(jasmine.objectContaining({height: 12.3, unit: 'vw'})); + expect(utils.parseHeight('12.5')).toEqual(jasmine.objectContaining({height: 12.5, unit: 'px'})); + expect(function() { utils.parseHeight('12.5 df'); }).toThrowError('Invalid height'); + + }); + + it('should parse negative height value', function() { + expect(utils.parseHeight(-12)).toEqual(jasmine.objectContaining({height: -12, unit: 'px'})); + expect(utils.parseHeight('-12px')).toEqual(jasmine.objectContaining({height: -12, unit: 'px'})); + expect(utils.parseHeight('-12.3px')).toEqual(jasmine.objectContaining({height: -12.3, unit: 'px'})); + expect(utils.parseHeight('-12.3em')).toEqual(jasmine.objectContaining({height: -12.3, unit: 'em'})); + expect(utils.parseHeight('-12.3rem')).toEqual(jasmine.objectContaining({height: -12.3, unit: 'rem'})); + expect(utils.parseHeight('-12.3vh')).toEqual(jasmine.objectContaining({height: -12.3, unit: 'vh'})); + expect(utils.parseHeight('-12.3vw')).toEqual(jasmine.objectContaining({height: -12.3, unit: 'vw'})); + expect(utils.parseHeight('-12.5')).toEqual(jasmine.objectContaining({height: -12.5, unit: 'px'})); + expect(function() { utils.parseHeight('-12.5 df'); }).toThrowError('Invalid height'); + }); + }); +}); diff --git a/src/gridstack.jQueryUI.js b/src/gridstack.jQueryUI.js new file mode 100644 index 000000000..c5d493615 --- /dev/null +++ b/src/gridstack.jQueryUI.js @@ -0,0 +1,97 @@ +/** + * gridstack.js 0.3.0-dev + * http://troolee.github.io/gridstack.js/ + * (c) 2014-2016 Pavel Reznikov, Dylan Weiss + * gridstack.js may be freely distributed under the MIT license. + * @preserve +*/ +(function(factory) { + if (typeof define === 'function' && define.amd) { + define(['jquery', 'lodash', 'gridstack', 'jquery-ui/data', 'jquery-ui/disable-selection', 'jquery-ui/focusable', + 'jquery-ui/form', 'jquery-ui/ie', 'jquery-ui/keycode', 'jquery-ui/labels', 'jquery-ui/jquery-1-7', + 'jquery-ui/plugin', 'jquery-ui/safe-active-element', 'jquery-ui/safe-blur', 'jquery-ui/scroll-parent', + 'jquery-ui/tabbable', 'jquery-ui/unique-id', 'jquery-ui/version', 'jquery-ui/widget', + 'jquery-ui/widgets/mouse', 'jquery-ui/widgets/draggable', 'jquery-ui/widgets/droppable', + 'jquery-ui/widgets/resizable'], factory); + } else if (typeof exports !== 'undefined') { + try { jQuery = require('jquery'); } catch (e) {} + try { _ = require('lodash'); } catch (e) {} + try { GridStackUI = require('gridstack'); } catch (e) {} + factory(jQuery, _, GridStackUI); + } else { + factory(jQuery, _, GridStackUI); + } +})(function($, _, GridStackUI) { + + var scope = window; + + /** + * @class JQueryUIGridStackDragDropPlugin + * jQuery UI implementation of drag'n'drop gridstack plugin. + */ + function JQueryUIGridStackDragDropPlugin(grid) { + GridStackUI.GridStackDragDropPlugin.call(this, grid); + } + + GridStackUI.GridStackDragDropPlugin.registerPlugin(JQueryUIGridStackDragDropPlugin); + + JQueryUIGridStackDragDropPlugin.prototype = Object.create(GridStackUI.GridStackDragDropPlugin.prototype); + JQueryUIGridStackDragDropPlugin.prototype.constructor = JQueryUIGridStackDragDropPlugin; + + JQueryUIGridStackDragDropPlugin.prototype.resizable = function(el, opts) { + el = $(el); + if (opts === 'disable' || opts === 'enable') { + el.resizable(opts); + } else if (opts === 'option') { + var key = arguments[2]; + var value = arguments[3]; + el.resizable(opts, key, value); + } else { + el.resizable(_.extend({}, this.grid.opts.resizable, { + start: opts.start || function() {}, + stop: opts.stop || function() {}, + resize: opts.resize || function() {} + })); + } + return this; + }; + + JQueryUIGridStackDragDropPlugin.prototype.draggable = function(el, opts) { + el = $(el); + if (opts === 'disable' || opts === 'enable') { + el.draggable(opts); + } else { + el.draggable(_.extend({}, this.grid.opts.draggable, { + containment: this.grid.opts.isNested ? this.grid.container.parent() : null, + start: opts.start || function() {}, + stop: opts.stop || function() {}, + drag: opts.drag || function() {} + })); + } + return this; + }; + + JQueryUIGridStackDragDropPlugin.prototype.droppable = function(el, opts) { + el = $(el); + if (opts === 'disable' || opts === 'enable') { + el.droppable(opts); + } else { + el.droppable({ + accept: opts.accept + }); + } + return this; + }; + + JQueryUIGridStackDragDropPlugin.prototype.isDroppable = function(el, opts) { + el = $(el); + return Boolean(el.data('droppable')); + }; + + JQueryUIGridStackDragDropPlugin.prototype.on = function(el, eventName, callback) { + $(el).on(eventName, callback); + return this; + }; + + return JQueryUIGridStackDragDropPlugin; +}); diff --git a/src/gridstack.js b/src/gridstack.js index 61c893f8a..b48eb853a 100644 --- a/src/gridstack.js +++ b/src/gridstack.js @@ -1,27 +1,42 @@ -// gridstack.js 0.2.4-dev -// http://troolee.github.io/gridstack.js/ -// (c) 2014-2016 Pavel Reznikov -// gridstack.js may be freely distributed under the MIT license. - +/** + * gridstack.js 0.3.0-dev + * http://troolee.github.io/gridstack.js/ + * (c) 2014-2016 Pavel Reznikov, Dylan Weiss + * gridstack.js may be freely distributed under the MIT license. + * @preserve +*/ (function(factory) { if (typeof define === 'function' && define.amd) { - define(['jquery', 'lodash', 'jquery-ui/core', 'jquery-ui/widget', 'jquery-ui/mouse', 'jquery-ui/draggable', - 'jquery-ui/resizable'], factory); - } - else if (typeof exports !== 'undefined') { - try { jQuery = require('jquery'); } catch(e) {} - try { _ = require('lodash'); } catch(e) {} - factory(jQuery, _); - } - else { + define(['jquery', 'lodash'], factory); + } else if (typeof exports !== 'undefined') { + try { jQuery = require('jquery'); } catch (e) {} + try { _ = require('lodash'); } catch (e) {} + factory(jQuery, _); + } else { factory(jQuery, _); } })(function($, _) { var scope = window; + var obsolete = function(f, oldName, newName) { + var wrapper = function() { + console.warn('gridstack.js: Function `' + oldName + '` is deprecated as of v0.2.5 and has been replaced ' + + 'with `' + newName + '`. It will be **completely** removed in v1.0.'); + return f.apply(this, arguments); + }; + wrapper.prototype = f.prototype; + + return wrapper; + }; + + var obsoleteOpts = function(oldName, newName) { + console.warn('gridstack.js: Option `' + oldName + '` is deprecated as of v0.2.5 and has been replaced with `' + + newName + '`. It will be **completely** removed in v1.0.'); + }; + var Utils = { - is_intercepted: function(a, b) { + isIntercepted: function(a, b) { return !(a.x + a.width <= b.x || b.x + b.width <= a.x || a.y + a.height <= b.y || b.y + b.height <= a.y); }, @@ -31,175 +46,249 @@ return _.sortBy(nodes, function(n) { return dir * (n.x + n.y * width); }); }, - create_stylesheet: function(id) { + createStylesheet: function(id) { var style = document.createElement('style'); style.setAttribute('type', 'text/css'); - style.setAttribute('data-gs-id', id); + style.setAttribute('data-gs-style-id', id); if (style.styleSheet) { style.styleSheet.cssText = ''; - } - else { + } else { style.appendChild(document.createTextNode('')); } document.getElementsByTagName('head')[0].appendChild(style); return style.sheet; }, - remove_stylesheet: function(id) { - $("STYLE[data-gs-id=" + id +"]").remove(); + + removeStylesheet: function(id) { + $('STYLE[data-gs-style-id=' + id + ']').remove(); }, - insert_css_rule: function(sheet, selector, rules, index) { + + insertCSSRule: function(sheet, selector, rules, index) { if (typeof sheet.insertRule === 'function') { sheet.insertRule(selector + '{' + rules + '}', index); - } - else if (typeof sheet.addRule === 'function') { + } else if (typeof sheet.addRule === 'function') { sheet.addRule(selector, rules, index); } }, toBool: function(v) { - if (typeof v == 'boolean') + if (typeof v == 'boolean') { return v; + } if (typeof v == 'string') { v = v.toLowerCase(); - return !(v == '' || v == 'no' || v == 'false' || v == '0'); + return !(v === '' || v == 'no' || v == 'false' || v == '0'); } return Boolean(v); + }, + + _collisionNodeCheck: function(n) { + return n != this.node && Utils.isIntercepted(n, this.nn); + }, + + _didCollide: function(bn) { + return Utils.isIntercepted({x: this.n.x, y: this.newY, width: this.n.width, height: this.n.height}, bn); + }, + + _isAddNodeIntercepted: function(n) { + return Utils.isIntercepted({x: this.x, y: this.y, width: this.node.width, height: this.node.height}, n); + }, + + parseHeight: function(val) { + var height = val; + var heightUnit = 'px'; + if (height && _.isString(height)) { + var match = height.match(/^(-[0-9]+\.[0-9]+|[0-9]*\.[0-9]+|-[0-9]+|[0-9]+)(px|em|rem|vh|vw)?$/); + if (!match) { + throw new Error('Invalid height'); + } + heightUnit = match[2] || 'px'; + height = parseFloat(match[1]); + } + return {height: height, unit: heightUnit}; } }; - var id_seq = 0; + // jscs:disable requireCamelCaseOrUpperCaseIdentifiers + Utils.is_intercepted = obsolete(Utils.isIntercepted, 'is_intercepted', 'isIntercepted'); + + Utils.create_stylesheet = obsolete(Utils.createStylesheet, 'create_stylesheet', 'createStylesheet'); + + Utils.remove_stylesheet = obsolete(Utils.removeStylesheet, 'remove_stylesheet', 'removeStylesheet'); + + Utils.insert_css_rule = obsolete(Utils.insertCSSRule, 'insert_css_rule', 'insertCSSRule'); + // jscs:enable requireCamelCaseOrUpperCaseIdentifiers + + /** + * @class GridStackDragDropPlugin + * Base class for drag'n'drop plugin. + */ + function GridStackDragDropPlugin(grid) { + this.grid = grid; + } + + GridStackDragDropPlugin.registeredPlugins = []; + + GridStackDragDropPlugin.registerPlugin = function(pluginClass) { + GridStackDragDropPlugin.registeredPlugins.push(pluginClass); + }; + + GridStackDragDropPlugin.prototype.resizable = function(el, opts) { + return this; + }; + + GridStackDragDropPlugin.prototype.draggable = function(el, opts) { + return this; + }; + + GridStackDragDropPlugin.prototype.droppable = function(el, opts) { + return this; + }; + + GridStackDragDropPlugin.prototype.isDroppable = function(el) { + return false; + }; + + GridStackDragDropPlugin.prototype.on = function(el, eventName, callback) { + return this; + }; + + + var idSeq = 0; - var GridStackEngine = function(width, onchange, float_mode, height, items) { + var GridStackEngine = function(width, onchange, floatMode, height, items) { this.width = width; - this['float'] = float_mode || false; + this.float = floatMode || false; this.height = height || 0; this.nodes = items || []; this.onchange = onchange || function() {}; - this._update_counter = 0; - this._float = this['float']; + this._updateCounter = 0; + this._float = this.float; + + this._addedNodes = []; + this._removedNodes = []; }; - GridStackEngine.prototype.batch_update = function() { - this._update_counter = 1; + GridStackEngine.prototype.batchUpdate = function() { + this._updateCounter = 1; this.float = true; }; GridStackEngine.prototype.commit = function() { - this._update_counter = 0; - if (this._update_counter == 0) { + if (this._updateCounter !== 0) { + this._updateCounter = 0; this.float = this._float; - this._pack_nodes(); + this._packNodes(); this._notify(); } }; - GridStackEngine.prototype._fix_collisions = function(node) { - this._sort_nodes(-1); + // For Meteor support: https://github.com/troolee/gridstack.js/pull/272 + GridStackEngine.prototype.getNodeDataByDOMEl = function(el) { + return _.find(this.nodes, function(n) { return el.get(0) === n.el.get(0); }); + }; + + GridStackEngine.prototype._fixCollisions = function(node) { + var self = this; + this._sortNodes(-1); - var nn = node, has_locked = Boolean(_.find(this.nodes, function(n) { return n.locked })); - if (!this.float && !has_locked) { + var nn = node; + var hasLocked = Boolean(_.find(this.nodes, function(n) { return n.locked; })); + if (!this.float && !hasLocked) { nn = {x: 0, y: node.y, width: this.width, height: node.height}; } - while (true) { - var collision_node = _.find(this.nodes, _.bind(function(n) { - return n != node && Utils.is_intercepted(n, nn); - }, this)); - if (typeof collision_node == 'undefined') { + var collisionNode = _.find(this.nodes, _.bind(Utils._collisionNodeCheck, {node: node, nn: nn})); + if (typeof collisionNode == 'undefined') { return; } - this.move_node(collision_node, collision_node.x, node.y + node.height, - collision_node.width, collision_node.height, true); + this.moveNode(collisionNode, collisionNode.x, node.y + node.height, + collisionNode.width, collisionNode.height, true); } }; - GridStackEngine.prototype.what_is_here = function(x, y, width, height) { - var nn = {x: x || 0, y: y || 0, width: width || 1, height: height || 1}; - var collision_node = _.find(this.nodes, _.bind(function(n) { - return Utils.is_intercepted(n, nn); + GridStackEngine.prototype.whatIsHere = function(x, y, width, height) { + var nn = {x: x || 0, y: y || 0, width: width || 1, height: height || 1}; + var collisionNode = _.find(this.nodes, _.bind(function(n) { + return Utils.isIntercepted(n, nn); }, this)); - return collision_node; + return collisionNode; }; - GridStackEngine.prototype.is_area_empty = function(x, y, width, height) { - var collision_node = this.what_is_here(x, y, width, height); - return collision_node == null; + GridStackEngine.prototype.isAreaEmpty = function(x, y, width, height) { + var collisionNode = this.whatIsHere(x, y, width, height); + return collisionNode === null || typeof collisionNode === 'undefined'; }; - GridStackEngine.prototype._sort_nodes = function(dir) { + GridStackEngine.prototype._sortNodes = function(dir) { this.nodes = Utils.sort(this.nodes, dir, this.width); }; - GridStackEngine.prototype._pack_nodes = function() { - this._sort_nodes(); + GridStackEngine.prototype._packNodes = function() { + this._sortNodes(); if (this.float) { _.each(this.nodes, _.bind(function(n, i) { - if (n._updating || typeof n._orig_y == 'undefined' || n.y == n._orig_y) + if (n._updating || typeof n._origY == 'undefined' || n.y == n._origY) { return; + } - var new_y = n.y; - while (new_y >= n._orig_y) { - var collision_node = _.chain(this.nodes) - .find(function(bn) { - return n != bn && - Utils.is_intercepted({x: n.x, y: new_y, width: n.width, height: n.height}, bn); - }) + var newY = n.y; + while (newY >= n._origY) { + var collisionNode = _.chain(this.nodes) + .find(_.bind(Utils._didCollide, {n: n, newY: newY})) .value(); - if (!collision_node) { + if (!collisionNode) { n._dirty = true; - n.y = new_y; + n.y = newY; } - --new_y; + --newY; } }, this)); - } - else { + } else { _.each(this.nodes, _.bind(function(n, i) { - if (n.locked) + if (n.locked) { return; + } while (n.y > 0) { - var new_y = n.y - 1; - var can_be_moved = i == 0; + var newY = n.y - 1; + var canBeMoved = i === 0; if (i > 0) { - var collision_node = _.chain(this.nodes) + var collisionNode = _.chain(this.nodes) .take(i) - .find(function(bn) { - return Utils.is_intercepted({x: n.x, y: new_y, width: n.width, height: n.height}, bn); - }) + .find(_.bind(Utils._didCollide, {n: n, newY: newY})) .value(); - can_be_moved = typeof collision_node == 'undefined'; + canBeMoved = typeof collisionNode == 'undefined'; } - if (!can_be_moved) { + if (!canBeMoved) { break; } - n._dirty = n.y != new_y; - n.y = new_y; + n._dirty = n.y != newY; + n.y = newY; } }, this)); } }; - GridStackEngine.prototype._prepare_node = function(node, resizing) { - node = _.defaults(node || {}, {width: 1, height: 1, x: 0, y: 0 }); + GridStackEngine.prototype._prepareNode = function(node, resizing) { + node = _.defaults(node || {}, {width: 1, height: 1, x: 0, y: 0}); node.x = parseInt('' + node.x); node.y = parseInt('' + node.y); node.width = parseInt('' + node.width); node.height = parseInt('' + node.height); - node.auto_position = node.auto_position || false; - node.no_resize = node.no_resize || false; - node.no_move = node.no_move || false; + node.autoPosition = node.autoPosition || false; + node.noResize = node.noResize || false; + node.noMove = node.noMove || false; if (node.width > this.width) { node.width = this.width; - } - else if (node.width < 1) { + } else if (node.width < 1) { node.width = 1; } @@ -214,8 +303,7 @@ if (node.x + node.width > this.width) { if (resizing) { node.width = this.width - node.x; - } - else { + } else { node.x = this.width - node.width; } } @@ -228,44 +316,48 @@ }; GridStackEngine.prototype._notify = function() { - if (this._update_counter) { + var args = Array.prototype.slice.call(arguments, 0); + args[0] = typeof args[0] === 'undefined' ? [] : [args[0]]; + args[1] = typeof args[1] === 'undefined' ? true : args[1]; + if (this._updateCounter) { return; } - var deleted_nodes = Array.prototype.slice.call(arguments, 1).concat(this.get_dirty_nodes()); - deleted_nodes = deleted_nodes.concat(this.get_dirty_nodes()); - this.onchange(deleted_nodes); + var deletedNodes = args[0].concat(this.getDirtyNodes()); + this.onchange(deletedNodes, args[1]); }; - GridStackEngine.prototype.clean_nodes = function() { - _.each(this.nodes, function(n) {n._dirty = false }); + GridStackEngine.prototype.cleanNodes = function() { + if (this._updateCounter) { + return; + } + _.each(this.nodes, function(n) {n._dirty = false; }); }; - GridStackEngine.prototype.get_dirty_nodes = function() { + GridStackEngine.prototype.getDirtyNodes = function() { return _.filter(this.nodes, function(n) { return n._dirty; }); }; - GridStackEngine.prototype.add_node = function(node) { - node = this._prepare_node(node); + GridStackEngine.prototype.addNode = function(node, triggerAddEvent) { + node = this._prepareNode(node); - if (typeof node.max_width != 'undefined') node.width = Math.min(node.width, node.max_width); - if (typeof node.max_height != 'undefined') node.height = Math.min(node.height, node.max_height); - if (typeof node.min_width != 'undefined') node.width = Math.max(node.width, node.min_width); - if (typeof node.min_height != 'undefined') node.height = Math.max(node.height, node.min_height); + if (typeof node.maxWidth != 'undefined') { node.width = Math.min(node.width, node.maxWidth); } + if (typeof node.maxHeight != 'undefined') { node.height = Math.min(node.height, node.maxHeight); } + if (typeof node.minWidth != 'undefined') { node.width = Math.max(node.width, node.minWidth); } + if (typeof node.minHeight != 'undefined') { node.height = Math.max(node.height, node.minHeight); } - node._id = ++id_seq; + node._id = ++idSeq; node._dirty = true; - if (node.auto_position) { - this._sort_nodes(); + if (node.autoPosition) { + this._sortNodes(); for (var i = 0;; ++i) { - var x = i % this.width, y = Math.floor(i / this.width); + var x = i % this.width; + var y = Math.floor(i / this.width); if (x + node.width > this.width) { continue; } - if (!_.find(this.nodes, function(n) { - return Utils.is_intercepted({x: x, y: y, width: node.width, height: node.height}, n); - })) { + if (!_.find(this.nodes, _.bind(Utils._isAddNodeIntercepted, {x: x, y: y, node: node}))) { node.x = x; node.y = y; break; @@ -274,30 +366,37 @@ } this.nodes.push(node); + if (typeof triggerAddEvent != 'undefined' && triggerAddEvent) { + this._addedNodes.push(_.clone(node)); + } - this._fix_collisions(node); - this._pack_nodes(); + this._fixCollisions(node); + this._packNodes(); this._notify(); return node; }; - GridStackEngine.prototype.remove_node = function(node) { + GridStackEngine.prototype.removeNode = function(node, detachNode) { if (!node) { return; } node._id = null; this.nodes = _.without(this.nodes, node); - this._pack_nodes(); - this._notify(node); + this._packNodes(); + this._notify(node, detachNode); }; - GridStackEngine.prototype.can_move_node = function(node, x, y, width, height) { - var has_locked = Boolean(_.find(this.nodes, function(n) { return n.locked })); + GridStackEngine.prototype.canMoveNode = function(node, x, y, width, height) { + if (!this.isNodeChangedPosition(node, x, y, width, height)) { + return false; + } + var hasLocked = Boolean(_.find(this.nodes, function(n) { return n.locked; })); - if (!this.height && !has_locked) + if (!this.height && !hasLocked) { return true; + } - var cloned_node; + var clonedNode; var clone = new GridStackEngine( this.width, null, @@ -305,50 +404,77 @@ 0, _.map(this.nodes, function(n) { if (n == node) { - cloned_node = $.extend({}, n); - return cloned_node; + clonedNode = $.extend({}, n); + return clonedNode; } return $.extend({}, n); })); - clone.move_node(cloned_node, x, y, width, height); + if (typeof clonedNode === 'undefined') { + return true; + } + + clone.moveNode(clonedNode, x, y, width, height); var res = true; - if (has_locked) + if (hasLocked) { res &= !Boolean(_.find(clone.nodes, function(n) { - return n != cloned_node && Boolean(n.locked) && Boolean(n._dirty); + return n != clonedNode && Boolean(n.locked) && Boolean(n._dirty); })); - if (this.height) - res &= clone.get_grid_height() <= this.height; + } + if (this.height) { + res &= clone.getGridHeight() <= this.height; + } return res; }; - GridStackEngine.prototype.can_be_placed_with_respect_to_height = function(node) { - if (!this.height) + GridStackEngine.prototype.canBePlacedWithRespectToHeight = function(node) { + if (!this.height) { return true; + } var clone = new GridStackEngine( this.width, null, this.float, 0, - _.map(this.nodes, function(n) { return $.extend({}, n) })); - clone.add_node(node); - return clone.get_grid_height() <= this.height; + _.map(this.nodes, function(n) { return $.extend({}, n); })); + clone.addNode(node); + return clone.getGridHeight() <= this.height; }; - GridStackEngine.prototype.move_node = function(node, x, y, width, height, no_pack) { - if (typeof x != 'number') x = node.x; - if (typeof y != 'number') y = node.y; - if (typeof width != 'number') width = node.width; - if (typeof height != 'number') height = node.height; + GridStackEngine.prototype.isNodeChangedPosition = function(node, x, y, width, height) { + if (typeof x != 'number') { x = node.x; } + if (typeof y != 'number') { y = node.y; } + if (typeof width != 'number') { width = node.width; } + if (typeof height != 'number') { height = node.height; } + + if (typeof node.maxWidth != 'undefined') { width = Math.min(width, node.maxWidth); } + if (typeof node.maxHeight != 'undefined') { height = Math.min(height, node.maxHeight); } + if (typeof node.minWidth != 'undefined') { width = Math.max(width, node.minWidth); } + if (typeof node.minHeight != 'undefined') { height = Math.max(height, node.minHeight); } + + if (node.x == x && node.y == y && node.width == width && node.height == height) { + return false; + } + return true; + }; + + GridStackEngine.prototype.moveNode = function(node, x, y, width, height, noPack) { + if (!this.isNodeChangedPosition(node, x, y, width, height)) { + return node; + } + if (typeof x != 'number') { x = node.x; } + if (typeof y != 'number') { y = node.y; } + if (typeof width != 'number') { width = node.width; } + if (typeof height != 'number') { height = node.height; } - if (typeof node.max_width != 'undefined') width = Math.min(width, node.max_width); - if (typeof node.max_height != 'undefined') height = Math.min(height, node.max_height); - if (typeof node.min_width != 'undefined') width = Math.max(width, node.min_width); - if (typeof node.min_height != 'undefined') height = Math.max(height, node.min_height); + if (typeof node.maxWidth != 'undefined') { width = Math.min(width, node.maxWidth); } + if (typeof node.maxHeight != 'undefined') { height = Math.min(height, node.maxHeight); } + if (typeof node.minWidth != 'undefined') { width = Math.max(width, node.minWidth); } + if (typeof node.minHeight != 'undefined') { height = Math.max(height, node.minHeight); } if (node.x == x && node.y == y && node.width == width && node.height == height) { return node; @@ -362,30 +488,35 @@ node.width = width; node.height = height; - node = this._prepare_node(node, resizing); + node.lastTriedX = x; + node.lastTriedY = y; + node.lastTriedWidth = width; + node.lastTriedHeight = height; + + node = this._prepareNode(node, resizing); - this._fix_collisions(node); - if (!no_pack) { - this._pack_nodes(); + this._fixCollisions(node); + if (!noPack) { + this._packNodes(); this._notify(); } return node; }; - GridStackEngine.prototype.get_grid_height = function() { + GridStackEngine.prototype.getGridHeight = function() { return _.reduce(this.nodes, function(memo, n) { return Math.max(memo, n.y + n.height); }, 0); }; - GridStackEngine.prototype.begin_update = function(node) { + GridStackEngine.prototype.beginUpdate = function(node) { _.each(this.nodes, function(n) { - n._orig_y = n.y; + n._origY = n.y; }); node._updating = true; }; - GridStackEngine.prototype.end_update = function() { + GridStackEngine.prototype.endUpdate = function() { _.each(this.nodes, function(n) { - n._orig_y = n.y; + n._origY = n.y; }); var n = _.find(this.nodes, function(n) { return n._updating; }); if (n) { @@ -394,76 +525,158 @@ }; var GridStack = function(el, opts) { - var self = this, one_column_mode; + var self = this; + var oneColumnMode, isAutoCellHeight; opts = opts || {}; this.container = $(el); - opts.item_class = opts.item_class || 'grid-stack-item'; - var is_nested = this.container.closest('.' + opts.item_class).size() > 0; + // jscs:disable requireCamelCaseOrUpperCaseIdentifiers + if (typeof opts.handle_class !== 'undefined') { + opts.handleClass = opts.handle_class; + obsoleteOpts('handle_class', 'handleClass'); + } + if (typeof opts.item_class !== 'undefined') { + opts.itemClass = opts.item_class; + obsoleteOpts('item_class', 'itemClass'); + } + if (typeof opts.placeholder_class !== 'undefined') { + opts.placeholderClass = opts.placeholder_class; + obsoleteOpts('placeholder_class', 'placeholderClass'); + } + if (typeof opts.placeholder_text !== 'undefined') { + opts.placeholderText = opts.placeholder_text; + obsoleteOpts('placeholder_text', 'placeholderText'); + } + if (typeof opts.cell_height !== 'undefined') { + opts.cellHeight = opts.cell_height; + obsoleteOpts('cell_height', 'cellHeight'); + } + if (typeof opts.vertical_margin !== 'undefined') { + opts.verticalMargin = opts.vertical_margin; + obsoleteOpts('vertical_margin', 'verticalMargin'); + } + if (typeof opts.min_width !== 'undefined') { + opts.minWidth = opts.min_width; + obsoleteOpts('min_width', 'minWidth'); + } + if (typeof opts.static_grid !== 'undefined') { + opts.staticGrid = opts.static_grid; + obsoleteOpts('static_grid', 'staticGrid'); + } + if (typeof opts.is_nested !== 'undefined') { + opts.isNested = opts.is_nested; + obsoleteOpts('is_nested', 'isNested'); + } + if (typeof opts.always_show_resize_handle !== 'undefined') { + opts.alwaysShowResizeHandle = opts.always_show_resize_handle; + obsoleteOpts('always_show_resize_handle', 'alwaysShowResizeHandle'); + } + // jscs:enable requireCamelCaseOrUpperCaseIdentifiers + + opts.itemClass = opts.itemClass || 'grid-stack-item'; + var isNested = this.container.closest('.' + opts.itemClass).length > 0; this.opts = _.defaults(opts || {}, { width: parseInt(this.container.attr('data-gs-width')) || 12, height: parseInt(this.container.attr('data-gs-height')) || 0, - item_class: 'grid-stack-item', - placeholder_class: 'grid-stack-placeholder', - placeholder_text: '', + itemClass: 'grid-stack-item', + placeholderClass: 'grid-stack-placeholder', + placeholderText: '', handle: '.grid-stack-item-content', - handle_class: null, - cell_height: 60, - vertical_margin: 20, + handleClass: null, + cellHeight: 60, + verticalMargin: 20, auto: true, - min_width: 768, + minWidth: 768, float: false, - static_grid: false, + staticGrid: false, _class: 'grid-stack-instance-' + (Math.random() * 10000).toFixed(0), animate: Boolean(this.container.attr('data-gs-animate')) || false, - always_show_resize_handle: opts.always_show_resize_handle || false, + alwaysShowResizeHandle: opts.alwaysShowResizeHandle || false, resizable: _.defaults(opts.resizable || {}, { - autoHide: !(opts.always_show_resize_handle || false), + autoHide: !(opts.alwaysShowResizeHandle || false), handles: 'se' }), draggable: _.defaults(opts.draggable || {}, { - handle: (opts.handle_class ? '.' + opts.handle_class : (opts.handle ? opts.handle : '')) || '.grid-stack-item-content', + 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, + rtl: 'auto', + removable: false, + removeTimeout: 2000, + verticalMarginUnit: 'px', + cellHeightUnit: 'px', + oneColumnModeClass: opts.oneColumnModeClass || 'grid-stack-one-column-mode', + ddPlugin: null }); - this.opts.is_nested = is_nested; + + if (this.opts.ddPlugin === false) { + this.opts.ddPlugin = GridStackDragDropPlugin; + } else if (this.opts.ddPlugin === null) { + this.opts.ddPlugin = _.first(GridStackDragDropPlugin.registeredPlugins) || GridStackDragDropPlugin; + } + + this.dd = new this.opts.ddPlugin(this); + + if (this.opts.rtl === 'auto') { + this.opts.rtl = this.container.css('direction') === 'rtl'; + } + + if (this.opts.rtl) { + this.container.addClass('grid-stack-rtl'); + } + + this.opts.isNested = isNested; + + isAutoCellHeight = this.opts.cellHeight === 'auto'; + if (isAutoCellHeight) { + self.cellHeight(self.cellWidth(), true); + } else { + this.cellHeight(this.opts.cellHeight, true); + } + this.verticalMargin(this.opts.verticalMargin, true); this.container.addClass(this.opts._class); - this._set_static_class(); + this._setStaticClass(); - if (is_nested) { + if (isNested) { this.container.addClass('grid-stack-nested'); } - this._init_styles(); + this._initStyles(); - this.grid = new GridStackEngine(this.opts.width, function(nodes) { - var max_height = 0; + this.grid = new GridStackEngine(this.opts.width, function(nodes, detachNode) { + detachNode = typeof detachNode === 'undefined' ? true : detachNode; + var maxHeight = 0; _.each(nodes, function(n) { - if (n._id == null) { - n.el.remove(); - } - else { + if (detachNode && n._id === null) { + if (n.el) { + n.el.remove(); + } + } else { n.el .attr('data-gs-x', n.x) .attr('data-gs-y', n.y) .attr('data-gs-width', n.width) .attr('data-gs-height', n.height); - max_height = Math.max(max_height, n.y + n.height); + maxHeight = Math.max(maxHeight, n.y + n.height); } }); - self._update_styles(self.opts.height || (max_height + 10)); + self._updateStyles(self.opts.height || (max_height + 10)); }, this.opts.float, this.opts.height); if (this.opts.auto) { var elements = []; var _this = this; - this.container.children('.' + this.opts.item_class + ':not(.' + this.opts.placeholder_class + ')').each(function(index, el) { + this.container.children('.' + this.opts.itemClass + ':not(.' + this.opts.placeholderClass + ')') + .each(function(index, el) { el = $(el); elements.push({ el: el, @@ -471,70 +684,219 @@ }); }); _.chain(elements).sortBy(function(x) { return x.i; }).each(function(i) { - self._prepare_element(i.el); + self._prepareElement(i.el); }).value(); } - this.set_animation(this.opts.animate); + this.setAnimation(this.opts.animate); this.placeholder = $( - '
' + - '
' + this.opts.placeholder_text + '
').hide(); + '
' + + '
' + this.opts.placeholderText + '
').hide(); - this.container.height(this._calculate_container_height()); + this._updateContainerHeight(); // setting styles also for empty grids - this._update_styles(); + this._updateStyles(); - this.on_resize_handler = function() { - if (self._is_one_column_mode()) { - if (one_column_mode) - return; + this._updateHeightsOnResize = _.throttle(function() { + self.cellHeight(self.cellWidth(), false); + }, 100); - one_column_mode = true; + this.onResizeHandler = function() { + if (isAutoCellHeight) { + self._updateHeightsOnResize(); + } - self.grid._sort_nodes(); + if (self._isOneColumnMode()) { + if (oneColumnMode) { + return; + } + self.container.addClass(self.opts.oneColumnModeClass); + oneColumnMode = true; + + self.grid._sortNodes(); _.each(self.grid.nodes, function(node) { self.container.append(node.el); - if (self.opts.static_grid) { + if (self.opts.staticGrid) { return; } - if (!node.no_move) { - node.el.draggable('disable'); + if (node.noMove || self.opts.disableDrag) { + self.dd.draggable(node.el, 'disable'); } - if (!node.no_resize) { - node.el.resizable('disable'); + if (node.noResize || self.opts.disableResize) { + self.dd.resizable(node.el, 'disable'); } + + node.el.trigger('resize'); }); - } - else { - if (!one_column_mode) + } else { + if (!oneColumnMode) { return; + } - one_column_mode = false; + self.container.removeClass(self.opts.oneColumnModeClass); + oneColumnMode = false; - if (self.opts.static_grid) { + if (self.opts.staticGrid) { return; } _.each(self.grid.nodes, function(node) { - if (!node.no_move) { - node.el.draggable('enable'); + if (!node.noMove && !self.opts.disableDrag) { + self.dd.draggable(node.el, 'enable'); } - if (!node.no_resize) { - node.el.resizable('enable'); + if (!node.noResize && !self.opts.disableResize) { + self.dd.resizable(node.el, 'enable'); } + + node.el.trigger('resize'); }); } }; - $(window).resize(this.on_resize_handler); - this.on_resize_handler(); + $(window).resize(this.onResizeHandler); + this.onResizeHandler(); + + if (!self.opts.staticGrid && typeof self.opts.removable === 'string') { + var trashZone = $(self.opts.removable); + if (!this.dd.isDroppable(trashZone)) { + this.dd.droppable(trashZone, { + accept: '.' + self.opts.itemClass + }); + } + this.dd + .on(trashZone, 'dropover', function(event, ui) { + var el = $(ui.draggable); + var node = el.data('_gridstack_node'); + if (node._grid !== self) { + return; + } + self._setupRemovingTimeout(el); + }) + .on(trashZone, 'dropout', function(event, ui) { + var el = $(ui.draggable); + var node = el.data('_gridstack_node'); + if (node._grid !== self) { + return; + } + self._clearRemovingTimeout(el); + }); + } + + if (!self.opts.staticGrid && self.opts.acceptWidgets) { + var draggingElement = null; + + var onDrag = function(event, ui) { + var el = draggingElement; + var node = el.data('_gridstack_node'); + var pos = self.getCellFromPixel(ui.offset, true); + var x = Math.max(0, pos.x); + var y = Math.max(0, pos.y); + if (!node._added) { + node._added = true; + + node.el = el; + node.x = x; + node.y = y; + self.grid.cleanNodes(); + self.grid.beginUpdate(node); + self.grid.addNode(node); + + self.container.append(self.placeholder); + self.placeholder + .attr('data-gs-x', node.x) + .attr('data-gs-y', node.y) + .attr('data-gs-width', node.width) + .attr('data-gs-height', node.height) + .show(); + node.el = self.placeholder; + node._beforeDragX = node.x; + node._beforeDragY = node.y; + + self._updateContainerHeight(); + } else { + if (!self.grid.canMoveNode(node, x, y)) { + return; + } + self.grid.moveNode(node, x, y); + self._updateContainerHeight(); + } + }; + + this.dd + .droppable(self.container, { + accept: function(el) { + el = $(el); + var node = el.data('_gridstack_node'); + if (node && node._grid === self) { + return false; + } + return el.is(self.opts.acceptWidgets === true ? '.grid-stack-item' : self.opts.acceptWidgets); + } + }) + .on(self.container, 'dropover', function(event, ui) { + var offset = self.container.offset(); + var el = $(ui.draggable); + var cellWidth = self.cellWidth(); + var cellHeight = self.cellHeight(); + var origNode = el.data('_gridstack_node'); + + var width = origNode ? origNode.width : (Math.ceil(el.outerWidth() / cellWidth)); + var height = origNode ? origNode.height : (Math.ceil(el.outerHeight() / cellHeight)); + + draggingElement = el; + + var node = self.grid._prepareNode({width: width, height: height, _added: false, _temporary: true}); + el.data('_gridstack_node', node); + el.data('_gridstack_node_orig', origNode); + + el.on('drag', onDrag); + }) + .on(self.container, 'dropout', function(event, ui) { + var el = $(ui.draggable); + el.unbind('drag', onDrag); + var node = el.data('_gridstack_node'); + node.el = null; + self.grid.removeNode(node); + self.placeholder.detach(); + self._updateContainerHeight(); + el.data('_gridstack_node', el.data('_gridstack_node_orig')); + }) + .on(self.container, 'drop', function(event, ui) { + self.placeholder.detach(); + + var node = $(ui.draggable).data('_gridstack_node'); + node._grid = self; + var el = $(ui.draggable).clone(false); + el.data('_gridstack_node', node); + $(ui.draggable).remove(); + node.el = el; + self.placeholder.hide(); + el + .attr('data-gs-x', node.x) + .attr('data-gs-y', node.y) + .attr('data-gs-width', node.width) + .attr('data-gs-height', node.height) + .addClass(self.opts.itemClass) + .removeAttr('style') + .enableSelection() + .removeData('draggable') + .removeClass('ui-draggable ui-draggable-dragging ui-draggable-disabled') + .unbind('drag', onDrag); + self.container.append(el); + self._prepareElementsByNode(el, node); + self._updateContainerHeight(); + self._triggerChangeEvent(); + + self.grid.endUpdate(); + }); + } }; - GridStack.prototype._trigger_change_event = function(forceTrigger) { - var elements = this.grid.get_dirty_nodes(); + GridStack.prototype._triggerChangeEvent = function(forceTrigger) { + var elements = this.grid.getDirtyNodes(); var hasChanges = false; var eventParams = []; @@ -548,138 +910,237 @@ } }; - GridStack.prototype._init_styles = function() { - if (this._styles_id) { - $('[data-gs-id="' + this._styles_id + '"]').remove(); + GridStack.prototype._triggerAddEvent = function() { + if (this.grid._addedNodes && this.grid._addedNodes.length > 0) { + this.container.trigger('added', [_.map(this.grid._addedNodes, _.clone)]); + this.grid._addedNodes = []; + } + }; + + GridStack.prototype._triggerRemoveEvent = function() { + if (this.grid._removedNodes && this.grid._removedNodes.length > 0) { + this.container.trigger('removed', [_.map(this.grid._removedNodes, _.clone)]); + this.grid._removedNodes = []; } - this._styles_id = 'gridstack-style-' + (Math.random() * 100000).toFixed(); - this._styles = Utils.create_stylesheet(this._styles_id); - if (this._styles != null) + }; + + GridStack.prototype._initStyles = function() { + if (this._stylesId) { + Utils.removeStylesheet(this._stylesId); + } + this._stylesId = 'gridstack-style-' + (Math.random() * 100000).toFixed(); + this._styles = Utils.createStylesheet(this._stylesId); + if (this._styles !== null) { this._styles._max = 0; + } }; - GridStack.prototype._update_styles = function(max_height) { - if (this._styles == null) { + GridStack.prototype._updateStyles = function(maxHeight) { + if (this._styles === null || typeof this._styles === 'undefined') { return; } - var prefix = '.' + this.opts._class + ' .' + this.opts.item_class; + var prefix = '.' + this.opts._class + ' .' + this.opts.itemClass; + var self = this; + var getHeight; + + if (typeof maxHeight == 'undefined') { + maxHeight = this._styles._max || this.opts.height;; + this._initStyles(); + this._updateContainerHeight(); + } + if (!this.opts.cellHeight) { // The rest will be handled by CSS + return ; + } + if (this._styles._max !== 0 && maxHeight <= this._styles._max) { + return ; + } - if (typeof max_height == 'undefined') { - max_height = this._styles._max || this.opts.height; - this._init_styles(); - this._update_container_height(); + if (!this.opts.verticalMargin || this.opts.cellHeightUnit === this.opts.verticalMarginUnit) { + getHeight = function(nbRows, nbMargins) { + return (self.opts.cellHeight * nbRows + self.opts.verticalMargin * nbMargins) + + self.opts.cellHeightUnit; + }; + } else { + getHeight = function(nbRows, nbMargins) { + if (!nbRows || !nbMargins) { + return (self.opts.cellHeight * nbRows + self.opts.verticalMargin * nbMargins) + + self.opts.cellHeightUnit; + } + return 'calc(' + ((self.opts.cellHeight * nbRows) + self.opts.cellHeightUnit) + ' + ' + + ((self.opts.verticalMargin * nbMargins) + self.opts.verticalMarginUnit) + ')'; + }; } - if (this._styles._max == 0) { - Utils.insert_css_rule(this._styles, prefix, 'min-height: ' + (this.opts.cell_height) + 'px;', 0); + if (this._styles._max === 0) { + Utils.insertCSSRule(this._styles, prefix, 'min-height: ' + getHeight(1, 0) + ';', 0); } - if (max_height > this._styles._max) { - for (var i = this._styles._max; i < max_height; ++i) { - Utils.insert_css_rule(this._styles, + if (maxHeight > this._styles._max) { + for (var i = this._styles._max; i < maxHeight; ++i) { + Utils.insertCSSRule(this._styles, prefix + '[data-gs-height="' + (i + 1) + '"]', - 'height: ' + (this.opts.cell_height * (i + 1) + this.opts.vertical_margin * i) + 'px;', + 'height: ' + getHeight(i + 1, i) + ';', i ); - Utils.insert_css_rule(this._styles, + Utils.insertCSSRule(this._styles, prefix + '[data-gs-min-height="' + (i + 1) + '"]', - 'min-height: ' + (this.opts.cell_height * (i + 1) + this.opts.vertical_margin * i) + 'px;', + 'min-height: ' + getHeight(i + 1, i) + ';', i ); - Utils.insert_css_rule(this._styles, + Utils.insertCSSRule(this._styles, prefix + '[data-gs-max-height="' + (i + 1) + '"]', - 'max-height: ' + (this.opts.cell_height * (i + 1) + this.opts.vertical_margin * i) + 'px;', + 'max-height: ' + getHeight(i + 1, i) + ';', i ); - Utils.insert_css_rule(this._styles, + Utils.insertCSSRule(this._styles, prefix + '[data-gs-y="' + i + '"]', - 'top: ' + (this.opts.cell_height * i + this.opts.vertical_margin * i) + 'px;', + 'top: ' + getHeight(i, i) + ';', i ); } - this._styles._max = max_height; - } - }; - - GridStack.prototype._calculate_container_height = function() { - var gridHeight = this.grid.get_grid_height(); - if (!gridHeight) { - gridHeight = this.opts.height; + this._styles._max = maxHeight; } - return gridHeight * (this.opts.cell_height + this.opts.vertical_margin) - this.opts.vertical_margin; }; - GridStack.prototype._update_container_height = function() { - if (this.grid._update_counter) { + GridStack.prototype._updateContainerHeight = function() { + if (this.grid._updateCounter) { return; } - this.container.height(this._calculate_container_height()); + var height = this.grid.getGridHeight(); + this.container.attr('data-gs-current-height', height); + if (!this.opts.cellHeight) { + return ; + } + if (!this.opts.verticalMargin) { + this.container.css('height', (height * (this.opts.cellHeight)) + this.opts.cellHeightUnit); + } else if (this.opts.cellHeightUnit === this.opts.verticalMarginUnit) { + this.container.css('height', (height * (this.opts.cellHeight + this.opts.verticalMargin) - + this.opts.verticalMargin) + this.opts.cellHeightUnit); + } else { + this.container.css('height', 'calc(' + ((height * (this.opts.cellHeight)) + this.opts.cellHeightUnit) + + ' + ' + ((height * (this.opts.verticalMargin - 1)) + this.opts.verticalMarginUnit) + ')'); + } }; - GridStack.prototype._is_one_column_mode = function() { + GridStack.prototype._isOneColumnMode = function() { return (window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth) <= - this.opts.min_width; + this.opts.minWidth; }; - GridStack.prototype._prepare_element = function(el) { + GridStack.prototype._setupRemovingTimeout = function(el) { var self = this; - el = $(el); + var node = $(el).data('_gridstack_node'); - el.addClass(this.opts.item_class); + if (node._removeTimeout || !self.opts.removable) { + return; + } + node._removeTimeout = setTimeout(function() { + el.addClass('grid-stack-item-removing'); + node._isAboutToRemove = true; + }, self.opts.removeTimeout); + }; - var node = self.grid.add_node({ - x: el.attr('data-gs-x'), - y: el.attr('data-gs-y'), - width: el.attr('data-gs-width'), - height: el.attr('data-gs-height'), - max_width: el.attr('data-gs-max-width'), - min_width: el.attr('data-gs-min-width'), - max_height: el.attr('data-gs-max-height'), - min_height: el.attr('data-gs-min-height'), - auto_position: Utils.toBool(el.attr('data-gs-auto-position')), - no_resize: Utils.toBool(el.attr('data-gs-no-resize')), - no_move: Utils.toBool(el.attr('data-gs-no-move')), - locked: Utils.toBool(el.attr('data-gs-locked')), - el: el - }); - el.data('_gridstack_node', node); + GridStack.prototype._clearRemovingTimeout = function(el) { + var node = $(el).data('_gridstack_node'); + + if (!node._removeTimeout) { + return; + } + clearTimeout(node._removeTimeout); + node._removeTimeout = null; + el.removeClass('grid-stack-item-removing'); + node._isAboutToRemove = false; + }; - if (self.opts.static_grid) { + GridStack.prototype._prepareElementsByNode = function(el, node) { + if (typeof $.ui === 'undefined') { return; } + var self = this; - var cell_width, cell_height; + var cellWidth; + var cellHeight; - var drag_or_resize = function(event, ui) { - var x = Math.round(ui.position.left / cell_width), - y = Math.floor((ui.position.top + cell_height / 2) / cell_height), - width, height; - if (event.type != "drag") { - width = Math.round(ui.size.width / cell_width); - height = Math.round(ui.size.height / cell_height); + var dragOrResize = function(event, ui) { + var x = Math.round(ui.position.left / cellWidth); + var y = Math.floor((ui.position.top + cellHeight / 2) / cellHeight); + var width; + var height; + + if (event.type != 'drag') { + width = Math.round(ui.size.width / cellWidth); + height = Math.round(ui.size.height / cellHeight); } - if (!self.grid.can_move_node(node, x, y, width, height)) { + if (event.type == 'drag') { + if (x < 0 || x >= self.grid.width || y < 0) { + if (self.opts.removable === true) { + self._setupRemovingTimeout(el); + } + + x = node._beforeDragX; + y = node._beforeDragY; + + self.placeholder.detach(); + self.placeholder.hide(); + self.grid.removeNode(node); + self._updateContainerHeight(); + + node._temporaryRemoved = true; + } else { + self._clearRemovingTimeout(el); + + if (node._temporaryRemoved) { + self.grid.addNode(node); + self.placeholder + .attr('data-gs-x', x) + .attr('data-gs-y', y) + .attr('data-gs-width', width) + .attr('data-gs-height', height) + .show(); + self.container.append(self.placeholder); + node.el = self.placeholder; + node._temporaryRemoved = false; + } + } + } else if (event.type == 'resize') { + if (x < 0) { + return; + } + } + // width and height are undefined if not resizing + var lastTriedWidth = typeof width !== 'undefined' ? width : node.lastTriedWidth; + var lastTriedHeight = typeof height !== 'undefined' ? height : node.lastTriedHeight; + if (!self.grid.canMoveNode(node, x, y, width, height) || + (node.lastTriedX === x && node.lastTriedY === y && + node.lastTriedWidth === lastTriedWidth && node.lastTriedHeight === lastTriedHeight)) { return; } - self.grid.move_node(node, x, y, width, height); - self._update_container_height(); + node.lastTriedX = x; + node.lastTriedY = y; + node.lastTriedWidth = width; + node.lastTriedHeight = height; + self.grid.moveNode(node, x, y, width, height); + self._updateContainerHeight(); }; - var on_start_moving = function(event, ui) { - if (self.opts.draggable.handle && event.type === 'dragstart') { + var onStartMoving = function(event, ui) { + + if (self.opts.draggable.handle && event.type === 'dragstart') { // if handle specified, don't allow drag from anywhere else if (!$(event.originalEvent.target).closest(self.opts.draggable.handle).length) { return false; } } + self.container.append(self.placeholder); var o = $(this); - self.grid.clean_nodes(); - self.grid.begin_update(node); - cell_width = o.outerWidth() / o.attr('data-gs-width'); - cell_height = self.opts.cell_height + self.opts.vertical_margin; + self.grid.cleanNodes(); + self.grid.beginUpdate(node); + cellWidth = self.cellWidth(); + var strictCellHeight = Math.ceil(o.outerHeight() / o.attr('data-gs-height')); + cellHeight = self.container.height() / parseInt(self.container.attr('data-gs-current-height')); self.placeholder .attr('data-gs-x', o.attr('data-gs-x')) .attr('data-gs-y', o.attr('data-gs-y')) @@ -687,125 +1148,202 @@ .attr('data-gs-height', o.attr('data-gs-height')) .show(); node.el = self.placeholder; + node._beforeDragX = node.x; + node._beforeDragY = node.y; - el.resizable('option', 'minWidth', Math.round(cell_width * (node.min_width || 1))); - el.resizable('option', 'minHeight', self.opts.cell_height * (node.min_height || 1)); + self.dd.resizable(el, 'option', 'minWidth', cellWidth * (node.minWidth || 1)); + self.dd.resizable(el, 'option', 'minHeight', strictCellHeight * (node.minHeight || 1)); if (event.type == 'resizestart') { o.find('.grid-stack-item').trigger('resizestart'); } }; - var on_end_moving = function(event, ui) { - self.placeholder.detach(); + var onEndMoving = function(event, ui) { var o = $(this); + if (!o.data('_gridstack_node')) { + return; + } + + var forceNotify = false; + self.placeholder.detach(); node.el = o; self.placeholder.hide(); - o - .attr('data-gs-x', node.x) - .attr('data-gs-y', node.y) - .attr('data-gs-width', node.width) - .attr('data-gs-height', node.height) - .removeAttr('style'); - self._update_container_height(); - self._trigger_change_event(); - - self.grid.end_update(); - - var nested_grids = o.find('.grid-stack'); - if (nested_grids.length && event.type == 'resizestop') { - nested_grids.each(function(index, el) { - $(el).data('gridstack').on_resize_handler(); + + if (node._isAboutToRemove) { + forceNotify = true; + el.removeData('_gridstack_node'); + el.remove(); + } else { + self._clearRemovingTimeout(el); + if (!node._temporaryRemoved) { + o + .attr('data-gs-x', node.x) + .attr('data-gs-y', node.y) + .attr('data-gs-width', node.width) + .attr('data-gs-height', node.height) + .removeAttr('style'); + } else { + o + .attr('data-gs-x', node._beforeDragX) + .attr('data-gs-y', node._beforeDragY) + .attr('data-gs-width', node.width) + .attr('data-gs-height', node.height) + .removeAttr('style'); + node.x = node._beforeDragX; + node.y = node._beforeDragY; + self.grid.addNode(node); + } + } + self._updateContainerHeight(); + self._triggerChangeEvent(forceNotify); + + self.grid.endUpdate(); + + var nestedGrids = o.find('.grid-stack'); + if (nestedGrids.length && event.type == 'resizestop') { + nestedGrids.each(function(index, el) { + $(el).data('gridstack').onResizeHandler(); }); o.find('.grid-stack-item').trigger('resizestop'); } }; - el - .draggable(_.extend(this.opts.draggable, { - containment: this.opts.is_nested ? this.container.parent() : null - })) - .on('dragstart', on_start_moving) - .on('dragstop', on_end_moving) - .on('drag', drag_or_resize) - .resizable(_.extend(this.opts.resizable, {})) - .on('resizestart', on_start_moving) - .on('resizestop', on_end_moving) - .on('resize', drag_or_resize); + this.dd + .draggable(el, { + start: onStartMoving, + stop: onEndMoving, + drag: dragOrResize + }) + .resizable(el, { + start: onStartMoving, + stop: onEndMoving, + resize: dragOrResize + }); - if (node.no_move || this._is_one_column_mode()) { - el.draggable('disable'); + if (node.noMove || this._isOneColumnMode() || this.opts.disableDrag) { + this.dd.draggable(el, 'disable'); } - if (node.no_resize || this._is_one_column_mode()) { - el.resizable('disable'); + if (node.noResize || this._isOneColumnMode() || this.opts.disableResize) { + this.dd.resizable(el, 'disable'); } el.attr('data-gs-locked', node.locked ? 'yes' : null); }; - GridStack.prototype.set_animation = function(enable) { + GridStack.prototype._prepareElement = function(el, triggerAddEvent) { + triggerAddEvent = typeof triggerAddEvent != 'undefined' ? triggerAddEvent : false; + var self = this; + el = $(el); + + el.addClass(this.opts.itemClass); + var node = self.grid.addNode({ + x: el.attr('data-gs-x'), + y: el.attr('data-gs-y'), + width: el.attr('data-gs-width'), + height: el.attr('data-gs-height'), + maxWidth: el.attr('data-gs-max-width'), + minWidth: el.attr('data-gs-min-width'), + maxHeight: el.attr('data-gs-max-height'), + minHeight: el.attr('data-gs-min-height'), + autoPosition: Utils.toBool(el.attr('data-gs-auto-position')), + noResize: Utils.toBool(el.attr('data-gs-no-resize')), + noMove: Utils.toBool(el.attr('data-gs-no-move')), + locked: Utils.toBool(el.attr('data-gs-locked')), + el: el, + id: el.attr('data-gs-id'), + _grid: self + }, triggerAddEvent); + el.data('_gridstack_node', node); + + this._prepareElementsByNode(el, node); + }; + + GridStack.prototype.setAnimation = function(enable) { if (enable) { this.container.addClass('grid-stack-animate'); - } - else { + } else { this.container.removeClass('grid-stack-animate'); } }; - GridStack.prototype.add_widget = function(el, x, y, width, height, auto_position) { + GridStack.prototype.addWidget = function(el, x, y, width, height, autoPosition, minWidth, maxWidth, + minHeight, maxHeight, id) { el = $(el); - if (typeof x != 'undefined') el.attr('data-gs-x', x); - if (typeof y != 'undefined') el.attr('data-gs-y', y); - if (typeof width != 'undefined') el.attr('data-gs-width', width); - if (typeof height != 'undefined') el.attr('data-gs-height', height); - if (typeof auto_position != 'undefined') el.attr('data-gs-auto-position', auto_position ? 'yes' : null); + if (typeof x != 'undefined') { el.attr('data-gs-x', x); } + if (typeof y != 'undefined') { el.attr('data-gs-y', y); } + if (typeof width != 'undefined') { el.attr('data-gs-width', width); } + if (typeof height != 'undefined') { el.attr('data-gs-height', height); } + if (typeof autoPosition != 'undefined') { el.attr('data-gs-auto-position', autoPosition ? 'yes' : null); } + if (typeof minWidth != 'undefined') { el.attr('data-gs-min-width', minWidth); } + if (typeof maxWidth != 'undefined') { el.attr('data-gs-max-width', maxWidth); } + if (typeof minHeight != 'undefined') { el.attr('data-gs-min-height', minHeight); } + if (typeof maxHeight != 'undefined') { el.attr('data-gs-max-height', maxHeight); } + if (typeof id != 'undefined') { el.attr('data-gs-id', id); } this.container.append(el); + this.make_widget(el); + return el; }; - GridStack.prototype.make_widget = function(el) { + GridStack.prototype.makeWidget = function(el) { el = $(el); - this._prepare_element(el); - this._update_container_height(); - this._trigger_change_event(true); + this._prepareElement(el, true); + this._triggerAddEvent(); + this._updateContainerHeight(); + this._triggerChangeEvent(true); return el; }; - GridStack.prototype.will_it_fit = function(x, y, width, height, auto_position) { - var node = {x: x, y: y, width: width, height: height, auto_position: auto_position}; - return this.grid.can_be_placed_with_respect_to_height(node); + GridStack.prototype.willItFit = function(x, y, width, height, autoPosition) { + var node = {x: x, y: y, width: width, height: height, autoPosition: autoPosition}; + return this.grid.canBePlacedWithRespectToHeight(node); }; - GridStack.prototype.remove_widget = function(el, detach_node) { - detach_node = typeof detach_node === 'undefined' ? true : detach_node; + GridStack.prototype.removeWidget = function(el, detachNode) { + detachNode = typeof detachNode === 'undefined' ? true : detachNode; el = $(el); var node = el.data('_gridstack_node'); - this.grid.remove_node(node); + + // For Meteor support: https://github.com/troolee/gridstack.js/pull/272 + if (!node) { + node = this.grid.getNodeDataByDOMEl(el); + } + + this.grid.removeNode(node, detachNode); el.removeData('_gridstack_node'); - this._update_container_height(); - if (detach_node) + this._updateContainerHeight(); + if (detachNode) { el.remove(); - this._trigger_change_event(true); + } + this._triggerChangeEvent(true); + this._triggerRemoveEvent(); }; - GridStack.prototype.remove_all = function(detach_node) { + GridStack.prototype.removeAll = function(detachNode) { _.each(this.grid.nodes, _.bind(function(node) { - this.remove_widget(node.el, detach_node); + this.removeWidget(node.el, detachNode); }, this)); this.grid.nodes = []; - this._update_container_height(); + this._updateContainerHeight(); }; - GridStack.prototype.destroy = function() { - $(window).off("resize", this.on_resize_handler); + GridStack.prototype.destroy = function(detachGrid) { + $(window).off('resize', this.onResizeHandler); this.disable(); - this.container.remove(); - Utils.remove_stylesheet(this._styles_id); - if (this.grid) + if (typeof detachGrid != 'undefined' && !detachGrid) { + this.removeAll(false); + this.container.removeData('gridstack'); + } else { + this.container.remove(); + } + Utils.removeStylesheet(this._stylesId); + if (this.grid) { this.grid = null; + } }; GridStack.prototype.resizable = function(el, val) { @@ -814,16 +1352,15 @@ el.each(function(index, el) { el = $(el); var node = el.data('_gridstack_node'); - if (typeof node == 'undefined' || node == null || self.opts.static_grid) { + if (typeof node == 'undefined' || node === null || typeof $.ui === 'undefined' || self.opts.static_grid) { return; } - node.no_resize = !(val || false); - if (node.no_resize || self._is_one_column_mode()) { - el.resizable('disable'); - } - else { - el.resizable('enable'); + node.noResize = !(val || false); + if (node.noResize || self._isOneColumnMode()) { + self.dd.resizable(el, 'disable'); + } else { + self.dd.resizable(el, 'enable'); } }); return this; @@ -835,32 +1372,45 @@ el.each(function(index, el) { el = $(el); var node = el.data('_gridstack_node'); - if (typeof node == 'undefined' || node == null || self.opts.static_grid) { + if (typeof node == 'undefined' || node === null || typeof $.ui === 'undefined' || self.opts.static_grid) { return; } - node.no_move = !(val || false); - if (node.no_move || self._is_one_column_mode()) { - el.draggable('disable'); + node.noMove = !(val || false); + if (node.noMove || self._isOneColumnMode()) { + self.dd.draggable(el, 'disable'); el.removeClass('ui-draggable-handle'); - } - else { - el.draggable('enable'); + } else { + self.dd.draggable(el, 'enable'); el.addClass('ui-draggable-handle'); } }); return this; }; + GridStack.prototype.enableMove = function(doEnable, includeNewWidgets) { + this.movable(this.container.children('.' + this.opts.itemClass), doEnable); + if (includeNewWidgets) { + this.opts.disableDrag = !doEnable; + } + }; + + GridStack.prototype.enableResize = function(doEnable, includeNewWidgets) { + this.resizable(this.container.children('.' + this.opts.itemClass), doEnable); + if (includeNewWidgets) { + this.opts.disableResize = !doEnable; + } + }; + GridStack.prototype.disable = function() { - this.movable(this.container.children('.' + this.opts.item_class), false); - this.resizable(this.container.children('.' + this.opts.item_class), false); + this.movable(this.container.children('.' + this.opts.itemClass), false); + this.resizable(this.container.children('.' + this.opts.itemClass), false); this.container.trigger('disable'); }; GridStack.prototype.enable = function() { - this.movable(this.container.children('.' + this.opts.item_class), true); - this.resizable(this.container.children('.' + this.opts.item_class), true); + this.movable(this.container.children('.' + this.opts.itemClass), true); + this.resizable(this.container.children('.' + this.opts.itemClass), true); this.container.trigger('enable'); }; @@ -869,7 +1419,7 @@ el.each(function(index, el) { el = $(el); var node = el.data('_gridstack_node'); - if (typeof node == 'undefined' || node == null) { + if (typeof node == 'undefined' || node === null) { return; } @@ -879,154 +1429,220 @@ return this; }; - GridStack.prototype.min_height = function (el, val) { + GridStack.prototype.maxHeight = function(el, val) { el = $(el); - el.each(function (index, el) { + el.each(function(index, el) { el = $(el); var node = el.data('_gridstack_node'); - if (typeof node == 'undefined' || node == null) { + if (typeof node === 'undefined' || node === null) { return; } - if(!isNaN(val)){ - node.min_height = (val || false); + if (!isNaN(val)) { + node.maxHeight = (val || false); + el.attr('data-gs-max-height', val); + } + }); + return this; + }; + + GridStack.prototype.minHeight = function(el, val) { + el = $(el); + el.each(function(index, el) { + el = $(el); + var node = el.data('_gridstack_node'); + if (typeof node === 'undefined' || node === null) { + return; + } + + if (!isNaN(val)) { + node.minHeight = (val || false); el.attr('data-gs-min-height', val); } }); return this; }; - GridStack.prototype.min_width = function (el, val) { + GridStack.prototype.maxWidth = function(el, val) { el = $(el); - el.each(function (index, el) { + el.each(function(index, el) { el = $(el); var node = el.data('_gridstack_node'); - if (typeof node == 'undefined' || node == null) { + if (typeof node === 'undefined' || node === null) { return; } - if(!isNaN(val)){ - node.min_width = (val || false); + if (!isNaN(val)) { + node.maxWidth = (val || false); + el.attr('data-gs-max-width', val); + } + }); + return this; + }; + + GridStack.prototype.minWidth = function(el, val) { + el = $(el); + el.each(function(index, el) { + el = $(el); + var node = el.data('_gridstack_node'); + if (typeof node === 'undefined' || node === null) { + return; + } + + if (!isNaN(val)) { + node.minWidth = (val || false); el.attr('data-gs-min-width', val); } }); return this; }; - GridStack.prototype._update_element = function(el, callback) { + GridStack.prototype._updateElement = function(el, callback) { + el = $(el).first(); var node = el.data('_gridstack_node'); - if (typeof node == 'undefined' || node == null) { + if (typeof node == 'undefined' || node === null) { return; } var self = this; - self.grid.clean_nodes(); - self.grid.begin_update(node); + self.grid.cleanNodes(); + self.grid.beginUpdate(node); callback.call(this, el, node); - self._update_container_height(); - self._trigger_change_event(); + self._updateContainerHeight(); + self._triggerChangeEvent(); - self.grid.end_update(); + self.grid.endUpdate(); }; GridStack.prototype.resize = function(el, width, height) { - this._update_element(el, function(el, node) { - width = (width != null && typeof width != 'undefined') ? width : node.width; - height = (height != null && typeof height != 'undefined') ? height : node.height; + this._updateElement(el, function(el, node) { + width = (width !== null && typeof width != 'undefined') ? width : node.width; + height = (height !== null && typeof height != 'undefined') ? height : node.height; - this.grid.move_node(node, node.x, node.y, width, height); + this.grid.moveNode(node, node.x, node.y, width, height); }); }; GridStack.prototype.move = function(el, x, y) { - this._update_element(el, function(el, node) { - x = (x != null && typeof x != 'undefined') ? x : node.x; - y = (y != null && typeof y != 'undefined') ? y : node.y; + this._updateElement(el, function(el, node) { + x = (x !== null && typeof x != 'undefined') ? x : node.x; + y = (y !== null && typeof y != 'undefined') ? y : node.y; - this.grid.move_node(node, x, y, node.width, node.height); + this.grid.moveNode(node, x, y, node.width, node.height); }); }; GridStack.prototype.update = function(el, x, y, width, height) { - this._update_element(el, function(el, node) { - x = (x != null && typeof x != 'undefined') ? x : node.x; - y = (y != null && typeof y != 'undefined') ? y : node.y; - width = (width != null && typeof width != 'undefined') ? width : node.width; - height = (height != null && typeof height != 'undefined') ? height : node.height; + this._updateElement(el, function(el, node) { + x = (x !== null && typeof x != 'undefined') ? x : node.x; + y = (y !== null && typeof y != 'undefined') ? y : node.y; + width = (width !== null && typeof width != 'undefined') ? width : node.width; + height = (height !== null && typeof height != 'undefined') ? height : node.height; - this.grid.move_node(node, x, y, width, height); + this.grid.moveNode(node, x, y, width, height); }); }; - GridStack.prototype.cell_height = function(val) { + GridStack.prototype.verticalMargin = function(val, noUpdate) { if (typeof val == 'undefined') { - return this.opts.cell_height; + return this.opts.verticalMargin; } - val = parseInt(val); - if (val == this.opts.cell_height) - return; - this.opts.cell_height = val || this.opts.cell_height; - this._update_styles(); + + var heightData = Utils.parseHeight(val); + + if (this.opts.verticalMarginUnit === heightData.unit && this.opts.height === heightData.height) { + return ; + } + this.opts.verticalMarginUnit = heightData.unit; + this.opts.verticalMargin = heightData.height; + + if (!noUpdate) { + this._updateStyles(); + } + }; + + GridStack.prototype.cellHeight = function(val, noUpdate) { + if (typeof val == 'undefined') { + if (this.opts.cellHeight) { + return this.opts.cellHeight; + } + var o = this.container.children('.' + this.opts.itemClass).first(); + return Math.ceil(o.outerHeight() / o.attr('data-gs-height')); + } + var heightData = Utils.parseHeight(val); + + if (this.opts.cellHeightUnit === heightData.heightUnit && this.opts.height === heightData.height) { + return ; + } + this.opts.cellHeightUnit = heightData.unit; + this.opts.cellHeight = heightData.height; + + if (!noUpdate) { + this._updateStyles(); + } + }; - GridStack.prototype.cell_width = function() { - var o = this.container.children('.' + this.opts.item_class).first(); - return Math.ceil(o.outerWidth() / o.attr('data-gs-width')); + GridStack.prototype.cellWidth = function() { + return Math.round(this.container.outerWidth() / this.opts.width); }; - GridStack.prototype.get_cell_from_pixel = function(position) { - var containerPos = this.container.position(); + GridStack.prototype.getCellFromPixel = function(position, useOffset) { + var containerPos = (typeof useOffset != 'undefined' && useOffset) ? + this.container.offset() : this.container.position(); var relativeLeft = position.left - containerPos.left; var relativeTop = position.top - containerPos.top; - var column_width = Math.floor(this.container.width() / this.opts.width); - var row_height = this.opts.cell_height + this.opts.vertical_margin; + var columnWidth = Math.floor(this.container.width() / this.opts.width); + var rowHeight = Math.floor(this.container.height() / parseInt(this.container.attr('data-gs-current-height'))); - return {x: Math.floor(relativeLeft / column_width), y: Math.floor(relativeTop / row_height)}; + return {x: Math.floor(relativeLeft / columnWidth), y: Math.floor(relativeTop / rowHeight)}; }; - GridStack.prototype.batch_update = function() { - this.grid.batch_update(); + GridStack.prototype.batchUpdate = function() { + this.grid.batchUpdate(); }; GridStack.prototype.commit = function() { this.grid.commit(); - this._update_container_height(); + this._updateContainerHeight(); }; - GridStack.prototype.is_area_empty = function(x, y, width, height) { - return this.grid.is_area_empty(x, y, width, height); + GridStack.prototype.isAreaEmpty = function(x, y, width, height) { + return this.grid.isAreaEmpty(x, y, width, height); }; - GridStack.prototype.set_static = function(static_value) { - this.opts.static_grid = (static_value === true); - this._set_static_class(); + GridStack.prototype.setStatic = function(staticValue) { + this.opts.staticGrid = (staticValue === true); + this.enableMove(!staticValue); + this.enableResize(!staticValue); + this._setStaticClass(); }; - GridStack.prototype._set_static_class = function() { - var static_class_name = 'grid-stack-static'; + GridStack.prototype._setStaticClass = function() { + var staticClassName = 'grid-stack-static'; - if (this.opts.static_grid === true) { - this.container.addClass(static_class_name); + if (this.opts.staticGrid === true) { + this.container.addClass(staticClassName); } else { - this.container.removeClass(static_class_name); + this.container.removeClass(staticClassName); } }; - GridStack.prototype.refresh_nodes = function() { + GridStack.prototype.refreshNodes = function() { var that = this; - this.remove_all(false); + this.removeAll(false); this.container.find('.' + this.opts.item_class).each(function(k, node){ $(node).off('dragstart dragstop drag resizestart resizestop resize'); that.make_widget(node); }); }; - GridStack.prototype.get_cell_from_absolute_pixel = function(nodeOffset) { + GridStack.prototype.getCellFromAbsolutePixel = function(nodeOffset) { var offset = this.container.offset(), position = this.container.position(); @@ -1036,29 +1652,122 @@ top: nodeOffset.top - offset.top + position.top }; - return this.get_cell_from_pixel(nodeOffset); + return this.getCellFromPixel(nodeOffset); }; + GridStack.prototype._updateNodeWidths = function(oldWidth, newWidth) { + this.grid._sortNodes(); + this.grid.batchUpdate(); + var node = {}; + for (var i = 0; i < this.grid.nodes.length; i++) { + node = this.grid.nodes[i]; + this.update(node.el, Math.round(node.x * newWidth / oldWidth), undefined, + Math.round(node.width * newWidth / oldWidth), undefined); + } + this.grid.commit(); + }; + + GridStack.prototype.setGridWidth = function(gridWidth,doNotPropagate) { + this.container.removeClass('grid-stack-' + this.opts.width); + if (doNotPropagate !== true) { + this._updateNodeWidths(this.opts.width, gridWidth); + } + this.opts.width = gridWidth; + this.grid.width = gridWidth; + this.container.addClass('grid-stack-' + gridWidth); + }; + + // jscs:disable requireCamelCaseOrUpperCaseIdentifiers + GridStackEngine.prototype.batch_update = obsolete(GridStackEngine.prototype.batchUpdate); + GridStackEngine.prototype._fix_collisions = obsolete(GridStackEngine.prototype._fixCollisions, + '_fix_collisions', '_fixCollisions'); + GridStackEngine.prototype.is_area_empty = obsolete(GridStackEngine.prototype.isAreaEmpty, + 'is_area_empty', 'isAreaEmpty'); + GridStackEngine.prototype._sort_nodes = obsolete(GridStackEngine.prototype._sortNodes, + '_sort_nodes', '_sortNodes'); + GridStackEngine.prototype._pack_nodes = obsolete(GridStackEngine.prototype._packNodes, + '_pack_nodes', '_packNodes'); + GridStackEngine.prototype._prepare_node = obsolete(GridStackEngine.prototype._prepareNode, + '_prepare_node', '_prepareNode'); + GridStackEngine.prototype.clean_nodes = obsolete(GridStackEngine.prototype.cleanNodes, + 'clean_nodes', 'cleanNodes'); + GridStackEngine.prototype.get_dirty_nodes = obsolete(GridStackEngine.prototype.getDirtyNodes, + 'get_dirty_nodes', 'getDirtyNodes'); + GridStackEngine.prototype.add_node = obsolete(GridStackEngine.prototype.addNode, + 'add_node', 'addNode, '); + GridStackEngine.prototype.remove_node = obsolete(GridStackEngine.prototype.removeNode, + 'remove_node', 'removeNode'); + GridStackEngine.prototype.can_move_node = obsolete(GridStackEngine.prototype.canMoveNode, + 'can_move_node', 'canMoveNode'); + GridStackEngine.prototype.move_node = obsolete(GridStackEngine.prototype.moveNode, + 'move_node', 'moveNode'); + GridStackEngine.prototype.get_grid_height = obsolete(GridStackEngine.prototype.getGridHeight, + 'get_grid_height', 'getGridHeight'); + GridStackEngine.prototype.begin_update = obsolete(GridStackEngine.prototype.beginUpdate, + 'begin_update', 'beginUpdate'); + GridStackEngine.prototype.end_update = obsolete(GridStackEngine.prototype.endUpdate, + 'end_update', 'endUpdate'); + GridStackEngine.prototype.can_be_placed_with_respect_to_height = + obsolete(GridStackEngine.prototype.canBePlacedWithRespectToHeight, + 'can_be_placed_with_respect_to_height', 'canBePlacedWithRespectToHeight'); + GridStack.prototype._trigger_change_event = obsolete(GridStack.prototype._triggerChangeEvent, + '_trigger_change_event', '_triggerChangeEvent'); + GridStack.prototype._init_styles = obsolete(GridStack.prototype._initStyles, + '_init_styles', '_initStyles'); + GridStack.prototype._update_styles = obsolete(GridStack.prototype._updateStyles, + '_update_styles', '_updateStyles'); + GridStack.prototype._update_container_height = obsolete(GridStack.prototype._updateContainerHeight, + '_update_container_height', '_updateContainerHeight'); + GridStack.prototype._is_one_column_mode = obsolete(GridStack.prototype._isOneColumnMode, + '_is_one_column_mode','_isOneColumnMode'); + GridStack.prototype._prepare_element = obsolete(GridStack.prototype._prepareElement, + '_prepare_element', '_prepareElement'); + GridStack.prototype.set_animation = obsolete(GridStack.prototype.setAnimation, + 'set_animation', 'setAnimation'); + GridStack.prototype.add_widget = obsolete(GridStack.prototype.addWidget, + 'add_widget', 'addWidget'); + GridStack.prototype.make_widget = obsolete(GridStack.prototype.makeWidget, + 'make_widget', 'makeWidget'); + GridStack.prototype.will_it_fit = obsolete(GridStack.prototype.willItFit, + 'will_it_fit', 'willItFit'); + GridStack.prototype.remove_widget = obsolete(GridStack.prototype.removeWidget, + 'remove_widget', 'removeWidget'); + GridStack.prototype.remove_all = obsolete(GridStack.prototype.removeAll, + 'remove_all', 'removeAll'); + GridStack.prototype.min_height = obsolete(GridStack.prototype.minHeight, + 'min_height', 'minHeight'); + GridStack.prototype.min_width = obsolete(GridStack.prototype.minWidth, + 'min_width', 'minWidth'); + GridStack.prototype._update_element = obsolete(GridStack.prototype._updateElement, + '_update_element', '_updateElement'); + GridStack.prototype.cell_height = obsolete(GridStack.prototype.cellHeight, + 'cell_height', 'cellHeight'); + GridStack.prototype.cell_width = obsolete(GridStack.prototype.cellWidth, + 'cell_width', 'cellWidth'); + GridStack.prototype.get_cell_from_pixel = obsolete(GridStack.prototype.getCellFromPixel, + 'get_cell_from_pixel', 'getCellFromPixel'); + GridStack.prototype.batch_update = obsolete(GridStack.prototype.batchUpdate, + 'batch_update', 'batchUpdate'); + GridStack.prototype.is_area_empty = obsolete(GridStack.prototype.isAreaEmpty, + 'is_area_empty', 'isAreaEmpty'); + GridStack.prototype.set_static = obsolete(GridStack.prototype.setStatic, + 'set_static', 'setStatic'); + GridStack.prototype._set_static_class = obsolete(GridStack.prototype._setStaticClass, + '_set_static_class', '_setStaticClass'); + // jscs:enable requireCamelCaseOrUpperCaseIdentifiers + scope.GridStackUI = GridStack; scope.GridStackUI.Utils = Utils; + scope.GridStackUI.Engine = GridStackEngine; + scope.GridStackUI.GridStackDragDropPlugin = GridStackDragDropPlugin; - function event_stop_propagate(event) { - event.stopPropagation(); - } $.fn.gridstack = function(opts) { return this.each(function() { var o = $(this); if (!o.data('gridstack')) { o - .data('gridstack', new GridStack(this, opts)) - .on('dragstart', event_stop_propagate) - .on('dragstop', event_stop_propagate) - .on('drag', event_stop_propagate) - .on('resizestart', event_stop_propagate) - .on('resizestop', event_stop_propagate) - .on('resize', event_stop_propagate) - .on('change', event_stop_propagate); + .data('gridstack', new GridStack(this, opts)); } }); }; diff --git a/src/gridstack.scss b/src/gridstack.scss index 46fa37a6b..dbd6bfaa9 100644 --- a/src/gridstack.scss +++ b/src/gridstack.scss @@ -16,6 +16,14 @@ $animation_speed: .3s !default; .grid-stack { position: relative; + &.grid-stack-rtl { + direction: ltr; + + > .grid-stack-item { + direction: rtl; + } + } + .grid-stack-placeholder > .placeholder-content { border: 1px dashed lightgray; margin: 0; @@ -71,26 +79,17 @@ $animation_speed: .3s !default; > .ui-resizable-se, > .ui-resizable-sw { - text-align: right; - color: gray; - - padding: 2px 3px 0 0; - margin: 0; - - font: normal normal normal 10px/1 FontAwesome; - font-size: inherit; - text-rendering: auto; - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; - - &::before { content: "\f065"; } + background-image: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iaXNvLTg4NTktMSI/Pgo8IS0tIEdlbmVyYXRvcjogQWRvYmUgSWxsdXN0cmF0b3IgMTYuMC4wLCBTVkcgRXhwb3J0IFBsdWctSW4gLiBTVkcgVmVy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MWMtMy42MTcsMy42MjEtNS40MjQsNy45MDUtNS40MjQsMTIuODU0ICAgYzAsNC45NDUsMS44MDcsOS4yMjcsNS40MjQsMTIuODQ3bDczLjA4OSw3My4wODhjMy42MTcsMy42MTcsNy44OTgsNS40MjQsMTIuODQ3LDUuNDI0YzQuOTUsMCw5LjIzNC0xLjgwNywxMi44NDktNS40MjQgICBsNzMuMDg3LTczLjA4OGMzLjYxMy0zLjYyLDUuNDIxLTcuOTAxLDUuNDIxLTEyLjg0N2MwLTQuOTQ4LTEuODA4LTkuMjMyLTUuNDIxLTEyLjg1NCAgIEMzMzguMTQyLDQwMy44MDIsMzMzLjg1Nyw0MDEuOTk0LDMyOC45MDYsNDAxLjk5NHoiIGZpbGw9IiM2NjY2NjYiLz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8L3N2Zz4K); + background-repeat: no-repeat; + background-position: center; + @include vendor(transform, rotate(45deg)); } > .ui-resizable-se { - display: inline-block; - @include vendor(transform, rotate(90deg)); + @include vendor(transform, rotate(-45deg)); } + > .ui-resizable-nw { cursor: nw-resize; width: 20px; height: 20px; left: 10px; top: 0; } > .ui-resizable-n { cursor: n-resize; height: 10px; top: 0; left: 25px; right: 25px; } > .ui-resizable-ne { cursor: ne-resize; width: 20px; height: 20px; right: 10px; top: 0; } @@ -100,6 +99,12 @@ $animation_speed: .3s !default; > .ui-resizable-sw { cursor: sw-resize; width: 20px; height: 20px; left: 10px; bottom: 0; } > .ui-resizable-w { cursor: w-resize; width: 10px; left: $horizontal_padding / 2; top: 15px; bottom: 15px; } + &.ui-draggable-dragging { + &> .ui-resizable-handle { + display: none !important; + } + } + @for $i from 1 through $gridstack-columns { &[data-gs-width='#{$i}'] { width: (100% / $gridstack-columns) * $i; } &[data-gs-x='#{$i}'] { left: (100% / $gridstack-columns) * $i; } @@ -118,26 +123,18 @@ $animation_speed: .3s !default; &.grid-stack-animate .grid-stack-item.grid-stack-placeholder{ @include vendor(transition, left .0s, top .0s, height .0s, width .0s); } -} - -/** Uncomment this to show bottom-left resize handle **/ -/* -.grid-stack > .grid-stack-item > .ui-resizable-sw { - display: inline-block; - @include vendor(transform, rotate(180deg)); -} -*/ - -@media (max-width: 768px) { - .grid-stack-item { - position: relative !important; - width: auto !important; - left: 0 !important; - top: auto !important; - margin-bottom: $vertical_padding; - - .ui-resizable-handle { display: none; } - } - - .grid-stack { height: auto !important; } + + &.grid-stack-one-column-mode { + height: auto !important; + &> .grid-stack-item { + position: relative !important; + width: auto !important; + left: 0 !important; + top: auto !important; + margin-bottom: $vertical_padding; + max-width: none !important; + + &> .ui-resizable-handle { display: none; } + } + } } From 2db38e19bed16cb88946cc7f94bb1b374cc95751 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Inga=20Br=C5=ABnava?= Date: Thu, 24 Nov 2016 10:53:54 +0100 Subject: [PATCH 11/35] Fixes --- src/gridstack.css | 3 +-- src/gridstack.js | 13 +++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/gridstack.css b/src/gridstack.css index 7f1baccc7..319d58a75 100644 --- a/src/gridstack.css +++ b/src/gridstack.css @@ -301,7 +301,7 @@ -o-transform: rotate(180deg); transform: rotate(180deg); } - +*/ @media (max-width: 768px) { .grid-stack-item { position: relative !important; @@ -318,4 +318,3 @@ height: auto !important; } } -*/ diff --git a/src/gridstack.js b/src/gridstack.js index b48eb853a..d864309d1 100644 --- a/src/gridstack.js +++ b/src/gridstack.js @@ -945,7 +945,7 @@ var getHeight; if (typeof maxHeight == 'undefined') { - maxHeight = this._styles._max || this.opts.height;; + maxHeight = this._styles._max || this.opts.height; this._initStyles(); this._updateContainerHeight(); } @@ -1283,7 +1283,7 @@ if (typeof id != 'undefined') { el.attr('data-gs-id', id); } this.container.append(el); - this.make_widget(el); + this.makeWidget(el); return el; }; @@ -1352,7 +1352,7 @@ el.each(function(index, el) { el = $(el); var node = el.data('_gridstack_node'); - if (typeof node == 'undefined' || node === null || typeof $.ui === 'undefined' || self.opts.static_grid) { + if (typeof node == 'undefined' || node === null || typeof $.ui === 'undefined' || self.opts.staticGrid) { return; } @@ -1372,7 +1372,8 @@ el.each(function(index, el) { el = $(el); var node = el.data('_gridstack_node'); - if (typeof node == 'undefined' || node === null || typeof $.ui === 'undefined' || self.opts.static_grid) { + + if (typeof node == 'undefined' || node === null || typeof $.ui === 'undefined' || self.opts.staticGrid) { return; } @@ -1636,9 +1637,9 @@ GridStack.prototype.refreshNodes = function() { var that = this; this.removeAll(false); - this.container.find('.' + this.opts.item_class).each(function(k, node){ + this.container.find('.' + this.opts.itemClass).each(function(k, node){ $(node).off('dragstart dragstop drag resizestart resizestop resize'); - that.make_widget(node); + that.makeWidget(node); }); }; From a945811ed0b75426e2dcd4b8e8f16b30a445f373 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Inga=20Br=C5=ABnava?= Date: Tue, 29 Nov 2016 13:42:40 +0100 Subject: [PATCH 12/35] Fixes and improvements .. hopefully --- src/gridstack.js | 69 +++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 65 insertions(+), 4 deletions(-) diff --git a/src/gridstack.js b/src/gridstack.js index d864309d1..cb0aa5f86 100644 --- a/src/gridstack.js +++ b/src/gridstack.js @@ -222,6 +222,31 @@ return collisionNode === null || typeof collisionNode === 'undefined'; }; + GridStackEngine.prototype.findFreeSpace = function(w, h) { + var freeSpace = null, + i, j; + + // first free for 1x1 or we have specified width and height + if (!w) { w = 1; } + if (!h) { h = 1; } + + for (i = 0; i < this.width; i++) { + if (freeSpace) { + break; + } + for (j = 0; j < this.height; j++) { + if (freeSpace) { + break; + } + if (this.isAreaEmpty(i, j, w, h)) { + freeSpace = {x: i, y: j, w: w, h: h}; + } + } + } + + return freeSpace; + }; + GridStackEngine.prototype._sortNodes = function(dir) { this.nodes = Utils.sort(this.nodes, dir, this.width); }; @@ -425,6 +450,11 @@ } if (this.height) { res &= clone.getGridHeight() <= this.height; + + // always allow moving the one out of bounds + if (node.y + node.height > this.height) { + res = true; + } } return res; @@ -1352,7 +1382,7 @@ el.each(function(index, el) { el = $(el); var node = el.data('_gridstack_node'); - if (typeof node == 'undefined' || node === null || typeof $.ui === 'undefined' || self.opts.staticGrid) { + if (typeof node == 'undefined' || node === null || typeof $.ui === 'undefined') { return; } @@ -1373,7 +1403,7 @@ el = $(el); var node = el.data('_gridstack_node'); - if (typeof node == 'undefined' || node === null || typeof $.ui === 'undefined' || self.opts.staticGrid) { + if (typeof node == 'undefined' || node === null || typeof $.ui === 'undefined') { return; } @@ -1617,6 +1647,10 @@ return this.grid.isAreaEmpty(x, y, width, height); }; + GridStack.prototype.findFreeSpace = function(w, h) { + return this.grid.findFreeSpace(w, h); + }; + GridStack.prototype.setStatic = function(staticValue) { this.opts.staticGrid = (staticValue === true); this.enableMove(!staticValue); @@ -1634,13 +1668,40 @@ } }; - GridStack.prototype.refreshNodes = function() { + GridStack.prototype.refreshNodes = function(force, isDisabled) { var that = this; - this.removeAll(false); + + if (force) { + this.removeAll(false); + } else { + // remove all nodes, purge those that arent attached anymore + for (var i = 0; i < this.grid.nodes.length; i++) { + node = this.grid.nodes[i]; + this.removeWidget(node, !!node._updating); + // this.removeWidget(node, false); + } + this.grid.nodes = []; + if (!this.placeholder.hasClass('drag-external')) { + this.placeholder.detach(); + this.placeholder.hide(); + } + this._updateContainerHeight(); + } + this.container.find('.' + this.opts.itemClass).each(function(k, node){ $(node).off('dragstart dragstop drag resizestart resizestop resize'); that.makeWidget(node); }); + + if (this.opts.staticGrid && isDisabled) { + return; + } + + if (isDisabled) { + this.disable(); + } else { + this.enable(); + } }; GridStack.prototype.getCellFromAbsolutePixel = function(nodeOffset) { From 6b7023dede16cc548bba43ece41d84bc09a7a748 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Inga=20Br=C5=ABnava?= Date: Tue, 29 Nov 2016 14:33:22 +0100 Subject: [PATCH 13/35] Revert --- src/gridstack.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gridstack.js b/src/gridstack.js index cb0aa5f86..7a4119515 100644 --- a/src/gridstack.js +++ b/src/gridstack.js @@ -1382,7 +1382,7 @@ el.each(function(index, el) { el = $(el); var node = el.data('_gridstack_node'); - if (typeof node == 'undefined' || node === null || typeof $.ui === 'undefined') { + if (typeof node == 'undefined' || node === null || typeof $.ui === 'undefined' || self.opts.staticGrid) { return; } @@ -1403,7 +1403,7 @@ el = $(el); var node = el.data('_gridstack_node'); - if (typeof node == 'undefined' || node === null || typeof $.ui === 'undefined') { + if (typeof node == 'undefined' || node === null || typeof $.ui === 'undefined' || self.opts.staticGrid) { return; } From 51ec9e53bcc3e47edcf95fdc5e056952b7405013 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Inga=20Br=C5=ABnava?= Date: Tue, 29 Nov 2016 14:48:09 +0100 Subject: [PATCH 14/35] Lower requirements... --- bower.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bower.json b/bower.json index 37e390b63..205d92687 100644 --- a/bower.json +++ b/bower.json @@ -15,8 +15,8 @@ ], "dependencies": { "lodash": ">= 4.14.2", - "jquery": ">= 3.1.0", - "jquery-ui": ">= 1.12.0" + "jquery": ">= 2.1.0", + "jquery-ui": ">= 1.11.0" }, "keywords": [ "gridstack", From a530388e311838bc9f7eb1e153ccbd62dd07aed7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Inga=20Br=C5=ABnava?= Date: Wed, 30 Nov 2016 12:23:20 +0100 Subject: [PATCH 15/35] Simplify --- src/gridstack.js | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/src/gridstack.js b/src/gridstack.js index 7a4119515..bf38aedf4 100644 --- a/src/gridstack.js +++ b/src/gridstack.js @@ -1104,7 +1104,7 @@ } if (event.type == 'drag') { - if (x < 0 || x >= self.grid.width || y < 0) { + if (x < 0 || x >= self.grid.width || y < 0 || (self.grid.height && y >= self.grid.height)) { if (self.opts.removable === true) { self._setupRemovingTimeout(el); } @@ -1668,25 +1668,10 @@ } }; - GridStack.prototype.refreshNodes = function(force, isDisabled) { + GridStack.prototype.refreshNodes = function(isDisabled) { var that = this; - if (force) { - this.removeAll(false); - } else { - // remove all nodes, purge those that arent attached anymore - for (var i = 0; i < this.grid.nodes.length; i++) { - node = this.grid.nodes[i]; - this.removeWidget(node, !!node._updating); - // this.removeWidget(node, false); - } - this.grid.nodes = []; - if (!this.placeholder.hasClass('drag-external')) { - this.placeholder.detach(); - this.placeholder.hide(); - } - this._updateContainerHeight(); - } + this.removeAll(false); this.container.find('.' + this.opts.itemClass).each(function(k, node){ $(node).off('dragstart dragstop drag resizestart resizestop resize'); From 6bfb902c780755be49e9b396a4513ced2aee01b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Inga=20Br=C5=ABnava?= Date: Wed, 30 Nov 2016 14:20:21 +0100 Subject: [PATCH 16/35] Fix --- src/gridstack.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gridstack.js b/src/gridstack.js index bf38aedf4..238459b81 100644 --- a/src/gridstack.js +++ b/src/gridstack.js @@ -1037,7 +1037,7 @@ if (this.grid._updateCounter) { return; } - var height = this.grid.getGridHeight(); + var height = this.opts.height || this.grid.getGridHeight(); this.container.attr('data-gs-current-height', height); if (!this.opts.cellHeight) { return ; From 5c5efaddeb16a1db11fc08208d9189667c7227b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Inga=20Br=C5=ABnava?= Date: Mon, 9 Jan 2017 14:55:28 +0100 Subject: [PATCH 17/35] Improvements to counter the datawall overlaying bug --- src/gridstack.js | 54 ++++++++++++++++++++++++++++++++++++------------ 1 file changed, 41 insertions(+), 13 deletions(-) diff --git a/src/gridstack.js b/src/gridstack.js index 238459b81..c7695568b 100644 --- a/src/gridstack.js +++ b/src/gridstack.js @@ -190,7 +190,7 @@ return _.find(this.nodes, function(n) { return el.get(0) === n.el.get(0); }); }; - GridStackEngine.prototype._fixCollisions = function(node) { + GridStackEngine.prototype._fixCollisions = function(node, isClone) { var self = this; this._sortNodes(-1); @@ -204,8 +204,34 @@ if (typeof collisionNode == 'undefined') { return; } - this.moveNode(collisionNode, collisionNode.x, node.y + node.height, - collisionNode.width, collisionNode.height, true); + + // will try to fix the collision + var newPos, + newY = node.y + node.height, + wrongPos = !isClone && ((node.y + node.height + collisionNode.height) > this.height); + + if (wrongPos) { + // if the pos is out of bounds, put it on first available + newPos = this.findFreeSpace(collisionNode.width, collisionNode.height); + if (!newPos) { + newPos = this.findFreeSpace(); + } + if (!newPos) { + return; // hmm + } + } else { + newPos = { + x: collisionNode.x, + y: node.y + node.height, + w: collisionNode.width, + h: collisionNode.height + }; + } + + if (newPos) { + this.moveNode(collisionNode, newPos.x, newPos.y, newPos.w, newPos.h, true, isClone); + } + } }; @@ -230,11 +256,11 @@ if (!w) { w = 1; } if (!h) { h = 1; } - for (i = 0; i < this.width; i++) { + for (i = 0; i <= (this.width - w); i++) { if (freeSpace) { break; } - for (j = 0; j < this.height; j++) { + for (j = 0; j <= (this.height - h); j++) { if (freeSpace) { break; } @@ -317,7 +343,9 @@ node.width = 1; } - if (node.height < 1) { + if (this.height && (node.height > this.height)) { + node.height = this.height; + } else if (node.height < 1) { node.height = 1; } @@ -362,7 +390,7 @@ return _.filter(this.nodes, function(n) { return n._dirty; }); }; - GridStackEngine.prototype.addNode = function(node, triggerAddEvent) { + GridStackEngine.prototype.addNode = function(node, triggerAddEvent, isClone) { node = this._prepareNode(node); if (typeof node.maxWidth != 'undefined') { node.width = Math.min(node.width, node.maxWidth); } @@ -395,7 +423,7 @@ this._addedNodes.push(_.clone(node)); } - this._fixCollisions(node); + this._fixCollisions(node, isClone); this._packNodes(); this._notify(); return node; @@ -439,7 +467,7 @@ return true; } - clone.moveNode(clonedNode, x, y, width, height); + clone.moveNode(clonedNode, x, y, width, height, false, true); var res = true; @@ -453,7 +481,7 @@ // always allow moving the one out of bounds if (node.y + node.height > this.height) { - res = true; + res = true; } } @@ -471,7 +499,7 @@ this.float, 0, _.map(this.nodes, function(n) { return $.extend({}, n); })); - clone.addNode(node); + clone.addNode(node, false, true); return clone.getGridHeight() <= this.height; }; @@ -492,7 +520,7 @@ return true; }; - GridStackEngine.prototype.moveNode = function(node, x, y, width, height, noPack) { + GridStackEngine.prototype.moveNode = function(node, x, y, width, height, noPack, isClone) { if (!this.isNodeChangedPosition(node, x, y, width, height)) { return node; } @@ -525,7 +553,7 @@ node = this._prepareNode(node, resizing); - this._fixCollisions(node); + this._fixCollisions(node, isClone); if (!noPack) { this._packNodes(); this._notify(); From f84f3ab5c06794a909590359dfa9dbd53d3c7e73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Inga=20Br=C5=ABnava?= Date: Mon, 9 Jan 2017 14:56:20 +0100 Subject: [PATCH 18/35] Build resources --- dist/gridstack.all.js | 28 ++++-- dist/gridstack.jQueryUI.min.js | 2 +- dist/gridstack.js | 161 ++++++++++++++++++++++++++++----- dist/gridstack.min.js | 26 ++++-- dist/gridstack.min.map | 2 +- 5 files changed, 178 insertions(+), 41 deletions(-) diff --git a/dist/gridstack.all.js b/dist/gridstack.all.js index d8165226b..6fc0fc91f 100644 --- a/dist/gridstack.all.js +++ b/dist/gridstack.all.js @@ -5,7 +5,7 @@ * gridstack.js may be freely distributed under the MIT license. * @preserve */ -!function(a){if("function"==typeof define&&define.amd)define(["jquery","lodash"],a);else if("undefined"!=typeof exports){try{jQuery=require("jquery")}catch(a){}try{_=require("lodash")}catch(a){}a(jQuery,_)}else a(jQuery,_)}(function(a,b){ +!function(a){if("function"==typeof define&&define.amd)define(["jquery","lodash"],a);else if("undefined"!=typeof exports){try{jQuery=require("jquery")}catch(b){}try{_=require("lodash")}catch(b){}a(jQuery,_)}else a(jQuery,_)}(function(a,b){ // jscs:enable requireCamelCaseOrUpperCaseIdentifiers /** * @class GridStackDragDropPlugin @@ -13,27 +13,39 @@ */ function c(a){this.grid=a}var d=window,e=function(a,b,c){var d=function(){return console.warn("gridstack.js: Function `"+b+"` is deprecated as of v0.2.5 and has been replaced with `"+c+"`. It will be **completely** removed in v1.0."),a.apply(this,arguments)};return d.prototype=a.prototype,d},f=function(a,b){console.warn("gridstack.js: Option `"+a+"` is deprecated as of v0.2.5 and has been replaced with `"+b+"`. It will be **completely** removed in v1.0.")},g={isIntercepted:function(a,b){return!(a.x+a.width<=b.x||b.x+b.width<=a.x||a.y+a.height<=b.y||b.y+b.height<=a.y)},sort:function(a,c,d){return d=d||b.chain(a).map(function(a){return a.x+a.width}).max().value(),c=c!=-1?1:-1,b.sortBy(a,function(a){return c*(a.x+a.y*d)})},createStylesheet:function(a){var b=document.createElement("style");return b.setAttribute("type","text/css"),b.setAttribute("data-gs-style-id",a),b.styleSheet?b.styleSheet.cssText="":b.appendChild(document.createTextNode("")),document.getElementsByTagName("head")[0].appendChild(b),b.sheet},removeStylesheet:function(b){a("STYLE[data-gs-style-id="+b+"]").remove()},insertCSSRule:function(a,b,c,d){"function"==typeof a.insertRule?a.insertRule(b+"{"+c+"}",d):"function"==typeof a.addRule&&a.addRule(b,c,d)},toBool:function(a){return"boolean"==typeof a?a:"string"==typeof a?(a=a.toLowerCase(),!(""===a||"no"==a||"false"==a||"0"==a)):Boolean(a)},_collisionNodeCheck:function(a){return a!=this.node&&g.isIntercepted(a,this.nn)},_didCollide:function(a){return g.isIntercepted({x:this.n.x,y:this.newY,width:this.n.width,height:this.n.height},a)},_isAddNodeIntercepted:function(a){return g.isIntercepted({x:this.x,y:this.y,width:this.node.width,height:this.node.height},a)},parseHeight:function(a){var c=a,d="px";if(c&&b.isString(c)){var e=c.match(/^(-[0-9]+\.[0-9]+|[0-9]*\.[0-9]+|-[0-9]+|[0-9]+)(px|em|rem|vh|vw)?$/);if(!e)throw new Error("Invalid height");d=e[2]||"px",c=parseFloat(e[1])}return{height:c,unit:d}}}; // jscs:disable requireCamelCaseOrUpperCaseIdentifiers -g.is_intercepted=e(g.isIntercepted,"is_intercepted","isIntercepted"),g.create_stylesheet=e(g.createStylesheet,"create_stylesheet","createStylesheet"),g.remove_stylesheet=e(g.removeStylesheet,"remove_stylesheet","removeStylesheet"),g.insert_css_rule=e(g.insertCSSRule,"insert_css_rule","insertCSSRule"),c.registeredPlugins=[],c.registerPlugin=function(a){c.registeredPlugins.push(a)},c.prototype.resizable=function(a,b){return this},c.prototype.draggable=function(a,b){return this},c.prototype.droppable=function(a,b){return this},c.prototype.isDroppable=function(a){return!1},c.prototype.on=function(a,b,c){return this};var h=0,i=function(a,b,c,d,e){this.width=a,this.float=c||!1,this.height=d||0,this.nodes=e||[],this.onchange=b||function(){},this._updateCounter=0,this._float=this.float,this._addedNodes=[],this._removedNodes=[]};i.prototype.batchUpdate=function(){this._updateCounter=1,this.float=!0},i.prototype.commit=function(){0!==this._updateCounter&&(this._updateCounter=0,this.float=this._float,this._packNodes(),this._notify())}, +g.is_intercepted=e(g.isIntercepted,"is_intercepted","isIntercepted"),g.create_stylesheet=e(g.createStylesheet,"create_stylesheet","createStylesheet"),g.remove_stylesheet=e(g.removeStylesheet,"remove_stylesheet","removeStylesheet"),g.insert_css_rule=e(g.insertCSSRule,"insert_css_rule","insertCSSRule"),c.registeredPlugins=[],c.registerPlugin=function(a){c.registeredPlugins.push(a)},c.prototype.resizable=function(a,b){return this},c.prototype.draggable=function(a,b){return this},c.prototype.droppable=function(a,b){return this},c.prototype.isDroppable=function(a){return!1},c.prototype.on=function(a,b,c){return this};var h=0,i=function(a,b,c,d,e){this.width=a,this["float"]=c||!1,this.height=d||0,this.nodes=e||[],this.onchange=b||function(){},this._updateCounter=0,this._float=this["float"],this._addedNodes=[],this._removedNodes=[]};i.prototype.batchUpdate=function(){this._updateCounter=1,this["float"]=!0},i.prototype.commit=function(){0!==this._updateCounter&&(this._updateCounter=0,this["float"]=this._float,this._packNodes(),this._notify())}, // For Meteor support: https://github.com/troolee/gridstack.js/pull/272 -i.prototype.getNodeDataByDOMEl=function(a){return b.find(this.nodes,function(b){return a.get(0)===b.el.get(0)})},i.prototype._fixCollisions=function(a){this._sortNodes(-1);var c=a,d=Boolean(b.find(this.nodes,function(a){return a.locked}));for(this.float||d||(c={x:0,y:a.y,width:this.width,height:a.height});;){var e=b.find(this.nodes,b.bind(g._collisionNodeCheck,{node:a,nn:c}));if("undefined"==typeof e)return;this.moveNode(e,e.x,a.y+a.height,e.width,e.height,!0)}},i.prototype.isAreaEmpty=function(a,c,d,e){var f={x:a||0,y:c||0,width:d||1,height:e||1},h=b.find(this.nodes,b.bind(function(a){return g.isIntercepted(a,f)},this));return null===h||"undefined"==typeof h},i.prototype._sortNodes=function(a){this.nodes=g.sort(this.nodes,a,this.width)},i.prototype._packNodes=function(){this._sortNodes(),this.float?b.each(this.nodes,b.bind(function(a,c){if(!a._updating&&"undefined"!=typeof a._origY&&a.y!=a._origY)for(var d=a.y;d>=a._origY;){var e=b.chain(this.nodes).find(b.bind(g._didCollide,{n:a,newY:d})).value();e||(a._dirty=!0,a.y=d),--d}},this)):b.each(this.nodes,b.bind(function(a,c){if(!a.locked)for(;a.y>0;){var d=a.y-1,e=0===c;if(c>0){var f=b.chain(this.nodes).take(c).find(b.bind(g._didCollide,{n:a,newY:d})).value();e="undefined"==typeof f}if(!e)break;a._dirty=a.y!=d,a.y=d}},this))},i.prototype._prepareNode=function(a,c){return a=b.defaults(a||{},{width:1,height:1,x:0,y:0}),a.x=parseInt(""+a.x),a.y=parseInt(""+a.y),a.width=parseInt(""+a.width),a.height=parseInt(""+a.height),a.autoPosition=a.autoPosition||!1,a.noResize=a.noResize||!1,a.noMove=a.noMove||!1,a.width>this.width?a.width=this.width:a.width<1&&(a.width=1),a.height<1&&(a.height=1),a.x<0&&(a.x=0),a.x+a.width>this.width&&(c?a.width=this.width-a.x:a.x=this.width-a.width),a.y<0&&(a.y=0),a},i.prototype._notify=function(){var a=Array.prototype.slice.call(arguments,0);if(a[0]="undefined"==typeof a[0]?[]:[a[0]],a[1]="undefined"==typeof a[1]||a[1],!this._updateCounter){var b=a[0].concat(this.getDirtyNodes());this.onchange(b,a[1])}},i.prototype.cleanNodes=function(){this._updateCounter||b.each(this.nodes,function(a){a._dirty=!1})},i.prototype.getDirtyNodes=function(){return b.filter(this.nodes,function(a){return a._dirty})},i.prototype.addNode=function(a,c){if(a=this._prepareNode(a),"undefined"!=typeof a.maxWidth&&(a.width=Math.min(a.width,a.maxWidth)),"undefined"!=typeof a.maxHeight&&(a.height=Math.min(a.height,a.maxHeight)),"undefined"!=typeof a.minWidth&&(a.width=Math.max(a.width,a.minWidth)),"undefined"!=typeof a.minHeight&&(a.height=Math.max(a.height,a.minHeight)),a._id=++h,a._dirty=!0,a.autoPosition){this._sortNodes();for(var d=0;;++d){var e=d%this.width,f=Math.floor(d/this.width);if(!(e+a.width>this.width||b.find(this.nodes,b.bind(g._isAddNodeIntercepted,{x:e,y:f,node:a})))){a.x=e,a.y=f;break}}}return this.nodes.push(a),"undefined"!=typeof c&&c&&this._addedNodes.push(b.clone(a)),this._fixCollisions(a),this._packNodes(),this._notify(),a},i.prototype.removeNode=function(a,c){c="undefined"==typeof c||c,this._removedNodes.push(b.clone(a)),a._id=null,this.nodes=b.without(this.nodes,a),this._packNodes(),this._notify(a,c)},i.prototype.canMoveNode=function(c,d,e,f,g){if(!this.isNodeChangedPosition(c,d,e,f,g))return!1;var h=Boolean(b.find(this.nodes,function(a){return a.locked}));if(!this.height&&!h)return!0;var j,k=new i(this.width,null,this.float,0,b.map(this.nodes,function(b){return b==c?j=a.extend({},b):a.extend({},b)}));if("undefined"==typeof j)return!0;k.moveNode(j,d,e,f,g);var l=!0;return h&&(l&=!Boolean(b.find(k.nodes,function(a){return a!=j&&Boolean(a.locked)&&Boolean(a._dirty)}))),this.height&&(l&=k.getGridHeight()<=this.height),l},i.prototype.canBePlacedWithRespectToHeight=function(c){if(!this.height)return!0;var d=new i(this.width,null,this.float,0,b.map(this.nodes,function(b){return a.extend({},b)}));return d.addNode(c),d.getGridHeight()<=this.height},i.prototype.isNodeChangedPosition=function(a,b,c,d,e){return"number"!=typeof b&&(b=a.x),"number"!=typeof c&&(c=a.y),"number"!=typeof d&&(d=a.width),"number"!=typeof e&&(e=a.height),"undefined"!=typeof a.maxWidth&&(d=Math.min(d,a.maxWidth)),"undefined"!=typeof a.maxHeight&&(e=Math.min(e,a.maxHeight)),"undefined"!=typeof a.minWidth&&(d=Math.max(d,a.minWidth)),"undefined"!=typeof a.minHeight&&(e=Math.max(e,a.minHeight)),a.x!=b||a.y!=c||a.width!=d||a.height!=e},i.prototype.moveNode=function(a,b,c,d,e,f){if(!this.isNodeChangedPosition(a,b,c,d,e))return a;if("number"!=typeof b&&(b=a.x),"number"!=typeof c&&(c=a.y),"number"!=typeof d&&(d=a.width),"number"!=typeof e&&(e=a.height),"undefined"!=typeof a.maxWidth&&(d=Math.min(d,a.maxWidth)),"undefined"!=typeof a.maxHeight&&(e=Math.min(e,a.maxHeight)),"undefined"!=typeof a.minWidth&&(d=Math.max(d,a.minWidth)),"undefined"!=typeof a.minHeight&&(e=Math.max(e,a.minHeight)),a.x==b&&a.y==c&&a.width==d&&a.height==e)return a;var g=a.width!=d;return a._dirty=!0,a.x=b,a.y=c,a.width=d,a.height=e,a.lastTriedX=b,a.lastTriedY=c,a.lastTriedWidth=d,a.lastTriedHeight=e,a=this._prepareNode(a,g),this._fixCollisions(a),f||(this._packNodes(),this._notify()),a},i.prototype.getGridHeight=function(){return b.reduce(this.nodes,function(a,b){return Math.max(a,b.y+b.height)},0)},i.prototype.beginUpdate=function(a){b.each(this.nodes,function(a){a._origY=a.y}),a._updating=!0},i.prototype.endUpdate=function(){b.each(this.nodes,function(a){a._origY=a.y});var a=b.find(this.nodes,function(a){return a._updating});a&&(a._updating=!1)};var j=function(d,e){var g,h,j=this;e=e||{},this.container=a(d), +i.prototype.getNodeDataByDOMEl=function(a){return b.find(this.nodes,function(b){return a.get(0)===b.el.get(0)})},i.prototype._fixCollisions=function(a,c){this._sortNodes(-1);var d=a,e=Boolean(b.find(this.nodes,function(a){return a.locked}));for(this["float"]||e||(d={x:0,y:a.y,width:this.width,height:a.height});;){var f=b.find(this.nodes,b.bind(g._collisionNodeCheck,{node:a,nn:d}));if("undefined"==typeof f)return; +// will try to fix the collision +var h,i=(a.y+a.height,!c&&a.y+a.height+f.height>this.height);if(i){if( +// if the pos is out of bounds, put it on first available +h=this.findFreeSpace(f.width,f.height),h||(h=this.findFreeSpace()),!h)return}else h={x:f.x,y:a.y+a.height,w:f.width,h:f.height};h&&this.moveNode(f,h.x,h.y,h.w,h.h,!0,c)}},i.prototype.whatIsHere=function(a,c,d,e){var f={x:a||0,y:c||0,width:d||1,height:e||1},h=b.find(this.nodes,b.bind(function(a){return g.isIntercepted(a,f)},this));return h},i.prototype.isAreaEmpty=function(a,b,c,d){var e=this.whatIsHere(a,b,c,d);return null===e||"undefined"==typeof e},i.prototype.findFreeSpace=function(a,b){var c,d,e=null;for( +// first free for 1x1 or we have specified width and height +a||(a=1),b||(b=1),c=0;c<=this.width-a&&!e;c++)for(d=0;d<=this.height-b&&!e;d++)this.isAreaEmpty(c,d,a,b)&&(e={x:c,y:d,w:a,h:b});return e},i.prototype._sortNodes=function(a){this.nodes=g.sort(this.nodes,a,this.width)},i.prototype._packNodes=function(){this._sortNodes(),this["float"]?b.each(this.nodes,b.bind(function(a,c){if(!a._updating&&"undefined"!=typeof a._origY&&a.y!=a._origY)for(var d=a.y;d>=a._origY;){var e=b.chain(this.nodes).find(b.bind(g._didCollide,{n:a,newY:d})).value();e||(a._dirty=!0,a.y=d),--d}},this)):b.each(this.nodes,b.bind(function(a,c){if(!a.locked)for(;a.y>0;){var d=a.y-1,e=0===c;if(c>0){var f=b.chain(this.nodes).take(c).find(b.bind(g._didCollide,{n:a,newY:d})).value();e="undefined"==typeof f}if(!e)break;a._dirty=a.y!=d,a.y=d}},this))},i.prototype._prepareNode=function(a,c){return a=b.defaults(a||{},{width:1,height:1,x:0,y:0}),a.x=parseInt(""+a.x),a.y=parseInt(""+a.y),a.width=parseInt(""+a.width),a.height=parseInt(""+a.height),a.autoPosition=a.autoPosition||!1,a.noResize=a.noResize||!1,a.noMove=a.noMove||!1,a.width>this.width?a.width=this.width:a.width<1&&(a.width=1),this.height&&a.height>this.height?a.height=this.height:a.height<1&&(a.height=1),a.x<0&&(a.x=0),a.x+a.width>this.width&&(c?a.width=this.width-a.x:a.x=this.width-a.width),a.y<0&&(a.y=0),a},i.prototype._notify=function(){var a=Array.prototype.slice.call(arguments,0);if(a[0]="undefined"==typeof a[0]?[]:[a[0]],a[1]="undefined"==typeof a[1]||a[1],!this._updateCounter){var b=a[0].concat(this.getDirtyNodes());this.onchange(b,a[1])}},i.prototype.cleanNodes=function(){this._updateCounter||b.each(this.nodes,function(a){a._dirty=!1})},i.prototype.getDirtyNodes=function(){return b.filter(this.nodes,function(a){return a._dirty})},i.prototype.addNode=function(a,c,d){if(a=this._prepareNode(a),"undefined"!=typeof a.maxWidth&&(a.width=Math.min(a.width,a.maxWidth)),"undefined"!=typeof a.maxHeight&&(a.height=Math.min(a.height,a.maxHeight)),"undefined"!=typeof a.minWidth&&(a.width=Math.max(a.width,a.minWidth)),"undefined"!=typeof a.minHeight&&(a.height=Math.max(a.height,a.minHeight)),a._id=++h,a._dirty=!0,a.autoPosition){this._sortNodes();for(var e=0;;++e){var f=e%this.width,i=Math.floor(e/this.width);if(!(f+a.width>this.width||b.find(this.nodes,b.bind(g._isAddNodeIntercepted,{x:f,y:i,node:a})))){a.x=f,a.y=i;break}}}return this.nodes.push(a),"undefined"!=typeof c&&c&&this._addedNodes.push(b.clone(a)),this._fixCollisions(a,d),this._packNodes(),this._notify(),a},i.prototype.removeNode=function(a,c){a&&(a._id=null,this.nodes=b.without(this.nodes,a),this._packNodes(),this._notify(a,c))},i.prototype.canMoveNode=function(c,d,e,f,g){if(!this.isNodeChangedPosition(c,d,e,f,g))return!1;var h=Boolean(b.find(this.nodes,function(a){return a.locked}));if(!this.height&&!h)return!0;var j,k=new i(this.width,null,this["float"],0,b.map(this.nodes,function(b){return b==c?j=a.extend({},b):a.extend({},b)}));if("undefined"==typeof j)return!0;k.moveNode(j,d,e,f,g,!1,!0);var l=!0; +// always allow moving the one out of bounds +return h&&(l&=!Boolean(b.find(k.nodes,function(a){return a!=j&&Boolean(a.locked)&&Boolean(a._dirty)}))),this.height&&(l&=k.getGridHeight()<=this.height,c.y+c.height>this.height&&(l=!0)),l},i.prototype.canBePlacedWithRespectToHeight=function(c){if(!this.height)return!0;var d=new i(this.width,null,this["float"],0,b.map(this.nodes,function(b){return a.extend({},b)}));return d.addNode(c,!1,!0),d.getGridHeight()<=this.height},i.prototype.isNodeChangedPosition=function(a,b,c,d,e){return"number"!=typeof b&&(b=a.x),"number"!=typeof c&&(c=a.y),"number"!=typeof d&&(d=a.width),"number"!=typeof e&&(e=a.height),"undefined"!=typeof a.maxWidth&&(d=Math.min(d,a.maxWidth)),"undefined"!=typeof a.maxHeight&&(e=Math.min(e,a.maxHeight)),"undefined"!=typeof a.minWidth&&(d=Math.max(d,a.minWidth)),"undefined"!=typeof a.minHeight&&(e=Math.max(e,a.minHeight)),a.x!=b||a.y!=c||a.width!=d||a.height!=e},i.prototype.moveNode=function(a,b,c,d,e,f,g){if(!this.isNodeChangedPosition(a,b,c,d,e))return a;if("number"!=typeof b&&(b=a.x),"number"!=typeof c&&(c=a.y),"number"!=typeof d&&(d=a.width),"number"!=typeof e&&(e=a.height),"undefined"!=typeof a.maxWidth&&(d=Math.min(d,a.maxWidth)),"undefined"!=typeof a.maxHeight&&(e=Math.min(e,a.maxHeight)),"undefined"!=typeof a.minWidth&&(d=Math.max(d,a.minWidth)),"undefined"!=typeof a.minHeight&&(e=Math.max(e,a.minHeight)),a.x==b&&a.y==c&&a.width==d&&a.height==e)return a;var h=a.width!=d;return a._dirty=!0,a.x=b,a.y=c,a.width=d,a.height=e,a.lastTriedX=b,a.lastTriedY=c,a.lastTriedWidth=d,a.lastTriedHeight=e,a=this._prepareNode(a,h),this._fixCollisions(a,g),f||(this._packNodes(),this._notify()),a},i.prototype.getGridHeight=function(){return b.reduce(this.nodes,function(a,b){return Math.max(a,b.y+b.height)},0)},i.prototype.beginUpdate=function(a){b.each(this.nodes,function(a){a._origY=a.y}),a._updating=!0},i.prototype.endUpdate=function(){b.each(this.nodes,function(a){a._origY=a.y});var a=b.find(this.nodes,function(a){return a._updating});a&&(a._updating=!1)};var j=function(d,e){var g,h,j=this;e=e||{},this.container=a(d), // jscs:disable requireCamelCaseOrUpperCaseIdentifiers "undefined"!=typeof e.handle_class&&(e.handleClass=e.handle_class,f("handle_class","handleClass")),"undefined"!=typeof e.item_class&&(e.itemClass=e.item_class,f("item_class","itemClass")),"undefined"!=typeof e.placeholder_class&&(e.placeholderClass=e.placeholder_class,f("placeholder_class","placeholderClass")),"undefined"!=typeof e.placeholder_text&&(e.placeholderText=e.placeholder_text,f("placeholder_text","placeholderText")),"undefined"!=typeof e.cell_height&&(e.cellHeight=e.cell_height,f("cell_height","cellHeight")),"undefined"!=typeof e.vertical_margin&&(e.verticalMargin=e.vertical_margin,f("vertical_margin","verticalMargin")),"undefined"!=typeof e.min_width&&(e.minWidth=e.min_width,f("min_width","minWidth")),"undefined"!=typeof e.static_grid&&(e.staticGrid=e.static_grid,f("static_grid","staticGrid")),"undefined"!=typeof e.is_nested&&(e.isNested=e.is_nested,f("is_nested","isNested")),"undefined"!=typeof e.always_show_resize_handle&&(e.alwaysShowResizeHandle=e.always_show_resize_handle,f("always_show_resize_handle","alwaysShowResizeHandle")), // jscs:enable requireCamelCaseOrUpperCaseIdentifiers -e.itemClass=e.itemClass||"grid-stack-item";var k=this.container.closest("."+e.itemClass).length>0;if(this.opts=b.defaults(e||{},{width:parseInt(this.container.attr("data-gs-width"))||12,height:parseInt(this.container.attr("data-gs-height"))||0,itemClass:"grid-stack-item",placeholderClass:"grid-stack-placeholder",placeholderText:"",handle:".grid-stack-item-content",handleClass:null,cellHeight:60,verticalMargin:20,auto:!0,minWidth:768,float:!1,staticGrid:!1,_class:"grid-stack-instance-"+(1e4*Math.random()).toFixed(0),animate:Boolean(this.container.attr("data-gs-animate"))||!1,alwaysShowResizeHandle:e.alwaysShowResizeHandle||!1,resizable:b.defaults(e.resizable||{},{autoHide:!e.alwaysShowResizeHandle,handles:"se"}),draggable:b.defaults(e.draggable||{},{handle:(e.handleClass?"."+e.handleClass:e.handle?e.handle:"")||".grid-stack-item-content",scroll:!1,appendTo:"body"}),disableDrag:e.disableDrag||!1,disableResize:e.disableResize||!1,rtl:"auto",removable:!1,removeTimeout:2e3,verticalMarginUnit:"px",cellHeightUnit:"px",oneColumnModeClass:e.oneColumnModeClass||"grid-stack-one-column-mode",ddPlugin:null}),this.opts.ddPlugin===!1?this.opts.ddPlugin=c:null===this.opts.ddPlugin&&(this.opts.ddPlugin=b.first(c.registeredPlugins)||c),this.dd=new this.opts.ddPlugin(this),"auto"===this.opts.rtl&&(this.opts.rtl="rtl"===this.container.css("direction")),this.opts.rtl&&this.container.addClass("grid-stack-rtl"),this.opts.isNested=k,h="auto"===this.opts.cellHeight,h?j.cellHeight(j.cellWidth(),!0):this.cellHeight(this.opts.cellHeight,!0),this.verticalMargin(this.opts.verticalMargin,!0),this.container.addClass(this.opts._class),this._setStaticClass(),k&&this.container.addClass("grid-stack-nested"),this._initStyles(),this.grid=new i(this.opts.width,function(a,c){c="undefined"==typeof c||c;var d=0;b.each(a,function(a){c&&null===a._id?a.el&&a.el.remove():(a.el.attr("data-gs-x",a.x).attr("data-gs-y",a.y).attr("data-gs-width",a.width).attr("data-gs-height",a.height),d=Math.max(d,a.y+a.height))}),j._updateStyles(d+10)},this.opts.float,this.opts.height),this.opts.auto){var l=[],m=this;this.container.children("."+this.opts.itemClass+":not(."+this.opts.placeholderClass+")").each(function(b,c){c=a(c),l.push({el:c,i:parseInt(c.attr("data-gs-x"))+parseInt(c.attr("data-gs-y"))*m.opts.width})}),b.chain(l).sortBy(function(a){return a.i}).each(function(a){j._prepareElement(a.el)}).value()}if(this.setAnimation(this.opts.animate),this.placeholder=a('
'+this.opts.placeholderText+"
").hide(),this._updateContainerHeight(),this._updateHeightsOnResize=b.throttle(function(){j.cellHeight(j.cellWidth(),!1)},100),this.onResizeHandler=function(){if(h&&j._updateHeightsOnResize(),j._isOneColumnMode()){if(g)return;j.container.addClass(j.opts.oneColumnModeClass),g=!0,j.grid._sortNodes(),b.each(j.grid.nodes,function(a){j.container.append(a.el),j.opts.staticGrid||((a.noMove||j.opts.disableDrag)&&j.dd.draggable(a.el,"disable"),(a.noResize||j.opts.disableResize)&&j.dd.resizable(a.el,"disable"),a.el.trigger("resize"))})}else{if(!g)return;if(j.container.removeClass(j.opts.oneColumnModeClass),g=!1,j.opts.staticGrid)return;b.each(j.grid.nodes,function(a){a.noMove||j.opts.disableDrag||j.dd.draggable(a.el,"enable"),a.noResize||j.opts.disableResize||j.dd.resizable(a.el,"enable"),a.el.trigger("resize")})}},a(window).resize(this.onResizeHandler),this.onResizeHandler(),!j.opts.staticGrid&&"string"==typeof j.opts.removable){var n=a(j.opts.removable);this.dd.isDroppable(n)||this.dd.droppable(n,{accept:"."+j.opts.itemClass}),this.dd.on(n,"dropover",function(b,c){var d=a(c.draggable),e=d.data("_gridstack_node");e._grid===j&&j._setupRemovingTimeout(d)}).on(n,"dropout",function(b,c){var d=a(c.draggable),e=d.data("_gridstack_node");e._grid===j&&j._clearRemovingTimeout(d)})}if(!j.opts.staticGrid&&j.opts.acceptWidgets){var o=null,p=function(a,b){var c=o,d=c.data("_gridstack_node"),e=j.getCellFromPixel(b.offset,!0),f=Math.max(0,e.x),g=Math.max(0,e.y);if(d._added){if(!j.grid.canMoveNode(d,f,g))return;j.grid.moveNode(d,f,g),j._updateContainerHeight()}else d._added=!0,d.el=c,d.x=f,d.y=g,j.grid.cleanNodes(),j.grid.beginUpdate(d),j.grid.addNode(d),j.container.append(j.placeholder),j.placeholder.attr("data-gs-x",d.x).attr("data-gs-y",d.y).attr("data-gs-width",d.width).attr("data-gs-height",d.height).show(),d.el=j.placeholder,d._beforeDragX=d.x,d._beforeDragY=d.y,j._updateContainerHeight()};this.dd.droppable(j.container,{accept:function(b){b=a(b);var c=b.data("_gridstack_node");return(!c||c._grid!==j)&&b.is(j.opts.acceptWidgets===!0?".grid-stack-item":j.opts.acceptWidgets)}}).on(j.container,"dropover",function(b,c){var d=(j.container.offset(),a(c.draggable)),e=j.cellWidth(),f=j.cellHeight(),g=d.data("_gridstack_node"),h=g?g.width:Math.ceil(d.outerWidth()/e),i=g?g.height:Math.ceil(d.outerHeight()/f);o=d;var k=j.grid._prepareNode({width:h,height:i,_added:!1,_temporary:!0});d.data("_gridstack_node",k),d.data("_gridstack_node_orig",g),d.on("drag",p)}).on(j.container,"dropout",function(b,c){var d=a(c.draggable);d.unbind("drag",p);var e=d.data("_gridstack_node");e.el=null,j.grid.removeNode(e),j.placeholder.detach(),j._updateContainerHeight(),d.data("_gridstack_node",d.data("_gridstack_node_orig"))}).on(j.container,"drop",function(b,c){j.placeholder.detach();var d=a(c.draggable).data("_gridstack_node");d._grid=j;var e=a(c.draggable).clone(!1);e.data("_gridstack_node",d),a(c.draggable).remove(),d.el=e,j.placeholder.hide(),e.attr("data-gs-x",d.x).attr("data-gs-y",d.y).attr("data-gs-width",d.width).attr("data-gs-height",d.height).addClass(j.opts.itemClass).removeAttr("style").enableSelection().removeData("draggable").removeClass("ui-draggable ui-draggable-dragging ui-draggable-disabled").unbind("drag",p),j.container.append(e),j._prepareElementsByNode(e,d),j._updateContainerHeight(),j._triggerChangeEvent(),j.grid.endUpdate()})}}; +e.itemClass=e.itemClass||"grid-stack-item";var k=this.container.closest("."+e.itemClass).length>0;if(this.opts=b.defaults(e||{},{width:parseInt(this.container.attr("data-gs-width"))||12,height:parseInt(this.container.attr("data-gs-height"))||0,itemClass:"grid-stack-item",placeholderClass:"grid-stack-placeholder",placeholderText:"",handle:".grid-stack-item-content",handleClass:null,cellHeight:60,verticalMargin:20,auto:!0,minWidth:768,"float":!1,staticGrid:!1,_class:"grid-stack-instance-"+(1e4*Math.random()).toFixed(0),animate:Boolean(this.container.attr("data-gs-animate"))||!1,alwaysShowResizeHandle:e.alwaysShowResizeHandle||!1,resizable:b.defaults(e.resizable||{},{autoHide:!e.alwaysShowResizeHandle,handles:"se"}),draggable:b.defaults(e.draggable||{},{handle:(e.handleClass?"."+e.handleClass:e.handle?e.handle:"")||".grid-stack-item-content",scroll:!1,appendTo:"body"}),disableDrag:e.disableDrag||!1,disableResize:e.disableResize||!1,rtl:"auto",removable:!1,removeTimeout:2e3,verticalMarginUnit:"px",cellHeightUnit:"px",oneColumnModeClass:e.oneColumnModeClass||"grid-stack-one-column-mode",ddPlugin:null}),this.opts.ddPlugin===!1?this.opts.ddPlugin=c:null===this.opts.ddPlugin&&(this.opts.ddPlugin=b.first(c.registeredPlugins)||c),this.dd=new this.opts.ddPlugin(this),"auto"===this.opts.rtl&&(this.opts.rtl="rtl"===this.container.css("direction")),this.opts.rtl&&this.container.addClass("grid-stack-rtl"),this.opts.isNested=k,h="auto"===this.opts.cellHeight,h?j.cellHeight(j.cellWidth(),!0):this.cellHeight(this.opts.cellHeight,!0),this.verticalMargin(this.opts.verticalMargin,!0),this.container.addClass(this.opts._class),this._setStaticClass(),k&&this.container.addClass("grid-stack-nested"),this._initStyles(),this.grid=new i(this.opts.width,function(a,c){c="undefined"==typeof c||c;var d=0;b.each(a,function(a){c&&null===a._id?a.el&&a.el.remove():(a.el.attr("data-gs-x",a.x).attr("data-gs-y",a.y).attr("data-gs-width",a.width).attr("data-gs-height",a.height),d=Math.max(d,a.y+a.height))}),j._updateStyles(j.opts.height||max_height+10)},this.opts["float"],this.opts.height),this.opts.auto){var l=[],m=this;this.container.children("."+this.opts.itemClass+":not(."+this.opts.placeholderClass+")").each(function(b,c){c=a(c),l.push({el:c,i:parseInt(c.attr("data-gs-x"))+parseInt(c.attr("data-gs-y"))*m.opts.width})}),b.chain(l).sortBy(function(a){return a.i}).each(function(a){j._prepareElement(a.el)}).value()}if(this.setAnimation(this.opts.animate),this.placeholder=a('
'+this.opts.placeholderText+"
").hide(),this._updateContainerHeight(), +// setting styles also for empty grids +this._updateStyles(),this._updateHeightsOnResize=b.throttle(function(){j.cellHeight(j.cellWidth(),!1)},100),this.onResizeHandler=function(){if(h&&j._updateHeightsOnResize(),j._isOneColumnMode()){if(g)return;j.container.addClass(j.opts.oneColumnModeClass),g=!0,j.grid._sortNodes(),b.each(j.grid.nodes,function(a){j.container.append(a.el),j.opts.staticGrid||((a.noMove||j.opts.disableDrag)&&j.dd.draggable(a.el,"disable"),(a.noResize||j.opts.disableResize)&&j.dd.resizable(a.el,"disable"),a.el.trigger("resize"))})}else{if(!g)return;if(j.container.removeClass(j.opts.oneColumnModeClass),g=!1,j.opts.staticGrid)return;b.each(j.grid.nodes,function(a){a.noMove||j.opts.disableDrag||j.dd.draggable(a.el,"enable"),a.noResize||j.opts.disableResize||j.dd.resizable(a.el,"enable"),a.el.trigger("resize")})}},a(window).resize(this.onResizeHandler),this.onResizeHandler(),!j.opts.staticGrid&&"string"==typeof j.opts.removable){var n=a(j.opts.removable);this.dd.isDroppable(n)||this.dd.droppable(n,{accept:"."+j.opts.itemClass}),this.dd.on(n,"dropover",function(b,c){var d=a(c.draggable),e=d.data("_gridstack_node");e._grid===j&&j._setupRemovingTimeout(d)}).on(n,"dropout",function(b,c){var d=a(c.draggable),e=d.data("_gridstack_node");e._grid===j&&j._clearRemovingTimeout(d)})}if(!j.opts.staticGrid&&j.opts.acceptWidgets){var o=null,p=function(a,b){var c=o,d=c.data("_gridstack_node"),e=j.getCellFromPixel(b.offset,!0),f=Math.max(0,e.x),g=Math.max(0,e.y);if(d._added){if(!j.grid.canMoveNode(d,f,g))return;j.grid.moveNode(d,f,g),j._updateContainerHeight()}else d._added=!0,d.el=c,d.x=f,d.y=g,j.grid.cleanNodes(),j.grid.beginUpdate(d),j.grid.addNode(d),j.container.append(j.placeholder),j.placeholder.attr("data-gs-x",d.x).attr("data-gs-y",d.y).attr("data-gs-width",d.width).attr("data-gs-height",d.height).show(),d.el=j.placeholder,d._beforeDragX=d.x,d._beforeDragY=d.y,j._updateContainerHeight()};this.dd.droppable(j.container,{accept:function(b){b=a(b);var c=b.data("_gridstack_node");return(!c||c._grid!==j)&&b.is(j.opts.acceptWidgets===!0?".grid-stack-item":j.opts.acceptWidgets)}}).on(j.container,"dropover",function(b,c){var d=(j.container.offset(),a(c.draggable)),e=j.cellWidth(),f=j.cellHeight(),g=d.data("_gridstack_node"),h=g?g.width:Math.ceil(d.outerWidth()/e),i=g?g.height:Math.ceil(d.outerHeight()/f);o=d;var k=j.grid._prepareNode({width:h,height:i,_added:!1,_temporary:!0});d.data("_gridstack_node",k),d.data("_gridstack_node_orig",g),d.on("drag",p)}).on(j.container,"dropout",function(b,c){var d=a(c.draggable);d.unbind("drag",p);var e=d.data("_gridstack_node");e.el=null,j.grid.removeNode(e),j.placeholder.detach(),j._updateContainerHeight(),d.data("_gridstack_node",d.data("_gridstack_node_orig"))}).on(j.container,"drop",function(b,c){j.placeholder.detach();var d=a(c.draggable).data("_gridstack_node");d._grid=j;var e=a(c.draggable).clone(!1);e.data("_gridstack_node",d),a(c.draggable).remove(),d.el=e,j.placeholder.hide(),e.attr("data-gs-x",d.x).attr("data-gs-y",d.y).attr("data-gs-width",d.width).attr("data-gs-height",d.height).addClass(j.opts.itemClass).removeAttr("style").enableSelection().removeData("draggable").removeClass("ui-draggable ui-draggable-dragging ui-draggable-disabled").unbind("drag",p),j.container.append(e),j._prepareElementsByNode(e,d),j._updateContainerHeight(),j._triggerChangeEvent(),j.grid.endUpdate()})}}; // jscs:disable requireCamelCaseOrUpperCaseIdentifiers // jscs:enable requireCamelCaseOrUpperCaseIdentifiers -return j.prototype._triggerChangeEvent=function(a){var b=this.grid.getDirtyNodes(),c=!1,d=[];b&&b.length&&(d.push(b),c=!0),(c||a===!0)&&this.container.trigger("change",d)},j.prototype._triggerAddEvent=function(){this.grid._addedNodes&&this.grid._addedNodes.length>0&&(this.container.trigger("added",[b.map(this.grid._addedNodes,b.clone)]),this.grid._addedNodes=[])},j.prototype._triggerRemoveEvent=function(){this.grid._removedNodes&&this.grid._removedNodes.length>0&&(this.container.trigger("removed",[b.map(this.grid._removedNodes,b.clone)]),this.grid._removedNodes=[])},j.prototype._initStyles=function(){this._stylesId&&g.removeStylesheet(this._stylesId),this._stylesId="gridstack-style-"+(1e5*Math.random()).toFixed(),this._styles=g.createStylesheet(this._stylesId),null!==this._styles&&(this._styles._max=0)},j.prototype._updateStyles=function(a){if(null!==this._styles&&"undefined"!=typeof this._styles){var b,c="."+this.opts._class+" ."+this.opts.itemClass,d=this;if("undefined"==typeof a&&(a=this._styles._max,this._initStyles(),this._updateContainerHeight()),this.opts.cellHeight&&!(0!==this._styles._max&&a<=this._styles._max)&&(b=this.opts.verticalMargin&&this.opts.cellHeightUnit!==this.opts.verticalMarginUnit?function(a,b){return a&&b?"calc("+(d.opts.cellHeight*a+d.opts.cellHeightUnit)+" + "+(d.opts.verticalMargin*b+d.opts.verticalMarginUnit)+")":d.opts.cellHeight*a+d.opts.verticalMargin*b+d.opts.cellHeightUnit}:function(a,b){return d.opts.cellHeight*a+d.opts.verticalMargin*b+d.opts.cellHeightUnit},0===this._styles._max&&g.insertCSSRule(this._styles,c,"min-height: "+b(1,0)+";",0),a>this._styles._max)){for(var e=this._styles._max;e=f.grid.width||k<0?(f.opts.removable===!0&&f._setupRemovingTimeout(b),j=c._beforeDragX,k=c._beforeDragY,f.placeholder.detach(),f.placeholder.hide(),f.grid.removeNode(c),f._updateContainerHeight(),c._temporaryRemoved=!0):(f._clearRemovingTimeout(b),c._temporaryRemoved&&(f.grid.addNode(c),f.placeholder.attr("data-gs-x",j).attr("data-gs-y",k).attr("data-gs-width",h).attr("data-gs-height",i).show(),f.container.append(f.placeholder),c.el=f.placeholder,c._temporaryRemoved=!1));else if("resize"==a.type&&j<0)return; +return j.prototype._triggerChangeEvent=function(a){var b=this.grid.getDirtyNodes(),c=!1,d=[];b&&b.length&&(d.push(b),c=!0),(c||a===!0)&&this.container.trigger("change",d)},j.prototype._triggerAddEvent=function(){this.grid._addedNodes&&this.grid._addedNodes.length>0&&(this.container.trigger("added",[b.map(this.grid._addedNodes,b.clone)]),this.grid._addedNodes=[])},j.prototype._triggerRemoveEvent=function(){this.grid._removedNodes&&this.grid._removedNodes.length>0&&(this.container.trigger("removed",[b.map(this.grid._removedNodes,b.clone)]),this.grid._removedNodes=[])},j.prototype._initStyles=function(){this._stylesId&&g.removeStylesheet(this._stylesId),this._stylesId="gridstack-style-"+(1e5*Math.random()).toFixed(),this._styles=g.createStylesheet(this._stylesId),null!==this._styles&&(this._styles._max=0)},j.prototype._updateStyles=function(a){if(null!==this._styles&&"undefined"!=typeof this._styles){var b,c="."+this.opts._class+" ."+this.opts.itemClass,d=this;if("undefined"==typeof a&&(a=this._styles._max||this.opts.height,this._initStyles(),this._updateContainerHeight()),this.opts.cellHeight&&!(0!==this._styles._max&&a<=this._styles._max)&&(b=this.opts.verticalMargin&&this.opts.cellHeightUnit!==this.opts.verticalMarginUnit?function(a,b){return a&&b?"calc("+(d.opts.cellHeight*a+d.opts.cellHeightUnit)+" + "+(d.opts.verticalMargin*b+d.opts.verticalMarginUnit)+")":d.opts.cellHeight*a+d.opts.verticalMargin*b+d.opts.cellHeightUnit}:function(a,b){return d.opts.cellHeight*a+d.opts.verticalMargin*b+d.opts.cellHeightUnit},0===this._styles._max&&g.insertCSSRule(this._styles,c,"min-height: "+b(1,0)+";",0),a>this._styles._max)){for(var e=this._styles._max;e=f.grid.width||k<0||f.grid.height&&k>=f.grid.height?(f.opts.removable===!0&&f._setupRemovingTimeout(b),j=c._beforeDragX,k=c._beforeDragY,f.placeholder.detach(),f.placeholder.hide(),f.grid.removeNode(c),f._updateContainerHeight(),c._temporaryRemoved=!0):(f._clearRemovingTimeout(b),c._temporaryRemoved&&(f.grid.addNode(c),f.placeholder.attr("data-gs-x",j).attr("data-gs-y",k).attr("data-gs-width",h).attr("data-gs-height",i).show(),f.container.append(f.placeholder),c.el=f.placeholder,c._temporaryRemoved=!1));else if("resize"==a.type&&j<0)return; // width and height are undefined if not resizing -var l="undefined"!=typeof h?h:c.lastTriedWidth,m="undefined"!=typeof i?i:c.lastTriedHeight;!f.grid.canMoveNode(c,j,k,h,i)||c.lastTriedX===j&&c.lastTriedY===k&&c.lastTriedWidth===l&&c.lastTriedHeight===m||(c.lastTriedX=j,c.lastTriedY=k,c.lastTriedWidth=h,c.lastTriedHeight=i,f.grid.moveNode(c,j,k,h,i),f._updateContainerHeight())},h=function(g,h){f.container.append(f.placeholder);var i=a(this);f.grid.cleanNodes(),f.grid.beginUpdate(c),d=f.cellWidth();var j=Math.ceil(i.outerHeight()/i.attr("data-gs-height"));e=f.container.height()/parseInt(f.container.attr("data-gs-current-height")),f.placeholder.attr("data-gs-x",i.attr("data-gs-x")).attr("data-gs-y",i.attr("data-gs-y")).attr("data-gs-width",i.attr("data-gs-width")).attr("data-gs-height",i.attr("data-gs-height")).show(),c.el=f.placeholder,c._beforeDragX=c.x,c._beforeDragY=c.y,f.dd.resizable(b,"option","minWidth",d*(c.minWidth||1)),f.dd.resizable(b,"option","minHeight",j*(c.minHeight||1)),"resizestart"==g.type&&i.find(".grid-stack-item").trigger("resizestart")},i=function(d,e){var g=a(this);if(g.data("_gridstack_node")){var h=!1;f.placeholder.detach(),c.el=g,f.placeholder.hide(),c._isAboutToRemove?(h=!0,b.removeData("_gridstack_node"),b.remove()):(f._clearRemovingTimeout(b),c._temporaryRemoved?(g.attr("data-gs-x",c._beforeDragX).attr("data-gs-y",c._beforeDragY).attr("data-gs-width",c.width).attr("data-gs-height",c.height).removeAttr("style"),c.x=c._beforeDragX,c.y=c._beforeDragY,f.grid.addNode(c)):g.attr("data-gs-x",c.x).attr("data-gs-y",c.y).attr("data-gs-width",c.width).attr("data-gs-height",c.height).removeAttr("style")),f._updateContainerHeight(),f._triggerChangeEvent(h),f.grid.endUpdate();var i=g.find(".grid-stack");i.length&&"resizestop"==d.type&&(i.each(function(b,c){a(c).data("gridstack").onResizeHandler()}),g.find(".grid-stack-item").trigger("resizestop"))}};this.dd.draggable(b,{start:h,stop:i,drag:g}).resizable(b,{start:h,stop:i,resize:g}),(c.noMove||this._isOneColumnMode()||this.opts.disableDrag)&&this.dd.draggable(b,"disable"),(c.noResize||this._isOneColumnMode()||this.opts.disableResize)&&this.dd.resizable(b,"disable"),b.attr("data-gs-locked",c.locked?"yes":null)}},j.prototype._prepareElement=function(b,c){c="undefined"!=typeof c&&c;var d=this;b=a(b),b.addClass(this.opts.itemClass);var e=d.grid.addNode({x:b.attr("data-gs-x"),y:b.attr("data-gs-y"),width:b.attr("data-gs-width"),height:b.attr("data-gs-height"),maxWidth:b.attr("data-gs-max-width"),minWidth:b.attr("data-gs-min-width"),maxHeight:b.attr("data-gs-max-height"),minHeight:b.attr("data-gs-min-height"),autoPosition:g.toBool(b.attr("data-gs-auto-position")),noResize:g.toBool(b.attr("data-gs-no-resize")),noMove:g.toBool(b.attr("data-gs-no-move")),locked:g.toBool(b.attr("data-gs-locked")),el:b,id:b.attr("data-gs-id"),_grid:d},c);b.data("_gridstack_node",e),this._prepareElementsByNode(b,e)},j.prototype.setAnimation=function(a){a?this.container.addClass("grid-stack-animate"):this.container.removeClass("grid-stack-animate")},j.prototype.addWidget=function(b,c,d,e,f,g,h,i,j,k,l){return b=a(b),"undefined"!=typeof c&&b.attr("data-gs-x",c),"undefined"!=typeof d&&b.attr("data-gs-y",d),"undefined"!=typeof e&&b.attr("data-gs-width",e),"undefined"!=typeof f&&b.attr("data-gs-height",f),"undefined"!=typeof g&&b.attr("data-gs-auto-position",g?"yes":null),"undefined"!=typeof h&&b.attr("data-gs-min-width",h),"undefined"!=typeof i&&b.attr("data-gs-max-width",i),"undefined"!=typeof j&&b.attr("data-gs-min-height",j),"undefined"!=typeof k&&b.attr("data-gs-max-height",k),"undefined"!=typeof l&&b.attr("data-gs-id",l),this.container.append(b),this._prepareElement(b,!0),this._triggerAddEvent(),this._updateContainerHeight(),this._triggerChangeEvent(!0),b},j.prototype.makeWidget=function(b){return b=a(b),this._prepareElement(b,!0),this._triggerAddEvent(),this._updateContainerHeight(),this._triggerChangeEvent(!0),b},j.prototype.willItFit=function(a,b,c,d,e){var f={x:a,y:b,width:c,height:d,autoPosition:e};return this.grid.canBePlacedWithRespectToHeight(f)},j.prototype.removeWidget=function(b,c){c="undefined"==typeof c||c,b=a(b);var d=b.data("_gridstack_node"); +var l="undefined"!=typeof h?h:c.lastTriedWidth,m="undefined"!=typeof i?i:c.lastTriedHeight;!f.grid.canMoveNode(c,j,k,h,i)||c.lastTriedX===j&&c.lastTriedY===k&&c.lastTriedWidth===l&&c.lastTriedHeight===m||(c.lastTriedX=j,c.lastTriedY=k,c.lastTriedWidth=h,c.lastTriedHeight=i,f.grid.moveNode(c,j,k,h,i),f._updateContainerHeight())},h=function(g,h){if(f.opts.draggable.handle&&"dragstart"===g.type&&!a(g.originalEvent.target).closest(f.opts.draggable.handle).length)return!1;f.container.append(f.placeholder);var i=a(this);f.grid.cleanNodes(),f.grid.beginUpdate(c),d=f.cellWidth();var j=Math.ceil(i.outerHeight()/i.attr("data-gs-height"));e=f.container.height()/parseInt(f.container.attr("data-gs-current-height")),f.placeholder.attr("data-gs-x",i.attr("data-gs-x")).attr("data-gs-y",i.attr("data-gs-y")).attr("data-gs-width",i.attr("data-gs-width")).attr("data-gs-height",i.attr("data-gs-height")).show(),c.el=f.placeholder,c._beforeDragX=c.x,c._beforeDragY=c.y,f.dd.resizable(b,"option","minWidth",d*(c.minWidth||1)),f.dd.resizable(b,"option","minHeight",j*(c.minHeight||1)),"resizestart"==g.type&&i.find(".grid-stack-item").trigger("resizestart")},i=function(d,e){var g=a(this);if(g.data("_gridstack_node")){var h=!1;f.placeholder.detach(),c.el=g,f.placeholder.hide(),c._isAboutToRemove?(h=!0,b.removeData("_gridstack_node"),b.remove()):(f._clearRemovingTimeout(b),c._temporaryRemoved?(g.attr("data-gs-x",c._beforeDragX).attr("data-gs-y",c._beforeDragY).attr("data-gs-width",c.width).attr("data-gs-height",c.height).removeAttr("style"),c.x=c._beforeDragX,c.y=c._beforeDragY,f.grid.addNode(c)):g.attr("data-gs-x",c.x).attr("data-gs-y",c.y).attr("data-gs-width",c.width).attr("data-gs-height",c.height).removeAttr("style")),f._updateContainerHeight(),f._triggerChangeEvent(h),f.grid.endUpdate();var i=g.find(".grid-stack");i.length&&"resizestop"==d.type&&(i.each(function(b,c){a(c).data("gridstack").onResizeHandler()}),g.find(".grid-stack-item").trigger("resizestop"))}};this.dd.draggable(b,{start:h,stop:i,drag:g}).resizable(b,{start:h,stop:i,resize:g}),(c.noMove||this._isOneColumnMode()||this.opts.disableDrag)&&this.dd.draggable(b,"disable"),(c.noResize||this._isOneColumnMode()||this.opts.disableResize)&&this.dd.resizable(b,"disable"),b.attr("data-gs-locked",c.locked?"yes":null)}},j.prototype._prepareElement=function(b,c){c="undefined"!=typeof c&&c;var d=this;b=a(b),b.addClass(this.opts.itemClass);var e=d.grid.addNode({x:b.attr("data-gs-x"),y:b.attr("data-gs-y"),width:b.attr("data-gs-width"),height:b.attr("data-gs-height"),maxWidth:b.attr("data-gs-max-width"),minWidth:b.attr("data-gs-min-width"),maxHeight:b.attr("data-gs-max-height"),minHeight:b.attr("data-gs-min-height"),autoPosition:g.toBool(b.attr("data-gs-auto-position")),noResize:g.toBool(b.attr("data-gs-no-resize")),noMove:g.toBool(b.attr("data-gs-no-move")),locked:g.toBool(b.attr("data-gs-locked")),el:b,id:b.attr("data-gs-id"),_grid:d},c);b.data("_gridstack_node",e),this._prepareElementsByNode(b,e)},j.prototype.setAnimation=function(a){a?this.container.addClass("grid-stack-animate"):this.container.removeClass("grid-stack-animate")},j.prototype.addWidget=function(b,c,d,e,f,g,h,i,j,k,l){return b=a(b),"undefined"!=typeof c&&b.attr("data-gs-x",c),"undefined"!=typeof d&&b.attr("data-gs-y",d),"undefined"!=typeof e&&b.attr("data-gs-width",e),"undefined"!=typeof f&&b.attr("data-gs-height",f),"undefined"!=typeof g&&b.attr("data-gs-auto-position",g?"yes":null),"undefined"!=typeof h&&b.attr("data-gs-min-width",h),"undefined"!=typeof i&&b.attr("data-gs-max-width",i),"undefined"!=typeof j&&b.attr("data-gs-min-height",j),"undefined"!=typeof k&&b.attr("data-gs-max-height",k),"undefined"!=typeof l&&b.attr("data-gs-id",l),this.container.append(b),this.makeWidget(b),b},j.prototype.makeWidget=function(b){return b=a(b),this._prepareElement(b,!0),this._triggerAddEvent(),this._updateContainerHeight(),this._triggerChangeEvent(!0),b},j.prototype.willItFit=function(a,b,c,d,e){var f={x:a,y:b,width:c,height:d,autoPosition:e};return this.grid.canBePlacedWithRespectToHeight(f)},j.prototype.removeWidget=function(b,c){c="undefined"==typeof c||c,b=a(b);var d=b.data("_gridstack_node"); // For Meteor support: https://github.com/troolee/gridstack.js/pull/272 -d||(d=this.grid.getNodeDataByDOMEl(b)),this.grid.removeNode(d,c),b.removeData("_gridstack_node"),this._updateContainerHeight(),c&&b.remove(),this._triggerChangeEvent(!0),this._triggerRemoveEvent()},j.prototype.removeAll=function(a){b.each(this.grid.nodes,b.bind(function(b){this.removeWidget(b.el,a)},this)),this.grid.nodes=[],this._updateContainerHeight()},j.prototype.destroy=function(b){a(window).off("resize",this.onResizeHandler),this.disable(),"undefined"==typeof b||b?this.container.remove():(this.removeAll(!1),this.container.removeData("gridstack")),g.removeStylesheet(this._stylesId),this.grid&&(this.grid=null)},j.prototype.resizable=function(b,c){var d=this;return b=a(b),b.each(function(b,e){e=a(e);var f=e.data("_gridstack_node");"undefined"!=typeof f&&null!==f&&"undefined"!=typeof a.ui&&(f.noResize=!c,f.noResize||d._isOneColumnMode()?d.dd.resizable(e,"disable"):d.dd.resizable(e,"enable"))}),this},j.prototype.movable=function(b,c){var d=this;return b=a(b),b.each(function(b,e){e=a(e);var f=e.data("_gridstack_node");"undefined"!=typeof f&&null!==f&&"undefined"!=typeof a.ui&&(f.noMove=!c,f.noMove||d._isOneColumnMode()?(d.dd.draggable(e,"disable"),e.removeClass("ui-draggable-handle")):(d.dd.draggable(e,"enable"),e.addClass("ui-draggable-handle")))}),this},j.prototype.enableMove=function(a,b){this.movable(this.container.children("."+this.opts.itemClass),a),b&&(this.opts.disableDrag=!a)},j.prototype.enableResize=function(a,b){this.resizable(this.container.children("."+this.opts.itemClass),a),b&&(this.opts.disableResize=!a)},j.prototype.disable=function(){this.movable(this.container.children("."+this.opts.itemClass),!1),this.resizable(this.container.children("."+this.opts.itemClass),!1),this.container.trigger("disable")},j.prototype.enable=function(){this.movable(this.container.children("."+this.opts.itemClass),!0),this.resizable(this.container.children("."+this.opts.itemClass),!0),this.container.trigger("enable")},j.prototype.locked=function(b,c){return b=a(b),b.each(function(b,d){d=a(d);var e=d.data("_gridstack_node");"undefined"!=typeof e&&null!==e&&(e.locked=c||!1,d.attr("data-gs-locked",e.locked?"yes":null))}),this},j.prototype.maxHeight=function(b,c){return b=a(b),b.each(function(b,d){d=a(d);var e=d.data("_gridstack_node");"undefined"!=typeof e&&null!==e&&(isNaN(c)||(e.maxHeight=c||!1,d.attr("data-gs-max-height",c)))}),this},j.prototype.minHeight=function(b,c){return b=a(b),b.each(function(b,d){d=a(d);var e=d.data("_gridstack_node");"undefined"!=typeof e&&null!==e&&(isNaN(c)||(e.minHeight=c||!1,d.attr("data-gs-min-height",c)))}),this},j.prototype.maxWidth=function(b,c){return b=a(b),b.each(function(b,d){d=a(d);var e=d.data("_gridstack_node");"undefined"!=typeof e&&null!==e&&(isNaN(c)||(e.maxWidth=c||!1,d.attr("data-gs-max-width",c)))}),this},j.prototype.minWidth=function(b,c){return b=a(b),b.each(function(b,d){d=a(d);var e=d.data("_gridstack_node");"undefined"!=typeof e&&null!==e&&(isNaN(c)||(e.minWidth=c||!1,d.attr("data-gs-min-width",c)))}),this},j.prototype._updateElement=function(b,c){b=a(b).first();var d=b.data("_gridstack_node");if("undefined"!=typeof d&&null!==d){var e=this;e.grid.cleanNodes(),e.grid.beginUpdate(d),c.call(this,b,d),e._updateContainerHeight(),e._triggerChangeEvent(),e.grid.endUpdate()}},j.prototype.resize=function(a,b,c){this._updateElement(a,function(a,d){b=null!==b&&"undefined"!=typeof b?b:d.width,c=null!==c&&"undefined"!=typeof c?c:d.height,this.grid.moveNode(d,d.x,d.y,b,c)})},j.prototype.move=function(a,b,c){this._updateElement(a,function(a,d){b=null!==b&&"undefined"!=typeof b?b:d.x,c=null!==c&&"undefined"!=typeof c?c:d.y,this.grid.moveNode(d,b,c,d.width,d.height)})},j.prototype.update=function(a,b,c,d,e){this._updateElement(a,function(a,f){b=null!==b&&"undefined"!=typeof b?b:f.x,c=null!==c&&"undefined"!=typeof c?c:f.y,d=null!==d&&"undefined"!=typeof d?d:f.width,e=null!==e&&"undefined"!=typeof e?e:f.height,this.grid.moveNode(f,b,c,d,e)})},j.prototype.verticalMargin=function(a,b){if("undefined"==typeof a)return this.opts.verticalMargin;var c=g.parseHeight(a);this.opts.verticalMarginUnit===c.unit&&this.opts.height===c.height||(this.opts.verticalMarginUnit=c.unit,this.opts.verticalMargin=c.height,b||this._updateStyles())},j.prototype.cellHeight=function(a,b){if("undefined"==typeof a){if(this.opts.cellHeight)return this.opts.cellHeight;var c=this.container.children("."+this.opts.itemClass).first();return Math.ceil(c.outerHeight()/c.attr("data-gs-height"))}var d=g.parseHeight(a);this.opts.cellHeightUnit===d.heightUnit&&this.opts.height===d.height||(this.opts.cellHeightUnit=d.unit,this.opts.cellHeight=d.height,b||this._updateStyles())},j.prototype.cellWidth=function(){return Math.round(this.container.outerWidth()/this.opts.width)},j.prototype.getCellFromPixel=function(a,b){var c="undefined"!=typeof b&&b?this.container.offset():this.container.position(),d=a.left-c.left,e=a.top-c.top,f=Math.floor(this.container.width()/this.opts.width),g=Math.floor(this.container.height()/parseInt(this.container.attr("data-gs-current-height")));return{x:Math.floor(d/f),y:Math.floor(e/g)}},j.prototype.batchUpdate=function(){this.grid.batchUpdate()},j.prototype.commit=function(){this.grid.commit(),this._updateContainerHeight()},j.prototype.isAreaEmpty=function(a,b,c,d){return this.grid.isAreaEmpty(a,b,c,d)},j.prototype.setStatic=function(a){this.opts.staticGrid=a===!0,this.enableMove(!a),this.enableResize(!a),this._setStaticClass()},j.prototype._setStaticClass=function(){var a="grid-stack-static";this.opts.staticGrid===!0?this.container.addClass(a):this.container.removeClass(a)},j.prototype._updateNodeWidths=function(a,b){this.grid._sortNodes(),this.grid.batchUpdate();for(var c={},d=0;d this.height); + + if (wrongPos) { + // if the pos is out of bounds, put it on first available + newPos = this.findFreeSpace(collisionNode.width, collisionNode.height); + if (!newPos) { + newPos = this.findFreeSpace(); + } + if (!newPos) { + return; // hmm + } + } else { + newPos = { + x: collisionNode.x, + y: node.y + node.height, + w: collisionNode.width, + h: collisionNode.height + }; + } + + if (newPos) { + this.moveNode(collisionNode, newPos.x, newPos.y, newPos.w, newPos.h, true, isClone); + } + } }; - GridStackEngine.prototype.isAreaEmpty = function(x, y, width, height) { - var nn = {x: x || 0, y: y || 0, width: width || 1, height: height || 1}; + GridStackEngine.prototype.whatIsHere = function(x, y, width, height) { + var nn = {x: x || 0, y: y || 0, width: width || 1, height: height || 1}; var collisionNode = _.find(this.nodes, _.bind(function(n) { return Utils.isIntercepted(n, nn); }, this)); + return collisionNode; + }; + + GridStackEngine.prototype.isAreaEmpty = function(x, y, width, height) { + var collisionNode = this.whatIsHere(x, y, width, height); return collisionNode === null || typeof collisionNode === 'undefined'; }; + GridStackEngine.prototype.findFreeSpace = function(w, h) { + var freeSpace = null, + i, j; + + // first free for 1x1 or we have specified width and height + if (!w) { w = 1; } + if (!h) { h = 1; } + + for (i = 0; i <= (this.width - w); i++) { + if (freeSpace) { + break; + } + for (j = 0; j <= (this.height - h); j++) { + if (freeSpace) { + break; + } + if (this.isAreaEmpty(i, j, w, h)) { + freeSpace = {x: i, y: j, w: w, h: h}; + } + } + } + + return freeSpace; + }; + GridStackEngine.prototype._sortNodes = function(dir) { this.nodes = Utils.sort(this.nodes, dir, this.width); }; @@ -287,7 +343,9 @@ node.width = 1; } - if (node.height < 1) { + if (this.height && (node.height > this.height)) { + node.height = this.height; + } else if (node.height < 1) { node.height = 1; } @@ -332,7 +390,7 @@ return _.filter(this.nodes, function(n) { return n._dirty; }); }; - GridStackEngine.prototype.addNode = function(node, triggerAddEvent) { + GridStackEngine.prototype.addNode = function(node, triggerAddEvent, isClone) { node = this._prepareNode(node); if (typeof node.maxWidth != 'undefined') { node.width = Math.min(node.width, node.maxWidth); } @@ -365,15 +423,16 @@ this._addedNodes.push(_.clone(node)); } - this._fixCollisions(node); + this._fixCollisions(node, isClone); this._packNodes(); this._notify(); return node; }; GridStackEngine.prototype.removeNode = function(node, detachNode) { - detachNode = typeof detachNode === 'undefined' ? true : detachNode; - this._removedNodes.push(_.clone(node)); + if (!node) { + return; + } node._id = null; this.nodes = _.without(this.nodes, node); this._packNodes(); @@ -408,7 +467,7 @@ return true; } - clone.moveNode(clonedNode, x, y, width, height); + clone.moveNode(clonedNode, x, y, width, height, false, true); var res = true; @@ -419,6 +478,11 @@ } if (this.height) { res &= clone.getGridHeight() <= this.height; + + // always allow moving the one out of bounds + if (node.y + node.height > this.height) { + res = true; + } } return res; @@ -435,7 +499,7 @@ this.float, 0, _.map(this.nodes, function(n) { return $.extend({}, n); })); - clone.addNode(node); + clone.addNode(node, false, true); return clone.getGridHeight() <= this.height; }; @@ -456,7 +520,7 @@ return true; }; - GridStackEngine.prototype.moveNode = function(node, x, y, width, height, noPack) { + GridStackEngine.prototype.moveNode = function(node, x, y, width, height, noPack, isClone) { if (!this.isNodeChangedPosition(node, x, y, width, height)) { return node; } @@ -489,7 +553,7 @@ node = this._prepareNode(node, resizing); - this._fixCollisions(node); + this._fixCollisions(node, isClone); if (!noPack) { this._packNodes(); this._notify(); @@ -663,7 +727,7 @@ maxHeight = Math.max(maxHeight, n.y + n.height); } }); - self._updateStyles(maxHeight + 10); + self._updateStyles(self.opts.height || (max_height + 10)); }, this.opts.float, this.opts.height); if (this.opts.auto) { @@ -690,6 +754,9 @@ this._updateContainerHeight(); + // setting styles also for empty grids + this._updateStyles(); + this._updateHeightsOnResize = _.throttle(function() { self.cellHeight(self.cellWidth(), false); }, 100); @@ -936,7 +1003,7 @@ var getHeight; if (typeof maxHeight == 'undefined') { - maxHeight = this._styles._max; + maxHeight = this._styles._max || this.opts.height; this._initStyles(); this._updateContainerHeight(); } @@ -998,7 +1065,7 @@ if (this.grid._updateCounter) { return; } - var height = this.grid.getGridHeight(); + var height = this.opts.height || this.grid.getGridHeight(); this.container.attr('data-gs-current-height', height); if (!this.opts.cellHeight) { return ; @@ -1065,7 +1132,7 @@ } if (event.type == 'drag') { - if (x < 0 || x >= self.grid.width || y < 0) { + if (x < 0 || x >= self.grid.width || y < 0 || (self.grid.height && y >= self.grid.height)) { if (self.opts.removable === true) { self._setupRemovingTimeout(el); } @@ -1117,6 +1184,14 @@ }; var onStartMoving = function(event, ui) { + + if (self.opts.draggable.handle && event.type === 'dragstart') { + // if handle specified, don't allow drag from anywhere else + if (!$(event.originalEvent.target).closest(self.opts.draggable.handle).length) { + return false; + } + } + self.container.append(self.placeholder); var o = $(this); self.grid.cleanNodes(); @@ -1265,10 +1340,8 @@ if (typeof maxHeight != 'undefined') { el.attr('data-gs-max-height', maxHeight); } if (typeof id != 'undefined') { el.attr('data-gs-id', id); } this.container.append(el); - this._prepareElement(el, true); - this._triggerAddEvent(); - this._updateContainerHeight(); - this._triggerChangeEvent(true); + + this.makeWidget(el); return el; }; @@ -1337,7 +1410,7 @@ el.each(function(index, el) { el = $(el); var node = el.data('_gridstack_node'); - if (typeof node == 'undefined' || node === null || typeof $.ui === 'undefined') { + if (typeof node == 'undefined' || node === null || typeof $.ui === 'undefined' || self.opts.staticGrid) { return; } @@ -1357,7 +1430,8 @@ el.each(function(index, el) { el = $(el); var node = el.data('_gridstack_node'); - if (typeof node == 'undefined' || node === null || typeof $.ui === 'undefined') { + + if (typeof node == 'undefined' || node === null || typeof $.ui === 'undefined' || self.opts.staticGrid) { return; } @@ -1483,6 +1557,7 @@ }; GridStack.prototype._updateElement = function(el, callback) { + el = $(el).first(); var node = el.data('_gridstack_node'); if (typeof node == 'undefined' || node === null) { @@ -1600,6 +1675,10 @@ return this.grid.isAreaEmpty(x, y, width, height); }; + GridStack.prototype.findFreeSpace = function(w, h) { + return this.grid.findFreeSpace(w, h); + }; + GridStack.prototype.setStatic = function(staticValue) { this.opts.staticGrid = (staticValue === true); this.enableMove(!staticValue); @@ -1617,6 +1696,40 @@ } }; + GridStack.prototype.refreshNodes = function(isDisabled) { + var that = this; + + this.removeAll(false); + + this.container.find('.' + this.opts.itemClass).each(function(k, node){ + $(node).off('dragstart dragstop drag resizestart resizestop resize'); + that.makeWidget(node); + }); + + if (this.opts.staticGrid && isDisabled) { + return; + } + + if (isDisabled) { + this.disable(); + } else { + this.enable(); + } + }; + + GridStack.prototype.getCellFromAbsolutePixel = function(nodeOffset) { + var offset = this.container.offset(), + position = this.container.position(); + + // offset relative to gridstack container itself + nodeOffset = { + left: nodeOffset.left - offset.left + position.left, + top: nodeOffset.top - offset.top + position.top + }; + + return this.getCellFromPixel(nodeOffset); + }; + GridStack.prototype._updateNodeWidths = function(oldWidth, newWidth) { this.grid._sortNodes(); this.grid.batchUpdate(); diff --git a/dist/gridstack.min.js b/dist/gridstack.min.js index 8f3dbcbbe..44d2a7a99 100644 --- a/dist/gridstack.min.js +++ b/dist/gridstack.min.js @@ -5,7 +5,7 @@ * gridstack.js may be freely distributed under the MIT license. * @preserve */ -!function(a){if("function"==typeof define&&define.amd)define(["jquery","lodash"],a);else if("undefined"!=typeof exports){try{jQuery=require("jquery")}catch(a){}try{_=require("lodash")}catch(a){}a(jQuery,_)}else a(jQuery,_)}(function(a,b){ +!function(a){if("function"==typeof define&&define.amd)define(["jquery","lodash"],a);else if("undefined"!=typeof exports){try{jQuery=require("jquery")}catch(b){}try{_=require("lodash")}catch(b){}a(jQuery,_)}else a(jQuery,_)}(function(a,b){ // jscs:enable requireCamelCaseOrUpperCaseIdentifiers /** * @class GridStackDragDropPlugin @@ -13,18 +13,30 @@ */ function c(a){this.grid=a}var d=window,e=function(a,b,c){var d=function(){return console.warn("gridstack.js: Function `"+b+"` is deprecated as of v0.2.5 and has been replaced with `"+c+"`. It will be **completely** removed in v1.0."),a.apply(this,arguments)};return d.prototype=a.prototype,d},f=function(a,b){console.warn("gridstack.js: Option `"+a+"` is deprecated as of v0.2.5 and has been replaced with `"+b+"`. It will be **completely** removed in v1.0.")},g={isIntercepted:function(a,b){return!(a.x+a.width<=b.x||b.x+b.width<=a.x||a.y+a.height<=b.y||b.y+b.height<=a.y)},sort:function(a,c,d){return d=d||b.chain(a).map(function(a){return a.x+a.width}).max().value(),c=c!=-1?1:-1,b.sortBy(a,function(a){return c*(a.x+a.y*d)})},createStylesheet:function(a){var b=document.createElement("style");return b.setAttribute("type","text/css"),b.setAttribute("data-gs-style-id",a),b.styleSheet?b.styleSheet.cssText="":b.appendChild(document.createTextNode("")),document.getElementsByTagName("head")[0].appendChild(b),b.sheet},removeStylesheet:function(b){a("STYLE[data-gs-style-id="+b+"]").remove()},insertCSSRule:function(a,b,c,d){"function"==typeof a.insertRule?a.insertRule(b+"{"+c+"}",d):"function"==typeof a.addRule&&a.addRule(b,c,d)},toBool:function(a){return"boolean"==typeof a?a:"string"==typeof a?(a=a.toLowerCase(),!(""===a||"no"==a||"false"==a||"0"==a)):Boolean(a)},_collisionNodeCheck:function(a){return a!=this.node&&g.isIntercepted(a,this.nn)},_didCollide:function(a){return g.isIntercepted({x:this.n.x,y:this.newY,width:this.n.width,height:this.n.height},a)},_isAddNodeIntercepted:function(a){return g.isIntercepted({x:this.x,y:this.y,width:this.node.width,height:this.node.height},a)},parseHeight:function(a){var c=a,d="px";if(c&&b.isString(c)){var e=c.match(/^(-[0-9]+\.[0-9]+|[0-9]*\.[0-9]+|-[0-9]+|[0-9]+)(px|em|rem|vh|vw)?$/);if(!e)throw new Error("Invalid height");d=e[2]||"px",c=parseFloat(e[1])}return{height:c,unit:d}}}; // jscs:disable requireCamelCaseOrUpperCaseIdentifiers -g.is_intercepted=e(g.isIntercepted,"is_intercepted","isIntercepted"),g.create_stylesheet=e(g.createStylesheet,"create_stylesheet","createStylesheet"),g.remove_stylesheet=e(g.removeStylesheet,"remove_stylesheet","removeStylesheet"),g.insert_css_rule=e(g.insertCSSRule,"insert_css_rule","insertCSSRule"),c.registeredPlugins=[],c.registerPlugin=function(a){c.registeredPlugins.push(a)},c.prototype.resizable=function(a,b){return this},c.prototype.draggable=function(a,b){return this},c.prototype.droppable=function(a,b){return this},c.prototype.isDroppable=function(a){return!1},c.prototype.on=function(a,b,c){return this};var h=0,i=function(a,b,c,d,e){this.width=a,this.float=c||!1,this.height=d||0,this.nodes=e||[],this.onchange=b||function(){},this._updateCounter=0,this._float=this.float,this._addedNodes=[],this._removedNodes=[]};i.prototype.batchUpdate=function(){this._updateCounter=1,this.float=!0},i.prototype.commit=function(){0!==this._updateCounter&&(this._updateCounter=0,this.float=this._float,this._packNodes(),this._notify())}, +g.is_intercepted=e(g.isIntercepted,"is_intercepted","isIntercepted"),g.create_stylesheet=e(g.createStylesheet,"create_stylesheet","createStylesheet"),g.remove_stylesheet=e(g.removeStylesheet,"remove_stylesheet","removeStylesheet"),g.insert_css_rule=e(g.insertCSSRule,"insert_css_rule","insertCSSRule"),c.registeredPlugins=[],c.registerPlugin=function(a){c.registeredPlugins.push(a)},c.prototype.resizable=function(a,b){return this},c.prototype.draggable=function(a,b){return this},c.prototype.droppable=function(a,b){return this},c.prototype.isDroppable=function(a){return!1},c.prototype.on=function(a,b,c){return this};var h=0,i=function(a,b,c,d,e){this.width=a,this["float"]=c||!1,this.height=d||0,this.nodes=e||[],this.onchange=b||function(){},this._updateCounter=0,this._float=this["float"],this._addedNodes=[],this._removedNodes=[]};i.prototype.batchUpdate=function(){this._updateCounter=1,this["float"]=!0},i.prototype.commit=function(){0!==this._updateCounter&&(this._updateCounter=0,this["float"]=this._float,this._packNodes(),this._notify())}, // For Meteor support: https://github.com/troolee/gridstack.js/pull/272 -i.prototype.getNodeDataByDOMEl=function(a){return b.find(this.nodes,function(b){return a.get(0)===b.el.get(0)})},i.prototype._fixCollisions=function(a){this._sortNodes(-1);var c=a,d=Boolean(b.find(this.nodes,function(a){return a.locked}));for(this.float||d||(c={x:0,y:a.y,width:this.width,height:a.height});;){var e=b.find(this.nodes,b.bind(g._collisionNodeCheck,{node:a,nn:c}));if("undefined"==typeof e)return;this.moveNode(e,e.x,a.y+a.height,e.width,e.height,!0)}},i.prototype.isAreaEmpty=function(a,c,d,e){var f={x:a||0,y:c||0,width:d||1,height:e||1},h=b.find(this.nodes,b.bind(function(a){return g.isIntercepted(a,f)},this));return null===h||"undefined"==typeof h},i.prototype._sortNodes=function(a){this.nodes=g.sort(this.nodes,a,this.width)},i.prototype._packNodes=function(){this._sortNodes(),this.float?b.each(this.nodes,b.bind(function(a,c){if(!a._updating&&"undefined"!=typeof a._origY&&a.y!=a._origY)for(var d=a.y;d>=a._origY;){var e=b.chain(this.nodes).find(b.bind(g._didCollide,{n:a,newY:d})).value();e||(a._dirty=!0,a.y=d),--d}},this)):b.each(this.nodes,b.bind(function(a,c){if(!a.locked)for(;a.y>0;){var d=a.y-1,e=0===c;if(c>0){var f=b.chain(this.nodes).take(c).find(b.bind(g._didCollide,{n:a,newY:d})).value();e="undefined"==typeof f}if(!e)break;a._dirty=a.y!=d,a.y=d}},this))},i.prototype._prepareNode=function(a,c){return a=b.defaults(a||{},{width:1,height:1,x:0,y:0}),a.x=parseInt(""+a.x),a.y=parseInt(""+a.y),a.width=parseInt(""+a.width),a.height=parseInt(""+a.height),a.autoPosition=a.autoPosition||!1,a.noResize=a.noResize||!1,a.noMove=a.noMove||!1,a.width>this.width?a.width=this.width:a.width<1&&(a.width=1),a.height<1&&(a.height=1),a.x<0&&(a.x=0),a.x+a.width>this.width&&(c?a.width=this.width-a.x:a.x=this.width-a.width),a.y<0&&(a.y=0),a},i.prototype._notify=function(){var a=Array.prototype.slice.call(arguments,0);if(a[0]="undefined"==typeof a[0]?[]:[a[0]],a[1]="undefined"==typeof a[1]||a[1],!this._updateCounter){var b=a[0].concat(this.getDirtyNodes());this.onchange(b,a[1])}},i.prototype.cleanNodes=function(){this._updateCounter||b.each(this.nodes,function(a){a._dirty=!1})},i.prototype.getDirtyNodes=function(){return b.filter(this.nodes,function(a){return a._dirty})},i.prototype.addNode=function(a,c){if(a=this._prepareNode(a),"undefined"!=typeof a.maxWidth&&(a.width=Math.min(a.width,a.maxWidth)),"undefined"!=typeof a.maxHeight&&(a.height=Math.min(a.height,a.maxHeight)),"undefined"!=typeof a.minWidth&&(a.width=Math.max(a.width,a.minWidth)),"undefined"!=typeof a.minHeight&&(a.height=Math.max(a.height,a.minHeight)),a._id=++h,a._dirty=!0,a.autoPosition){this._sortNodes();for(var d=0;;++d){var e=d%this.width,f=Math.floor(d/this.width);if(!(e+a.width>this.width||b.find(this.nodes,b.bind(g._isAddNodeIntercepted,{x:e,y:f,node:a})))){a.x=e,a.y=f;break}}}return this.nodes.push(a),"undefined"!=typeof c&&c&&this._addedNodes.push(b.clone(a)),this._fixCollisions(a),this._packNodes(),this._notify(),a},i.prototype.removeNode=function(a,c){c="undefined"==typeof c||c,this._removedNodes.push(b.clone(a)),a._id=null,this.nodes=b.without(this.nodes,a),this._packNodes(),this._notify(a,c)},i.prototype.canMoveNode=function(c,d,e,f,g){if(!this.isNodeChangedPosition(c,d,e,f,g))return!1;var h=Boolean(b.find(this.nodes,function(a){return a.locked}));if(!this.height&&!h)return!0;var j,k=new i(this.width,null,this.float,0,b.map(this.nodes,function(b){return b==c?j=a.extend({},b):a.extend({},b)}));if("undefined"==typeof j)return!0;k.moveNode(j,d,e,f,g);var l=!0;return h&&(l&=!Boolean(b.find(k.nodes,function(a){return a!=j&&Boolean(a.locked)&&Boolean(a._dirty)}))),this.height&&(l&=k.getGridHeight()<=this.height),l},i.prototype.canBePlacedWithRespectToHeight=function(c){if(!this.height)return!0;var d=new i(this.width,null,this.float,0,b.map(this.nodes,function(b){return a.extend({},b)}));return d.addNode(c),d.getGridHeight()<=this.height},i.prototype.isNodeChangedPosition=function(a,b,c,d,e){return"number"!=typeof b&&(b=a.x),"number"!=typeof c&&(c=a.y),"number"!=typeof d&&(d=a.width),"number"!=typeof e&&(e=a.height),"undefined"!=typeof a.maxWidth&&(d=Math.min(d,a.maxWidth)),"undefined"!=typeof a.maxHeight&&(e=Math.min(e,a.maxHeight)),"undefined"!=typeof a.minWidth&&(d=Math.max(d,a.minWidth)),"undefined"!=typeof a.minHeight&&(e=Math.max(e,a.minHeight)),a.x!=b||a.y!=c||a.width!=d||a.height!=e},i.prototype.moveNode=function(a,b,c,d,e,f){if(!this.isNodeChangedPosition(a,b,c,d,e))return a;if("number"!=typeof b&&(b=a.x),"number"!=typeof c&&(c=a.y),"number"!=typeof d&&(d=a.width),"number"!=typeof e&&(e=a.height),"undefined"!=typeof a.maxWidth&&(d=Math.min(d,a.maxWidth)),"undefined"!=typeof a.maxHeight&&(e=Math.min(e,a.maxHeight)),"undefined"!=typeof a.minWidth&&(d=Math.max(d,a.minWidth)),"undefined"!=typeof a.minHeight&&(e=Math.max(e,a.minHeight)),a.x==b&&a.y==c&&a.width==d&&a.height==e)return a;var g=a.width!=d;return a._dirty=!0,a.x=b,a.y=c,a.width=d,a.height=e,a.lastTriedX=b,a.lastTriedY=c,a.lastTriedWidth=d,a.lastTriedHeight=e,a=this._prepareNode(a,g),this._fixCollisions(a),f||(this._packNodes(),this._notify()),a},i.prototype.getGridHeight=function(){return b.reduce(this.nodes,function(a,b){return Math.max(a,b.y+b.height)},0)},i.prototype.beginUpdate=function(a){b.each(this.nodes,function(a){a._origY=a.y}),a._updating=!0},i.prototype.endUpdate=function(){b.each(this.nodes,function(a){a._origY=a.y});var a=b.find(this.nodes,function(a){return a._updating});a&&(a._updating=!1)};var j=function(d,e){var g,h,j=this;e=e||{},this.container=a(d), +i.prototype.getNodeDataByDOMEl=function(a){return b.find(this.nodes,function(b){return a.get(0)===b.el.get(0)})},i.prototype._fixCollisions=function(a,c){this._sortNodes(-1);var d=a,e=Boolean(b.find(this.nodes,function(a){return a.locked}));for(this["float"]||e||(d={x:0,y:a.y,width:this.width,height:a.height});;){var f=b.find(this.nodes,b.bind(g._collisionNodeCheck,{node:a,nn:d}));if("undefined"==typeof f)return; +// will try to fix the collision +var h,i=(a.y+a.height,!c&&a.y+a.height+f.height>this.height);if(i){if( +// if the pos is out of bounds, put it on first available +h=this.findFreeSpace(f.width,f.height),h||(h=this.findFreeSpace()),!h)return}else h={x:f.x,y:a.y+a.height,w:f.width,h:f.height};h&&this.moveNode(f,h.x,h.y,h.w,h.h,!0,c)}},i.prototype.whatIsHere=function(a,c,d,e){var f={x:a||0,y:c||0,width:d||1,height:e||1},h=b.find(this.nodes,b.bind(function(a){return g.isIntercepted(a,f)},this));return h},i.prototype.isAreaEmpty=function(a,b,c,d){var e=this.whatIsHere(a,b,c,d);return null===e||"undefined"==typeof e},i.prototype.findFreeSpace=function(a,b){var c,d,e=null;for( +// first free for 1x1 or we have specified width and height +a||(a=1),b||(b=1),c=0;c<=this.width-a&&!e;c++)for(d=0;d<=this.height-b&&!e;d++)this.isAreaEmpty(c,d,a,b)&&(e={x:c,y:d,w:a,h:b});return e},i.prototype._sortNodes=function(a){this.nodes=g.sort(this.nodes,a,this.width)},i.prototype._packNodes=function(){this._sortNodes(),this["float"]?b.each(this.nodes,b.bind(function(a,c){if(!a._updating&&"undefined"!=typeof a._origY&&a.y!=a._origY)for(var d=a.y;d>=a._origY;){var e=b.chain(this.nodes).find(b.bind(g._didCollide,{n:a,newY:d})).value();e||(a._dirty=!0,a.y=d),--d}},this)):b.each(this.nodes,b.bind(function(a,c){if(!a.locked)for(;a.y>0;){var d=a.y-1,e=0===c;if(c>0){var f=b.chain(this.nodes).take(c).find(b.bind(g._didCollide,{n:a,newY:d})).value();e="undefined"==typeof f}if(!e)break;a._dirty=a.y!=d,a.y=d}},this))},i.prototype._prepareNode=function(a,c){return a=b.defaults(a||{},{width:1,height:1,x:0,y:0}),a.x=parseInt(""+a.x),a.y=parseInt(""+a.y),a.width=parseInt(""+a.width),a.height=parseInt(""+a.height),a.autoPosition=a.autoPosition||!1,a.noResize=a.noResize||!1,a.noMove=a.noMove||!1,a.width>this.width?a.width=this.width:a.width<1&&(a.width=1),this.height&&a.height>this.height?a.height=this.height:a.height<1&&(a.height=1),a.x<0&&(a.x=0),a.x+a.width>this.width&&(c?a.width=this.width-a.x:a.x=this.width-a.width),a.y<0&&(a.y=0),a},i.prototype._notify=function(){var a=Array.prototype.slice.call(arguments,0);if(a[0]="undefined"==typeof a[0]?[]:[a[0]],a[1]="undefined"==typeof a[1]||a[1],!this._updateCounter){var b=a[0].concat(this.getDirtyNodes());this.onchange(b,a[1])}},i.prototype.cleanNodes=function(){this._updateCounter||b.each(this.nodes,function(a){a._dirty=!1})},i.prototype.getDirtyNodes=function(){return b.filter(this.nodes,function(a){return a._dirty})},i.prototype.addNode=function(a,c,d){if(a=this._prepareNode(a),"undefined"!=typeof a.maxWidth&&(a.width=Math.min(a.width,a.maxWidth)),"undefined"!=typeof a.maxHeight&&(a.height=Math.min(a.height,a.maxHeight)),"undefined"!=typeof a.minWidth&&(a.width=Math.max(a.width,a.minWidth)),"undefined"!=typeof a.minHeight&&(a.height=Math.max(a.height,a.minHeight)),a._id=++h,a._dirty=!0,a.autoPosition){this._sortNodes();for(var e=0;;++e){var f=e%this.width,i=Math.floor(e/this.width);if(!(f+a.width>this.width||b.find(this.nodes,b.bind(g._isAddNodeIntercepted,{x:f,y:i,node:a})))){a.x=f,a.y=i;break}}}return this.nodes.push(a),"undefined"!=typeof c&&c&&this._addedNodes.push(b.clone(a)),this._fixCollisions(a,d),this._packNodes(),this._notify(),a},i.prototype.removeNode=function(a,c){a&&(a._id=null,this.nodes=b.without(this.nodes,a),this._packNodes(),this._notify(a,c))},i.prototype.canMoveNode=function(c,d,e,f,g){if(!this.isNodeChangedPosition(c,d,e,f,g))return!1;var h=Boolean(b.find(this.nodes,function(a){return a.locked}));if(!this.height&&!h)return!0;var j,k=new i(this.width,null,this["float"],0,b.map(this.nodes,function(b){return b==c?j=a.extend({},b):a.extend({},b)}));if("undefined"==typeof j)return!0;k.moveNode(j,d,e,f,g,!1,!0);var l=!0; +// always allow moving the one out of bounds +return h&&(l&=!Boolean(b.find(k.nodes,function(a){return a!=j&&Boolean(a.locked)&&Boolean(a._dirty)}))),this.height&&(l&=k.getGridHeight()<=this.height,c.y+c.height>this.height&&(l=!0)),l},i.prototype.canBePlacedWithRespectToHeight=function(c){if(!this.height)return!0;var d=new i(this.width,null,this["float"],0,b.map(this.nodes,function(b){return a.extend({},b)}));return d.addNode(c,!1,!0),d.getGridHeight()<=this.height},i.prototype.isNodeChangedPosition=function(a,b,c,d,e){return"number"!=typeof b&&(b=a.x),"number"!=typeof c&&(c=a.y),"number"!=typeof d&&(d=a.width),"number"!=typeof e&&(e=a.height),"undefined"!=typeof a.maxWidth&&(d=Math.min(d,a.maxWidth)),"undefined"!=typeof a.maxHeight&&(e=Math.min(e,a.maxHeight)),"undefined"!=typeof a.minWidth&&(d=Math.max(d,a.minWidth)),"undefined"!=typeof a.minHeight&&(e=Math.max(e,a.minHeight)),a.x!=b||a.y!=c||a.width!=d||a.height!=e},i.prototype.moveNode=function(a,b,c,d,e,f,g){if(!this.isNodeChangedPosition(a,b,c,d,e))return a;if("number"!=typeof b&&(b=a.x),"number"!=typeof c&&(c=a.y),"number"!=typeof d&&(d=a.width),"number"!=typeof e&&(e=a.height),"undefined"!=typeof a.maxWidth&&(d=Math.min(d,a.maxWidth)),"undefined"!=typeof a.maxHeight&&(e=Math.min(e,a.maxHeight)),"undefined"!=typeof a.minWidth&&(d=Math.max(d,a.minWidth)),"undefined"!=typeof a.minHeight&&(e=Math.max(e,a.minHeight)),a.x==b&&a.y==c&&a.width==d&&a.height==e)return a;var h=a.width!=d;return a._dirty=!0,a.x=b,a.y=c,a.width=d,a.height=e,a.lastTriedX=b,a.lastTriedY=c,a.lastTriedWidth=d,a.lastTriedHeight=e,a=this._prepareNode(a,h),this._fixCollisions(a,g),f||(this._packNodes(),this._notify()),a},i.prototype.getGridHeight=function(){return b.reduce(this.nodes,function(a,b){return Math.max(a,b.y+b.height)},0)},i.prototype.beginUpdate=function(a){b.each(this.nodes,function(a){a._origY=a.y}),a._updating=!0},i.prototype.endUpdate=function(){b.each(this.nodes,function(a){a._origY=a.y});var a=b.find(this.nodes,function(a){return a._updating});a&&(a._updating=!1)};var j=function(d,e){var g,h,j=this;e=e||{},this.container=a(d), // jscs:disable requireCamelCaseOrUpperCaseIdentifiers "undefined"!=typeof e.handle_class&&(e.handleClass=e.handle_class,f("handle_class","handleClass")),"undefined"!=typeof e.item_class&&(e.itemClass=e.item_class,f("item_class","itemClass")),"undefined"!=typeof e.placeholder_class&&(e.placeholderClass=e.placeholder_class,f("placeholder_class","placeholderClass")),"undefined"!=typeof e.placeholder_text&&(e.placeholderText=e.placeholder_text,f("placeholder_text","placeholderText")),"undefined"!=typeof e.cell_height&&(e.cellHeight=e.cell_height,f("cell_height","cellHeight")),"undefined"!=typeof e.vertical_margin&&(e.verticalMargin=e.vertical_margin,f("vertical_margin","verticalMargin")),"undefined"!=typeof e.min_width&&(e.minWidth=e.min_width,f("min_width","minWidth")),"undefined"!=typeof e.static_grid&&(e.staticGrid=e.static_grid,f("static_grid","staticGrid")),"undefined"!=typeof e.is_nested&&(e.isNested=e.is_nested,f("is_nested","isNested")),"undefined"!=typeof e.always_show_resize_handle&&(e.alwaysShowResizeHandle=e.always_show_resize_handle,f("always_show_resize_handle","alwaysShowResizeHandle")), // jscs:enable requireCamelCaseOrUpperCaseIdentifiers -e.itemClass=e.itemClass||"grid-stack-item";var k=this.container.closest("."+e.itemClass).length>0;if(this.opts=b.defaults(e||{},{width:parseInt(this.container.attr("data-gs-width"))||12,height:parseInt(this.container.attr("data-gs-height"))||0,itemClass:"grid-stack-item",placeholderClass:"grid-stack-placeholder",placeholderText:"",handle:".grid-stack-item-content",handleClass:null,cellHeight:60,verticalMargin:20,auto:!0,minWidth:768,float:!1,staticGrid:!1,_class:"grid-stack-instance-"+(1e4*Math.random()).toFixed(0),animate:Boolean(this.container.attr("data-gs-animate"))||!1,alwaysShowResizeHandle:e.alwaysShowResizeHandle||!1,resizable:b.defaults(e.resizable||{},{autoHide:!e.alwaysShowResizeHandle,handles:"se"}),draggable:b.defaults(e.draggable||{},{handle:(e.handleClass?"."+e.handleClass:e.handle?e.handle:"")||".grid-stack-item-content",scroll:!1,appendTo:"body"}),disableDrag:e.disableDrag||!1,disableResize:e.disableResize||!1,rtl:"auto",removable:!1,removeTimeout:2e3,verticalMarginUnit:"px",cellHeightUnit:"px",oneColumnModeClass:e.oneColumnModeClass||"grid-stack-one-column-mode",ddPlugin:null}),this.opts.ddPlugin===!1?this.opts.ddPlugin=c:null===this.opts.ddPlugin&&(this.opts.ddPlugin=b.first(c.registeredPlugins)||c),this.dd=new this.opts.ddPlugin(this),"auto"===this.opts.rtl&&(this.opts.rtl="rtl"===this.container.css("direction")),this.opts.rtl&&this.container.addClass("grid-stack-rtl"),this.opts.isNested=k,h="auto"===this.opts.cellHeight,h?j.cellHeight(j.cellWidth(),!0):this.cellHeight(this.opts.cellHeight,!0),this.verticalMargin(this.opts.verticalMargin,!0),this.container.addClass(this.opts._class),this._setStaticClass(),k&&this.container.addClass("grid-stack-nested"),this._initStyles(),this.grid=new i(this.opts.width,function(a,c){c="undefined"==typeof c||c;var d=0;b.each(a,function(a){c&&null===a._id?a.el&&a.el.remove():(a.el.attr("data-gs-x",a.x).attr("data-gs-y",a.y).attr("data-gs-width",a.width).attr("data-gs-height",a.height),d=Math.max(d,a.y+a.height))}),j._updateStyles(d+10)},this.opts.float,this.opts.height),this.opts.auto){var l=[],m=this;this.container.children("."+this.opts.itemClass+":not(."+this.opts.placeholderClass+")").each(function(b,c){c=a(c),l.push({el:c,i:parseInt(c.attr("data-gs-x"))+parseInt(c.attr("data-gs-y"))*m.opts.width})}),b.chain(l).sortBy(function(a){return a.i}).each(function(a){j._prepareElement(a.el)}).value()}if(this.setAnimation(this.opts.animate),this.placeholder=a('
'+this.opts.placeholderText+"
").hide(),this._updateContainerHeight(),this._updateHeightsOnResize=b.throttle(function(){j.cellHeight(j.cellWidth(),!1)},100),this.onResizeHandler=function(){if(h&&j._updateHeightsOnResize(),j._isOneColumnMode()){if(g)return;j.container.addClass(j.opts.oneColumnModeClass),g=!0,j.grid._sortNodes(),b.each(j.grid.nodes,function(a){j.container.append(a.el),j.opts.staticGrid||((a.noMove||j.opts.disableDrag)&&j.dd.draggable(a.el,"disable"),(a.noResize||j.opts.disableResize)&&j.dd.resizable(a.el,"disable"),a.el.trigger("resize"))})}else{if(!g)return;if(j.container.removeClass(j.opts.oneColumnModeClass),g=!1,j.opts.staticGrid)return;b.each(j.grid.nodes,function(a){a.noMove||j.opts.disableDrag||j.dd.draggable(a.el,"enable"),a.noResize||j.opts.disableResize||j.dd.resizable(a.el,"enable"),a.el.trigger("resize")})}},a(window).resize(this.onResizeHandler),this.onResizeHandler(),!j.opts.staticGrid&&"string"==typeof j.opts.removable){var n=a(j.opts.removable);this.dd.isDroppable(n)||this.dd.droppable(n,{accept:"."+j.opts.itemClass}),this.dd.on(n,"dropover",function(b,c){var d=a(c.draggable),e=d.data("_gridstack_node");e._grid===j&&j._setupRemovingTimeout(d)}).on(n,"dropout",function(b,c){var d=a(c.draggable),e=d.data("_gridstack_node");e._grid===j&&j._clearRemovingTimeout(d)})}if(!j.opts.staticGrid&&j.opts.acceptWidgets){var o=null,p=function(a,b){var c=o,d=c.data("_gridstack_node"),e=j.getCellFromPixel(b.offset,!0),f=Math.max(0,e.x),g=Math.max(0,e.y);if(d._added){if(!j.grid.canMoveNode(d,f,g))return;j.grid.moveNode(d,f,g),j._updateContainerHeight()}else d._added=!0,d.el=c,d.x=f,d.y=g,j.grid.cleanNodes(),j.grid.beginUpdate(d),j.grid.addNode(d),j.container.append(j.placeholder),j.placeholder.attr("data-gs-x",d.x).attr("data-gs-y",d.y).attr("data-gs-width",d.width).attr("data-gs-height",d.height).show(),d.el=j.placeholder,d._beforeDragX=d.x,d._beforeDragY=d.y,j._updateContainerHeight()};this.dd.droppable(j.container,{accept:function(b){b=a(b);var c=b.data("_gridstack_node");return(!c||c._grid!==j)&&b.is(j.opts.acceptWidgets===!0?".grid-stack-item":j.opts.acceptWidgets)}}).on(j.container,"dropover",function(b,c){var d=(j.container.offset(),a(c.draggable)),e=j.cellWidth(),f=j.cellHeight(),g=d.data("_gridstack_node"),h=g?g.width:Math.ceil(d.outerWidth()/e),i=g?g.height:Math.ceil(d.outerHeight()/f);o=d;var k=j.grid._prepareNode({width:h,height:i,_added:!1,_temporary:!0});d.data("_gridstack_node",k),d.data("_gridstack_node_orig",g),d.on("drag",p)}).on(j.container,"dropout",function(b,c){var d=a(c.draggable);d.unbind("drag",p);var e=d.data("_gridstack_node");e.el=null,j.grid.removeNode(e),j.placeholder.detach(),j._updateContainerHeight(),d.data("_gridstack_node",d.data("_gridstack_node_orig"))}).on(j.container,"drop",function(b,c){j.placeholder.detach();var d=a(c.draggable).data("_gridstack_node");d._grid=j;var e=a(c.draggable).clone(!1);e.data("_gridstack_node",d),a(c.draggable).remove(),d.el=e,j.placeholder.hide(),e.attr("data-gs-x",d.x).attr("data-gs-y",d.y).attr("data-gs-width",d.width).attr("data-gs-height",d.height).addClass(j.opts.itemClass).removeAttr("style").enableSelection().removeData("draggable").removeClass("ui-draggable ui-draggable-dragging ui-draggable-disabled").unbind("drag",p),j.container.append(e),j._prepareElementsByNode(e,d),j._updateContainerHeight(),j._triggerChangeEvent(),j.grid.endUpdate()})}}; +e.itemClass=e.itemClass||"grid-stack-item";var k=this.container.closest("."+e.itemClass).length>0;if(this.opts=b.defaults(e||{},{width:parseInt(this.container.attr("data-gs-width"))||12,height:parseInt(this.container.attr("data-gs-height"))||0,itemClass:"grid-stack-item",placeholderClass:"grid-stack-placeholder",placeholderText:"",handle:".grid-stack-item-content",handleClass:null,cellHeight:60,verticalMargin:20,auto:!0,minWidth:768,"float":!1,staticGrid:!1,_class:"grid-stack-instance-"+(1e4*Math.random()).toFixed(0),animate:Boolean(this.container.attr("data-gs-animate"))||!1,alwaysShowResizeHandle:e.alwaysShowResizeHandle||!1,resizable:b.defaults(e.resizable||{},{autoHide:!e.alwaysShowResizeHandle,handles:"se"}),draggable:b.defaults(e.draggable||{},{handle:(e.handleClass?"."+e.handleClass:e.handle?e.handle:"")||".grid-stack-item-content",scroll:!1,appendTo:"body"}),disableDrag:e.disableDrag||!1,disableResize:e.disableResize||!1,rtl:"auto",removable:!1,removeTimeout:2e3,verticalMarginUnit:"px",cellHeightUnit:"px",oneColumnModeClass:e.oneColumnModeClass||"grid-stack-one-column-mode",ddPlugin:null}),this.opts.ddPlugin===!1?this.opts.ddPlugin=c:null===this.opts.ddPlugin&&(this.opts.ddPlugin=b.first(c.registeredPlugins)||c),this.dd=new this.opts.ddPlugin(this),"auto"===this.opts.rtl&&(this.opts.rtl="rtl"===this.container.css("direction")),this.opts.rtl&&this.container.addClass("grid-stack-rtl"),this.opts.isNested=k,h="auto"===this.opts.cellHeight,h?j.cellHeight(j.cellWidth(),!0):this.cellHeight(this.opts.cellHeight,!0),this.verticalMargin(this.opts.verticalMargin,!0),this.container.addClass(this.opts._class),this._setStaticClass(),k&&this.container.addClass("grid-stack-nested"),this._initStyles(),this.grid=new i(this.opts.width,function(a,c){c="undefined"==typeof c||c;var d=0;b.each(a,function(a){c&&null===a._id?a.el&&a.el.remove():(a.el.attr("data-gs-x",a.x).attr("data-gs-y",a.y).attr("data-gs-width",a.width).attr("data-gs-height",a.height),d=Math.max(d,a.y+a.height))}),j._updateStyles(j.opts.height||max_height+10)},this.opts["float"],this.opts.height),this.opts.auto){var l=[],m=this;this.container.children("."+this.opts.itemClass+":not(."+this.opts.placeholderClass+")").each(function(b,c){c=a(c),l.push({el:c,i:parseInt(c.attr("data-gs-x"))+parseInt(c.attr("data-gs-y"))*m.opts.width})}),b.chain(l).sortBy(function(a){return a.i}).each(function(a){j._prepareElement(a.el)}).value()}if(this.setAnimation(this.opts.animate),this.placeholder=a('
'+this.opts.placeholderText+"
").hide(),this._updateContainerHeight(), +// setting styles also for empty grids +this._updateStyles(),this._updateHeightsOnResize=b.throttle(function(){j.cellHeight(j.cellWidth(),!1)},100),this.onResizeHandler=function(){if(h&&j._updateHeightsOnResize(),j._isOneColumnMode()){if(g)return;j.container.addClass(j.opts.oneColumnModeClass),g=!0,j.grid._sortNodes(),b.each(j.grid.nodes,function(a){j.container.append(a.el),j.opts.staticGrid||((a.noMove||j.opts.disableDrag)&&j.dd.draggable(a.el,"disable"),(a.noResize||j.opts.disableResize)&&j.dd.resizable(a.el,"disable"),a.el.trigger("resize"))})}else{if(!g)return;if(j.container.removeClass(j.opts.oneColumnModeClass),g=!1,j.opts.staticGrid)return;b.each(j.grid.nodes,function(a){a.noMove||j.opts.disableDrag||j.dd.draggable(a.el,"enable"),a.noResize||j.opts.disableResize||j.dd.resizable(a.el,"enable"),a.el.trigger("resize")})}},a(window).resize(this.onResizeHandler),this.onResizeHandler(),!j.opts.staticGrid&&"string"==typeof j.opts.removable){var n=a(j.opts.removable);this.dd.isDroppable(n)||this.dd.droppable(n,{accept:"."+j.opts.itemClass}),this.dd.on(n,"dropover",function(b,c){var d=a(c.draggable),e=d.data("_gridstack_node");e._grid===j&&j._setupRemovingTimeout(d)}).on(n,"dropout",function(b,c){var d=a(c.draggable),e=d.data("_gridstack_node");e._grid===j&&j._clearRemovingTimeout(d)})}if(!j.opts.staticGrid&&j.opts.acceptWidgets){var o=null,p=function(a,b){var c=o,d=c.data("_gridstack_node"),e=j.getCellFromPixel(b.offset,!0),f=Math.max(0,e.x),g=Math.max(0,e.y);if(d._added){if(!j.grid.canMoveNode(d,f,g))return;j.grid.moveNode(d,f,g),j._updateContainerHeight()}else d._added=!0,d.el=c,d.x=f,d.y=g,j.grid.cleanNodes(),j.grid.beginUpdate(d),j.grid.addNode(d),j.container.append(j.placeholder),j.placeholder.attr("data-gs-x",d.x).attr("data-gs-y",d.y).attr("data-gs-width",d.width).attr("data-gs-height",d.height).show(),d.el=j.placeholder,d._beforeDragX=d.x,d._beforeDragY=d.y,j._updateContainerHeight()};this.dd.droppable(j.container,{accept:function(b){b=a(b);var c=b.data("_gridstack_node");return(!c||c._grid!==j)&&b.is(j.opts.acceptWidgets===!0?".grid-stack-item":j.opts.acceptWidgets)}}).on(j.container,"dropover",function(b,c){var d=(j.container.offset(),a(c.draggable)),e=j.cellWidth(),f=j.cellHeight(),g=d.data("_gridstack_node"),h=g?g.width:Math.ceil(d.outerWidth()/e),i=g?g.height:Math.ceil(d.outerHeight()/f);o=d;var k=j.grid._prepareNode({width:h,height:i,_added:!1,_temporary:!0});d.data("_gridstack_node",k),d.data("_gridstack_node_orig",g),d.on("drag",p)}).on(j.container,"dropout",function(b,c){var d=a(c.draggable);d.unbind("drag",p);var e=d.data("_gridstack_node");e.el=null,j.grid.removeNode(e),j.placeholder.detach(),j._updateContainerHeight(),d.data("_gridstack_node",d.data("_gridstack_node_orig"))}).on(j.container,"drop",function(b,c){j.placeholder.detach();var d=a(c.draggable).data("_gridstack_node");d._grid=j;var e=a(c.draggable).clone(!1);e.data("_gridstack_node",d),a(c.draggable).remove(),d.el=e,j.placeholder.hide(),e.attr("data-gs-x",d.x).attr("data-gs-y",d.y).attr("data-gs-width",d.width).attr("data-gs-height",d.height).addClass(j.opts.itemClass).removeAttr("style").enableSelection().removeData("draggable").removeClass("ui-draggable ui-draggable-dragging ui-draggable-disabled").unbind("drag",p),j.container.append(e),j._prepareElementsByNode(e,d),j._updateContainerHeight(),j._triggerChangeEvent(),j.grid.endUpdate()})}}; // jscs:disable requireCamelCaseOrUpperCaseIdentifiers // jscs:enable requireCamelCaseOrUpperCaseIdentifiers -return j.prototype._triggerChangeEvent=function(a){var b=this.grid.getDirtyNodes(),c=!1,d=[];b&&b.length&&(d.push(b),c=!0),(c||a===!0)&&this.container.trigger("change",d)},j.prototype._triggerAddEvent=function(){this.grid._addedNodes&&this.grid._addedNodes.length>0&&(this.container.trigger("added",[b.map(this.grid._addedNodes,b.clone)]),this.grid._addedNodes=[])},j.prototype._triggerRemoveEvent=function(){this.grid._removedNodes&&this.grid._removedNodes.length>0&&(this.container.trigger("removed",[b.map(this.grid._removedNodes,b.clone)]),this.grid._removedNodes=[])},j.prototype._initStyles=function(){this._stylesId&&g.removeStylesheet(this._stylesId),this._stylesId="gridstack-style-"+(1e5*Math.random()).toFixed(),this._styles=g.createStylesheet(this._stylesId),null!==this._styles&&(this._styles._max=0)},j.prototype._updateStyles=function(a){if(null!==this._styles&&"undefined"!=typeof this._styles){var b,c="."+this.opts._class+" ."+this.opts.itemClass,d=this;if("undefined"==typeof a&&(a=this._styles._max,this._initStyles(),this._updateContainerHeight()),this.opts.cellHeight&&!(0!==this._styles._max&&a<=this._styles._max)&&(b=this.opts.verticalMargin&&this.opts.cellHeightUnit!==this.opts.verticalMarginUnit?function(a,b){return a&&b?"calc("+(d.opts.cellHeight*a+d.opts.cellHeightUnit)+" + "+(d.opts.verticalMargin*b+d.opts.verticalMarginUnit)+")":d.opts.cellHeight*a+d.opts.verticalMargin*b+d.opts.cellHeightUnit}:function(a,b){return d.opts.cellHeight*a+d.opts.verticalMargin*b+d.opts.cellHeightUnit},0===this._styles._max&&g.insertCSSRule(this._styles,c,"min-height: "+b(1,0)+";",0),a>this._styles._max)){for(var e=this._styles._max;e=f.grid.width||k<0?(f.opts.removable===!0&&f._setupRemovingTimeout(b),j=c._beforeDragX,k=c._beforeDragY,f.placeholder.detach(),f.placeholder.hide(),f.grid.removeNode(c),f._updateContainerHeight(),c._temporaryRemoved=!0):(f._clearRemovingTimeout(b),c._temporaryRemoved&&(f.grid.addNode(c),f.placeholder.attr("data-gs-x",j).attr("data-gs-y",k).attr("data-gs-width",h).attr("data-gs-height",i).show(),f.container.append(f.placeholder),c.el=f.placeholder,c._temporaryRemoved=!1));else if("resize"==a.type&&j<0)return; +return j.prototype._triggerChangeEvent=function(a){var b=this.grid.getDirtyNodes(),c=!1,d=[];b&&b.length&&(d.push(b),c=!0),(c||a===!0)&&this.container.trigger("change",d)},j.prototype._triggerAddEvent=function(){this.grid._addedNodes&&this.grid._addedNodes.length>0&&(this.container.trigger("added",[b.map(this.grid._addedNodes,b.clone)]),this.grid._addedNodes=[])},j.prototype._triggerRemoveEvent=function(){this.grid._removedNodes&&this.grid._removedNodes.length>0&&(this.container.trigger("removed",[b.map(this.grid._removedNodes,b.clone)]),this.grid._removedNodes=[])},j.prototype._initStyles=function(){this._stylesId&&g.removeStylesheet(this._stylesId),this._stylesId="gridstack-style-"+(1e5*Math.random()).toFixed(),this._styles=g.createStylesheet(this._stylesId),null!==this._styles&&(this._styles._max=0)},j.prototype._updateStyles=function(a){if(null!==this._styles&&"undefined"!=typeof this._styles){var b,c="."+this.opts._class+" ."+this.opts.itemClass,d=this;if("undefined"==typeof a&&(a=this._styles._max||this.opts.height,this._initStyles(),this._updateContainerHeight()),this.opts.cellHeight&&!(0!==this._styles._max&&a<=this._styles._max)&&(b=this.opts.verticalMargin&&this.opts.cellHeightUnit!==this.opts.verticalMarginUnit?function(a,b){return a&&b?"calc("+(d.opts.cellHeight*a+d.opts.cellHeightUnit)+" + "+(d.opts.verticalMargin*b+d.opts.verticalMarginUnit)+")":d.opts.cellHeight*a+d.opts.verticalMargin*b+d.opts.cellHeightUnit}:function(a,b){return d.opts.cellHeight*a+d.opts.verticalMargin*b+d.opts.cellHeightUnit},0===this._styles._max&&g.insertCSSRule(this._styles,c,"min-height: "+b(1,0)+";",0),a>this._styles._max)){for(var e=this._styles._max;e=f.grid.width||k<0||f.grid.height&&k>=f.grid.height?(f.opts.removable===!0&&f._setupRemovingTimeout(b),j=c._beforeDragX,k=c._beforeDragY,f.placeholder.detach(),f.placeholder.hide(),f.grid.removeNode(c),f._updateContainerHeight(),c._temporaryRemoved=!0):(f._clearRemovingTimeout(b),c._temporaryRemoved&&(f.grid.addNode(c),f.placeholder.attr("data-gs-x",j).attr("data-gs-y",k).attr("data-gs-width",h).attr("data-gs-height",i).show(),f.container.append(f.placeholder),c.el=f.placeholder,c._temporaryRemoved=!1));else if("resize"==a.type&&j<0)return; // width and height are undefined if not resizing -var l="undefined"!=typeof h?h:c.lastTriedWidth,m="undefined"!=typeof i?i:c.lastTriedHeight;!f.grid.canMoveNode(c,j,k,h,i)||c.lastTriedX===j&&c.lastTriedY===k&&c.lastTriedWidth===l&&c.lastTriedHeight===m||(c.lastTriedX=j,c.lastTriedY=k,c.lastTriedWidth=h,c.lastTriedHeight=i,f.grid.moveNode(c,j,k,h,i),f._updateContainerHeight())},h=function(g,h){f.container.append(f.placeholder);var i=a(this);f.grid.cleanNodes(),f.grid.beginUpdate(c),d=f.cellWidth();var j=Math.ceil(i.outerHeight()/i.attr("data-gs-height"));e=f.container.height()/parseInt(f.container.attr("data-gs-current-height")),f.placeholder.attr("data-gs-x",i.attr("data-gs-x")).attr("data-gs-y",i.attr("data-gs-y")).attr("data-gs-width",i.attr("data-gs-width")).attr("data-gs-height",i.attr("data-gs-height")).show(),c.el=f.placeholder,c._beforeDragX=c.x,c._beforeDragY=c.y,f.dd.resizable(b,"option","minWidth",d*(c.minWidth||1)),f.dd.resizable(b,"option","minHeight",j*(c.minHeight||1)),"resizestart"==g.type&&i.find(".grid-stack-item").trigger("resizestart")},i=function(d,e){var g=a(this);if(g.data("_gridstack_node")){var h=!1;f.placeholder.detach(),c.el=g,f.placeholder.hide(),c._isAboutToRemove?(h=!0,b.removeData("_gridstack_node"),b.remove()):(f._clearRemovingTimeout(b),c._temporaryRemoved?(g.attr("data-gs-x",c._beforeDragX).attr("data-gs-y",c._beforeDragY).attr("data-gs-width",c.width).attr("data-gs-height",c.height).removeAttr("style"),c.x=c._beforeDragX,c.y=c._beforeDragY,f.grid.addNode(c)):g.attr("data-gs-x",c.x).attr("data-gs-y",c.y).attr("data-gs-width",c.width).attr("data-gs-height",c.height).removeAttr("style")),f._updateContainerHeight(),f._triggerChangeEvent(h),f.grid.endUpdate();var i=g.find(".grid-stack");i.length&&"resizestop"==d.type&&(i.each(function(b,c){a(c).data("gridstack").onResizeHandler()}),g.find(".grid-stack-item").trigger("resizestop"))}};this.dd.draggable(b,{start:h,stop:i,drag:g}).resizable(b,{start:h,stop:i,resize:g}),(c.noMove||this._isOneColumnMode()||this.opts.disableDrag)&&this.dd.draggable(b,"disable"),(c.noResize||this._isOneColumnMode()||this.opts.disableResize)&&this.dd.resizable(b,"disable"),b.attr("data-gs-locked",c.locked?"yes":null)}},j.prototype._prepareElement=function(b,c){c="undefined"!=typeof c&&c;var d=this;b=a(b),b.addClass(this.opts.itemClass);var e=d.grid.addNode({x:b.attr("data-gs-x"),y:b.attr("data-gs-y"),width:b.attr("data-gs-width"),height:b.attr("data-gs-height"),maxWidth:b.attr("data-gs-max-width"),minWidth:b.attr("data-gs-min-width"),maxHeight:b.attr("data-gs-max-height"),minHeight:b.attr("data-gs-min-height"),autoPosition:g.toBool(b.attr("data-gs-auto-position")),noResize:g.toBool(b.attr("data-gs-no-resize")),noMove:g.toBool(b.attr("data-gs-no-move")),locked:g.toBool(b.attr("data-gs-locked")),el:b,id:b.attr("data-gs-id"),_grid:d},c);b.data("_gridstack_node",e),this._prepareElementsByNode(b,e)},j.prototype.setAnimation=function(a){a?this.container.addClass("grid-stack-animate"):this.container.removeClass("grid-stack-animate")},j.prototype.addWidget=function(b,c,d,e,f,g,h,i,j,k,l){return b=a(b),"undefined"!=typeof c&&b.attr("data-gs-x",c),"undefined"!=typeof d&&b.attr("data-gs-y",d),"undefined"!=typeof e&&b.attr("data-gs-width",e),"undefined"!=typeof f&&b.attr("data-gs-height",f),"undefined"!=typeof g&&b.attr("data-gs-auto-position",g?"yes":null),"undefined"!=typeof h&&b.attr("data-gs-min-width",h),"undefined"!=typeof i&&b.attr("data-gs-max-width",i),"undefined"!=typeof j&&b.attr("data-gs-min-height",j),"undefined"!=typeof k&&b.attr("data-gs-max-height",k),"undefined"!=typeof l&&b.attr("data-gs-id",l),this.container.append(b),this._prepareElement(b,!0),this._triggerAddEvent(),this._updateContainerHeight(),this._triggerChangeEvent(!0),b},j.prototype.makeWidget=function(b){return b=a(b),this._prepareElement(b,!0),this._triggerAddEvent(),this._updateContainerHeight(),this._triggerChangeEvent(!0),b},j.prototype.willItFit=function(a,b,c,d,e){var f={x:a,y:b,width:c,height:d,autoPosition:e};return this.grid.canBePlacedWithRespectToHeight(f)},j.prototype.removeWidget=function(b,c){c="undefined"==typeof c||c,b=a(b);var d=b.data("_gridstack_node"); +var l="undefined"!=typeof h?h:c.lastTriedWidth,m="undefined"!=typeof i?i:c.lastTriedHeight;!f.grid.canMoveNode(c,j,k,h,i)||c.lastTriedX===j&&c.lastTriedY===k&&c.lastTriedWidth===l&&c.lastTriedHeight===m||(c.lastTriedX=j,c.lastTriedY=k,c.lastTriedWidth=h,c.lastTriedHeight=i,f.grid.moveNode(c,j,k,h,i),f._updateContainerHeight())},h=function(g,h){if(f.opts.draggable.handle&&"dragstart"===g.type&&!a(g.originalEvent.target).closest(f.opts.draggable.handle).length)return!1;f.container.append(f.placeholder);var i=a(this);f.grid.cleanNodes(),f.grid.beginUpdate(c),d=f.cellWidth();var j=Math.ceil(i.outerHeight()/i.attr("data-gs-height"));e=f.container.height()/parseInt(f.container.attr("data-gs-current-height")),f.placeholder.attr("data-gs-x",i.attr("data-gs-x")).attr("data-gs-y",i.attr("data-gs-y")).attr("data-gs-width",i.attr("data-gs-width")).attr("data-gs-height",i.attr("data-gs-height")).show(),c.el=f.placeholder,c._beforeDragX=c.x,c._beforeDragY=c.y,f.dd.resizable(b,"option","minWidth",d*(c.minWidth||1)),f.dd.resizable(b,"option","minHeight",j*(c.minHeight||1)),"resizestart"==g.type&&i.find(".grid-stack-item").trigger("resizestart")},i=function(d,e){var g=a(this);if(g.data("_gridstack_node")){var h=!1;f.placeholder.detach(),c.el=g,f.placeholder.hide(),c._isAboutToRemove?(h=!0,b.removeData("_gridstack_node"),b.remove()):(f._clearRemovingTimeout(b),c._temporaryRemoved?(g.attr("data-gs-x",c._beforeDragX).attr("data-gs-y",c._beforeDragY).attr("data-gs-width",c.width).attr("data-gs-height",c.height).removeAttr("style"),c.x=c._beforeDragX,c.y=c._beforeDragY,f.grid.addNode(c)):g.attr("data-gs-x",c.x).attr("data-gs-y",c.y).attr("data-gs-width",c.width).attr("data-gs-height",c.height).removeAttr("style")),f._updateContainerHeight(),f._triggerChangeEvent(h),f.grid.endUpdate();var i=g.find(".grid-stack");i.length&&"resizestop"==d.type&&(i.each(function(b,c){a(c).data("gridstack").onResizeHandler()}),g.find(".grid-stack-item").trigger("resizestop"))}};this.dd.draggable(b,{start:h,stop:i,drag:g}).resizable(b,{start:h,stop:i,resize:g}),(c.noMove||this._isOneColumnMode()||this.opts.disableDrag)&&this.dd.draggable(b,"disable"),(c.noResize||this._isOneColumnMode()||this.opts.disableResize)&&this.dd.resizable(b,"disable"),b.attr("data-gs-locked",c.locked?"yes":null)}},j.prototype._prepareElement=function(b,c){c="undefined"!=typeof c&&c;var d=this;b=a(b),b.addClass(this.opts.itemClass);var e=d.grid.addNode({x:b.attr("data-gs-x"),y:b.attr("data-gs-y"),width:b.attr("data-gs-width"),height:b.attr("data-gs-height"),maxWidth:b.attr("data-gs-max-width"),minWidth:b.attr("data-gs-min-width"),maxHeight:b.attr("data-gs-max-height"),minHeight:b.attr("data-gs-min-height"),autoPosition:g.toBool(b.attr("data-gs-auto-position")),noResize:g.toBool(b.attr("data-gs-no-resize")),noMove:g.toBool(b.attr("data-gs-no-move")),locked:g.toBool(b.attr("data-gs-locked")),el:b,id:b.attr("data-gs-id"),_grid:d},c);b.data("_gridstack_node",e),this._prepareElementsByNode(b,e)},j.prototype.setAnimation=function(a){a?this.container.addClass("grid-stack-animate"):this.container.removeClass("grid-stack-animate")},j.prototype.addWidget=function(b,c,d,e,f,g,h,i,j,k,l){return b=a(b),"undefined"!=typeof c&&b.attr("data-gs-x",c),"undefined"!=typeof d&&b.attr("data-gs-y",d),"undefined"!=typeof e&&b.attr("data-gs-width",e),"undefined"!=typeof f&&b.attr("data-gs-height",f),"undefined"!=typeof g&&b.attr("data-gs-auto-position",g?"yes":null),"undefined"!=typeof h&&b.attr("data-gs-min-width",h),"undefined"!=typeof i&&b.attr("data-gs-max-width",i),"undefined"!=typeof j&&b.attr("data-gs-min-height",j),"undefined"!=typeof k&&b.attr("data-gs-max-height",k),"undefined"!=typeof l&&b.attr("data-gs-id",l),this.container.append(b),this.makeWidget(b),b},j.prototype.makeWidget=function(b){return b=a(b),this._prepareElement(b,!0),this._triggerAddEvent(),this._updateContainerHeight(),this._triggerChangeEvent(!0),b},j.prototype.willItFit=function(a,b,c,d,e){var f={x:a,y:b,width:c,height:d,autoPosition:e};return this.grid.canBePlacedWithRespectToHeight(f)},j.prototype.removeWidget=function(b,c){c="undefined"==typeof c||c,b=a(b);var d=b.data("_gridstack_node"); // For Meteor support: https://github.com/troolee/gridstack.js/pull/272 -d||(d=this.grid.getNodeDataByDOMEl(b)),this.grid.removeNode(d,c),b.removeData("_gridstack_node"),this._updateContainerHeight(),c&&b.remove(),this._triggerChangeEvent(!0),this._triggerRemoveEvent()},j.prototype.removeAll=function(a){b.each(this.grid.nodes,b.bind(function(b){this.removeWidget(b.el,a)},this)),this.grid.nodes=[],this._updateContainerHeight()},j.prototype.destroy=function(b){a(window).off("resize",this.onResizeHandler),this.disable(),"undefined"==typeof b||b?this.container.remove():(this.removeAll(!1),this.container.removeData("gridstack")),g.removeStylesheet(this._stylesId),this.grid&&(this.grid=null)},j.prototype.resizable=function(b,c){var d=this;return b=a(b),b.each(function(b,e){e=a(e);var f=e.data("_gridstack_node");"undefined"!=typeof f&&null!==f&&"undefined"!=typeof a.ui&&(f.noResize=!c,f.noResize||d._isOneColumnMode()?d.dd.resizable(e,"disable"):d.dd.resizable(e,"enable"))}),this},j.prototype.movable=function(b,c){var d=this;return b=a(b),b.each(function(b,e){e=a(e);var f=e.data("_gridstack_node");"undefined"!=typeof f&&null!==f&&"undefined"!=typeof a.ui&&(f.noMove=!c,f.noMove||d._isOneColumnMode()?(d.dd.draggable(e,"disable"),e.removeClass("ui-draggable-handle")):(d.dd.draggable(e,"enable"),e.addClass("ui-draggable-handle")))}),this},j.prototype.enableMove=function(a,b){this.movable(this.container.children("."+this.opts.itemClass),a),b&&(this.opts.disableDrag=!a)},j.prototype.enableResize=function(a,b){this.resizable(this.container.children("."+this.opts.itemClass),a),b&&(this.opts.disableResize=!a)},j.prototype.disable=function(){this.movable(this.container.children("."+this.opts.itemClass),!1),this.resizable(this.container.children("."+this.opts.itemClass),!1),this.container.trigger("disable")},j.prototype.enable=function(){this.movable(this.container.children("."+this.opts.itemClass),!0),this.resizable(this.container.children("."+this.opts.itemClass),!0),this.container.trigger("enable")},j.prototype.locked=function(b,c){return b=a(b),b.each(function(b,d){d=a(d);var e=d.data("_gridstack_node");"undefined"!=typeof e&&null!==e&&(e.locked=c||!1,d.attr("data-gs-locked",e.locked?"yes":null))}),this},j.prototype.maxHeight=function(b,c){return b=a(b),b.each(function(b,d){d=a(d);var e=d.data("_gridstack_node");"undefined"!=typeof e&&null!==e&&(isNaN(c)||(e.maxHeight=c||!1,d.attr("data-gs-max-height",c)))}),this},j.prototype.minHeight=function(b,c){return b=a(b),b.each(function(b,d){d=a(d);var e=d.data("_gridstack_node");"undefined"!=typeof e&&null!==e&&(isNaN(c)||(e.minHeight=c||!1,d.attr("data-gs-min-height",c)))}),this},j.prototype.maxWidth=function(b,c){return b=a(b),b.each(function(b,d){d=a(d);var e=d.data("_gridstack_node");"undefined"!=typeof e&&null!==e&&(isNaN(c)||(e.maxWidth=c||!1,d.attr("data-gs-max-width",c)))}),this},j.prototype.minWidth=function(b,c){return b=a(b),b.each(function(b,d){d=a(d);var e=d.data("_gridstack_node");"undefined"!=typeof e&&null!==e&&(isNaN(c)||(e.minWidth=c||!1,d.attr("data-gs-min-width",c)))}),this},j.prototype._updateElement=function(b,c){b=a(b).first();var d=b.data("_gridstack_node");if("undefined"!=typeof d&&null!==d){var e=this;e.grid.cleanNodes(),e.grid.beginUpdate(d),c.call(this,b,d),e._updateContainerHeight(),e._triggerChangeEvent(),e.grid.endUpdate()}},j.prototype.resize=function(a,b,c){this._updateElement(a,function(a,d){b=null!==b&&"undefined"!=typeof b?b:d.width,c=null!==c&&"undefined"!=typeof c?c:d.height,this.grid.moveNode(d,d.x,d.y,b,c)})},j.prototype.move=function(a,b,c){this._updateElement(a,function(a,d){b=null!==b&&"undefined"!=typeof b?b:d.x,c=null!==c&&"undefined"!=typeof c?c:d.y,this.grid.moveNode(d,b,c,d.width,d.height)})},j.prototype.update=function(a,b,c,d,e){this._updateElement(a,function(a,f){b=null!==b&&"undefined"!=typeof b?b:f.x,c=null!==c&&"undefined"!=typeof c?c:f.y,d=null!==d&&"undefined"!=typeof d?d:f.width,e=null!==e&&"undefined"!=typeof e?e:f.height,this.grid.moveNode(f,b,c,d,e)})},j.prototype.verticalMargin=function(a,b){if("undefined"==typeof a)return this.opts.verticalMargin;var c=g.parseHeight(a);this.opts.verticalMarginUnit===c.unit&&this.opts.height===c.height||(this.opts.verticalMarginUnit=c.unit,this.opts.verticalMargin=c.height,b||this._updateStyles())},j.prototype.cellHeight=function(a,b){if("undefined"==typeof a){if(this.opts.cellHeight)return this.opts.cellHeight;var c=this.container.children("."+this.opts.itemClass).first();return Math.ceil(c.outerHeight()/c.attr("data-gs-height"))}var d=g.parseHeight(a);this.opts.cellHeightUnit===d.heightUnit&&this.opts.height===d.height||(this.opts.cellHeightUnit=d.unit,this.opts.cellHeight=d.height,b||this._updateStyles())},j.prototype.cellWidth=function(){return Math.round(this.container.outerWidth()/this.opts.width)},j.prototype.getCellFromPixel=function(a,b){var c="undefined"!=typeof b&&b?this.container.offset():this.container.position(),d=a.left-c.left,e=a.top-c.top,f=Math.floor(this.container.width()/this.opts.width),g=Math.floor(this.container.height()/parseInt(this.container.attr("data-gs-current-height")));return{x:Math.floor(d/f),y:Math.floor(e/g)}},j.prototype.batchUpdate=function(){this.grid.batchUpdate()},j.prototype.commit=function(){this.grid.commit(),this._updateContainerHeight()},j.prototype.isAreaEmpty=function(a,b,c,d){return this.grid.isAreaEmpty(a,b,c,d)},j.prototype.setStatic=function(a){this.opts.staticGrid=a===!0,this.enableMove(!a),this.enableResize(!a),this._setStaticClass()},j.prototype._setStaticClass=function(){var a="grid-stack-static";this.opts.staticGrid===!0?this.container.addClass(a):this.container.removeClass(a)},j.prototype._updateNodeWidths=function(a,b){this.grid._sortNodes(),this.grid.batchUpdate();for(var c={},d=0;d Date: Tue, 10 Jan 2017 10:41:32 +0100 Subject: [PATCH 19/35] Improvements to counter the datawall overlaying bug nr2 --- src/gridstack.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/gridstack.js b/src/gridstack.js index c7695568b..ec983a19d 100644 --- a/src/gridstack.js +++ b/src/gridstack.js @@ -212,7 +212,7 @@ if (wrongPos) { // if the pos is out of bounds, put it on first available - newPos = this.findFreeSpace(collisionNode.width, collisionNode.height); + newPos = this.findFreeSpace(collisionNode.width, collisionNode.height, collisionNode); if (!newPos) { newPos = this.findFreeSpace(); } @@ -237,19 +237,20 @@ GridStackEngine.prototype.whatIsHere = function(x, y, width, height) { var nn = {x: x || 0, y: y || 0, width: width || 1, height: height || 1}; - var collisionNode = _.find(this.nodes, _.bind(function(n) { + var collisionNodes = _.filter(this.nodes, _.bind(function(n) { return Utils.isIntercepted(n, nn); }, this)); - return collisionNode; + return collisionNodes; }; GridStackEngine.prototype.isAreaEmpty = function(x, y, width, height) { - var collisionNode = this.whatIsHere(x, y, width, height); - return collisionNode === null || typeof collisionNode === 'undefined'; + var collisionNodes = this.whatIsHere(x, y, width, height); + return collisionNodes.length === 0; }; - GridStackEngine.prototype.findFreeSpace = function(w, h) { + GridStackEngine.prototype.findFreeSpace = function(w, h, forNode) { var freeSpace = null, + nodesHere = [], i, j; // first free for 1x1 or we have specified width and height @@ -264,8 +265,9 @@ if (freeSpace) { break; } - if (this.isAreaEmpty(i, j, w, h)) { - freeSpace = {x: i, y: j, w: w, h: h}; + nodesHere = this.whatIsHere(i, j, w, h); + if (!nodesHere.length || (forNode && nodesHere.length === 1 && nodesHere[0] === forNode)) { + freeSpace = {x: i, y: j, w: w, h: h}; } } } From af4623061abd20fe35953965881e844aad0baa79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Inga=20Br=C5=ABnava?= Date: Tue, 10 Jan 2017 10:43:09 +0100 Subject: [PATCH 20/35] Built assets --- dist/gridstack.all.js | 4 ++-- dist/gridstack.js | 18 ++++++++++-------- dist/gridstack.min.js | 4 ++-- dist/gridstack.min.map | 2 +- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/dist/gridstack.all.js b/dist/gridstack.all.js index 6fc0fc91f..f4b9c2a31 100644 --- a/dist/gridstack.all.js +++ b/dist/gridstack.all.js @@ -19,9 +19,9 @@ i.prototype.getNodeDataByDOMEl=function(a){return b.find(this.nodes,function(b){ // will try to fix the collision var h,i=(a.y+a.height,!c&&a.y+a.height+f.height>this.height);if(i){if( // if the pos is out of bounds, put it on first available -h=this.findFreeSpace(f.width,f.height),h||(h=this.findFreeSpace()),!h)return}else h={x:f.x,y:a.y+a.height,w:f.width,h:f.height};h&&this.moveNode(f,h.x,h.y,h.w,h.h,!0,c)}},i.prototype.whatIsHere=function(a,c,d,e){var f={x:a||0,y:c||0,width:d||1,height:e||1},h=b.find(this.nodes,b.bind(function(a){return g.isIntercepted(a,f)},this));return h},i.prototype.isAreaEmpty=function(a,b,c,d){var e=this.whatIsHere(a,b,c,d);return null===e||"undefined"==typeof e},i.prototype.findFreeSpace=function(a,b){var c,d,e=null;for( +h=this.findFreeSpace(f.width,f.height,f),h||(h=this.findFreeSpace()),!h)return}else h={x:f.x,y:a.y+a.height,w:f.width,h:f.height};h&&this.moveNode(f,h.x,h.y,h.w,h.h,!0,c)}},i.prototype.whatIsHere=function(a,c,d,e){var f={x:a||0,y:c||0,width:d||1,height:e||1},h=b.filter(this.nodes,b.bind(function(a){return g.isIntercepted(a,f)},this));return h},i.prototype.isAreaEmpty=function(a,b,c,d){var e=this.whatIsHere(a,b,c,d);return 0===e.length},i.prototype.findFreeSpace=function(a,b,c){var d,e,f=null,g=[];for( // first free for 1x1 or we have specified width and height -a||(a=1),b||(b=1),c=0;c<=this.width-a&&!e;c++)for(d=0;d<=this.height-b&&!e;d++)this.isAreaEmpty(c,d,a,b)&&(e={x:c,y:d,w:a,h:b});return e},i.prototype._sortNodes=function(a){this.nodes=g.sort(this.nodes,a,this.width)},i.prototype._packNodes=function(){this._sortNodes(),this["float"]?b.each(this.nodes,b.bind(function(a,c){if(!a._updating&&"undefined"!=typeof a._origY&&a.y!=a._origY)for(var d=a.y;d>=a._origY;){var e=b.chain(this.nodes).find(b.bind(g._didCollide,{n:a,newY:d})).value();e||(a._dirty=!0,a.y=d),--d}},this)):b.each(this.nodes,b.bind(function(a,c){if(!a.locked)for(;a.y>0;){var d=a.y-1,e=0===c;if(c>0){var f=b.chain(this.nodes).take(c).find(b.bind(g._didCollide,{n:a,newY:d})).value();e="undefined"==typeof f}if(!e)break;a._dirty=a.y!=d,a.y=d}},this))},i.prototype._prepareNode=function(a,c){return a=b.defaults(a||{},{width:1,height:1,x:0,y:0}),a.x=parseInt(""+a.x),a.y=parseInt(""+a.y),a.width=parseInt(""+a.width),a.height=parseInt(""+a.height),a.autoPosition=a.autoPosition||!1,a.noResize=a.noResize||!1,a.noMove=a.noMove||!1,a.width>this.width?a.width=this.width:a.width<1&&(a.width=1),this.height&&a.height>this.height?a.height=this.height:a.height<1&&(a.height=1),a.x<0&&(a.x=0),a.x+a.width>this.width&&(c?a.width=this.width-a.x:a.x=this.width-a.width),a.y<0&&(a.y=0),a},i.prototype._notify=function(){var a=Array.prototype.slice.call(arguments,0);if(a[0]="undefined"==typeof a[0]?[]:[a[0]],a[1]="undefined"==typeof a[1]||a[1],!this._updateCounter){var b=a[0].concat(this.getDirtyNodes());this.onchange(b,a[1])}},i.prototype.cleanNodes=function(){this._updateCounter||b.each(this.nodes,function(a){a._dirty=!1})},i.prototype.getDirtyNodes=function(){return b.filter(this.nodes,function(a){return a._dirty})},i.prototype.addNode=function(a,c,d){if(a=this._prepareNode(a),"undefined"!=typeof a.maxWidth&&(a.width=Math.min(a.width,a.maxWidth)),"undefined"!=typeof a.maxHeight&&(a.height=Math.min(a.height,a.maxHeight)),"undefined"!=typeof a.minWidth&&(a.width=Math.max(a.width,a.minWidth)),"undefined"!=typeof a.minHeight&&(a.height=Math.max(a.height,a.minHeight)),a._id=++h,a._dirty=!0,a.autoPosition){this._sortNodes();for(var e=0;;++e){var f=e%this.width,i=Math.floor(e/this.width);if(!(f+a.width>this.width||b.find(this.nodes,b.bind(g._isAddNodeIntercepted,{x:f,y:i,node:a})))){a.x=f,a.y=i;break}}}return this.nodes.push(a),"undefined"!=typeof c&&c&&this._addedNodes.push(b.clone(a)),this._fixCollisions(a,d),this._packNodes(),this._notify(),a},i.prototype.removeNode=function(a,c){a&&(a._id=null,this.nodes=b.without(this.nodes,a),this._packNodes(),this._notify(a,c))},i.prototype.canMoveNode=function(c,d,e,f,g){if(!this.isNodeChangedPosition(c,d,e,f,g))return!1;var h=Boolean(b.find(this.nodes,function(a){return a.locked}));if(!this.height&&!h)return!0;var j,k=new i(this.width,null,this["float"],0,b.map(this.nodes,function(b){return b==c?j=a.extend({},b):a.extend({},b)}));if("undefined"==typeof j)return!0;k.moveNode(j,d,e,f,g,!1,!0);var l=!0; +a||(a=1),b||(b=1),d=0;d<=this.width-a&&!f;d++)for(e=0;e<=this.height-b&&!f;e++)g=this.whatIsHere(d,e,a,b),(!g.length||c&&1===g.length&&g[0]===c)&&(f={x:d,y:e,w:a,h:b});return f},i.prototype._sortNodes=function(a){this.nodes=g.sort(this.nodes,a,this.width)},i.prototype._packNodes=function(){this._sortNodes(),this["float"]?b.each(this.nodes,b.bind(function(a,c){if(!a._updating&&"undefined"!=typeof a._origY&&a.y!=a._origY)for(var d=a.y;d>=a._origY;){var e=b.chain(this.nodes).find(b.bind(g._didCollide,{n:a,newY:d})).value();e||(a._dirty=!0,a.y=d),--d}},this)):b.each(this.nodes,b.bind(function(a,c){if(!a.locked)for(;a.y>0;){var d=a.y-1,e=0===c;if(c>0){var f=b.chain(this.nodes).take(c).find(b.bind(g._didCollide,{n:a,newY:d})).value();e="undefined"==typeof f}if(!e)break;a._dirty=a.y!=d,a.y=d}},this))},i.prototype._prepareNode=function(a,c){return a=b.defaults(a||{},{width:1,height:1,x:0,y:0}),a.x=parseInt(""+a.x),a.y=parseInt(""+a.y),a.width=parseInt(""+a.width),a.height=parseInt(""+a.height),a.autoPosition=a.autoPosition||!1,a.noResize=a.noResize||!1,a.noMove=a.noMove||!1,a.width>this.width?a.width=this.width:a.width<1&&(a.width=1),this.height&&a.height>this.height?a.height=this.height:a.height<1&&(a.height=1),a.x<0&&(a.x=0),a.x+a.width>this.width&&(c?a.width=this.width-a.x:a.x=this.width-a.width),a.y<0&&(a.y=0),a},i.prototype._notify=function(){var a=Array.prototype.slice.call(arguments,0);if(a[0]="undefined"==typeof a[0]?[]:[a[0]],a[1]="undefined"==typeof a[1]||a[1],!this._updateCounter){var b=a[0].concat(this.getDirtyNodes());this.onchange(b,a[1])}},i.prototype.cleanNodes=function(){this._updateCounter||b.each(this.nodes,function(a){a._dirty=!1})},i.prototype.getDirtyNodes=function(){return b.filter(this.nodes,function(a){return a._dirty})},i.prototype.addNode=function(a,c,d){if(a=this._prepareNode(a),"undefined"!=typeof a.maxWidth&&(a.width=Math.min(a.width,a.maxWidth)),"undefined"!=typeof a.maxHeight&&(a.height=Math.min(a.height,a.maxHeight)),"undefined"!=typeof a.minWidth&&(a.width=Math.max(a.width,a.minWidth)),"undefined"!=typeof a.minHeight&&(a.height=Math.max(a.height,a.minHeight)),a._id=++h,a._dirty=!0,a.autoPosition){this._sortNodes();for(var e=0;;++e){var f=e%this.width,i=Math.floor(e/this.width);if(!(f+a.width>this.width||b.find(this.nodes,b.bind(g._isAddNodeIntercepted,{x:f,y:i,node:a})))){a.x=f,a.y=i;break}}}return this.nodes.push(a),"undefined"!=typeof c&&c&&this._addedNodes.push(b.clone(a)),this._fixCollisions(a,d),this._packNodes(),this._notify(),a},i.prototype.removeNode=function(a,c){a&&(a._id=null,this.nodes=b.without(this.nodes,a),this._packNodes(),this._notify(a,c))},i.prototype.canMoveNode=function(c,d,e,f,g){if(!this.isNodeChangedPosition(c,d,e,f,g))return!1;var h=Boolean(b.find(this.nodes,function(a){return a.locked}));if(!this.height&&!h)return!0;var j,k=new i(this.width,null,this["float"],0,b.map(this.nodes,function(b){return b==c?j=a.extend({},b):a.extend({},b)}));if("undefined"==typeof j)return!0;k.moveNode(j,d,e,f,g,!1,!0);var l=!0; // always allow moving the one out of bounds return h&&(l&=!Boolean(b.find(k.nodes,function(a){return a!=j&&Boolean(a.locked)&&Boolean(a._dirty)}))),this.height&&(l&=k.getGridHeight()<=this.height,c.y+c.height>this.height&&(l=!0)),l},i.prototype.canBePlacedWithRespectToHeight=function(c){if(!this.height)return!0;var d=new i(this.width,null,this["float"],0,b.map(this.nodes,function(b){return a.extend({},b)}));return d.addNode(c,!1,!0),d.getGridHeight()<=this.height},i.prototype.isNodeChangedPosition=function(a,b,c,d,e){return"number"!=typeof b&&(b=a.x),"number"!=typeof c&&(c=a.y),"number"!=typeof d&&(d=a.width),"number"!=typeof e&&(e=a.height),"undefined"!=typeof a.maxWidth&&(d=Math.min(d,a.maxWidth)),"undefined"!=typeof a.maxHeight&&(e=Math.min(e,a.maxHeight)),"undefined"!=typeof a.minWidth&&(d=Math.max(d,a.minWidth)),"undefined"!=typeof a.minHeight&&(e=Math.max(e,a.minHeight)),a.x!=b||a.y!=c||a.width!=d||a.height!=e},i.prototype.moveNode=function(a,b,c,d,e,f,g){if(!this.isNodeChangedPosition(a,b,c,d,e))return a;if("number"!=typeof b&&(b=a.x),"number"!=typeof c&&(c=a.y),"number"!=typeof d&&(d=a.width),"number"!=typeof e&&(e=a.height),"undefined"!=typeof a.maxWidth&&(d=Math.min(d,a.maxWidth)),"undefined"!=typeof a.maxHeight&&(e=Math.min(e,a.maxHeight)),"undefined"!=typeof a.minWidth&&(d=Math.max(d,a.minWidth)),"undefined"!=typeof a.minHeight&&(e=Math.max(e,a.minHeight)),a.x==b&&a.y==c&&a.width==d&&a.height==e)return a;var h=a.width!=d;return a._dirty=!0,a.x=b,a.y=c,a.width=d,a.height=e,a.lastTriedX=b,a.lastTriedY=c,a.lastTriedWidth=d,a.lastTriedHeight=e,a=this._prepareNode(a,h),this._fixCollisions(a,g),f||(this._packNodes(),this._notify()),a},i.prototype.getGridHeight=function(){return b.reduce(this.nodes,function(a,b){return Math.max(a,b.y+b.height)},0)},i.prototype.beginUpdate=function(a){b.each(this.nodes,function(a){a._origY=a.y}),a._updating=!0},i.prototype.endUpdate=function(){b.each(this.nodes,function(a){a._origY=a.y});var a=b.find(this.nodes,function(a){return a._updating});a&&(a._updating=!1)};var j=function(d,e){var g,h,j=this;e=e||{},this.container=a(d), // jscs:disable requireCamelCaseOrUpperCaseIdentifiers diff --git a/dist/gridstack.js b/dist/gridstack.js index c7695568b..ec983a19d 100644 --- a/dist/gridstack.js +++ b/dist/gridstack.js @@ -212,7 +212,7 @@ if (wrongPos) { // if the pos is out of bounds, put it on first available - newPos = this.findFreeSpace(collisionNode.width, collisionNode.height); + newPos = this.findFreeSpace(collisionNode.width, collisionNode.height, collisionNode); if (!newPos) { newPos = this.findFreeSpace(); } @@ -237,19 +237,20 @@ GridStackEngine.prototype.whatIsHere = function(x, y, width, height) { var nn = {x: x || 0, y: y || 0, width: width || 1, height: height || 1}; - var collisionNode = _.find(this.nodes, _.bind(function(n) { + var collisionNodes = _.filter(this.nodes, _.bind(function(n) { return Utils.isIntercepted(n, nn); }, this)); - return collisionNode; + return collisionNodes; }; GridStackEngine.prototype.isAreaEmpty = function(x, y, width, height) { - var collisionNode = this.whatIsHere(x, y, width, height); - return collisionNode === null || typeof collisionNode === 'undefined'; + var collisionNodes = this.whatIsHere(x, y, width, height); + return collisionNodes.length === 0; }; - GridStackEngine.prototype.findFreeSpace = function(w, h) { + GridStackEngine.prototype.findFreeSpace = function(w, h, forNode) { var freeSpace = null, + nodesHere = [], i, j; // first free for 1x1 or we have specified width and height @@ -264,8 +265,9 @@ if (freeSpace) { break; } - if (this.isAreaEmpty(i, j, w, h)) { - freeSpace = {x: i, y: j, w: w, h: h}; + nodesHere = this.whatIsHere(i, j, w, h); + if (!nodesHere.length || (forNode && nodesHere.length === 1 && nodesHere[0] === forNode)) { + freeSpace = {x: i, y: j, w: w, h: h}; } } } diff --git a/dist/gridstack.min.js b/dist/gridstack.min.js index 44d2a7a99..6e80d84da 100644 --- a/dist/gridstack.min.js +++ b/dist/gridstack.min.js @@ -19,9 +19,9 @@ i.prototype.getNodeDataByDOMEl=function(a){return b.find(this.nodes,function(b){ // will try to fix the collision var h,i=(a.y+a.height,!c&&a.y+a.height+f.height>this.height);if(i){if( // if the pos is out of bounds, put it on first available -h=this.findFreeSpace(f.width,f.height),h||(h=this.findFreeSpace()),!h)return}else h={x:f.x,y:a.y+a.height,w:f.width,h:f.height};h&&this.moveNode(f,h.x,h.y,h.w,h.h,!0,c)}},i.prototype.whatIsHere=function(a,c,d,e){var f={x:a||0,y:c||0,width:d||1,height:e||1},h=b.find(this.nodes,b.bind(function(a){return g.isIntercepted(a,f)},this));return h},i.prototype.isAreaEmpty=function(a,b,c,d){var e=this.whatIsHere(a,b,c,d);return null===e||"undefined"==typeof e},i.prototype.findFreeSpace=function(a,b){var c,d,e=null;for( +h=this.findFreeSpace(f.width,f.height,f),h||(h=this.findFreeSpace()),!h)return}else h={x:f.x,y:a.y+a.height,w:f.width,h:f.height};h&&this.moveNode(f,h.x,h.y,h.w,h.h,!0,c)}},i.prototype.whatIsHere=function(a,c,d,e){var f={x:a||0,y:c||0,width:d||1,height:e||1},h=b.filter(this.nodes,b.bind(function(a){return g.isIntercepted(a,f)},this));return h},i.prototype.isAreaEmpty=function(a,b,c,d){var e=this.whatIsHere(a,b,c,d);return 0===e.length},i.prototype.findFreeSpace=function(a,b,c){var d,e,f=null,g=[];for( // first free for 1x1 or we have specified width and height -a||(a=1),b||(b=1),c=0;c<=this.width-a&&!e;c++)for(d=0;d<=this.height-b&&!e;d++)this.isAreaEmpty(c,d,a,b)&&(e={x:c,y:d,w:a,h:b});return e},i.prototype._sortNodes=function(a){this.nodes=g.sort(this.nodes,a,this.width)},i.prototype._packNodes=function(){this._sortNodes(),this["float"]?b.each(this.nodes,b.bind(function(a,c){if(!a._updating&&"undefined"!=typeof a._origY&&a.y!=a._origY)for(var d=a.y;d>=a._origY;){var e=b.chain(this.nodes).find(b.bind(g._didCollide,{n:a,newY:d})).value();e||(a._dirty=!0,a.y=d),--d}},this)):b.each(this.nodes,b.bind(function(a,c){if(!a.locked)for(;a.y>0;){var d=a.y-1,e=0===c;if(c>0){var f=b.chain(this.nodes).take(c).find(b.bind(g._didCollide,{n:a,newY:d})).value();e="undefined"==typeof f}if(!e)break;a._dirty=a.y!=d,a.y=d}},this))},i.prototype._prepareNode=function(a,c){return a=b.defaults(a||{},{width:1,height:1,x:0,y:0}),a.x=parseInt(""+a.x),a.y=parseInt(""+a.y),a.width=parseInt(""+a.width),a.height=parseInt(""+a.height),a.autoPosition=a.autoPosition||!1,a.noResize=a.noResize||!1,a.noMove=a.noMove||!1,a.width>this.width?a.width=this.width:a.width<1&&(a.width=1),this.height&&a.height>this.height?a.height=this.height:a.height<1&&(a.height=1),a.x<0&&(a.x=0),a.x+a.width>this.width&&(c?a.width=this.width-a.x:a.x=this.width-a.width),a.y<0&&(a.y=0),a},i.prototype._notify=function(){var a=Array.prototype.slice.call(arguments,0);if(a[0]="undefined"==typeof a[0]?[]:[a[0]],a[1]="undefined"==typeof a[1]||a[1],!this._updateCounter){var b=a[0].concat(this.getDirtyNodes());this.onchange(b,a[1])}},i.prototype.cleanNodes=function(){this._updateCounter||b.each(this.nodes,function(a){a._dirty=!1})},i.prototype.getDirtyNodes=function(){return b.filter(this.nodes,function(a){return a._dirty})},i.prototype.addNode=function(a,c,d){if(a=this._prepareNode(a),"undefined"!=typeof a.maxWidth&&(a.width=Math.min(a.width,a.maxWidth)),"undefined"!=typeof a.maxHeight&&(a.height=Math.min(a.height,a.maxHeight)),"undefined"!=typeof a.minWidth&&(a.width=Math.max(a.width,a.minWidth)),"undefined"!=typeof a.minHeight&&(a.height=Math.max(a.height,a.minHeight)),a._id=++h,a._dirty=!0,a.autoPosition){this._sortNodes();for(var e=0;;++e){var f=e%this.width,i=Math.floor(e/this.width);if(!(f+a.width>this.width||b.find(this.nodes,b.bind(g._isAddNodeIntercepted,{x:f,y:i,node:a})))){a.x=f,a.y=i;break}}}return this.nodes.push(a),"undefined"!=typeof c&&c&&this._addedNodes.push(b.clone(a)),this._fixCollisions(a,d),this._packNodes(),this._notify(),a},i.prototype.removeNode=function(a,c){a&&(a._id=null,this.nodes=b.without(this.nodes,a),this._packNodes(),this._notify(a,c))},i.prototype.canMoveNode=function(c,d,e,f,g){if(!this.isNodeChangedPosition(c,d,e,f,g))return!1;var h=Boolean(b.find(this.nodes,function(a){return a.locked}));if(!this.height&&!h)return!0;var j,k=new i(this.width,null,this["float"],0,b.map(this.nodes,function(b){return b==c?j=a.extend({},b):a.extend({},b)}));if("undefined"==typeof j)return!0;k.moveNode(j,d,e,f,g,!1,!0);var l=!0; +a||(a=1),b||(b=1),d=0;d<=this.width-a&&!f;d++)for(e=0;e<=this.height-b&&!f;e++)g=this.whatIsHere(d,e,a,b),(!g.length||c&&1===g.length&&g[0]===c)&&(f={x:d,y:e,w:a,h:b});return f},i.prototype._sortNodes=function(a){this.nodes=g.sort(this.nodes,a,this.width)},i.prototype._packNodes=function(){this._sortNodes(),this["float"]?b.each(this.nodes,b.bind(function(a,c){if(!a._updating&&"undefined"!=typeof a._origY&&a.y!=a._origY)for(var d=a.y;d>=a._origY;){var e=b.chain(this.nodes).find(b.bind(g._didCollide,{n:a,newY:d})).value();e||(a._dirty=!0,a.y=d),--d}},this)):b.each(this.nodes,b.bind(function(a,c){if(!a.locked)for(;a.y>0;){var d=a.y-1,e=0===c;if(c>0){var f=b.chain(this.nodes).take(c).find(b.bind(g._didCollide,{n:a,newY:d})).value();e="undefined"==typeof f}if(!e)break;a._dirty=a.y!=d,a.y=d}},this))},i.prototype._prepareNode=function(a,c){return a=b.defaults(a||{},{width:1,height:1,x:0,y:0}),a.x=parseInt(""+a.x),a.y=parseInt(""+a.y),a.width=parseInt(""+a.width),a.height=parseInt(""+a.height),a.autoPosition=a.autoPosition||!1,a.noResize=a.noResize||!1,a.noMove=a.noMove||!1,a.width>this.width?a.width=this.width:a.width<1&&(a.width=1),this.height&&a.height>this.height?a.height=this.height:a.height<1&&(a.height=1),a.x<0&&(a.x=0),a.x+a.width>this.width&&(c?a.width=this.width-a.x:a.x=this.width-a.width),a.y<0&&(a.y=0),a},i.prototype._notify=function(){var a=Array.prototype.slice.call(arguments,0);if(a[0]="undefined"==typeof a[0]?[]:[a[0]],a[1]="undefined"==typeof a[1]||a[1],!this._updateCounter){var b=a[0].concat(this.getDirtyNodes());this.onchange(b,a[1])}},i.prototype.cleanNodes=function(){this._updateCounter||b.each(this.nodes,function(a){a._dirty=!1})},i.prototype.getDirtyNodes=function(){return b.filter(this.nodes,function(a){return a._dirty})},i.prototype.addNode=function(a,c,d){if(a=this._prepareNode(a),"undefined"!=typeof a.maxWidth&&(a.width=Math.min(a.width,a.maxWidth)),"undefined"!=typeof a.maxHeight&&(a.height=Math.min(a.height,a.maxHeight)),"undefined"!=typeof a.minWidth&&(a.width=Math.max(a.width,a.minWidth)),"undefined"!=typeof a.minHeight&&(a.height=Math.max(a.height,a.minHeight)),a._id=++h,a._dirty=!0,a.autoPosition){this._sortNodes();for(var e=0;;++e){var f=e%this.width,i=Math.floor(e/this.width);if(!(f+a.width>this.width||b.find(this.nodes,b.bind(g._isAddNodeIntercepted,{x:f,y:i,node:a})))){a.x=f,a.y=i;break}}}return this.nodes.push(a),"undefined"!=typeof c&&c&&this._addedNodes.push(b.clone(a)),this._fixCollisions(a,d),this._packNodes(),this._notify(),a},i.prototype.removeNode=function(a,c){a&&(a._id=null,this.nodes=b.without(this.nodes,a),this._packNodes(),this._notify(a,c))},i.prototype.canMoveNode=function(c,d,e,f,g){if(!this.isNodeChangedPosition(c,d,e,f,g))return!1;var h=Boolean(b.find(this.nodes,function(a){return a.locked}));if(!this.height&&!h)return!0;var j,k=new i(this.width,null,this["float"],0,b.map(this.nodes,function(b){return b==c?j=a.extend({},b):a.extend({},b)}));if("undefined"==typeof j)return!0;k.moveNode(j,d,e,f,g,!1,!0);var l=!0; // always allow moving the one out of bounds return h&&(l&=!Boolean(b.find(k.nodes,function(a){return a!=j&&Boolean(a.locked)&&Boolean(a._dirty)}))),this.height&&(l&=k.getGridHeight()<=this.height,c.y+c.height>this.height&&(l=!0)),l},i.prototype.canBePlacedWithRespectToHeight=function(c){if(!this.height)return!0;var d=new i(this.width,null,this["float"],0,b.map(this.nodes,function(b){return a.extend({},b)}));return d.addNode(c,!1,!0),d.getGridHeight()<=this.height},i.prototype.isNodeChangedPosition=function(a,b,c,d,e){return"number"!=typeof b&&(b=a.x),"number"!=typeof c&&(c=a.y),"number"!=typeof d&&(d=a.width),"number"!=typeof e&&(e=a.height),"undefined"!=typeof a.maxWidth&&(d=Math.min(d,a.maxWidth)),"undefined"!=typeof a.maxHeight&&(e=Math.min(e,a.maxHeight)),"undefined"!=typeof a.minWidth&&(d=Math.max(d,a.minWidth)),"undefined"!=typeof a.minHeight&&(e=Math.max(e,a.minHeight)),a.x!=b||a.y!=c||a.width!=d||a.height!=e},i.prototype.moveNode=function(a,b,c,d,e,f,g){if(!this.isNodeChangedPosition(a,b,c,d,e))return a;if("number"!=typeof b&&(b=a.x),"number"!=typeof c&&(c=a.y),"number"!=typeof d&&(d=a.width),"number"!=typeof e&&(e=a.height),"undefined"!=typeof a.maxWidth&&(d=Math.min(d,a.maxWidth)),"undefined"!=typeof a.maxHeight&&(e=Math.min(e,a.maxHeight)),"undefined"!=typeof a.minWidth&&(d=Math.max(d,a.minWidth)),"undefined"!=typeof a.minHeight&&(e=Math.max(e,a.minHeight)),a.x==b&&a.y==c&&a.width==d&&a.height==e)return a;var h=a.width!=d;return a._dirty=!0,a.x=b,a.y=c,a.width=d,a.height=e,a.lastTriedX=b,a.lastTriedY=c,a.lastTriedWidth=d,a.lastTriedHeight=e,a=this._prepareNode(a,h),this._fixCollisions(a,g),f||(this._packNodes(),this._notify()),a},i.prototype.getGridHeight=function(){return b.reduce(this.nodes,function(a,b){return Math.max(a,b.y+b.height)},0)},i.prototype.beginUpdate=function(a){b.each(this.nodes,function(a){a._origY=a.y}),a._updating=!0},i.prototype.endUpdate=function(){b.each(this.nodes,function(a){a._origY=a.y});var a=b.find(this.nodes,function(a){return a._updating});a&&(a._updating=!1)};var j=function(d,e){var g,h,j=this;e=e||{},this.container=a(d), // jscs:disable requireCamelCaseOrUpperCaseIdentifiers diff --git a/dist/gridstack.min.map b/dist/gridstack.min.map index f4e479891..7a5e1c85b 100644 --- a/dist/gridstack.min.map +++ b/dist/gridstack.min.map @@ -1 +1 @@ -{"version":3,"sources":["../src/gridstack.js","../src/gridstack.jQueryUI.js"],"names":["factory","define","amd","exports","jQuery","require","e","_","$","GridStackDragDropPlugin","grid","this","scope","window","obsolete","f","oldName","newName","wrapper","console","warn","apply","arguments","prototype","obsoleteOpts","Utils","isIntercepted","a","b","x","width","y","height","sort","nodes","dir","chain","map","node","max","value","sortBy","n","createStylesheet","id","style","document","createElement","setAttribute","styleSheet","cssText","appendChild","createTextNode","getElementsByTagName","sheet","removeStylesheet","remove","insertCSSRule","selector","rules","index","insertRule","addRule","toBool","v","toLowerCase","Boolean","_collisionNodeCheck","nn","_didCollide","bn","newY","_isAddNodeIntercepted","parseHeight","val","heightUnit","isString","match","Error","parseFloat","unit","is_intercepted","create_stylesheet","remove_stylesheet","insert_css_rule","registeredPlugins","registerPlugin","pluginClass","push","resizable","el","opts","draggable","droppable","isDroppable","on","eventName","callback","idSeq","GridStackEngine","onchange","floatMode","items","_updateCounter","_float","_addedNodes","_removedNodes","batchUpdate","commit","_packNodes","_notify","getNodeDataByDOMEl","find","get","_fixCollisions","isClone","_sortNodes","hasLocked","locked","collisionNode","bind","newPos","wrongPos","findFreeSpace","w","h","moveNode","whatIsHere","isAreaEmpty","i","j","freeSpace","each","_updating","_origY","_dirty","canBeMoved","take","_prepareNode","resizing","defaults","parseInt","autoPosition","noResize","noMove","args","Array","slice","call","deletedNodes","concat","getDirtyNodes","cleanNodes","filter","addNode","triggerAddEvent","maxWidth","Math","min","maxHeight","minWidth","minHeight","_id","floor","clone","removeNode","detachNode","without","canMoveNode","isNodeChangedPosition","clonedNode","extend","res","getGridHeight","canBePlacedWithRespectToHeight","noPack","lastTriedX","lastTriedY","lastTriedWidth","lastTriedHeight","reduce","memo","beginUpdate","endUpdate","GridStack","oneColumnMode","isAutoCellHeight","self","container","handle_class","handleClass","item_class","itemClass","placeholder_class","placeholderClass","placeholder_text","placeholderText","cell_height","cellHeight","vertical_margin","verticalMargin","min_width","static_grid","staticGrid","is_nested","isNested","always_show_resize_handle","alwaysShowResizeHandle","closest","length","attr","handle","auto","float","_class","random","toFixed","animate","autoHide","handles","scroll","appendTo","disableDrag","disableResize","rtl","removable","removeTimeout","verticalMarginUnit","cellHeightUnit","oneColumnModeClass","ddPlugin","first","dd","css","addClass","cellWidth","_setStaticClass","_initStyles","_updateStyles","max_height","elements","_this","children","_prepareElement","setAnimation","placeholder","hide","_updateContainerHeight","_updateHeightsOnResize","throttle","onResizeHandler","_isOneColumnMode","append","trigger","removeClass","resize","trashZone","accept","event","ui","data","_grid","_setupRemovingTimeout","_clearRemovingTimeout","acceptWidgets","draggingElement","onDrag","pos","getCellFromPixel","offset","_added","show","_beforeDragX","_beforeDragY","is","origNode","ceil","outerWidth","outerHeight","_temporary","unbind","detach","removeAttr","enableSelection","removeData","_prepareElementsByNode","_triggerChangeEvent","forceTrigger","hasChanges","eventParams","_triggerAddEvent","_triggerRemoveEvent","_stylesId","_styles","_max","getHeight","prefix","nbRows","nbMargins","innerWidth","documentElement","clientWidth","body","_removeTimeout","setTimeout","_isAboutToRemove","clearTimeout","dragOrResize","round","position","left","top","type","size","_temporaryRemoved","onStartMoving","originalEvent","target","o","strictCellHeight","onEndMoving","forceNotify","nestedGrids","start","stop","drag","enable","addWidget","makeWidget","willItFit","removeWidget","removeAll","destroy","detachGrid","off","disable","movable","enableMove","doEnable","includeNewWidgets","enableResize","isNaN","_updateElement","move","update","noUpdate","heightData","useOffset","containerPos","relativeLeft","relativeTop","columnWidth","rowHeight","setStatic","staticValue","staticClassName","refreshNodes","isDisabled","that","k","getCellFromAbsolutePixel","nodeOffset","_updateNodeWidths","oldWidth","newWidth","undefined","setGridWidth","gridWidth","doNotPropagate","batch_update","_fix_collisions","is_area_empty","_sort_nodes","_pack_nodes","_prepare_node","clean_nodes","get_dirty_nodes","add_node","remove_node","can_move_node","move_node","get_grid_height","begin_update","end_update","can_be_placed_with_respect_to_height","_trigger_change_event","_init_styles","_update_styles","_update_container_height","_is_one_column_mode","_prepare_element","set_animation","add_widget","make_widget","will_it_fit","remove_widget","remove_all","min_height","_update_element","cell_width","get_cell_from_pixel","set_static","_set_static_class","GridStackUI","Engine","fn","gridstack","JQueryUIGridStackDragDropPlugin","Object","create","constructor","key","containment","parent"],"mappings":";;;;;;;CAOA,SAAUA,GACN,GAAsB,kBAAXC,SAAyBA,OAAOC,IACvCD,QAAQ,SAAU,UAAWD,OAC1B,IAAuB,mBAAZG,SAAyB,CACvC,IAAMC,OAASC,QAAQ,UAAa,MAAOC,IAC3C,IAAMC,EAAIF,QAAQ,UAAa,MAAOC,IACtCN,EAAQI,OAAQG,OAEhBP,GAAQI,OAAQG,IAErB,SAASC,EAAGD;;;;;;AA4GX,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4Y","file":"gridstack.all.js"} \ No newline at end of file +{"version":3,"sources":["../src/gridstack.js","../src/gridstack.jQueryUI.js"],"names":["factory","define","amd","exports","jQuery","require","e","_","$","GridStackDragDropPlugin","grid","this","scope","window","obsolete","f","oldName","newName","wrapper","console","warn","apply","arguments","prototype","obsoleteOpts","Utils","isIntercepted","a","b","x","width","y","height","sort","nodes","dir","chain","map","node","max","value","sortBy","n","createStylesheet","id","style","document","createElement","setAttribute","styleSheet","cssText","appendChild","createTextNode","getElementsByTagName","sheet","removeStylesheet","remove","insertCSSRule","selector","rules","index","insertRule","addRule","toBool","v","toLowerCase","Boolean","_collisionNodeCheck","nn","_didCollide","bn","newY","_isAddNodeIntercepted","parseHeight","val","heightUnit","isString","match","Error","parseFloat","unit","is_intercepted","create_stylesheet","remove_stylesheet","insert_css_rule","registeredPlugins","registerPlugin","pluginClass","push","resizable","el","opts","draggable","droppable","isDroppable","on","eventName","callback","idSeq","GridStackEngine","onchange","floatMode","items","_updateCounter","_float","_addedNodes","_removedNodes","batchUpdate","commit","_packNodes","_notify","getNodeDataByDOMEl","find","get","_fixCollisions","isClone","_sortNodes","hasLocked","locked","collisionNode","bind","newPos","wrongPos","findFreeSpace","w","h","moveNode","whatIsHere","collisionNodes","filter","isAreaEmpty","length","forNode","i","j","freeSpace","nodesHere","each","_updating","_origY","_dirty","canBeMoved","take","_prepareNode","resizing","defaults","parseInt","autoPosition","noResize","noMove","args","Array","slice","call","deletedNodes","concat","getDirtyNodes","cleanNodes","addNode","triggerAddEvent","maxWidth","Math","min","maxHeight","minWidth","minHeight","_id","floor","clone","removeNode","detachNode","without","canMoveNode","isNodeChangedPosition","clonedNode","extend","res","getGridHeight","canBePlacedWithRespectToHeight","noPack","lastTriedX","lastTriedY","lastTriedWidth","lastTriedHeight","reduce","memo","beginUpdate","endUpdate","GridStack","oneColumnMode","isAutoCellHeight","self","container","handle_class","handleClass","item_class","itemClass","placeholder_class","placeholderClass","placeholder_text","placeholderText","cell_height","cellHeight","vertical_margin","verticalMargin","min_width","static_grid","staticGrid","is_nested","isNested","always_show_resize_handle","alwaysShowResizeHandle","closest","attr","handle","auto","float","_class","random","toFixed","animate","autoHide","handles","scroll","appendTo","disableDrag","disableResize","rtl","removable","removeTimeout","verticalMarginUnit","cellHeightUnit","oneColumnModeClass","ddPlugin","first","dd","css","addClass","cellWidth","_setStaticClass","_initStyles","_updateStyles","max_height","elements","_this","children","_prepareElement","setAnimation","placeholder","hide","_updateContainerHeight","_updateHeightsOnResize","throttle","onResizeHandler","_isOneColumnMode","append","trigger","removeClass","resize","trashZone","accept","event","ui","data","_grid","_setupRemovingTimeout","_clearRemovingTimeout","acceptWidgets","draggingElement","onDrag","pos","getCellFromPixel","offset","_added","show","_beforeDragX","_beforeDragY","is","origNode","ceil","outerWidth","outerHeight","_temporary","unbind","detach","removeAttr","enableSelection","removeData","_prepareElementsByNode","_triggerChangeEvent","forceTrigger","hasChanges","eventParams","_triggerAddEvent","_triggerRemoveEvent","_stylesId","_styles","_max","getHeight","prefix","nbRows","nbMargins","innerWidth","documentElement","clientWidth","body","_removeTimeout","setTimeout","_isAboutToRemove","clearTimeout","dragOrResize","round","position","left","top","type","size","_temporaryRemoved","onStartMoving","originalEvent","target","o","strictCellHeight","onEndMoving","forceNotify","nestedGrids","start","stop","drag","enable","addWidget","makeWidget","willItFit","removeWidget","removeAll","destroy","detachGrid","off","disable","movable","enableMove","doEnable","includeNewWidgets","enableResize","isNaN","_updateElement","move","update","noUpdate","heightData","useOffset","containerPos","relativeLeft","relativeTop","columnWidth","rowHeight","setStatic","staticValue","staticClassName","refreshNodes","isDisabled","that","k","getCellFromAbsolutePixel","nodeOffset","_updateNodeWidths","oldWidth","newWidth","undefined","setGridWidth","gridWidth","doNotPropagate","batch_update","_fix_collisions","is_area_empty","_sort_nodes","_pack_nodes","_prepare_node","clean_nodes","get_dirty_nodes","add_node","remove_node","can_move_node","move_node","get_grid_height","begin_update","end_update","can_be_placed_with_respect_to_height","_trigger_change_event","_init_styles","_update_styles","_update_container_height","_is_one_column_mode","_prepare_element","set_animation","add_widget","make_widget","will_it_fit","remove_widget","remove_all","min_height","_update_element","cell_width","get_cell_from_pixel","set_static","_set_static_class","GridStackUI","Engine","fn","gridstack","JQueryUIGridStackDragDropPlugin","Object","create","constructor","key","containment","parent"],"mappings":";;;;;;;CAOA,SAAUA,GACN,GAAsB,kBAAXC,SAAyBA,OAAOC,IACvCD,QAAQ,SAAU,UAAWD,OAC1B,IAAuB,mBAAZG,SAAyB,CACvC,IAAMC,OAASC,QAAQ,UAAa,MAAOC,IAC3C,IAAMC,EAAIF,QAAQ,UAAa,MAAOC,IACtCN,EAAQI,OAAQG,OAEhBP,GAAQI,OAAQG,IAErB,SAASC,EAAGD;;;;;;AA4GX,QAASE,GAAwBC,GAC7BC,KAAKD,KAAOA,EA3GhB,GAAIE,GAAQC,OAERC,EAAW,SAASC,EAAGC,EAASC,GAChC,GAAIC,GAAU,WAGV,MAFAC,SAAQC,KAAK,2BAA6BJ,EAAU,4DACzCC,EAAU,iDACdF,EAAEM,MAAMV,KAAMW,WAIzB,OAFAJ,GAAQK,UAAYR,EAAEQ,UAEfL,GAGPM,EAAe,SAASR,EAASC,GACjCE,QAAQC,KAAK,yBAA2BJ,EAAU,4DAC9CC,EAAU,kDAGdQ,GACAC,cAAe,SAASC,EAAGC,GACvB,QAASD,EAAEE,EAAIF,EAAEG,OAASF,EAAEC,GAAKD,EAAEC,EAAID,EAAEE,OAASH,EAAEE,GAAKF,EAAEI,EAAIJ,EAAEK,QAAUJ,EAAEG,GAAKH,EAAEG,EAAIH,EAAEI,QAAUL,EAAEI,IAG1GE,KAAM,SAASC,EAAOC,EAAKL,GAGvB,MAFAA,GAAQA,GAASvB,EAAE6B,MAAMF,GAAOG,IAAI,SAASC,GAAQ,MAAOA,GAAKT,EAAIS,EAAKR,QAAUS,MAAMC,QAC1FL,EAAMA,MAAY,KACX5B,EAAEkC,OAAOP,EAAO,SAASQ,GAAK,MAAOP,IAAOO,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CmU,YAAapZ,KAAKD,KAAKiF,KAAKsH,SAAWtM,KAAKD,KAAKsL,UAAUgO,SAAW,KACtE1F,MAAO3O,EAAK2O,OAAS,aACrBC,KAAM5O,EAAK4O,MAAQ,aACnBC,KAAM7O,EAAK6O,MAAQ,gBAGpB7T,MAGX+Y,EAAgCnY,UAAUsE,UAAY,SAASH,EAAIC,GAS/D,MARAD,GAAKlF,EAAEkF,GACM,YAATC,GAA+B,WAATA,EACtBD,EAAGG,UAAUF,GAEbD,EAAGG,WACCuK,OAAQzK,EAAKyK,SAGdzP,MAGX+Y,EAAgCnY,UAAUuE,YAAc,SAASJ,EAAIC,GAEjE,MADAD,GAAKlF,EAAEkF,GACAxB,QAAQwB,EAAG6K,KAAK,eAG3BmJ,EAAgCnY,UAAUwE,GAAK,SAASL,EAAIM,EAAWC,GAEnE,MADAzF,GAAEkF,GAAIK,GAAGC,EAAWC,GACbtF,MAGJ+Y","file":"gridstack.all.js"} \ No newline at end of file From 547c21328920bd08623663b948624955e9880e28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Inga=20Br=C5=ABnava?= Date: Tue, 10 Jan 2017 12:38:45 +0100 Subject: [PATCH 21/35] Improvements to counter the datawall overlaying bug nr2 --- src/gridstack.js | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/src/gridstack.js b/src/gridstack.js index ec983a19d..b3cd41748 100644 --- a/src/gridstack.js +++ b/src/gridstack.js @@ -207,17 +207,26 @@ // will try to fix the collision var newPos, - newY = node.y + node.height, wrongPos = !isClone && ((node.y + node.height + collisionNode.height) > this.height); if (wrongPos) { - // if the pos is out of bounds, put it on first available - newPos = this.findFreeSpace(collisionNode.width, collisionNode.height, collisionNode); - if (!newPos) { - newPos = this.findFreeSpace(); - } - if (!newPos) { - return; // hmm + // check the original Y position first + if (this.isAreaEmpty(collisionNode.x, collisionNode._origY, collisionNode.width, collisionNode.height, collisionNode)) { + newPos = { + x: collisionNode.x, + y: collisionNode._origY, + w: collisionNode.width, + h: collisionNode.height + }; + } else { + // if the pos is out of bounds, put it on first available + newPos = this.findFreeSpace(collisionNode.width, collisionNode.height, collisionNode); + if (!newPos) { + newPos = this.findFreeSpace(); + } + if (!newPos) { + return; // hmm + } } } else { newPos = { @@ -229,7 +238,8 @@ } if (newPos) { - this.moveNode(collisionNode, newPos.x, newPos.y, newPos.w, newPos.h, true, isClone); + // all recursive collision fixes are treated like they are isClone true + this.moveNode(collisionNode, newPos.x, newPos.y, newPos.w, newPos.h, true, true); } } @@ -243,14 +253,13 @@ return collisionNodes; }; - GridStackEngine.prototype.isAreaEmpty = function(x, y, width, height) { - var collisionNodes = this.whatIsHere(x, y, width, height); - return collisionNodes.length === 0; + GridStackEngine.prototype.isAreaEmpty = function(x, y, width, height, exceptNode) { + var collisionNodes = this.whatIsHere(x, y, width, height); + return (!collisionNodes.length || (exceptNode && collisionNodes.length === 1 && collisionNodes[0] === exceptNode)); }; GridStackEngine.prototype.findFreeSpace = function(w, h, forNode) { var freeSpace = null, - nodesHere = [], i, j; // first free for 1x1 or we have specified width and height @@ -265,8 +274,7 @@ if (freeSpace) { break; } - nodesHere = this.whatIsHere(i, j, w, h); - if (!nodesHere.length || (forNode && nodesHere.length === 1 && nodesHere[0] === forNode)) { + if (this.isAreaEmpty(i, j, w, h, forNode)) { freeSpace = {x: i, y: j, w: w, h: h}; } } From 8694619cb436346373c732809154355df6fbfa60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Inga=20Br=C5=ABnava?= Date: Tue, 10 Jan 2017 12:40:36 +0100 Subject: [PATCH 22/35] Assets built --- dist/gridstack.all.js | 10 +++++++--- dist/gridstack.js | 38 +++++++++++++++++++++++--------------- dist/gridstack.min.js | 10 +++++++--- dist/gridstack.min.map | 2 +- 4 files changed, 38 insertions(+), 22 deletions(-) diff --git a/dist/gridstack.all.js b/dist/gridstack.all.js index f4b9c2a31..a8c002a21 100644 --- a/dist/gridstack.all.js +++ b/dist/gridstack.all.js @@ -17,11 +17,15 @@ g.is_intercepted=e(g.isIntercepted,"is_intercepted","isIntercepted"),g.create_st // For Meteor support: https://github.com/troolee/gridstack.js/pull/272 i.prototype.getNodeDataByDOMEl=function(a){return b.find(this.nodes,function(b){return a.get(0)===b.el.get(0)})},i.prototype._fixCollisions=function(a,c){this._sortNodes(-1);var d=a,e=Boolean(b.find(this.nodes,function(a){return a.locked}));for(this["float"]||e||(d={x:0,y:a.y,width:this.width,height:a.height});;){var f=b.find(this.nodes,b.bind(g._collisionNodeCheck,{node:a,nn:d}));if("undefined"==typeof f)return; // will try to fix the collision -var h,i=(a.y+a.height,!c&&a.y+a.height+f.height>this.height);if(i){if( +var h,i=!c&&a.y+a.height+f.height>this.height;if(i){ +// check the original Y position first +if(this.isAreaEmpty(f.x,f._origY,f.width,f.height,f))h={x:f.x,y:f._origY,w:f.width,h:f.height};else if( // if the pos is out of bounds, put it on first available -h=this.findFreeSpace(f.width,f.height,f),h||(h=this.findFreeSpace()),!h)return}else h={x:f.x,y:a.y+a.height,w:f.width,h:f.height};h&&this.moveNode(f,h.x,h.y,h.w,h.h,!0,c)}},i.prototype.whatIsHere=function(a,c,d,e){var f={x:a||0,y:c||0,width:d||1,height:e||1},h=b.filter(this.nodes,b.bind(function(a){return g.isIntercepted(a,f)},this));return h},i.prototype.isAreaEmpty=function(a,b,c,d){var e=this.whatIsHere(a,b,c,d);return 0===e.length},i.prototype.findFreeSpace=function(a,b,c){var d,e,f=null,g=[];for( +h=this.findFreeSpace(f.width,f.height,f),h||(h=this.findFreeSpace()),!h)return}else h={x:f.x,y:a.y+a.height,w:f.width,h:f.height};h&& +// all recursive collision fixes are treated like they are isClone true +this.moveNode(f,h.x,h.y,h.w,h.h,!0,!0)}},i.prototype.whatIsHere=function(a,c,d,e){var f={x:a||0,y:c||0,width:d||1,height:e||1},h=b.filter(this.nodes,b.bind(function(a){return g.isIntercepted(a,f)},this));return h},i.prototype.isAreaEmpty=function(a,b,c,d,e){var f=this.whatIsHere(a,b,c,d);return!f.length||e&&1===f.length&&f[0]===e},i.prototype.findFreeSpace=function(a,b,c){var d,e,f=null;for( // first free for 1x1 or we have specified width and height -a||(a=1),b||(b=1),d=0;d<=this.width-a&&!f;d++)for(e=0;e<=this.height-b&&!f;e++)g=this.whatIsHere(d,e,a,b),(!g.length||c&&1===g.length&&g[0]===c)&&(f={x:d,y:e,w:a,h:b});return f},i.prototype._sortNodes=function(a){this.nodes=g.sort(this.nodes,a,this.width)},i.prototype._packNodes=function(){this._sortNodes(),this["float"]?b.each(this.nodes,b.bind(function(a,c){if(!a._updating&&"undefined"!=typeof a._origY&&a.y!=a._origY)for(var d=a.y;d>=a._origY;){var e=b.chain(this.nodes).find(b.bind(g._didCollide,{n:a,newY:d})).value();e||(a._dirty=!0,a.y=d),--d}},this)):b.each(this.nodes,b.bind(function(a,c){if(!a.locked)for(;a.y>0;){var d=a.y-1,e=0===c;if(c>0){var f=b.chain(this.nodes).take(c).find(b.bind(g._didCollide,{n:a,newY:d})).value();e="undefined"==typeof f}if(!e)break;a._dirty=a.y!=d,a.y=d}},this))},i.prototype._prepareNode=function(a,c){return a=b.defaults(a||{},{width:1,height:1,x:0,y:0}),a.x=parseInt(""+a.x),a.y=parseInt(""+a.y),a.width=parseInt(""+a.width),a.height=parseInt(""+a.height),a.autoPosition=a.autoPosition||!1,a.noResize=a.noResize||!1,a.noMove=a.noMove||!1,a.width>this.width?a.width=this.width:a.width<1&&(a.width=1),this.height&&a.height>this.height?a.height=this.height:a.height<1&&(a.height=1),a.x<0&&(a.x=0),a.x+a.width>this.width&&(c?a.width=this.width-a.x:a.x=this.width-a.width),a.y<0&&(a.y=0),a},i.prototype._notify=function(){var a=Array.prototype.slice.call(arguments,0);if(a[0]="undefined"==typeof a[0]?[]:[a[0]],a[1]="undefined"==typeof a[1]||a[1],!this._updateCounter){var b=a[0].concat(this.getDirtyNodes());this.onchange(b,a[1])}},i.prototype.cleanNodes=function(){this._updateCounter||b.each(this.nodes,function(a){a._dirty=!1})},i.prototype.getDirtyNodes=function(){return b.filter(this.nodes,function(a){return a._dirty})},i.prototype.addNode=function(a,c,d){if(a=this._prepareNode(a),"undefined"!=typeof a.maxWidth&&(a.width=Math.min(a.width,a.maxWidth)),"undefined"!=typeof a.maxHeight&&(a.height=Math.min(a.height,a.maxHeight)),"undefined"!=typeof a.minWidth&&(a.width=Math.max(a.width,a.minWidth)),"undefined"!=typeof a.minHeight&&(a.height=Math.max(a.height,a.minHeight)),a._id=++h,a._dirty=!0,a.autoPosition){this._sortNodes();for(var e=0;;++e){var f=e%this.width,i=Math.floor(e/this.width);if(!(f+a.width>this.width||b.find(this.nodes,b.bind(g._isAddNodeIntercepted,{x:f,y:i,node:a})))){a.x=f,a.y=i;break}}}return this.nodes.push(a),"undefined"!=typeof c&&c&&this._addedNodes.push(b.clone(a)),this._fixCollisions(a,d),this._packNodes(),this._notify(),a},i.prototype.removeNode=function(a,c){a&&(a._id=null,this.nodes=b.without(this.nodes,a),this._packNodes(),this._notify(a,c))},i.prototype.canMoveNode=function(c,d,e,f,g){if(!this.isNodeChangedPosition(c,d,e,f,g))return!1;var h=Boolean(b.find(this.nodes,function(a){return a.locked}));if(!this.height&&!h)return!0;var j,k=new i(this.width,null,this["float"],0,b.map(this.nodes,function(b){return b==c?j=a.extend({},b):a.extend({},b)}));if("undefined"==typeof j)return!0;k.moveNode(j,d,e,f,g,!1,!0);var l=!0; +a||(a=1),b||(b=1),d=0;d<=this.width-a&&!f;d++)for(e=0;e<=this.height-b&&!f;e++)this.isAreaEmpty(d,e,a,b,c)&&(f={x:d,y:e,w:a,h:b});return f},i.prototype._sortNodes=function(a){this.nodes=g.sort(this.nodes,a,this.width)},i.prototype._packNodes=function(){this._sortNodes(),this["float"]?b.each(this.nodes,b.bind(function(a,c){if(!a._updating&&"undefined"!=typeof a._origY&&a.y!=a._origY)for(var d=a.y;d>=a._origY;){var e=b.chain(this.nodes).find(b.bind(g._didCollide,{n:a,newY:d})).value();e||(a._dirty=!0,a.y=d),--d}},this)):b.each(this.nodes,b.bind(function(a,c){if(!a.locked)for(;a.y>0;){var d=a.y-1,e=0===c;if(c>0){var f=b.chain(this.nodes).take(c).find(b.bind(g._didCollide,{n:a,newY:d})).value();e="undefined"==typeof f}if(!e)break;a._dirty=a.y!=d,a.y=d}},this))},i.prototype._prepareNode=function(a,c){return a=b.defaults(a||{},{width:1,height:1,x:0,y:0}),a.x=parseInt(""+a.x),a.y=parseInt(""+a.y),a.width=parseInt(""+a.width),a.height=parseInt(""+a.height),a.autoPosition=a.autoPosition||!1,a.noResize=a.noResize||!1,a.noMove=a.noMove||!1,a.width>this.width?a.width=this.width:a.width<1&&(a.width=1),this.height&&a.height>this.height?a.height=this.height:a.height<1&&(a.height=1),a.x<0&&(a.x=0),a.x+a.width>this.width&&(c?a.width=this.width-a.x:a.x=this.width-a.width),a.y<0&&(a.y=0),a},i.prototype._notify=function(){var a=Array.prototype.slice.call(arguments,0);if(a[0]="undefined"==typeof a[0]?[]:[a[0]],a[1]="undefined"==typeof a[1]||a[1],!this._updateCounter){var b=a[0].concat(this.getDirtyNodes());this.onchange(b,a[1])}},i.prototype.cleanNodes=function(){this._updateCounter||b.each(this.nodes,function(a){a._dirty=!1})},i.prototype.getDirtyNodes=function(){return b.filter(this.nodes,function(a){return a._dirty})},i.prototype.addNode=function(a,c,d){if(a=this._prepareNode(a),"undefined"!=typeof a.maxWidth&&(a.width=Math.min(a.width,a.maxWidth)),"undefined"!=typeof a.maxHeight&&(a.height=Math.min(a.height,a.maxHeight)),"undefined"!=typeof a.minWidth&&(a.width=Math.max(a.width,a.minWidth)),"undefined"!=typeof a.minHeight&&(a.height=Math.max(a.height,a.minHeight)),a._id=++h,a._dirty=!0,a.autoPosition){this._sortNodes();for(var e=0;;++e){var f=e%this.width,i=Math.floor(e/this.width);if(!(f+a.width>this.width||b.find(this.nodes,b.bind(g._isAddNodeIntercepted,{x:f,y:i,node:a})))){a.x=f,a.y=i;break}}}return this.nodes.push(a),"undefined"!=typeof c&&c&&this._addedNodes.push(b.clone(a)),this._fixCollisions(a,d),this._packNodes(),this._notify(),a},i.prototype.removeNode=function(a,c){a&&(a._id=null,this.nodes=b.without(this.nodes,a),this._packNodes(),this._notify(a,c))},i.prototype.canMoveNode=function(c,d,e,f,g){if(!this.isNodeChangedPosition(c,d,e,f,g))return!1;var h=Boolean(b.find(this.nodes,function(a){return a.locked}));if(!this.height&&!h)return!0;var j,k=new i(this.width,null,this["float"],0,b.map(this.nodes,function(b){return b==c?j=a.extend({},b):a.extend({},b)}));if("undefined"==typeof j)return!0;k.moveNode(j,d,e,f,g,!1,!0);var l=!0; // always allow moving the one out of bounds return h&&(l&=!Boolean(b.find(k.nodes,function(a){return a!=j&&Boolean(a.locked)&&Boolean(a._dirty)}))),this.height&&(l&=k.getGridHeight()<=this.height,c.y+c.height>this.height&&(l=!0)),l},i.prototype.canBePlacedWithRespectToHeight=function(c){if(!this.height)return!0;var d=new i(this.width,null,this["float"],0,b.map(this.nodes,function(b){return a.extend({},b)}));return d.addNode(c,!1,!0),d.getGridHeight()<=this.height},i.prototype.isNodeChangedPosition=function(a,b,c,d,e){return"number"!=typeof b&&(b=a.x),"number"!=typeof c&&(c=a.y),"number"!=typeof d&&(d=a.width),"number"!=typeof e&&(e=a.height),"undefined"!=typeof a.maxWidth&&(d=Math.min(d,a.maxWidth)),"undefined"!=typeof a.maxHeight&&(e=Math.min(e,a.maxHeight)),"undefined"!=typeof a.minWidth&&(d=Math.max(d,a.minWidth)),"undefined"!=typeof a.minHeight&&(e=Math.max(e,a.minHeight)),a.x!=b||a.y!=c||a.width!=d||a.height!=e},i.prototype.moveNode=function(a,b,c,d,e,f,g){if(!this.isNodeChangedPosition(a,b,c,d,e))return a;if("number"!=typeof b&&(b=a.x),"number"!=typeof c&&(c=a.y),"number"!=typeof d&&(d=a.width),"number"!=typeof e&&(e=a.height),"undefined"!=typeof a.maxWidth&&(d=Math.min(d,a.maxWidth)),"undefined"!=typeof a.maxHeight&&(e=Math.min(e,a.maxHeight)),"undefined"!=typeof a.minWidth&&(d=Math.max(d,a.minWidth)),"undefined"!=typeof a.minHeight&&(e=Math.max(e,a.minHeight)),a.x==b&&a.y==c&&a.width==d&&a.height==e)return a;var h=a.width!=d;return a._dirty=!0,a.x=b,a.y=c,a.width=d,a.height=e,a.lastTriedX=b,a.lastTriedY=c,a.lastTriedWidth=d,a.lastTriedHeight=e,a=this._prepareNode(a,h),this._fixCollisions(a,g),f||(this._packNodes(),this._notify()),a},i.prototype.getGridHeight=function(){return b.reduce(this.nodes,function(a,b){return Math.max(a,b.y+b.height)},0)},i.prototype.beginUpdate=function(a){b.each(this.nodes,function(a){a._origY=a.y}),a._updating=!0},i.prototype.endUpdate=function(){b.each(this.nodes,function(a){a._origY=a.y});var a=b.find(this.nodes,function(a){return a._updating});a&&(a._updating=!1)};var j=function(d,e){var g,h,j=this;e=e||{},this.container=a(d), // jscs:disable requireCamelCaseOrUpperCaseIdentifiers diff --git a/dist/gridstack.js b/dist/gridstack.js index ec983a19d..b3cd41748 100644 --- a/dist/gridstack.js +++ b/dist/gridstack.js @@ -207,17 +207,26 @@ // will try to fix the collision var newPos, - newY = node.y + node.height, wrongPos = !isClone && ((node.y + node.height + collisionNode.height) > this.height); if (wrongPos) { - // if the pos is out of bounds, put it on first available - newPos = this.findFreeSpace(collisionNode.width, collisionNode.height, collisionNode); - if (!newPos) { - newPos = this.findFreeSpace(); - } - if (!newPos) { - return; // hmm + // check the original Y position first + if (this.isAreaEmpty(collisionNode.x, collisionNode._origY, collisionNode.width, collisionNode.height, collisionNode)) { + newPos = { + x: collisionNode.x, + y: collisionNode._origY, + w: collisionNode.width, + h: collisionNode.height + }; + } else { + // if the pos is out of bounds, put it on first available + newPos = this.findFreeSpace(collisionNode.width, collisionNode.height, collisionNode); + if (!newPos) { + newPos = this.findFreeSpace(); + } + if (!newPos) { + return; // hmm + } } } else { newPos = { @@ -229,7 +238,8 @@ } if (newPos) { - this.moveNode(collisionNode, newPos.x, newPos.y, newPos.w, newPos.h, true, isClone); + // all recursive collision fixes are treated like they are isClone true + this.moveNode(collisionNode, newPos.x, newPos.y, newPos.w, newPos.h, true, true); } } @@ -243,14 +253,13 @@ return collisionNodes; }; - GridStackEngine.prototype.isAreaEmpty = function(x, y, width, height) { - var collisionNodes = this.whatIsHere(x, y, width, height); - return collisionNodes.length === 0; + GridStackEngine.prototype.isAreaEmpty = function(x, y, width, height, exceptNode) { + var collisionNodes = this.whatIsHere(x, y, width, height); + return (!collisionNodes.length || (exceptNode && collisionNodes.length === 1 && collisionNodes[0] === exceptNode)); }; GridStackEngine.prototype.findFreeSpace = function(w, h, forNode) { var freeSpace = null, - nodesHere = [], i, j; // first free for 1x1 or we have specified width and height @@ -265,8 +274,7 @@ if (freeSpace) { break; } - nodesHere = this.whatIsHere(i, j, w, h); - if (!nodesHere.length || (forNode && nodesHere.length === 1 && nodesHere[0] === forNode)) { + if (this.isAreaEmpty(i, j, w, h, forNode)) { freeSpace = {x: i, y: j, w: w, h: h}; } } diff --git a/dist/gridstack.min.js b/dist/gridstack.min.js index 6e80d84da..a30fe2e3e 100644 --- a/dist/gridstack.min.js +++ b/dist/gridstack.min.js @@ -17,11 +17,15 @@ g.is_intercepted=e(g.isIntercepted,"is_intercepted","isIntercepted"),g.create_st // For Meteor support: https://github.com/troolee/gridstack.js/pull/272 i.prototype.getNodeDataByDOMEl=function(a){return b.find(this.nodes,function(b){return a.get(0)===b.el.get(0)})},i.prototype._fixCollisions=function(a,c){this._sortNodes(-1);var d=a,e=Boolean(b.find(this.nodes,function(a){return a.locked}));for(this["float"]||e||(d={x:0,y:a.y,width:this.width,height:a.height});;){var f=b.find(this.nodes,b.bind(g._collisionNodeCheck,{node:a,nn:d}));if("undefined"==typeof f)return; // will try to fix the collision -var h,i=(a.y+a.height,!c&&a.y+a.height+f.height>this.height);if(i){if( +var h,i=!c&&a.y+a.height+f.height>this.height;if(i){ +// check the original Y position first +if(this.isAreaEmpty(f.x,f._origY,f.width,f.height,f))h={x:f.x,y:f._origY,w:f.width,h:f.height};else if( // if the pos is out of bounds, put it on first available -h=this.findFreeSpace(f.width,f.height,f),h||(h=this.findFreeSpace()),!h)return}else h={x:f.x,y:a.y+a.height,w:f.width,h:f.height};h&&this.moveNode(f,h.x,h.y,h.w,h.h,!0,c)}},i.prototype.whatIsHere=function(a,c,d,e){var f={x:a||0,y:c||0,width:d||1,height:e||1},h=b.filter(this.nodes,b.bind(function(a){return g.isIntercepted(a,f)},this));return h},i.prototype.isAreaEmpty=function(a,b,c,d){var e=this.whatIsHere(a,b,c,d);return 0===e.length},i.prototype.findFreeSpace=function(a,b,c){var d,e,f=null,g=[];for( +h=this.findFreeSpace(f.width,f.height,f),h||(h=this.findFreeSpace()),!h)return}else h={x:f.x,y:a.y+a.height,w:f.width,h:f.height};h&& +// all recursive collision fixes are treated like they are isClone true +this.moveNode(f,h.x,h.y,h.w,h.h,!0,!0)}},i.prototype.whatIsHere=function(a,c,d,e){var f={x:a||0,y:c||0,width:d||1,height:e||1},h=b.filter(this.nodes,b.bind(function(a){return g.isIntercepted(a,f)},this));return h},i.prototype.isAreaEmpty=function(a,b,c,d,e){var f=this.whatIsHere(a,b,c,d);return!f.length||e&&1===f.length&&f[0]===e},i.prototype.findFreeSpace=function(a,b,c){var d,e,f=null;for( // first free for 1x1 or we have specified width and height -a||(a=1),b||(b=1),d=0;d<=this.width-a&&!f;d++)for(e=0;e<=this.height-b&&!f;e++)g=this.whatIsHere(d,e,a,b),(!g.length||c&&1===g.length&&g[0]===c)&&(f={x:d,y:e,w:a,h:b});return f},i.prototype._sortNodes=function(a){this.nodes=g.sort(this.nodes,a,this.width)},i.prototype._packNodes=function(){this._sortNodes(),this["float"]?b.each(this.nodes,b.bind(function(a,c){if(!a._updating&&"undefined"!=typeof a._origY&&a.y!=a._origY)for(var d=a.y;d>=a._origY;){var e=b.chain(this.nodes).find(b.bind(g._didCollide,{n:a,newY:d})).value();e||(a._dirty=!0,a.y=d),--d}},this)):b.each(this.nodes,b.bind(function(a,c){if(!a.locked)for(;a.y>0;){var d=a.y-1,e=0===c;if(c>0){var f=b.chain(this.nodes).take(c).find(b.bind(g._didCollide,{n:a,newY:d})).value();e="undefined"==typeof f}if(!e)break;a._dirty=a.y!=d,a.y=d}},this))},i.prototype._prepareNode=function(a,c){return a=b.defaults(a||{},{width:1,height:1,x:0,y:0}),a.x=parseInt(""+a.x),a.y=parseInt(""+a.y),a.width=parseInt(""+a.width),a.height=parseInt(""+a.height),a.autoPosition=a.autoPosition||!1,a.noResize=a.noResize||!1,a.noMove=a.noMove||!1,a.width>this.width?a.width=this.width:a.width<1&&(a.width=1),this.height&&a.height>this.height?a.height=this.height:a.height<1&&(a.height=1),a.x<0&&(a.x=0),a.x+a.width>this.width&&(c?a.width=this.width-a.x:a.x=this.width-a.width),a.y<0&&(a.y=0),a},i.prototype._notify=function(){var a=Array.prototype.slice.call(arguments,0);if(a[0]="undefined"==typeof a[0]?[]:[a[0]],a[1]="undefined"==typeof a[1]||a[1],!this._updateCounter){var b=a[0].concat(this.getDirtyNodes());this.onchange(b,a[1])}},i.prototype.cleanNodes=function(){this._updateCounter||b.each(this.nodes,function(a){a._dirty=!1})},i.prototype.getDirtyNodes=function(){return b.filter(this.nodes,function(a){return a._dirty})},i.prototype.addNode=function(a,c,d){if(a=this._prepareNode(a),"undefined"!=typeof a.maxWidth&&(a.width=Math.min(a.width,a.maxWidth)),"undefined"!=typeof a.maxHeight&&(a.height=Math.min(a.height,a.maxHeight)),"undefined"!=typeof a.minWidth&&(a.width=Math.max(a.width,a.minWidth)),"undefined"!=typeof a.minHeight&&(a.height=Math.max(a.height,a.minHeight)),a._id=++h,a._dirty=!0,a.autoPosition){this._sortNodes();for(var e=0;;++e){var f=e%this.width,i=Math.floor(e/this.width);if(!(f+a.width>this.width||b.find(this.nodes,b.bind(g._isAddNodeIntercepted,{x:f,y:i,node:a})))){a.x=f,a.y=i;break}}}return this.nodes.push(a),"undefined"!=typeof c&&c&&this._addedNodes.push(b.clone(a)),this._fixCollisions(a,d),this._packNodes(),this._notify(),a},i.prototype.removeNode=function(a,c){a&&(a._id=null,this.nodes=b.without(this.nodes,a),this._packNodes(),this._notify(a,c))},i.prototype.canMoveNode=function(c,d,e,f,g){if(!this.isNodeChangedPosition(c,d,e,f,g))return!1;var h=Boolean(b.find(this.nodes,function(a){return a.locked}));if(!this.height&&!h)return!0;var j,k=new i(this.width,null,this["float"],0,b.map(this.nodes,function(b){return b==c?j=a.extend({},b):a.extend({},b)}));if("undefined"==typeof j)return!0;k.moveNode(j,d,e,f,g,!1,!0);var l=!0; +a||(a=1),b||(b=1),d=0;d<=this.width-a&&!f;d++)for(e=0;e<=this.height-b&&!f;e++)this.isAreaEmpty(d,e,a,b,c)&&(f={x:d,y:e,w:a,h:b});return f},i.prototype._sortNodes=function(a){this.nodes=g.sort(this.nodes,a,this.width)},i.prototype._packNodes=function(){this._sortNodes(),this["float"]?b.each(this.nodes,b.bind(function(a,c){if(!a._updating&&"undefined"!=typeof a._origY&&a.y!=a._origY)for(var d=a.y;d>=a._origY;){var e=b.chain(this.nodes).find(b.bind(g._didCollide,{n:a,newY:d})).value();e||(a._dirty=!0,a.y=d),--d}},this)):b.each(this.nodes,b.bind(function(a,c){if(!a.locked)for(;a.y>0;){var d=a.y-1,e=0===c;if(c>0){var f=b.chain(this.nodes).take(c).find(b.bind(g._didCollide,{n:a,newY:d})).value();e="undefined"==typeof f}if(!e)break;a._dirty=a.y!=d,a.y=d}},this))},i.prototype._prepareNode=function(a,c){return a=b.defaults(a||{},{width:1,height:1,x:0,y:0}),a.x=parseInt(""+a.x),a.y=parseInt(""+a.y),a.width=parseInt(""+a.width),a.height=parseInt(""+a.height),a.autoPosition=a.autoPosition||!1,a.noResize=a.noResize||!1,a.noMove=a.noMove||!1,a.width>this.width?a.width=this.width:a.width<1&&(a.width=1),this.height&&a.height>this.height?a.height=this.height:a.height<1&&(a.height=1),a.x<0&&(a.x=0),a.x+a.width>this.width&&(c?a.width=this.width-a.x:a.x=this.width-a.width),a.y<0&&(a.y=0),a},i.prototype._notify=function(){var a=Array.prototype.slice.call(arguments,0);if(a[0]="undefined"==typeof a[0]?[]:[a[0]],a[1]="undefined"==typeof a[1]||a[1],!this._updateCounter){var b=a[0].concat(this.getDirtyNodes());this.onchange(b,a[1])}},i.prototype.cleanNodes=function(){this._updateCounter||b.each(this.nodes,function(a){a._dirty=!1})},i.prototype.getDirtyNodes=function(){return b.filter(this.nodes,function(a){return a._dirty})},i.prototype.addNode=function(a,c,d){if(a=this._prepareNode(a),"undefined"!=typeof a.maxWidth&&(a.width=Math.min(a.width,a.maxWidth)),"undefined"!=typeof a.maxHeight&&(a.height=Math.min(a.height,a.maxHeight)),"undefined"!=typeof a.minWidth&&(a.width=Math.max(a.width,a.minWidth)),"undefined"!=typeof a.minHeight&&(a.height=Math.max(a.height,a.minHeight)),a._id=++h,a._dirty=!0,a.autoPosition){this._sortNodes();for(var e=0;;++e){var f=e%this.width,i=Math.floor(e/this.width);if(!(f+a.width>this.width||b.find(this.nodes,b.bind(g._isAddNodeIntercepted,{x:f,y:i,node:a})))){a.x=f,a.y=i;break}}}return this.nodes.push(a),"undefined"!=typeof c&&c&&this._addedNodes.push(b.clone(a)),this._fixCollisions(a,d),this._packNodes(),this._notify(),a},i.prototype.removeNode=function(a,c){a&&(a._id=null,this.nodes=b.without(this.nodes,a),this._packNodes(),this._notify(a,c))},i.prototype.canMoveNode=function(c,d,e,f,g){if(!this.isNodeChangedPosition(c,d,e,f,g))return!1;var h=Boolean(b.find(this.nodes,function(a){return a.locked}));if(!this.height&&!h)return!0;var j,k=new i(this.width,null,this["float"],0,b.map(this.nodes,function(b){return b==c?j=a.extend({},b):a.extend({},b)}));if("undefined"==typeof j)return!0;k.moveNode(j,d,e,f,g,!1,!0);var l=!0; // always allow moving the one out of bounds return h&&(l&=!Boolean(b.find(k.nodes,function(a){return a!=j&&Boolean(a.locked)&&Boolean(a._dirty)}))),this.height&&(l&=k.getGridHeight()<=this.height,c.y+c.height>this.height&&(l=!0)),l},i.prototype.canBePlacedWithRespectToHeight=function(c){if(!this.height)return!0;var d=new i(this.width,null,this["float"],0,b.map(this.nodes,function(b){return a.extend({},b)}));return d.addNode(c,!1,!0),d.getGridHeight()<=this.height},i.prototype.isNodeChangedPosition=function(a,b,c,d,e){return"number"!=typeof b&&(b=a.x),"number"!=typeof c&&(c=a.y),"number"!=typeof d&&(d=a.width),"number"!=typeof e&&(e=a.height),"undefined"!=typeof a.maxWidth&&(d=Math.min(d,a.maxWidth)),"undefined"!=typeof a.maxHeight&&(e=Math.min(e,a.maxHeight)),"undefined"!=typeof a.minWidth&&(d=Math.max(d,a.minWidth)),"undefined"!=typeof a.minHeight&&(e=Math.max(e,a.minHeight)),a.x!=b||a.y!=c||a.width!=d||a.height!=e},i.prototype.moveNode=function(a,b,c,d,e,f,g){if(!this.isNodeChangedPosition(a,b,c,d,e))return a;if("number"!=typeof b&&(b=a.x),"number"!=typeof c&&(c=a.y),"number"!=typeof d&&(d=a.width),"number"!=typeof e&&(e=a.height),"undefined"!=typeof a.maxWidth&&(d=Math.min(d,a.maxWidth)),"undefined"!=typeof a.maxHeight&&(e=Math.min(e,a.maxHeight)),"undefined"!=typeof a.minWidth&&(d=Math.max(d,a.minWidth)),"undefined"!=typeof a.minHeight&&(e=Math.max(e,a.minHeight)),a.x==b&&a.y==c&&a.width==d&&a.height==e)return a;var h=a.width!=d;return a._dirty=!0,a.x=b,a.y=c,a.width=d,a.height=e,a.lastTriedX=b,a.lastTriedY=c,a.lastTriedWidth=d,a.lastTriedHeight=e,a=this._prepareNode(a,h),this._fixCollisions(a,g),f||(this._packNodes(),this._notify()),a},i.prototype.getGridHeight=function(){return b.reduce(this.nodes,function(a,b){return Math.max(a,b.y+b.height)},0)},i.prototype.beginUpdate=function(a){b.each(this.nodes,function(a){a._origY=a.y}),a._updating=!0},i.prototype.endUpdate=function(){b.each(this.nodes,function(a){a._origY=a.y});var a=b.find(this.nodes,function(a){return a._updating});a&&(a._updating=!1)};var j=function(d,e){var g,h,j=this;e=e||{},this.container=a(d), // jscs:disable requireCamelCaseOrUpperCaseIdentifiers diff --git a/dist/gridstack.min.map b/dist/gridstack.min.map index 7a5e1c85b..eb8e837af 100644 --- a/dist/gridstack.min.map +++ b/dist/gridstack.min.map @@ -1 +1 @@ -{"version":3,"sources":["../src/gridstack.js","../src/gridstack.jQueryUI.js"],"names":["factory","define","amd","exports","jQuery","require","e","_","$","GridStackDragDropPlugin","grid","this","scope","window","obsolete","f","oldName","newName","wrapper","console","warn","apply","arguments","prototype","obsoleteOpts","Utils","isIntercepted","a","b","x","width","y","height","sort","nodes","dir","chain","map","node","max","value","sortBy","n","createStylesheet","id","style","document","createElement","setAttribute","styleSheet","cssText","appendChild","createTextNode","getElementsByTagName","sheet","removeStylesheet","remove","insertCSSRule","selector","rules","index","insertRule","addRule","toBool","v","toLowerCase","Boolean","_collisionNodeCheck","nn","_didCollide","bn","newY","_isAddNodeIntercepted","parseHeight","val","heightUnit","isString","match","Error","parseFloat","unit","is_intercepted","create_stylesheet","remove_stylesheet","insert_css_rule","registeredPlugins","registerPlugin","pluginClass","push","resizable","el","opts","draggable","droppable","isDroppable","on","eventName","callback","idSeq","GridStackEngine","onchange","floatMode","items","_updateCounter","_float","_addedNodes","_removedNodes","batchUpdate","commit","_packNodes","_notify","getNodeDataByDOMEl","find","get","_fixCollisions","isClone","_sortNodes","hasLocked","locked","collisionNode","bind","newPos","wrongPos","findFreeSpace","w","h","moveNode","whatIsHere","collisionNodes","filter","isAreaEmpty","length","forNode","i","j","freeSpace","nodesHere","each","_updating","_origY","_dirty","canBeMoved","take","_prepareNode","resizing","defaults","parseInt","autoPosition","noResize","noMove","args","Array","slice","call","deletedNodes","concat","getDirtyNodes","cleanNodes","addNode","triggerAddEvent","maxWidth","Math","min","maxHeight","minWidth","minHeight","_id","floor","clone","removeNode","detachNode","without","canMoveNode","isNodeChangedPosition","clonedNode","extend","res","getGridHeight","canBePlacedWithRespectToHeight","noPack","lastTriedX","lastTriedY","lastTriedWidth","lastTriedHeight","reduce","memo","beginUpdate","endUpdate","GridStack","oneColumnMode","isAutoCellHeight","self","container","handle_class","handleClass","item_class","itemClass","placeholder_class","placeholderClass","placeholder_text","placeholderText","cell_height","cellHeight","vertical_margin","verticalMargin","min_width","static_grid","staticGrid","is_nested","isNested","always_show_resize_handle","alwaysShowResizeHandle","closest","attr","handle","auto","float","_class","random","toFixed","animate","autoHide","handles","scroll","appendTo","disableDrag","disableResize","rtl","removable","removeTimeout","verticalMarginUnit","cellHeightUnit","oneColumnModeClass","ddPlugin","first","dd","css","addClass","cellWidth","_setStaticClass","_initStyles","_updateStyles","max_height","elements","_this","children","_prepareElement","setAnimation","placeholder","hide","_updateContainerHeight","_updateHeightsOnResize","throttle","onResizeHandler","_isOneColumnMode","append","trigger","removeClass","resize","trashZone","accept","event","ui","data","_grid","_setupRemovingTimeout","_clearRemovingTimeout","acceptWidgets","draggingElement","onDrag","pos","getCellFromPixel","offset","_added","show","_beforeDragX","_beforeDragY","is","origNode","ceil","outerWidth","outerHeight","_temporary","unbind","detach","removeAttr","enableSelection","removeData","_prepareElementsByNode","_triggerChangeEvent","forceTrigger","hasChanges","eventParams","_triggerAddEvent","_triggerRemoveEvent","_stylesId","_styles","_max","getHeight","prefix","nbRows","nbMargins","innerWidth","documentElement","clientWidth","body","_removeTimeout","setTimeout","_isAboutToRemove","clearTimeout","dragOrResize","round","position","left","top","type","size","_temporaryRemoved","onStartMoving","originalEvent","target","o","strictCellHeight","onEndMoving","forceNotify","nestedGrids","start","stop","drag","enable","addWidget","makeWidget","willItFit","removeWidget","removeAll","destroy","detachGrid","off","disable","movable","enableMove","doEnable","includeNewWidgets","enableResize","isNaN","_updateElement","move","update","noUpdate","heightData","useOffset","containerPos","relativeLeft","relativeTop","columnWidth","rowHeight","setStatic","staticValue","staticClassName","refreshNodes","isDisabled","that","k","getCellFromAbsolutePixel","nodeOffset","_updateNodeWidths","oldWidth","newWidth","undefined","setGridWidth","gridWidth","doNotPropagate","batch_update","_fix_collisions","is_area_empty","_sort_nodes","_pack_nodes","_prepare_node","clean_nodes","get_dirty_nodes","add_node","remove_node","can_move_node","move_node","get_grid_height","begin_update","end_update","can_be_placed_with_respect_to_height","_trigger_change_event","_init_styles","_update_styles","_update_container_height","_is_one_column_mode","_prepare_element","set_animation","add_widget","make_widget","will_it_fit","remove_widget","remove_all","min_height","_update_element","cell_width","get_cell_from_pixel","set_static","_set_static_class","GridStackUI","Engine","fn","gridstack","JQueryUIGridStackDragDropPlugin","Object","create","constructor","key","containment","parent"],"mappings":";;;;;;;CAOA,SAAUA,GACN,GAAsB,kBAAXC,SAAyBA,OAAOC,IACvCD,QAAQ,SAAU,UAAWD,OAC1B,IAAuB,mBAAZG,SAAyB,CACvC,IAAMC,OAASC,QAAQ,UAAa,MAAOC,IAC3C,IAAMC,EAAIF,QAAQ,UAAa,MAAOC,IACtCN,EAAQI,OAAQG,OAEhBP,GAAQI,OAAQG,IAErB,SAASC,EAAGD;;;;;;AA4GX,QAASE,GAAwBC,GAC7BC,KAAKD,KAAOA,EA3GhB,GAAIE,GAAQC,OAERC,EAAW,SAASC,EAAGC,EAASC,GAChC,GAAIC,GAAU,WAGV,MAFAC,SAAQC,KAAK,2BAA6BJ,EAAU,4DACzCC,EAAU,iDACdF,EAAEM,MAAMV,KAAMW,WAIzB,OAFAJ,GAAQK,UAAYR,EAAEQ,UAEfL,GAGPM,EAAe,SAASR,EAASC,GACjCE,QAAQC,KAAK,yBAA2BJ,EAAU,4DAC9CC,EAAU,kDAGdQ,GACAC,cAAe,SAASC,EAAGC,GACvB,QAASD,EAAEE,EAAIF,EAAEG,OAASF,EAAEC,GAAKD,EAAEC,EAAID,EAAEE,OAASH,EAAEE,GAAKF,EAAEI,EAAIJ,EAAEK,QAAUJ,EAAEG,GAAKH,EAAEG,EAAIH,EAAEI,QAAUL,EAAEI,IAG1GE,KAAM,SAASC,EAAOC,EAAKL,GAGvB,MAFAA,GAAQA,GAASvB,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,UAAY,SAASF,EAAIC,GAY/D,MAXAD,GAAKlF,EAAEkF,GACM,YAATC,GAA+B,WAATA,EACtBD,EAAGE,UAAUD,GAEbD,EAAGE,UAAUrF,EAAEwK,UAAWpK,KAAKD,KAAKiF,KAAKC,WACrCmU,YAAapZ,KAAKD,KAAKiF,KAAKsH,SAAWtM,KAAKD,KAAKsL,UAAUgO,SAAW,KACtE1F,MAAO3O,EAAK2O,OAAS,aACrBC,KAAM5O,EAAK4O,MAAQ,aACnBC,KAAM7O,EAAK6O,MAAQ,gBAGpB7T,MAGX+Y,EAAgCnY,UAAUsE,UAAY,SAASH,EAAIC,GAS/D,MARAD,GAAKlF,EAAEkF,GACM,YAATC,GAA+B,WAATA,EACtBD,EAAGG,UAAUF,GAEbD,EAAGG,WACCuK,OAAQzK,EAAKyK,SAGdzP,MAGX+Y,EAAgCnY,UAAUuE,YAAc,SAASJ,EAAIC,GAEjE,MADAD,GAAKlF,EAAEkF,GACAxB,QAAQwB,EAAG6K,KAAK,eAG3BmJ,EAAgCnY,UAAUwE,GAAK,SAASL,EAAIM,EAAWC,GAEnE,MADAzF,GAAEkF,GAAIK,GAAGC,EAAWC,GACbtF,MAGJ+Y","file":"gridstack.all.js"} \ No newline at end of file +{"version":3,"sources":["../src/gridstack.js","../src/gridstack.jQueryUI.js"],"names":["factory","define","amd","exports","jQuery","require","e","_","$","GridStackDragDropPlugin","grid","this","scope","window","obsolete","f","oldName","newName","wrapper","console","warn","apply","arguments","prototype","obsoleteOpts","Utils","isIntercepted","a","b","x","width","y","height","sort","nodes","dir","chain","map","node","max","value","sortBy","n","createStylesheet","id","style","document","createElement","setAttribute","styleSheet","cssText","appendChild","createTextNode","getElementsByTagName","sheet","removeStylesheet","remove","insertCSSRule","selector","rules","index","insertRule","addRule","toBool","v","toLowerCase","Boolean","_collisionNodeCheck","nn","_didCollide","bn","newY","_isAddNodeIntercepted","parseHeight","val","heightUnit","isString","match","Error","parseFloat","unit","is_intercepted","create_stylesheet","remove_stylesheet","insert_css_rule","registeredPlugins","registerPlugin","pluginClass","push","resizable","el","opts","draggable","droppable","isDroppable","on","eventName","callback","idSeq","GridStackEngine","onchange","floatMode","items","_updateCounter","_float","_addedNodes","_removedNodes","batchUpdate","commit","_packNodes","_notify","getNodeDataByDOMEl","find","get","_fixCollisions","isClone","_sortNodes","hasLocked","locked","collisionNode","bind","newPos","wrongPos","isAreaEmpty","_origY","w","h","findFreeSpace","moveNode","whatIsHere","collisionNodes","filter","exceptNode","length","forNode","i","j","freeSpace","each","_updating","_dirty","canBeMoved","take","_prepareNode","resizing","defaults","parseInt","autoPosition","noResize","noMove","args","Array","slice","call","deletedNodes","concat","getDirtyNodes","cleanNodes","addNode","triggerAddEvent","maxWidth","Math","min","maxHeight","minWidth","minHeight","_id","floor","clone","removeNode","detachNode","without","canMoveNode","isNodeChangedPosition","clonedNode","extend","res","getGridHeight","canBePlacedWithRespectToHeight","noPack","lastTriedX","lastTriedY","lastTriedWidth","lastTriedHeight","reduce","memo","beginUpdate","endUpdate","GridStack","oneColumnMode","isAutoCellHeight","self","container","handle_class","handleClass","item_class","itemClass","placeholder_class","placeholderClass","placeholder_text","placeholderText","cell_height","cellHeight","vertical_margin","verticalMargin","min_width","static_grid","staticGrid","is_nested","isNested","always_show_resize_handle","alwaysShowResizeHandle","closest","attr","handle","auto","float","_class","random","toFixed","animate","autoHide","handles","scroll","appendTo","disableDrag","disableResize","rtl","removable","removeTimeout","verticalMarginUnit","cellHeightUnit","oneColumnModeClass","ddPlugin","first","dd","css","addClass","cellWidth","_setStaticClass","_initStyles","_updateStyles","max_height","elements","_this","children","_prepareElement","setAnimation","placeholder","hide","_updateContainerHeight","_updateHeightsOnResize","throttle","onResizeHandler","_isOneColumnMode","append","trigger","removeClass","resize","trashZone","accept","event","ui","data","_grid","_setupRemovingTimeout","_clearRemovingTimeout","acceptWidgets","draggingElement","onDrag","pos","getCellFromPixel","offset","_added","show","_beforeDragX","_beforeDragY","is","origNode","ceil","outerWidth","outerHeight","_temporary","unbind","detach","removeAttr","enableSelection","removeData","_prepareElementsByNode","_triggerChangeEvent","forceTrigger","hasChanges","eventParams","_triggerAddEvent","_triggerRemoveEvent","_stylesId","_styles","_max","getHeight","prefix","nbRows","nbMargins","innerWidth","documentElement","clientWidth","body","_removeTimeout","setTimeout","_isAboutToRemove","clearTimeout","dragOrResize","round","position","left","top","type","size","_temporaryRemoved","onStartMoving","originalEvent","target","o","strictCellHeight","onEndMoving","forceNotify","nestedGrids","start","stop","drag","enable","addWidget","makeWidget","willItFit","removeWidget","removeAll","destroy","detachGrid","off","disable","movable","enableMove","doEnable","includeNewWidgets","enableResize","isNaN","_updateElement","move","update","noUpdate","heightData","useOffset","containerPos","relativeLeft","relativeTop","columnWidth","rowHeight","setStatic","staticValue","staticClassName","refreshNodes","isDisabled","that","k","getCellFromAbsolutePixel","nodeOffset","_updateNodeWidths","oldWidth","newWidth","undefined","setGridWidth","gridWidth","doNotPropagate","batch_update","_fix_collisions","is_area_empty","_sort_nodes","_pack_nodes","_prepare_node","clean_nodes","get_dirty_nodes","add_node","remove_node","can_move_node","move_node","get_grid_height","begin_update","end_update","can_be_placed_with_respect_to_height","_trigger_change_event","_init_styles","_update_styles","_update_container_height","_is_one_column_mode","_prepare_element","set_animation","add_widget","make_widget","will_it_fit","remove_widget","remove_all","min_height","_update_element","cell_width","get_cell_from_pixel","set_static","_set_static_class","GridStackUI","Engine","fn","gridstack","JQueryUIGridStackDragDropPlugin","Object","create","constructor","key","containment","parent"],"mappings":";;;;;;;CAOA,SAAUA,GACN,GAAsB,kBAAXC,SAAyBA,OAAOC,IACvCD,QAAQ,SAAU,UAAWD,OAC1B,IAAuB,mBAAZG,SAAyB,CACvC,IAAMC,OAASC,QAAQ,UAAa,MAAOC,IAC3C,IAAMC,EAAIF,QAAQ,UAAa,MAAOC,IACtCN,EAAQI,OAAQG,OAEhBP,GAAQI,OAAQG,IAErB,SAASC,EAAGD;;;;;;AA4GX,QAASE,GAAwBC,GAC7BC,KA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dzP,MAGX+Y,EAAgCnY,UAAUuE,YAAc,SAASJ,EAAIC,GAEjE,MADAD,GAAKlF,EAAEkF,GACAxB,QAAQwB,EAAG6K,KAAK,eAG3BmJ,EAAgCnY,UAAUwE,GAAK,SAASL,EAAIM,EAAWC,GAEnE,MADAzF,GAAEkF,GAAIK,GAAGC,EAAWC,GACbtF,MAGJ+Y","file":"gridstack.all.js"} \ No newline at end of file From 37d9dc9ef545ffe5a306bcbd1a6953c276c521ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Inga=20Br=C5=ABnava?= Date: Wed, 25 Jan 2017 09:04:02 +0100 Subject: [PATCH 23/35] No automove of other blocks --- src/gridstack.js | 50 +++++++++++++----------------------------------- 1 file changed, 13 insertions(+), 37 deletions(-) diff --git a/src/gridstack.js b/src/gridstack.js index b3cd41748..750260304 100644 --- a/src/gridstack.js +++ b/src/gridstack.js @@ -205,43 +205,7 @@ return; } - // will try to fix the collision - var newPos, - wrongPos = !isClone && ((node.y + node.height + collisionNode.height) > this.height); - - if (wrongPos) { - // check the original Y position first - if (this.isAreaEmpty(collisionNode.x, collisionNode._origY, collisionNode.width, collisionNode.height, collisionNode)) { - newPos = { - x: collisionNode.x, - y: collisionNode._origY, - w: collisionNode.width, - h: collisionNode.height - }; - } else { - // if the pos is out of bounds, put it on first available - newPos = this.findFreeSpace(collisionNode.width, collisionNode.height, collisionNode); - if (!newPos) { - newPos = this.findFreeSpace(); - } - if (!newPos) { - return; // hmm - } - } - } else { - newPos = { - x: collisionNode.x, - y: node.y + node.height, - w: collisionNode.width, - h: collisionNode.height - }; - } - - if (newPos) { - // all recursive collision fixes are treated like they are isClone true - this.moveNode(collisionNode, newPos.x, newPos.y, newPos.w, newPos.h, true, true); - } - + this.moveNode(collisionNode, collisionNode.x, node.y + node.height, collisionNode.width, collisionNode.height, true); } }; @@ -254,6 +218,10 @@ }; GridStackEngine.prototype.isAreaEmpty = function(x, y, width, height, exceptNode) { + // first check if is not out of bounds + if (y + height > this.height || x + width > this.width) { + return false; + } var collisionNodes = this.whatIsHere(x, y, width, height); return (!collisionNodes.length || (exceptNode && collisionNodes.length === 1 && collisionNodes[0] === exceptNode)); }; @@ -459,6 +427,10 @@ return true; } + if (!this.isAreaEmpty(x, y, width, height, node)) { + return false; + } + var clonedNode; var clone = new GridStackEngine( this.width, @@ -548,6 +520,10 @@ return node; } + if (!this.isAreaEmpty(x, y, width, height, node)) { + return node; + } + var resizing = node.width != width; node._dirty = true; From b1d37b7c1b54e03dcaa933c0a4770996fdf57428 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Inga=20Br=C5=ABnava?= Date: Wed, 25 Jan 2017 09:05:31 +0100 Subject: [PATCH 24/35] Assets --- dist/gridstack.all.js | 16 +++++--------- dist/gridstack.js | 50 +++++++++++------------------------------- dist/gridstack.min.js | 16 +++++--------- dist/gridstack.min.map | 2 +- 4 files changed, 24 insertions(+), 60 deletions(-) diff --git a/dist/gridstack.all.js b/dist/gridstack.all.js index a8c002a21..0f5c843ca 100644 --- a/dist/gridstack.all.js +++ b/dist/gridstack.all.js @@ -15,19 +15,13 @@ function c(a){this.grid=a}var d=window,e=function(a,b,c){var d=function(){return // jscs:disable requireCamelCaseOrUpperCaseIdentifiers g.is_intercepted=e(g.isIntercepted,"is_intercepted","isIntercepted"),g.create_stylesheet=e(g.createStylesheet,"create_stylesheet","createStylesheet"),g.remove_stylesheet=e(g.removeStylesheet,"remove_stylesheet","removeStylesheet"),g.insert_css_rule=e(g.insertCSSRule,"insert_css_rule","insertCSSRule"),c.registeredPlugins=[],c.registerPlugin=function(a){c.registeredPlugins.push(a)},c.prototype.resizable=function(a,b){return this},c.prototype.draggable=function(a,b){return this},c.prototype.droppable=function(a,b){return this},c.prototype.isDroppable=function(a){return!1},c.prototype.on=function(a,b,c){return this};var h=0,i=function(a,b,c,d,e){this.width=a,this["float"]=c||!1,this.height=d||0,this.nodes=e||[],this.onchange=b||function(){},this._updateCounter=0,this._float=this["float"],this._addedNodes=[],this._removedNodes=[]};i.prototype.batchUpdate=function(){this._updateCounter=1,this["float"]=!0},i.prototype.commit=function(){0!==this._updateCounter&&(this._updateCounter=0,this["float"]=this._float,this._packNodes(),this._notify())}, // For Meteor support: https://github.com/troolee/gridstack.js/pull/272 -i.prototype.getNodeDataByDOMEl=function(a){return b.find(this.nodes,function(b){return a.get(0)===b.el.get(0)})},i.prototype._fixCollisions=function(a,c){this._sortNodes(-1);var d=a,e=Boolean(b.find(this.nodes,function(a){return a.locked}));for(this["float"]||e||(d={x:0,y:a.y,width:this.width,height:a.height});;){var f=b.find(this.nodes,b.bind(g._collisionNodeCheck,{node:a,nn:d}));if("undefined"==typeof f)return; -// will try to fix the collision -var h,i=!c&&a.y+a.height+f.height>this.height;if(i){ -// check the original Y position first -if(this.isAreaEmpty(f.x,f._origY,f.width,f.height,f))h={x:f.x,y:f._origY,w:f.width,h:f.height};else if( -// if the pos is out of bounds, put it on first available -h=this.findFreeSpace(f.width,f.height,f),h||(h=this.findFreeSpace()),!h)return}else h={x:f.x,y:a.y+a.height,w:f.width,h:f.height};h&& -// all recursive collision fixes are treated like they are isClone true -this.moveNode(f,h.x,h.y,h.w,h.h,!0,!0)}},i.prototype.whatIsHere=function(a,c,d,e){var f={x:a||0,y:c||0,width:d||1,height:e||1},h=b.filter(this.nodes,b.bind(function(a){return g.isIntercepted(a,f)},this));return h},i.prototype.isAreaEmpty=function(a,b,c,d,e){var f=this.whatIsHere(a,b,c,d);return!f.length||e&&1===f.length&&f[0]===e},i.prototype.findFreeSpace=function(a,b,c){var d,e,f=null;for( +i.prototype.getNodeDataByDOMEl=function(a){return b.find(this.nodes,function(b){return a.get(0)===b.el.get(0)})},i.prototype._fixCollisions=function(a,c){this._sortNodes(-1);var d=a,e=Boolean(b.find(this.nodes,function(a){return a.locked}));for(this["float"]||e||(d={x:0,y:a.y,width:this.width,height:a.height});;){var f=b.find(this.nodes,b.bind(g._collisionNodeCheck,{node:a,nn:d}));if("undefined"==typeof f)return;this.moveNode(f,f.x,a.y+a.height,f.width,f.height,!0)}},i.prototype.whatIsHere=function(a,c,d,e){var f={x:a||0,y:c||0,width:d||1,height:e||1},h=b.filter(this.nodes,b.bind(function(a){return g.isIntercepted(a,f)},this));return h},i.prototype.isAreaEmpty=function(a,b,c,d,e){ +// first check if is not out of bounds +if(b+d>this.height||a+c>this.width)return!1;var f=this.whatIsHere(a,b,c,d);return!f.length||e&&1===f.length&&f[0]===e},i.prototype.findFreeSpace=function(a,b,c){var d,e,f=null;for( // first free for 1x1 or we have specified width and height -a||(a=1),b||(b=1),d=0;d<=this.width-a&&!f;d++)for(e=0;e<=this.height-b&&!f;e++)this.isAreaEmpty(d,e,a,b,c)&&(f={x:d,y:e,w:a,h:b});return f},i.prototype._sortNodes=function(a){this.nodes=g.sort(this.nodes,a,this.width)},i.prototype._packNodes=function(){this._sortNodes(),this["float"]?b.each(this.nodes,b.bind(function(a,c){if(!a._updating&&"undefined"!=typeof a._origY&&a.y!=a._origY)for(var d=a.y;d>=a._origY;){var e=b.chain(this.nodes).find(b.bind(g._didCollide,{n:a,newY:d})).value();e||(a._dirty=!0,a.y=d),--d}},this)):b.each(this.nodes,b.bind(function(a,c){if(!a.locked)for(;a.y>0;){var d=a.y-1,e=0===c;if(c>0){var f=b.chain(this.nodes).take(c).find(b.bind(g._didCollide,{n:a,newY:d})).value();e="undefined"==typeof f}if(!e)break;a._dirty=a.y!=d,a.y=d}},this))},i.prototype._prepareNode=function(a,c){return a=b.defaults(a||{},{width:1,height:1,x:0,y:0}),a.x=parseInt(""+a.x),a.y=parseInt(""+a.y),a.width=parseInt(""+a.width),a.height=parseInt(""+a.height),a.autoPosition=a.autoPosition||!1,a.noResize=a.noResize||!1,a.noMove=a.noMove||!1,a.width>this.width?a.width=this.width:a.width<1&&(a.width=1),this.height&&a.height>this.height?a.height=this.height:a.height<1&&(a.height=1),a.x<0&&(a.x=0),a.x+a.width>this.width&&(c?a.width=this.width-a.x:a.x=this.width-a.width),a.y<0&&(a.y=0),a},i.prototype._notify=function(){var a=Array.prototype.slice.call(arguments,0);if(a[0]="undefined"==typeof a[0]?[]:[a[0]],a[1]="undefined"==typeof a[1]||a[1],!this._updateCounter){var b=a[0].concat(this.getDirtyNodes());this.onchange(b,a[1])}},i.prototype.cleanNodes=function(){this._updateCounter||b.each(this.nodes,function(a){a._dirty=!1})},i.prototype.getDirtyNodes=function(){return b.filter(this.nodes,function(a){return a._dirty})},i.prototype.addNode=function(a,c,d){if(a=this._prepareNode(a),"undefined"!=typeof a.maxWidth&&(a.width=Math.min(a.width,a.maxWidth)),"undefined"!=typeof a.maxHeight&&(a.height=Math.min(a.height,a.maxHeight)),"undefined"!=typeof a.minWidth&&(a.width=Math.max(a.width,a.minWidth)),"undefined"!=typeof a.minHeight&&(a.height=Math.max(a.height,a.minHeight)),a._id=++h,a._dirty=!0,a.autoPosition){this._sortNodes();for(var e=0;;++e){var f=e%this.width,i=Math.floor(e/this.width);if(!(f+a.width>this.width||b.find(this.nodes,b.bind(g._isAddNodeIntercepted,{x:f,y:i,node:a})))){a.x=f,a.y=i;break}}}return this.nodes.push(a),"undefined"!=typeof c&&c&&this._addedNodes.push(b.clone(a)),this._fixCollisions(a,d),this._packNodes(),this._notify(),a},i.prototype.removeNode=function(a,c){a&&(a._id=null,this.nodes=b.without(this.nodes,a),this._packNodes(),this._notify(a,c))},i.prototype.canMoveNode=function(c,d,e,f,g){if(!this.isNodeChangedPosition(c,d,e,f,g))return!1;var h=Boolean(b.find(this.nodes,function(a){return a.locked}));if(!this.height&&!h)return!0;var j,k=new i(this.width,null,this["float"],0,b.map(this.nodes,function(b){return b==c?j=a.extend({},b):a.extend({},b)}));if("undefined"==typeof j)return!0;k.moveNode(j,d,e,f,g,!1,!0);var l=!0; +a||(a=1),b||(b=1),d=0;d<=this.width-a&&!f;d++)for(e=0;e<=this.height-b&&!f;e++)this.isAreaEmpty(d,e,a,b,c)&&(f={x:d,y:e,w:a,h:b});return f},i.prototype._sortNodes=function(a){this.nodes=g.sort(this.nodes,a,this.width)},i.prototype._packNodes=function(){this._sortNodes(),this["float"]?b.each(this.nodes,b.bind(function(a,c){if(!a._updating&&"undefined"!=typeof a._origY&&a.y!=a._origY)for(var d=a.y;d>=a._origY;){var e=b.chain(this.nodes).find(b.bind(g._didCollide,{n:a,newY:d})).value();e||(a._dirty=!0,a.y=d),--d}},this)):b.each(this.nodes,b.bind(function(a,c){if(!a.locked)for(;a.y>0;){var d=a.y-1,e=0===c;if(c>0){var f=b.chain(this.nodes).take(c).find(b.bind(g._didCollide,{n:a,newY:d})).value();e="undefined"==typeof f}if(!e)break;a._dirty=a.y!=d,a.y=d}},this))},i.prototype._prepareNode=function(a,c){return a=b.defaults(a||{},{width:1,height:1,x:0,y:0}),a.x=parseInt(""+a.x),a.y=parseInt(""+a.y),a.width=parseInt(""+a.width),a.height=parseInt(""+a.height),a.autoPosition=a.autoPosition||!1,a.noResize=a.noResize||!1,a.noMove=a.noMove||!1,a.width>this.width?a.width=this.width:a.width<1&&(a.width=1),this.height&&a.height>this.height?a.height=this.height:a.height<1&&(a.height=1),a.x<0&&(a.x=0),a.x+a.width>this.width&&(c?a.width=this.width-a.x:a.x=this.width-a.width),a.y<0&&(a.y=0),a},i.prototype._notify=function(){var a=Array.prototype.slice.call(arguments,0);if(a[0]="undefined"==typeof a[0]?[]:[a[0]],a[1]="undefined"==typeof a[1]||a[1],!this._updateCounter){var b=a[0].concat(this.getDirtyNodes());this.onchange(b,a[1])}},i.prototype.cleanNodes=function(){this._updateCounter||b.each(this.nodes,function(a){a._dirty=!1})},i.prototype.getDirtyNodes=function(){return b.filter(this.nodes,function(a){return a._dirty})},i.prototype.addNode=function(a,c,d){if(a=this._prepareNode(a),"undefined"!=typeof a.maxWidth&&(a.width=Math.min(a.width,a.maxWidth)),"undefined"!=typeof a.maxHeight&&(a.height=Math.min(a.height,a.maxHeight)),"undefined"!=typeof a.minWidth&&(a.width=Math.max(a.width,a.minWidth)),"undefined"!=typeof a.minHeight&&(a.height=Math.max(a.height,a.minHeight)),a._id=++h,a._dirty=!0,a.autoPosition){this._sortNodes();for(var e=0;;++e){var f=e%this.width,i=Math.floor(e/this.width);if(!(f+a.width>this.width||b.find(this.nodes,b.bind(g._isAddNodeIntercepted,{x:f,y:i,node:a})))){a.x=f,a.y=i;break}}}return this.nodes.push(a),"undefined"!=typeof c&&c&&this._addedNodes.push(b.clone(a)),this._fixCollisions(a,d),this._packNodes(),this._notify(),a},i.prototype.removeNode=function(a,c){a&&(a._id=null,this.nodes=b.without(this.nodes,a),this._packNodes(),this._notify(a,c))},i.prototype.canMoveNode=function(c,d,e,f,g){if(!this.isNodeChangedPosition(c,d,e,f,g))return!1;var h=Boolean(b.find(this.nodes,function(a){return a.locked}));if(!this.height&&!h)return!0;if(!this.isAreaEmpty(d,e,f,g,c))return!1;var j,k=new i(this.width,null,this["float"],0,b.map(this.nodes,function(b){return b==c?j=a.extend({},b):a.extend({},b)}));if("undefined"==typeof j)return!0;k.moveNode(j,d,e,f,g,!1,!0);var l=!0; // always allow moving the one out of bounds -return h&&(l&=!Boolean(b.find(k.nodes,function(a){return a!=j&&Boolean(a.locked)&&Boolean(a._dirty)}))),this.height&&(l&=k.getGridHeight()<=this.height,c.y+c.height>this.height&&(l=!0)),l},i.prototype.canBePlacedWithRespectToHeight=function(c){if(!this.height)return!0;var d=new i(this.width,null,this["float"],0,b.map(this.nodes,function(b){return a.extend({},b)}));return d.addNode(c,!1,!0),d.getGridHeight()<=this.height},i.prototype.isNodeChangedPosition=function(a,b,c,d,e){return"number"!=typeof b&&(b=a.x),"number"!=typeof c&&(c=a.y),"number"!=typeof d&&(d=a.width),"number"!=typeof e&&(e=a.height),"undefined"!=typeof a.maxWidth&&(d=Math.min(d,a.maxWidth)),"undefined"!=typeof a.maxHeight&&(e=Math.min(e,a.maxHeight)),"undefined"!=typeof a.minWidth&&(d=Math.max(d,a.minWidth)),"undefined"!=typeof a.minHeight&&(e=Math.max(e,a.minHeight)),a.x!=b||a.y!=c||a.width!=d||a.height!=e},i.prototype.moveNode=function(a,b,c,d,e,f,g){if(!this.isNodeChangedPosition(a,b,c,d,e))return a;if("number"!=typeof b&&(b=a.x),"number"!=typeof c&&(c=a.y),"number"!=typeof d&&(d=a.width),"number"!=typeof e&&(e=a.height),"undefined"!=typeof a.maxWidth&&(d=Math.min(d,a.maxWidth)),"undefined"!=typeof a.maxHeight&&(e=Math.min(e,a.maxHeight)),"undefined"!=typeof a.minWidth&&(d=Math.max(d,a.minWidth)),"undefined"!=typeof a.minHeight&&(e=Math.max(e,a.minHeight)),a.x==b&&a.y==c&&a.width==d&&a.height==e)return a;var h=a.width!=d;return a._dirty=!0,a.x=b,a.y=c,a.width=d,a.height=e,a.lastTriedX=b,a.lastTriedY=c,a.lastTriedWidth=d,a.lastTriedHeight=e,a=this._prepareNode(a,h),this._fixCollisions(a,g),f||(this._packNodes(),this._notify()),a},i.prototype.getGridHeight=function(){return b.reduce(this.nodes,function(a,b){return Math.max(a,b.y+b.height)},0)},i.prototype.beginUpdate=function(a){b.each(this.nodes,function(a){a._origY=a.y}),a._updating=!0},i.prototype.endUpdate=function(){b.each(this.nodes,function(a){a._origY=a.y});var a=b.find(this.nodes,function(a){return a._updating});a&&(a._updating=!1)};var j=function(d,e){var g,h,j=this;e=e||{},this.container=a(d), +return h&&(l&=!Boolean(b.find(k.nodes,function(a){return a!=j&&Boolean(a.locked)&&Boolean(a._dirty)}))),this.height&&(l&=k.getGridHeight()<=this.height,c.y+c.height>this.height&&(l=!0)),l},i.prototype.canBePlacedWithRespectToHeight=function(c){if(!this.height)return!0;var d=new i(this.width,null,this["float"],0,b.map(this.nodes,function(b){return a.extend({},b)}));return d.addNode(c,!1,!0),d.getGridHeight()<=this.height},i.prototype.isNodeChangedPosition=function(a,b,c,d,e){return"number"!=typeof b&&(b=a.x),"number"!=typeof c&&(c=a.y),"number"!=typeof d&&(d=a.width),"number"!=typeof e&&(e=a.height),"undefined"!=typeof a.maxWidth&&(d=Math.min(d,a.maxWidth)),"undefined"!=typeof a.maxHeight&&(e=Math.min(e,a.maxHeight)),"undefined"!=typeof a.minWidth&&(d=Math.max(d,a.minWidth)),"undefined"!=typeof a.minHeight&&(e=Math.max(e,a.minHeight)),a.x!=b||a.y!=c||a.width!=d||a.height!=e},i.prototype.moveNode=function(a,b,c,d,e,f,g){if(!this.isNodeChangedPosition(a,b,c,d,e))return a;if("number"!=typeof b&&(b=a.x),"number"!=typeof c&&(c=a.y),"number"!=typeof d&&(d=a.width),"number"!=typeof e&&(e=a.height),"undefined"!=typeof a.maxWidth&&(d=Math.min(d,a.maxWidth)),"undefined"!=typeof a.maxHeight&&(e=Math.min(e,a.maxHeight)),"undefined"!=typeof a.minWidth&&(d=Math.max(d,a.minWidth)),"undefined"!=typeof a.minHeight&&(e=Math.max(e,a.minHeight)),a.x==b&&a.y==c&&a.width==d&&a.height==e)return a;if(!this.isAreaEmpty(b,c,d,e,a))return a;var h=a.width!=d;return a._dirty=!0,a.x=b,a.y=c,a.width=d,a.height=e,a.lastTriedX=b,a.lastTriedY=c,a.lastTriedWidth=d,a.lastTriedHeight=e,a=this._prepareNode(a,h),this._fixCollisions(a,g),f||(this._packNodes(),this._notify()),a},i.prototype.getGridHeight=function(){return b.reduce(this.nodes,function(a,b){return Math.max(a,b.y+b.height)},0)},i.prototype.beginUpdate=function(a){b.each(this.nodes,function(a){a._origY=a.y}),a._updating=!0},i.prototype.endUpdate=function(){b.each(this.nodes,function(a){a._origY=a.y});var a=b.find(this.nodes,function(a){return a._updating});a&&(a._updating=!1)};var j=function(d,e){var g,h,j=this;e=e||{},this.container=a(d), // jscs:disable requireCamelCaseOrUpperCaseIdentifiers "undefined"!=typeof e.handle_class&&(e.handleClass=e.handle_class,f("handle_class","handleClass")),"undefined"!=typeof e.item_class&&(e.itemClass=e.item_class,f("item_class","itemClass")),"undefined"!=typeof e.placeholder_class&&(e.placeholderClass=e.placeholder_class,f("placeholder_class","placeholderClass")),"undefined"!=typeof e.placeholder_text&&(e.placeholderText=e.placeholder_text,f("placeholder_text","placeholderText")),"undefined"!=typeof e.cell_height&&(e.cellHeight=e.cell_height,f("cell_height","cellHeight")),"undefined"!=typeof e.vertical_margin&&(e.verticalMargin=e.vertical_margin,f("vertical_margin","verticalMargin")),"undefined"!=typeof e.min_width&&(e.minWidth=e.min_width,f("min_width","minWidth")),"undefined"!=typeof e.static_grid&&(e.staticGrid=e.static_grid,f("static_grid","staticGrid")),"undefined"!=typeof e.is_nested&&(e.isNested=e.is_nested,f("is_nested","isNested")),"undefined"!=typeof e.always_show_resize_handle&&(e.alwaysShowResizeHandle=e.always_show_resize_handle,f("always_show_resize_handle","alwaysShowResizeHandle")), // jscs:enable requireCamelCaseOrUpperCaseIdentifiers diff --git a/dist/gridstack.js b/dist/gridstack.js index b3cd41748..750260304 100644 --- a/dist/gridstack.js +++ b/dist/gridstack.js @@ -205,43 +205,7 @@ return; } - // will try to fix the collision - var newPos, - wrongPos = !isClone && ((node.y + node.height + collisionNode.height) > this.height); - - if (wrongPos) { - // check the original Y position first - if (this.isAreaEmpty(collisionNode.x, collisionNode._origY, collisionNode.width, collisionNode.height, collisionNode)) { - newPos = { - x: collisionNode.x, - y: collisionNode._origY, - w: collisionNode.width, - h: collisionNode.height - }; - } else { - // if the pos is out of bounds, put it on first available - newPos = this.findFreeSpace(collisionNode.width, collisionNode.height, collisionNode); - if (!newPos) { - newPos = this.findFreeSpace(); - } - if (!newPos) { - return; // hmm - } - } - } else { - newPos = { - x: collisionNode.x, - y: node.y + node.height, - w: collisionNode.width, - h: collisionNode.height - }; - } - - if (newPos) { - // all recursive collision fixes are treated like they are isClone true - this.moveNode(collisionNode, newPos.x, newPos.y, newPos.w, newPos.h, true, true); - } - + this.moveNode(collisionNode, collisionNode.x, node.y + node.height, collisionNode.width, collisionNode.height, true); } }; @@ -254,6 +218,10 @@ }; GridStackEngine.prototype.isAreaEmpty = function(x, y, width, height, exceptNode) { + // first check if is not out of bounds + if (y + height > this.height || x + width > this.width) { + return false; + } var collisionNodes = this.whatIsHere(x, y, width, height); return (!collisionNodes.length || (exceptNode && collisionNodes.length === 1 && collisionNodes[0] === exceptNode)); }; @@ -459,6 +427,10 @@ return true; } + if (!this.isAreaEmpty(x, y, width, height, node)) { + return false; + } + var clonedNode; var clone = new GridStackEngine( this.width, @@ -548,6 +520,10 @@ return node; } + if (!this.isAreaEmpty(x, y, width, height, node)) { + return node; + } + var resizing = node.width != width; node._dirty = true; diff --git a/dist/gridstack.min.js b/dist/gridstack.min.js index a30fe2e3e..326bdb1fc 100644 --- a/dist/gridstack.min.js +++ b/dist/gridstack.min.js @@ -15,19 +15,13 @@ function c(a){this.grid=a}var d=window,e=function(a,b,c){var d=function(){return // jscs:disable requireCamelCaseOrUpperCaseIdentifiers g.is_intercepted=e(g.isIntercepted,"is_intercepted","isIntercepted"),g.create_stylesheet=e(g.createStylesheet,"create_stylesheet","createStylesheet"),g.remove_stylesheet=e(g.removeStylesheet,"remove_stylesheet","removeStylesheet"),g.insert_css_rule=e(g.insertCSSRule,"insert_css_rule","insertCSSRule"),c.registeredPlugins=[],c.registerPlugin=function(a){c.registeredPlugins.push(a)},c.prototype.resizable=function(a,b){return this},c.prototype.draggable=function(a,b){return this},c.prototype.droppable=function(a,b){return this},c.prototype.isDroppable=function(a){return!1},c.prototype.on=function(a,b,c){return this};var h=0,i=function(a,b,c,d,e){this.width=a,this["float"]=c||!1,this.height=d||0,this.nodes=e||[],this.onchange=b||function(){},this._updateCounter=0,this._float=this["float"],this._addedNodes=[],this._removedNodes=[]};i.prototype.batchUpdate=function(){this._updateCounter=1,this["float"]=!0},i.prototype.commit=function(){0!==this._updateCounter&&(this._updateCounter=0,this["float"]=this._float,this._packNodes(),this._notify())}, // For Meteor support: https://github.com/troolee/gridstack.js/pull/272 -i.prototype.getNodeDataByDOMEl=function(a){return b.find(this.nodes,function(b){return a.get(0)===b.el.get(0)})},i.prototype._fixCollisions=function(a,c){this._sortNodes(-1);var d=a,e=Boolean(b.find(this.nodes,function(a){return a.locked}));for(this["float"]||e||(d={x:0,y:a.y,width:this.width,height:a.height});;){var f=b.find(this.nodes,b.bind(g._collisionNodeCheck,{node:a,nn:d}));if("undefined"==typeof f)return; -// will try to fix the collision -var h,i=!c&&a.y+a.height+f.height>this.height;if(i){ -// check the original Y position first -if(this.isAreaEmpty(f.x,f._origY,f.width,f.height,f))h={x:f.x,y:f._origY,w:f.width,h:f.height};else if( -// if the pos is out of bounds, put it on first available -h=this.findFreeSpace(f.width,f.height,f),h||(h=this.findFreeSpace()),!h)return}else h={x:f.x,y:a.y+a.height,w:f.width,h:f.height};h&& -// all recursive collision fixes are treated like they are isClone true -this.moveNode(f,h.x,h.y,h.w,h.h,!0,!0)}},i.prototype.whatIsHere=function(a,c,d,e){var f={x:a||0,y:c||0,width:d||1,height:e||1},h=b.filter(this.nodes,b.bind(function(a){return g.isIntercepted(a,f)},this));return h},i.prototype.isAreaEmpty=function(a,b,c,d,e){var f=this.whatIsHere(a,b,c,d);return!f.length||e&&1===f.length&&f[0]===e},i.prototype.findFreeSpace=function(a,b,c){var d,e,f=null;for( +i.prototype.getNodeDataByDOMEl=function(a){return b.find(this.nodes,function(b){return a.get(0)===b.el.get(0)})},i.prototype._fixCollisions=function(a,c){this._sortNodes(-1);var d=a,e=Boolean(b.find(this.nodes,function(a){return a.locked}));for(this["float"]||e||(d={x:0,y:a.y,width:this.width,height:a.height});;){var f=b.find(this.nodes,b.bind(g._collisionNodeCheck,{node:a,nn:d}));if("undefined"==typeof f)return;this.moveNode(f,f.x,a.y+a.height,f.width,f.height,!0)}},i.prototype.whatIsHere=function(a,c,d,e){var f={x:a||0,y:c||0,width:d||1,height:e||1},h=b.filter(this.nodes,b.bind(function(a){return g.isIntercepted(a,f)},this));return h},i.prototype.isAreaEmpty=function(a,b,c,d,e){ +// first check if is not out of bounds +if(b+d>this.height||a+c>this.width)return!1;var f=this.whatIsHere(a,b,c,d);return!f.length||e&&1===f.length&&f[0]===e},i.prototype.findFreeSpace=function(a,b,c){var d,e,f=null;for( // first free for 1x1 or we have specified width and height -a||(a=1),b||(b=1),d=0;d<=this.width-a&&!f;d++)for(e=0;e<=this.height-b&&!f;e++)this.isAreaEmpty(d,e,a,b,c)&&(f={x:d,y:e,w:a,h:b});return f},i.prototype._sortNodes=function(a){this.nodes=g.sort(this.nodes,a,this.width)},i.prototype._packNodes=function(){this._sortNodes(),this["float"]?b.each(this.nodes,b.bind(function(a,c){if(!a._updating&&"undefined"!=typeof a._origY&&a.y!=a._origY)for(var d=a.y;d>=a._origY;){var e=b.chain(this.nodes).find(b.bind(g._didCollide,{n:a,newY:d})).value();e||(a._dirty=!0,a.y=d),--d}},this)):b.each(this.nodes,b.bind(function(a,c){if(!a.locked)for(;a.y>0;){var d=a.y-1,e=0===c;if(c>0){var f=b.chain(this.nodes).take(c).find(b.bind(g._didCollide,{n:a,newY:d})).value();e="undefined"==typeof f}if(!e)break;a._dirty=a.y!=d,a.y=d}},this))},i.prototype._prepareNode=function(a,c){return a=b.defaults(a||{},{width:1,height:1,x:0,y:0}),a.x=parseInt(""+a.x),a.y=parseInt(""+a.y),a.width=parseInt(""+a.width),a.height=parseInt(""+a.height),a.autoPosition=a.autoPosition||!1,a.noResize=a.noResize||!1,a.noMove=a.noMove||!1,a.width>this.width?a.width=this.width:a.width<1&&(a.width=1),this.height&&a.height>this.height?a.height=this.height:a.height<1&&(a.height=1),a.x<0&&(a.x=0),a.x+a.width>this.width&&(c?a.width=this.width-a.x:a.x=this.width-a.width),a.y<0&&(a.y=0),a},i.prototype._notify=function(){var a=Array.prototype.slice.call(arguments,0);if(a[0]="undefined"==typeof a[0]?[]:[a[0]],a[1]="undefined"==typeof a[1]||a[1],!this._updateCounter){var b=a[0].concat(this.getDirtyNodes());this.onchange(b,a[1])}},i.prototype.cleanNodes=function(){this._updateCounter||b.each(this.nodes,function(a){a._dirty=!1})},i.prototype.getDirtyNodes=function(){return b.filter(this.nodes,function(a){return a._dirty})},i.prototype.addNode=function(a,c,d){if(a=this._prepareNode(a),"undefined"!=typeof a.maxWidth&&(a.width=Math.min(a.width,a.maxWidth)),"undefined"!=typeof a.maxHeight&&(a.height=Math.min(a.height,a.maxHeight)),"undefined"!=typeof a.minWidth&&(a.width=Math.max(a.width,a.minWidth)),"undefined"!=typeof a.minHeight&&(a.height=Math.max(a.height,a.minHeight)),a._id=++h,a._dirty=!0,a.autoPosition){this._sortNodes();for(var e=0;;++e){var f=e%this.width,i=Math.floor(e/this.width);if(!(f+a.width>this.width||b.find(this.nodes,b.bind(g._isAddNodeIntercepted,{x:f,y:i,node:a})))){a.x=f,a.y=i;break}}}return this.nodes.push(a),"undefined"!=typeof c&&c&&this._addedNodes.push(b.clone(a)),this._fixCollisions(a,d),this._packNodes(),this._notify(),a},i.prototype.removeNode=function(a,c){a&&(a._id=null,this.nodes=b.without(this.nodes,a),this._packNodes(),this._notify(a,c))},i.prototype.canMoveNode=function(c,d,e,f,g){if(!this.isNodeChangedPosition(c,d,e,f,g))return!1;var h=Boolean(b.find(this.nodes,function(a){return a.locked}));if(!this.height&&!h)return!0;var j,k=new i(this.width,null,this["float"],0,b.map(this.nodes,function(b){return b==c?j=a.extend({},b):a.extend({},b)}));if("undefined"==typeof j)return!0;k.moveNode(j,d,e,f,g,!1,!0);var l=!0; +a||(a=1),b||(b=1),d=0;d<=this.width-a&&!f;d++)for(e=0;e<=this.height-b&&!f;e++)this.isAreaEmpty(d,e,a,b,c)&&(f={x:d,y:e,w:a,h:b});return f},i.prototype._sortNodes=function(a){this.nodes=g.sort(this.nodes,a,this.width)},i.prototype._packNodes=function(){this._sortNodes(),this["float"]?b.each(this.nodes,b.bind(function(a,c){if(!a._updating&&"undefined"!=typeof a._origY&&a.y!=a._origY)for(var d=a.y;d>=a._origY;){var e=b.chain(this.nodes).find(b.bind(g._didCollide,{n:a,newY:d})).value();e||(a._dirty=!0,a.y=d),--d}},this)):b.each(this.nodes,b.bind(function(a,c){if(!a.locked)for(;a.y>0;){var d=a.y-1,e=0===c;if(c>0){var f=b.chain(this.nodes).take(c).find(b.bind(g._didCollide,{n:a,newY:d})).value();e="undefined"==typeof f}if(!e)break;a._dirty=a.y!=d,a.y=d}},this))},i.prototype._prepareNode=function(a,c){return a=b.defaults(a||{},{width:1,height:1,x:0,y:0}),a.x=parseInt(""+a.x),a.y=parseInt(""+a.y),a.width=parseInt(""+a.width),a.height=parseInt(""+a.height),a.autoPosition=a.autoPosition||!1,a.noResize=a.noResize||!1,a.noMove=a.noMove||!1,a.width>this.width?a.width=this.width:a.width<1&&(a.width=1),this.height&&a.height>this.height?a.height=this.height:a.height<1&&(a.height=1),a.x<0&&(a.x=0),a.x+a.width>this.width&&(c?a.width=this.width-a.x:a.x=this.width-a.width),a.y<0&&(a.y=0),a},i.prototype._notify=function(){var a=Array.prototype.slice.call(arguments,0);if(a[0]="undefined"==typeof a[0]?[]:[a[0]],a[1]="undefined"==typeof a[1]||a[1],!this._updateCounter){var b=a[0].concat(this.getDirtyNodes());this.onchange(b,a[1])}},i.prototype.cleanNodes=function(){this._updateCounter||b.each(this.nodes,function(a){a._dirty=!1})},i.prototype.getDirtyNodes=function(){return b.filter(this.nodes,function(a){return a._dirty})},i.prototype.addNode=function(a,c,d){if(a=this._prepareNode(a),"undefined"!=typeof a.maxWidth&&(a.width=Math.min(a.width,a.maxWidth)),"undefined"!=typeof a.maxHeight&&(a.height=Math.min(a.height,a.maxHeight)),"undefined"!=typeof a.minWidth&&(a.width=Math.max(a.width,a.minWidth)),"undefined"!=typeof a.minHeight&&(a.height=Math.max(a.height,a.minHeight)),a._id=++h,a._dirty=!0,a.autoPosition){this._sortNodes();for(var e=0;;++e){var f=e%this.width,i=Math.floor(e/this.width);if(!(f+a.width>this.width||b.find(this.nodes,b.bind(g._isAddNodeIntercepted,{x:f,y:i,node:a})))){a.x=f,a.y=i;break}}}return this.nodes.push(a),"undefined"!=typeof c&&c&&this._addedNodes.push(b.clone(a)),this._fixCollisions(a,d),this._packNodes(),this._notify(),a},i.prototype.removeNode=function(a,c){a&&(a._id=null,this.nodes=b.without(this.nodes,a),this._packNodes(),this._notify(a,c))},i.prototype.canMoveNode=function(c,d,e,f,g){if(!this.isNodeChangedPosition(c,d,e,f,g))return!1;var h=Boolean(b.find(this.nodes,function(a){return a.locked}));if(!this.height&&!h)return!0;if(!this.isAreaEmpty(d,e,f,g,c))return!1;var j,k=new i(this.width,null,this["float"],0,b.map(this.nodes,function(b){return b==c?j=a.extend({},b):a.extend({},b)}));if("undefined"==typeof j)return!0;k.moveNode(j,d,e,f,g,!1,!0);var l=!0; // always allow moving the one out of bounds -return h&&(l&=!Boolean(b.find(k.nodes,function(a){return a!=j&&Boolean(a.locked)&&Boolean(a._dirty)}))),this.height&&(l&=k.getGridHeight()<=this.height,c.y+c.height>this.height&&(l=!0)),l},i.prototype.canBePlacedWithRespectToHeight=function(c){if(!this.height)return!0;var d=new i(this.width,null,this["float"],0,b.map(this.nodes,function(b){return a.extend({},b)}));return d.addNode(c,!1,!0),d.getGridHeight()<=this.height},i.prototype.isNodeChangedPosition=function(a,b,c,d,e){return"number"!=typeof b&&(b=a.x),"number"!=typeof c&&(c=a.y),"number"!=typeof d&&(d=a.width),"number"!=typeof e&&(e=a.height),"undefined"!=typeof a.maxWidth&&(d=Math.min(d,a.maxWidth)),"undefined"!=typeof a.maxHeight&&(e=Math.min(e,a.maxHeight)),"undefined"!=typeof a.minWidth&&(d=Math.max(d,a.minWidth)),"undefined"!=typeof a.minHeight&&(e=Math.max(e,a.minHeight)),a.x!=b||a.y!=c||a.width!=d||a.height!=e},i.prototype.moveNode=function(a,b,c,d,e,f,g){if(!this.isNodeChangedPosition(a,b,c,d,e))return a;if("number"!=typeof b&&(b=a.x),"number"!=typeof c&&(c=a.y),"number"!=typeof d&&(d=a.width),"number"!=typeof e&&(e=a.height),"undefined"!=typeof a.maxWidth&&(d=Math.min(d,a.maxWidth)),"undefined"!=typeof a.maxHeight&&(e=Math.min(e,a.maxHeight)),"undefined"!=typeof a.minWidth&&(d=Math.max(d,a.minWidth)),"undefined"!=typeof a.minHeight&&(e=Math.max(e,a.minHeight)),a.x==b&&a.y==c&&a.width==d&&a.height==e)return a;var h=a.width!=d;return a._dirty=!0,a.x=b,a.y=c,a.width=d,a.height=e,a.lastTriedX=b,a.lastTriedY=c,a.lastTriedWidth=d,a.lastTriedHeight=e,a=this._prepareNode(a,h),this._fixCollisions(a,g),f||(this._packNodes(),this._notify()),a},i.prototype.getGridHeight=function(){return b.reduce(this.nodes,function(a,b){return Math.max(a,b.y+b.height)},0)},i.prototype.beginUpdate=function(a){b.each(this.nodes,function(a){a._origY=a.y}),a._updating=!0},i.prototype.endUpdate=function(){b.each(this.nodes,function(a){a._origY=a.y});var a=b.find(this.nodes,function(a){return a._updating});a&&(a._updating=!1)};var j=function(d,e){var g,h,j=this;e=e||{},this.container=a(d), +return h&&(l&=!Boolean(b.find(k.nodes,function(a){return a!=j&&Boolean(a.locked)&&Boolean(a._dirty)}))),this.height&&(l&=k.getGridHeight()<=this.height,c.y+c.height>this.height&&(l=!0)),l},i.prototype.canBePlacedWithRespectToHeight=function(c){if(!this.height)return!0;var d=new i(this.width,null,this["float"],0,b.map(this.nodes,function(b){return a.extend({},b)}));return d.addNode(c,!1,!0),d.getGridHeight()<=this.height},i.prototype.isNodeChangedPosition=function(a,b,c,d,e){return"number"!=typeof b&&(b=a.x),"number"!=typeof c&&(c=a.y),"number"!=typeof d&&(d=a.width),"number"!=typeof e&&(e=a.height),"undefined"!=typeof a.maxWidth&&(d=Math.min(d,a.maxWidth)),"undefined"!=typeof a.maxHeight&&(e=Math.min(e,a.maxHeight)),"undefined"!=typeof a.minWidth&&(d=Math.max(d,a.minWidth)),"undefined"!=typeof a.minHeight&&(e=Math.max(e,a.minHeight)),a.x!=b||a.y!=c||a.width!=d||a.height!=e},i.prototype.moveNode=function(a,b,c,d,e,f,g){if(!this.isNodeChangedPosition(a,b,c,d,e))return a;if("number"!=typeof b&&(b=a.x),"number"!=typeof c&&(c=a.y),"number"!=typeof d&&(d=a.width),"number"!=typeof e&&(e=a.height),"undefined"!=typeof a.maxWidth&&(d=Math.min(d,a.maxWidth)),"undefined"!=typeof a.maxHeight&&(e=Math.min(e,a.maxHeight)),"undefined"!=typeof a.minWidth&&(d=Math.max(d,a.minWidth)),"undefined"!=typeof a.minHeight&&(e=Math.max(e,a.minHeight)),a.x==b&&a.y==c&&a.width==d&&a.height==e)return a;if(!this.isAreaEmpty(b,c,d,e,a))return a;var h=a.width!=d;return a._dirty=!0,a.x=b,a.y=c,a.width=d,a.height=e,a.lastTriedX=b,a.lastTriedY=c,a.lastTriedWidth=d,a.lastTriedHeight=e,a=this._prepareNode(a,h),this._fixCollisions(a,g),f||(this._packNodes(),this._notify()),a},i.prototype.getGridHeight=function(){return b.reduce(this.nodes,function(a,b){return Math.max(a,b.y+b.height)},0)},i.prototype.beginUpdate=function(a){b.each(this.nodes,function(a){a._origY=a.y}),a._updating=!0},i.prototype.endUpdate=function(){b.each(this.nodes,function(a){a._origY=a.y});var a=b.find(this.nodes,function(a){return a._updating});a&&(a._updating=!1)};var j=function(d,e){var g,h,j=this;e=e||{},this.container=a(d), // jscs:disable requireCamelCaseOrUpperCaseIdentifiers "undefined"!=typeof e.handle_class&&(e.handleClass=e.handle_class,f("handle_class","handleClass")),"undefined"!=typeof e.item_class&&(e.itemClass=e.item_class,f("item_class","itemClass")),"undefined"!=typeof e.placeholder_class&&(e.placeholderClass=e.placeholder_class,f("placeholder_class","placeholderClass")),"undefined"!=typeof e.placeholder_text&&(e.placeholderText=e.placeholder_text,f("placeholder_text","placeholderText")),"undefined"!=typeof e.cell_height&&(e.cellHeight=e.cell_height,f("cell_height","cellHeight")),"undefined"!=typeof e.vertical_margin&&(e.verticalMargin=e.vertical_margin,f("vertical_margin","verticalMargin")),"undefined"!=typeof e.min_width&&(e.minWidth=e.min_width,f("min_width","minWidth")),"undefined"!=typeof e.static_grid&&(e.staticGrid=e.static_grid,f("static_grid","staticGrid")),"undefined"!=typeof e.is_nested&&(e.isNested=e.is_nested,f("is_nested","isNested")),"undefined"!=typeof e.always_show_resize_handle&&(e.alwaysShowResizeHandle=e.always_show_resize_handle,f("always_show_resize_handle","alwaysShowResizeHandle")), // jscs:enable requireCamelCaseOrUpperCaseIdentifiers diff --git a/dist/gridstack.min.map b/dist/gridstack.min.map index eb8e837af..435bbc3e2 100644 --- a/dist/gridstack.min.map +++ b/dist/gridstack.min.map @@ -1 +1 @@ -{"version":3,"sources":["../src/gridstack.js","../src/gridstack.jQueryUI.js"],"names":["factory","define","amd","exports","jQuery","require","e","_","$","GridStackDragDropPlugin","grid","this","scope","window","obsolete","f","oldName","newName","wrapper","console","warn","apply","arguments","prototype","obsoleteOpts","Utils","isIntercepted","a","b","x","width","y","height","sort","nodes","dir","chain","map","node","max","value","sortBy","n","createStylesheet","id","style","document","createElement","setAttribute","styleSheet","cssText","appendChild","createTextNode","getElementsByTagName","sheet","removeStylesheet","remove","insertCSSRule","selector","rules","index","insertRule","addRule","toBool","v","toLowerCase","Boolean","_collisionNodeCheck","nn","_didCollide","bn","newY","_isAddNodeIntercepted","parseHeight","val","heightUnit","isString","match","Error","parseFloat","unit","is_intercepted","create_stylesheet","remove_stylesheet","insert_css_rule","registeredPlugins","registerPlugin","pluginClass","push","resizable","el","opts","draggable","droppable","isDroppable","on","eventName","callback","idSeq","GridStackEngine","onchange","floatMode","items","_updateCounter","_float","_addedNodes","_removedNodes","batchUpdate","commit","_packNodes","_notify","getNodeDataByDOMEl","find","get","_fixCollisions","isClone","_sortNodes","hasLocked","locked","collisionNode","bind","newPos","wrongPos","isAreaEmpty","_origY","w","h","findFreeSpace","moveNode","whatIsHere","collisionNodes","filter","exceptNode","length","forNode","i","j","freeSpace","each","_updating","_dirty","canBeMoved","take","_prepareNode","resizing","defaults","parseInt","autoPosition","noResize","noMove","args","Array","slice","call","deletedNodes","concat","getDirtyNodes","cleanNodes","addNode","triggerAddEvent","maxWidth","Math","min","maxHeight","minWidth","minHeight","_id","floor","clone","removeNode","detachNode","without","canMoveNode","isNodeChangedPosition","clonedNode","extend","res","getGridHeight","canBePlacedWithRespectToHeight","noPack","lastTriedX","lastTriedY","lastTriedWidth","lastTriedHeight","reduce","memo","beginUpdate","endUpdate","GridStack","oneColumnMode","isAutoCellHeight","self","container","handle_class","handleClass","item_class","itemClass","placeholder_class","placeholderClass","placeholder_text","placeholderText","cell_height","cellHeight","vertical_margin","verticalMargin","min_width","static_grid","staticGrid","is_nested","isNested","always_show_resize_handle","alwaysShowResizeHandle","closest","attr","handle","auto","float","_class","random","toFixed","animate","autoHide","handles","scroll","appendTo","disableDrag","disableResize","rtl","removable","removeTimeout","verticalMarginUnit","cellHeightUnit","oneColumnModeClass","ddPlugin","first","dd","css","addClass","cellWidth","_setStaticClass","_initStyles","_updateStyles","max_height","elements","_this","children","_prepareElement","setAnimation","placeholder","hide","_updateContainerHeight","_updateHeightsOnResize","throttle","onResizeHandler","_isOneColumnMode","append","trigger","removeClass","resize","trashZone","accept","event","ui","data","_grid","_setupRemovingTimeout","_clearRemovingTimeout","acceptWidgets","draggingElement","onDrag","pos","getCellFromPixel","offset","_added","show","_beforeDragX","_beforeDragY","is","origNode","ceil","outerWidth","outerHeight","_temporary","unbind","detach","removeAttr","enableSelection","removeData","_prepareElementsByNode","_triggerChangeEvent","forceTrigger","hasChanges","eventParams","_triggerAddEvent","_triggerRemoveEvent","_stylesId","_styles","_max","getHeight","prefix","nbRows","nbMargins","innerWidth","documentElement","clientWidth","body","_removeTimeout","setTimeout","_isAboutToRemove","clearTimeout","dragOrResize","round","position","left","top","type","size","_temporaryRemoved","onStartMoving","originalEvent","target","o","strictCellHeight","onEndMoving","forceNotify","nestedGrids","start","stop","drag","enable","addWidget","makeWidget","willItFit","removeWidget","removeAll","destroy","detachGrid","off","disable","movable","enableMove","doEnable","includeNewWidgets","enableResize","isNaN","_updateElement","move","update","noUpdate","heightData","useOffset","containerPos","relativeLeft","relativeTop","columnWidth","rowHeight","setStatic","staticValue","staticClassName","refreshNodes","isDisabled","that","k","getCellFromAbsolutePixel","nodeOffset","_updateNodeWidths","oldWidth","newWidth","undefined","setGridWidth","gridWidth","doNotPropagate","batch_update","_fix_collisions","is_area_empty","_sort_nodes","_pack_nodes","_prepare_node","clean_nodes","get_dirty_nodes","add_node","remove_node","can_move_node","move_node","get_grid_height","begin_update","end_update","can_be_placed_with_respect_to_height","_trigger_change_event","_init_styles","_update_styles","_update_container_height","_is_one_column_mode","_prepare_element","set_animation","add_widget","make_widget","will_it_fit","remove_widget","remove_all","min_height","_update_element","cell_width","get_cell_from_pixel","set_static","_set_static_class","GridStackUI","Engine","fn","gridstack","JQueryUIGridStackDragDropPlugin","Object","create","constructor","key","containment","parent"],"mappings":";;;;;;;CAOA,SAAUA,GACN,GAAsB,kBAAXC,SAAyBA,OAAOC,IACvCD,QAAQ,SAAU,UAAWD,OAC1B,IAAuB,mBAAZG,SAAyB,CACvC,IAAMC,OAASC,QAAQ,UAAa,MAAOC,IAC3C,IAAMC,EAAIF,QAAQ,UAAa,MAAOC,IACtCN,EAAQI,OAAQG,OAEhBP,GAAQI,OAAQG,IAErB,SAASC,EAAGD;;;;;;AA4GX,QAASE,GAAwBC,GAC7BC,KAAKD,KAAOA,EA3GhB,GAAIE,GAAQC,OAERC,EAAW,SAASC,EAAGC,EAASC,GAChC,GAAIC,GAAU,WAGV,MAFAC,SAAQC,KAAK,2BAA6BJ,EAAU,4DACzCC,EAAU,iDACdF,EAAEM,MAAMV,KAAMW,WAIzB,OAFAJ,GAAQK,UAAYR,EAAEQ,UAEfL,GAGPM,EAAe,SAASR,EAASC,GACjCE,QAAQC,KAAK,yBAA2BJ,EAAU,4DAC9CC,EAAU,kDAGdQ,GACAC,cAAe,SAASC,EAAGC,GACvB,QAASD,EAAEE,EAAIF,EAAEG,OAASF,EAAEC,GAAKD,EAAEC,EAAID,EAAEE,OAASH,EAAEE,GAAKF,EAAEI,EAAIJ,EAAEK,QAAUJ,EAAEG,GAAKH,EAAEG,EAAIH,EAAEI,QAAUL,EAAEI,IAG1GE,KA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KtX,OAExBkD,GAAGD,UAAUlF,EAAEwK,UAAWpK,KAAKD,KAAKiF,KAAKF,WACrC6O,MAAO3O,EAAK2O,OAAS,aACrBC,KAAM5O,EAAK4O,MAAQ,aACnBrE,OAAQvK,EAAKuK,QAAU,eAG/B,OAAOvP,OAGX+Y,EAAgCnY,UAAUqE,UAAY,SAASF,EAAIC,GAY/D,MAXAD,GAAKlF,EAAEkF,GACM,YAATC,GAA+B,WAATA,EACtBD,EAAGE,UAAUD,GAEbD,EAAGE,UAAUrF,EAAEwK,UAAWpK,KAAKD,KAAKiF,KAAKC,WACrCmU,YAAapZ,KAAKD,KAAKiF,KAAKsH,SAAWtM,KAAKD,KAAKsL,UAAUgO,SAAW,KACtE1F,MAAO3O,EAAK2O,OAAS,aACrBC,KAAM5O,EAAK4O,MAAQ,aACnBC,KAAM7O,EAAK6O,MAAQ,gBAGpB7T,MAGX+Y,EAAgCnY,UAAUsE,UAAY,SAASH,EAAIC,GAS/D,MARAD,GAAKlF,EAAEkF,GACM,YAATC,GAA+B,WAATA,EACtBD,EAAGG,UAAUF,GAEbD,EAAGG,WACCuK,OAAQzK,EAAKyK,SAGdzP,MAGX+Y,EAAgCnY,UAAUuE,YAAc,SAASJ,EAAIC,GAEjE,MADAD,GAAKlF,EAAEkF,GACAxB,QAAQwB,EAAG6K,KAAK,eAG3BmJ,EAAgCnY,UAAUwE,GAAK,SAASL,EAAIM,EAAWC,GAEnE,MADAzF,GAAEkF,GAAIK,GAAGC,EAAWC,GACbtF,MAGJ+Y","file":"gridstack.all.js"} \ No newline at end of file +{"version":3,"sources":["../src/gridstack.js","../src/gridstack.jQueryUI.js"],"names":["factory","define","amd","exports","jQuery","require","e","_","$","GridStackDragDropPlugin","grid","this","scope","window","obsolete","f","oldName","newName","wrapper","console","warn","apply","arguments","prototype","obsoleteOpts","Utils","isIntercepted","a","b","x","width","y","height","sort","nodes","dir","chain","map","node","max","value","sortBy","n","createStylesheet","id","style","document","createElement","setAttribute","styleSheet","cssText","appendChild","createTextNode","getElementsByTagName","sheet","removeStylesheet","remove","insertCSSRule","selector","rules","index","insertRule","addRule","toBool","v","toLowerCase","Boolean","_collisionNodeCheck","nn","_didCollide","bn","newY","_isAddNodeIntercepted","parseHeight","val","heightUnit","isString","match","Error","parseFloat","unit","is_intercepted","create_stylesheet","remove_stylesheet","insert_css_rule","registeredPlugins","registerPlugin","pluginClass","push","resizable","el","opts","draggable","droppable","isDroppable","on","eventName","callback","idSeq","GridStackEngine","onchange","floatMode","items","_updateCounter","_float","_addedNodes","_removedNodes","batchUpdate","commit","_packNodes","_notify","getNodeDataByDOMEl","find","get","_fixCollisions","isClone","_sortNodes","hasLocked","locked","collisionNode","bind","moveNode","whatIsHere","collisionNodes","filter","isAreaEmpty","exceptNode","length","findFreeSpace","w","h","forNode","i","j","freeSpace","each","_updating","_origY","_dirty","canBeMoved","take","_prepareNode","resizing","defaults","parseInt","autoPosition","noResize","noMove","args","Array","slice","call","deletedNodes","concat","getDirtyNodes","cleanNodes","addNode","triggerAddEvent","maxWidth","Math","min","maxHeight","minWidth","minHeight","_id","floor","clone","removeNode","detachNode","without","canMoveNode","isNodeChangedPosition","clonedNode","extend","res","getGridHeight","canBePlacedWithRespectToHeight","noPack","lastTriedX","lastTriedY","lastTriedWidth","lastTriedHeight","reduce","memo","beginUpdate","endUpdate","GridStack","oneColumnMode","isAutoCellHeight","self","container","handle_class","handleClass","item_class","itemClass","placeholder_class","placeholderClass","placeholder_text","placeholderText","cell_height","cellHeight","vertical_margin","verticalMargin","min_width","static_grid","staticGrid","is_nested","isNested","always_show_resize_handle","alwaysShowResizeHandle","closest","attr","handle","auto","float","_class","random","toFixed","animate","autoHide","handles","scroll","appendTo","disableDrag","disableResize","rtl","removable","removeTimeout","verticalMarginUnit","cellHeightUnit","oneColumnModeClass","ddPlugin","first","dd","css","addClass","cellWidth","_setStaticClass","_initStyles","_updateStyles","max_height","elements","_this","children","_prepareElement","setAnimation","placeholder","hide","_updateContainerHeight","_updateHeightsOnResize","throttle","onResizeHandler","_isOneColumnMode","append","trigger","removeClass","resize","trashZone","accept","event","ui","data","_grid","_setupRemovingTimeout","_clearRemovingTimeout","acceptWidgets","draggingElement","onDrag","pos","getCellFromPixel","offset","_added","show","_beforeDragX","_beforeDragY","is","origNode","ceil","outerWidth","outerHeight","_temporary","unbind","detach","removeAttr","enableSelection","removeData","_prepareElementsByNode","_triggerChangeEvent","forceTrigger","hasChanges","eventParams","_triggerAddEvent","_triggerRemoveEvent","_stylesId","_styles","_max","getHeight","prefix","nbRows","nbMargins","innerWidth","documentElement","clientWidth","body","_removeTimeout","setTimeout","_isAboutToRemove","clearTimeout","dragOrResize","round","position","left","top","type","size","_temporaryRemoved","onStartMoving","originalEvent","target","o","strictCellHeight","onEndMoving","forceNotify","nestedGrids","start","stop","drag","enable","addWidget","makeWidget","willItFit","removeWidget","removeAll","destroy","detachGrid","off","disable","movable","enableMove","doEnable","includeNewWidgets","enableResize","isNaN","_updateElement","move","update","noUpdate","heightData","useOffset","containerPos","relativeLeft","relativeTop","columnWidth","rowHeight","setStatic","staticValue","staticClassName","refreshNodes","isDisabled","that","k","getCellFromAbsolutePixel","nodeOffset","_updateNodeWidths","oldWidth","newWidth","undefined","setGridWidth","gridWidth","doNotPropagate","batch_update","_fix_collisions","is_area_empty","_sort_nodes","_pack_nodes","_prepare_node","clean_nodes","get_dirty_nodes","add_node","remove_node","can_move_node","move_node","get_grid_height","begin_update","end_update","can_be_placed_with_respect_to_height","_trigger_change_event","_init_styles","_update_styles","_update_container_height","_is_one_column_mode","_prepare_element","set_animation","add_widget","make_widget","will_it_fit","remove_widget","remove_all","min_height","_update_element","cell_width","get_cell_from_pixel","set_static","_set_static_class","GridStackUI","Engine","fn","gridstack","JQueryUIGridStackDragDropPlugin","Object","create","constructor","key","containment","parent"],"mappings":";;;;;;;CAOA,SAAUA,GACN,GAAsB,kBAAXC,SAAyBA,OAAOC,IACvCD,QAAQ,SAAU,UAAWD,OAC1B,IAAuB,mBAAZG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eAG3BmJ,EAAgCjY,UAAUwE,GAAK,SAASL,EAAIM,EAAWC,GAEnE,MADAzF,GAAEkF,GAAIK,GAAGC,EAAWC,GACbtF,MAGJ6Y","file":"gridstack.all.js"} \ No newline at end of file From 9bf2f87e0ba92b6fffac23d838db26985b51b0f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Inga=20Br=C5=ABnava?= Date: Wed, 25 Jan 2017 10:31:13 +0100 Subject: [PATCH 25/35] Remove overlayed items at start --- src/gridstack.js | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/src/gridstack.js b/src/gridstack.js index 750260304..0a620be96 100644 --- a/src/gridstack.js +++ b/src/gridstack.js @@ -1282,11 +1282,12 @@ el = $(el); el.addClass(this.opts.itemClass); - var node = self.grid.addNode({ - x: el.attr('data-gs-x'), - y: el.attr('data-gs-y'), - width: el.attr('data-gs-width'), - height: el.attr('data-gs-height'), + + var props = { + x: parseInt(el.attr('data-gs-x'), 10), + y: parseInt(el.attr('data-gs-y'), 10), + width: parseInt(el.attr('data-gs-width'), 10), + height: parseInt(el.attr('data-gs-height'), 10), maxWidth: el.attr('data-gs-max-width'), minWidth: el.attr('data-gs-min-width'), maxHeight: el.attr('data-gs-max-height'), @@ -1298,7 +1299,24 @@ el: el, id: el.attr('data-gs-id'), _grid: self - }, triggerAddEvent); + }; + + if (!this.isAreaEmpty(props.x, props.y, props.width, props.height)) { + var freeSpace = this.findFreeSpace(props.width, props.height); + if (!freeSpace) { + freeSpace = this.findFreeSpace(1, 1); + } + if (freeSpace) { + props.x = freeSpace.x; + props.y = freeSpace.y; + props.width = freeSpace.w; + props.height = freeSpace.h; + } else { + return; + } + } + + var node = self.grid.addNode(props, triggerAddEvent); el.data('_gridstack_node', node); this._prepareElementsByNode(el, node); From c429dfb4eda450c15fe8a77b203b2a3dc91f8276 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Inga=20Br=C5=ABnava?= Date: Wed, 25 Jan 2017 10:31:45 +0100 Subject: [PATCH 26/35] Assets --- dist/gridstack.all.js | 2 +- dist/gridstack.js | 30 ++++++++++++++++++++++++------ dist/gridstack.min.js | 2 +- dist/gridstack.min.map | 2 +- 4 files changed, 27 insertions(+), 9 deletions(-) diff --git a/dist/gridstack.all.js b/dist/gridstack.all.js index 0f5c843ca..83f2b9aee 100644 --- a/dist/gridstack.all.js +++ b/dist/gridstack.all.js @@ -32,7 +32,7 @@ this._updateStyles(),this._updateHeightsOnResize=b.throttle(function(){j.cellHei // jscs:enable requireCamelCaseOrUpperCaseIdentifiers return j.prototype._triggerChangeEvent=function(a){var b=this.grid.getDirtyNodes(),c=!1,d=[];b&&b.length&&(d.push(b),c=!0),(c||a===!0)&&this.container.trigger("change",d)},j.prototype._triggerAddEvent=function(){this.grid._addedNodes&&this.grid._addedNodes.length>0&&(this.container.trigger("added",[b.map(this.grid._addedNodes,b.clone)]),this.grid._addedNodes=[])},j.prototype._triggerRemoveEvent=function(){this.grid._removedNodes&&this.grid._removedNodes.length>0&&(this.container.trigger("removed",[b.map(this.grid._removedNodes,b.clone)]),this.grid._removedNodes=[])},j.prototype._initStyles=function(){this._stylesId&&g.removeStylesheet(this._stylesId),this._stylesId="gridstack-style-"+(1e5*Math.random()).toFixed(),this._styles=g.createStylesheet(this._stylesId),null!==this._styles&&(this._styles._max=0)},j.prototype._updateStyles=function(a){if(null!==this._styles&&"undefined"!=typeof this._styles){var b,c="."+this.opts._class+" ."+this.opts.itemClass,d=this;if("undefined"==typeof a&&(a=this._styles._max||this.opts.height,this._initStyles(),this._updateContainerHeight()),this.opts.cellHeight&&!(0!==this._styles._max&&a<=this._styles._max)&&(b=this.opts.verticalMargin&&this.opts.cellHeightUnit!==this.opts.verticalMarginUnit?function(a,b){return a&&b?"calc("+(d.opts.cellHeight*a+d.opts.cellHeightUnit)+" + "+(d.opts.verticalMargin*b+d.opts.verticalMarginUnit)+")":d.opts.cellHeight*a+d.opts.verticalMargin*b+d.opts.cellHeightUnit}:function(a,b){return d.opts.cellHeight*a+d.opts.verticalMargin*b+d.opts.cellHeightUnit},0===this._styles._max&&g.insertCSSRule(this._styles,c,"min-height: "+b(1,0)+";",0),a>this._styles._max)){for(var e=this._styles._max;e=f.grid.width||k<0||f.grid.height&&k>=f.grid.height?(f.opts.removable===!0&&f._setupRemovingTimeout(b),j=c._beforeDragX,k=c._beforeDragY,f.placeholder.detach(),f.placeholder.hide(),f.grid.removeNode(c),f._updateContainerHeight(),c._temporaryRemoved=!0):(f._clearRemovingTimeout(b),c._temporaryRemoved&&(f.grid.addNode(c),f.placeholder.attr("data-gs-x",j).attr("data-gs-y",k).attr("data-gs-width",h).attr("data-gs-height",i).show(),f.container.append(f.placeholder),c.el=f.placeholder,c._temporaryRemoved=!1));else if("resize"==a.type&&j<0)return; // width and height are undefined if not resizing -var l="undefined"!=typeof h?h:c.lastTriedWidth,m="undefined"!=typeof i?i:c.lastTriedHeight;!f.grid.canMoveNode(c,j,k,h,i)||c.lastTriedX===j&&c.lastTriedY===k&&c.lastTriedWidth===l&&c.lastTriedHeight===m||(c.lastTriedX=j,c.lastTriedY=k,c.lastTriedWidth=h,c.lastTriedHeight=i,f.grid.moveNode(c,j,k,h,i),f._updateContainerHeight())},h=function(g,h){if(f.opts.draggable.handle&&"dragstart"===g.type&&!a(g.originalEvent.target).closest(f.opts.draggable.handle).length)return!1;f.container.append(f.placeholder);var i=a(this);f.grid.cleanNodes(),f.grid.beginUpdate(c),d=f.cellWidth();var j=Math.ceil(i.outerHeight()/i.attr("data-gs-height"));e=f.container.height()/parseInt(f.container.attr("data-gs-current-height")),f.placeholder.attr("data-gs-x",i.attr("data-gs-x")).attr("data-gs-y",i.attr("data-gs-y")).attr("data-gs-width",i.attr("data-gs-width")).attr("data-gs-height",i.attr("data-gs-height")).show(),c.el=f.placeholder,c._beforeDragX=c.x,c._beforeDragY=c.y,f.dd.resizable(b,"option","minWidth",d*(c.minWidth||1)),f.dd.resizable(b,"option","minHeight",j*(c.minHeight||1)),"resizestart"==g.type&&i.find(".grid-stack-item").trigger("resizestart")},i=function(d,e){var g=a(this);if(g.data("_gridstack_node")){var h=!1;f.placeholder.detach(),c.el=g,f.placeholder.hide(),c._isAboutToRemove?(h=!0,b.removeData("_gridstack_node"),b.remove()):(f._clearRemovingTimeout(b),c._temporaryRemoved?(g.attr("data-gs-x",c._beforeDragX).attr("data-gs-y",c._beforeDragY).attr("data-gs-width",c.width).attr("data-gs-height",c.height).removeAttr("style"),c.x=c._beforeDragX,c.y=c._beforeDragY,f.grid.addNode(c)):g.attr("data-gs-x",c.x).attr("data-gs-y",c.y).attr("data-gs-width",c.width).attr("data-gs-height",c.height).removeAttr("style")),f._updateContainerHeight(),f._triggerChangeEvent(h),f.grid.endUpdate();var i=g.find(".grid-stack");i.length&&"resizestop"==d.type&&(i.each(function(b,c){a(c).data("gridstack").onResizeHandler()}),g.find(".grid-stack-item").trigger("resizestop"))}};this.dd.draggable(b,{start:h,stop:i,drag:g}).resizable(b,{start:h,stop:i,resize:g}),(c.noMove||this._isOneColumnMode()||this.opts.disableDrag)&&this.dd.draggable(b,"disable"),(c.noResize||this._isOneColumnMode()||this.opts.disableResize)&&this.dd.resizable(b,"disable"),b.attr("data-gs-locked",c.locked?"yes":null)}},j.prototype._prepareElement=function(b,c){c="undefined"!=typeof c&&c;var d=this;b=a(b),b.addClass(this.opts.itemClass);var e=d.grid.addNode({x:b.attr("data-gs-x"),y:b.attr("data-gs-y"),width:b.attr("data-gs-width"),height:b.attr("data-gs-height"),maxWidth:b.attr("data-gs-max-width"),minWidth:b.attr("data-gs-min-width"),maxHeight:b.attr("data-gs-max-height"),minHeight:b.attr("data-gs-min-height"),autoPosition:g.toBool(b.attr("data-gs-auto-position")),noResize:g.toBool(b.attr("data-gs-no-resize")),noMove:g.toBool(b.attr("data-gs-no-move")),locked:g.toBool(b.attr("data-gs-locked")),el:b,id:b.attr("data-gs-id"),_grid:d},c);b.data("_gridstack_node",e),this._prepareElementsByNode(b,e)},j.prototype.setAnimation=function(a){a?this.container.addClass("grid-stack-animate"):this.container.removeClass("grid-stack-animate")},j.prototype.addWidget=function(b,c,d,e,f,g,h,i,j,k,l){return b=a(b),"undefined"!=typeof c&&b.attr("data-gs-x",c),"undefined"!=typeof d&&b.attr("data-gs-y",d),"undefined"!=typeof e&&b.attr("data-gs-width",e),"undefined"!=typeof f&&b.attr("data-gs-height",f),"undefined"!=typeof g&&b.attr("data-gs-auto-position",g?"yes":null),"undefined"!=typeof h&&b.attr("data-gs-min-width",h),"undefined"!=typeof i&&b.attr("data-gs-max-width",i),"undefined"!=typeof j&&b.attr("data-gs-min-height",j),"undefined"!=typeof k&&b.attr("data-gs-max-height",k),"undefined"!=typeof l&&b.attr("data-gs-id",l),this.container.append(b),this.makeWidget(b),b},j.prototype.makeWidget=function(b){return b=a(b),this._prepareElement(b,!0),this._triggerAddEvent(),this._updateContainerHeight(),this._triggerChangeEvent(!0),b},j.prototype.willItFit=function(a,b,c,d,e){var f={x:a,y:b,width:c,height:d,autoPosition:e};return this.grid.canBePlacedWithRespectToHeight(f)},j.prototype.removeWidget=function(b,c){c="undefined"==typeof c||c,b=a(b);var d=b.data("_gridstack_node"); +var l="undefined"!=typeof h?h:c.lastTriedWidth,m="undefined"!=typeof i?i:c.lastTriedHeight;!f.grid.canMoveNode(c,j,k,h,i)||c.lastTriedX===j&&c.lastTriedY===k&&c.lastTriedWidth===l&&c.lastTriedHeight===m||(c.lastTriedX=j,c.lastTriedY=k,c.lastTriedWidth=h,c.lastTriedHeight=i,f.grid.moveNode(c,j,k,h,i),f._updateContainerHeight())},h=function(g,h){if(f.opts.draggable.handle&&"dragstart"===g.type&&!a(g.originalEvent.target).closest(f.opts.draggable.handle).length)return!1;f.container.append(f.placeholder);var i=a(this);f.grid.cleanNodes(),f.grid.beginUpdate(c),d=f.cellWidth();var j=Math.ceil(i.outerHeight()/i.attr("data-gs-height"));e=f.container.height()/parseInt(f.container.attr("data-gs-current-height")),f.placeholder.attr("data-gs-x",i.attr("data-gs-x")).attr("data-gs-y",i.attr("data-gs-y")).attr("data-gs-width",i.attr("data-gs-width")).attr("data-gs-height",i.attr("data-gs-height")).show(),c.el=f.placeholder,c._beforeDragX=c.x,c._beforeDragY=c.y,f.dd.resizable(b,"option","minWidth",d*(c.minWidth||1)),f.dd.resizable(b,"option","minHeight",j*(c.minHeight||1)),"resizestart"==g.type&&i.find(".grid-stack-item").trigger("resizestart")},i=function(d,e){var g=a(this);if(g.data("_gridstack_node")){var h=!1;f.placeholder.detach(),c.el=g,f.placeholder.hide(),c._isAboutToRemove?(h=!0,b.removeData("_gridstack_node"),b.remove()):(f._clearRemovingTimeout(b),c._temporaryRemoved?(g.attr("data-gs-x",c._beforeDragX).attr("data-gs-y",c._beforeDragY).attr("data-gs-width",c.width).attr("data-gs-height",c.height).removeAttr("style"),c.x=c._beforeDragX,c.y=c._beforeDragY,f.grid.addNode(c)):g.attr("data-gs-x",c.x).attr("data-gs-y",c.y).attr("data-gs-width",c.width).attr("data-gs-height",c.height).removeAttr("style")),f._updateContainerHeight(),f._triggerChangeEvent(h),f.grid.endUpdate();var i=g.find(".grid-stack");i.length&&"resizestop"==d.type&&(i.each(function(b,c){a(c).data("gridstack").onResizeHandler()}),g.find(".grid-stack-item").trigger("resizestop"))}};this.dd.draggable(b,{start:h,stop:i,drag:g}).resizable(b,{start:h,stop:i,resize:g}),(c.noMove||this._isOneColumnMode()||this.opts.disableDrag)&&this.dd.draggable(b,"disable"),(c.noResize||this._isOneColumnMode()||this.opts.disableResize)&&this.dd.resizable(b,"disable"),b.attr("data-gs-locked",c.locked?"yes":null)}},j.prototype._prepareElement=function(b,c){c="undefined"!=typeof c&&c;var d=this;b=a(b),b.addClass(this.opts.itemClass);var e={x:parseInt(b.attr("data-gs-x"),10),y:parseInt(b.attr("data-gs-y"),10),width:parseInt(b.attr("data-gs-width"),10),height:parseInt(b.attr("data-gs-height"),10),maxWidth:b.attr("data-gs-max-width"),minWidth:b.attr("data-gs-min-width"),maxHeight:b.attr("data-gs-max-height"),minHeight:b.attr("data-gs-min-height"),autoPosition:g.toBool(b.attr("data-gs-auto-position")),noResize:g.toBool(b.attr("data-gs-no-resize")),noMove:g.toBool(b.attr("data-gs-no-move")),locked:g.toBool(b.attr("data-gs-locked")),el:b,id:b.attr("data-gs-id"),_grid:d};if(!this.isAreaEmpty(e.x,e.y,e.width,e.height)){var f=this.findFreeSpace(e.width,e.height);if(f||(f=this.findFreeSpace(1,1)),!f)return;e.x=f.x,e.y=f.y,e.width=f.w,e.height=f.h}var h=d.grid.addNode(e,c);b.data("_gridstack_node",h),this._prepareElementsByNode(b,h)},j.prototype.setAnimation=function(a){a?this.container.addClass("grid-stack-animate"):this.container.removeClass("grid-stack-animate")},j.prototype.addWidget=function(b,c,d,e,f,g,h,i,j,k,l){return b=a(b),"undefined"!=typeof c&&b.attr("data-gs-x",c),"undefined"!=typeof d&&b.attr("data-gs-y",d),"undefined"!=typeof e&&b.attr("data-gs-width",e),"undefined"!=typeof f&&b.attr("data-gs-height",f),"undefined"!=typeof g&&b.attr("data-gs-auto-position",g?"yes":null),"undefined"!=typeof h&&b.attr("data-gs-min-width",h),"undefined"!=typeof i&&b.attr("data-gs-max-width",i),"undefined"!=typeof j&&b.attr("data-gs-min-height",j),"undefined"!=typeof k&&b.attr("data-gs-max-height",k),"undefined"!=typeof l&&b.attr("data-gs-id",l),this.container.append(b),this.makeWidget(b),b},j.prototype.makeWidget=function(b){return b=a(b),this._prepareElement(b,!0),this._triggerAddEvent(),this._updateContainerHeight(),this._triggerChangeEvent(!0),b},j.prototype.willItFit=function(a,b,c,d,e){var f={x:a,y:b,width:c,height:d,autoPosition:e};return this.grid.canBePlacedWithRespectToHeight(f)},j.prototype.removeWidget=function(b,c){c="undefined"==typeof c||c,b=a(b);var d=b.data("_gridstack_node"); // For Meteor support: https://github.com/troolee/gridstack.js/pull/272 d||(d=this.grid.getNodeDataByDOMEl(b)),this.grid.removeNode(d,c),b.removeData("_gridstack_node"),this._updateContainerHeight(),c&&b.remove(),this._triggerChangeEvent(!0),this._triggerRemoveEvent()},j.prototype.removeAll=function(a){b.each(this.grid.nodes,b.bind(function(b){this.removeWidget(b.el,a)},this)),this.grid.nodes=[],this._updateContainerHeight()},j.prototype.destroy=function(b){a(window).off("resize",this.onResizeHandler),this.disable(),"undefined"==typeof b||b?this.container.remove():(this.removeAll(!1),this.container.removeData("gridstack")),g.removeStylesheet(this._stylesId),this.grid&&(this.grid=null)},j.prototype.resizable=function(b,c){var d=this;return b=a(b),b.each(function(b,e){e=a(e);var f=e.data("_gridstack_node");"undefined"==typeof f||null===f||"undefined"==typeof a.ui||d.opts.staticGrid||(f.noResize=!c,f.noResize||d._isOneColumnMode()?d.dd.resizable(e,"disable"):d.dd.resizable(e,"enable"))}),this},j.prototype.movable=function(b,c){var d=this;return b=a(b),b.each(function(b,e){e=a(e);var f=e.data("_gridstack_node");"undefined"==typeof f||null===f||"undefined"==typeof a.ui||d.opts.staticGrid||(f.noMove=!c,f.noMove||d._isOneColumnMode()?(d.dd.draggable(e,"disable"),e.removeClass("ui-draggable-handle")):(d.dd.draggable(e,"enable"),e.addClass("ui-draggable-handle")))}),this},j.prototype.enableMove=function(a,b){this.movable(this.container.children("."+this.opts.itemClass),a),b&&(this.opts.disableDrag=!a)},j.prototype.enableResize=function(a,b){this.resizable(this.container.children("."+this.opts.itemClass),a),b&&(this.opts.disableResize=!a)},j.prototype.disable=function(){this.movable(this.container.children("."+this.opts.itemClass),!1),this.resizable(this.container.children("."+this.opts.itemClass),!1),this.container.trigger("disable")},j.prototype.enable=function(){this.movable(this.container.children("."+this.opts.itemClass),!0),this.resizable(this.container.children("."+this.opts.itemClass),!0),this.container.trigger("enable")},j.prototype.locked=function(b,c){return b=a(b),b.each(function(b,d){d=a(d);var e=d.data("_gridstack_node");"undefined"!=typeof e&&null!==e&&(e.locked=c||!1,d.attr("data-gs-locked",e.locked?"yes":null))}),this},j.prototype.maxHeight=function(b,c){return b=a(b),b.each(function(b,d){d=a(d);var e=d.data("_gridstack_node");"undefined"!=typeof e&&null!==e&&(isNaN(c)||(e.maxHeight=c||!1,d.attr("data-gs-max-height",c)))}),this},j.prototype.minHeight=function(b,c){return b=a(b),b.each(function(b,d){d=a(d);var e=d.data("_gridstack_node");"undefined"!=typeof e&&null!==e&&(isNaN(c)||(e.minHeight=c||!1,d.attr("data-gs-min-height",c)))}),this},j.prototype.maxWidth=function(b,c){return b=a(b),b.each(function(b,d){d=a(d);var e=d.data("_gridstack_node");"undefined"!=typeof e&&null!==e&&(isNaN(c)||(e.maxWidth=c||!1,d.attr("data-gs-max-width",c)))}),this},j.prototype.minWidth=function(b,c){return b=a(b),b.each(function(b,d){d=a(d);var e=d.data("_gridstack_node");"undefined"!=typeof e&&null!==e&&(isNaN(c)||(e.minWidth=c||!1,d.attr("data-gs-min-width",c)))}),this},j.prototype._updateElement=function(b,c){b=a(b).first();var d=b.data("_gridstack_node");if("undefined"!=typeof d&&null!==d){var e=this;e.grid.cleanNodes(),e.grid.beginUpdate(d),c.call(this,b,d),e._updateContainerHeight(),e._triggerChangeEvent(),e.grid.endUpdate()}},j.prototype.resize=function(a,b,c){this._updateElement(a,function(a,d){b=null!==b&&"undefined"!=typeof b?b:d.width,c=null!==c&&"undefined"!=typeof c?c:d.height,this.grid.moveNode(d,d.x,d.y,b,c)})},j.prototype.move=function(a,b,c){this._updateElement(a,function(a,d){b=null!==b&&"undefined"!=typeof b?b:d.x,c=null!==c&&"undefined"!=typeof c?c:d.y,this.grid.moveNode(d,b,c,d.width,d.height)})},j.prototype.update=function(a,b,c,d,e){this._updateElement(a,function(a,f){b=null!==b&&"undefined"!=typeof b?b:f.x,c=null!==c&&"undefined"!=typeof c?c:f.y,d=null!==d&&"undefined"!=typeof d?d:f.width,e=null!==e&&"undefined"!=typeof e?e:f.height,this.grid.moveNode(f,b,c,d,e)})},j.prototype.verticalMargin=function(a,b){if("undefined"==typeof a)return this.opts.verticalMargin;var c=g.parseHeight(a);this.opts.verticalMarginUnit===c.unit&&this.opts.height===c.height||(this.opts.verticalMarginUnit=c.unit,this.opts.verticalMargin=c.height,b||this._updateStyles())},j.prototype.cellHeight=function(a,b){if("undefined"==typeof a){if(this.opts.cellHeight)return this.opts.cellHeight;var c=this.container.children("."+this.opts.itemClass).first();return Math.ceil(c.outerHeight()/c.attr("data-gs-height"))}var d=g.parseHeight(a);this.opts.cellHeightUnit===d.heightUnit&&this.opts.height===d.height||(this.opts.cellHeightUnit=d.unit,this.opts.cellHeight=d.height,b||this._updateStyles())},j.prototype.cellWidth=function(){return Math.round(this.container.outerWidth()/this.opts.width)},j.prototype.getCellFromPixel=function(a,b){var c="undefined"!=typeof b&&b?this.container.offset():this.container.position(),d=a.left-c.left,e=a.top-c.top,f=Math.floor(this.container.width()/this.opts.width),g=Math.floor(this.container.height()/parseInt(this.container.attr("data-gs-current-height")));return{x:Math.floor(d/f),y:Math.floor(e/g)}},j.prototype.batchUpdate=function(){this.grid.batchUpdate()},j.prototype.commit=function(){this.grid.commit(),this._updateContainerHeight()},j.prototype.isAreaEmpty=function(a,b,c,d){return this.grid.isAreaEmpty(a,b,c,d)},j.prototype.findFreeSpace=function(a,b){return this.grid.findFreeSpace(a,b)},j.prototype.setStatic=function(a){this.opts.staticGrid=a===!0,this.enableMove(!a),this.enableResize(!a),this._setStaticClass()},j.prototype._setStaticClass=function(){var a="grid-stack-static";this.opts.staticGrid===!0?this.container.addClass(a):this.container.removeClass(a)},j.prototype.refreshNodes=function(b){var c=this;this.removeAll(!1),this.container.find("."+this.opts.itemClass).each(function(b,d){a(d).off("dragstart dragstop drag resizestart resizestop resize"),c.makeWidget(d)}),this.opts.staticGrid&&b||(b?this.disable():this.enable())},j.prototype.getCellFromAbsolutePixel=function(a){var b=this.container.offset(),c=this.container.position(); // offset relative to gridstack container itself diff --git a/dist/gridstack.js b/dist/gridstack.js index 750260304..0a620be96 100644 --- a/dist/gridstack.js +++ b/dist/gridstack.js @@ -1282,11 +1282,12 @@ el = $(el); el.addClass(this.opts.itemClass); - var node = self.grid.addNode({ - x: el.attr('data-gs-x'), - y: el.attr('data-gs-y'), - width: el.attr('data-gs-width'), - height: el.attr('data-gs-height'), + + var props = { + x: parseInt(el.attr('data-gs-x'), 10), + y: parseInt(el.attr('data-gs-y'), 10), + width: parseInt(el.attr('data-gs-width'), 10), + height: parseInt(el.attr('data-gs-height'), 10), maxWidth: el.attr('data-gs-max-width'), minWidth: el.attr('data-gs-min-width'), maxHeight: el.attr('data-gs-max-height'), @@ -1298,7 +1299,24 @@ el: el, id: el.attr('data-gs-id'), _grid: self - }, triggerAddEvent); + }; + + if (!this.isAreaEmpty(props.x, props.y, props.width, props.height)) { + var freeSpace = this.findFreeSpace(props.width, props.height); + if (!freeSpace) { + freeSpace = this.findFreeSpace(1, 1); + } + if (freeSpace) { + props.x = freeSpace.x; + props.y = freeSpace.y; + props.width = freeSpace.w; + props.height = freeSpace.h; + } else { + return; + } + } + + var node = self.grid.addNode(props, triggerAddEvent); el.data('_gridstack_node', node); this._prepareElementsByNode(el, node); diff --git a/dist/gridstack.min.js b/dist/gridstack.min.js index 326bdb1fc..b0c370bc2 100644 --- a/dist/gridstack.min.js +++ b/dist/gridstack.min.js @@ -32,7 +32,7 @@ this._updateStyles(),this._updateHeightsOnResize=b.throttle(function(){j.cellHei // jscs:enable requireCamelCaseOrUpperCaseIdentifiers return j.prototype._triggerChangeEvent=function(a){var b=this.grid.getDirtyNodes(),c=!1,d=[];b&&b.length&&(d.push(b),c=!0),(c||a===!0)&&this.container.trigger("change",d)},j.prototype._triggerAddEvent=function(){this.grid._addedNodes&&this.grid._addedNodes.length>0&&(this.container.trigger("added",[b.map(this.grid._addedNodes,b.clone)]),this.grid._addedNodes=[])},j.prototype._triggerRemoveEvent=function(){this.grid._removedNodes&&this.grid._removedNodes.length>0&&(this.container.trigger("removed",[b.map(this.grid._removedNodes,b.clone)]),this.grid._removedNodes=[])},j.prototype._initStyles=function(){this._stylesId&&g.removeStylesheet(this._stylesId),this._stylesId="gridstack-style-"+(1e5*Math.random()).toFixed(),this._styles=g.createStylesheet(this._stylesId),null!==this._styles&&(this._styles._max=0)},j.prototype._updateStyles=function(a){if(null!==this._styles&&"undefined"!=typeof this._styles){var b,c="."+this.opts._class+" ."+this.opts.itemClass,d=this;if("undefined"==typeof a&&(a=this._styles._max||this.opts.height,this._initStyles(),this._updateContainerHeight()),this.opts.cellHeight&&!(0!==this._styles._max&&a<=this._styles._max)&&(b=this.opts.verticalMargin&&this.opts.cellHeightUnit!==this.opts.verticalMarginUnit?function(a,b){return a&&b?"calc("+(d.opts.cellHeight*a+d.opts.cellHeightUnit)+" + "+(d.opts.verticalMargin*b+d.opts.verticalMarginUnit)+")":d.opts.cellHeight*a+d.opts.verticalMargin*b+d.opts.cellHeightUnit}:function(a,b){return d.opts.cellHeight*a+d.opts.verticalMargin*b+d.opts.cellHeightUnit},0===this._styles._max&&g.insertCSSRule(this._styles,c,"min-height: "+b(1,0)+";",0),a>this._styles._max)){for(var e=this._styles._max;e=f.grid.width||k<0||f.grid.height&&k>=f.grid.height?(f.opts.removable===!0&&f._setupRemovingTimeout(b),j=c._beforeDragX,k=c._beforeDragY,f.placeholder.detach(),f.placeholder.hide(),f.grid.removeNode(c),f._updateContainerHeight(),c._temporaryRemoved=!0):(f._clearRemovingTimeout(b),c._temporaryRemoved&&(f.grid.addNode(c),f.placeholder.attr("data-gs-x",j).attr("data-gs-y",k).attr("data-gs-width",h).attr("data-gs-height",i).show(),f.container.append(f.placeholder),c.el=f.placeholder,c._temporaryRemoved=!1));else if("resize"==a.type&&j<0)return; // width and height are undefined if not resizing -var l="undefined"!=typeof h?h:c.lastTriedWidth,m="undefined"!=typeof i?i:c.lastTriedHeight;!f.grid.canMoveNode(c,j,k,h,i)||c.lastTriedX===j&&c.lastTriedY===k&&c.lastTriedWidth===l&&c.lastTriedHeight===m||(c.lastTriedX=j,c.lastTriedY=k,c.lastTriedWidth=h,c.lastTriedHeight=i,f.grid.moveNode(c,j,k,h,i),f._updateContainerHeight())},h=function(g,h){if(f.opts.draggable.handle&&"dragstart"===g.type&&!a(g.originalEvent.target).closest(f.opts.draggable.handle).length)return!1;f.container.append(f.placeholder);var i=a(this);f.grid.cleanNodes(),f.grid.beginUpdate(c),d=f.cellWidth();var j=Math.ceil(i.outerHeight()/i.attr("data-gs-height"));e=f.container.height()/parseInt(f.container.attr("data-gs-current-height")),f.placeholder.attr("data-gs-x",i.attr("data-gs-x")).attr("data-gs-y",i.attr("data-gs-y")).attr("data-gs-width",i.attr("data-gs-width")).attr("data-gs-height",i.attr("data-gs-height")).show(),c.el=f.placeholder,c._beforeDragX=c.x,c._beforeDragY=c.y,f.dd.resizable(b,"option","minWidth",d*(c.minWidth||1)),f.dd.resizable(b,"option","minHeight",j*(c.minHeight||1)),"resizestart"==g.type&&i.find(".grid-stack-item").trigger("resizestart")},i=function(d,e){var g=a(this);if(g.data("_gridstack_node")){var h=!1;f.placeholder.detach(),c.el=g,f.placeholder.hide(),c._isAboutToRemove?(h=!0,b.removeData("_gridstack_node"),b.remove()):(f._clearRemovingTimeout(b),c._temporaryRemoved?(g.attr("data-gs-x",c._beforeDragX).attr("data-gs-y",c._beforeDragY).attr("data-gs-width",c.width).attr("data-gs-height",c.height).removeAttr("style"),c.x=c._beforeDragX,c.y=c._beforeDragY,f.grid.addNode(c)):g.attr("data-gs-x",c.x).attr("data-gs-y",c.y).attr("data-gs-width",c.width).attr("data-gs-height",c.height).removeAttr("style")),f._updateContainerHeight(),f._triggerChangeEvent(h),f.grid.endUpdate();var i=g.find(".grid-stack");i.length&&"resizestop"==d.type&&(i.each(function(b,c){a(c).data("gridstack").onResizeHandler()}),g.find(".grid-stack-item").trigger("resizestop"))}};this.dd.draggable(b,{start:h,stop:i,drag:g}).resizable(b,{start:h,stop:i,resize:g}),(c.noMove||this._isOneColumnMode()||this.opts.disableDrag)&&this.dd.draggable(b,"disable"),(c.noResize||this._isOneColumnMode()||this.opts.disableResize)&&this.dd.resizable(b,"disable"),b.attr("data-gs-locked",c.locked?"yes":null)}},j.prototype._prepareElement=function(b,c){c="undefined"!=typeof c&&c;var d=this;b=a(b),b.addClass(this.opts.itemClass);var e=d.grid.addNode({x:b.attr("data-gs-x"),y:b.attr("data-gs-y"),width:b.attr("data-gs-width"),height:b.attr("data-gs-height"),maxWidth:b.attr("data-gs-max-width"),minWidth:b.attr("data-gs-min-width"),maxHeight:b.attr("data-gs-max-height"),minHeight:b.attr("data-gs-min-height"),autoPosition:g.toBool(b.attr("data-gs-auto-position")),noResize:g.toBool(b.attr("data-gs-no-resize")),noMove:g.toBool(b.attr("data-gs-no-move")),locked:g.toBool(b.attr("data-gs-locked")),el:b,id:b.attr("data-gs-id"),_grid:d},c);b.data("_gridstack_node",e),this._prepareElementsByNode(b,e)},j.prototype.setAnimation=function(a){a?this.container.addClass("grid-stack-animate"):this.container.removeClass("grid-stack-animate")},j.prototype.addWidget=function(b,c,d,e,f,g,h,i,j,k,l){return b=a(b),"undefined"!=typeof c&&b.attr("data-gs-x",c),"undefined"!=typeof d&&b.attr("data-gs-y",d),"undefined"!=typeof e&&b.attr("data-gs-width",e),"undefined"!=typeof f&&b.attr("data-gs-height",f),"undefined"!=typeof g&&b.attr("data-gs-auto-position",g?"yes":null),"undefined"!=typeof h&&b.attr("data-gs-min-width",h),"undefined"!=typeof i&&b.attr("data-gs-max-width",i),"undefined"!=typeof j&&b.attr("data-gs-min-height",j),"undefined"!=typeof k&&b.attr("data-gs-max-height",k),"undefined"!=typeof l&&b.attr("data-gs-id",l),this.container.append(b),this.makeWidget(b),b},j.prototype.makeWidget=function(b){return b=a(b),this._prepareElement(b,!0),this._triggerAddEvent(),this._updateContainerHeight(),this._triggerChangeEvent(!0),b},j.prototype.willItFit=function(a,b,c,d,e){var f={x:a,y:b,width:c,height:d,autoPosition:e};return this.grid.canBePlacedWithRespectToHeight(f)},j.prototype.removeWidget=function(b,c){c="undefined"==typeof c||c,b=a(b);var d=b.data("_gridstack_node"); +var l="undefined"!=typeof h?h:c.lastTriedWidth,m="undefined"!=typeof i?i:c.lastTriedHeight;!f.grid.canMoveNode(c,j,k,h,i)||c.lastTriedX===j&&c.lastTriedY===k&&c.lastTriedWidth===l&&c.lastTriedHeight===m||(c.lastTriedX=j,c.lastTriedY=k,c.lastTriedWidth=h,c.lastTriedHeight=i,f.grid.moveNode(c,j,k,h,i),f._updateContainerHeight())},h=function(g,h){if(f.opts.draggable.handle&&"dragstart"===g.type&&!a(g.originalEvent.target).closest(f.opts.draggable.handle).length)return!1;f.container.append(f.placeholder);var i=a(this);f.grid.cleanNodes(),f.grid.beginUpdate(c),d=f.cellWidth();var j=Math.ceil(i.outerHeight()/i.attr("data-gs-height"));e=f.container.height()/parseInt(f.container.attr("data-gs-current-height")),f.placeholder.attr("data-gs-x",i.attr("data-gs-x")).attr("data-gs-y",i.attr("data-gs-y")).attr("data-gs-width",i.attr("data-gs-width")).attr("data-gs-height",i.attr("data-gs-height")).show(),c.el=f.placeholder,c._beforeDragX=c.x,c._beforeDragY=c.y,f.dd.resizable(b,"option","minWidth",d*(c.minWidth||1)),f.dd.resizable(b,"option","minHeight",j*(c.minHeight||1)),"resizestart"==g.type&&i.find(".grid-stack-item").trigger("resizestart")},i=function(d,e){var g=a(this);if(g.data("_gridstack_node")){var h=!1;f.placeholder.detach(),c.el=g,f.placeholder.hide(),c._isAboutToRemove?(h=!0,b.removeData("_gridstack_node"),b.remove()):(f._clearRemovingTimeout(b),c._temporaryRemoved?(g.attr("data-gs-x",c._beforeDragX).attr("data-gs-y",c._beforeDragY).attr("data-gs-width",c.width).attr("data-gs-height",c.height).removeAttr("style"),c.x=c._beforeDragX,c.y=c._beforeDragY,f.grid.addNode(c)):g.attr("data-gs-x",c.x).attr("data-gs-y",c.y).attr("data-gs-width",c.width).attr("data-gs-height",c.height).removeAttr("style")),f._updateContainerHeight(),f._triggerChangeEvent(h),f.grid.endUpdate();var i=g.find(".grid-stack");i.length&&"resizestop"==d.type&&(i.each(function(b,c){a(c).data("gridstack").onResizeHandler()}),g.find(".grid-stack-item").trigger("resizestop"))}};this.dd.draggable(b,{start:h,stop:i,drag:g}).resizable(b,{start:h,stop:i,resize:g}),(c.noMove||this._isOneColumnMode()||this.opts.disableDrag)&&this.dd.draggable(b,"disable"),(c.noResize||this._isOneColumnMode()||this.opts.disableResize)&&this.dd.resizable(b,"disable"),b.attr("data-gs-locked",c.locked?"yes":null)}},j.prototype._prepareElement=function(b,c){c="undefined"!=typeof c&&c;var d=this;b=a(b),b.addClass(this.opts.itemClass);var e={x:parseInt(b.attr("data-gs-x"),10),y:parseInt(b.attr("data-gs-y"),10),width:parseInt(b.attr("data-gs-width"),10),height:parseInt(b.attr("data-gs-height"),10),maxWidth:b.attr("data-gs-max-width"),minWidth:b.attr("data-gs-min-width"),maxHeight:b.attr("data-gs-max-height"),minHeight:b.attr("data-gs-min-height"),autoPosition:g.toBool(b.attr("data-gs-auto-position")),noResize:g.toBool(b.attr("data-gs-no-resize")),noMove:g.toBool(b.attr("data-gs-no-move")),locked:g.toBool(b.attr("data-gs-locked")),el:b,id:b.attr("data-gs-id"),_grid:d};if(!this.isAreaEmpty(e.x,e.y,e.width,e.height)){var f=this.findFreeSpace(e.width,e.height);if(f||(f=this.findFreeSpace(1,1)),!f)return;e.x=f.x,e.y=f.y,e.width=f.w,e.height=f.h}var h=d.grid.addNode(e,c);b.data("_gridstack_node",h),this._prepareElementsByNode(b,h)},j.prototype.setAnimation=function(a){a?this.container.addClass("grid-stack-animate"):this.container.removeClass("grid-stack-animate")},j.prototype.addWidget=function(b,c,d,e,f,g,h,i,j,k,l){return b=a(b),"undefined"!=typeof c&&b.attr("data-gs-x",c),"undefined"!=typeof d&&b.attr("data-gs-y",d),"undefined"!=typeof e&&b.attr("data-gs-width",e),"undefined"!=typeof f&&b.attr("data-gs-height",f),"undefined"!=typeof g&&b.attr("data-gs-auto-position",g?"yes":null),"undefined"!=typeof h&&b.attr("data-gs-min-width",h),"undefined"!=typeof i&&b.attr("data-gs-max-width",i),"undefined"!=typeof j&&b.attr("data-gs-min-height",j),"undefined"!=typeof k&&b.attr("data-gs-max-height",k),"undefined"!=typeof l&&b.attr("data-gs-id",l),this.container.append(b),this.makeWidget(b),b},j.prototype.makeWidget=function(b){return b=a(b),this._prepareElement(b,!0),this._triggerAddEvent(),this._updateContainerHeight(),this._triggerChangeEvent(!0),b},j.prototype.willItFit=function(a,b,c,d,e){var f={x:a,y:b,width:c,height:d,autoPosition:e};return this.grid.canBePlacedWithRespectToHeight(f)},j.prototype.removeWidget=function(b,c){c="undefined"==typeof c||c,b=a(b);var d=b.data("_gridstack_node"); // For Meteor support: https://github.com/troolee/gridstack.js/pull/272 d||(d=this.grid.getNodeDataByDOMEl(b)),this.grid.removeNode(d,c),b.removeData("_gridstack_node"),this._updateContainerHeight(),c&&b.remove(),this._triggerChangeEvent(!0),this._triggerRemoveEvent()},j.prototype.removeAll=function(a){b.each(this.grid.nodes,b.bind(function(b){this.removeWidget(b.el,a)},this)),this.grid.nodes=[],this._updateContainerHeight()},j.prototype.destroy=function(b){a(window).off("resize",this.onResizeHandler),this.disable(),"undefined"==typeof b||b?this.container.remove():(this.removeAll(!1),this.container.removeData("gridstack")),g.removeStylesheet(this._stylesId),this.grid&&(this.grid=null)},j.prototype.resizable=function(b,c){var d=this;return b=a(b),b.each(function(b,e){e=a(e);var f=e.data("_gridstack_node");"undefined"==typeof f||null===f||"undefined"==typeof a.ui||d.opts.staticGrid||(f.noResize=!c,f.noResize||d._isOneColumnMode()?d.dd.resizable(e,"disable"):d.dd.resizable(e,"enable"))}),this},j.prototype.movable=function(b,c){var d=this;return b=a(b),b.each(function(b,e){e=a(e);var f=e.data("_gridstack_node");"undefined"==typeof f||null===f||"undefined"==typeof a.ui||d.opts.staticGrid||(f.noMove=!c,f.noMove||d._isOneColumnMode()?(d.dd.draggable(e,"disable"),e.removeClass("ui-draggable-handle")):(d.dd.draggable(e,"enable"),e.addClass("ui-draggable-handle")))}),this},j.prototype.enableMove=function(a,b){this.movable(this.container.children("."+this.opts.itemClass),a),b&&(this.opts.disableDrag=!a)},j.prototype.enableResize=function(a,b){this.resizable(this.container.children("."+this.opts.itemClass),a),b&&(this.opts.disableResize=!a)},j.prototype.disable=function(){this.movable(this.container.children("."+this.opts.itemClass),!1),this.resizable(this.container.children("."+this.opts.itemClass),!1),this.container.trigger("disable")},j.prototype.enable=function(){this.movable(this.container.children("."+this.opts.itemClass),!0),this.resizable(this.container.children("."+this.opts.itemClass),!0),this.container.trigger("enable")},j.prototype.locked=function(b,c){return b=a(b),b.each(function(b,d){d=a(d);var e=d.data("_gridstack_node");"undefined"!=typeof e&&null!==e&&(e.locked=c||!1,d.attr("data-gs-locked",e.locked?"yes":null))}),this},j.prototype.maxHeight=function(b,c){return b=a(b),b.each(function(b,d){d=a(d);var e=d.data("_gridstack_node");"undefined"!=typeof e&&null!==e&&(isNaN(c)||(e.maxHeight=c||!1,d.attr("data-gs-max-height",c)))}),this},j.prototype.minHeight=function(b,c){return b=a(b),b.each(function(b,d){d=a(d);var e=d.data("_gridstack_node");"undefined"!=typeof e&&null!==e&&(isNaN(c)||(e.minHeight=c||!1,d.attr("data-gs-min-height",c)))}),this},j.prototype.maxWidth=function(b,c){return b=a(b),b.each(function(b,d){d=a(d);var e=d.data("_gridstack_node");"undefined"!=typeof e&&null!==e&&(isNaN(c)||(e.maxWidth=c||!1,d.attr("data-gs-max-width",c)))}),this},j.prototype.minWidth=function(b,c){return b=a(b),b.each(function(b,d){d=a(d);var e=d.data("_gridstack_node");"undefined"!=typeof e&&null!==e&&(isNaN(c)||(e.minWidth=c||!1,d.attr("data-gs-min-width",c)))}),this},j.prototype._updateElement=function(b,c){b=a(b).first();var d=b.data("_gridstack_node");if("undefined"!=typeof d&&null!==d){var e=this;e.grid.cleanNodes(),e.grid.beginUpdate(d),c.call(this,b,d),e._updateContainerHeight(),e._triggerChangeEvent(),e.grid.endUpdate()}},j.prototype.resize=function(a,b,c){this._updateElement(a,function(a,d){b=null!==b&&"undefined"!=typeof b?b:d.width,c=null!==c&&"undefined"!=typeof c?c:d.height,this.grid.moveNode(d,d.x,d.y,b,c)})},j.prototype.move=function(a,b,c){this._updateElement(a,function(a,d){b=null!==b&&"undefined"!=typeof b?b:d.x,c=null!==c&&"undefined"!=typeof c?c:d.y,this.grid.moveNode(d,b,c,d.width,d.height)})},j.prototype.update=function(a,b,c,d,e){this._updateElement(a,function(a,f){b=null!==b&&"undefined"!=typeof b?b:f.x,c=null!==c&&"undefined"!=typeof c?c:f.y,d=null!==d&&"undefined"!=typeof d?d:f.width,e=null!==e&&"undefined"!=typeof e?e:f.height,this.grid.moveNode(f,b,c,d,e)})},j.prototype.verticalMargin=function(a,b){if("undefined"==typeof a)return this.opts.verticalMargin;var c=g.parseHeight(a);this.opts.verticalMarginUnit===c.unit&&this.opts.height===c.height||(this.opts.verticalMarginUnit=c.unit,this.opts.verticalMargin=c.height,b||this._updateStyles())},j.prototype.cellHeight=function(a,b){if("undefined"==typeof a){if(this.opts.cellHeight)return this.opts.cellHeight;var c=this.container.children("."+this.opts.itemClass).first();return Math.ceil(c.outerHeight()/c.attr("data-gs-height"))}var d=g.parseHeight(a);this.opts.cellHeightUnit===d.heightUnit&&this.opts.height===d.height||(this.opts.cellHeightUnit=d.unit,this.opts.cellHeight=d.height,b||this._updateStyles())},j.prototype.cellWidth=function(){return Math.round(this.container.outerWidth()/this.opts.width)},j.prototype.getCellFromPixel=function(a,b){var c="undefined"!=typeof b&&b?this.container.offset():this.container.position(),d=a.left-c.left,e=a.top-c.top,f=Math.floor(this.container.width()/this.opts.width),g=Math.floor(this.container.height()/parseInt(this.container.attr("data-gs-current-height")));return{x:Math.floor(d/f),y:Math.floor(e/g)}},j.prototype.batchUpdate=function(){this.grid.batchUpdate()},j.prototype.commit=function(){this.grid.commit(),this._updateContainerHeight()},j.prototype.isAreaEmpty=function(a,b,c,d){return this.grid.isAreaEmpty(a,b,c,d)},j.prototype.findFreeSpace=function(a,b){return this.grid.findFreeSpace(a,b)},j.prototype.setStatic=function(a){this.opts.staticGrid=a===!0,this.enableMove(!a),this.enableResize(!a),this._setStaticClass()},j.prototype._setStaticClass=function(){var a="grid-stack-static";this.opts.staticGrid===!0?this.container.addClass(a):this.container.removeClass(a)},j.prototype.refreshNodes=function(b){var c=this;this.removeAll(!1),this.container.find("."+this.opts.itemClass).each(function(b,d){a(d).off("dragstart dragstop drag resizestart resizestop resize"),c.makeWidget(d)}),this.opts.staticGrid&&b||(b?this.disable():this.enable())},j.prototype.getCellFromAbsolutePixel=function(a){var b=this.container.offset(),c=this.container.position(); // offset relative to gridstack container itself diff --git a/dist/gridstack.min.map b/dist/gridstack.min.map index 435bbc3e2..de3d38410 100644 --- a/dist/gridstack.min.map +++ b/dist/gridstack.min.map @@ -1 +1 @@ -{"version":3,"sources":["../src/gridstack.js","../src/gridstack.jQueryUI.js"],"names":["factory","define","amd","exports","jQuery","require","e","_","$","GridStackDragDropPlugin","grid","this","scope","window","obsolete","f","oldName","newName","wrapper","console","warn","apply","arguments","prototype","obsoleteOpts","Utils","isIntercepted","a","b","x","width","y","height","sort","nodes","dir","chain","map","node","max","value","sortBy","n","createStylesheet","id","style","document","createElement","setAttribute","styleSheet","cssText","appendChild","createTextNode","getElementsByTagName","sheet","removeStylesheet","remove","insertCSSRule","selector","rules","index","insertRule","addRule","toBool","v","toLowerCase","Boolean","_collisionNodeCheck","nn","_didCollide","bn","newY","_isAddNodeIntercepted","parseHeight","val","heightUnit","isString","match","Error","parseFloat","unit","is_intercepted","create_stylesheet","remove_stylesheet","insert_css_rule","registeredPlugins","registerPlugin","pluginClass","push","resizable","el","opts","draggable","droppable","isDroppable","on","eventName","callback","idSeq","GridStackEngine","onchange","floatMode","items","_updateCounter","_float","_addedNodes","_removedNodes","batchUpdate","commit","_packNodes","_notify","getNodeDataByDOMEl","find","get","_fixCollisions","isClone","_sortNodes","hasLocked","locked","collisionNode","bind","moveNode","whatIsHere","collisionNodes","filter","isAreaEmpty","exceptNode","length","findFreeSpace","w","h","forNode","i","j","freeSpace","each","_updating","_origY","_dirty","canBeMoved","take","_prepareNode","resizing","defaults","parseInt","autoPosition","noResize","noMove","args","Array","slice","call","deletedNodes","concat","getDirtyNodes","cleanNodes","addNode","triggerAddEvent","maxWidth","Math","min","maxHeight","minWidth","minHeight","_id","floor","clone","removeNode","detachNode","without","canMoveNode","isNodeChangedPosition","clonedNode","extend","res","getGridHeight","canBePlacedWithRespectToHeight","noPack","lastTriedX","lastTriedY","lastTriedWidth","lastTriedHeight","reduce","memo","beginUpdate","endUpdate","GridStack","oneColumnMode","isAutoCellHeight","self","container","handle_class","handleClass","item_class","itemClass","placeholder_class","placeholderClass","placeholder_text","placeholderText","cell_height","cellHeight","vertical_margin","verticalMargin","min_width","static_grid","staticGrid","is_nested","isNested","always_show_resize_handle","alwaysShowResizeHandle","closest","attr","handle","auto","float","_class","random","toFixed","animate","autoHide","handles","scroll","appendTo","disableDrag","disableResize","rtl","removable","removeTimeout","verticalMarginUnit","cellHeightUnit","oneColumnModeClass","ddPlugin","first","dd","css","addClass","cellWidth","_setStaticClass","_initStyles","_updateStyles","max_height","elements","_this","children","_prepareElement","setAnimation","placeholder","hide","_updateContainerHeight","_updateHeightsOnResize","throttle","onResizeHandler","_isOneColumnMode","append","trigger","removeClass","resize","trashZone","accept","event","ui","data","_grid","_setupRemovingTimeout","_clearRemovingTimeout","acceptWidgets","draggingElement","onDrag","pos","getCellFromPixel","offset","_added","show","_beforeDragX","_beforeDragY","is","origNode","ceil","outerWidth","outerHeight","_temporary","unbind","detach","removeAttr","enableSelection","removeData","_prepareElementsByNode","_triggerChangeEvent","forceTrigger","hasChanges","eventParams","_triggerAddEvent","_triggerRemoveEvent","_stylesId","_styles","_max","getHeight","prefix","nbRows","nbMargins","innerWidth","documentElement","clientWidth","body","_removeTimeout","setTimeout","_isAboutToRemove","clearTimeout","dragOrResize","round","position","left","top","type","size","_temporaryRemoved","onStartMoving","originalEvent","target","o","strictCellHeight","onEndMoving","forceNotify","nestedGrids","start","stop","drag","enable","addWidget","makeWidget","willItFit","removeWidget","removeAll","destroy","detachGrid","off","disable","movable","enableMove","doEnable","includeNewWidgets","enableResize","isNaN","_updateElement","move","update","noUpdate","heightData","useOffset","containerPos","relativeLeft","relativeTop","columnWidth","rowHeight","setStatic","staticValue","staticClassName","refreshNodes","isDisabled","that","k","getCellFromAbsolutePixel","nodeOffset","_updateNodeWidths","oldWidth","newWidth","undefined","setGridWidth","gridWidth","doNotPropagate","batch_update","_fix_collisions","is_area_empty","_sort_nodes","_pack_nodes","_prepare_node","clean_nodes","get_dirty_nodes","add_node","remove_node","can_move_node","move_node","get_grid_height","begin_update","end_update","can_be_placed_with_respect_to_height","_trigger_change_event","_init_styles","_update_styles","_update_container_height","_is_one_column_mode","_prepare_element","set_animation","add_widget","make_widget","will_it_fit","remove_widget","remove_all","min_height","_update_element","cell_width","get_cell_from_pixel","set_static","_set_static_class","GridStackUI","Engine","fn","gridstack","JQueryUIGridStackDragDropPlugin","Object","create","constructor","key","containment","parent"],"mappings":";;;;;;;CAOA,SAAUA,GACN,GAAsB,kBAAXC,SAAyBA,OAAOC,IACvCD,QAAQ,SAAU,UAAWD,OAC1B,IAAuB,mBAAZG,SAAyB,CACvC,IAAMC,OAASC,QAAQ,UAAa,MAAOC,IAC3C,IAAMC,EAAIF,QAAQ,UAAa,MAAOC,IACtCN,EAAQI,OAAQG,OAEhBP,GAAQI,OAAQG,IAErB,SAASC,EAAGD;;;;;;AA4GX,QAASE,GAAwBC,GAC7BC,KAAKD,KAAOA,EA3GhB,GAAIE,GAAQC,OAERC,EAAW,SAASC,EAAGC,EAASC,GAChC,GAAIC,GAAU,WAGV,MAFAC,SAAQC,KAAK,2BAA6BJ,EAAU,4DACzCC,EAAU,iDACdF,EAAEM,MAAMV,KAAMW,WAIzB,OAFAJ,GAAQK,UAAYR,EAAEQ,UAEfL,GAGPM,EAAe,SAASR,EAASC,GACjCE,QAAQC,KAAK,yBAA2BJ,EAAU,4DAC9CC,EAAU,kDAGdQ,GACAC,cAAe,S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,KAAM1O,EAAK0O,MAAQ,aACnBrE,OAAQrK,EAAKqK,QAAU,eAG/B,OAAOrP,OAGX6Y,EAAgCjY,UAAUqE,UAAY,SAASF,EAAIC,GAY/D,MAXAD,GAAKlF,EAAEkF,GACM,YAATC,GAA+B,WAATA,EACtBD,EAAGE,UAAUD,GAEbD,EAAGE,UAAUrF,EAAEsK,UAAWlK,KAAKD,KAAKiF,KAAKC,WACrCiU,YAAalZ,KAAKD,KAAKiF,KAAKoH,SAAWpM,KAAKD,KAAKoL,UAAUgO,SAAW,KACtE1F,MAAOzO,EAAKyO,OAAS,aACrBC,KAAM1O,EAAK0O,MAAQ,aACnBC,KAAM3O,EAAK2O,MAAQ,gBAGpB3T,MAGX6Y,EAAgCjY,UAAUsE,UAAY,SAASH,EAAIC,GAS/D,MARAD,GAAKlF,EAAEkF,GACM,YAATC,GAA+B,WAATA,EACtBD,EAAGG,UAAUF,GAEbD,EAAGG,WACCqK,OAAQvK,EAAKuK,SAGdvP,MAGX6Y,EAAgCjY,UAAUuE,YAAc,SAASJ,EAAIC,GAEjE,MADAD,GAAKlF,EAAEkF,GACAxB,QAAQwB,EAAG2K,KAAK,eAG3BmJ,EAAgCjY,UAAUwE,GAAK,SAASL,EAAIM,EAAWC,GAEnE,MADAzF,GAAEkF,GAAIK,GAAGC,EAAWC,GACbtF,MAGJ6Y","file":"gridstack.all.js"} \ No newline at end of file +{"version":3,"sources":["../src/gridstack.js","../src/gridstack.jQueryUI.js"],"names":["factory","define","amd","exports","jQuery","require","e","_","$","GridStackDragDropPlugin","grid","this","scope","window","obsolete","f","oldName","newName","wrapper","console","warn","apply","arguments","prototype","obsoleteOpts","Utils","isIntercepted","a","b","x","width","y","height","sort","nodes","dir","chain","map","node","max","value","sortBy","n","createStylesheet","id","style","document","createElement","setAttribute","styleSheet","cssText","appendChild","createTextNode","getElementsByTagName","sheet","removeStylesheet","remove","insertCSSRule","selector","rules","index","insertRule","addRule","toBool","v","toLowerCase","Boolean","_collisionNodeCheck","nn","_didCollide","bn","newY","_isAddNodeIntercepted","parseHeight","val","heightUnit","isString","match","Error","parseFloat","unit","is_intercepted","create_stylesheet","remove_stylesheet","insert_css_rule","registeredPlugins","registerPlugin","pluginClass","push","resizable","el","opts","draggable","droppable","isDroppable","on","eventName","callback","idSeq","GridStackEngine","onchange","floatMode","items","_updateCounter","_float","_addedNodes","_removedNodes","batchUpdate","commit","_packNodes","_notify","getNodeDataByDOMEl","find","get","_fixCollisions","isClone","_sortNodes","hasLocked","locked","collisionNode","bind","moveNode","whatIsHere","collisionNodes","filter","isAreaEmpty","exceptNode","length","findFreeSpace","w","h","forNode","i","j","freeSpace","each","_updating","_origY","_dirty","canBeMoved","take","_prepareNode","resizing","defaults","parseInt","autoPosition","noResize","noMove","args","Array","slice","call","deletedNodes","concat","getDirtyNodes","cleanNodes","addNode","triggerAddEvent","maxWidth","Math","min","maxHeight","minWidth","minHeight","_id","floor","clone","removeNode","detachNode","without","canMoveNode","isNodeChangedPosition","clonedNode","extend","res","getGridHeight","canBePlacedWithRespectToHeight","noPack","lastTriedX","lastTriedY","lastTriedWidth","lastTriedHeight","reduce","memo","beginUpdate","endUpdate","GridStack","oneColumnMode","isAutoCellHeight","self","container","handle_class","handleClass","item_class","itemClass","placeholder_class","placeholderClass","placeholder_text","placeholderText","cell_height","cellHeight","vertical_margin","verticalMargin","min_width","static_grid","staticGrid","is_nested","isNested","always_show_resize_handle","alwaysShowResizeHandle","closest","attr","handle","auto","float","_class","random","toFixed","animate","autoHide","handles","scroll","appendTo","disableDrag","disableResize","rtl","removable","removeTimeout","verticalMarginUnit","cellHeightUnit","oneColumnModeClass","ddPlugin","first","dd","css","addClass","cellWidth","_setStaticClass","_initStyles","_updateStyles","max_height","elements","_this","children","_prepareElement","setAnimation","placeholder","hide","_updateContainerHeight","_updateHeightsOnResize","throttle","onResizeHandler","_isOneColumnMode","append","trigger","removeClass","resize","trashZone","accept","event","ui","data","_grid","_setupRemovingTimeout","_clearRemovingTimeout","acceptWidgets","draggingElement","onDrag","pos","getCellFromPixel","offset","_added","show","_beforeDragX","_beforeDragY","is","origNode","ceil","outerWidth","outerHeight","_temporary","unbind","detach","removeAttr","enableSelection","removeData","_prepareElementsByNode","_triggerChangeEvent","forceTrigger","hasChanges","eventParams","_triggerAddEvent","_triggerRemoveEvent","_stylesId","_styles","_max","getHeight","prefix","nbRows","nbMargins","innerWidth","documentElement","clientWidth","body","_removeTimeout","setTimeout","_isAboutToRemove","clearTimeout","dragOrResize","round","position","left","top","type","size","_temporaryRemoved","onStartMoving","originalEvent","target","o","strictCellHeight","onEndMoving","forceNotify","nestedGrids","start","stop","drag","props","enable","addWidget","makeWidget","willItFit","removeWidget","removeAll","destroy","detachGrid","off","disable","movable","enableMove","doEnable","includeNewWidgets","enableResize","isNaN","_updateElement","move","update","noUpdate","heightData","useOffset","containerPos","relativeLeft","relativeTop","columnWidth","rowHeight","setStatic","staticValue","staticClassName","refreshNodes","isDisabled","that","k","getCellFromAbsolutePixel","nodeOffset","_updateNodeWidths","oldWidth","newWidth","undefined","setGridWidth","gridWidth","doNotPropagate","batch_update","_fix_collisions","is_area_empty","_sort_nodes","_pack_nodes","_prepare_node","clean_nodes","get_dirty_nodes","add_node","remove_node","can_move_node","move_node","get_grid_height","begin_update","end_update","can_be_placed_with_respect_to_height","_trigger_change_event","_init_styles","_update_styles","_update_container_height","_is_one_column_mode","_prepare_element","set_animation","add_widget","make_widget","will_it_fit","remove_widget","remove_all","min_height","_update_element","cell_width","get_cell_from_pixel","set_static","_set_static_class","GridStackUI","Engine","fn","gridstack","JQueryUIGridStackDragDropPlugin","Object","create","constructor","key","containment","parent"],"mappings":";;;;;;;CAOA,SAAUA,GACN,GAAsB,kBAAXC,SAAyBA,OAAOC,IACvCD,QAAQ,SAAU,UAAWD,OAC1B,IAAuB,mBAAZG,SAAyB,CACvC,IAAMC,OAASC,QAAQ,UAAa,MAAOC,IAC3C,IAAMC,EAAIF,QAAQ,UAAa,MAAOC,IACtCN,EAAQI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O,MAAQ,aACnBC,KAAM3O,EAAK2O,MAAQ,gBAGpB3T,MAGX8Y,EAAgClY,UAAUsE,UAAY,SAASH,EAAIC,GAS/D,MARAD,GAAKlF,EAAEkF,GACM,YAATC,GAA+B,WAATA,EACtBD,EAAGG,UAAUF,GAEbD,EAAGG,WACCqK,OAAQvK,EAAKuK,SAGdvP,MAGX8Y,EAAgClY,UAAUuE,YAAc,SAASJ,EAAIC,GAEjE,MADAD,GAAKlF,EAAEkF,GACAxB,QAAQwB,EAAG2K,KAAK,eAG3BoJ,EAAgClY,UAAUwE,GAAK,SAASL,EAAIM,EAAWC,GAEnE,MADAzF,GAAEkF,GAAIK,GAAGC,EAAWC,GACbtF,MAGJ8Y","file":"gridstack.all.js"} \ No newline at end of file From af41e968f41082b558e6930ebc90c7859ffeb866 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Inga=20Br=C5=ABnava?= Date: Wed, 25 Jan 2017 16:04:02 +0100 Subject: [PATCH 27/35] Fix placeholder when moving back in --- src/gridstack.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/gridstack.js b/src/gridstack.js index 0a620be96..c7636792c 100644 --- a/src/gridstack.js +++ b/src/gridstack.js @@ -219,7 +219,7 @@ GridStackEngine.prototype.isAreaEmpty = function(x, y, width, height, exceptNode) { // first check if is not out of bounds - if (y + height > this.height || x + width > this.width) { + if (y < 0 || y + height > this.height || x < 0 || x + width > this.width) { return false; } var collisionNodes = this.whatIsHere(x, y, width, height); @@ -1118,7 +1118,17 @@ } if (event.type == 'drag') { - if (x < 0 || x >= self.grid.width || y < 0 || (self.grid.height && y >= self.grid.height)) { + var cannotPutHere = !self.isAreaEmpty(x, y), + whatIsHere; + + if (cannotPutHere) { + whatIsHere = self.grid.whatIsHere(x, y); + if (whatIsHere && whatIsHere[0] && whatIsHere[0].el !== this.placeholder) { + cannotPutHere = false; + } + } + + if (cannotPutHere) { if (self.opts.removable === true) { self._setupRemovingTimeout(el); } @@ -1675,8 +1685,8 @@ this._updateContainerHeight(); }; - GridStack.prototype.isAreaEmpty = function(x, y, width, height) { - return this.grid.isAreaEmpty(x, y, width, height); + GridStack.prototype.isAreaEmpty = function(x, y, width, height, exceptNode) { + return this.grid.isAreaEmpty(x, y, width, height, exceptNode); }; GridStack.prototype.findFreeSpace = function(w, h) { From 46143d9a6bfd5b9a68b6eeffe2f612cbb69151a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Inga=20Br=C5=ABnava?= Date: Wed, 25 Jan 2017 16:04:08 +0100 Subject: [PATCH 28/35] Assets --- dist/gridstack.all.js | 8 ++++---- dist/gridstack.js | 18 ++++++++++++++---- dist/gridstack.min.js | 8 ++++---- dist/gridstack.min.map | 2 +- 4 files changed, 23 insertions(+), 13 deletions(-) diff --git a/dist/gridstack.all.js b/dist/gridstack.all.js index 83f2b9aee..443d21d66 100644 --- a/dist/gridstack.all.js +++ b/dist/gridstack.all.js @@ -17,7 +17,7 @@ g.is_intercepted=e(g.isIntercepted,"is_intercepted","isIntercepted"),g.create_st // For Meteor support: https://github.com/troolee/gridstack.js/pull/272 i.prototype.getNodeDataByDOMEl=function(a){return b.find(this.nodes,function(b){return a.get(0)===b.el.get(0)})},i.prototype._fixCollisions=function(a,c){this._sortNodes(-1);var d=a,e=Boolean(b.find(this.nodes,function(a){return a.locked}));for(this["float"]||e||(d={x:0,y:a.y,width:this.width,height:a.height});;){var f=b.find(this.nodes,b.bind(g._collisionNodeCheck,{node:a,nn:d}));if("undefined"==typeof f)return;this.moveNode(f,f.x,a.y+a.height,f.width,f.height,!0)}},i.prototype.whatIsHere=function(a,c,d,e){var f={x:a||0,y:c||0,width:d||1,height:e||1},h=b.filter(this.nodes,b.bind(function(a){return g.isIntercepted(a,f)},this));return h},i.prototype.isAreaEmpty=function(a,b,c,d,e){ // first check if is not out of bounds -if(b+d>this.height||a+c>this.width)return!1;var f=this.whatIsHere(a,b,c,d);return!f.length||e&&1===f.length&&f[0]===e},i.prototype.findFreeSpace=function(a,b,c){var d,e,f=null;for( +if(b<0||b+d>this.height||a<0||a+c>this.width)return!1;var f=this.whatIsHere(a,b,c,d);return!f.length||e&&1===f.length&&f[0]===e},i.prototype.findFreeSpace=function(a,b,c){var d,e,f=null;for( // first free for 1x1 or we have specified width and height a||(a=1),b||(b=1),d=0;d<=this.width-a&&!f;d++)for(e=0;e<=this.height-b&&!f;e++)this.isAreaEmpty(d,e,a,b,c)&&(f={x:d,y:e,w:a,h:b});return f},i.prototype._sortNodes=function(a){this.nodes=g.sort(this.nodes,a,this.width)},i.prototype._packNodes=function(){this._sortNodes(),this["float"]?b.each(this.nodes,b.bind(function(a,c){if(!a._updating&&"undefined"!=typeof a._origY&&a.y!=a._origY)for(var d=a.y;d>=a._origY;){var e=b.chain(this.nodes).find(b.bind(g._didCollide,{n:a,newY:d})).value();e||(a._dirty=!0,a.y=d),--d}},this)):b.each(this.nodes,b.bind(function(a,c){if(!a.locked)for(;a.y>0;){var d=a.y-1,e=0===c;if(c>0){var f=b.chain(this.nodes).take(c).find(b.bind(g._didCollide,{n:a,newY:d})).value();e="undefined"==typeof f}if(!e)break;a._dirty=a.y!=d,a.y=d}},this))},i.prototype._prepareNode=function(a,c){return a=b.defaults(a||{},{width:1,height:1,x:0,y:0}),a.x=parseInt(""+a.x),a.y=parseInt(""+a.y),a.width=parseInt(""+a.width),a.height=parseInt(""+a.height),a.autoPosition=a.autoPosition||!1,a.noResize=a.noResize||!1,a.noMove=a.noMove||!1,a.width>this.width?a.width=this.width:a.width<1&&(a.width=1),this.height&&a.height>this.height?a.height=this.height:a.height<1&&(a.height=1),a.x<0&&(a.x=0),a.x+a.width>this.width&&(c?a.width=this.width-a.x:a.x=this.width-a.width),a.y<0&&(a.y=0),a},i.prototype._notify=function(){var a=Array.prototype.slice.call(arguments,0);if(a[0]="undefined"==typeof a[0]?[]:[a[0]],a[1]="undefined"==typeof a[1]||a[1],!this._updateCounter){var b=a[0].concat(this.getDirtyNodes());this.onchange(b,a[1])}},i.prototype.cleanNodes=function(){this._updateCounter||b.each(this.nodes,function(a){a._dirty=!1})},i.prototype.getDirtyNodes=function(){return b.filter(this.nodes,function(a){return a._dirty})},i.prototype.addNode=function(a,c,d){if(a=this._prepareNode(a),"undefined"!=typeof a.maxWidth&&(a.width=Math.min(a.width,a.maxWidth)),"undefined"!=typeof a.maxHeight&&(a.height=Math.min(a.height,a.maxHeight)),"undefined"!=typeof a.minWidth&&(a.width=Math.max(a.width,a.minWidth)),"undefined"!=typeof a.minHeight&&(a.height=Math.max(a.height,a.minHeight)),a._id=++h,a._dirty=!0,a.autoPosition){this._sortNodes();for(var e=0;;++e){var f=e%this.width,i=Math.floor(e/this.width);if(!(f+a.width>this.width||b.find(this.nodes,b.bind(g._isAddNodeIntercepted,{x:f,y:i,node:a})))){a.x=f,a.y=i;break}}}return this.nodes.push(a),"undefined"!=typeof c&&c&&this._addedNodes.push(b.clone(a)),this._fixCollisions(a,d),this._packNodes(),this._notify(),a},i.prototype.removeNode=function(a,c){a&&(a._id=null,this.nodes=b.without(this.nodes,a),this._packNodes(),this._notify(a,c))},i.prototype.canMoveNode=function(c,d,e,f,g){if(!this.isNodeChangedPosition(c,d,e,f,g))return!1;var h=Boolean(b.find(this.nodes,function(a){return a.locked}));if(!this.height&&!h)return!0;if(!this.isAreaEmpty(d,e,f,g,c))return!1;var j,k=new i(this.width,null,this["float"],0,b.map(this.nodes,function(b){return b==c?j=a.extend({},b):a.extend({},b)}));if("undefined"==typeof j)return!0;k.moveNode(j,d,e,f,g,!1,!0);var l=!0; // always allow moving the one out of bounds @@ -30,11 +30,11 @@ e.itemClass=e.itemClass||"grid-stack-item";var k=this.container.closest("."+e.it this._updateStyles(),this._updateHeightsOnResize=b.throttle(function(){j.cellHeight(j.cellWidth(),!1)},100),this.onResizeHandler=function(){if(h&&j._updateHeightsOnResize(),j._isOneColumnMode()){if(g)return;j.container.addClass(j.opts.oneColumnModeClass),g=!0,j.grid._sortNodes(),b.each(j.grid.nodes,function(a){j.container.append(a.el),j.opts.staticGrid||((a.noMove||j.opts.disableDrag)&&j.dd.draggable(a.el,"disable"),(a.noResize||j.opts.disableResize)&&j.dd.resizable(a.el,"disable"),a.el.trigger("resize"))})}else{if(!g)return;if(j.container.removeClass(j.opts.oneColumnModeClass),g=!1,j.opts.staticGrid)return;b.each(j.grid.nodes,function(a){a.noMove||j.opts.disableDrag||j.dd.draggable(a.el,"enable"),a.noResize||j.opts.disableResize||j.dd.resizable(a.el,"enable"),a.el.trigger("resize")})}},a(window).resize(this.onResizeHandler),this.onResizeHandler(),!j.opts.staticGrid&&"string"==typeof j.opts.removable){var n=a(j.opts.removable);this.dd.isDroppable(n)||this.dd.droppable(n,{accept:"."+j.opts.itemClass}),this.dd.on(n,"dropover",function(b,c){var d=a(c.draggable),e=d.data("_gridstack_node");e._grid===j&&j._setupRemovingTimeout(d)}).on(n,"dropout",function(b,c){var d=a(c.draggable),e=d.data("_gridstack_node");e._grid===j&&j._clearRemovingTimeout(d)})}if(!j.opts.staticGrid&&j.opts.acceptWidgets){var o=null,p=function(a,b){var c=o,d=c.data("_gridstack_node"),e=j.getCellFromPixel(b.offset,!0),f=Math.max(0,e.x),g=Math.max(0,e.y);if(d._added){if(!j.grid.canMoveNode(d,f,g))return;j.grid.moveNode(d,f,g),j._updateContainerHeight()}else d._added=!0,d.el=c,d.x=f,d.y=g,j.grid.cleanNodes(),j.grid.beginUpdate(d),j.grid.addNode(d),j.container.append(j.placeholder),j.placeholder.attr("data-gs-x",d.x).attr("data-gs-y",d.y).attr("data-gs-width",d.width).attr("data-gs-height",d.height).show(),d.el=j.placeholder,d._beforeDragX=d.x,d._beforeDragY=d.y,j._updateContainerHeight()};this.dd.droppable(j.container,{accept:function(b){b=a(b);var c=b.data("_gridstack_node");return(!c||c._grid!==j)&&b.is(j.opts.acceptWidgets===!0?".grid-stack-item":j.opts.acceptWidgets)}}).on(j.container,"dropover",function(b,c){var d=(j.container.offset(),a(c.draggable)),e=j.cellWidth(),f=j.cellHeight(),g=d.data("_gridstack_node"),h=g?g.width:Math.ceil(d.outerWidth()/e),i=g?g.height:Math.ceil(d.outerHeight()/f);o=d;var k=j.grid._prepareNode({width:h,height:i,_added:!1,_temporary:!0});d.data("_gridstack_node",k),d.data("_gridstack_node_orig",g),d.on("drag",p)}).on(j.container,"dropout",function(b,c){var d=a(c.draggable);d.unbind("drag",p);var e=d.data("_gridstack_node");e.el=null,j.grid.removeNode(e),j.placeholder.detach(),j._updateContainerHeight(),d.data("_gridstack_node",d.data("_gridstack_node_orig"))}).on(j.container,"drop",function(b,c){j.placeholder.detach();var d=a(c.draggable).data("_gridstack_node");d._grid=j;var e=a(c.draggable).clone(!1);e.data("_gridstack_node",d),a(c.draggable).remove(),d.el=e,j.placeholder.hide(),e.attr("data-gs-x",d.x).attr("data-gs-y",d.y).attr("data-gs-width",d.width).attr("data-gs-height",d.height).addClass(j.opts.itemClass).removeAttr("style").enableSelection().removeData("draggable").removeClass("ui-draggable ui-draggable-dragging ui-draggable-disabled").unbind("drag",p),j.container.append(e),j._prepareElementsByNode(e,d),j._updateContainerHeight(),j._triggerChangeEvent(),j.grid.endUpdate()})}}; // jscs:disable requireCamelCaseOrUpperCaseIdentifiers // jscs:enable requireCamelCaseOrUpperCaseIdentifiers -return j.prototype._triggerChangeEvent=function(a){var b=this.grid.getDirtyNodes(),c=!1,d=[];b&&b.length&&(d.push(b),c=!0),(c||a===!0)&&this.container.trigger("change",d)},j.prototype._triggerAddEvent=function(){this.grid._addedNodes&&this.grid._addedNodes.length>0&&(this.container.trigger("added",[b.map(this.grid._addedNodes,b.clone)]),this.grid._addedNodes=[])},j.prototype._triggerRemoveEvent=function(){this.grid._removedNodes&&this.grid._removedNodes.length>0&&(this.container.trigger("removed",[b.map(this.grid._removedNodes,b.clone)]),this.grid._removedNodes=[])},j.prototype._initStyles=function(){this._stylesId&&g.removeStylesheet(this._stylesId),this._stylesId="gridstack-style-"+(1e5*Math.random()).toFixed(),this._styles=g.createStylesheet(this._stylesId),null!==this._styles&&(this._styles._max=0)},j.prototype._updateStyles=function(a){if(null!==this._styles&&"undefined"!=typeof this._styles){var b,c="."+this.opts._class+" ."+this.opts.itemClass,d=this;if("undefined"==typeof a&&(a=this._styles._max||this.opts.height,this._initStyles(),this._updateContainerHeight()),this.opts.cellHeight&&!(0!==this._styles._max&&a<=this._styles._max)&&(b=this.opts.verticalMargin&&this.opts.cellHeightUnit!==this.opts.verticalMarginUnit?function(a,b){return a&&b?"calc("+(d.opts.cellHeight*a+d.opts.cellHeightUnit)+" + "+(d.opts.verticalMargin*b+d.opts.verticalMarginUnit)+")":d.opts.cellHeight*a+d.opts.verticalMargin*b+d.opts.cellHeightUnit}:function(a,b){return d.opts.cellHeight*a+d.opts.verticalMargin*b+d.opts.cellHeightUnit},0===this._styles._max&&g.insertCSSRule(this._styles,c,"min-height: "+b(1,0)+";",0),a>this._styles._max)){for(var e=this._styles._max;e=f.grid.width||k<0||f.grid.height&&k>=f.grid.height?(f.opts.removable===!0&&f._setupRemovingTimeout(b),j=c._beforeDragX,k=c._beforeDragY,f.placeholder.detach(),f.placeholder.hide(),f.grid.removeNode(c),f._updateContainerHeight(),c._temporaryRemoved=!0):(f._clearRemovingTimeout(b),c._temporaryRemoved&&(f.grid.addNode(c),f.placeholder.attr("data-gs-x",j).attr("data-gs-y",k).attr("data-gs-width",h).attr("data-gs-height",i).show(),f.container.append(f.placeholder),c.el=f.placeholder,c._temporaryRemoved=!1));else if("resize"==a.type&&j<0)return; +return j.prototype._triggerChangeEvent=function(a){var b=this.grid.getDirtyNodes(),c=!1,d=[];b&&b.length&&(d.push(b),c=!0),(c||a===!0)&&this.container.trigger("change",d)},j.prototype._triggerAddEvent=function(){this.grid._addedNodes&&this.grid._addedNodes.length>0&&(this.container.trigger("added",[b.map(this.grid._addedNodes,b.clone)]),this.grid._addedNodes=[])},j.prototype._triggerRemoveEvent=function(){this.grid._removedNodes&&this.grid._removedNodes.length>0&&(this.container.trigger("removed",[b.map(this.grid._removedNodes,b.clone)]),this.grid._removedNodes=[])},j.prototype._initStyles=function(){this._stylesId&&g.removeStylesheet(this._stylesId),this._stylesId="gridstack-style-"+(1e5*Math.random()).toFixed(),this._styles=g.createStylesheet(this._stylesId),null!==this._styles&&(this._styles._max=0)},j.prototype._updateStyles=function(a){if(null!==this._styles&&"undefined"!=typeof this._styles){var b,c="."+this.opts._class+" ."+this.opts.itemClass,d=this;if("undefined"==typeof a&&(a=this._styles._max||this.opts.height,this._initStyles(),this._updateContainerHeight()),this.opts.cellHeight&&!(0!==this._styles._max&&a<=this._styles._max)&&(b=this.opts.verticalMargin&&this.opts.cellHeightUnit!==this.opts.verticalMarginUnit?function(a,b){return a&&b?"calc("+(d.opts.cellHeight*a+d.opts.cellHeightUnit)+" + "+(d.opts.verticalMargin*b+d.opts.verticalMarginUnit)+")":d.opts.cellHeight*a+d.opts.verticalMargin*b+d.opts.cellHeightUnit}:function(a,b){return d.opts.cellHeight*a+d.opts.verticalMargin*b+d.opts.cellHeightUnit},0===this._styles._max&&g.insertCSSRule(this._styles,c,"min-height: "+b(1,0)+";",0),a>this._styles._max)){for(var e=this._styles._max;e this.height || x + width > this.width) { + if (y < 0 || y + height > this.height || x < 0 || x + width > this.width) { return false; } var collisionNodes = this.whatIsHere(x, y, width, height); @@ -1118,7 +1118,17 @@ } if (event.type == 'drag') { - if (x < 0 || x >= self.grid.width || y < 0 || (self.grid.height && y >= self.grid.height)) { + var cannotPutHere = !self.isAreaEmpty(x, y), + whatIsHere; + + if (cannotPutHere) { + whatIsHere = self.grid.whatIsHere(x, y); + if (whatIsHere && whatIsHere[0] && whatIsHere[0].el !== this.placeholder) { + cannotPutHere = false; + } + } + + if (cannotPutHere) { if (self.opts.removable === true) { self._setupRemovingTimeout(el); } @@ -1675,8 +1685,8 @@ this._updateContainerHeight(); }; - GridStack.prototype.isAreaEmpty = function(x, y, width, height) { - return this.grid.isAreaEmpty(x, y, width, height); + GridStack.prototype.isAreaEmpty = function(x, y, width, height, exceptNode) { + return this.grid.isAreaEmpty(x, y, width, height, exceptNode); }; GridStack.prototype.findFreeSpace = function(w, h) { diff --git a/dist/gridstack.min.js b/dist/gridstack.min.js index b0c370bc2..09d968d75 100644 --- a/dist/gridstack.min.js +++ b/dist/gridstack.min.js @@ -17,7 +17,7 @@ g.is_intercepted=e(g.isIntercepted,"is_intercepted","isIntercepted"),g.create_st // For Meteor support: https://github.com/troolee/gridstack.js/pull/272 i.prototype.getNodeDataByDOMEl=function(a){return b.find(this.nodes,function(b){return a.get(0)===b.el.get(0)})},i.prototype._fixCollisions=function(a,c){this._sortNodes(-1);var d=a,e=Boolean(b.find(this.nodes,function(a){return a.locked}));for(this["float"]||e||(d={x:0,y:a.y,width:this.width,height:a.height});;){var f=b.find(this.nodes,b.bind(g._collisionNodeCheck,{node:a,nn:d}));if("undefined"==typeof f)return;this.moveNode(f,f.x,a.y+a.height,f.width,f.height,!0)}},i.prototype.whatIsHere=function(a,c,d,e){var f={x:a||0,y:c||0,width:d||1,height:e||1},h=b.filter(this.nodes,b.bind(function(a){return g.isIntercepted(a,f)},this));return h},i.prototype.isAreaEmpty=function(a,b,c,d,e){ // first check if is not out of bounds -if(b+d>this.height||a+c>this.width)return!1;var f=this.whatIsHere(a,b,c,d);return!f.length||e&&1===f.length&&f[0]===e},i.prototype.findFreeSpace=function(a,b,c){var d,e,f=null;for( +if(b<0||b+d>this.height||a<0||a+c>this.width)return!1;var f=this.whatIsHere(a,b,c,d);return!f.length||e&&1===f.length&&f[0]===e},i.prototype.findFreeSpace=function(a,b,c){var d,e,f=null;for( // first free for 1x1 or we have specified width and height a||(a=1),b||(b=1),d=0;d<=this.width-a&&!f;d++)for(e=0;e<=this.height-b&&!f;e++)this.isAreaEmpty(d,e,a,b,c)&&(f={x:d,y:e,w:a,h:b});return f},i.prototype._sortNodes=function(a){this.nodes=g.sort(this.nodes,a,this.width)},i.prototype._packNodes=function(){this._sortNodes(),this["float"]?b.each(this.nodes,b.bind(function(a,c){if(!a._updating&&"undefined"!=typeof a._origY&&a.y!=a._origY)for(var d=a.y;d>=a._origY;){var e=b.chain(this.nodes).find(b.bind(g._didCollide,{n:a,newY:d})).value();e||(a._dirty=!0,a.y=d),--d}},this)):b.each(this.nodes,b.bind(function(a,c){if(!a.locked)for(;a.y>0;){var d=a.y-1,e=0===c;if(c>0){var f=b.chain(this.nodes).take(c).find(b.bind(g._didCollide,{n:a,newY:d})).value();e="undefined"==typeof f}if(!e)break;a._dirty=a.y!=d,a.y=d}},this))},i.prototype._prepareNode=function(a,c){return a=b.defaults(a||{},{width:1,height:1,x:0,y:0}),a.x=parseInt(""+a.x),a.y=parseInt(""+a.y),a.width=parseInt(""+a.width),a.height=parseInt(""+a.height),a.autoPosition=a.autoPosition||!1,a.noResize=a.noResize||!1,a.noMove=a.noMove||!1,a.width>this.width?a.width=this.width:a.width<1&&(a.width=1),this.height&&a.height>this.height?a.height=this.height:a.height<1&&(a.height=1),a.x<0&&(a.x=0),a.x+a.width>this.width&&(c?a.width=this.width-a.x:a.x=this.width-a.width),a.y<0&&(a.y=0),a},i.prototype._notify=function(){var a=Array.prototype.slice.call(arguments,0);if(a[0]="undefined"==typeof a[0]?[]:[a[0]],a[1]="undefined"==typeof a[1]||a[1],!this._updateCounter){var b=a[0].concat(this.getDirtyNodes());this.onchange(b,a[1])}},i.prototype.cleanNodes=function(){this._updateCounter||b.each(this.nodes,function(a){a._dirty=!1})},i.prototype.getDirtyNodes=function(){return b.filter(this.nodes,function(a){return a._dirty})},i.prototype.addNode=function(a,c,d){if(a=this._prepareNode(a),"undefined"!=typeof a.maxWidth&&(a.width=Math.min(a.width,a.maxWidth)),"undefined"!=typeof a.maxHeight&&(a.height=Math.min(a.height,a.maxHeight)),"undefined"!=typeof a.minWidth&&(a.width=Math.max(a.width,a.minWidth)),"undefined"!=typeof a.minHeight&&(a.height=Math.max(a.height,a.minHeight)),a._id=++h,a._dirty=!0,a.autoPosition){this._sortNodes();for(var e=0;;++e){var f=e%this.width,i=Math.floor(e/this.width);if(!(f+a.width>this.width||b.find(this.nodes,b.bind(g._isAddNodeIntercepted,{x:f,y:i,node:a})))){a.x=f,a.y=i;break}}}return this.nodes.push(a),"undefined"!=typeof c&&c&&this._addedNodes.push(b.clone(a)),this._fixCollisions(a,d),this._packNodes(),this._notify(),a},i.prototype.removeNode=function(a,c){a&&(a._id=null,this.nodes=b.without(this.nodes,a),this._packNodes(),this._notify(a,c))},i.prototype.canMoveNode=function(c,d,e,f,g){if(!this.isNodeChangedPosition(c,d,e,f,g))return!1;var h=Boolean(b.find(this.nodes,function(a){return a.locked}));if(!this.height&&!h)return!0;if(!this.isAreaEmpty(d,e,f,g,c))return!1;var j,k=new i(this.width,null,this["float"],0,b.map(this.nodes,function(b){return b==c?j=a.extend({},b):a.extend({},b)}));if("undefined"==typeof j)return!0;k.moveNode(j,d,e,f,g,!1,!0);var l=!0; // always allow moving the one out of bounds @@ -30,11 +30,11 @@ e.itemClass=e.itemClass||"grid-stack-item";var k=this.container.closest("."+e.it this._updateStyles(),this._updateHeightsOnResize=b.throttle(function(){j.cellHeight(j.cellWidth(),!1)},100),this.onResizeHandler=function(){if(h&&j._updateHeightsOnResize(),j._isOneColumnMode()){if(g)return;j.container.addClass(j.opts.oneColumnModeClass),g=!0,j.grid._sortNodes(),b.each(j.grid.nodes,function(a){j.container.append(a.el),j.opts.staticGrid||((a.noMove||j.opts.disableDrag)&&j.dd.draggable(a.el,"disable"),(a.noResize||j.opts.disableResize)&&j.dd.resizable(a.el,"disable"),a.el.trigger("resize"))})}else{if(!g)return;if(j.container.removeClass(j.opts.oneColumnModeClass),g=!1,j.opts.staticGrid)return;b.each(j.grid.nodes,function(a){a.noMove||j.opts.disableDrag||j.dd.draggable(a.el,"enable"),a.noResize||j.opts.disableResize||j.dd.resizable(a.el,"enable"),a.el.trigger("resize")})}},a(window).resize(this.onResizeHandler),this.onResizeHandler(),!j.opts.staticGrid&&"string"==typeof j.opts.removable){var n=a(j.opts.removable);this.dd.isDroppable(n)||this.dd.droppable(n,{accept:"."+j.opts.itemClass}),this.dd.on(n,"dropover",function(b,c){var d=a(c.draggable),e=d.data("_gridstack_node");e._grid===j&&j._setupRemovingTimeout(d)}).on(n,"dropout",function(b,c){var d=a(c.draggable),e=d.data("_gridstack_node");e._grid===j&&j._clearRemovingTimeout(d)})}if(!j.opts.staticGrid&&j.opts.acceptWidgets){var o=null,p=function(a,b){var c=o,d=c.data("_gridstack_node"),e=j.getCellFromPixel(b.offset,!0),f=Math.max(0,e.x),g=Math.max(0,e.y);if(d._added){if(!j.grid.canMoveNode(d,f,g))return;j.grid.moveNode(d,f,g),j._updateContainerHeight()}else d._added=!0,d.el=c,d.x=f,d.y=g,j.grid.cleanNodes(),j.grid.beginUpdate(d),j.grid.addNode(d),j.container.append(j.placeholder),j.placeholder.attr("data-gs-x",d.x).attr("data-gs-y",d.y).attr("data-gs-width",d.width).attr("data-gs-height",d.height).show(),d.el=j.placeholder,d._beforeDragX=d.x,d._beforeDragY=d.y,j._updateContainerHeight()};this.dd.droppable(j.container,{accept:function(b){b=a(b);var c=b.data("_gridstack_node");return(!c||c._grid!==j)&&b.is(j.opts.acceptWidgets===!0?".grid-stack-item":j.opts.acceptWidgets)}}).on(j.container,"dropover",function(b,c){var d=(j.container.offset(),a(c.draggable)),e=j.cellWidth(),f=j.cellHeight(),g=d.data("_gridstack_node"),h=g?g.width:Math.ceil(d.outerWidth()/e),i=g?g.height:Math.ceil(d.outerHeight()/f);o=d;var k=j.grid._prepareNode({width:h,height:i,_added:!1,_temporary:!0});d.data("_gridstack_node",k),d.data("_gridstack_node_orig",g),d.on("drag",p)}).on(j.container,"dropout",function(b,c){var d=a(c.draggable);d.unbind("drag",p);var e=d.data("_gridstack_node");e.el=null,j.grid.removeNode(e),j.placeholder.detach(),j._updateContainerHeight(),d.data("_gridstack_node",d.data("_gridstack_node_orig"))}).on(j.container,"drop",function(b,c){j.placeholder.detach();var d=a(c.draggable).data("_gridstack_node");d._grid=j;var e=a(c.draggable).clone(!1);e.data("_gridstack_node",d),a(c.draggable).remove(),d.el=e,j.placeholder.hide(),e.attr("data-gs-x",d.x).attr("data-gs-y",d.y).attr("data-gs-width",d.width).attr("data-gs-height",d.height).addClass(j.opts.itemClass).removeAttr("style").enableSelection().removeData("draggable").removeClass("ui-draggable ui-draggable-dragging ui-draggable-disabled").unbind("drag",p),j.container.append(e),j._prepareElementsByNode(e,d),j._updateContainerHeight(),j._triggerChangeEvent(),j.grid.endUpdate()})}}; // jscs:disable requireCamelCaseOrUpperCaseIdentifiers // jscs:enable requireCamelCaseOrUpperCaseIdentifiers -return j.prototype._triggerChangeEvent=function(a){var b=this.grid.getDirtyNodes(),c=!1,d=[];b&&b.length&&(d.push(b),c=!0),(c||a===!0)&&this.container.trigger("change",d)},j.prototype._triggerAddEvent=function(){this.grid._addedNodes&&this.grid._addedNodes.length>0&&(this.container.trigger("added",[b.map(this.grid._addedNodes,b.clone)]),this.grid._addedNodes=[])},j.prototype._triggerRemoveEvent=function(){this.grid._removedNodes&&this.grid._removedNodes.length>0&&(this.container.trigger("removed",[b.map(this.grid._removedNodes,b.clone)]),this.grid._removedNodes=[])},j.prototype._initStyles=function(){this._stylesId&&g.removeStylesheet(this._stylesId),this._stylesId="gridstack-style-"+(1e5*Math.random()).toFixed(),this._styles=g.createStylesheet(this._stylesId),null!==this._styles&&(this._styles._max=0)},j.prototype._updateStyles=function(a){if(null!==this._styles&&"undefined"!=typeof this._styles){var b,c="."+this.opts._class+" ."+this.opts.itemClass,d=this;if("undefined"==typeof a&&(a=this._styles._max||this.opts.height,this._initStyles(),this._updateContainerHeight()),this.opts.cellHeight&&!(0!==this._styles._max&&a<=this._styles._max)&&(b=this.opts.verticalMargin&&this.opts.cellHeightUnit!==this.opts.verticalMarginUnit?function(a,b){return a&&b?"calc("+(d.opts.cellHeight*a+d.opts.cellHeightUnit)+" + "+(d.opts.verticalMargin*b+d.opts.verticalMarginUnit)+")":d.opts.cellHeight*a+d.opts.verticalMargin*b+d.opts.cellHeightUnit}:function(a,b){return d.opts.cellHeight*a+d.opts.verticalMargin*b+d.opts.cellHeightUnit},0===this._styles._max&&g.insertCSSRule(this._styles,c,"min-height: "+b(1,0)+";",0),a>this._styles._max)){for(var e=this._styles._max;e=f.grid.width||k<0||f.grid.height&&k>=f.grid.height?(f.opts.removable===!0&&f._setupRemovingTimeout(b),j=c._beforeDragX,k=c._beforeDragY,f.placeholder.detach(),f.placeholder.hide(),f.grid.removeNode(c),f._updateContainerHeight(),c._temporaryRemoved=!0):(f._clearRemovingTimeout(b),c._temporaryRemoved&&(f.grid.addNode(c),f.placeholder.attr("data-gs-x",j).attr("data-gs-y",k).attr("data-gs-width",h).attr("data-gs-height",i).show(),f.container.append(f.placeholder),c.el=f.placeholder,c._temporaryRemoved=!1));else if("resize"==a.type&&j<0)return; +return j.prototype._triggerChangeEvent=function(a){var b=this.grid.getDirtyNodes(),c=!1,d=[];b&&b.length&&(d.push(b),c=!0),(c||a===!0)&&this.container.trigger("change",d)},j.prototype._triggerAddEvent=function(){this.grid._addedNodes&&this.grid._addedNodes.length>0&&(this.container.trigger("added",[b.map(this.grid._addedNodes,b.clone)]),this.grid._addedNodes=[])},j.prototype._triggerRemoveEvent=function(){this.grid._removedNodes&&this.grid._removedNodes.length>0&&(this.container.trigger("removed",[b.map(this.grid._removedNodes,b.clone)]),this.grid._removedNodes=[])},j.prototype._initStyles=function(){this._stylesId&&g.removeStylesheet(this._stylesId),this._stylesId="gridstack-style-"+(1e5*Math.random()).toFixed(),this._styles=g.createStylesheet(this._stylesId),null!==this._styles&&(this._styles._max=0)},j.prototype._updateStyles=function(a){if(null!==this._styles&&"undefined"!=typeof this._styles){var b,c="."+this.opts._class+" ."+this.opts.itemClass,d=this;if("undefined"==typeof a&&(a=this._styles._max||this.opts.height,this._initStyles(),this._updateContainerHeight()),this.opts.cellHeight&&!(0!==this._styles._max&&a<=this._styles._max)&&(b=this.opts.verticalMargin&&this.opts.cellHeightUnit!==this.opts.verticalMarginUnit?function(a,b){return a&&b?"calc("+(d.opts.cellHeight*a+d.opts.cellHeightUnit)+" + "+(d.opts.verticalMargin*b+d.opts.verticalMarginUnit)+")":d.opts.cellHeight*a+d.opts.verticalMargin*b+d.opts.cellHeightUnit}:function(a,b){return d.opts.cellHeight*a+d.opts.verticalMargin*b+d.opts.cellHeightUnit},0===this._styles._max&&g.insertCSSRule(this._styles,c,"min-height: "+b(1,0)+";",0),a>this._styles._max)){for(var e=this._styles._max;e Date: Thu, 26 Jan 2017 12:06:15 +0100 Subject: [PATCH 29/35] Fix previous fix --- src/gridstack.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gridstack.js b/src/gridstack.js index c7636792c..86db3763b 100644 --- a/src/gridstack.js +++ b/src/gridstack.js @@ -1118,12 +1118,12 @@ } if (event.type == 'drag') { - var cannotPutHere = !self.isAreaEmpty(x, y), + var cannotPutHere = !self.isAreaEmpty(x, y, node.width, node.height, node), whatIsHere; if (cannotPutHere) { - whatIsHere = self.grid.whatIsHere(x, y); - if (whatIsHere && whatIsHere[0] && whatIsHere[0].el !== this.placeholder) { + whatIsHere = self.grid.whatIsHere(x, y, node.width, node.height); + if (whatIsHere && whatIsHere.length === 1 && whatIsHere[0].el === this.placeholder) { cannotPutHere = false; } } From 641cad2d8b6eeba014359155c29839c299bdc2bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Inga=20Br=C5=ABnava?= Date: Thu, 26 Jan 2017 12:06:37 +0100 Subject: [PATCH 30/35] Assets --- dist/gridstack.all.js | 2 +- dist/gridstack.js | 6 +++--- dist/gridstack.min.js | 2 +- dist/gridstack.min.map | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/dist/gridstack.all.js b/dist/gridstack.all.js index 443d21d66..77cf06b98 100644 --- a/dist/gridstack.all.js +++ b/dist/gridstack.all.js @@ -30,7 +30,7 @@ e.itemClass=e.itemClass||"grid-stack-item";var k=this.container.closest("."+e.it this._updateStyles(),this._updateHeightsOnResize=b.throttle(function(){j.cellHeight(j.cellWidth(),!1)},100),this.onResizeHandler=function(){if(h&&j._updateHeightsOnResize(),j._isOneColumnMode()){if(g)return;j.container.addClass(j.opts.oneColumnModeClass),g=!0,j.grid._sortNodes(),b.each(j.grid.nodes,function(a){j.container.append(a.el),j.opts.staticGrid||((a.noMove||j.opts.disableDrag)&&j.dd.draggable(a.el,"disable"),(a.noResize||j.opts.disableResize)&&j.dd.resizable(a.el,"disable"),a.el.trigger("resize"))})}else{if(!g)return;if(j.container.removeClass(j.opts.oneColumnModeClass),g=!1,j.opts.staticGrid)return;b.each(j.grid.nodes,function(a){a.noMove||j.opts.disableDrag||j.dd.draggable(a.el,"enable"),a.noResize||j.opts.disableResize||j.dd.resizable(a.el,"enable"),a.el.trigger("resize")})}},a(window).resize(this.onResizeHandler),this.onResizeHandler(),!j.opts.staticGrid&&"string"==typeof j.opts.removable){var n=a(j.opts.removable);this.dd.isDroppable(n)||this.dd.droppable(n,{accept:"."+j.opts.itemClass}),this.dd.on(n,"dropover",function(b,c){var d=a(c.draggable),e=d.data("_gridstack_node");e._grid===j&&j._setupRemovingTimeout(d)}).on(n,"dropout",function(b,c){var d=a(c.draggable),e=d.data("_gridstack_node");e._grid===j&&j._clearRemovingTimeout(d)})}if(!j.opts.staticGrid&&j.opts.acceptWidgets){var o=null,p=function(a,b){var c=o,d=c.data("_gridstack_node"),e=j.getCellFromPixel(b.offset,!0),f=Math.max(0,e.x),g=Math.max(0,e.y);if(d._added){if(!j.grid.canMoveNode(d,f,g))return;j.grid.moveNode(d,f,g),j._updateContainerHeight()}else d._added=!0,d.el=c,d.x=f,d.y=g,j.grid.cleanNodes(),j.grid.beginUpdate(d),j.grid.addNode(d),j.container.append(j.placeholder),j.placeholder.attr("data-gs-x",d.x).attr("data-gs-y",d.y).attr("data-gs-width",d.width).attr("data-gs-height",d.height).show(),d.el=j.placeholder,d._beforeDragX=d.x,d._beforeDragY=d.y,j._updateContainerHeight()};this.dd.droppable(j.container,{accept:function(b){b=a(b);var c=b.data("_gridstack_node");return(!c||c._grid!==j)&&b.is(j.opts.acceptWidgets===!0?".grid-stack-item":j.opts.acceptWidgets)}}).on(j.container,"dropover",function(b,c){var d=(j.container.offset(),a(c.draggable)),e=j.cellWidth(),f=j.cellHeight(),g=d.data("_gridstack_node"),h=g?g.width:Math.ceil(d.outerWidth()/e),i=g?g.height:Math.ceil(d.outerHeight()/f);o=d;var k=j.grid._prepareNode({width:h,height:i,_added:!1,_temporary:!0});d.data("_gridstack_node",k),d.data("_gridstack_node_orig",g),d.on("drag",p)}).on(j.container,"dropout",function(b,c){var d=a(c.draggable);d.unbind("drag",p);var e=d.data("_gridstack_node");e.el=null,j.grid.removeNode(e),j.placeholder.detach(),j._updateContainerHeight(),d.data("_gridstack_node",d.data("_gridstack_node_orig"))}).on(j.container,"drop",function(b,c){j.placeholder.detach();var d=a(c.draggable).data("_gridstack_node");d._grid=j;var e=a(c.draggable).clone(!1);e.data("_gridstack_node",d),a(c.draggable).remove(),d.el=e,j.placeholder.hide(),e.attr("data-gs-x",d.x).attr("data-gs-y",d.y).attr("data-gs-width",d.width).attr("data-gs-height",d.height).addClass(j.opts.itemClass).removeAttr("style").enableSelection().removeData("draggable").removeClass("ui-draggable ui-draggable-dragging ui-draggable-disabled").unbind("drag",p),j.container.append(e),j._prepareElementsByNode(e,d),j._updateContainerHeight(),j._triggerChangeEvent(),j.grid.endUpdate()})}}; // jscs:disable requireCamelCaseOrUpperCaseIdentifiers // jscs:enable requireCamelCaseOrUpperCaseIdentifiers -return j.prototype._triggerChangeEvent=function(a){var b=this.grid.getDirtyNodes(),c=!1,d=[];b&&b.length&&(d.push(b),c=!0),(c||a===!0)&&this.container.trigger("change",d)},j.prototype._triggerAddEvent=function(){this.grid._addedNodes&&this.grid._addedNodes.length>0&&(this.container.trigger("added",[b.map(this.grid._addedNodes,b.clone)]),this.grid._addedNodes=[])},j.prototype._triggerRemoveEvent=function(){this.grid._removedNodes&&this.grid._removedNodes.length>0&&(this.container.trigger("removed",[b.map(this.grid._removedNodes,b.clone)]),this.grid._removedNodes=[])},j.prototype._initStyles=function(){this._stylesId&&g.removeStylesheet(this._stylesId),this._stylesId="gridstack-style-"+(1e5*Math.random()).toFixed(),this._styles=g.createStylesheet(this._stylesId),null!==this._styles&&(this._styles._max=0)},j.prototype._updateStyles=function(a){if(null!==this._styles&&"undefined"!=typeof this._styles){var b,c="."+this.opts._class+" ."+this.opts.itemClass,d=this;if("undefined"==typeof a&&(a=this._styles._max||this.opts.height,this._initStyles(),this._updateContainerHeight()),this.opts.cellHeight&&!(0!==this._styles._max&&a<=this._styles._max)&&(b=this.opts.verticalMargin&&this.opts.cellHeightUnit!==this.opts.verticalMarginUnit?function(a,b){return a&&b?"calc("+(d.opts.cellHeight*a+d.opts.cellHeightUnit)+" + "+(d.opts.verticalMargin*b+d.opts.verticalMarginUnit)+")":d.opts.cellHeight*a+d.opts.verticalMargin*b+d.opts.cellHeightUnit}:function(a,b){return d.opts.cellHeight*a+d.opts.verticalMargin*b+d.opts.cellHeightUnit},0===this._styles._max&&g.insertCSSRule(this._styles,c,"min-height: "+b(1,0)+";",0),a>this._styles._max)){for(var e=this._styles._max;e0&&(this.container.trigger("added",[b.map(this.grid._addedNodes,b.clone)]),this.grid._addedNodes=[])},j.prototype._triggerRemoveEvent=function(){this.grid._removedNodes&&this.grid._removedNodes.length>0&&(this.container.trigger("removed",[b.map(this.grid._removedNodes,b.clone)]),this.grid._removedNodes=[])},j.prototype._initStyles=function(){this._stylesId&&g.removeStylesheet(this._stylesId),this._stylesId="gridstack-style-"+(1e5*Math.random()).toFixed(),this._styles=g.createStylesheet(this._stylesId),null!==this._styles&&(this._styles._max=0)},j.prototype._updateStyles=function(a){if(null!==this._styles&&"undefined"!=typeof this._styles){var b,c="."+this.opts._class+" ."+this.opts.itemClass,d=this;if("undefined"==typeof a&&(a=this._styles._max||this.opts.height,this._initStyles(),this._updateContainerHeight()),this.opts.cellHeight&&!(0!==this._styles._max&&a<=this._styles._max)&&(b=this.opts.verticalMargin&&this.opts.cellHeightUnit!==this.opts.verticalMarginUnit?function(a,b){return a&&b?"calc("+(d.opts.cellHeight*a+d.opts.cellHeightUnit)+" + "+(d.opts.verticalMargin*b+d.opts.verticalMarginUnit)+")":d.opts.cellHeight*a+d.opts.verticalMargin*b+d.opts.cellHeightUnit}:function(a,b){return d.opts.cellHeight*a+d.opts.verticalMargin*b+d.opts.cellHeightUnit},0===this._styles._max&&g.insertCSSRule(this._styles,c,"min-height: "+b(1,0)+";",0),a>this._styles._max)){for(var e=this._styles._max;e0&&(this.container.trigger("added",[b.map(this.grid._addedNodes,b.clone)]),this.grid._addedNodes=[])},j.prototype._triggerRemoveEvent=function(){this.grid._removedNodes&&this.grid._removedNodes.length>0&&(this.container.trigger("removed",[b.map(this.grid._removedNodes,b.clone)]),this.grid._removedNodes=[])},j.prototype._initStyles=function(){this._stylesId&&g.removeStylesheet(this._stylesId),this._stylesId="gridstack-style-"+(1e5*Math.random()).toFixed(),this._styles=g.createStylesheet(this._stylesId),null!==this._styles&&(this._styles._max=0)},j.prototype._updateStyles=function(a){if(null!==this._styles&&"undefined"!=typeof this._styles){var b,c="."+this.opts._class+" ."+this.opts.itemClass,d=this;if("undefined"==typeof a&&(a=this._styles._max||this.opts.height,this._initStyles(),this._updateContainerHeight()),this.opts.cellHeight&&!(0!==this._styles._max&&a<=this._styles._max)&&(b=this.opts.verticalMargin&&this.opts.cellHeightUnit!==this.opts.verticalMarginUnit?function(a,b){return a&&b?"calc("+(d.opts.cellHeight*a+d.opts.cellHeightUnit)+" + "+(d.opts.verticalMargin*b+d.opts.verticalMarginUnit)+")":d.opts.cellHeight*a+d.opts.verticalMargin*b+d.opts.cellHeightUnit}:function(a,b){return d.opts.cellHeight*a+d.opts.verticalMargin*b+d.opts.cellHeightUnit},0===this._styles._max&&g.insertCSSRule(this._styles,c,"min-height: "+b(1,0)+";",0),a>this._styles._max)){for(var e=this._styles._max;e0&&(this.container.trigger("added",[b.map(this.grid._addedNodes,b.clone)]),this.grid._addedNodes=[])},j.prototype._triggerRemoveEvent=function(){this.grid._removedNodes&&this.grid._removedNodes.length>0&&(this.container.trigger("removed",[b.map(this.grid._removedNodes,b.clone)]),this.grid._removedNodes=[])},j.prototype._initStyles=function(){this._stylesId&&g.removeStylesheet(this._stylesId),this._stylesId="gridstack-style-"+(1e5*Math.random()).toFixed(),this._styles=g.createStylesheet(this._stylesId),null!==this._styles&&(this._styles._max=0)},j.prototype._updateStyles=function(a){if(null!==this._styles&&"undefined"!=typeof this._styles){var b,c="."+this.opts._class+" ."+this.opts.itemClass,d=this;if("undefined"==typeof a&&(a=this._styles._max||this.opts.height,this._initStyles(),this._updateContainerHeight()),this.opts.cellHeight&&!(0!==this._styles._max&&a<=this._styles._max)&&(b=this.opts.verticalMargin&&this.opts.cellHeightUnit!==this.opts.verticalMarginUnit?function(a,b){return a&&b?"calc("+(d.opts.cellHeight*a+d.opts.cellHeightUnit)+" + "+(d.opts.verticalMargin*b+d.opts.verticalMarginUnit)+")":d.opts.cellHeight*a+d.opts.verticalMargin*b+d.opts.cellHeightUnit}:function(a,b){return d.opts.cellHeight*a+d.opts.verticalMargin*b+d.opts.cellHeightUnit},0===this._styles._max&&g.insertCSSRule(this._styles,c,"min-height: "+b(1,0)+";",0),a>this._styles._max)){for(var e=this._styles._max;e Date: Thu, 26 Jan 2017 20:50:03 +0100 Subject: [PATCH 31/35] External function on draggable start --- src/gridstack.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/gridstack.js b/src/gridstack.js index 86db3763b..8ce3b130f 100644 --- a/src/gridstack.js +++ b/src/gridstack.js @@ -1211,6 +1211,10 @@ if (event.type == 'resizestart') { o.find('.grid-stack-item').trigger('resizestart'); } + + if (typeof self.opts.draggable.start === 'function') { + self.opts.draggable.start(event, ui); + } }; var onEndMoving = function(event, ui) { From 83a7dfbb3190dad1390b450a9b43f44da137a10f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Inga=20Br=C5=ABnava?= Date: Thu, 26 Jan 2017 20:50:43 +0100 Subject: [PATCH 32/35] Assets --- dist/gridstack.all.js | 2 +- dist/gridstack.js | 4 ++++ dist/gridstack.min.js | 2 +- dist/gridstack.min.map | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/dist/gridstack.all.js b/dist/gridstack.all.js index 77cf06b98..7ef922084 100644 --- a/dist/gridstack.all.js +++ b/dist/gridstack.all.js @@ -32,7 +32,7 @@ this._updateStyles(),this._updateHeightsOnResize=b.throttle(function(){j.cellHei // jscs:enable requireCamelCaseOrUpperCaseIdentifiers return j.prototype._triggerChangeEvent=function(a){var b=this.grid.getDirtyNodes(),c=!1,d=[];b&&b.length&&(d.push(b),c=!0),(c||a===!0)&&this.container.trigger("change",d)},j.prototype._triggerAddEvent=function(){this.grid._addedNodes&&this.grid._addedNodes.length>0&&(this.container.trigger("added",[b.map(this.grid._addedNodes,b.clone)]),this.grid._addedNodes=[])},j.prototype._triggerRemoveEvent=function(){this.grid._removedNodes&&this.grid._removedNodes.length>0&&(this.container.trigger("removed",[b.map(this.grid._removedNodes,b.clone)]),this.grid._removedNodes=[])},j.prototype._initStyles=function(){this._stylesId&&g.removeStylesheet(this._stylesId),this._stylesId="gridstack-style-"+(1e5*Math.random()).toFixed(),this._styles=g.createStylesheet(this._stylesId),null!==this._styles&&(this._styles._max=0)},j.prototype._updateStyles=function(a){if(null!==this._styles&&"undefined"!=typeof this._styles){var b,c="."+this.opts._class+" ."+this.opts.itemClass,d=this;if("undefined"==typeof a&&(a=this._styles._max||this.opts.height,this._initStyles(),this._updateContainerHeight()),this.opts.cellHeight&&!(0!==this._styles._max&&a<=this._styles._max)&&(b=this.opts.verticalMargin&&this.opts.cellHeightUnit!==this.opts.verticalMarginUnit?function(a,b){return a&&b?"calc("+(d.opts.cellHeight*a+d.opts.cellHeightUnit)+" + "+(d.opts.verticalMargin*b+d.opts.verticalMarginUnit)+")":d.opts.cellHeight*a+d.opts.verticalMargin*b+d.opts.cellHeightUnit}:function(a,b){return d.opts.cellHeight*a+d.opts.verticalMargin*b+d.opts.cellHeightUnit},0===this._styles._max&&g.insertCSSRule(this._styles,c,"min-height: "+b(1,0)+";",0),a>this._styles._max)){for(var e=this._styles._max;e0&&(this.container.trigger("added",[b.map(this.grid._addedNodes,b.clone)]),this.grid._addedNodes=[])},j.prototype._triggerRemoveEvent=function(){this.grid._removedNodes&&this.grid._removedNodes.length>0&&(this.container.trigger("removed",[b.map(this.grid._removedNodes,b.clone)]),this.grid._removedNodes=[])},j.prototype._initStyles=function(){this._stylesId&&g.removeStylesheet(this._stylesId),this._stylesId="gridstack-style-"+(1e5*Math.random()).toFixed(),this._styles=g.createStylesheet(this._stylesId),null!==this._styles&&(this._styles._max=0)},j.prototype._updateStyles=function(a){if(null!==this._styles&&"undefined"!=typeof this._styles){var b,c="."+this.opts._class+" ."+this.opts.itemClass,d=this;if("undefined"==typeof a&&(a=this._styles._max||this.opts.height,this._initStyles(),this._updateContainerHeight()),this.opts.cellHeight&&!(0!==this._styles._max&&a<=this._styles._max)&&(b=this.opts.verticalMargin&&this.opts.cellHeightUnit!==this.opts.verticalMarginUnit?function(a,b){return a&&b?"calc("+(d.opts.cellHeight*a+d.opts.cellHeightUnit)+" + "+(d.opts.verticalMargin*b+d.opts.verticalMarginUnit)+")":d.opts.cellHeight*a+d.opts.verticalMargin*b+d.opts.cellHeightUnit}:function(a,b){return d.opts.cellHeight*a+d.opts.verticalMargin*b+d.opts.cellHeightUnit},0===this._styles._max&&g.insertCSSRule(this._styles,c,"min-height: "+b(1,0)+";",0),a>this._styles._max)){for(var e=this._styles._max;e Date: Wed, 15 Feb 2017 15:27:44 +0100 Subject: [PATCH 33/35] Show grid on small screens --- src/gridstack.css | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gridstack.css b/src/gridstack.css index 319d58a75..7feeaffa4 100644 --- a/src/gridstack.css +++ b/src/gridstack.css @@ -302,6 +302,7 @@ transform: rotate(180deg); } */ +/* @media (max-width: 768px) { .grid-stack-item { position: relative !important; @@ -318,3 +319,4 @@ height: auto !important; } } +*/ From adfbfc0bd31338c1851ab4d7a6f2f162be3f7e8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Inga=20Br=C5=ABnava?= Date: Mon, 29 May 2017 08:07:33 +0200 Subject: [PATCH 34/35] Cleanup --- src/gridstack.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/gridstack.js b/src/gridstack.js index 8ce3b130f..070bd5f53 100644 --- a/src/gridstack.js +++ b/src/gridstack.js @@ -190,7 +190,7 @@ return _.find(this.nodes, function(n) { return el.get(0) === n.el.get(0); }); }; - GridStackEngine.prototype._fixCollisions = function(node, isClone) { + GridStackEngine.prototype._fixCollisions = function(node) { var self = this; this._sortNodes(-1); @@ -205,7 +205,8 @@ return; } - this.moveNode(collisionNode, collisionNode.x, node.y + node.height, collisionNode.width, collisionNode.height, true); + this.moveNode(collisionNode, collisionNode.x, node.y + node.height, + collisionNode.width, collisionNode.height, true); } }; @@ -368,7 +369,7 @@ return _.filter(this.nodes, function(n) { return n._dirty; }); }; - GridStackEngine.prototype.addNode = function(node, triggerAddEvent, isClone) { + GridStackEngine.prototype.addNode = function(node, triggerAddEvent) { node = this._prepareNode(node); if (typeof node.maxWidth != 'undefined') { node.width = Math.min(node.width, node.maxWidth); } @@ -401,7 +402,7 @@ this._addedNodes.push(_.clone(node)); } - this._fixCollisions(node, isClone); + this._fixCollisions(node); this._packNodes(); this._notify(); return node; @@ -449,7 +450,7 @@ return true; } - clone.moveNode(clonedNode, x, y, width, height, false, true); + clone.moveNode(clonedNode, x, y, width, height); var res = true; @@ -481,7 +482,7 @@ this.float, 0, _.map(this.nodes, function(n) { return $.extend({}, n); })); - clone.addNode(node, false, true); + clone.addNode(node); return clone.getGridHeight() <= this.height; }; @@ -502,7 +503,7 @@ return true; }; - GridStackEngine.prototype.moveNode = function(node, x, y, width, height, noPack, isClone) { + GridStackEngine.prototype.moveNode = function(node, x, y, width, height, noPack) { if (!this.isNodeChangedPosition(node, x, y, width, height)) { return node; } @@ -539,7 +540,7 @@ node = this._prepareNode(node, resizing); - this._fixCollisions(node, isClone); + this._fixCollisions(node); if (!noPack) { this._packNodes(); this._notify(); From 951d8fb5e14fef887e05ada7dccf488395aa896f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Inga=20Br=C5=ABnava?= Date: Wed, 31 May 2017 07:35:36 +0200 Subject: [PATCH 35/35] No collision checking anymore --- src/gridstack.js | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/gridstack.js b/src/gridstack.js index 82bc1663c..15fd232e2 100644 --- a/src/gridstack.js +++ b/src/gridstack.js @@ -191,23 +191,23 @@ }; GridStackEngine.prototype._fixCollisions = function(node) { - var self = this; - this._sortNodes(-1); - - var nn = node; - var hasLocked = Boolean(_.find(this.nodes, function(n) { return n.locked; })); - if (!this.float && !hasLocked) { - nn = {x: 0, y: node.y, width: this.width, height: node.height}; - } - while (true) { - var collisionNode = _.find(this.nodes, _.bind(Utils._collisionNodeCheck, {node: node, nn: nn})); - if (typeof collisionNode == 'undefined') { - return; - } - - this.moveNode(collisionNode, collisionNode.x, node.y + node.height, - collisionNode.width, collisionNode.height, true); - } + // var self = this; + // this._sortNodes(-1); + + // var nn = node; + // var hasLocked = Boolean(_.find(this.nodes, function(n) { return n.locked; })); + // if (!this.float && !hasLocked) { + // nn = {x: 0, y: node.y, width: this.width, height: node.height}; + // } + // while (true) { + // var collisionNode = _.find(this.nodes, _.bind(Utils._collisionNodeCheck, {node: node, nn: nn})); + // if (typeof collisionNode == 'undefined') { + // return; + // } + + // this.moveNode(collisionNode, collisionNode.x, node.y + node.height, + // collisionNode.width, collisionNode.height, true); + // } }; GridStackEngine.prototype.whatIsHere = function(x, y, width, height) {