2020-12-02 14:26:20 +01:00
|
|
|
/** gridstack.js 1.2.1 - JQuery UI Drag&Drop plugin @preserve */
|
2020-03-26 12:29:38 +01:00
|
|
|
/**
|
2020-12-02 14:26:20 +01:00
|
|
|
* https://gridstackjs.com/
|
|
|
|
* (c) 2014-2020 Alain Dumesny, Dylan Weiss, Pavel Reznikov
|
2020-03-26 12:29:38 +01:00
|
|
|
* gridstack.js may be freely distributed under the MIT license.
|
|
|
|
*/
|
|
|
|
(function(factory) {
|
|
|
|
if (typeof define === "function" && define.amd) {
|
2020-12-02 14:26:20 +01:00
|
|
|
define(["jquery", "gridstack", "exports"], factory);
|
2020-03-26 12:29:38 +01:00
|
|
|
} else if (typeof exports !== "undefined") {
|
|
|
|
try {
|
|
|
|
jQuery = require("jquery");
|
|
|
|
} catch (e) {}
|
|
|
|
try {
|
2020-12-02 14:26:20 +01:00
|
|
|
gridstack = require("gridstack");
|
2020-03-26 12:29:38 +01:00
|
|
|
} catch (e) {}
|
2020-12-02 14:26:20 +01:00
|
|
|
factory(jQuery, gridstack.GridStack, exports);
|
2020-03-26 12:29:38 +01:00
|
|
|
} else {
|
2020-12-02 14:26:20 +01:00
|
|
|
factory(jQuery, GridStack, window);
|
2020-03-26 12:29:38 +01:00
|
|
|
}
|
2020-12-02 14:26:20 +01:00
|
|
|
})(function($, GridStack, scope) {
|
2020-03-26 12:29:38 +01:00
|
|
|
/**
|
|
|
|
* @class JQueryUIGridStackDragDropPlugin
|
|
|
|
* jQuery UI implementation of drag'n'drop gridstack plugin.
|
|
|
|
*/
|
|
|
|
function JQueryUIGridStackDragDropPlugin(grid) {
|
2020-12-02 14:26:20 +01:00
|
|
|
GridStack.DragDropPlugin.call(this, grid);
|
2020-03-26 12:29:38 +01:00
|
|
|
}
|
|
|
|
|
2020-12-02 14:26:20 +01:00
|
|
|
GridStack.DragDropPlugin.registerPlugin(JQueryUIGridStackDragDropPlugin);
|
2020-03-26 12:29:38 +01:00
|
|
|
|
|
|
|
JQueryUIGridStackDragDropPlugin.prototype = Object.create(
|
2020-12-02 14:26:20 +01:00
|
|
|
GridStack.DragDropPlugin.prototype
|
2020-03-26 12:29:38 +01:00
|
|
|
);
|
|
|
|
JQueryUIGridStackDragDropPlugin.prototype.constructor = JQueryUIGridStackDragDropPlugin;
|
|
|
|
|
|
|
|
JQueryUIGridStackDragDropPlugin.prototype.resizable = function(el, opts) {
|
|
|
|
el = $(el);
|
2020-12-02 14:26:20 +01:00
|
|
|
if (opts === "disable" || opts === "enable" || opts === "destroy") {
|
2020-03-26 12:29:38 +01:00
|
|
|
el.resizable(opts);
|
|
|
|
} else if (opts === "option") {
|
|
|
|
var key = arguments[2];
|
|
|
|
var value = arguments[3];
|
|
|
|
el.resizable(opts, key, value);
|
|
|
|
} else {
|
2020-12-02 14:26:20 +01:00
|
|
|
var handles = el.data("gs-resize-handles")
|
|
|
|
? el.data("gs-resize-handles")
|
|
|
|
: this.grid.opts.resizable.handles;
|
2020-03-26 12:29:38 +01:00
|
|
|
el.resizable(
|
2020-12-02 14:26:20 +01:00
|
|
|
$.extend(
|
|
|
|
{},
|
|
|
|
this.grid.opts.resizable,
|
|
|
|
{
|
|
|
|
handles: handles
|
|
|
|
},
|
|
|
|
{
|
|
|
|
start: opts.start || function() {},
|
|
|
|
stop: opts.stop || function() {},
|
|
|
|
resize: opts.resize || function() {}
|
|
|
|
}
|
|
|
|
)
|
2020-03-26 12:29:38 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
return this;
|
|
|
|
};
|
|
|
|
|
|
|
|
JQueryUIGridStackDragDropPlugin.prototype.draggable = function(el, opts) {
|
|
|
|
el = $(el);
|
2020-12-02 14:26:20 +01:00
|
|
|
if (opts === "disable" || opts === "enable" || opts === "destroy") {
|
2020-03-26 12:29:38 +01:00
|
|
|
el.draggable(opts);
|
|
|
|
} else {
|
|
|
|
el.draggable(
|
2020-12-02 14:26:20 +01:00
|
|
|
$.extend({}, this.grid.opts.draggable, {
|
|
|
|
containment:
|
|
|
|
this.grid.opts.isNested && !this.grid.opts.dragOut
|
|
|
|
? this.grid.$el.parent()
|
|
|
|
: this.grid.opts.draggable.containment || null,
|
2020-03-26 12:29:38 +01:00
|
|
|
start: opts.start || function() {},
|
|
|
|
stop: opts.stop || function() {},
|
|
|
|
drag: opts.drag || function() {}
|
|
|
|
})
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return this;
|
|
|
|
};
|
|
|
|
|
|
|
|
JQueryUIGridStackDragDropPlugin.prototype.droppable = function(el, opts) {
|
|
|
|
el = $(el);
|
2020-12-02 14:26:20 +01:00
|
|
|
el.droppable(opts);
|
2020-03-26 12:29:38 +01:00
|
|
|
return this;
|
|
|
|
};
|
|
|
|
|
|
|
|
JQueryUIGridStackDragDropPlugin.prototype.isDroppable = function(el, opts) {
|
|
|
|
el = $(el);
|
|
|
|
return Boolean(el.data("droppable"));
|
|
|
|
};
|
|
|
|
|
|
|
|
JQueryUIGridStackDragDropPlugin.prototype.on = function(
|
|
|
|
el,
|
|
|
|
eventName,
|
|
|
|
callback
|
|
|
|
) {
|
|
|
|
$(el).on(eventName, callback);
|
|
|
|
return this;
|
|
|
|
};
|
|
|
|
|
2020-12-02 14:26:20 +01:00
|
|
|
scope.JQueryUIGridStackDragDropPlugin = JQueryUIGridStackDragDropPlugin;
|
|
|
|
|
2020-03-26 12:29:38 +01:00
|
|
|
return JQueryUIGridStackDragDropPlugin;
|
|
|
|
});
|