{"version":3,"sources":["https:\/\/virtual.arte.unicen.edu.ar\/lib\/amd\/src\/modal.js"],"names":["define","$","Templates","Notification","KeyCodes","CustomEvents","ModalBackdrop","Event","ModalEvents","FocusLock","SELECTORS","CONTAINER","MODAL","HEADER","TITLE","BODY","FOOTER","HIDE","DIALOG","FORM","MENU_BAR","HAS_Z_INDEX","CAN_RECEIVE_FOCUS","TEMPLATES","LOADING","BACKDROP","backdropPromise","modalCounter","Modal","root","modal","find","header","title","body","footer","hiddenSiblings","isAttached","bodyJS","footerJS","modalCount","is","exception","message","length","registerEventListeners","prototype","attachToDOM","append","trapFocus","runTemplateJS","countOtherVisibleModals","count","each","index","element","hasClass","bind","getBackdrop","render","then","html","fail","getRoot","getModal","getTitle","getBody","getFooter","getModalCount","setTitle","value","asyncSet","setBody","notifyFilterContentUpdated","trigger","bodyRendered","jsPendingId","M","util","js_pending","contentPromise","css","state","height","innerHeight","animate","loadingIcon","hide","fadeIn","when","promise","fadeOut","js","result","isVisible","currentHeight","newHeight","opacity","duration","queue","always","js_complete","setFooter","showFooter","done","hasFooterContent","children","hideFooter","addClass","removeClass","setLarge","isLarge","setSmall","isSmall","calculateZIndex","items","zIndex","parseInt","item","itemZIndex","hasFocus","target","document","activeElement","has","hasTransitions","show","backdrop","currentIndex","newIndex","setZIndex","accessibilityShow","focus","shown","hideIfNotForm","formElement","untrapFocus","accessibilityHide","one","hidden","destroy","remove","destroyed","child","attr","data","push","sibling","previousValue","removeAttr","on","e","keyCode","escape","click","closest","events","activate","originalEvent","preventDefault","setFunction","p","hasOwnProperty","Deferred","resolve","content"],"mappings":"yQAwBAA,OAAM,cAAC,CACH,QADG,CAEH,gBAFG,CAGH,mBAHG,CAIH,gBAJG,CAKH,gCALG,CAMH,qBANG,CAOH,YAPG,CAQH,mBARG,CASH,2BATG,CAAD,CAUH,SAASC,CAAT,CAAYC,CAAZ,CAAuBC,CAAvB,CAAqCC,CAArC,CAA+CC,CAA\/C,CAA6DC,CAA7D,CAA4EC,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/E,KAAK1D,IAAL,GACA0D,CAAI,CAACa,aAAL,CAAmBC,cAAnB,EACH,CAHgE,CAG\/DtG,IAH+D,CAG1D,IAH0D,CAAjE,CAIH,CA9BD,CAwCA7B,CAAK,CAACkB,SAAN,CAAgByB,QAAhB,CAA2B,SAASD,CAAT,CAAgB0F,CAAhB,CAA6B,CACpD,GAAIC,CAAAA,CAAC,CAAG3F,CAAR,CACA,GAAqB,QAAjB,WAAOA,CAAP,GAA6B,CAACA,CAAK,CAAC4F,cAAN,CAAqB,MAArB,CAAlC,CAAgE,CAC5DD,CAAC,CAAGhK,CAAC,CAACkK,QAAF,EAAJ,CACAF,CAAC,CAACG,OAAF,CAAU9F,CAAV,CACH,CAED2F,CAAC,CAACrG,IAAF,CAAO,SAASyG,CAAT,CAAkB,CACrBL,CAAW,CAACK,CAAD,CAGd,CAJD,EAKCvG,IALD,CAKM3D,CAAY,CAACuC,SALnB,EAOA,MAAOuH,CAAAA,CACV,CAfD,CAiBA,MAAOrI,CAAAA,CACV,CAtuBK,CAAN","sourcesContent":["\/\/ This file is part of Moodle - http:\/\/moodle.org\/\n\/\/\n\/\/ Moodle is free software: you can redistribute it and\/or modify\n\/\/ it under the terms of the GNU General Public License as published by\n\/\/ the Free Software Foundation, either version 3 of the License, or\n\/\/ (at your option) any later version.\n\/\/\n\/\/ Moodle is distributed in the hope that it will be useful,\n\/\/ but WITHOUT ANY WARRANTY; without even the implied warranty of\n\/\/ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n\/\/ GNU General Public License for more details.\n\/\/\n\/\/ You should have received a copy of the GNU General Public License\n\/\/ along with Moodle. If not, see .\n\n\/**\n * Contain the logic for modals.\n *\n * @module core\/modal\n * @class modal\n * @package core\n * @copyright 2016 Ryan Wyllie \n * @license http:\/\/www.gnu.org\/copyleft\/gpl.html GNU GPL v3 or later\n *\/\ndefine([\n 'jquery',\n 'core\/templates',\n 'core\/notification',\n 'core\/key_codes',\n 'core\/custom_interaction_events',\n 'core\/modal_backdrop',\n 'core\/event',\n 'core\/modal_events',\n 'core\/local\/aria\/focuslock',\n], function($, Templates, Notification, KeyCodes, CustomEvents, ModalBackdrop, Event, ModalEvents, FocusLock) {\n\n var SELECTORS = {\n CONTAINER: '[data-region=\"modal-container\"]',\n MODAL: '[data-region=\"modal\"]',\n HEADER: '[data-region=\"header\"]',\n TITLE: '[data-region=\"title\"]',\n BODY: '[data-region=\"body\"]',\n FOOTER: '[data-region=\"footer\"]',\n HIDE: '[data-action=\"hide\"]',\n DIALOG: '[role=dialog]',\n FORM: 'form',\n MENU_BAR: '[role=menubar]',\n HAS_Z_INDEX: '.moodle-has-zindex',\n CAN_RECEIVE_FOCUS: 'input:not([type=\"hidden\"]), a[href], button, textarea, select, [tabindex]',\n };\n\n var TEMPLATES = {\n LOADING: 'core\/loading',\n BACKDROP: 'core\/modal_backdrop',\n };\n\n \/**\n * Module singleton for the backdrop to be reused by all Modal instances.\n *\/\n var backdropPromise;\n\n \/**\n * A counter that gets incremented for each modal created. This can be\n * used to generate unique values for the modals.\n *\/\n var modalCounter = 0;\n\n \/**\n * Constructor for the Modal.\n *\n * @param {object} root The root jQuery element for the modal\n *\/\n var Modal = function(root) {\n this.root = $(root);\n this.modal = this.root.find(SELECTORS.MODAL);\n this.header = this.modal.find(SELECTORS.HEADER);\n this.title = this.header.find(SELECTORS.TITLE);\n this.body = this.modal.find(SELECTORS.BODY);\n this.footer = this.modal.find(SELECTORS.FOOTER);\n this.hiddenSiblings = [];\n this.isAttached = false;\n this.bodyJS = null;\n this.footerJS = null;\n this.modalCount = modalCounter++;\n\n if (!this.root.is(SELECTORS.CONTAINER)) {\n Notification.exception({message: 'Element is not a modal container'});\n }\n\n if (!this.modal.length) {\n Notification.exception({message: 'Container does not contain a modal'});\n }\n\n if (!this.header.length) {\n Notification.exception({message: 'Modal is missing a header region'});\n }\n\n if (!this.title.length) {\n Notification.exception({message: 'Modal header is missing a title region'});\n }\n\n if (!this.body.length) {\n Notification.exception({message: 'Modal is missing a body region'});\n }\n\n if (!this.footer.length) {\n Notification.exception({message: 'Modal is missing a footer region'});\n }\n\n this.registerEventListeners();\n };\n\n \/**\n * Add the modal to the page, if it hasn't already been added. This includes running any\n * javascript that has been cached until now.\n *\n * @method attachToDOM\n *\/\n Modal.prototype.attachToDOM = function() {\n if (this.isAttached) {\n return;\n }\n\n $('body').append(this.root);\n FocusLock.trapFocus(this.root[0]);\n\n \/\/ If we'd cached any JS then we can run it how that the modal is\n \/\/ attached to the DOM.\n if (this.bodyJS) {\n Templates.runTemplateJS(this.bodyJS);\n this.bodyJS = null;\n }\n\n if (this.footerJS) {\n Templates.runTemplateJS(this.footerJS);\n this.footerJS = null;\n }\n\n this.isAttached = true;\n };\n\n \/**\n * Count the number of other visible modals (not including this one).\n *\n * @method countOtherVisibleModals\n * @return {int}\n *\/\n Modal.prototype.countOtherVisibleModals = function() {\n var count = 0;\n $('body').find(SELECTORS.CONTAINER).each(function(index, element) {\n element = $(element);\n\n \/\/ If we haven't found ourself and the element is visible.\n if (!this.root.is(element) && element.hasClass('show')) {\n count++;\n }\n }.bind(this));\n\n return count;\n };\n\n \/**\n * Get the modal backdrop.\n *\n * @method getBackdrop\n * @return {object} jQuery promise\n *\/\n Modal.prototype.getBackdrop = function() {\n if (!backdropPromise) {\n backdropPromise = Templates.render(TEMPLATES.BACKDROP, {})\n .then(function(html) {\n var element = $(html);\n\n return new ModalBackdrop(element);\n })\n .fail(Notification.exception);\n }\n\n return backdropPromise;\n };\n\n \/**\n * Get the root element of this modal.\n *\n * @method getRoot\n * @return {object} jQuery object\n *\/\n Modal.prototype.getRoot = function() {\n return this.root;\n };\n\n \/**\n * Get the modal element of this modal.\n *\n * @method getModal\n * @return {object} jQuery object\n *\/\n Modal.prototype.getModal = function() {\n return this.modal;\n };\n\n \/**\n * Get the modal title element.\n *\n * @method getTitle\n * @return {object} jQuery object\n *\/\n Modal.prototype.getTitle = function() {\n return this.title;\n };\n\n \/**\n * Get the modal body element.\n *\n * @method getBody\n * @return {object} jQuery object\n *\/\n Modal.prototype.getBody = function() {\n return this.body;\n };\n\n \/**\n * Get the modal footer element.\n *\n * @method getFooter\n * @return {object} jQuery object\n *\/\n Modal.prototype.getFooter = function() {\n return this.footer;\n };\n\n \/**\n * Get the unique modal count.\n *\n * @method getModalCount\n * @return {int}\n *\/\n Modal.prototype.getModalCount = function() {\n return this.modalCount;\n };\n\n \/**\n * Set the modal title element.\n *\n * This method is overloaded to take either a string value for the title or a jQuery promise that is resolved with\n * HTML most commonly from a Str.get_string call.\n *\n * @method setTitle\n * @param {(string|object)} value The title string or jQuery promise which resolves to the title.\n *\/\n Modal.prototype.setTitle = function(value) {\n var title = this.getTitle();\n\n this.asyncSet(value, title.html.bind(title));\n };\n\n \/**\n * Set the modal body element.\n *\n * This method is overloaded to take either a string value for the body or a jQuery promise that is resolved with\n * HTML and Javascript most commonly from a Templates.render call.\n *\n * @method setBody\n * @param {(string|object)} value The body string or jQuery promise which resolves to the body.\n *\/\n Modal.prototype.setBody = function(value) {\n var body = this.getBody();\n\n if (typeof value === 'string') {\n \/\/ Just set the value if it's a string.\n body.html(value);\n Event.notifyFilterContentUpdated(body);\n this.getRoot().trigger(ModalEvents.bodyRendered, this);\n } else {\n var jsPendingId = 'amd-modal-js-pending-id-' + this.getModalCount();\n M.util.js_pending(jsPendingId);\n \/\/ Otherwise we assume it's a promise to be resolved with\n \/\/ html and javascript.\n var contentPromise = null;\n body.css('overflow', 'hidden');\n\n if (value.state() == 'pending') {\n \/\/ We're still waiting for the body promise to resolve so\n \/\/ let's show a loading icon.\n var height = body.innerHeight();\n if (height < 100) {\n height = 100;\n }\n\n body.animate({height: height + 'px'}, 150);\n\n body.html('');\n contentPromise = Templates.render(TEMPLATES.LOADING, {})\n .then(function(html) {\n var loadingIcon = $(html).hide();\n body.html(loadingIcon);\n loadingIcon.fadeIn(150);\n\n \/\/ We only want the loading icon to fade out\n \/\/ when the content for the body has finished\n \/\/ loading.\n return $.when(loadingIcon.promise(), value);\n })\n .then(function(loadingIcon) {\n \/\/ Once the content has finished loading and\n \/\/ the loading icon has been shown then we can\n \/\/ fade the icon away to reveal the content.\n return loadingIcon.fadeOut(100).promise();\n })\n .then(function() {\n return value;\n });\n } else {\n \/\/ The content is already loaded so let's just display\n \/\/ it to the user. No need for a loading icon.\n contentPromise = value;\n }\n\n \/\/ Now we can actually display the content.\n contentPromise.then(function(html, js) {\n var result = null;\n\n if (this.isVisible()) {\n \/\/ If the modal is visible then we should display\n \/\/ the content gracefully for the user.\n body.css('opacity', 0);\n var currentHeight = body.innerHeight();\n body.html(html);\n \/\/ We need to clear any height values we've set here\n \/\/ in order to measure the height of the content being\n \/\/ added. This then allows us to animate the height\n \/\/ transition.\n body.css('height', '');\n var newHeight = body.innerHeight();\n body.css('height', currentHeight + 'px');\n result = body.animate(\n {height: newHeight + 'px', opacity: 1},\n {duration: 150, queue: false}\n ).promise();\n } else {\n \/\/ Since the modal isn't visible we can just immediately\n \/\/ set the content. No need to animate it.\n body.html(html);\n }\n\n if (js) {\n if (this.isAttached) {\n \/\/ If we're in the DOM then run the JS immediately.\n Templates.runTemplateJS(js);\n } else {\n \/\/ Otherwise cache it to be run when we're attached.\n this.bodyJS = js;\n }\n }\n\n return result;\n }.bind(this))\n .then(function(result) {\n Event.notifyFilterContentUpdated(body);\n this.getRoot().trigger(ModalEvents.bodyRendered, this);\n return result;\n }.bind(this))\n .fail(Notification.exception)\n .always(function() {\n \/\/ When we're done displaying all of the content we need\n \/\/ to clear the custom values we've set here.\n body.css('height', '');\n body.css('overflow', '');\n body.css('opacity', '');\n M.util.js_complete(jsPendingId);\n\n return;\n })\n .fail(Notification.exception);\n }\n };\n\n \/**\n * Set the modal footer element. The footer element is made visible, if it\n * isn't already.\n *\n * This method is overloaded to take either a string\n * value for the body or a jQuery promise that is resolved with HTML and Javascript\n * most commonly from a Templates.render call.\n *\n * @method setFooter\n * @param {(string|object)} value The footer string or jQuery promise\n *\/\n Modal.prototype.setFooter = function(value) {\n \/\/ Make sure the footer is visible.\n this.showFooter();\n\n var footer = this.getFooter();\n\n if (typeof value === 'string') {\n \/\/ Just set the value if it's a string.\n footer.html(value);\n } else {\n \/\/ Otherwise we assume it's a promise to be resolved with\n \/\/ html and javascript.\n Templates.render(TEMPLATES.LOADING, {}).done(function(html) {\n footer.html(html);\n\n value.done(function(html, js) {\n footer.html(html);\n\n if (js) {\n if (this.isAttached) {\n \/\/ If we're in the DOM then run the JS immediately.\n Templates.runTemplateJS(js);\n } else {\n \/\/ Otherwise cache it to be run when we're attached.\n this.footerJS = js;\n }\n }\n }.bind(this));\n }.bind(this));\n }\n };\n\n \/**\n * Check if the footer has any content in it.\n *\n * @method hasFooterContent\n * @return {bool}\n *\/\n Modal.prototype.hasFooterContent = function() {\n return this.getFooter().children().length ? true : false;\n };\n\n \/**\n * Hide the footer element.\n *\n * @method hideFooter\n *\/\n Modal.prototype.hideFooter = function() {\n this.getFooter().addClass('hidden');\n };\n\n \/**\n * Show the footer element.\n *\n * @method showFooter\n *\/\n Modal.prototype.showFooter = function() {\n this.getFooter().removeClass('hidden');\n };\n\n \/**\n * Mark the modal as a large modal.\n *\n * @method setLarge\n *\/\n Modal.prototype.setLarge = function() {\n if (this.isLarge()) {\n return;\n }\n\n this.getModal().addClass('modal-lg');\n };\n\n \/**\n * Check if the modal is a large modal.\n *\n * @method isLarge\n * @return {bool}\n *\/\n Modal.prototype.isLarge = function() {\n return this.getModal().hasClass('modal-lg');\n };\n\n \/**\n * Mark the modal as a small modal.\n *\n * @method setSmall\n *\/\n Modal.prototype.setSmall = function() {\n if (this.isSmall()) {\n return;\n }\n\n this.getModal().removeClass('modal-lg');\n };\n\n \/**\n * Check if the modal is a small modal.\n *\n * @method isSmall\n * @return {bool}\n *\/\n Modal.prototype.isSmall = function() {\n return !this.getModal().hasClass('modal-lg');\n };\n\n \/**\n * Determine the highest z-index value currently on the page.\n *\n * @method calculateZIndex\n * @return {int}\n *\/\n Modal.prototype.calculateZIndex = function() {\n var items = $(SELECTORS.DIALOG + ', ' + SELECTORS.MENU_BAR + ', ' + SELECTORS.HAS_Z_INDEX);\n var zIndex = parseInt(this.root.css('z-index'));\n\n items.each(function(index, item) {\n item = $(item);\n \/\/ Note that webkit browsers won't return the z-index value from the CSS stylesheet\n \/\/ if the element doesn't have a position specified. Instead it'll return \"auto\".\n var itemZIndex = item.css('z-index') ? parseInt(item.css('z-index')) : 0;\n\n if (itemZIndex > zIndex) {\n zIndex = itemZIndex;\n }\n });\n\n return zIndex;\n };\n\n \/**\n * Check if this modal is visible.\n *\n * @method isVisible\n * @return {bool}\n *\/\n Modal.prototype.isVisible = function() {\n return this.root.hasClass('show');\n };\n\n \/**\n * Check if this modal has focus.\n *\n * @method hasFocus\n * @return {bool}\n *\/\n Modal.prototype.hasFocus = function() {\n var target = $(document.activeElement);\n return this.root.is(target) || this.root.has(target).length;\n };\n\n \/**\n * Check if this modal has CSS transitions applied.\n *\n * @method hasTransitions\n * @return {bool}\n *\/\n Modal.prototype.hasTransitions = function() {\n return this.getRoot().hasClass('fade');\n };\n\n \/**\n * Display this modal. The modal will be attached to the DOM if it hasn't\n * already been.\n *\n * @method show\n *\/\n Modal.prototype.show = function() {\n if (this.isVisible()) {\n return;\n }\n\n if (this.hasFooterContent()) {\n this.showFooter();\n } else {\n this.hideFooter();\n }\n\n if (!this.isAttached) {\n this.attachToDOM();\n }\n\n this.getBackdrop().done(function(backdrop) {\n var currentIndex = this.calculateZIndex();\n var newIndex = currentIndex + 2;\n var newBackdropIndex = newIndex - 1;\n this.root.css('z-index', newIndex);\n backdrop.setZIndex(newBackdropIndex);\n backdrop.show();\n\n this.root.removeClass('hide').addClass('show');\n this.accessibilityShow();\n this.getModal().focus();\n $('body').addClass('modal-open');\n this.root.trigger(ModalEvents.shown, this);\n }.bind(this));\n };\n\n \/**\n * Hide this modal if it does not contain a form.\n *\n * @method hideIfNotForm\n *\/\n Modal.prototype.hideIfNotForm = function() {\n var formElement = this.modal.find(SELECTORS.FORM);\n if (formElement.length == 0) {\n this.hide();\n }\n };\n\n \/**\n * Hide this modal.\n *\n * @method hide\n *\/\n Modal.prototype.hide = function() {\n this.getBackdrop().done(function(backdrop) {\n FocusLock.untrapFocus();\n if (!this.countOtherVisibleModals()) {\n \/\/ Hide the backdrop if we're the last open modal.\n backdrop.hide();\n $('body').removeClass('modal-open');\n }\n\n var currentIndex = parseInt(this.root.css('z-index'));\n this.root.css('z-index', '');\n backdrop.setZIndex(currentIndex - 3);\n\n this.accessibilityHide();\n\n if (this.hasTransitions()) {\n \/\/ Wait for CSS transitions to complete before hiding the element.\n this.getRoot().one('transitionend webkitTransitionEnd oTransitionEnd', function() {\n this.getRoot().removeClass('show').addClass('hide');\n }.bind(this));\n } else {\n this.getRoot().removeClass('show').addClass('hide');\n }\n\n this.root.trigger(ModalEvents.hidden, this);\n }.bind(this));\n };\n\n \/**\n * Remove this modal from the DOM.\n *\n * @method destroy\n *\/\n Modal.prototype.destroy = function() {\n this.root.remove();\n this.root.trigger(ModalEvents.destroyed, this);\n };\n\n \/**\n * Sets the appropriate aria attributes on this dialogue and the other\n * elements in the DOM to ensure that screen readers are able to navigate\n * the dialogue popup correctly.\n *\n * @method accessibilityShow\n *\/\n Modal.prototype.accessibilityShow = function() {\n \/\/ We need to get a list containing each sibling element and the shallowest\n \/\/ non-ancestral nodes in the DOM. We can shortcut this a little by leveraging\n \/\/ the fact that this dialogue is always appended to the document body therefore\n \/\/ it's siblings are the shallowest non-ancestral nodes. If that changes then\n \/\/ this code should also be updated.\n $('body').children().each(function(index, child) {\n \/\/ Skip the current modal.\n if (!this.root.is(child)) {\n child = $(child);\n var hidden = child.attr('aria-hidden');\n \/\/ If they are already hidden we can ignore them.\n if (hidden !== 'true') {\n \/\/ Save their current state.\n child.data('previous-aria-hidden', hidden);\n this.hiddenSiblings.push(child);\n\n \/\/ Hide this node from screen readers.\n child.attr('aria-hidden', 'true');\n }\n }\n }.bind(this));\n\n \/\/ Make us visible to screen readers.\n this.root.attr('aria-hidden', 'false');\n };\n\n \/**\n * Restores the aria visibility on the DOM elements changed when displaying\n * the dialogue popup and makes the dialogue aria hidden to allow screen\n * readers to navigate the main page correctly when the dialogue is closed.\n *\n * @method accessibilityHide\n *\/\n Modal.prototype.accessibilityHide = function() {\n this.root.attr('aria-hidden', 'true');\n\n \/\/ Restore the sibling nodes back to their original values.\n $.each(this.hiddenSiblings, function(index, sibling) {\n sibling = $(sibling);\n var previousValue = sibling.data('previous-aria-hidden');\n \/\/ If the element didn't previously have an aria-hidden attribute\n \/\/ then we can just remove the one we set.\n if (typeof previousValue == 'undefined') {\n sibling.removeAttr('aria-hidden');\n } else {\n \/\/ Otherwise set it back to the old value (which will be false).\n sibling.attr('aria-hidden', previousValue);\n }\n });\n\n \/\/ Clear the cache. No longer need to store these.\n this.hiddenSiblings = [];\n };\n\n \/**\n * Set up all of the event handling for the modal.\n *\n * @method registerEventListeners\n *\/\n Modal.prototype.registerEventListeners = function() {\n this.getRoot().on('keydown', function(e) {\n if (!this.isVisible()) {\n return;\n }\n\n if (e.keyCode == KeyCodes.escape) {\n this.hide();\n }\n }.bind(this));\n\n \/\/ Listen for clicks on the modal container.\n this.getRoot().click(function(e) {\n \/\/ If the click wasn't inside the modal element then we should\n \/\/ hide the modal.\n if (!$(e.target).closest(SELECTORS.MODAL).length) {\n \/\/ The check above fails to detect the click was inside the modal when the DOM tree is already changed.\n \/\/ So, we check if we can still find the container element or not. If not, then the DOM tree is changed.\n \/\/ It's best not to hide the modal in that case.\n if ($(e.target).closest(SELECTORS.CONTAINER).length) {\n this.hideIfNotForm();\n }\n }\n }.bind(this));\n\n CustomEvents.define(this.getModal(), [CustomEvents.events.activate]);\n this.getModal().on(CustomEvents.events.activate, SELECTORS.HIDE, function(e, data) {\n this.hide();\n data.originalEvent.preventDefault();\n }.bind(this));\n };\n\n \/**\n * Set or resolve and set the value using the function.\n *\n * @method asyncSet\n * @param {(string|object)} value The string or jQuery promise.\n * @param {function} setFunction The setter\n * @return {Promise}\n *\/\n Modal.prototype.asyncSet = function(value, setFunction) {\n var p = value;\n if (typeof value !== 'object' || !value.hasOwnProperty('then')) {\n p = $.Deferred();\n p.resolve(value);\n }\n\n p.then(function(content) {\n setFunction(content);\n\n return;\n })\n .fail(Notification.exception);\n\n return p;\n };\n\n return Modal;\n});\n"],"file":"modal.min.js"}