|
1 | 1 | // gridstack.js 0.2.4-dev |
2 | 2 | // http://troolee.github.io/gridstack.js/ |
3 | | -// (c) 2014-2015 Pavel Reznikov |
| 3 | +// (c) 2014-2016 Pavel Reznikov |
4 | 4 | // gridstack.js may be freely distributed under the MIT license. |
5 | 5 |
|
6 | 6 | (function(factory) { |
7 | 7 | if (typeof define === 'function' && define.amd) { |
8 | 8 | define(['jquery', 'lodash', 'jquery-ui/core', 'jquery-ui/widget', 'jquery-ui/mouse', 'jquery-ui/draggable', |
9 | 9 | 'jquery-ui/resizable'], factory); |
10 | 10 | } |
| 11 | + else if (typeof exports !== 'undefined') { |
| 12 | + try { jQuery = require('jquery'); } catch(e) {} |
| 13 | + try { _ = require('lodash'); } catch(e) {} |
| 14 | + factory(jQuery, _); |
| 15 | + } |
11 | 16 | else { |
12 | 17 | factory(jQuery, _); |
13 | 18 | } |
|
99 | 104 | } |
100 | 105 |
|
101 | 106 | while (true) { |
102 | | - var collision_node = _.find(this.nodes, function(n) { |
| 107 | + var collision_node = _.find(this.nodes, _.bind(function(n) { |
103 | 108 | return n != node && Utils.is_intercepted(n, nn); |
104 | | - }, this); |
| 109 | + }, this)); |
105 | 110 | if (typeof collision_node == 'undefined') { |
106 | 111 | return; |
107 | 112 | } |
|
112 | 117 |
|
113 | 118 | GridStackEngine.prototype.is_area_empty = function(x, y, width, height) { |
114 | 119 | var nn = {x: x || 0, y: y || 0, width: width || 1, height: height || 1}; |
115 | | - var collision_node = _.find(this.nodes, function(n) { |
| 120 | + var collision_node = _.find(this.nodes, _.bind(function(n) { |
116 | 121 | return Utils.is_intercepted(n, nn); |
117 | | - }, this); |
| 122 | + }, this)); |
118 | 123 | return collision_node == null; |
119 | 124 | }; |
120 | 125 |
|
|
126 | 131 | this._sort_nodes(); |
127 | 132 |
|
128 | 133 | if (this.float) { |
129 | | - _.each(this.nodes, function(n, i) { |
| 134 | + _.each(this.nodes, _.bind(function(n, i) { |
130 | 135 | if (n._updating || typeof n._orig_y == 'undefined' || n.y == n._orig_y) |
131 | 136 | return; |
132 | 137 |
|
|
145 | 150 | } |
146 | 151 | --new_y; |
147 | 152 | } |
148 | | - }, this); |
| 153 | + }, this)); |
149 | 154 | } |
150 | 155 | else { |
151 | | - _.each(this.nodes, function(n, i) { |
| 156 | + _.each(this.nodes, _.bind(function(n, i) { |
152 | 157 | if (n.locked) |
153 | 158 | return; |
154 | 159 | while (n.y > 0) { |
|
171 | 176 | n._dirty = n.y != new_y; |
172 | 177 | n.y = new_y; |
173 | 178 | } |
174 | | - }, this); |
| 179 | + }, this)); |
175 | 180 | } |
176 | 181 | }; |
177 | 182 |
|
|
748 | 753 | }; |
749 | 754 |
|
750 | 755 | GridStack.prototype.remove_all = function(detach_node) { |
751 | | - _.each(this.grid.nodes, function(node) { |
| 756 | + _.each(this.grid.nodes, _.bind(function(node) { |
752 | 757 | this.remove_widget(node.el, detach_node); |
753 | | - }, this); |
| 758 | + }, this)); |
754 | 759 | this.grid.nodes = []; |
755 | 760 | this._update_container_height(); |
756 | 761 | }; |
|
796 | 801 | node.no_move = !(val || false); |
797 | 802 | if (node.no_move) { |
798 | 803 | el.draggable('disable'); |
| 804 | + el.removeClass('ui-draggable-handle'); |
799 | 805 | } |
800 | 806 | else { |
801 | 807 | el.draggable('enable'); |
| 808 | + el.addClass('ui-draggable-handle'); |
802 | 809 | } |
803 | 810 | }); |
804 | 811 | return this; |
|
807 | 814 | GridStack.prototype.disable = function() { |
808 | 815 | this.movable(this.container.children('.' + this.opts.item_class), false); |
809 | 816 | this.resizable(this.container.children('.' + this.opts.item_class), false); |
| 817 | + this.container.trigger('disable'); |
810 | 818 | }; |
811 | 819 |
|
812 | 820 | GridStack.prototype.enable = function() { |
813 | 821 | this.movable(this.container.children('.' + this.opts.item_class), true); |
814 | 822 | this.resizable(this.container.children('.' + this.opts.item_class), true); |
| 823 | + this.container.trigger('enable'); |
815 | 824 | }; |
816 | 825 |
|
817 | 826 | GridStack.prototype.locked = function(el, val) { |
|
0 commit comments