[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
1 // This file is part of Moodle - http://moodle.org/ 2 // 3 // Moodle is free software: you can redistribute it and/or modify 4 // it under the terms of the GNU General Public License as published by 5 // the Free Software Foundation, either version 3 of the License, or 6 // (at your option) any later version. 7 // 8 // Moodle is distributed in the hope that it will be useful, 9 // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 // GNU General Public License for more details. 12 // 13 // You should have received a copy of the GNU General Public License 14 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 15 16 /** 17 * Wrapper for the YUI M.core.notification class. Allows us to 18 * use the YUI version in AMD code until it is replaced. 19 * 20 * @module tool_lp/dialogue 21 * @package tool_lp 22 * @copyright 2015 Damyon Wiese <damyon@moodle.com> 23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 24 */ 25 define(['core/yui'], function(Y) { 26 27 // Private variables and functions. 28 /** 29 * Constructor 30 * 31 * @param {String} title Title for the window. 32 * @param {String} content The content for the window. 33 * @param {function} afterShow Callback executed after the window is opened. 34 * @param {function} afterHide Callback executed after the window is closed. 35 * @param {Boolean} wide Specify we want an extra wide dialogue (the size is standard, but wider than the default). 36 */ 37 var dialogue = function(title, content, afterShow, afterHide, wide) { 38 this.yuiDialogue = null; 39 var parent = this; 40 41 // Default for wide is false. 42 if (typeof wide == 'undefined') { 43 wide = false; 44 } 45 46 Y.use('moodle-core-notification', 'timers', function() { 47 var width = '480px'; 48 if (wide) { 49 width = '800px'; 50 } 51 52 parent.yuiDialogue = new M.core.dialogue({ 53 headerContent: title, 54 bodyContent: content, 55 draggable: true, 56 visible: false, 57 center: true, 58 modal: true, 59 width: width 60 }); 61 62 parent.yuiDialogue.after('visibleChange', function(e) { 63 if (e.newVal) { 64 // Delay the callback call to the next tick, otherwise it can happen that it is 65 // executed before the dialogue constructor returns. 66 if ((typeof afterShow !== 'undefined')) { 67 Y.soon(function() { 68 afterShow(parent); 69 parent.yuiDialogue.centerDialogue(); 70 }); 71 } 72 } else { 73 if ((typeof afterHide !== 'undefined')) { 74 Y.soon(function() { 75 afterHide(parent); 76 }); 77 } 78 } 79 }); 80 81 parent.yuiDialogue.show(); 82 }); 83 }; 84 85 /** 86 * Close this window. 87 */ 88 dialogue.prototype.close = function() { 89 this.yuiDialogue.hide(); 90 this.yuiDialogue.destroy(); 91 }; 92 93 /** 94 * Get content. 95 * @return {node} 96 */ 97 dialogue.prototype.getContent = function() { 98 return this.yuiDialogue.bodyNode.getDOMNode(); 99 }; 100 101 return /** @alias module:tool_lp/dialogue */ dialogue; 102 });
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Aug 11 10:00:09 2016 | Cross-referenced by PHPXref 0.7.1 |