27
27
28
28
create_stylesheet : function ( ) {
29
29
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 :(
35
30
style . appendChild ( document . createTextNode ( "" ) ) ;
36
-
37
31
document . head . appendChild ( style ) ;
38
-
39
32
return style . sheet ;
40
33
} ,
41
34
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
+
42
44
toBool : function ( v ) {
43
45
if ( typeof v == 'boolean' )
44
46
return v ;
443
445
444
446
if ( max_height > this . _styles . _max ) {
445
447
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
+ ) ;
455
469
}
456
470
this . _styles . _max = max_height ;
457
471
}
754
768
} ;
755
769
756
770
return scope . GridStackUI ;
757
- } ) ;
771
+ } ) ;
0 commit comments