11gridstack.js
22============
33
4- gridstack.js is a jQuery plugin for widget layout. This is drag-and-drop multi-column grid. It allows you to build
4+ gridstack.js is a jQuery plugin for widget layout. This is drag-and-drop multi-column grid. It allows you to build
55draggable responsive bootstrap v3 friendly layouts. It also works great with [ knockout.js] ( http://knockoutjs.com ) and
66touch devices.
77
9292## Requirements
9393
9494* [ lodash.js] ( https://lodash.com ) (>= 3.5.0)
95- * [ jQuery] ( http://jquery.com ) (>= 1.11.0)
95+ * [ jQuery] ( http://jquery.com ) (>= 1.11.0)
9696* [ jQuery UI] ( http://jqueryui.com ) (>= 1.11.0). Minimum required components: Core, Widget, Mouse, Draggable, Resizable
9797* (Optional) [ knockout.js] ( http://knockoutjs.com ) (>= 3.2.0)
9898* (Optional) [ jquery-ui-touch-punch] ( https://github.com/furf/jquery-ui-touch-punch ) for touch-based devices support
@@ -103,13 +103,13 @@ Note: You can still use [underscore.js](http://underscorejs.org) (>= 1.7.0) inst
103103
104104``` html
105105<div class =" grid-stack" >
106- <div class =" grid-stack-item"
107- data-gs-x =" 0" data-gs-y =" 0"
106+ <div class =" grid-stack-item"
107+ data-gs-x =" 0" data-gs-y =" 0"
108108 data-gs-width =" 4" data-gs-height =" 2" >
109109 <div class =" grid-stack-item-content" ></div >
110110 </div >
111- <div class =" grid-stack-item"
112- data-gs-x =" 4" data-gs-y =" 0"
111+ <div class =" grid-stack-item"
112+ data-gs-x =" 4" data-gs-y =" 0"
113113 data-gs-width =" 4" data-gs-height =" 4" >
114114 <div class =" grid-stack-item-content" ></div >
115115 </div >
@@ -128,18 +128,18 @@ $(function () {
128128
129129## Options
130130
131- - ` always_show_resize_handle ` - if ` true ` the resizing handles are shown even if the user is not hovering over the widget
132- (default: ` false ` )
131+ - ` always_show_resize_handle ` - if ` true ` the resizing handles are shown even if the user is not hovering over the widget
132+ (default: ` false ` )
133133- ` animate ` - turns animation on (default: ` false ` )
134134- ` auto ` - if ` false ` gridstack will not initialize existing items (default: ` true ` )
135135- ` cell_height ` - one cell height (default: ` 60 ` )
136- - ` draggable ` - allows to override jQuery UI draggable options. (default: ` {handle: '.grid-stack-item-content', scroll: true, appendTo: 'body'} ` )
136+ - ` draggable ` - allows to override jQuery UI draggable options. (default: ` {handle: '.grid-stack-item-content', scroll: true, appendTo: 'body'} ` )
137137- ` handle ` - draggable handle selector (default: ` '.grid-stack-item-content' ` )
138138- ` handle_class ` - draggable handle class (e.g. ` 'grid-stack-item-content' ` ). If set ` handle ` is ignored (default: ` null ` )
139139- ` height ` - maximum rows amount. Default is ` 0 ` which means no maximum rows
140140- ` float ` - enable floating widgets (default: ` false ` ) See [ example] ( http://troolee.github.io/gridstack.js/demo/float.html )
141141- ` item_class ` - widget class (default: ` 'grid-stack-item' ` )
142- - ` min_width ` - minimal width. If window width is less, grid will be shown in one-column mode (default: ` 768 ` )
142+ - ` 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 ` )
143143- ` placeholder_class ` - class for placeholder (default: ` 'grid-stack-placeholder' ` )
144144- ` resizable ` - allows to override jQuery UI resizable options. (default: ` {autoHide: true, handles: 'se'} ` )
145145- ` 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.
@@ -148,7 +148,7 @@ $(function () {
148148
149149## Grid attributes
150150
151- - ` data-gs-animate ` - turns animation on
151+ - ` data-gs-animate ` - turns animation on
152152- ` data-gs-width ` - amount of columns
153153- ` data-gs-height ` - maximum rows amount. Default is ` 0 ` which means no maximum rows.
154154
@@ -158,13 +158,13 @@ $(function () {
158158- ` data-gs-width ` , ` data-gs-height ` - element size
159159- ` data-gs-max-width ` , ` data-gs-min-width ` , ` data-gs-max-height ` , ` data-gs-min-height ` - element constraints
160160- ` data-gs-no-resize ` - disable element resizing
161- - ` data-gs-no-move ` - disable element moving
162- - ` data-gs-auto-position ` - tells to ignore ` data-gs-x ` and ` data-gs-y ` attributes and to place element to the first
161+ - ` data-gs-no-move ` - disable element moving
162+ - ` data-gs-auto-position ` - tells to ignore ` data-gs-x ` and ` data-gs-y ` attributes and to place element to the first
163163 available position
164164- ` data-gs-locked ` - the widget will be locked. It means another widget wouldn't be able to move it during dragging or resizing.
165165The widget can still be dragged or resized. You need to add ` data-gs-no-resize ` and ` data-gs-no-move ` attributes
166166to completely lock the widget.
167-
167+
168168## Events
169169
170170### onchange(items)
@@ -258,7 +258,7 @@ grid.add_widget(el, 0, 0, 3, 2, true);
258258
259259### batch_update()
260260
261- Initailizes batch updates. You will see no changes until ` commit ` method is called.
261+ Initailizes batch updates. You will see no changes until ` commit ` method is called.
262262
263263### cell_height()
264264
@@ -283,7 +283,7 @@ Finishes batch updates. Updates DOM nodes. You must call it after `batch_update`
283283
284284### destroy()
285285
286- Destroys a grid instance.
286+ Destroys a grid instance.
287287
288288### disable()
289289
@@ -322,7 +322,7 @@ Checks if specified area is empty.
322322Locks/unlocks widget.
323323
324324- ` el ` - widget to modify.
325- - ` val ` - if ` true ` widget will be locked.
325+ - ` val ` - if ` true ` widget will be locked.
326326
327327### min_width(el, val)
328328
@@ -381,13 +381,13 @@ Parameters:
381381Enables/Disables resizing.
382382
383383- ` el ` - widget to modify
384- - ` val ` - if ` true ` widget will be resizable.
384+ - ` val ` - if ` true ` widget will be resizable.
385385
386386### set_static(static_value)
387387
388388Toggle the grid static state. Also toggle the ` grid-stack-static ` class.
389389
390- - ` static_value ` - if ` true ` the grid become static.
390+ - ` static_value ` - if ` true ` the grid become static.
391391
392392### update(el, x, y, width, height)
393393
@@ -412,7 +412,7 @@ else {
412412 alert (' Not enough free space to place the widget' );
413413}
414414```
415-
415+
416416
417417## Utils
418418
@@ -522,7 +522,7 @@ template:
522522 ' ....',
523523 ' </div>', // <-- NO SPACE **AFTER** </div>
524524 '</div> ' // <-- NO SPACE **BEFORE** </div>
525- ].join('') // <-- JOIN WITH **EMPTY** STRING
525+ ].join('') // <-- JOIN WITH **EMPTY** STRING
526526```
527527
528528Otherwise ` addDisposeCallback ` won't work.
@@ -540,8 +540,8 @@ For rails users, integration of gridstack.js and its dependencies can be done th
540540
541541## Change grid width
542542
543- To change grid width (columns count), to addition to ` width ` option, CSS rules
544- for ` .grid-stack-item[data-gs-width="X"] ` and ` .grid-stack-item[data-gs-x="X"] ` have to be changed accordingly.
543+ To change grid width (columns count), to addition to ` width ` option, CSS rules
544+ for ` .grid-stack-item[data-gs-width="X"] ` and ` .grid-stack-item[data-gs-x="X"] ` have to be changed accordingly.
545545
546546For instance for 3-column grid you need to rewrite CSS to be:
547547
@@ -590,7 +590,7 @@ Or you can include `gridstack-extra.css`. See below for more details.
590590## Extra CSS
591591
592592There are few extra CSS batteries in ` gridstack-extra.css ` (` gridstack-extra.min.css ` ).
593-
593+
594594### Different grid widths
595595
596596You can use other than 12 grid width:
@@ -607,7 +607,7 @@ See example: [2 grids demo](http://troolee.github.io/gridstack.js/demo/two.html)
607607## Save grid to array
608608
609609Because gridstack doesn't track any kind of user-defined widget id there is no reason to make serialization to be part
610- of gridstack API. To serialize grid you can simply do something like this (let's say you store widget id inside ` data-custom-id `
610+ of gridstack API. To serialize grid you can simply do something like this (let's say you store widget id inside ` data-custom-id `
611611attribute):
612612
613613``` javascript
@@ -627,7 +627,7 @@ alert(JSON.stringify(res));
627627
628628See example: [ Serialization demo] ( http://troolee.github.io/gridstack.js/demo/serialization.html )
629629
630- You can also use ` onchange ` event if you need to save only changed widgets right away they have been changed.
630+ You can also use ` onchange ` event if you need to save only changed widgets right away they have been changed.
631631
632632## Load grid from array
633633
@@ -649,7 +649,7 @@ var grid = $('.grid-stack').data('gridstack');
649649grid .remove_all ();
650650
651651_ .each (serialization, function (node ) {
652- grid .add_widget ($ (' <div><div class="grid-stack-item-content" /></div>' ),
652+ grid .add_widget ($ (' <div><div class="grid-stack-item-content" /></div>' ),
653653 node .x , node .y , node .width , node .height );
654654});
655655```
@@ -715,14 +715,14 @@ for i in range(N):
715715 print ' .grid-stack > .grid-stack-item[data-gs-y="%(index)s "] { top: %(height)s px }' % {' index' : i , ' height' : h}
716716```
717717
718- There are at least two more issues with gridstack in IE8 with jQueryUI resizable (it seems it doesn't work) and
719- droppable. If you have any suggestions about support of IE8 you are welcome here: https://github.com/troolee/gridstack.js/issues/76
718+ There are at least two more issues with gridstack in IE8 with jQueryUI resizable (it seems it doesn't work) and
719+ droppable. If you have any suggestions about support of IE8 you are welcome here: https://github.com/troolee/gridstack.js/issues/76
720720
721721
722722## Nested grids
723723
724- Gridstack may be nested. All nested grids have an additional class ` grid-stack-nested ` which is assigned automatically
725- during initialization.
724+ Gridstack may be nested. All nested grids have an additional class ` grid-stack-nested ` which is assigned automatically
725+ during initialization.
726726See example: [ Nested grid demo] ( http://troolee.github.io/gridstack.js/demo/nested.html )
727727
728728
@@ -776,7 +776,7 @@ Changes
776776- auto-generate css rules (widgets ` height ` and ` top ` )
777777- add ` GridStackUI.Utils.sort ` utility function
778778- add ` remove_all ` API method
779- - add ` resize ` and ` move ` API methods
779+ - add ` resize ` and ` move ` API methods
780780- add ` resizable ` and ` movable ` API methods
781781- add ` data-gs-no-move ` attribute
782782- add ` float ` option
@@ -812,4 +812,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
812812LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
813813OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
814814SOFTWARE.
815-
0 commit comments