Skip to content

Commit

Permalink
MDL-28195 confirm_action should allow the button labels to be customised
Browse files Browse the repository at this point in the history
  • Loading branch information
timhunt authored and Sam Hemelryk committed Jul 11, 2011
1 parent a8361fc commit c159d8e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
13 changes: 11 additions & 2 deletions lib/javascript-static.js
Expand Up @@ -275,8 +275,17 @@ M.util.show_confirm_dialog = function(e, args) {
} }
}; };


var buttons = [ {text: M.str.moodle.cancel, handler: handle_cancel, isDefault: true}, if (!args.cancellabel) {
{text: M.str.moodle.yes, handler: handle_yes} ]; args.cancellabel = M.str.moodle.cancel;
}
if (!args.continuelabel) {
args.continuelabel = M.str.moodle.yes;
}

var buttons = [
{text: args.cancellabel, handler: handle_cancel, isDefault: true},
{text: args.continuelabel, handler: handle_yes}
];


simpledialog.cfg.queueProperty('buttons', buttons); simpledialog.cfg.queueProperty('buttons', buttons);


Expand Down
6 changes: 4 additions & 2 deletions lib/outputactions.php
Expand Up @@ -85,8 +85,10 @@ public function __construct($event, $jsfunction, $jsfunctionargs=array()) {
* Confirm action * Confirm action
*/ */
class confirm_action extends component_action { class confirm_action extends component_action {
public function __construct($message, $callback=null) { public function __construct($message, $callback = null, $continuelabel = null, $cancellabel = null) {
parent::__construct('click', 'M.util.show_confirm_dialog', array('message' => $message, 'callback' => $callback)); parent::__construct('click', 'M.util.show_confirm_dialog', array(
'message' => $message, 'callback' => $callback,
'continuelabel' => $continuelabel, 'cancellabel' => $cancellabel));
} }
} }


Expand Down
2 changes: 1 addition & 1 deletion lib/outputcomponents.php
Expand Up @@ -481,7 +481,7 @@ public function __construct(moodle_url $url, $label, $method='post') {
* @return void * @return void
*/ */
public function add_confirm_action($confirmmessage) { public function add_confirm_action($confirmmessage) {
$this->add_action(new component_action('click', 'M.util.show_confirm_dialog', array('message' => $confirmmessage))); $this->add_action(new confirm_action($confirmmessage));
} }


/** /**
Expand Down

0 comments on commit c159d8e

Please sign in to comment.