1(function() { 2 ASPx.HtmlEditorClasses.Managers.LayoutManager = ASPx.CreateClass(null, { 3 constructor: function(htmlEditor) { 4 this.htmlEditor = htmlEditor; 5 this.isFullscreenMode = false; 6 this.fullscreenTempVars = {}; 7 this.layoutCalculator = ASPx.GetHtmlEditorLayoutCalculator(); 8 this.isWidthDefinedInPercent = false; 9 this.initialMainElementWidth = -1; 10 this.minWidth = 0; 11 this.minHeight = 0; 12 this.maxWidth = 0; 13 this.maxHeight = 0; 14 this.currentHeight = 0; 15 this.currentWidth = 0; 16 this.resizeTempVars = {}; 17 this.inAdjusting = false; 18 this.isFirstUpdate = true; 19 this.eventManager = null; 20 }, 21 initializeEventManager: function() { 22 this.eventManager = new ASPx.HtmlEditorClasses.Managers.LayoutEventManager(this); 23 }, 24 isInFullscreen: function() { 25 return this.isFullscreenMode; 26 }, 27 getMainElement: function() { 28 return this.htmlEditor.GetMainElement(); 29 }, 30 isInAdjusting: function() { 31 return this.inAdjusting; 32 }, 33 updateLayout: function(activeView, isInitializing) { 34 if(this.getMainElement().offsetWidth == 0) 35 return; 36 this.inAdjusting = true; 37 isInitializing = !!isInitializing; 38 if(this.isFullscreenMode) 39 this.adjustSizeInFullscreen(); 40 this.layoutCalculator.updateLayout(this.htmlEditor, activeView, isInitializing); 41 this.inAdjusting = false; 42 }, 43 adjustSizeInPercent: function() { 44 this.inAdjusting = true; 45 var mainElement = this.getMainElement(); 46 var mainCell = this.htmlEditor.getMainCell(); 47 if(this.currentHeight) 48 this.percentSizeDiv.style.height = this.currentHeight + "px"; 49 this.removeChildrenFromFlow(mainCell, true); 50 var newOffsetWidth = this.percentSizeDiv.offsetWidth; 51 this.removeChildrenFromFlow(mainCell, false); 52 this.percentSizeDiv.style.height = "0px"; 53 if(this.adjustResizeTimerID){ 54 ASPx.Timer.ClearTimer(this.adjustResizeTimerID); 55 delete this.adjustResizeTimerID; 56 } 57 if(this.oldOffsetWidth != newOffsetWidth || newOffsetWidth != mainElement.offsetWidth) { 58 if(!this.percentResizeStarted || this.resizeTempVars.startMainWidth === undefined) { 59 this.saveStartSize(); 60 this.percentResizeStarted = true; 61 } 62 this.setDeltaWidthInternal(newOffsetWidth - this.resizeTempVars.startMainWidth, true); 63 } 64 this.inAdjusting = false; 65 this.oldOffsetWidth = newOffsetWidth; 66 }, 67 removeChildrenFromFlow: function(parent, remove) { 68 var elements = ASPx.GetChildElementNodes(parent); 69 for(var i = 0, l = elements.length; i < l; i++) { 70 if(ASPx.Browser.IE && ASPx.Browser.MajorVersion >= 9) 71 elements[i].style.position = remove ? "absolute" : ""; 72 else 73 ASPx.SetElementDisplay(elements[i], !remove); 74 } 75 }, 76 setDeltaSize: function() { 77 this.setDeltaWidthInternal(this.rtl 78 ? this.resizeTempVars.startSizeGripXPos - this.resizeTempVars.currentSizeGripXPos 79 : this.resizeTempVars.currentSizeGripXPos - this.resizeTempVars.startSizeGripXPos 80 ); 81 this.setDeltaHeightInternal(this.resizeTempVars.currentSizeGripYPos - this.resizeTempVars.startSizeGripYPos); 82 }, 83 setDeltaWidthInternal: function(delta, isCheckRanges) { 84 isCheckRanges = ASPx.IsExists(isCheckRanges) ? isCheckRanges : true; 85 var lastMainElementHeight = this.getMainElement().offsetHeight; 86 var width; 87 if(isCheckRanges) 88 width = this.getSizeInRanges(this.minWidth, this.maxWidth, this.resizeTempVars.startMainWidth, this.resizeTempVars.startResizeElWidth, delta); 89 else 90 width = this.resizeTempVars.startResizeElWidth + delta; 91 this.getMainElement().style.width = ""; 92 this.getCurrentEditElement().style.width = "100%"; 93 this.htmlEditor.getMainCell().firstChild.style.width = Math.max(width, 1) + "px"; 94 this.adjustInnerControls(); 95 var mainElementDeltaHeight = this.getMainElement().offsetHeight - lastMainElementHeight; 96 if(mainElementDeltaHeight != 0){ 97 this.setDeltaHeightInternal(-mainElementDeltaHeight); 98 this.resizeTempVars.startResizeElHeight -= mainElementDeltaHeight; 99 } 100 }, 101 setDeltaHeightInternal: function(delta, isCheckRanges) { 102 isCheckRanges = ASPx.IsExists(isCheckRanges) ? isCheckRanges : true; 103 var height; 104 if(isCheckRanges)
105 height = this.getSizeInRanges(this.minHeight, this.maxHeight, this.resizeTempVars.startMainHeight, this.resizeTempVars.startResizeElHeight, delta); 106 else 107 height = this.resizeTempVars.startResizeElHeight + delta; 108 this.getMainElement().style.height = ""; 109 this.htmlEditor.getEditAreaCell().style.height = ""; 110 this.setEditElementHeight(this.getCurrentEditElement(), Math.max(height, 5)); 111 if(!this.resizeTempVars.isInResize) 112 this.adjustInnerControls(); 113 }, 114 adjustInnerControls: function() { 115 if(this.htmlEditor.isHtmlView() && !this.htmlEditor.isSimpleHtmlEditingMode()) 116 this.htmlEditor.getHtmlViewWrapper().adjustControl(); 117 var tabControl = this.htmlEditor.statusBarManager.getTabControl(); 118 if(tabControl && !tabControl.GetMainElement()) 119 tabControl = null; 120 var ribbon = this.htmlEditor.barDockManager.getRibbon(); 121 if(ribbon && !ribbon.GetMainElement()) 122 ribbon = null; 123 if(tabControl && ribbon) { 124 tabControl.CollapseControl(); 125 ribbon.AdjustControlCore(); 126 tabControl.ExpandControl(); 127 tabControl.AdjustControlCore(); 128 var ribbonMarkerSize = ribbon.GetControlPercentMarkerSize(true); 129 if(ribbon.adjustedSizes.width < ribbonMarkerSize.width) 130 ribbon.AdjustControlCore(); 131 ribbon.ResetControlPercentMarkerSize(); 132 } 133 else if(tabControl) 134 tabControl.AdjustControlCore(); 135 else if(ribbon) 136 ribbon.AdjustControlCore(); 137 if(this.htmlEditor.tagInspector) 138 this.htmlEditor.tagInspector.adjustControl(); 139 }, 140 getSizeInRanges: function(minSize, maxSize, startMainElementSize, startResizeElementSize, delta) { 141 var size = startResizeElementSize + delta; 142 if(maxSize > 0 && delta > 0 && startMainElementSize + delta > maxSize){ 143 size = (maxSize - startMainElementSize + startResizeElementSize); 144 } 145 if(minSize > 0 && delta < 0 && startMainElementSize + delta < minSize){ 146 size = (minSize - startMainElementSize + startResizeElementSize); 147 } 148 return size; 149 }, 150 saveCurrentSizeGripPosition: function(evt, isSaveStart) { 151 this.resizeTempVars.currentSizeGripXPos = ASPx.Evt.GetEventX(evt); 152 this.resizeTempVars.currentSizeGripYPos = ASPx.Evt.GetEventY(evt); 153 if(isSaveStart) { 154 this.resizeTempVars.startSizeGripXPos = this.resizeTempVars.currentSizeGripXPos; 155 this.resizeTempVars.startSizeGripYPos = this.resizeTempVars.currentSizeGripYPos; 156 } 157 }, 158 saveStartSize: function() { 159 this.resizeTempVars.startResizeElWidth = ASPx.GetClearClientWidth(this.htmlEditor.getMainCell().firstChild); 160 var resizeElStyleHeight = ASPx.PxToInt(this.getCurrentEditElement().style.height); 161 var resizeElClientHeight = this.getCurrentEditElement().clientHeight; 162 this.resizeTempVars.startResizeElHeight = (resizeElStyleHeight < 1 && resizeElClientHeight >= 0) ? resizeElClientHeight : resizeElStyleHeight; 163 this.resizeTempVars.startMainWidth = this.getMainElement().offsetWidth; 164 this.resizeTempVars.startMainHeight = this.getMainElement().offsetHeight; 165 }, 166 setResizingPanelVisibility: function(visible) { 167 if(!this.resizingPanel) { 168 var html = "<div style='overflow:hidden; position: fixed; "; 169 if(ASPx.Browser.IE ){ 170 html += "background-color: White; "; 171 html += ASPx.Browser.MajorVersion < 10 ? "filter: alpha(opacity=0.1);" : "opacity: 0.01"; 172 } 173 html += "'></div>"; 174 this.resizingPanel = ASPx.CreateHtmlElementFromString(html); 175 this.htmlEditor.getStatusBarCell().appendChild(this.resizingPanel); 176 } 177 if(visible) { 178 ASPx.SetAbsoluteX(this.resizingPanel, 0); 179 ASPx.SetAbsoluteY(this.resizingPanel, 0); 180 ASPx.SetStyles(this.resizingPanel, { 181 width: ASPx.GetDocumentWidth(), 182 height: ASPx.GetDocumentHeight() 183 }); 184 } 185 ASPx.SetElementDisplay(this.resizingPanel, visible); 186 }, 187 setEditElementHeight: function(element, value) { 188 element.style.height = value + "px"; 189 if(ASPx.Browser.IE && ASPx.Browser.MajorVersion >= 11 && (this.htmlEditor.isDesignView() || this.htmlEditor.isPreview())) 190 ASPx.SetOffsetHeight(this.htmlEditor.core.getActiveWrapper().getWindow().frameElement, value); 191 }, 192 disableDynamicHeightMode: function () { 193 var el = this.getMainElement().parentNode; 194 if (el && ASPx.ElementHasCssClass(el, "dxhe-dynamic-height")) { 195 ASPx.RemoveClassNameFromElement(el, "dxhe-dynamic-height"); 196 ASPx.Attr.RemoveStyleAttribute(el, "height"); 197 } 198 }, 199 setResizeRanges: function(minWidth, minHeight, maxWidth, maxHeight) { 200 this.minWidth = minWidth; 201 this.minHeight = minHeight; 202 this.maxWidth = maxWidth; 203 this.maxHeight = maxHeight; 204 }, 205 setHeight: function(height) { 206 if(this.isInAdjusting()) return; 207 if(this.isInFullscreen()) 208 this.fullscreenTempVars.savedCurrentHeight = height; 209 else { 210 this.disableDynamicHeightMode(); 211 this.setHeightInternal(height, true); 212 this.resizeTempVars = {}; 213 } 214 }, 215 setWidth: function(width) { 216 this.isWidthDefinedInPercent = false; 217 if(this.isInAdjusting()) return; 218 if(this.isInFullscreen()) 219 this.fullscreenTempVars.savedCurrentWidth = width; 220 else { 221 this.setWidthInternal(width, true); 222 this.resizeTempVars = {}; 223 } 224 }, 225 setHeightInternal: function(height, isCheckRanges, isSaveSize) { 226 var currentEditElementHeight = this.htmlEditor.enableTagInspector ? 25 + this.htmlEditor.getTagInspectorWrapperElement().offsetHeight : 25; 227 if(this.getCurrentEditElement().offsetHeight < currentEditElementHeight) 228 this.setEditElementHeight(this.getCurrentEditElement(), currentEditElementHeight); 229 isSaveSize = ASPx.IsExists(isSaveSize) ? isSaveSize : true; 230 this.saveStartSize(); 231 if(this.resizeTempVars.startMainHeight == 0 && !this.postponedHeight) 232 this.postponedHeight = height; 233 this.setDeltaHeightInternal(height - this.resizeTempVars.startMainHeight, isCheckRanges); 234 if(isSaveSize) 235 this.saveCurrentSize(false, true, true); 236 }, 237 setWidthInternal: function(width, isCheckRanges, isSaveSize) { 238 isSaveSize = ASPx.IsExists(isSaveSize) ? isSaveSize : true; 239 this.saveStartSize(); 240 if(this.resizeTempVars.startMainWidth == 0 && !this.postponedWidth) 241 this.postponedWidth = width; 242 this.setDeltaWidthInternal(width - this.resizeTempVars.startMainWidth, isCheckRanges); 243 if(isSaveSize) 244 this.saveCurrentSize(true, false, true); 245 }, 246 restoreHeight: function(value) { 247 if(ASPx.IsExists(value)) 248 this.currentHeight = value; 249 this.setHeightInternal(this.currentHeight); 250 }, 251 restoreWidth: function(value) { 252 if(ASPx.IsExists(value)) 253 this.currentWidth = value; 254 this.setWidthInternal(this.currentWidth);
255 }, 256 saveCurrentSize: function(saveWidth, saveHeight, updateClientState, saveToCookie) { 257 var mainElement = this.getMainElement(); 258 if(saveWidth){ 259 var currentWidth = mainElement.offsetWidth; 260 if(currentWidth > 0){ 261 this.currentWidth = currentWidth; 262 if(updateClientState){ 263 this.htmlEditor.SetClientStateFieldValue("CurrentWidth", this.isWidthDefinedInPercent 264 ? Math.round(ASPx.PercentageToFloat(this.initialMainElementWidth)*100) 265 : this.currentWidth, saveToCookie); 266 this.htmlEditor.SetClientStateFieldValue("IsPercentWidth", this.isWidthDefinedInPercent ? 1 : 0, saveToCookie); 267 } 268 } 269 } 270 if(saveHeight){ 271 var currentHeight = mainElement.offsetHeight; 272 if(currentHeight > 0){ 273 this.currentHeight = currentHeight; 274 if(updateClientState){ 275 this.htmlEditor.SetClientStateFieldValue("CurrentHeight", this.currentHeight, saveToCookie); 276 } 277 } 278 } 279 }, 280 setFullscreenMode: function(enable) { 281 enable = ASPx.IsExists(enable) ? enable : !this.isFullscreenMode; 282 var sizeGrip = this.htmlEditor.getSizeGrip(); 283 this.isFullscreenMode = enable; 284 var mainElement = this.getMainElement(); 285 if(enable) { 286 ASPx.Attr.ChangeStyleAttribute(mainElement, ASPx.Browser.IE ? "borderTopWidth" : "border-top-width", "0px"); 287 ASPx.Attr.ChangeStyleAttribute(mainElement, ASPx.Browser.IE ? "borderLeftWidth" : "border-left-width", "0px"); 288 ASPx.Attr.ChangeStyleAttribute(mainElement, ASPx.Browser.IE ? "borderRightWidth" : "border-right-width", "0px"); 289 ASPx.Attr.ChangeStyleAttribute(mainElement, ASPx.Browser.IE ? "borderBottomWidth" : "border-bottom-width", "0px"); 290 this.fullscreenTempVars.savedBodyScrollTop = ASPx.GetDocumentScrollTop(); 291 this.fullscreenTempVars.savedBodyScrollLeft = ASPx.GetDocumentScrollLeft(); 292 this.showPlaceholderDiv(true); 293 ASPx.Attr.ChangeStyleAttribute(mainElement, "position", "fixed"); 294 ASPx.Attr.ChangeStyleAttribute(mainElement, "top", "0px"); 295 ASPx.Attr.ChangeStyleAttribute(mainElement, "left", "0px"); 296 ASPx.Attr.ChangeStyleAttribute(mainElement, ASPx.Browser.IE ? "zIndex" : "z-index", 10001); 297 this.hideBodyScroll(); 298 this.fullscreenTempVars.savedBodyMargin = document.body.style.margin; 299 document.body.style.margin = 0; 300 if(ASPx.Browser.IE && ASPx.Browser.MajorVersion < 8){ 301 document.documentElement.scrollTop = 0; 302 document.documentElement.scrollLeft = 0; 303 } 304 this.fullscreenTempVars.savedCurrentWidth = this.currentWidth; 305 this.fullscreenTempVars.savedCurrentHeight = this.currentHeight; 306 if(sizeGrip) 307 sizeGrip.style.visibility = "hidden"; 308 this.showCoverDiv(true); 309 this.htmlEditor.barDockManager.setExternalRibbonPositionOnPageTop(); 310 this.adjustSizeInFullscreen(); 311 } 312 else { 313 this.showCoverDiv(false); 314 ASPx.Attr.RestoreStyleAttribute(mainElement, "left"); 315 ASPx.Attr.RestoreStyleAttribute(mainElement, "top"); 316 this.restoreBodyScroll(); 317 ASPx.Attr.RestoreStyleAttribute(mainElement, ASPx.Browser.IE ? "zIndex" : "z-index"); 318 document.body.style.margin = this.fullscreenTempVars.savedBodyMargin; 319 ASPx.Attr.RestoreStyleAttribute(mainElement, "position"); 320 ASPx.Attr.RestoreStyleAttribute(mainElement, ASPx.Browser.IE ? "borderTopWidth" : "border-top-width"); 321 ASPx.Attr.RestoreStyleAttribute(mainElement, ASPx.Browser.IE ? "borderLeftWidth" : "border-left-width"); 322 ASPx.Attr.RestoreStyleAttribute(mainElement, ASPx.Browser.IE ? "borderRightWidth" : "border-right-width"); 323 ASPx.Attr.RestoreStyleAttribute(mainElement, ASPx.Browser.IE ? "borderBottomWidth" : "border-bottom-width"); 324 this.setHeightInternal(this.fullscreenTempVars.savedCurrentHeight, false, false); 325 this.setWidthInternal(this.fullscreenTempVars.savedCurrentWidth, false, false); 326 this.currentWidth = this.fullscreenTempVars.savedCurrentWidth; 327 this.currentHeight = this.fullscreenTempVars.savedCurrentHeight; 328 document.body.style.margin = this.fullscreenTempVars.savedBodyMargin; 329 document.documentElement.scrollTop = this.fullscreenTempVars.savedBodyScrollTop; 330 document.documentElement.scrollLeft = this.fullscreenTempVars.savedBodyScrollTop; 331 this.showPlaceholderDiv(false);
332 this.htmlEditor.barDockManager.restoreExternalRibbonPositionOnPage(); 333 if(sizeGrip) 334 sizeGrip.style.visibility = ""; 335 } 336 this.htmlEditor.removeFocus(true); 337 this.htmlEditor.Focus(); 338 return enable; 339 }, 340 hideBodyScroll: function() { 341 ASPx.Attr.ChangeStyleAttribute(document.documentElement, "position", "static"); 342 ASPx.Attr.ChangeStyleAttribute(document.documentElement, "overflow", "hidden"); 343 }, 344 restoreBodyScroll: function() { 345 if (!ASPx.Dialog.GetLastDialog(this.htmlEditor)) { 346 ASPx.Attr.RestoreStyleAttribute(document.documentElement, "overflow"); 347 ASPx.Attr.RestoreStyleAttribute(document.documentElement, "position"); 348 } 349 }, 350 adjustSizeInFullscreen: function() { 351 if(!this.isInFullscreen()) 352 return false; 353 this.setWidthInternal(ASPx.GetDocumentClientWidth(), false, false); 354 var height = 0; 355 var barDockManager = this.htmlEditor.barDockManager; 356 var ribbon = barDockManager.getRibbon(true); 357 if(ribbon && this.isFullscreenMode) 358 height = ribbon.GetMainElement().offsetHeight; 359 this.setHeightInternal(ASPx.GetDocumentClientHeight() - height, false, false); 360 return true; 361 }, 362 showCoverDiv: function(isShow) { 363 if(!this.coverDiv) { 364 this.coverDiv = ASPx.CreateHtmlElementFromString("<div class='dxhe-coverDiv'></div>"); 365 this.getMainElement().parentNode.insertBefore(this.coverDiv, this.getMainElement()); 366 } 367 ASPx.SetElementDisplay(this.coverDiv, isShow); 368 }, 369 showPlaceholderDiv: function(isShow) { 370 if(!this.placeholderDiv) { 371 this.placeholderDiv = ASPx.CreateHtmlElementFromString("<div style='background-color: White; display:none;'></div>"); 372 ASPx.InsertElementAfter(this.placeholderDiv, this.getMainElement()); 373 ASPx.SetStyles(this.placeholderDiv, { 374 width: this.htmlEditor.GetWidth(), 375 height: this.htmlEditor.GetHeight() 376 }); 377 } 378 ASPx.SetElementDisplay(this.placeholderDiv, isShow); 379 }, 380 getCurrentEditElement: function() { 381 if(this.htmlEditor.isDesignView()) 382 return this.htmlEditor.getDesignViewCell(); 383 if(this.htmlEditor.isHtmlView()) 384 return this.getHtmlViewEditElement(); 385 return this.htmlEditor.getPreviewCell(); 386 }, 387 collapseViewAreas: function() { 388 var designViewCell = this.htmlEditor.getDesignViewCell(); 389 var previewCell = this.htmlEditor.getPreviewCell(); 390 if(designViewCell) 391 this.setEditElementHeight(designViewCell, 0); 392 if(this.htmlEditor.isHtmlViewAllowed()) 393 this.setEditElementHeight(this.getHtmlViewEditElement(), 0); 394 if(previewCell) 395 this.setEditElementHeight(previewCell, 0); 396 if(ASPx.Browser.Edge) 397 var dummy = this.getMainElement().offsetHeight; 398 }, 399 showHideViewAreas: function(showDesignView, showHtmlView, showPreview) { 400 var designViewTable = this.htmlEditor.getDesignViewTable(); 401 var htmlViewTable = this.htmlEditor.getHtmlViewTable(); 402 var previewTable = this.htmlEditor.getPreviewTable(); 403 if(designViewTable) 404 ASPx.SetElementDisplay(designViewTable, showDesignView); 405 if(htmlViewTable) 406 ASPx.SetElementDisplay(htmlViewTable, showHtmlView); 407 if(previewTable) 408 ASPx.SetElementDisplay(previewTable, showPreview); 409 }, 410 getHtmlViewEditElement: function() { 411 var wrapper = this.htmlEditor.getHtmlViewWrapper(); 412 return this.htmlEditor.isSimpleHtmlEditingMode() ? wrapper.getInputElement() : wrapper.getMainElement(); 413 }, 414 hideViewAreas: function() { 415 this.showHideViewAreas(false, false, false); 416 }, 417 showHideViewAreasDependingOnActiveView: function(activeView) { 418 this.showHideViewAreas(this.htmlEditor.isDesignView(activeView), this.htmlEditor.isHtmlView(activeView), this.htmlEditor.isPreview(activeView)); 419 }, 420 correctSizeOnSwitchToView: function(view) { 421 ASPx.SetStyles(this.htmlEditor.getEditAreaCell(), { height: "100%", width: "100%" }); 422 this.restoreWidth(); 423 this.restoreHeight(); 424 }, 425 setPostponedSize: function() { 426 this.setPostponedWidth(); 427 this.setPostponedHeight(); 428 }, 429 setPostponedWidth: function() { 430 if(this.postponedWidth) { 431 this.setWidth(this.postponedWidth); 432 this.postponedWidth = undefined; 433 } 434 }, 435 setPostponedHeight: function() { 436 if(this.postponedHeight) { 437 this.setHeight(this.postponedHeight); 438 this.postponedHeight = undefined; 439 } 440 } 441 }); 442})(); 443
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.