|
98 | 98 |
|
99 | 99 | _isAddNodeIntercepted: function(n) { |
100 | 100 | return Utils.isIntercepted({x: this.x, y: this.y, width: this.node.width, height: this.node.height}, n); |
| 101 | + }, |
| 102 | + |
| 103 | + parseHeight: function(val) { |
| 104 | + var height = val; |
| 105 | + var heightUnit = 'px'; |
| 106 | + if (height && _.isString(height)) { |
| 107 | + var match = height.match(/^([0-9]*\.[0-9]+|[0-9]+)(px|em|rem|vh|vw)?$/); |
| 108 | + if (!match) { |
| 109 | + throw new Error('Invalid height'); |
| 110 | + } |
| 111 | + heightUnit = match[2]; |
| 112 | + height = parseFloat(match[1]); |
| 113 | + } |
| 114 | + return {height: height, unit: heightUnit}; |
101 | 115 | } |
102 | 116 | }; |
103 | 117 |
|
|
514 | 528 | appendTo: 'body' |
515 | 529 | }), |
516 | 530 | disableDrag: opts.disableDrag || false, |
517 | | - disableResize: opts.disableResize || false |
| 531 | + disableResize: opts.disableResize || false, |
| 532 | + rtl: 'auto' |
518 | 533 | }); |
| 534 | + |
| 535 | + if (this.opts.rtl === 'auto') { |
| 536 | + this.opts.rtl = this.container.css('direction') === 'rtl'; |
| 537 | + } |
| 538 | + |
| 539 | + if (this.opts.rtl) { |
| 540 | + this.container.addClass('grid-stack-rtl'); |
| 541 | + } |
| 542 | + |
519 | 543 | this.opts.isNested = isNested; |
520 | 544 |
|
521 | 545 | this.cellHeight(this.opts.cellHeight, true); |
|
1125 | 1149 | }); |
1126 | 1150 | }; |
1127 | 1151 |
|
1128 | | - function parseHeight(val) { |
1129 | | - var height = val; |
1130 | | - var heightUnit = 'px'; |
1131 | | - if (height && _.isString(height)) { |
1132 | | - var match = height.match(/^([0-9]*\.[0-9]+|[0-9]+)(px|em|rem|vh|vw)?$/); |
1133 | | - if (!match) { |
1134 | | - throw new Error('Invalid height'); |
1135 | | - } |
1136 | | - heightUnit = match[2]; |
1137 | | - height = parseFloat(match[1]); |
1138 | | - } |
1139 | | - return {height: height, unit: heightUnit}; |
1140 | | - } |
1141 | | - |
1142 | 1152 | GridStack.prototype.verticalMargin = function(val, noUpdate) { |
1143 | 1153 | if (typeof val == 'undefined') { |
1144 | 1154 | return this.opts.verticalMargin; |
1145 | 1155 | } |
1146 | 1156 |
|
1147 | | - var heightData = parseHeight(val); |
| 1157 | + var heightData = Utils.parseHeight(val); |
1148 | 1158 |
|
1149 | 1159 | if (this.opts.verticalMarginUnit === heightData.unit && this.opts.height === heightData.height) { |
1150 | 1160 | return ; |
|
1165 | 1175 | var o = this.container.children('.' + this.opts.itemClass).first(); |
1166 | 1176 | return Math.ceil(o.outerHeight() / o.attr('data-gs-height')); |
1167 | 1177 | } |
1168 | | - var heightData = parseHeight(val); |
| 1178 | + var heightData = Utils.parseHeight(val); |
1169 | 1179 |
|
1170 | 1180 | if (this.opts.cellHeightUnit === heightData.heightUnit && this.opts.height === heightData.height) { |
1171 | 1181 | return ; |
|
0 commit comments