diff --git a/.jscsrc b/.jscsrc new file mode 100644 index 0000000..423b011 --- /dev/null +++ b/.jscsrc @@ -0,0 +1,14 @@ +{ + "preset": "google", + "validateIndentation": "\t", + "maximumLineLength": 120, + "jsDoc": { + "checkAnnotations": { + "preset": "jsdoc3", + "extra": { + "preserve": true + } + } + }, + "requireCamelCaseOrUpperCaseIdentifiers": true +} diff --git a/README.md b/README.md index 4bdc993..d76fd7d 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,7 @@ Join gridstack.js on Slack: https://gridstackjs.troolee.com - [Requirements](#requirements) - [Install](#install) - [Basic usage](#basic-usage) + - [Migrating to v0.2.5](#migrating-to-v025) - [Options](#options) - [Grid attributes](#grid-attributes) - [Item attributes](#item-attributes) @@ -31,30 +32,32 @@ Join gridstack.js on Slack: https://gridstackjs.troolee.com - [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) + - [addWidget(el, x, y, width, height, autoPosition)](#addwidgetel-x-y-width-height-autoposition) + - [batchUpdate()](#batchupdate) + - [cellHeight()](#cellheight) + - [cellHeight(val)](#cellheightval) + - [cellWidth()](#cellwidth) - [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) + - [getCellFromPixel(position)](#getcellfrompixelposition) + - [isAreaEmpty(x, y, width, height)](#isareaemptyx-y-width-height) - [locked(el, val)](#lockedel-val) - - [min_width(el, val)](#min_widthel-val) - - [min_height(el, val)](#min_heightel-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) - - [remove_widget(el, detach_node)](#remove_widgetel-detach_node) - - [remove_all()](#remove_all) + - [removeWidget(el, detachNode)](#removewidgetel-detachnode) + - [removeAll()](#removeall) - [resize(el, width, height)](#resizeel-width-height) - [resizable(el, val)](#resizableel-val) - - [set_static(static_value)](#set_staticstatic_value) + - [setStatic(static_value)](#setstaticstatic_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) + - [willItFit(x, y, width, height, autoPosition)](#willitfitx-y-width-height-autoposition) - [Utils](#utils) - [GridStackUI.Utils.sort(nodes[, dir[, width]])](#gridstackuiutilssortnodes-dir-width) - [Touch devices support](#touch-devices-support) @@ -96,7 +99,6 @@ Usage * [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 Note: You can still use [underscore.js](http://underscorejs.org) (>= 1.7.0) instead of lodash.js @@ -151,28 +153,34 @@ $(function () { ``` +## Migrating to v0.2.5 + +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. + ## Options -- `always_show_resize_handle` - if `true` the resizing handles are shown even if the user is not hovering over the widget +- `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`) -- `cell_height` - one cell height (default: `60`). Can be: +- `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 will have to be defined in CSS files. - `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`) +- `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) -- `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: `''`) +- `itemClass` - widget class (default: `'grid-stack-item'`) +- `minWidth` - 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`) +- `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'}`) -- `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`). Can be: +- `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`) @@ -204,12 +212,12 @@ to completely lock the widget. Occurs when adding/removing widgets or existing widgets change their position/size ```javascript -var serialize_widget_map = function (items) { +var serializeWidgetMap = function (items) { console.log(items); }; $('.grid-stack').on('change', function (e, items) { - serialize_widget_map(items); + serializeWidgetMap(items); }); ``` @@ -267,7 +275,7 @@ $('.grid-stack').on('enable', function(event) { ## API -### add_widget(el, x, y, width, height, auto_position) +### addWidget(el, x, y, width, height, autoPosition) Creates new widget and returns it. @@ -275,7 +283,7 @@ 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 +- `autoPosition` - 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 @@ -285,50 +293,33 @@ before calling `add_widget` for additional check. $('.grid-stack').gridstack(); var grid = $('.grid-stack').data('gridstack'); -grid.add_widget(el, 0, 0, 3, 2, true); +grid.addWidget(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() +### batchUpdate() Initailizes batch updates. You will see no changes until `commit` method is called. -### cell_height() +### cellHeight() Gets current cell height. -### cell_height(val) +### 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.cell_height(grid.cell_width() * 1.2); +grid.cellHeight(grid.cellWidth() * 1.2); ``` -### cell_width() +### cellWidth() Gets current cell width. ### commit() -Finishes batch updates. Updates DOM nodes. You must call it after `batch_update`. +Finishes batch updates. Updates DOM nodes. You must call it after `batchUpdate`. ### destroy() @@ -352,7 +343,7 @@ grid.movable('.grid-stack-item', true); grid.resizable('.grid-stack-item', true); ``` -### get_cell_from_pixel(position) +### getCellFromPixel(position) Get the position of the cell under a pixel on screen. @@ -362,7 +353,7 @@ Parameters : Returns an object with properties `x` and `y` i.e. the column and row in the grid. -### is_area_empty(x, y, width, height) +### isAreaEmpty(x, y, width, height) Checks if specified area is empty. @@ -373,19 +364,50 @@ Locks/unlocks widget. - `el` - widget to modify. - `val` - if `true` widget will be locked. -### min_width(el, val) +### makeWidget(el) -Set the minWidth for a widget. +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.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 -### min_height(el, val) +### minWidth(el, val) -Set the minHeight for a widget. +Set the `minWidth` for a widget. - `el` - widget to modify. -- `val` - A numeric value of the number of rows +- `val` - A numeric value of the number of columns ### movable(el, val) @@ -403,16 +425,16 @@ Parameters: - `el` - widget to move - `x`, `y` - new position. If value is `null` or `undefined` it will be ignored. -### remove_widget(el, detach_node) +### removeWidget(el, detachNode) 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`). +- `detachNode` - if `false` DOM node won't be removed from the tree (Optional. Default `true`). -### remove_all() +### removeAll() Removes all widgets from the grid. @@ -432,7 +454,7 @@ Enables/Disables resizing. - `el` - widget to modify - `val` - if `true` widget will be resizable. -### set_static(static_value) +### setStatic(static_value) Toggle the grid static state. Also toggle the `grid-stack-static` class. @@ -448,14 +470,14 @@ Parameters: Updates widget position/size. -### will_it_fit(x, y, width, height, auto_position) +### 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.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); +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'); @@ -487,7 +509,7 @@ working on touch-based devices. ``` -Also `always_show_resize_handle` option may be useful: +Also `alwaysShowResizeHandle` option may be useful: ```javascript $(function () { @@ -517,9 +539,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); }); }; }; @@ -695,10 +717,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); }); ``` @@ -780,7 +802,9 @@ Changes #### v0.2.5-dev (Development version) -- `cell_height` and `vertical_margin` can now be string (e.g. '3em', '20px') (Thanks to @jlowcs) +- 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. #### v0.2.4 (2016-02-15) diff --git a/demo/float.html b/demo/float.html index 638ec2a..fe5bc7c 100644 --- a/demo/float.html +++ b/demo/float.html @@ -68,18 +68,19 @@ this.grid = $('.grid-stack').data('gridstack'); - this.add_new_widget = function () { + this.addNewWidget = function () { var node = this.items.pop() || { x: 12 * Math.random(), y: 5 * Math.random(), width: 1 + 3 * Math.random(), height: 1 + 3 * Math.random() }; - this.grid.add_widget($('
'), + this.grid.addWidget($('
'), node.x, node.y, node.width, node.height); + return false; }.bind(this); - $('#add-new-widget').click(this.add_new_widget); + $('#add-new-widget').click(this.addNewWidget); }; }); diff --git a/demo/knockout.html b/demo/knockout.html index 2a7a360..dd16b3e 100644 --- a/demo/knockout.html +++ b/demo/knockout.html @@ -38,7 +38,7 @@

knockout.js Demo

- +

@@ -64,9 +64,9 @@ } 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); }); }; }; @@ -78,7 +78,7 @@ [ '
', '
', - '
', + '
', '
', '
' ].join('') @@ -90,7 +90,7 @@ this.widgets = ko.observableArray(widgets); - this.add_new_widget = function () { + this.addNewWidget = function () { this.widgets.push({ x: 0, y: 0, @@ -98,10 +98,12 @@ height: Math.floor(1 + 3 * Math.random()), auto_position: true }); + return false; }; - this.delete_widget = function (item) { + this.deleteWidget = function (item) { self.widgets.remove(item); + return false; }; }; diff --git a/demo/knockout2.html b/demo/knockout2.html index af558ec..96d2819 100644 --- a/demo/knockout2.html +++ b/demo/knockout2.html @@ -38,7 +38,7 @@

knockout.js Demo

- +

@@ -64,9 +64,9 @@ } 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); }); }; }; @@ -83,7 +83,7 @@ this.widgets = ko.observableArray(widgets); - this.add_new_widget = function () { + this.addNewWidget = function () { this.widgets.push({ x: 0, y: 0, @@ -91,10 +91,12 @@ height: Math.floor(1 + 3 * Math.random()), auto_position: true }); + return false; }; - this.delete_widget = function (item) { + this.deleteWidget = function (item) { self.widgets.remove(item); + return false; }; }; @@ -113,7 +115,7 @@ diff --git a/demo/serialization.html b/demo/serialization.html index 06ddbc6..b8484ea 100644 --- a/demo/serialization.html +++ b/demo/serialization.html @@ -56,12 +56,11 @@ diff --git a/demo/two.html b/demo/two.html index a9f64f7..7219455 100644 --- a/demo/two.html +++ b/demo/two.html @@ -75,7 +75,7 @@ var grid = $(this).data('gridstack'); _.each(items, function (node) { - grid.add_widget($('
'), + grid.addWidget($('
'), node.x, node.y, node.width, node.height); }, this); }); diff --git a/dist/gridstack.js b/dist/gridstack.js index 36689a4..73bdd28 100644 --- a/dist/gridstack.js +++ b/dist/gridstack.js @@ -9,21 +9,35 @@ 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 { + } 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); }, @@ -33,170 +47,192 @@ 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); 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-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); + }, + + _didCollideFloat: function(bn) { + return this.n != bn && + Utils.isIntercepted({x: this.n.x, y: this.newY, width: this.n.width, height: this.n.height}, bn); + }, + + _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); } }; - var id_seq = 0; + // jscs:disable requireCamelCaseOrUpperCaseIdentifiers + Utils.is_intercepted = obsolete(Utils.isIntercepted, 'is_intercepted', 'isIntercepted'); - var GridStackEngine = function(width, onchange, float_mode, height, items) { + 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 + + 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; }; - 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) { + this._updateCounter = 0; + if (this._updateCounter === 0) { this.float = this._float; - this._pack_nodes(); + this._packNodes(); this._notify(); } }; - GridStackEngine.prototype._fix_collisions = function(node) { - this._sort_nodes(-1); + 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.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; }; - 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; } @@ -211,8 +247,7 @@ if (node.x + node.width > this.width) { if (resizing) { node.width = this.width - node.x; - } - else { + } else { node.x = this.width - node.width; } } @@ -225,44 +260,43 @@ }; GridStackEngine.prototype._notify = function() { - if (this._update_counter) { + 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 = Array.prototype.slice.call(arguments, 1).concat(this.getDirtyNodes()); + deletedNodes = deletedNodes.concat(this.getDirtyNodes()); + this.onchange(deletedNodes); }; - GridStackEngine.prototype.clean_nodes = function() { - _.each(this.nodes, function(n) {n._dirty = false }); + GridStackEngine.prototype.cleanNodes = function() { + _.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) { + 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; @@ -272,26 +306,27 @@ this.nodes.push(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) { node._id = null; this.nodes = _.without(this.nodes, node); - this._pack_nodes(); + this._packNodes(); this._notify(node); }; - 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) { + 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, @@ -299,50 +334,53 @@ 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); + 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.moveNode = function(node, x, y, width, height, noPack) { + 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; @@ -356,30 +394,30 @@ node.width = width; node.height = height; - node = this._prepare_node(node, resizing); + 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) { @@ -388,79 +426,128 @@ }; var GridStack = function(el, opts) { - var self = this, one_column_mode; + var self = this; + var oneColumnMode; 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.item_class !== 'undefined') { + opts.itemClass = opts.item_class; + obsoleteOpts('item_class', 'itemClass'); + } + 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).size() > 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' }) }); - this.opts.is_nested = is_nested; + this.opts.isNested = isNested; - this.cell_height(this.opts.cell_height, true); - this.vertical_margin(this.opts.vertical_margin, true); + 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; + var maxHeight = 0; _.each(nodes, function(n) { - if (n._id == null) { + if (n._id === null) { n.el.remove(); - } - else { + } 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, @@ -468,67 +555,68 @@ }); }); _.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._update_container_height(); + this._updateContainerHeight(); - this.on_resize_handler = function() { - if (self._is_one_column_mode()) { - if (one_column_mode) + this.onResizeHandler = function() { + if (self._isOneColumnMode()) { + if (oneColumnMode) { return; + } - one_column_mode = true; + oneColumnMode = true; - self.grid._sort_nodes(); + 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) { + if (!node.noMove) { node.el.draggable('disable'); } - if (!node.no_resize) { + if (!node.noResize) { node.el.resizable('disable'); } }); - } - else { - if (!one_column_mode) + } else { + if (!oneColumnMode) { return; + } - one_column_mode = false; + oneColumnMode = false; - if (self.opts.static_grid) { + if (self.opts.staticGrid) { return; } _.each(self.grid.nodes, function(node) { - if (!node.no_move) { + if (!node.noMove) { node.el.draggable('enable'); } - if (!node.no_resize) { + if (!node.noResize) { node.el.resizable('enable'); } }); } }; - $(window).resize(this.on_resize_handler); - this.on_resize_handler(); + $(window).resize(this.onResizeHandler); + this.onResizeHandler(); }; - 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 = []; @@ -542,162 +630,165 @@ } }; - GridStack.prototype._init_styles = function() { - if (!this.opts.cell_height) { //that will be handled by CSS + GridStack.prototype._initStyles = function() { + if (!this.opts.cellHeight) { //that will be handled by CSS return ; } - if (this._styles_id) { - $('[data-gs-id="' + this._styles_id + '"]').remove(); + if (this._stylesId) { + $('[data-gs-id="' + this._stylesId + '"]').remove(); } - this._styles_id = 'gridstack-style-' + (Math.random() * 100000).toFixed(); - this._styles = Utils.create_stylesheet(this._styles_id); - if (this._styles != null) + 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) { return; } - var prefix = '.' + this.opts._class + ' .' + this.opts.item_class, - self = this, - get_height - ; + var prefix = '.' + this.opts._class + ' .' + this.opts.itemClass; + var self = this; + var getHeight; - if (typeof max_height == 'undefined') { - max_height = this._styles._max; - this._init_styles(); - this._update_container_height(); + if (typeof maxHeight == 'undefined') { + maxHeight = this._styles._max; + this._initStyles(); + this._updateContainerHeight(); } - - if (!this.opts.cell_height) { //the rest will be handled by CSS + if (!this.opts.cellHeight) { //the rest will be handled by CSS return ; } - if (this._styles._max !== 0 && max_height <= this._styles._max) { + if (this._styles._max !== 0 && maxHeight <= this._styles._max) { return ; } - if (!this.opts.vertical_margin || this.opts.cell_height_unit === this.opts.vertical_margin_unit) { - get_height = function (nbRows, nbMargins) { - return (self.opts.cell_height * nbRows + self.opts.vertical_margin * nbMargins) + self.opts.cell_height_unit; - } + 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 { - get_height = function (nbRows, nbMargins) { + getHeight = function(nbRows, nbMargins) { if (!nbRows || !nbMargins) { - return (self.opts.cell_height * nbRows + self.opts.vertical_margin * nbMargins) + self.opts.cell_height_unit; + return (self.opts.cellHeight * nbRows + self.opts.verticalMargin * nbMargins) + self.opts.cellHeightUnit; } - return 'calc(' + ((self.opts.cell_height * nbRows) + self.opts.cell_height_unit) + ' + ' + ((self.opts.vertical_margin * nbMargins) + self.opts.vertical_margin_unit) + ')'; - } + 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: ' + get_height(1, 0) + ';', 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: ' + get_height(i + 1, i) + ';', + '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: ' + get_height(i + 1, i) + ';', + '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: ' + get_height(i + 1, i) + ';', + 'max-height: ' + getHeight(i + 1, i) + ';', i ); - Utils.insert_css_rule(this._styles, + Utils.insertCSSRule(this._styles, prefix + '[data-gs-y="' + i + '"]', - 'top: ' + get_height(i, i) + ';', + '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; } - var height = this.grid.get_grid_height(); + var height = this.grid.getGridHeight(); this.container.attr('data-gs-current-height', height); - if (!this.opts.cell_height) { + if (!this.opts.cellHeight) { return ; } - if (!this.opts.vertical_margin) { - this.container.css('height', (height * (this.opts.cell_height)) + this.opts.cell_height_unit); - } else if (this.opts.cell_height_unit === this.opts.vertical_margin_unit) { - this.container.css('height', (height * (this.opts.cell_height + this.opts.vertical_margin) - this.opts.vertical_margin) + this.opts.cell_height_unit); + 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.cell_height)) + this.opts.cell_height_unit) + ' + ' + ((height * (this.opts.vertical_margin - 1)) + this.opts.vertical_margin_unit) + ')'); + 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._prepareElement = function(el) { var self = this; el = $(el); - el.addClass(this.opts.item_class); - - var node = self.grid.add_node({ + 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'), - 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')), + 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 }); el.data('_gridstack_node', node); - if (self.opts.static_grid) { + if (self.opts.staticGrid) { return; } - 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 (!self.grid.canMoveNode(node, x, y, width, height)) { return; } - self.grid.move_node(node, x, y, width, height); - self._update_container_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 = Math.ceil(o.outerWidth() / o.attr('data-gs-width')); - var strict_cell_height = Math.ceil(o.outerHeight() / o.attr('data-gs-height')); - cell_height = self.container.height() / parseInt(self.container.attr('data-gs-current-height')); + self.grid.cleanNodes(); + self.grid.beginUpdate(node); + cellWidth = Math.ceil(o.outerWidth() / o.attr('data-gs-width')); + 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')) @@ -706,15 +797,15 @@ .show(); node.el = self.placeholder; - el.resizable('option', 'minWidth', cell_width * (node.min_width || 1)); - el.resizable('option', 'minHeight', strict_cell_height * (node.min_height || 1)); + el.resizable('option', 'minWidth', cellWidth * (node.minWidth || 1)); + el.resizable('option', 'minHeight', strictCellHeight * (node.minHeight || 1)); if (event.type == 'resizestart') { o.find('.grid-stack-item').trigger('resizestart'); } }; - var on_end_moving = function(event, ui) { + var onEndMoving = function(event, ui) { self.placeholder.detach(); var o = $(this); node.el = o; @@ -725,15 +816,15 @@ .attr('data-gs-width', node.width) .attr('data-gs-height', node.height) .removeAttr('style'); - self._update_container_height(); - self._trigger_change_event(); + self._updateContainerHeight(); + self._triggerChangeEvent(); - self.grid.end_update(); + self.grid.endUpdate(); - 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(); + 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'); } @@ -741,93 +832,94 @@ el .draggable(_.extend(this.opts.draggable, { - containment: this.opts.is_nested ? this.container.parent() : null, - start: on_start_moving, - stop: on_end_moving, - drag: drag_or_resize + containment: this.opts.isNested ? this.container.parent() : null, + start: onStartMoving, + stop: onEndMoving, + drag: dragOrResize })) .resizable(_.extend(this.opts.resizable, { - start: on_start_moving, - stop: on_end_moving, - resize: drag_or_resize + start: onStartMoving, + stop: onEndMoving, + resize: dragOrResize })); - if (node.no_move || this._is_one_column_mode()) { + if (node.noMove || this._isOneColumnMode()) { el.draggable('disable'); } - if (node.no_resize || this._is_one_column_mode()) { + if (node.noResize || this._isOneColumnMode()) { el.resizable('disable'); } el.attr('data-gs-locked', node.locked ? 'yes' : null); }; - GridStack.prototype.set_animation = function(enable) { + 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) { 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); } this.container.append(el); - this._prepare_element(el); - this._update_container_height(); - this._trigger_change_event(true); + this._prepareElement(el); + 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); + 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); + this.grid.removeNode(node); 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); }; - 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); + $(window).off('resize', this.onResizeHandler); this.disable(); this.container.remove(); - Utils.remove_stylesheet(this._styles_id); - if (this.grid) + Utils.removeStylesheet(this._stylesId); + if (this.grid) { this.grid = null; + } }; GridStack.prototype.resizable = function(el, val) { @@ -836,15 +928,14 @@ 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; } - node.no_resize = !(val || false); - if (node.no_resize || self._is_one_column_mode()) { + node.noResize = !(val || false); + if (node.noResize || self._isOneColumnMode()) { el.resizable('disable'); - } - else { + } else { el.resizable('enable'); } }); @@ -857,16 +948,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) { return; } - node.no_move = !(val || false); - if (node.no_move || self._is_one_column_mode()) { + node.noMove = !(val || false); + if (node.noMove || self._isOneColumnMode()) { el.draggable('disable'); el.removeClass('ui-draggable-handle'); - } - else { + } else { el.draggable('enable'); el.addClass('ui-draggable-handle'); } @@ -875,14 +965,14 @@ }; 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'); }; @@ -891,7 +981,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; } @@ -901,188 +991,302 @@ 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) { 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) { 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); }); }; function parseHeight(val) { var height = val; - var height_unit = 'px'; + var heightUnit = 'px'; if (height && _.isString(height)) { var match = height.match(/^([0-9]+)(px|em|rem)?$/); if (!match) { throw new Error('Invalid height'); } - height_unit = match[2]; + heightUnit = match[2]; height = parseInt(match[1]); } - return {height: height, unit: height_unit}; + return {height: height, unit: heightUnit}; } - GridStack.prototype.vertical_margin = function (val, noUpdate) { + GridStack.prototype.verticalMargin = function(val, noUpdate) { if (typeof val == 'undefined') { - return this.opts.vertical_margin; + return this.opts.verticalMargin; } var heightData = parseHeight(val); - if (this.opts.vertical_margin_unit === heightData.unit && this.opts.height === heightData.height) { + if (this.opts.verticalMarginUnit === heightData.unit && this.opts.height === heightData.height) { return ; } - this.opts.vertical_margin_unit = heightData.unit; - this.opts.vertical_margin = heightData.height; + this.opts.verticalMarginUnit = heightData.unit; + this.opts.verticalMargin = heightData.height; if (!noUpdate) { - this._update_styles(); + this._updateStyles(); } }; - GridStack.prototype.cell_height = function (val, noUpdate) { + GridStack.prototype.cellHeight = function(val, noUpdate) { if (typeof val == 'undefined') { - if (this.opts.cell_height) { - return this.opts.cell_height; + if (this.opts.cellHeight) { + return this.opts.cellHeight; } else { - var o = this.container.children('.' + this.opts.item_class).first(); + var o = this.container.children('.' + this.opts.itemClass).first(); return Math.ceil(o.outerHeight() / o.attr('data-gs-height')); } - } + } var heightData = parseHeight(val); - if (this.opts.cell_height_unit === heightData.height_unit && this.opts.height === heightData.height) { + if (this.opts.cellHeightUnit === heightData.heightUnit && this.opts.height === heightData.height) { return ; } - this.opts.cell_height_unit = heightData.unit; - this.opts.cell_height = heightData.height; + this.opts.cellHeightUnit = heightData.unit; + this.opts.cellHeight = heightData.height; if (!noUpdate) { - this._update_styles(); + this._updateStyles(); } + }; - GridStack.prototype.cell_width = function() { - var o = this.container.children('.' + this.opts.item_class).first(); + GridStack.prototype.cellWidth = function() { + var o = this.container.children('.' + this.opts.itemClass).first(); return Math.ceil(o.outerWidth() / o.attr('data-gs-width')); }; - GridStack.prototype.get_cell_from_pixel = function(position) { + GridStack.prototype.getCellFromPixel = function(position) { var containerPos = 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 = Math.floor(this.container.height() / parseInt(this.container.attr('data-gs-current-height'))); + 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._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); } }; + // 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; diff --git a/dist/gridstack.min.js b/dist/gridstack.min.js index df10912..7c982de 100644 --- a/dist/gridstack.min.js +++ b/dist/gridstack.min.js @@ -5,5 +5,12 @@ * gridstack.js may be freely distributed under the MIT license. * @preserve */ -!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){var c=a,d="px";if(c&&b.isString(c)){var e=c.match(/^([0-9]+)(px|em|rem)?$/);if(!e)throw new Error("Invalid height");d=e[2],c=parseInt(e[1])}return{height:c,unit:d}}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.cell_height(this.opts.cell_height,!0),this.vertical_margin(this.opts.vertical_margin,!0),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._update_container_height(),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.opts.cell_height&&(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,c="."+this.opts._class+" ."+this.opts.item_class,d=this;if("undefined"==typeof a&&(a=this._styles._max,this._init_styles(),this._update_container_height()),this.opts.cell_height&&!(0!==this._styles._max&&a<=this._styles._max)&&(b=this.opts.vertical_margin&&this.opts.cell_height_unit!==this.opts.vertical_margin_unit?function(a,b){return a&&b?"calc("+(d.opts.cell_height*a+d.opts.cell_height_unit)+" + "+(d.opts.vertical_margin*b+d.opts.vertical_margin_unit)+")":d.opts.cell_height*a+d.opts.vertical_margin*b+d.opts.cell_height_unit}:function(a,b){return d.opts.cell_height*a+d.opts.vertical_margin*b+d.opts.cell_height_unit},0==this._styles._max&&e.insert_css_rule(this._styles,c,"min-height: "+b(1,0)+";",0),a>this._styles._max)){for(var f=this._styles._max;a>f;++f)e.insert_css_rule(this._styles,c+'[data-gs-height="'+(f+1)+'"]',"height: "+b(f+1,f)+";",f),e.insert_css_rule(this._styles,c+'[data-gs-min-height="'+(f+1)+'"]',"min-height: "+b(f+1,f)+";",f),e.insert_css_rule(this._styles,c+'[data-gs-max-height="'+(f+1)+'"]',"max-height: "+b(f+1,f)+";",f),e.insert_css_rule(this._styles,c+'[data-gs-y="'+f+'"]',"top: "+b(f,f)+";",f);this._styles._max=a}}},h.prototype._update_container_height=function(){if(!this.grid._update_counter){var a=this.grid.get_grid_height();this.container.attr("data-gs-current-height",a),this.opts.cell_height&&(this.opts.vertical_margin?this.opts.cell_height_unit===this.opts.vertical_margin_unit?this.container.css("height",a*(this.opts.cell_height+this.opts.vertical_margin)-this.opts.vertical_margin+this.opts.cell_height_unit):this.container.css("height","calc("+(a*this.opts.cell_height+this.opts.cell_height_unit)+" + "+(a*(this.opts.vertical_margin-1)+this.opts.vertical_margin_unit)+")"):this.container.css("height",a*this.opts.cell_height+this.opts.cell_height_unit))}},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=Math.ceil(i.outerWidth()/i.attr("data-gs-width"));var j=Math.ceil(i.outerHeight()/i.attr("data-gs-height"));h=d.container.height()/parseInt(d.container.attr("data-gs-current-height")),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",g*(f.min_width||1)),c.resizable("option","minHeight",j*(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,start:j,stop:k,drag:i})).resizable(b.extend(this.opts.resizable,{start:j,stop:k,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.vertical_margin=function(a,b){if("undefined"==typeof a)return this.opts.vertical_margin;var d=c(a);(this.opts.vertical_margin_unit!==d.unit||this.opts.height!==d.height)&&(this.opts.vertical_margin_unit=d.unit,this.opts.vertical_margin=d.height,b||this._update_styles())},h.prototype.cell_height=function(a,b){if("undefined"==typeof a){if(this.opts.cell_height)return this.opts.cell_height;var d=this.container.children("."+this.opts.item_class).first();return Math.ceil(d.outerHeight()/d.attr("data-gs-height"))}var e=c(a);(this.opts.cell_height_unit!==e.height_unit||this.opts.height!==e.height)&&(this.opts.cell_height_unit=e.unit,this.opts.cell_height=e.height,b||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=Math.floor(this.container.height()/parseInt(this.container.attr("data-gs-current-height")));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 c=a(this);c.data("gridstack")||c.data("gridstack",new h(this,b))})},d.GridStackUI}); +!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){var c=a,d="px";if(c&&b.isString(c)){var e=c.match(/^([0-9]+)(px|em|rem)?$/);if(!e)throw new Error("Invalid height");d=e[2],c=parseInt(e[1])}return{height:c,unit:d}}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=-1!=c?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-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-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)},_didCollideFloat:function(a){return this.n!=a&&g.isIntercepted({x:this.n.x,y:this.newY,width:this.n.width,height:this.n.height},a)},_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)}}; +// 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"); +// jscs:enable requireCamelCaseOrUpperCaseIdentifiers +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"]};i.prototype.batchUpdate=function(){this._updateCounter=1,this["float"]=!0},i.prototype.commit=function(){this._updateCounter=0,0===this._updateCounter&&(this["float"]=this._float,this._packNodes(),this._notify())},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},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(){if(!this._updateCounter){var a=Array.prototype.slice.call(arguments,1).concat(this.getDirtyNodes());a=a.concat(this.getDirtyNodes()),this.onchange(a)}},i.prototype.cleanNodes=function(){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){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 c=0;;++c){var d=c%this.width,e=Math.floor(c/this.width);if(!(d+a.width>this.width||b.find(this.nodes,b.bind(g._isAddNodeIntercepted,{x:d,y:e,node:a})))){a.x=d,a.y=e;break}}}return this.nodes.push(a),this._fixCollisions(a),this._packNodes(),this._notify(),a},i.prototype.removeNode=function(a){a._id=null,this.nodes=b.without(this.nodes,a),this._packNodes(),this._notify(a)},i.prototype.canMoveNode=function(c,d,e,f,g){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)}));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.moveNode=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.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=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(c,d){var e,g=this;d=d||{},this.container=a(c),"undefined"!=typeof d.handle_class&&(d.handleClass=d.handle_class,f("handle_class","handleClass")),"undefined"!=typeof d.item_class&&(d.itemClass=d.item_class,f("item_class","itemClass")),"undefined"!=typeof d.placeholder_class&&(d.placeholderClass=d.placeholder_class,f("placeholder_class","placeholderClass")),"undefined"!=typeof d.placeholder_text&&(d.placeholderText=d.placeholder_text,f("placeholder_text","placeholderText")),"undefined"!=typeof d.item_class&&(d.itemClass=d.item_class,f("item_class","itemClass")),"undefined"!=typeof d.cell_height&&(d.cellHeight=d.cell_height,f("cell_height","cellHeight")),"undefined"!=typeof d.vertical_margin&&(d.verticalMargin=d.vertical_margin,f("vertical_margin","verticalMargin")),"undefined"!=typeof d.min_width&&(d.minWidth=d.min_width,f("min_width","minWidth")),"undefined"!=typeof d.static_grid&&(d.staticGrid=d.static_grid,f("static_grid","staticGrid")),"undefined"!=typeof d.is_nested&&(d.isNested=d.is_nested,f("is_nested","isNested")),"undefined"!=typeof d.always_show_resize_handle&&(d.alwaysShowResizeHandle=d.always_show_resize_handle,f("always_show_resize_handle","alwaysShowResizeHandle")),d.itemClass=d.itemClass||"grid-stack-item";var h=this.container.closest("."+d.itemClass).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,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:d.alwaysShowResizeHandle||!1,resizable:b.defaults(d.resizable||{},{autoHide:!d.alwaysShowResizeHandle,handles:"se"}),draggable:b.defaults(d.draggable||{},{handle:(d.handleClass?"."+d.handleClass:d.handle?d.handle:"")||".grid-stack-item-content",scroll:!1,appendTo:"body"})}),this.opts.isNested=h,this.cellHeight(this.opts.cellHeight,!0),this.verticalMargin(this.opts.verticalMargin,!0),this.container.addClass(this.opts._class),this._setStaticClass(),h&&this.container.addClass("grid-stack-nested"),this._initStyles(),this.grid=new i(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))}),g._updateStyles(c+10)},this.opts["float"],this.opts.height),this.opts.auto){var j=[],k=this;this.container.children("."+this.opts.itemClass+":not(."+this.opts.placeholderClass+")").each(function(b,c){c=a(c),j.push({el:c,i:parseInt(c.attr("data-gs-x"))+parseInt(c.attr("data-gs-y"))*k.opts.width})}),b.chain(j).sortBy(function(a){return a.i}).each(function(a){g._prepareElement(a.el)}).value()}this.setAnimation(this.opts.animate),this.placeholder=a('
'+this.opts.placeholderText+"
").hide(),this._updateContainerHeight(),this.onResizeHandler=function(){if(g._isOneColumnMode()){if(e)return;e=!0,g.grid._sortNodes(),b.each(g.grid.nodes,function(a){g.container.append(a.el),g.opts.staticGrid||(a.noMove||a.el.draggable("disable"),a.noResize||a.el.resizable("disable"))})}else{if(!e)return;if(e=!1,g.opts.staticGrid)return;b.each(g.grid.nodes,function(a){a.noMove||a.el.draggable("enable"),a.noResize||a.el.resizable("enable")})}},a(window).resize(this.onResizeHandler),this.onResizeHandler()}; +// 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._initStyles=function(){this.opts.cellHeight&&(this._stylesId&&a('[data-gs-id="'+this._stylesId+'"]').remove(),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){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;a>e;++e)g.insertCSSRule(this._styles,c+'[data-gs-height="'+(e+1)+'"]',"height: "+b(e+1,e)+";",e),g.insertCSSRule(this._styles,c+'[data-gs-min-height="'+(e+1)+'"]',"min-height: "+b(e+1,e)+";",e),g.insertCSSRule(this._styles,c+'[data-gs-max-height="'+(e+1)+'"]',"max-height: "+b(e+1,e)+";",e),g.insertCSSRule(this._styles,c+'[data-gs-y="'+e+'"]',"top: "+b(e,e)+";",e);this._styles._max=a}}},j.prototype._updateContainerHeight=function(){if(!this.grid._updateCounter){var a=this.grid.getGridHeight();this.container.attr("data-gs-current-height",a),this.opts.cellHeight&&(this.opts.verticalMargin?this.opts.cellHeightUnit===this.opts.verticalMarginUnit?this.container.css("height",a*(this.opts.cellHeight+this.opts.verticalMargin)-this.opts.verticalMargin+this.opts.cellHeightUnit):this.container.css("height","calc("+(a*this.opts.cellHeight+this.opts.cellHeightUnit)+" + "+(a*(this.opts.verticalMargin-1)+this.opts.verticalMarginUnit)+")"):this.container.css("height",a*this.opts.cellHeight+this.opts.cellHeightUnit))}},j.prototype._isOneColumnMode=function(){return(window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth)<=this.opts.minWidth},j.prototype._prepareElement=function(c){var d=this;c=a(c),c.addClass(this.opts.itemClass);var e=d.grid.addNode({x:c.attr("data-gs-x"),y:c.attr("data-gs-y"),width:c.attr("data-gs-width"),height:c.attr("data-gs-height"),maxWidth:c.attr("data-gs-max-width"),minWidth:c.attr("data-gs-min-width"),maxHeight:c.attr("data-gs-max-height"),minHeight:c.attr("data-gs-min-height"),autoPosition:g.toBool(c.attr("data-gs-auto-position")),noResize:g.toBool(c.attr("data-gs-no-resize")),noMove:g.toBool(c.attr("data-gs-no-move")),locked:g.toBool(c.attr("data-gs-locked")),el:c});if(c.data("_gridstack_node",e),!d.opts.staticGrid){var f,h,i=function(a,b){var c,g,i=Math.round(b.position.left/f),j=Math.floor((b.position.top+h/2)/h);"drag"!=a.type&&(c=Math.round(b.size.width/f),g=Math.round(b.size.height/h)),d.grid.canMoveNode(e,i,j,c,g)&&(d.grid.moveNode(e,i,j,c,g),d._updateContainerHeight())},j=function(b,g){d.container.append(d.placeholder);var i=a(this);d.grid.cleanNodes(),d.grid.beginUpdate(e),f=Math.ceil(i.outerWidth()/i.attr("data-gs-width"));var j=Math.ceil(i.outerHeight()/i.attr("data-gs-height"));h=d.container.height()/parseInt(d.container.attr("data-gs-current-height")),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(),e.el=d.placeholder,c.resizable("option","minWidth",f*(e.minWidth||1)),c.resizable("option","minHeight",j*(e.minHeight||1)),"resizestart"==b.type&&i.find(".grid-stack-item").trigger("resizestart")},k=function(b,c){d.placeholder.detach();var f=a(this);e.el=f,d.placeholder.hide(),f.attr("data-gs-x",e.x).attr("data-gs-y",e.y).attr("data-gs-width",e.width).attr("data-gs-height",e.height).removeAttr("style"),d._updateContainerHeight(),d._triggerChangeEvent(),d.grid.endUpdate();var g=f.find(".grid-stack");g.length&&"resizestop"==b.type&&(g.each(function(b,c){a(c).data("gridstack").onResizeHandler()}),f.find(".grid-stack-item").trigger("resizestop"))};c.draggable(b.extend(this.opts.draggable,{containment:this.opts.isNested?this.container.parent():null,start:j,stop:k,drag:i})).resizable(b.extend(this.opts.resizable,{start:j,stop:k,resize:i})),(e.noMove||this._isOneColumnMode())&&c.draggable("disable"),(e.noResize||this._isOneColumnMode())&&c.resizable("disable"),c.attr("data-gs-locked",e.locked?"yes":null)}},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){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._prepareElement(b),this._updateContainerHeight(),this._triggerChangeEvent(!0),b},j.prototype.makeWidget=function(b){return b=a(b),this._prepareElement(b),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?!0:c,b=a(b);var d=b.data("_gridstack_node");this.grid.removeNode(d),b.removeData("_gridstack_node"),this._updateContainerHeight(),c&&b.remove(),this._triggerChangeEvent(!0)},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(){a(window).off("resize",this.onResizeHandler),this.disable(),this.container.remove(),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&&(f.noResize=!c,f.noResize||d._isOneColumnMode()?e.resizable("disable"):e.resizable("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&&(f.noMove=!c,f.noMove||d._isOneColumnMode()?(e.draggable("disable"),e.removeClass("ui-draggable-handle")):(e.draggable("enable"),e.addClass("ui-draggable-handle")))}),this},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 d=c(a);(this.opts.verticalMarginUnit!==d.unit||this.opts.height!==d.height)&&(this.opts.verticalMarginUnit=d.unit,this.opts.verticalMargin=d.height,b||this._updateStyles())},j.prototype.cellHeight=function(a,b){if("undefined"==typeof a){if(this.opts.cellHeight)return this.opts.cellHeight;var d=this.container.children("."+this.opts.itemClass).first();return Math.ceil(d.outerHeight()/d.attr("data-gs-height"))}var e=c(a);(this.opts.cellHeightUnit!==e.heightUnit||this.opts.height!==e.height)&&(this.opts.cellHeightUnit=e.unit,this.opts.cellHeight=e.height,b||this._updateStyles())},j.prototype.cellWidth=function(){var a=this.container.children("."+this.opts.itemClass).first();return Math.ceil(a.outerWidth()/a.attr("data-gs-width"))},j.prototype.getCellFromPixel=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=Math.floor(this.container.height()/parseInt(this.container.attr("data-gs-current-height")));return{x:Math.floor(c/e),y:Math.floor(d/f)}},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._setStaticClass()},j.prototype._setStaticClass=function(){var a="grid-stack-static";this.opts.staticGrid===!0?this.container.addClass(a):this.container.removeClass(a)},i.prototype.batch_update=e(i.prototype.batchUpdate),i.prototype._fix_collisions=e(i.prototype._fixCollisions,"_fix_collisions","_fixCollisions"),i.prototype.is_area_empty=e(i.prototype.isAreaEmpty,"is_area_empty","isAreaEmpty"),i.prototype._sort_nodes=e(i.prototype._sortNodes,"_sort_nodes","_sortNodes"),i.prototype._pack_nodes=e(i.prototype._packNodes,"_pack_nodes","_packNodes"),i.prototype._prepare_node=e(i.prototype._prepareNode,"_prepare_node","_prepareNode"),i.prototype.clean_nodes=e(i.prototype.cleanNodes,"clean_nodes","cleanNodes"),i.prototype.get_dirty_nodes=e(i.prototype.getDirtyNodes,"get_dirty_nodes","getDirtyNodes"),i.prototype.add_node=e(i.prototype.addNode,"add_node","addNode, "),i.prototype.remove_node=e(i.prototype.removeNode,"remove_node","removeNode"),i.prototype.can_move_node=e(i.prototype.canMoveNode,"can_move_node","canMoveNode"),i.prototype.move_node=e(i.prototype.moveNode,"move_node","moveNode"),i.prototype.get_grid_height=e(i.prototype.getGridHeight,"get_grid_height","getGridHeight"),i.prototype.begin_update=e(i.prototype.beginUpdate,"begin_update","beginUpdate"),i.prototype.end_update=e(i.prototype.endUpdate,"end_update","endUpdate"),i.prototype.can_be_placed_with_respect_to_height=e(i.prototype.canBePlacedWithRespectToHeight,"can_be_placed_with_respect_to_height","canBePlacedWithRespectToHeight"),j.prototype._trigger_change_event=e(j.prototype._triggerChangeEvent,"_trigger_change_event","_triggerChangeEvent"),j.prototype._init_styles=e(j.prototype._initStyles,"_init_styles","_initStyles"),j.prototype._update_styles=e(j.prototype._updateStyles,"_update_styles","_updateStyles"),j.prototype._update_container_height=e(j.prototype._updateContainerHeight,"_update_container_height","_updateContainerHeight"),j.prototype._is_one_column_mode=e(j.prototype._isOneColumnMode,"_is_one_column_mode"," _isOneColumnMode"),j.prototype._prepare_element=e(j.prototype._prepareElement,"_prepare_element","_prepareElement"),j.prototype.set_animation=e(j.prototype.setAnimation,"set_animation","setAnimation"),j.prototype.add_widget=e(j.prototype.addWidget,"add_widget","addWidget"),j.prototype.make_widget=e(j.prototype.makeWidget,"make_widget","makeWidget"),j.prototype.will_it_fit=e(j.prototype.willItFit,"will_it_fit","willItFit"),j.prototype.remove_widget=e(j.prototype.removeWidget,"remove_widget","removeWidget"),j.prototype.remove_all=e(j.prototype.removeAll,"remove_all","removeAll"),j.prototype.min_height=e(j.prototype.minHeight,"min_height","minHeight"),j.prototype.min_width=e(j.prototype.minWidth,"min_width","minWidth"),j.prototype._update_element=e(j.prototype._updateElement,"_update_element","_updateElement"),j.prototype.cell_height=e(j.prototype.cellHeight,"cell_height","cellHeight"),j.prototype.cell_width=e(j.prototype.cellWidth,"cell_width","cellWidth"),j.prototype.get_cell_from_pixel=e(j.prototype.getCellFromPixel,"get_cell_from_pixel","getCellFromPixel"),j.prototype.batch_update=e(j.prototype.batchUpdate,"batch_update","batchUpdate"),j.prototype.is_area_empty=e(j.prototype.isAreaEmpty,"is_area_empty","isAreaEmpty"),j.prototype.set_static=e(j.prototype.setStatic,"set_static","setStatic"),j.prototype._set_static_class=e(j.prototype._setStaticClass,"_set_static_class","_setStaticClass"),d.GridStackUI=j,d.GridStackUI.Utils=g,a.fn.gridstack=function(b){return this.each(function(){var c=a(this);c.data("gridstack")||c.data("gridstack",new j(this,b))})},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 44d7f2f..f2b6988 100644 --- a/dist/gridstack.min.map +++ b/dist/gridstack.min.map @@ -1 +1 @@ -{"version":3,"sources":["../src/gridstack.js"],"names":["factory","define","amd","exports","jQuery","require","e","_","$","parseHeight","val","height","height_unit","isString","match","Error","parseInt","unit","scope","window","Utils","is_intercepted","a","b","x","width","y","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","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","_update_container_height","on_resize_handler","_is_one_column_mode","append","resize","_trigger_change_event","forceTrigger","hasChanges","eventParams","length","trigger","_styles_id","_styles","_max","get_height","prefix","cell_height_unit","vertical_margin_unit","nbRows","nbMargins","css","innerWidth","documentElement","clientWidth","body","data","cell_width","drag_or_resize","event","ui","round","position","left","top","type","on_start_moving","o","ceil","outerWidth","strict_cell_height","outerHeight","show","on_end_moving","detach","removeAttr","nested_grids","containment","parent","start","stop","drag","enable","removeClass","add_widget","make_widget","will_it_fit","remove_widget","detach_node","removeData","remove_all","destroy","off","disable","movable","isNaN","_update_element","callback","first","move","update","noUpdate","heightData","get_cell_from_pixel","containerPos","relativeLeft","relativeTop","column_width","row_height","set_static","static_value","static_class_name","GridStackUI","fn","gridstack"],"mappings":";;;;;;;CAOA,SAAUA,GACN,GAAsB,kBAAXC,SAAyBA,OAAOC,IACvCD,QAAQ,SAAU,SAAU,iBAAkB,mBAAoB,kBAAmB,sBACjF,uBAAwBD,OAE3B,IAAuB,mBAAZG,SAAyB,CACvC,IAAMC,OAASC,QAAQ,UAAa,MAAMC,IAC1C,IAAMC,EAAIF,QAAQ,UAAa,MAAMC,IACrCN,EAAQI,OAAQG,OAGdP,GAAQI,OAAQG,IAErB,SAASC,EAAGD,GAs8BX,QAASE,GAAYC,GACjB,GAAIC,GAASD,EACTE,EAAc,IAClB,IAAID,GAAUJ,EAAEM,SAASF,GAAS,CAC9B,GAAIG,GAAQH,EAAOG,MAAM,yBACzB,KAAKA,EACD,KAAM,IAAIC,OAAM,iBAEpBH,GAAcE,EAAM,GACpBH,EAASK,SAASF,EAAM,IAE5B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axC,IAE1C2C,EAAe7I,KAAKM,MAAMlD,KAAKuE,UAAUhH,QAAUyC,KAAKoE,KAAK7G,OAC7DmO,EAAa9I,KAAKM,MAAMlD,KAAKuE,UAAU9H,SAAWK,SAASkD,KAAKuE,UAAUK,KAAK,2BAEnF,QAAQtH,EAAGsF,KAAKM,MAAMqI,EAAeE,GAAejO,EAAGoF,KAAKM,MAAMsI,EAAcE,KAGpFxH,EAAU/D,UAAUC,aAAe,WAC/BJ,KAAKoG,KAAKhG,gBAGd8D,EAAU/D,UAAUE,OAAS,WACzBL,KAAKoG,KAAK/F,SACVL,KAAK6G,4BAGT3C,EAAU/D,UAAUc,cAAgB,SAAS3D,EAAGE,EAAGD,EAAOd,GACtD,MAAOuD,MAAKoG,KAAKnF,cAAc3D,EAAGE,EAAGD,EAAOd,IAGhDyH,EAAU/D,UAAUwL,WAAa,SAASC,GACtC5L,KAAKoE,KAAKiB,YAAeuG,KAAiB,EAC1C5L,KAAKkG,qBAGThC,EAAU/D,UAAU+F,kBAAoB,WACpC,GAAI2F,GAAoB,mBAEpB7L,MAAKoE,KAAKiB,eAAgB,EAC1BrF,KAAKuE,UAAU0B,SAAS4F,GAExB7L,KAAKuE,UAAU0F,YAAY4B,IAInC7O,EAAM8O,YAAc5H,EAEpBlH,EAAM8O,YAAY5O,MAAQA,EAE1BZ,EAAEyP,GAAGC,UAAY,SAAS5H,GACtB,MAAOpE,MAAKkB,KAAK,WACb,GAAI+H,GAAI3M,EAAE0D,KACLiJ,GAAEX,KAAK,cACRW,EACKX,KAAK,YAAa,GAAIpE,GAAUlE,KAAMoE,OAKhDpH,EAAM8O","file":"gridstack.min.js"} \ No newline at end of file +{"version":3,"sources":["../src/gridstack.js"],"names":["factory","define","amd","exports","jQuery","require","e","_","$","parseHeight","val","height","heightUnit","isString","match","Error","parseInt","unit","scope","window","obsolete","f","oldName","newName","wrapper","console","warn","apply","this","arguments","prototype","obsoleteOpts","Utils","isIntercepted","a","b","x","width","y","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","_didCollideFloat","bn","newY","_didCollide","_isAddNodeIntercepted","is_intercepted","create_stylesheet","remove_stylesheet","insert_css_rule","idSeq","GridStackEngine","onchange","floatMode","items","_updateCounter","_float","batchUpdate","commit","_packNodes","_notify","_fixCollisions","_sortNodes","hasLocked","find","locked","collisionNode","bind","moveNode","isAreaEmpty","each","i","_updating","_origY","_dirty","canBeMoved","take","_prepareNode","resizing","defaults","autoPosition","noResize","noMove","deletedNodes","Array","slice","call","concat","getDirtyNodes","cleanNodes","filter","addNode","maxWidth","Math","min","maxHeight","minWidth","minHeight","_id","floor","push","removeNode","without","canMoveNode","clonedNode","clone","extend","res","getGridHeight","canBePlacedWithRespectToHeight","noPack","reduce","memo","beginUpdate","endUpdate","GridStack","el","opts","oneColumnMode","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","size","attr","handle","auto","float","_class","random","toFixed","animate","resizable","autoHide","handles","draggable","scroll","appendTo","addClass","_setStaticClass","_initStyles","grid","_updateStyles","elements","_this","children","_prepareElement","setAnimation","placeholder","hide","_updateContainerHeight","onResizeHandler","_isOneColumnMode","append","resize","_triggerChangeEvent","forceTrigger","hasChanges","eventParams","length","trigger","_stylesId","_styles","_max","getHeight","prefix","cellHeightUnit","verticalMarginUnit","nbRows","nbMargins","css","innerWidth","documentElement","clientWidth","body","data","cellWidth","dragOrResize","event","ui","round","position","left","top","type","onStartMoving","o","ceil","outerWidth","strictCellHeight","outerHeight","show","onEndMoving","detach","removeAttr","nestedGrids","containment","parent","start","stop","drag","enable","removeClass","addWidget","makeWidget","willItFit","removeWidget","detachNode","removeData","removeAll","destroy","off","disable","movable","isNaN","_updateElement","callback","first","move","update","noUpdate","heightData","getCellFromPixel","containerPos","relativeLeft","relativeTop","columnWidth","rowHeight","setStatic","staticValue","staticClassName","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","fn","gridstack"],"mappings":";;;;;;;CAOA,SAAUA,GACN,GAAsB,kBAAXC,SAAyBA,OAAOC,IACvCD,QAAQ,SAAU,SAAU,iBAAkB,mBAAoB,kBAAmB,sBACjF,uBAAwBD,OACzB,IAAuB,mBAAZG,SAAyB,CACvC,IAAMC,OAASC,QAAQ,UAAa,MAAOC,IAC3C,IAAMC,EAAIF,QAAQ,UAAa,MAAOC,IACtCN,EAAQI,OAAQG,OAEhBP,GAAQI,OAAQG,IAErB,SAASC,EAAGD,GAokCX,QAASE,GAAYC,GACjB,GAAIC,GAASD,EACTE,EAAa,IACjB,IAAID,GAAUJ,EAAEM,SAASF,GAAS,CAC9B,GAAIG,GAAQH,EAAOG,MAAM,yBACzB,KAAKA,EACD,KAAM,IAAIC,OAAM,iBAEpBH,GAAaE,EAAM,GACnBH,EAASK,SAASF,EAAM,IAE5B,OAAQH,OAAQA,EAAQM,KAAML,GA7kClC,GAAIM,GAAQC,OAERC,EAAW,SAASC,EAAGC,EAASC,GAChC,GAAIC,GAAU,WAGV,MAFAC,SAAQC,KAAK,2BAA6BJ,EAAU,4DAChDC,EAAU,iDACPF,EAAEM,MAAMC,KAAMC,WAIzB,OAFAL,GAAQM,UAAYT,EAAES,UAEfN,GAGPO,EAAe,SAAST,EAASC,GACj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BACrB7G,EAAUvH,UAAUwR,WAAalS,EAASiI,EAAUvH,UAAUuO,UAC1D,aAAc,aAClBhH,EAAUvH,UAAUyR,WAAanS,EAASiI,EAAUvH,UAAUqG,UAC1D,aAAc,aAClBkB,EAAUvH,UAAUyI,UAAYnJ,EAASiI,EAAUvH,UAAUoG,SACzD,YAAa,YACjBmB,EAAUvH,UAAU0R,gBAAkBpS,EAASiI,EAAUvH,UAAU6O,eAC/D,kBAAmB,kBACvBtH,EAAUvH,UAAUqI,YAAc/I,EAASiI,EAAUvH,UAAUsI,WAC3D,cAAe,cACnBf,EAAUvH,UAAU2R,WAAarS,EAASiI,EAAUvH,UAAUsM,UAC1D,aAAc,aAClB/E,EAAUvH,UAAU4R,oBAAsBtS,EAASiI,EAAUvH,UAAUoP,iBACnE,sBAAuB,oBAC3B7H,EAAUvH,UAAU6P,aAAevQ,EAASiI,EAAUvH,UAAU6D,YAC5D,eAAgB,eACpB0D,EAAUvH,UAAU+P,cAAgBzQ,EAASiI,EAAUvH,UAAUyE,YAC7D,gBAAiB,eACrB8C,EAAUvH,UAAU6R,WAAavS,EAASiI,EAAUvH,UAAU0P,UAC1D,aAAc,aAClBnI,EAAUvH,UAAU8R,kBAAoBxS,EAASiI,EAAUvH,UAAUiK,gBACjE,oBAAqB,mBAGzB7K,EAAM2S,YAAcxK,EAEpBnI,EAAM2S,YAAY7R,MAAQA,EAE1BxB,EAAEsT,GAAGC,UAAY,SAASxK,GACtB,MAAO3H,MAAK4E,KAAK,WACb,GAAIsI,GAAItO,EAAEoB,KACLkN,GAAEX,KAAK,cACRW,EACKX,KAAK,YAAa,GAAI9E,GAAUzH,KAAM2H,OAKhDrI,EAAM2S","file":"gridstack.min.js"} \ No newline at end of file diff --git a/src/gridstack.js b/src/gridstack.js index 36689a4..73bdd28 100644 --- a/src/gridstack.js +++ b/src/gridstack.js @@ -9,21 +9,35 @@ 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 { + } 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); }, @@ -33,170 +47,192 @@ 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); 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-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); + }, + + _didCollideFloat: function(bn) { + return this.n != bn && + Utils.isIntercepted({x: this.n.x, y: this.newY, width: this.n.width, height: this.n.height}, bn); + }, + + _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); } }; - var id_seq = 0; + // jscs:disable requireCamelCaseOrUpperCaseIdentifiers + Utils.is_intercepted = obsolete(Utils.isIntercepted, 'is_intercepted', 'isIntercepted'); - var GridStackEngine = function(width, onchange, float_mode, height, items) { + 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 + + 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; }; - 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) { + this._updateCounter = 0; + if (this._updateCounter === 0) { this.float = this._float; - this._pack_nodes(); + this._packNodes(); this._notify(); } }; - GridStackEngine.prototype._fix_collisions = function(node) { - this._sort_nodes(-1); + 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.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; }; - 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; } @@ -211,8 +247,7 @@ if (node.x + node.width > this.width) { if (resizing) { node.width = this.width - node.x; - } - else { + } else { node.x = this.width - node.width; } } @@ -225,44 +260,43 @@ }; GridStackEngine.prototype._notify = function() { - if (this._update_counter) { + 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 = Array.prototype.slice.call(arguments, 1).concat(this.getDirtyNodes()); + deletedNodes = deletedNodes.concat(this.getDirtyNodes()); + this.onchange(deletedNodes); }; - GridStackEngine.prototype.clean_nodes = function() { - _.each(this.nodes, function(n) {n._dirty = false }); + GridStackEngine.prototype.cleanNodes = function() { + _.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) { + 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; @@ -272,26 +306,27 @@ this.nodes.push(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) { node._id = null; this.nodes = _.without(this.nodes, node); - this._pack_nodes(); + this._packNodes(); this._notify(node); }; - 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) { + 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, @@ -299,50 +334,53 @@ 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); + 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.moveNode = function(node, x, y, width, height, noPack) { + 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; @@ -356,30 +394,30 @@ node.width = width; node.height = height; - node = this._prepare_node(node, resizing); + 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) { @@ -388,79 +426,128 @@ }; var GridStack = function(el, opts) { - var self = this, one_column_mode; + var self = this; + var oneColumnMode; 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.item_class !== 'undefined') { + opts.itemClass = opts.item_class; + obsoleteOpts('item_class', 'itemClass'); + } + 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).size() > 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' }) }); - this.opts.is_nested = is_nested; + this.opts.isNested = isNested; - this.cell_height(this.opts.cell_height, true); - this.vertical_margin(this.opts.vertical_margin, true); + 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; + var maxHeight = 0; _.each(nodes, function(n) { - if (n._id == null) { + if (n._id === null) { n.el.remove(); - } - else { + } 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, @@ -468,67 +555,68 @@ }); }); _.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._update_container_height(); + this._updateContainerHeight(); - this.on_resize_handler = function() { - if (self._is_one_column_mode()) { - if (one_column_mode) + this.onResizeHandler = function() { + if (self._isOneColumnMode()) { + if (oneColumnMode) { return; + } - one_column_mode = true; + oneColumnMode = true; - self.grid._sort_nodes(); + 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) { + if (!node.noMove) { node.el.draggable('disable'); } - if (!node.no_resize) { + if (!node.noResize) { node.el.resizable('disable'); } }); - } - else { - if (!one_column_mode) + } else { + if (!oneColumnMode) { return; + } - one_column_mode = false; + oneColumnMode = false; - if (self.opts.static_grid) { + if (self.opts.staticGrid) { return; } _.each(self.grid.nodes, function(node) { - if (!node.no_move) { + if (!node.noMove) { node.el.draggable('enable'); } - if (!node.no_resize) { + if (!node.noResize) { node.el.resizable('enable'); } }); } }; - $(window).resize(this.on_resize_handler); - this.on_resize_handler(); + $(window).resize(this.onResizeHandler); + this.onResizeHandler(); }; - 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 = []; @@ -542,162 +630,165 @@ } }; - GridStack.prototype._init_styles = function() { - if (!this.opts.cell_height) { //that will be handled by CSS + GridStack.prototype._initStyles = function() { + if (!this.opts.cellHeight) { //that will be handled by CSS return ; } - if (this._styles_id) { - $('[data-gs-id="' + this._styles_id + '"]').remove(); + if (this._stylesId) { + $('[data-gs-id="' + this._stylesId + '"]').remove(); } - this._styles_id = 'gridstack-style-' + (Math.random() * 100000).toFixed(); - this._styles = Utils.create_stylesheet(this._styles_id); - if (this._styles != null) + 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) { return; } - var prefix = '.' + this.opts._class + ' .' + this.opts.item_class, - self = this, - get_height - ; + var prefix = '.' + this.opts._class + ' .' + this.opts.itemClass; + var self = this; + var getHeight; - if (typeof max_height == 'undefined') { - max_height = this._styles._max; - this._init_styles(); - this._update_container_height(); + if (typeof maxHeight == 'undefined') { + maxHeight = this._styles._max; + this._initStyles(); + this._updateContainerHeight(); } - - if (!this.opts.cell_height) { //the rest will be handled by CSS + if (!this.opts.cellHeight) { //the rest will be handled by CSS return ; } - if (this._styles._max !== 0 && max_height <= this._styles._max) { + if (this._styles._max !== 0 && maxHeight <= this._styles._max) { return ; } - if (!this.opts.vertical_margin || this.opts.cell_height_unit === this.opts.vertical_margin_unit) { - get_height = function (nbRows, nbMargins) { - return (self.opts.cell_height * nbRows + self.opts.vertical_margin * nbMargins) + self.opts.cell_height_unit; - } + 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 { - get_height = function (nbRows, nbMargins) { + getHeight = function(nbRows, nbMargins) { if (!nbRows || !nbMargins) { - return (self.opts.cell_height * nbRows + self.opts.vertical_margin * nbMargins) + self.opts.cell_height_unit; + return (self.opts.cellHeight * nbRows + self.opts.verticalMargin * nbMargins) + self.opts.cellHeightUnit; } - return 'calc(' + ((self.opts.cell_height * nbRows) + self.opts.cell_height_unit) + ' + ' + ((self.opts.vertical_margin * nbMargins) + self.opts.vertical_margin_unit) + ')'; - } + 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: ' + get_height(1, 0) + ';', 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: ' + get_height(i + 1, i) + ';', + '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: ' + get_height(i + 1, i) + ';', + '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: ' + get_height(i + 1, i) + ';', + 'max-height: ' + getHeight(i + 1, i) + ';', i ); - Utils.insert_css_rule(this._styles, + Utils.insertCSSRule(this._styles, prefix + '[data-gs-y="' + i + '"]', - 'top: ' + get_height(i, i) + ';', + '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; } - var height = this.grid.get_grid_height(); + var height = this.grid.getGridHeight(); this.container.attr('data-gs-current-height', height); - if (!this.opts.cell_height) { + if (!this.opts.cellHeight) { return ; } - if (!this.opts.vertical_margin) { - this.container.css('height', (height * (this.opts.cell_height)) + this.opts.cell_height_unit); - } else if (this.opts.cell_height_unit === this.opts.vertical_margin_unit) { - this.container.css('height', (height * (this.opts.cell_height + this.opts.vertical_margin) - this.opts.vertical_margin) + this.opts.cell_height_unit); + 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.cell_height)) + this.opts.cell_height_unit) + ' + ' + ((height * (this.opts.vertical_margin - 1)) + this.opts.vertical_margin_unit) + ')'); + 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._prepareElement = function(el) { var self = this; el = $(el); - el.addClass(this.opts.item_class); - - var node = self.grid.add_node({ + 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'), - 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')), + 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 }); el.data('_gridstack_node', node); - if (self.opts.static_grid) { + if (self.opts.staticGrid) { return; } - 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 (!self.grid.canMoveNode(node, x, y, width, height)) { return; } - self.grid.move_node(node, x, y, width, height); - self._update_container_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 = Math.ceil(o.outerWidth() / o.attr('data-gs-width')); - var strict_cell_height = Math.ceil(o.outerHeight() / o.attr('data-gs-height')); - cell_height = self.container.height() / parseInt(self.container.attr('data-gs-current-height')); + self.grid.cleanNodes(); + self.grid.beginUpdate(node); + cellWidth = Math.ceil(o.outerWidth() / o.attr('data-gs-width')); + 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')) @@ -706,15 +797,15 @@ .show(); node.el = self.placeholder; - el.resizable('option', 'minWidth', cell_width * (node.min_width || 1)); - el.resizable('option', 'minHeight', strict_cell_height * (node.min_height || 1)); + el.resizable('option', 'minWidth', cellWidth * (node.minWidth || 1)); + el.resizable('option', 'minHeight', strictCellHeight * (node.minHeight || 1)); if (event.type == 'resizestart') { o.find('.grid-stack-item').trigger('resizestart'); } }; - var on_end_moving = function(event, ui) { + var onEndMoving = function(event, ui) { self.placeholder.detach(); var o = $(this); node.el = o; @@ -725,15 +816,15 @@ .attr('data-gs-width', node.width) .attr('data-gs-height', node.height) .removeAttr('style'); - self._update_container_height(); - self._trigger_change_event(); + self._updateContainerHeight(); + self._triggerChangeEvent(); - self.grid.end_update(); + self.grid.endUpdate(); - 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(); + 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'); } @@ -741,93 +832,94 @@ el .draggable(_.extend(this.opts.draggable, { - containment: this.opts.is_nested ? this.container.parent() : null, - start: on_start_moving, - stop: on_end_moving, - drag: drag_or_resize + containment: this.opts.isNested ? this.container.parent() : null, + start: onStartMoving, + stop: onEndMoving, + drag: dragOrResize })) .resizable(_.extend(this.opts.resizable, { - start: on_start_moving, - stop: on_end_moving, - resize: drag_or_resize + start: onStartMoving, + stop: onEndMoving, + resize: dragOrResize })); - if (node.no_move || this._is_one_column_mode()) { + if (node.noMove || this._isOneColumnMode()) { el.draggable('disable'); } - if (node.no_resize || this._is_one_column_mode()) { + if (node.noResize || this._isOneColumnMode()) { el.resizable('disable'); } el.attr('data-gs-locked', node.locked ? 'yes' : null); }; - GridStack.prototype.set_animation = function(enable) { + 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) { 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); } this.container.append(el); - this._prepare_element(el); - this._update_container_height(); - this._trigger_change_event(true); + this._prepareElement(el); + 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); + 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); + this.grid.removeNode(node); 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); }; - 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); + $(window).off('resize', this.onResizeHandler); this.disable(); this.container.remove(); - Utils.remove_stylesheet(this._styles_id); - if (this.grid) + Utils.removeStylesheet(this._stylesId); + if (this.grid) { this.grid = null; + } }; GridStack.prototype.resizable = function(el, val) { @@ -836,15 +928,14 @@ 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; } - node.no_resize = !(val || false); - if (node.no_resize || self._is_one_column_mode()) { + node.noResize = !(val || false); + if (node.noResize || self._isOneColumnMode()) { el.resizable('disable'); - } - else { + } else { el.resizable('enable'); } }); @@ -857,16 +948,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) { return; } - node.no_move = !(val || false); - if (node.no_move || self._is_one_column_mode()) { + node.noMove = !(val || false); + if (node.noMove || self._isOneColumnMode()) { el.draggable('disable'); el.removeClass('ui-draggable-handle'); - } - else { + } else { el.draggable('enable'); el.addClass('ui-draggable-handle'); } @@ -875,14 +965,14 @@ }; 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'); }; @@ -891,7 +981,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; } @@ -901,188 +991,302 @@ 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) { 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) { 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); }); }; function parseHeight(val) { var height = val; - var height_unit = 'px'; + var heightUnit = 'px'; if (height && _.isString(height)) { var match = height.match(/^([0-9]+)(px|em|rem)?$/); if (!match) { throw new Error('Invalid height'); } - height_unit = match[2]; + heightUnit = match[2]; height = parseInt(match[1]); } - return {height: height, unit: height_unit}; + return {height: height, unit: heightUnit}; } - GridStack.prototype.vertical_margin = function (val, noUpdate) { + GridStack.prototype.verticalMargin = function(val, noUpdate) { if (typeof val == 'undefined') { - return this.opts.vertical_margin; + return this.opts.verticalMargin; } var heightData = parseHeight(val); - if (this.opts.vertical_margin_unit === heightData.unit && this.opts.height === heightData.height) { + if (this.opts.verticalMarginUnit === heightData.unit && this.opts.height === heightData.height) { return ; } - this.opts.vertical_margin_unit = heightData.unit; - this.opts.vertical_margin = heightData.height; + this.opts.verticalMarginUnit = heightData.unit; + this.opts.verticalMargin = heightData.height; if (!noUpdate) { - this._update_styles(); + this._updateStyles(); } }; - GridStack.prototype.cell_height = function (val, noUpdate) { + GridStack.prototype.cellHeight = function(val, noUpdate) { if (typeof val == 'undefined') { - if (this.opts.cell_height) { - return this.opts.cell_height; + if (this.opts.cellHeight) { + return this.opts.cellHeight; } else { - var o = this.container.children('.' + this.opts.item_class).first(); + var o = this.container.children('.' + this.opts.itemClass).first(); return Math.ceil(o.outerHeight() / o.attr('data-gs-height')); } - } + } var heightData = parseHeight(val); - if (this.opts.cell_height_unit === heightData.height_unit && this.opts.height === heightData.height) { + if (this.opts.cellHeightUnit === heightData.heightUnit && this.opts.height === heightData.height) { return ; } - this.opts.cell_height_unit = heightData.unit; - this.opts.cell_height = heightData.height; + this.opts.cellHeightUnit = heightData.unit; + this.opts.cellHeight = heightData.height; if (!noUpdate) { - this._update_styles(); + this._updateStyles(); } + }; - GridStack.prototype.cell_width = function() { - var o = this.container.children('.' + this.opts.item_class).first(); + GridStack.prototype.cellWidth = function() { + var o = this.container.children('.' + this.opts.itemClass).first(); return Math.ceil(o.outerWidth() / o.attr('data-gs-width')); }; - GridStack.prototype.get_cell_from_pixel = function(position) { + GridStack.prototype.getCellFromPixel = function(position) { var containerPos = 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 = Math.floor(this.container.height() / parseInt(this.container.attr('data-gs-current-height'))); + 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._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); } }; + // 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;