Skip to content

Commit

Permalink
backup MDL-23727 The proceed button is now to the right of the screen…
Browse files Browse the repository at this point in the history
… and the cancel button throws a confirmation box.
  • Loading branch information
Sam Hemelryk committed Aug 17, 2010
1 parent baf8b9b commit 83a9c86
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 3 deletions.
13 changes: 11 additions & 2 deletions backup/util/ui/base_moodleform.class.php
Expand Up @@ -93,16 +93,25 @@ function definition() {
/**
* 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
Expand Down
2 changes: 1 addition & 1 deletion backup/util/ui/renderer.php
Expand Up @@ -146,9 +146,9 @@ public function backup_details($details, $nextstageurl) {
}
$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;
}
Expand Down
30 changes: 30 additions & 0 deletions backup/util/ui/yui/confirmcancel/confirmcancel.js
@@ -0,0 +1,30 @@
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']});
5 changes: 5 additions & 0 deletions lang/en/backup.php
Expand Up @@ -58,6 +58,11 @@
$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';
Expand Down

0 comments on commit 83a9c86

Please sign in to comment.