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