| Server IP : 172.67.187.206 / Your IP : 172.71.28.155 Web Server : Apache/2.4.25 (Win32) OpenSSL/1.0.2j PHP/5.6.30 System : Windows NT WIN-ECQAAA40806 6.2 build 9200 (Windows Server 2012 Standard Edition) i586 User : SYSTEM ( 0) PHP Version : 5.6.30 Disable Function : NONE MySQL : ON | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /Inetpub/www/myschool/triamudom/tuprblearn/backup/util/ui/yui/src/confirmcancel/js/ |
Upload File : |
/**
* Add a confirmation dialogue when cancelling a backup.
*
* @module moodle-backup-confirmcancel
*/
/**
* Add a confirmation dialogue when cancelling a backup.
*
* @class M.core_backup.confirmcancel
*/
// Namespace for the backup.
M.core_backup = M.core_backup || {};
M.core_backup.confirmcancel = {
/**
* An array of EventHandlers which call the confirm_cancel dialogue.
*
* @property listeners
* @protected
* @type Array
*/
listeners: [],
/**
* The configuration supplied to this instance.
*
* @property config
* @protected
* @type Object
*/
config: {},
/**
* Initializer to watch all cancel buttons.
*
* @method watch_cancel_buttons
* @param {Object} config The configuration for the confirmation dialogue.
*/
watch_cancel_buttons: function(config) {
this.config = config;
this.listeners.push(
Y.one(Y.config.doc.body).delegate('click', this.confirm_cancel, '.confirmcancel', this)
);
},
/**
* Display the confirmation dialogue.
*
* @method confirm_cancel
* @protected
* @param {EventFacade} e
*/
confirm_cancel: function(e) {
// Prevent the default event (submit) from firing.
e.preventDefault();
// Create the confirmation dialogue.
var confirm = new M.core.confirm(this.config);
// If the user clicks yes.
confirm.on('complete-yes', function() {
// Detach the listeners for the confirm box so they don't fire again.
new Y.EventHandle(M.core_backup.confirmcancel.listeners).detach();
// The currentTarget is a div surrounding the form elements. Simulating a click on the div is
// not going to submit a form so we need to find the form element to click.
var element = e.currentTarget.one('input, select, button');
// Simulate the original cancel button click.
if (element) {
element.simulate('click');
} else {
// Backwards compatibility only.
e.currentTarget.simulate('click');
}
}, this);
// Show the confirm box.
confirm.show();
}
};