Proyectos de Subversion Moodle

Rev

Autoría | Ultima modificación | Ver Log |

{"version":3,"file":"dialogue.min.js","sources":["../src/dialogue.js"],"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 <http://www.gnu.org/licenses/>.\n\n/**\n * Wrapper for the YUI M.core.notification class. Allows us to\n * use the YUI version in AMD code until it is replaced.\n *\n * @module     tool_lp/dialogue\n * @copyright  2015 Damyon Wiese <damyon@moodle.com>\n * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['core/yui'], function(Y) {\n\n    // Private variables and functions.\n    /**\n     * Constructor\n     *\n     * @param {String} title Title for the window.\n     * @param {String} content The content for the window.\n     * @param {function} afterShow Callback executed after the window is opened.\n     * @param {function} afterHide Callback executed after the window is closed.\n     * @param {Boolean} wide Specify we want an extra wide dialogue (the size is standard, but wider than the default).\n     * @param {String} height The height of the dialogue.\n     */\n    var dialogue = function(title, content, afterShow, afterHide, wide, height) {\n        M.util.js_pending('tool_lp/dialogue:dialogue');\n\n        this.yuiDialogue = null;\n        var parent = this;\n\n        // Default for wide is false.\n        if (typeof wide == 'undefined') {\n            wide = false;\n        }\n\n        Y.use('moodle-core-notification', 'timers', function() {\n            var width = '480px';\n            if (wide) {\n                width = '800px';\n            }\n\n            if (!height) {\n                height = 'auto';\n            }\n\n            parent.yuiDialogue = new M.core.dialogue({\n                headerContent: title,\n                bodyContent: content,\n                draggable: true,\n                visible: false,\n                center: true,\n                modal: true,\n                width: width,\n                height: height\n            });\n\n            parent.yuiDialogue.before('visibleChange', function() {\n                M.util.js_pending('tool_lp/dialogue:before:visibleChange');\n            });\n\n            parent.yuiDialogue.after('visibleChange', function(e) {\n                if (e.newVal) {\n                    // Delay the callback call to the next tick, otherwise it can happen that it is\n                    // executed before the dialogue constructor returns.\n                    if ((typeof afterShow !== 'undefined')) {\n                        Y.soon(function() {\n                            afterShow(parent);\n                            parent.yuiDialogue.centerDialogue();\n                            M.util.js_complete('tool_lp/dialogue:before:visibleChange');\n                        });\n                    } else {\n                        M.util.js_complete('tool_lp/dialogue:before:visibleChange');\n                    }\n                } else {\n                    if ((typeof afterHide !== 'undefined')) {\n                        Y.soon(function() {\n                            afterHide(parent);\n                            M.util.js_complete('tool_lp/dialogue:before:visibleChange');\n                        });\n                    } else {\n                        M.util.js_complete('tool_lp/dialogue:before:visibleChange');\n                    }\n                }\n            });\n\n            parent.yuiDialogue.show();\n            M.util.js_complete('tool_lp/dialogue:dialogue');\n        });\n    };\n\n    /**\n     * Close this window.\n     */\n    dialogue.prototype.close = function() {\n        this.yuiDialogue.hide();\n        this.yuiDialogue.destroy();\n    };\n\n    /**\n     * Get content.\n     * @return {node}\n     */\n    dialogue.prototype.getContent = function() {\n        return this.yuiDialogue.bodyNode.getDOMNode();\n    };\n\n    return /** @alias module:tool_lp/dialogue */ dialogue;\n});\n"],"names":["define","Y","dialogue","title","content","afterShow","afterHide","wide","height","M","util","js_pending","yuiDialogue","parent","this","use","width","core","headerContent","bodyContent","draggable","visible","center","modal","before","after","e","newVal","soon","centerDialogue","js_complete","show","prototype","close","hide","destroy","getContent","bodyNode","getDOMNode"],"mappings":";;;;;;;;AAuBAA,0BAAO,CAAC,aAAa,SAASC,OAatBC,SAAW,SAASC,MAAOC,QAASC,UAAWC,UAAWC,KAAMC,QAChEC,EAAEC,KAAKC,WAAW,kCAEbC,YAAc,SACfC,OAASC,UAGM,IAARP,OACPA,MAAO,GAGXN,EAAEc,IAAI,2BAA4B,UAAU,eACpCC,MAAQ,QACRT,OACAS,MAAQ,SAGPR,SACDA,OAAS,QAGbK,OAAOD,YAAc,IAAIH,EAAEQ,KAAKf,SAAS,CACrCgB,cAAef,MACfgB,YAAaf,QACbgB,WAAW,EACXC,SAAS,EACTC,QAAQ,EACRC,OAAO,EACPP,MAAOA,MACPR,OAAQA,SAGZK,OAAOD,YAAYY,OAAO,iBAAiB,WACvCf,EAAEC,KAAKC,WAAW,4CAGtBE,OAAOD,YAAYa,MAAM,iBAAiB,SAASC,GAC3CA,EAAEC,YAGwB,IAAdtB,UACRJ,EAAE2B,MAAK,WACHvB,UAAUQ,QACVA,OAAOD,YAAYiB,iBACnBpB,EAAEC,KAAKoB,YAAY,4CAGvBrB,EAAEC,KAAKoB,YAAY,8CAGG,IAAdxB,UACRL,EAAE2B,MAAK,WACHtB,UAAUO,QACVJ,EAAEC,KAAKoB,YAAY,4CAGvBrB,EAAEC,KAAKoB,YAAY,4CAK/BjB,OAAOD,YAAYmB,OACnBtB,EAAEC,KAAKoB,YAAY,wCAO3B5B,SAAS8B,UAAUC,MAAQ,gBAClBrB,YAAYsB,YACZtB,YAAYuB,WAOrBjC,SAAS8B,UAAUI,WAAa,kBACrBtB,KAAKF,YAAYyB,SAASC,cAGQpC"}