| @@ 8167-8310 (lines=144) @@ | ||
| 8164 | var FormatControls = { setup: setup }; |
|
| 8165 | ||
| 8166 | var GridLayout = AbsoluteLayout.extend({ |
|
| 8167 | recalc: function (container) { |
|
| 8168 | var settings, rows, cols, items, contLayoutRect, width, height, rect, ctrlLayoutRect, ctrl, x, y, posX, posY, ctrlSettings, contPaddingBox, align, spacingH, spacingV, alignH, alignV, maxX, maxY; |
|
| 8169 | var colWidths = []; |
|
| 8170 | var rowHeights = []; |
|
| 8171 | var ctrlMinWidth, ctrlMinHeight, availableWidth, availableHeight, reverseRows, idx; |
|
| 8172 | settings = container.settings; |
|
| 8173 | items = container.items().filter(':visible'); |
|
| 8174 | contLayoutRect = container.layoutRect(); |
|
| 8175 | cols = settings.columns || Math.ceil(Math.sqrt(items.length)); |
|
| 8176 | rows = Math.ceil(items.length / cols); |
|
| 8177 | spacingH = settings.spacingH || settings.spacing || 0; |
|
| 8178 | spacingV = settings.spacingV || settings.spacing || 0; |
|
| 8179 | alignH = settings.alignH || settings.align; |
|
| 8180 | alignV = settings.alignV || settings.align; |
|
| 8181 | contPaddingBox = container.paddingBox; |
|
| 8182 | reverseRows = 'reverseRows' in settings ? settings.reverseRows : container.isRtl(); |
|
| 8183 | if (alignH && typeof alignH === 'string') { |
|
| 8184 | alignH = [alignH]; |
|
| 8185 | } |
|
| 8186 | if (alignV && typeof alignV === 'string') { |
|
| 8187 | alignV = [alignV]; |
|
| 8188 | } |
|
| 8189 | for (x = 0; x < cols; x++) { |
|
| 8190 | colWidths.push(0); |
|
| 8191 | } |
|
| 8192 | for (y = 0; y < rows; y++) { |
|
| 8193 | rowHeights.push(0); |
|
| 8194 | } |
|
| 8195 | for (y = 0; y < rows; y++) { |
|
| 8196 | for (x = 0; x < cols; x++) { |
|
| 8197 | ctrl = items[y * cols + x]; |
|
| 8198 | if (!ctrl) { |
|
| 8199 | break; |
|
| 8200 | } |
|
| 8201 | ctrlLayoutRect = ctrl.layoutRect(); |
|
| 8202 | ctrlMinWidth = ctrlLayoutRect.minW; |
|
| 8203 | ctrlMinHeight = ctrlLayoutRect.minH; |
|
| 8204 | colWidths[x] = ctrlMinWidth > colWidths[x] ? ctrlMinWidth : colWidths[x]; |
|
| 8205 | rowHeights[y] = ctrlMinHeight > rowHeights[y] ? ctrlMinHeight : rowHeights[y]; |
|
| 8206 | } |
|
| 8207 | } |
|
| 8208 | availableWidth = contLayoutRect.innerW - contPaddingBox.left - contPaddingBox.right; |
|
| 8209 | for (maxX = 0, x = 0; x < cols; x++) { |
|
| 8210 | maxX += colWidths[x] + (x > 0 ? spacingH : 0); |
|
| 8211 | availableWidth -= (x > 0 ? spacingH : 0) + colWidths[x]; |
|
| 8212 | } |
|
| 8213 | availableHeight = contLayoutRect.innerH - contPaddingBox.top - contPaddingBox.bottom; |
|
| 8214 | for (maxY = 0, y = 0; y < rows; y++) { |
|
| 8215 | maxY += rowHeights[y] + (y > 0 ? spacingV : 0); |
|
| 8216 | availableHeight -= (y > 0 ? spacingV : 0) + rowHeights[y]; |
|
| 8217 | } |
|
| 8218 | maxX += contPaddingBox.left + contPaddingBox.right; |
|
| 8219 | maxY += contPaddingBox.top + contPaddingBox.bottom; |
|
| 8220 | rect = {}; |
|
| 8221 | rect.minW = maxX + (contLayoutRect.w - contLayoutRect.innerW); |
|
| 8222 | rect.minH = maxY + (contLayoutRect.h - contLayoutRect.innerH); |
|
| 8223 | rect.contentW = rect.minW - contLayoutRect.deltaW; |
|
| 8224 | rect.contentH = rect.minH - contLayoutRect.deltaH; |
|
| 8225 | rect.minW = Math.min(rect.minW, contLayoutRect.maxW); |
|
| 8226 | rect.minH = Math.min(rect.minH, contLayoutRect.maxH); |
|
| 8227 | rect.minW = Math.max(rect.minW, contLayoutRect.startMinWidth); |
|
| 8228 | rect.minH = Math.max(rect.minH, contLayoutRect.startMinHeight); |
|
| 8229 | if (contLayoutRect.autoResize && (rect.minW !== contLayoutRect.minW || rect.minH !== contLayoutRect.minH)) { |
|
| 8230 | rect.w = rect.minW; |
|
| 8231 | rect.h = rect.minH; |
|
| 8232 | container.layoutRect(rect); |
|
| 8233 | this.recalc(container); |
|
| 8234 | if (container._lastRect === null) { |
|
| 8235 | var parentCtrl = container.parent(); |
|
| 8236 | if (parentCtrl) { |
|
| 8237 | parentCtrl._lastRect = null; |
|
| 8238 | parentCtrl.recalc(); |
|
| 8239 | } |
|
| 8240 | } |
|
| 8241 | return; |
|
| 8242 | } |
|
| 8243 | if (contLayoutRect.autoResize) { |
|
| 8244 | rect = container.layoutRect(rect); |
|
| 8245 | rect.contentW = rect.minW - contLayoutRect.deltaW; |
|
| 8246 | rect.contentH = rect.minH - contLayoutRect.deltaH; |
|
| 8247 | } |
|
| 8248 | var flexV; |
|
| 8249 | if (settings.packV === 'start') { |
|
| 8250 | flexV = 0; |
|
| 8251 | } else { |
|
| 8252 | flexV = availableHeight > 0 ? Math.floor(availableHeight / rows) : 0; |
|
| 8253 | } |
|
| 8254 | var totalFlex = 0; |
|
| 8255 | var flexWidths = settings.flexWidths; |
|
| 8256 | if (flexWidths) { |
|
| 8257 | for (x = 0; x < flexWidths.length; x++) { |
|
| 8258 | totalFlex += flexWidths[x]; |
|
| 8259 | } |
|
| 8260 | } else { |
|
| 8261 | totalFlex = cols; |
|
| 8262 | } |
|
| 8263 | var ratio = availableWidth / totalFlex; |
|
| 8264 | for (x = 0; x < cols; x++) { |
|
| 8265 | colWidths[x] += flexWidths ? flexWidths[x] * ratio : ratio; |
|
| 8266 | } |
|
| 8267 | posY = contPaddingBox.top; |
|
| 8268 | for (y = 0; y < rows; y++) { |
|
| 8269 | posX = contPaddingBox.left; |
|
| 8270 | height = rowHeights[y] + flexV; |
|
| 8271 | for (x = 0; x < cols; x++) { |
|
| 8272 | if (reverseRows) { |
|
| 8273 | idx = y * cols + cols - 1 - x; |
|
| 8274 | } else { |
|
| 8275 | idx = y * cols + x; |
|
| 8276 | } |
|
| 8277 | ctrl = items[idx]; |
|
| 8278 | if (!ctrl) { |
|
| 8279 | break; |
|
| 8280 | } |
|
| 8281 | ctrlSettings = ctrl.settings; |
|
| 8282 | ctrlLayoutRect = ctrl.layoutRect(); |
|
| 8283 | width = Math.max(colWidths[x], ctrlLayoutRect.startMinWidth); |
|
| 8284 | ctrlLayoutRect.x = posX; |
|
| 8285 | ctrlLayoutRect.y = posY; |
|
| 8286 | align = ctrlSettings.alignH || (alignH ? alignH[x] || alignH[0] : null); |
|
| 8287 | if (align === 'center') { |
|
| 8288 | ctrlLayoutRect.x = posX + width / 2 - ctrlLayoutRect.w / 2; |
|
| 8289 | } else if (align === 'right') { |
|
| 8290 | ctrlLayoutRect.x = posX + width - ctrlLayoutRect.w; |
|
| 8291 | } else if (align === 'stretch') { |
|
| 8292 | ctrlLayoutRect.w = width; |
|
| 8293 | } |
|
| 8294 | align = ctrlSettings.alignV || (alignV ? alignV[x] || alignV[0] : null); |
|
| 8295 | if (align === 'center') { |
|
| 8296 | ctrlLayoutRect.y = posY + height / 2 - ctrlLayoutRect.h / 2; |
|
| 8297 | } else if (align === 'bottom') { |
|
| 8298 | ctrlLayoutRect.y = posY + height - ctrlLayoutRect.h; |
|
| 8299 | } else if (align === 'stretch') { |
|
| 8300 | ctrlLayoutRect.h = height; |
|
| 8301 | } |
|
| 8302 | ctrl.layoutRect(ctrlLayoutRect); |
|
| 8303 | posX += width + spacingH; |
|
| 8304 | if (ctrl.recalc) { |
|
| 8305 | ctrl.recalc(); |
|
| 8306 | } |
|
| 8307 | } |
|
| 8308 | posY += height + spacingV; |
|
| 8309 | } |
|
| 8310 | } |
|
| 8311 | }); |
|
| 8312 | ||
| 8313 | var Iframe = Widget.extend({ |
|
| @@ 8009-8152 (lines=144) @@ | ||
| 8006 | var FormatControls = { setup: setup$1 }; |
|
| 8007 | ||
| 8008 | var GridLayout = AbsoluteLayout.extend({ |
|
| 8009 | recalc: function (container) { |
|
| 8010 | var settings, rows, cols, items, contLayoutRect, width, height, rect, ctrlLayoutRect, ctrl, x, y, posX, posY, ctrlSettings, contPaddingBox, align, spacingH, spacingV, alignH, alignV, maxX, maxY; |
|
| 8011 | var colWidths = []; |
|
| 8012 | var rowHeights = []; |
|
| 8013 | var ctrlMinWidth, ctrlMinHeight, availableWidth, availableHeight, reverseRows, idx; |
|
| 8014 | settings = container.settings; |
|
| 8015 | items = container.items().filter(':visible'); |
|
| 8016 | contLayoutRect = container.layoutRect(); |
|
| 8017 | cols = settings.columns || Math.ceil(Math.sqrt(items.length)); |
|
| 8018 | rows = Math.ceil(items.length / cols); |
|
| 8019 | spacingH = settings.spacingH || settings.spacing || 0; |
|
| 8020 | spacingV = settings.spacingV || settings.spacing || 0; |
|
| 8021 | alignH = settings.alignH || settings.align; |
|
| 8022 | alignV = settings.alignV || settings.align; |
|
| 8023 | contPaddingBox = container.paddingBox; |
|
| 8024 | reverseRows = 'reverseRows' in settings ? settings.reverseRows : container.isRtl(); |
|
| 8025 | if (alignH && typeof alignH === 'string') { |
|
| 8026 | alignH = [alignH]; |
|
| 8027 | } |
|
| 8028 | if (alignV && typeof alignV === 'string') { |
|
| 8029 | alignV = [alignV]; |
|
| 8030 | } |
|
| 8031 | for (x = 0; x < cols; x++) { |
|
| 8032 | colWidths.push(0); |
|
| 8033 | } |
|
| 8034 | for (y = 0; y < rows; y++) { |
|
| 8035 | rowHeights.push(0); |
|
| 8036 | } |
|
| 8037 | for (y = 0; y < rows; y++) { |
|
| 8038 | for (x = 0; x < cols; x++) { |
|
| 8039 | ctrl = items[y * cols + x]; |
|
| 8040 | if (!ctrl) { |
|
| 8041 | break; |
|
| 8042 | } |
|
| 8043 | ctrlLayoutRect = ctrl.layoutRect(); |
|
| 8044 | ctrlMinWidth = ctrlLayoutRect.minW; |
|
| 8045 | ctrlMinHeight = ctrlLayoutRect.minH; |
|
| 8046 | colWidths[x] = ctrlMinWidth > colWidths[x] ? ctrlMinWidth : colWidths[x]; |
|
| 8047 | rowHeights[y] = ctrlMinHeight > rowHeights[y] ? ctrlMinHeight : rowHeights[y]; |
|
| 8048 | } |
|
| 8049 | } |
|
| 8050 | availableWidth = contLayoutRect.innerW - contPaddingBox.left - contPaddingBox.right; |
|
| 8051 | for (maxX = 0, x = 0; x < cols; x++) { |
|
| 8052 | maxX += colWidths[x] + (x > 0 ? spacingH : 0); |
|
| 8053 | availableWidth -= (x > 0 ? spacingH : 0) + colWidths[x]; |
|
| 8054 | } |
|
| 8055 | availableHeight = contLayoutRect.innerH - contPaddingBox.top - contPaddingBox.bottom; |
|
| 8056 | for (maxY = 0, y = 0; y < rows; y++) { |
|
| 8057 | maxY += rowHeights[y] + (y > 0 ? spacingV : 0); |
|
| 8058 | availableHeight -= (y > 0 ? spacingV : 0) + rowHeights[y]; |
|
| 8059 | } |
|
| 8060 | maxX += contPaddingBox.left + contPaddingBox.right; |
|
| 8061 | maxY += contPaddingBox.top + contPaddingBox.bottom; |
|
| 8062 | rect = {}; |
|
| 8063 | rect.minW = maxX + (contLayoutRect.w - contLayoutRect.innerW); |
|
| 8064 | rect.minH = maxY + (contLayoutRect.h - contLayoutRect.innerH); |
|
| 8065 | rect.contentW = rect.minW - contLayoutRect.deltaW; |
|
| 8066 | rect.contentH = rect.minH - contLayoutRect.deltaH; |
|
| 8067 | rect.minW = Math.min(rect.minW, contLayoutRect.maxW); |
|
| 8068 | rect.minH = Math.min(rect.minH, contLayoutRect.maxH); |
|
| 8069 | rect.minW = Math.max(rect.minW, contLayoutRect.startMinWidth); |
|
| 8070 | rect.minH = Math.max(rect.minH, contLayoutRect.startMinHeight); |
|
| 8071 | if (contLayoutRect.autoResize && (rect.minW !== contLayoutRect.minW || rect.minH !== contLayoutRect.minH)) { |
|
| 8072 | rect.w = rect.minW; |
|
| 8073 | rect.h = rect.minH; |
|
| 8074 | container.layoutRect(rect); |
|
| 8075 | this.recalc(container); |
|
| 8076 | if (container._lastRect === null) { |
|
| 8077 | var parentCtrl = container.parent(); |
|
| 8078 | if (parentCtrl) { |
|
| 8079 | parentCtrl._lastRect = null; |
|
| 8080 | parentCtrl.recalc(); |
|
| 8081 | } |
|
| 8082 | } |
|
| 8083 | return; |
|
| 8084 | } |
|
| 8085 | if (contLayoutRect.autoResize) { |
|
| 8086 | rect = container.layoutRect(rect); |
|
| 8087 | rect.contentW = rect.minW - contLayoutRect.deltaW; |
|
| 8088 | rect.contentH = rect.minH - contLayoutRect.deltaH; |
|
| 8089 | } |
|
| 8090 | var flexV; |
|
| 8091 | if (settings.packV === 'start') { |
|
| 8092 | flexV = 0; |
|
| 8093 | } else { |
|
| 8094 | flexV = availableHeight > 0 ? Math.floor(availableHeight / rows) : 0; |
|
| 8095 | } |
|
| 8096 | var totalFlex = 0; |
|
| 8097 | var flexWidths = settings.flexWidths; |
|
| 8098 | if (flexWidths) { |
|
| 8099 | for (x = 0; x < flexWidths.length; x++) { |
|
| 8100 | totalFlex += flexWidths[x]; |
|
| 8101 | } |
|
| 8102 | } else { |
|
| 8103 | totalFlex = cols; |
|
| 8104 | } |
|
| 8105 | var ratio = availableWidth / totalFlex; |
|
| 8106 | for (x = 0; x < cols; x++) { |
|
| 8107 | colWidths[x] += flexWidths ? flexWidths[x] * ratio : ratio; |
|
| 8108 | } |
|
| 8109 | posY = contPaddingBox.top; |
|
| 8110 | for (y = 0; y < rows; y++) { |
|
| 8111 | posX = contPaddingBox.left; |
|
| 8112 | height = rowHeights[y] + flexV; |
|
| 8113 | for (x = 0; x < cols; x++) { |
|
| 8114 | if (reverseRows) { |
|
| 8115 | idx = y * cols + cols - 1 - x; |
|
| 8116 | } else { |
|
| 8117 | idx = y * cols + x; |
|
| 8118 | } |
|
| 8119 | ctrl = items[idx]; |
|
| 8120 | if (!ctrl) { |
|
| 8121 | break; |
|
| 8122 | } |
|
| 8123 | ctrlSettings = ctrl.settings; |
|
| 8124 | ctrlLayoutRect = ctrl.layoutRect(); |
|
| 8125 | width = Math.max(colWidths[x], ctrlLayoutRect.startMinWidth); |
|
| 8126 | ctrlLayoutRect.x = posX; |
|
| 8127 | ctrlLayoutRect.y = posY; |
|
| 8128 | align = ctrlSettings.alignH || (alignH ? alignH[x] || alignH[0] : null); |
|
| 8129 | if (align === 'center') { |
|
| 8130 | ctrlLayoutRect.x = posX + width / 2 - ctrlLayoutRect.w / 2; |
|
| 8131 | } else if (align === 'right') { |
|
| 8132 | ctrlLayoutRect.x = posX + width - ctrlLayoutRect.w; |
|
| 8133 | } else if (align === 'stretch') { |
|
| 8134 | ctrlLayoutRect.w = width; |
|
| 8135 | } |
|
| 8136 | align = ctrlSettings.alignV || (alignV ? alignV[x] || alignV[0] : null); |
|
| 8137 | if (align === 'center') { |
|
| 8138 | ctrlLayoutRect.y = posY + height / 2 - ctrlLayoutRect.h / 2; |
|
| 8139 | } else if (align === 'bottom') { |
|
| 8140 | ctrlLayoutRect.y = posY + height - ctrlLayoutRect.h; |
|
| 8141 | } else if (align === 'stretch') { |
|
| 8142 | ctrlLayoutRect.h = height; |
|
| 8143 | } |
|
| 8144 | ctrl.layoutRect(ctrlLayoutRect); |
|
| 8145 | posX += width + spacingH; |
|
| 8146 | if (ctrl.recalc) { |
|
| 8147 | ctrl.recalc(); |
|
| 8148 | } |
|
| 8149 | } |
|
| 8150 | posY += height + spacingV; |
|
| 8151 | } |
|
| 8152 | } |
|
| 8153 | }); |
|
| 8154 | ||
| 8155 | var Iframe$1 = Widget.extend({ |
|