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

Skip to content

Commit 1201a4a

Browse files
committed
Use options for add_widget initializer, add max_height param
1 parent b82b76a commit 1201a4a

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/gridstack.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -568,13 +568,14 @@
568568
}
569569
};
570570

571-
GridStack.prototype.add_widget = function (el, x, y, width, height, auto_position) {
571+
GridStack.prototype.add_widget = function (el, options) {
572572
el = $(el);
573-
if (typeof x != 'undefined') el.attr('data-gs-x', x);
574-
if (typeof y != 'undefined') el.attr('data-gs-y', y);
575-
if (typeof width != 'undefined') el.attr('data-gs-width', width);
576-
if (typeof height != 'undefined') el.attr('data-gs-height', height);
577-
if (typeof auto_position != 'undefined') el.attr('data-gs-auto-position', auto_position ? 'yes' : null);
573+
if (typeof options.x !== 'undefined') el.attr('data-gs-x', options.x);
574+
if (typeof options.y !== 'undefined') el.attr('data-gs-y', options.y);
575+
if (typeof options.width !== 'undefined') el.attr('data-gs-width', options.width);
576+
if (typeof options.height !== 'undefined') el.attr('data-gs-height', options.height);
577+
if (typeof options.max_height !== 'undefined') el.attr('data-gs-max-height', options.max_height);
578+
if (typeof auto_position !== 'undefined') el.attr('data-gs-auto-position', options.auto_position ? 'yes' : null);
578579
this.container.append(el);
579580
this._prepare_element(el);
580581
this._update_container_height();

0 commit comments

Comments
 (0)