backup MDL-23727 The proceed button is now to the right of the screen and the cancel...
[moodle.git] / backup / util / ui / yui / confirmcancel / confirmcancel.js
CommitLineData
83a9c866
SH
1YUI.add('moodle-backup-confirmcancel', function(Y) {
2
3// Namespace for the backup
4M.core_backup = M.core_backup || {};
5/**
6 * Adds confirmation dialogues to the cancel buttons on the page.
7 *
8 * @param {object} config
9 */
10M.core_backup.watch_cancel_buttons = function(config) {
11 Y.all('.confirmcancel').each(function(){
12 this._confirmationListener = this._confirmationListener || this.on('click', function(e){
13 // Prevent the default event (sumbit) from firing
14 e.preventDefault();
15 // Create the confirm box
16 var confirm = new M.core.confirm(config);
17 // If the user clicks yes
18 confirm.on('complete-yes', function(e){
19 // Detach the listener for the confirm box so it doesn't fire again.
20 this._confirmationListener.detach();
21 // Simulate the original cancel button click
22 this.simulate('click');
23 }, this);
24 // Show the confirm box
25 confirm.show();
26 }, this);
27 });
28}
29
30}, '@VERSION@', {'requires':['base','node','moodle-enrol-notification']});