|
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 |
|
|
1125 | 1139 | }); |
1126 | 1140 | }; |
1127 | 1141 |
|
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 | 1142 | GridStack.prototype.verticalMargin = function(val, noUpdate) { |
1143 | 1143 | if (typeof val == 'undefined') { |
1144 | 1144 | return this.opts.verticalMargin; |
1145 | 1145 | } |
1146 | 1146 |
|
1147 | | - var heightData = parseHeight(val); |
| 1147 | + var heightData = Utils.parseHeight(val); |
1148 | 1148 |
|
1149 | 1149 | if (this.opts.verticalMarginUnit === heightData.unit && this.opts.height === heightData.height) { |
1150 | 1150 | return ; |
|
1165 | 1165 | var o = this.container.children('.' + this.opts.itemClass).first(); |
1166 | 1166 | return Math.ceil(o.outerHeight() / o.attr('data-gs-height')); |
1167 | 1167 | } |
1168 | | - var heightData = parseHeight(val); |
| 1168 | + var heightData = Utils.parseHeight(val); |
1169 | 1169 |
|
1170 | 1170 | if (this.opts.cellHeightUnit === heightData.heightUnit && this.opts.height === heightData.height) { |
1171 | 1171 | return ; |
|
0 commit comments