Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 219027b

Browse files
committed
update gridstack.js
1 parent 8f0dcf2 commit 219027b

File tree

1 file changed

+72
-38
lines changed

1 file changed

+72
-38
lines changed

gridstack.js

Lines changed: 72 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -375,47 +375,41 @@
375375
});
376376
};
377377

378-
if (!node.no_move) {
379-
el.draggable({
380-
handle: this.opts.handle,
381-
scroll: true,
382-
appendTo: 'body',
383-
384-
start: on_start_moving,
385-
stop: on_end_moving,
386-
drag: function (event, ui) {
387-
var x = Math.round(ui.position.left / cell_width),
388-
y = Math.floor(ui.position.top / cell_height);
389-
self.grid.move_node(node, x, y);
390-
self._update_container_height();
391-
}
392-
});
393-
394-
if (this._is_one_column_mode()) {
395-
el.draggable('disable');
378+
el.draggable({
379+
handle: this.opts.handle,
380+
scroll: true,
381+
appendTo: 'body',
382+
383+
start: on_start_moving,
384+
stop: on_end_moving,
385+
drag: function (event, ui) {
386+
var x = Math.round(ui.position.left / cell_width),
387+
y = Math.floor(ui.position.top / cell_height);
388+
self.grid.move_node(node, x, y);
389+
self._update_container_height();
396390
}
397-
}
391+
}).resizable({
392+
autoHide: true,
393+
handles: 'se',
394+
minHeight: this.opts.cell_height - 10,
395+
minWidth: 70,
396+
397+
start: on_start_moving,
398+
stop: on_end_moving,
399+
resize: function (event, ui) {
400+
var width = Math.round(ui.size.width / cell_width),
401+
height = Math.round(ui.size.height / cell_height);
402+
self.grid.move_node(node, node.x, node.y, width, height);
403+
self._update_container_height();
404+
}
405+
});
398406

399-
if (!node.no_resize) {
400-
el.resizable({
401-
autoHide: true,
402-
handles: 'se',
403-
minHeight: this.opts.cell_height - 10,
404-
minWidth: 70,
405-
406-
start: on_start_moving,
407-
stop: on_end_moving,
408-
resize: function (event, ui) {
409-
var width = Math.round(ui.size.width / cell_width),
410-
height = Math.round(ui.size.height / cell_height);
411-
self.grid.move_node(node, node.x, node.y, width, height);
412-
self._update_container_height();
413-
}
414-
});
407+
if (node.no_move || this._is_one_column_mode()) {
408+
el.draggable('disable');
409+
}
415410

416-
if (this._is_one_column_mode()) {
417-
el.resizable('disable');
418-
}
411+
if (node.no_resize || this._is_one_column_mode()) {
412+
el.resizable('disable');
419413
}
420414
};
421415

@@ -438,6 +432,46 @@
438432
this._update_container_height();
439433
};
440434

435+
GridStack.prototype.resizable = function (el, val) {
436+
el = $(el);
437+
el.each(function (index, el) {
438+
el = $(el);
439+
var node = el.data('_gridstack_node');
440+
if (typeof node == 'undefined') {
441+
return;
442+
}
443+
444+
node.no_resize = !(val || false);
445+
if (node.no_resize) {
446+
el.resizable('disable');
447+
}
448+
else {
449+
el.resizable('enable');
450+
}
451+
});
452+
return this;
453+
};
454+
455+
GridStack.prototype.movable = function (el, val) {
456+
el = $(el);
457+
el.each(function (index, el) {
458+
el = $(el);
459+
var node = el.data('_gridstack_node');
460+
if (typeof node == 'undefined') {
461+
return;
462+
}
463+
464+
node.no_move = !(val || false);
465+
if (node.no_move) {
466+
el.draggable('disable');
467+
}
468+
else {
469+
el.draggable('enable');
470+
}
471+
});
472+
return this;
473+
};
474+
441475
scope.GridStackUI = GridStack;
442476

443477
$.fn.gridstack = function (opts) {

0 commit comments

Comments
 (0)