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

Skip to content

Commit 4a4b627

Browse files
committed
update gridstack
1 parent e55ba50 commit 4a4b627

File tree

1 file changed

+31
-17
lines changed

1 file changed

+31
-17
lines changed

gridstack.js

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,20 @@
2727

2828
create_stylesheet: function () {
2929
var style = document.createElement("style");
30-
31-
// style.setAttribute("media", "screen")
32-
// style.setAttribute("media", "only screen and (max-width : 1024px)")
33-
34-
// WebKit hack :(
3530
style.appendChild(document.createTextNode(""));
36-
3731
document.head.appendChild(style);
38-
3932
return style.sheet;
4033
},
4134

35+
insert_css_rule: function (sheet, selector, rules, index) {
36+
if("insertRule" in sheet) {
37+
sheet.insertRule(selector + "{" + rules + "}", index);
38+
}
39+
else if("addRule" in sheet) {
40+
sheet.addRule(selector, rules, index);
41+
}
42+
},
43+
4244
toBool: function (v) {
4345
if (typeof v == 'boolean')
4446
return v;
@@ -443,15 +445,27 @@
443445

444446
if (max_height > this._styles._max) {
445447
for (var i = this._styles._max; i < max_height; ++i) {
446-
var css;
447-
css = '.' + this.opts._class + ' .' + this.opts.item_class + '[data-gs-height="' + (i + 1) + '"] { height: ' + (this.opts.cell_height * (i + 1) + this.opts.vertical_margin * i) + 'px; }';
448-
this._styles.insertRule(css, i);
449-
css = '.' + this.opts._class + ' .' + this.opts.item_class + '[data-gs-min-height="' + (i + 1) + '"] { min-height: ' + (this.opts.cell_height * (i + 1) + this.opts.vertical_margin * i) + 'px; }';
450-
this._styles.insertRule(css, i);
451-
css = '.' + this.opts._class + ' .' + this.opts.item_class + '[data-gs-max-height="' + (i + 1) + '"] { max-height: ' + (this.opts.cell_height * (i + 1) + this.opts.vertical_margin * i) + 'px; }';
452-
this._styles.insertRule(css, i);
453-
css = '.' + this.opts._class + ' .' + this.opts.item_class + '[data-gs-y="' + (i) + '"] { top: ' + (this.opts.cell_height * i + this.opts.vertical_margin * i) + 'px; }';
454-
this._styles.insertRule(css, i);
448+
var prefix = '.' + this.opts._class + ' .' + this.opts.item_class;
449+
Utils.insert_css_rule(this._styles,
450+
prefix + '[data-gs-height="' + (i + 1) + '"]',
451+
'height: ' + (this.opts.cell_height * (i + 1) + this.opts.vertical_margin * i) + 'px;',
452+
i
453+
);
454+
Utils.insert_css_rule(this._styles,
455+
prefix + '[data-gs-min-height="' + (i + 1) + '"]',
456+
'min-height: ' + (this.opts.cell_height * (i + 1) + this.opts.vertical_margin * i) + 'px;',
457+
i
458+
);
459+
Utils.insert_css_rule(this._styles,
460+
prefix + '[data-gs-max-height="' + (i + 1) + '"]',
461+
'max-height: ' + (this.opts.cell_height * (i + 1) + this.opts.vertical_margin * i) + 'px;',
462+
i
463+
);
464+
Utils.insert_css_rule(this._styles,
465+
prefix + '[data-gs-y="' + i + '"]',
466+
'top: ' + (this.opts.cell_height * i + this.opts.vertical_margin * i) + 'px;',
467+
i
468+
);
455469
}
456470
this._styles._max = max_height;
457471
}
@@ -754,4 +768,4 @@
754768
};
755769

756770
return scope.GridStackUI;
757-
});
771+
});

0 commit comments

Comments
 (0)