diff --git a/editor/ui/dialogs/content/EdDialogCommon.js b/editor/ui/dialogs/content/EdDialogCommon.js index aeeeec9e8ccf..09a68b591932 100644 --- a/editor/ui/dialogs/content/EdDialogCommon.js +++ b/editor/ui/dialogs/content/EdDialogCommon.js @@ -243,10 +243,45 @@ function SetTextboxFocus(textbox) function ShowInputErrorMessage(message) { - editorShell.AlertWithTitle(GetString("InputError"), message); + AlertWithTitle(GetString("InputError"), message); window.focus(); } +function AlertWithTitle(title, message) +{ + var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(); + promptService = promptService.QueryInterface(Components.interfaces.nsIPromptService); + + if (promptService) + { + if (!title) + title = GetString("Alert"); + + // "window" is the calling dialog window + promptService.alert(window, title, message); + } +} + +// Optional: Caller may supply text to substitue for "Ok" and/or "Cancel" +function ConfirmWithTitle(title, message, okButtonText, cancelButtonText) +{ + var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(); + promptService = promptService.QueryInterface(Components.interfaces.nsIPromptService); + + if (promptService) + { + var result = {value:0}; + var okFlag = okButtonText ? promptService.BUTTON_TITLE_IS_STRING : promptService.BUTTON_TITLE_OK; + var cancelFlag = cancelButtonText ? promptService.BUTTON_TITLE_IS_STRING : promptService.BUTTON_TITLE_CANCEL; + + promptService.confirmEx(window, title, message, + (okFlag * promptService.BUTTON_POS_0) + + (cancelFlag * promptService.BUTTON_POS_1), + okButtonText, cancelButtonText, null, null, {value:0}, result); + return (result.value == 0); + } +} + function GetString(name) { if (editorShell) diff --git a/editor/ui/dialogs/content/EdImageProps.js b/editor/ui/dialogs/content/EdImageProps.js index 89bba07ea204..705fb5bddfff 100644 --- a/editor/ui/dialogs/content/EdImageProps.js +++ b/editor/ui/dialogs/content/EdImageProps.js @@ -510,7 +510,7 @@ function ValidateData() { if ( !IsValidImage(dialog.srcInput.value)) { - editorShell.AlertWithTitle(GetString("Alert"), GetString("MissingImageError")); + AlertWithTitle(null, GetString("MissingImageError")); window.focus(); return false; } @@ -526,7 +526,7 @@ function ValidateData() var alt = dialog.altTextInput.value; if (doAltTextError && !alt) { - ShowInputErrorMessage(GetString("NoAltText")); + AlertWithTitle(null, GetString("NoAltText")); SetTextboxFocus(dialog.altTextInput); doAltTextError = false; return false; diff --git a/editor/ui/dialogs/content/EdTableProps.js b/editor/ui/dialogs/content/EdTableProps.js index 5ae5212b3d5a..35383c7736c3 100644 --- a/editor/ui/dialogs/content/EdTableProps.js +++ b/editor/ui/dialogs/content/EdTableProps.js @@ -795,6 +795,22 @@ function ValidateTableData() newColCount = Number(ValidateNumber(dialog.TableColumnsInput, null, 1, maxColumns, null, null, true)); if (gValidationError) return false; + // If user is deleting any cells, get confirmation + // (This is a global to the dialog and we ask only once per dialog session) + if ( !canDelete && + (newRowCount < rowCount || + newColCount < colCount) && + ConfirmWithTitle(GetString("DeleteTableTitle"), + GetString("DeleteTableMsg"), + GetString("DeleteCells")) ) + { + canDelete = true; + } + else + { + SetTextboxFocus(newRowCount < rowCount ? dialog.TableRowsInput : dialog.TableColumnsInput); + return false; + } ValidateNumber(dialog.TableWidthInput, dialog.TableWidthUnits, 1, maxPixels, globalTableElement, "width"); @@ -944,16 +960,6 @@ function CloneAttribute(destElement, srcElement, attr) editorShell.SetAttribute(destElement, attr, value); } -function ConfirmDeleteCells() -{ - if (0 == editorShell.ConfirmWithTitle(GetString("DeleteTableTitle"), GetString("DeleteTableMsg"), - GetString("DeleteCells"), "")) - { - return true; - } - return false; -} - function ApplyTableAttributes() { var newAlign = dialog.TableCaptionList.selectedItem.value; @@ -1001,16 +1007,6 @@ function ApplyTableAttributes() var foundcell; var i; - // If user is deleting any cells and get confirmation - // (This is a global to the dialog and we ask only once per dialog session) - if ( !canDelete && - (newRowCount < rowCount || - newColCount < colCount) && - ConfirmDeleteCells() ) - { - canDelete = true; - } - if (newRowCount != rowCount) { countDelta = newRowCount - rowCount;