[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
1 YUI.add('moodle-core-languninstallconfirm', function (Y, NAME) { 2 3 /* global NAME */ 4 5 /** 6 * Home for a Confirmation class. 7 * 8 * @module moodle-core-languninstallconfirm 9 */ 10 11 /** 12 * A class for a language uninstall confirmation. 13 * 14 * @class M.core.languninstallconfirm 15 * @constructor 16 * @extends Base 17 */ 18 function Confirmation() { 19 Confirmation.superclass.constructor.apply(this, arguments); 20 } 21 22 var SELECTORS = { 23 UNINSTALLBUTTON: '#languninstallbutton', 24 UNINSTALLSELECT: '#menuuninstalllang option', 25 ENGLISHOPTION: '#menuuninstalllang option[value=\'en\']' 26 }; 27 28 Confirmation.NAME = NAME; 29 Confirmation.ATTRS = { 30 /** 31 * Uninstall url 32 * 33 * @property uninstallUrl 34 * @type string 35 */ 36 uninstallUrl: { 37 validator: Y.Lang.isString 38 } 39 }; 40 Y.extend(Confirmation, Y.Base, { 41 /** 42 * Initializer. 43 * Registers onclicks. 44 * 45 * @method initializer 46 */ 47 initializer: function() { 48 Y.one(SELECTORS.UNINSTALLBUTTON).on('click', this._confirm, this); 49 }, 50 /** 51 * Confirmation. 52 * Displays the confirmation dialogue. 53 * 54 * @method _confirm 55 * @protected 56 * @param {EventFacade} e 57 */ 58 _confirm: function(e) { 59 e.preventDefault(); 60 var selectedLangCodes = []; 61 var selectedLangNames = []; 62 63 Y.all(SELECTORS.UNINSTALLSELECT).each(function(option) { 64 if (option.get('selected')) { 65 selectedLangCodes.push(option.getAttribute('value')); 66 selectedLangNames.push(option.get('text')); 67 } 68 }); 69 // Nothing was selected, show warning. 70 if (selectedLangCodes.length === 0) { 71 new M.core.alert({message: M.util.get_string('selectlangs', 'tool_langimport')}).show(); 72 return; 73 } else if (selectedLangCodes.indexOf('en') > -1) { // Don't uninstall english. 74 Y.one(SELECTORS.ENGLISHOPTION).set('selected', false); 75 new M.core.alert({message: M.util.get_string('noenglishuninstall', 'tool_langimport')}).show(); 76 return; 77 } 78 var confirmationConfig = { 79 modal: true, 80 visible: false, 81 centered: true, 82 title: M.util.get_string('uninstall', 'tool_langimport'), 83 question: M.util.get_string('uninstallconfirm', 'tool_langimport', selectedLangNames.join(", ")) 84 }; 85 new M.core.confirm(confirmationConfig) 86 .show() 87 .on('complete-yes', this._uninstall, this, selectedLangCodes); 88 }, 89 /** 90 * Uninstall. 91 * Redirects to an uninstall process. 92 * 93 * @method _uninstall 94 * @protected 95 * @param {EventFacade} e 96 * @param {Array} langCodes array of lang codes to be uninstalled 97 */ 98 _uninstall: function(e, langCodes) { 99 Y.config.win.location.href = this.get('uninstallUrl') + '?mode=4' + 100 '&sesskey=' + M.cfg.sesskey + 101 '&confirmtouninstall=' + langCodes.join('-'); 102 } 103 104 }); 105 106 Y.namespace('M.core.languninstallconfirm').Confirmation = Confirmation; 107 Y.namespace('M.core.languninstallconfirm').init = function(config) { 108 return new Confirmation(config); 109 }; 110 111 }, '@VERSION@', {"requires": ["base", "node", "moodle-core-notification-confirm", "moodle-core-notification-alert"]});
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 |