[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
1 /** 2 * Add a confirmation dialogue when cancelling a backup. 3 * 4 * @module moodle-backup-confirmcancel 5 */ 6 7 /** 8 * Add a confirmation dialogue when cancelling a backup. 9 * 10 * @class M.core_backup.confirmcancel 11 */ 12 13 14 // Namespace for the backup. 15 M.core_backup = M.core_backup || {}; 16 17 M.core_backup.confirmcancel = { 18 /** 19 * An array of EventHandlers which call the confirm_cancel dialogue. 20 * 21 * @property listeners 22 * @protected 23 * @type Array 24 */ 25 listeners: [], 26 27 /** 28 * The configuration supplied to this instance. 29 * 30 * @property config 31 * @protected 32 * @type Object 33 */ 34 config: {}, 35 36 /** 37 * Initializer to watch all cancel buttons. 38 * 39 * @method watch_cancel_buttons 40 * @param {Object} config The configuration for the confirmation dialogue. 41 */ 42 watch_cancel_buttons: function(config) { 43 this.config = config; 44 45 this.listeners.push( 46 Y.one(Y.config.doc.body).delegate('click', this.confirm_cancel, '.confirmcancel', this) 47 ); 48 }, 49 50 /** 51 * Display the confirmation dialogue. 52 * 53 * @method confirm_cancel 54 * @protected 55 * @param {EventFacade} e 56 */ 57 confirm_cancel: function(e) { 58 // Prevent the default event (submit) from firing. 59 e.preventDefault(); 60 61 // Create the confirmation dialogue. 62 var confirm = new M.core.confirm(this.config); 63 64 // If the user clicks yes. 65 confirm.on('complete-yes', function() { 66 // Detach the listeners for the confirm box so they don't fire again. 67 new Y.EventHandle(M.core_backup.confirmcancel.listeners).detach(); 68 69 // Simulate the original cancel button click. 70 e.currentTarget.simulate('click'); 71 }, this); 72 73 74 // Show the confirm box. 75 confirm.show(); 76 } 77 };
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 |