diff --git a/source/viewer/domutils.js b/source/viewer/domutils.js index a800ccd..b2c87fd 100644 --- a/source/viewer/domutils.js +++ b/source/viewer/domutils.js @@ -20,9 +20,38 @@ OV.GetInnerDimensions = function (element, outerWidth, outerHeight) }; }; -OV.AddDomElement = function (parentElement, elementType) +OV.CreateDomElement = function (elementType, className, innerHTML) { - const element = document.createElement (elementType); + let element = document.createElement (elementType); + if (className) { + element.className = className; + } + if (innerHTML) { + element.innerHTML = innerHTML; + } + return element; +}; + +OV.AddDomElement = function (parentElement, elementType, className, innerHTML) +{ + let element = OV.CreateDomElement (elementType, className, innerHTML); parentElement.appendChild (element); return element; }; + +OV.ClearDomElement = function (element) +{ + while (element.firstChild) { + element.removeChild (element.firstChild); + } +}; + +OV.CreateDiv = function (className, innerHTML) +{ + return OV.CreateDomElement ('div', className, innerHTML); +}; + +OV.AddDiv = function (parentElement, className, innerHTML) +{ + return OV.AddDomElement (parentElement, 'div', className, innerHTML); +}; diff --git a/website/o3dv/css/dialogs.css b/website/o3dv/css/dialogs.css index 5261486..c864902 100644 --- a/website/o3dv/css/dialogs.css +++ b/website/o3dv/css/dialogs.css @@ -1,5 +1,14 @@ +div.ov_modal +{ + position: absolute; +} + div.ov_modal_overlay { + width: 100%; + height: 100%; + left : 0; + top : 0; position: absolute; } @@ -83,6 +92,11 @@ div.ov_dialog textarea.ov_dialog_textarea box-sizing: border-box; } +div.ov_dialog div.ov_dialog_options +{ + height: 50px; +} + div.ov_dialog div.ov_dialog_select { margin: 20px 0px; @@ -91,6 +105,7 @@ div.ov_dialog div.ov_dialog_select div.ov_dialog div.ov_dialog_select div.ov_dialog_select_option { + width: 40px; margin-right: 5px; float: left; } @@ -202,7 +217,7 @@ div.ov_progress border-radius: 5px; } -div.ov_progress svg.ov_progress_img +div.ov_progress div.ov_progress_img svg { width: 80px; height: 80px; diff --git a/website/o3dv/js/dialogs.js b/website/o3dv/js/dialogs.js index a9da64f..0a74d8d 100644 --- a/website/o3dv/js/dialogs.js +++ b/website/o3dv/js/dialogs.js @@ -9,9 +9,9 @@ OV.ShowMessageDialog = function (title, message, subMessage) } } ]); - $('
').addClass ('ov_dialog_message').html (message).appendTo (contentDiv); + OV.AddDiv (contentDiv, 'ov_dialog_message', message); if (subMessage !== null) { - $('
').addClass ('ov_dialog_submessage').html (subMessage).appendTo (contentDiv); + OV.AddDiv (contentDiv, 'ov_dialog_submessage', subMessage); } dialog.Show (); return dialog; @@ -52,22 +52,21 @@ OV.ShowListPopup = function (items, callbacks) OV.CalculatePopupPositionToElementBottomRight = function (elementDiv, contentDiv) { - let offset = elementDiv.offset (); + let offset = elementDiv.getBoundingClientRect (); return { - x : offset.left + elementDiv.outerWidth (false), - y : offset.top + elementDiv.outerHeight (false) - contentDiv.outerHeight (true) + x : offset.left + elementDiv.offsetWidth, + y : offset.top + elementDiv.offsetHeight - contentDiv.offsetHeight }; }; OV.CalculatePopupPositionToScreen = function (globalMouseCoordinates, contentDiv) { - let windowObj = $(window); - let windowWidth = windowObj.outerWidth (); - let windowHeight = windowObj.outerHeight (); + let windowWidth = window.innerWidth; + let windowHeight = window.innerHeight; let left = globalMouseCoordinates.x; let top = globalMouseCoordinates.y; - let right = left + contentDiv.outerWidth (true); - let bottom = top + contentDiv.outerHeight (true); + let right = left + contentDiv.offsetWidth; + let bottom = top + contentDiv.offsetHeight; if (right > windowWidth) { left = left - (right - windowWidth); } diff --git a/website/o3dv/js/exportdialog.js b/website/o3dv/js/exportdialog.js index de66e28..fd2c5ff 100644 --- a/website/o3dv/js/exportdialog.js +++ b/website/o3dv/js/exportdialog.js @@ -100,17 +100,15 @@ OV.ExportDialog = class ]); let text = 'Select a format from the below list to export your model. Please note that the export can take several second.'; - $('
').html (text).addClass ('ov_dialog_section').appendTo (contentDiv); + OV.AddDiv (contentDiv, 'ov_dialog_section', text); - let buttonWidth = 40; - let optionsHeight = 50; - let exportFormatSelect = $('
').addClass ('ov_dialog_select').appendTo (contentDiv); - this.formatParameters.formatSettingsDiv = $('
').addClass ('ov_dialog_section').height (optionsHeight).appendTo (contentDiv); + let exportFormatSelect = OV.AddDiv (contentDiv, 'ov_dialog_select'); + this.formatParameters.formatSettingsDiv = OV.AddDiv (contentDiv, 'ov_dialog_section ov_dialog_options'); for (let i = 0; i < this.exportFormats.length; i++) { let exportFormat = this.exportFormats[i]; - let exportFormatButton = $('
').addClass ('ov_button').addClass ('outline').addClass ('ov_dialog_select_option').html (exportFormat.name).width (buttonWidth).appendTo (exportFormatSelect); + let exportFormatButton = OV.AddDiv (exportFormatSelect, 'ov_button outline ov_dialog_select_option', exportFormat.name); this.formatParameters.exportFormatButtonDivs.push (exportFormatButton); - exportFormatButton.click (() => { + exportFormatButton.addEventListener ('click', () => { this.OnExportFormatSelect (i); }); } @@ -122,28 +120,32 @@ OV.ExportDialog = class OnExportFormatSelect (exportFormatIndex) { - this.formatParameters.formatSettingsDiv.empty (); + OV.ClearDomElement (this.formatParameters.formatSettingsDiv); for (let i = 0; i < this.formatParameters.exportFormatButtonDivs.length; i++) { let exportFormatButtonDiv = this.formatParameters.exportFormatButtonDivs[i]; if (i === exportFormatIndex) { - exportFormatButtonDiv.removeClass ('outline'); + exportFormatButtonDiv.classList.remove ('outline'); } else { - exportFormatButtonDiv.addClass ('outline'); + exportFormatButtonDiv.classList.add ('outline'); } } let exportFormat = this.exportFormats[exportFormatIndex]; for (let i = 0; i < exportFormat.formats.length; i++) { let format = exportFormat.formats[i]; - let formatDiv = $('
').addClass ('ov_dialog_row').appendTo (this.formatParameters.formatSettingsDiv); - let formatLabel = $('