"),this.$document=$(this.getElementDocument()),this.$element.on("mousedown",this.onMouseDown.bind(this)),this.$head.addClass("oo-ui-window-head"),this.$body.addClass("oo-ui-window-body"),this.$foot.addClass("oo-ui-window-foot"),this.$content.append(this.$head,this.$body,this.$foot),this},r.ui.Window.prototype.onFocusTrapFocused=function(t){var e=this.$focusTrapBefore.is(t.target),i=r.ui.findFocusable(this.$content,e);i?i.focus():this.$content.trigger("focus")},r.ui.Window.prototype.open=function(t){if(!this.manager)throw new Error("Cannot open window, must be attached to a manager");return this.manager.openWindow(this,t)},r.ui.Window.prototype.close=function(t){if(!this.manager)throw new Error("Cannot close window, must be attached to a manager");return this.manager.closeWindow(this,t)},r.ui.Window.prototype.setup=function(t){var e=this;return this.toggle(!0),this.focusTrapHandler=r.ui.bind(this.onFocusTrapFocused,this),this.$focusTraps.on("focus",this.focusTrapHandler),this.getSetupProcess(t).execute().then(function(){e.updateSize(),e.$element.addClass("oo-ui-window-active oo-ui-window-setup").width(),e.$content.addClass("oo-ui-window-content-setup").width()})},r.ui.Window.prototype.ready=function(t){var e=this;return this.$content.trigger("focus"),this.getReadyProcess(t).execute().then(function(){e.$element.addClass("oo-ui-window-ready").width(),e.$content.addClass("oo-ui-window-content-ready").width()})},r.ui.Window.prototype.hold=function(t){var e=this;return this.getHoldProcess(t).execute().then(function(){var t=e.$content.find(r.ui.Element.static.getDocument(e.$content).activeElement);t.length&&t[0].blur(),e.$element.removeClass("oo-ui-window-ready oo-ui-window-setup").width(),e.$content.removeClass("oo-ui-window-content-ready oo-ui-window-content-setup").width()})},r.ui.Window.prototype.teardown=function(t){var e=this;return this.getTeardownProcess(t).execute().then(function(){e.$element.removeClass("oo-ui-window-active").width(),e.$focusTraps.off("focus",e.focusTrapHandler),e.toggle(!1)})},r.ui.Dialog=function(t){r.ui.Dialog.parent.call(this,t),r.ui.mixin.PendingElement.call(this),this.actions=new r.ui.ActionSet,this.attachedActions=[],this.currentAction=null,this.onDialogKeyDownHandler=this.onDialogKeyDown.bind(this),this.actions.connect(this,{click:"onActionClick",change:"onActionsChange"}),this.$element.addClass("oo-ui-dialog").attr("role","dialog")},r.inheritClass(r.ui.Dialog,r.ui.Window),r.mixinClass(r.ui.Dialog,r.ui.mixin.PendingElement),r.ui.Dialog.static.name="",r.ui.Dialog.static.title="",r.ui.Dialog.static.actions=[],r.ui.Dialog.static.escapable=!0,r.ui.Dialog.prototype.onDialogKeyDown=function(t){var e;t.which===r.ui.Keys.ESCAPE&&this.constructor.static.escapable?(this.executeAction(""),t.preventDefault(),t.stopPropagation()):t.which===r.ui.Keys.ENTER&&(t.ctrlKey||t.metaKey)&&0<(e=this.actions.get({flags:"primary",visible:!0,disabled:!1})).length&&(this.executeAction(e[0].getAction()),t.preventDefault(),t.stopPropagation())},r.ui.Dialog.prototype.onActionClick=function(t){this.isPending()||this.executeAction(t.getAction())},r.ui.Dialog.prototype.onActionsChange=function(){this.detachActions(),this.isClosing()||(this.attachActions(),this.isOpening()||this.updateSize())},r.ui.Dialog.prototype.getActions=function(){return this.actions},r.ui.Dialog.prototype.getActionProcess=function(t){return(new r.ui.Process).next(function(){t||this.close()},this)},r.ui.Dialog.prototype.getSetupProcess=function(o){return o=o||{},r.ui.Dialog.parent.prototype.getSetupProcess.call(this,o).next(function(){var t=this.constructor.static,e=void 0!==o.actions?o.actions:t.actions,i=void 0!==o.title?o.title:t.title;this.title.setLabel(i).setTitle(i),this.actions.add(this.getActionWidgets(e)),this.$element.on("keydown",this.onDialogKeyDownHandler)},this)},r.ui.Dialog.prototype.getTeardownProcess=function(t){return r.ui.Dialog.parent.prototype.getTeardownProcess.call(this,t).first(function(){this.$element.off("keydown",this.onDialogKeyDownHandler),this.actions.clear(),this.currentAction=null},this)},r.ui.Dialog.prototype.initialize=function(){r.ui.Dialog.parent.prototype.initialize.call(this),this.title=new r.ui.LabelWidget,this.$content.addClass("oo-ui-dialog-content"),this.$element.attr("aria-labelledby",this.title.getElementId()),this.setPendingElement(this.$head)},r.ui.Dialog.prototype.getActionWidgets=function(t){var e,i,o=[];for(e=0,i=t.length;e
"),this.container=new r.ui.PanelLayout({scrollable:!0,classes:["oo-ui-messageDialog-container"]}),this.text=new r.ui.PanelLayout({padded:!0,expanded:!1,classes:["oo-ui-messageDialog-text"]}),this.message=new r.ui.LabelWidget({classes:["oo-ui-messageDialog-message"]}),this.title.$element.addClass("oo-ui-messageDialog-title"),this.$content.addClass("oo-ui-messageDialog-content"),this.container.$element.append(this.text.$element),this.text.$element.append(this.title.$element,this.message.$element),this.$body.append(this.container.$element),this.$actions.addClass("oo-ui-messageDialog-actions"),this.$foot.append(this.$actions)},r.ui.MessageDialog.prototype.getActionWidgetConfig=function(t){return $.extend({},t,{framed:!1})},r.ui.MessageDialog.prototype.attachActions=function(){var t,e,i,o;for(r.ui.MessageDialog.parent.prototype.attachActions.call(this),i=this.actions.getSpecial(),o=this.actions.getOthers(),i.safe&&(this.$actions.append(i.safe.$element),i.safe.toggleFramed(!0)),t=0,e=o.length;ti.$element[0].clientWidth){this.toggleVerticalActionLayout(!0);break}this.$body.css("bottom",this.$foot.outerHeight(!0)),this.verticalActionLayout!==o&&this.updateSize()},r.ui.ProcessDialog=function(t){r.ui.ProcessDialog.parent.call(this,t),this.fitOnOpen=!1,this.$element.addClass("oo-ui-processDialog"),r.ui.isMobile()&&this.$element.addClass("oo-ui-isMobile")},r.inheritClass(r.ui.ProcessDialog,r.ui.Dialog),r.ui.ProcessDialog.prototype.onDismissErrorButtonClick=function(){this.hideErrors()},r.ui.ProcessDialog.prototype.onRetryButtonClick=function(){this.hideErrors(),this.executeAction(this.currentAction)},r.ui.ProcessDialog.prototype.initialize=function(){r.ui.ProcessDialog.parent.prototype.initialize.call(this),this.$navigation=$(""),this.$location=$("
"),this.$safeActions=$("
"),this.$primaryActions=$("
"),this.$otherActions=$("
"),this.dismissButton=new r.ui.ButtonWidget({label:r.ui.msg("ooui-dialog-process-dismiss")}),this.retryButton=new r.ui.ButtonWidget,this.$errors=$("
"),this.$errorsTitle=$("
"),this.dismissButton.connect(this,{click:"onDismissErrorButtonClick"}),this.retryButton.connect(this,{click:"onRetryButtonClick"}),this.title.connect(this,{labelChange:"fitLabel"}),this.title.$element.addClass("oo-ui-processDialog-title"),this.$location.append(this.title.$element).addClass("oo-ui-processDialog-location"),this.$safeActions.addClass("oo-ui-processDialog-actions-safe"),this.$primaryActions.addClass("oo-ui-processDialog-actions-primary"),this.$otherActions.addClass("oo-ui-processDialog-actions-other"),this.$errorsTitle.addClass("oo-ui-processDialog-errors-title").text(r.ui.msg("ooui-dialog-process-error")),this.$errors.addClass("oo-ui-processDialog-errors oo-ui-element-hidden").append(this.$errorsTitle,this.dismissButton.$element,this.retryButton.$element),this.$content.addClass("oo-ui-processDialog-content").append(this.$errors),this.$navigation.addClass("oo-ui-processDialog-navigation").append(this.$primaryActions,this.$location,this.$safeActions),this.$head.append(this.$navigation),this.$foot.append(this.$otherActions)},r.ui.ProcessDialog.prototype.getActionWidgetConfig=function(e){function t(t){return e.flags===t||Array.isArray(e.flags)&&-1!==e.flags.indexOf(t)}return e=$.extend({framed:!0},e),t("close")?$.extend(e,{icon:"close",invisibleLabel:!0}):t("back")&&$.extend(e,{icon:"previous",invisibleLabel:!0}),e},r.ui.ProcessDialog.prototype.attachActions=function(){var t,e,i,o,n;for(r.ui.ProcessDialog.parent.prototype.attachActions.call(this),o=this.actions.getSpecial(),n=this.actions.getOthers(),o.primary&&this.$primaryActions.append(o.primary.$element),t=0,e=n.length;t").addClass("oo-ui-processDialog-error").append(t[e].getMessage()),s.push(o[0]);this.$errorItems=$(s),u?(l[this.currentAction]=!0,(n=this.actions.get({actions:this.currentAction})).length&&this.retryButton.clearFlags().setFlags(n[0].getFlags())):(l[this.currentAction]=!1,this.actions.setAbilities(l)),a?this.retryButton.setLabel(r.ui.msg("ooui-dialog-process-continue")):this.retryButton.setLabel(r.ui.msg("ooui-dialog-process-retry")),this.retryButton.toggle(u),this.$errorsTitle.after(this.$errorItems),this.$errors.removeClass("oo-ui-element-hidden").scrollTop(0)},r.ui.ProcessDialog.prototype.hideErrors=function(){this.$errors.addClass("oo-ui-element-hidden"),this.$errorItems&&(this.$errorItems.remove(),this.$errorItems=null)},r.ui.ProcessDialog.prototype.getTeardownProcess=function(t){return r.ui.ProcessDialog.parent.prototype.getTeardownProcess.call(this,t).first(function(){this.hideErrors(),this.fitOnOpen=!1},this)},r.ui.getWindowManager=function(){return r.ui.windowManager||(r.ui.windowManager=new r.ui.WindowManager,$(document.body).append(r.ui.windowManager.$element),r.ui.windowManager.addWindows([new r.ui.MessageDialog])),r.ui.windowManager},r.ui.alert=function(t,e){return r.ui.getWindowManager().openWindow("message",$.extend({message:t,actions:[r.ui.MessageDialog.static.actions[0]]},e)).closed.then(function(){})},r.ui.confirm=function(t,e){return r.ui.getWindowManager().openWindow("message",$.extend({message:t},e)).closed.then(function(t){return!(!t||"accept"!==t.action)})},r.ui.prompt=function(t,e){var i,o=r.ui.getWindowManager(),n=new r.ui.TextInputWidget(e&&e.textInput||{}),s=new r.ui.FieldLayout(n,{align:"top",label:t});return(i=o.openWindow("message",$.extend({message:s.$element},e))).opened.then(function(){n.on("enter",function(){o.getCurrentWindow().close({action:"accept"})}),n.focus()}),i.closed.then(function(t){return t&&"accept"===t.action?n.getValue():null})}}(OO);