/**
* Definition applied after the data is organised.. why's it here? because I want
* to add elements on the fly.
+ * @global moodle_page $PAGE
*/
function definition_after_data() {
+ global $PAGE;
$buttonarray=array();
+ $buttonarray[] = $this->_form->createElement('submit', 'submitbutton', get_string($this->uistage->get_ui()->get_name().'stage'.$this->uistage->get_stage().'action', 'backup'), array('class'=>'proceedbutton'));
if (!$this->uistage->is_first_stage()) {
$buttonarray[] = $this->_form->createElement('submit', 'previous', get_string('previousstage','backup'));
}
- $buttonarray[] = $this->_form->createElement('submit', 'submitbutton', get_string($this->uistage->get_ui()->get_name().'stage'.$this->uistage->get_stage().'action', 'backup'));
- $buttonarray[] = $this->_form->createElement('cancel');
+ $buttonarray[] = $this->_form->createElement('cancel', 'cancel', get_string('cancel'), array('class'=>'confirmcancel'));
$this->_form->addGroup($buttonarray, 'buttonar', '', array(' '), false);
$this->_form->closeHeaderBefore('buttonar');
+
+ $config = new stdClass;
+ $config->title = get_string('confirmcancel', 'backup');
+ $config->question = get_string('confirmcancelquestion', 'backup');
+ $config->yesLabel = get_string('confirmcancelyes', 'backup');
+ $config->noLabel = get_string('confirmcancelno', 'backup');
+ $PAGE->requires->yui_module('moodle-backup-confirmcancel', 'M.core_backup.watch_cancel_buttons', array($config));
}
/**
* Closes any open divs
}
$html .= html_writer::end_tag('div');
$html .= html_writer::end_tag('div');
- $html .= html_writer::end_tag('div');
$html .= $this->output->single_button($nextstageurl, get_string('continue'), 'post');
+ $html .= html_writer::end_tag('div');
return $html;
}
--- /dev/null
+YUI.add('moodle-backup-confirmcancel', function(Y) {
+
+// Namespace for the backup
+M.core_backup = M.core_backup || {};
+/**
+ * Adds confirmation dialogues to the cancel buttons on the page.
+ *
+ * @param {object} config
+ */
+M.core_backup.watch_cancel_buttons = function(config) {
+ Y.all('.confirmcancel').each(function(){
+ this._confirmationListener = this._confirmationListener || this.on('click', function(e){
+ // Prevent the default event (sumbit) from firing
+ e.preventDefault();
+ // Create the confirm box
+ var confirm = new M.core.confirm(config);
+ // If the user clicks yes
+ confirm.on('complete-yes', function(e){
+ // Detach the listener for the confirm box so it doesn't fire again.
+ this._confirmationListener.detach();
+ // Simulate the original cancel button click
+ this.simulate('click');
+ }, this);
+ // Show the confirm box
+ confirm.show();
+ }, this);
+ });
+}
+
+}, '@VERSION@', {'requires':['base','node','moodle-enrol-notification']});
\ No newline at end of file
$string['configgeneraluserscompletion'] = 'If enabled user completion information will be included in backups by default.';
$string['configgeneraluserfiles'] = 'Sets the default for whether user files will be included in backups.';
$string['configgeneralusers'] = 'Sets the default for whether to include users in backups.';
+$string['confirmcancel'] = 'Cancel backup';
+$string['confirmcancelquestion'] = 'Are you sure you wish to cancel?
+Any information you have entered will be lost.';
+$string['confirmcancelyes'] = 'Cancel';
+$string['confirmcancelno'] = 'Stay';
$string['coursecategory'] = 'Category the course will be restored into';
$string['courseid'] = 'Original ID';
$string['coursesettings'] = 'Course settings';