From c159d8e8722916b93e875b23c0ddf2977d8ea157 Mon Sep 17 00:00:00 2001 From: Tim Hunt Date: Tue, 5 Jul 2011 13:50:59 +0100 Subject: [PATCH] MDL-28195 confirm_action should allow the button labels to be customised --- lib/javascript-static.js | 13 +++++++++++-- lib/outputactions.php | 6 ++++-- lib/outputcomponents.php | 2 +- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/lib/javascript-static.js b/lib/javascript-static.js index ae098c234f116..f8479204633bb 100644 --- a/lib/javascript-static.js +++ b/lib/javascript-static.js @@ -275,8 +275,17 @@ M.util.show_confirm_dialog = function(e, args) { } }; - var buttons = [ {text: M.str.moodle.cancel, handler: handle_cancel, isDefault: true}, - {text: M.str.moodle.yes, handler: handle_yes} ]; + if (!args.cancellabel) { + 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); diff --git a/lib/outputactions.php b/lib/outputactions.php index 133cec637725a..cd5dad4efab76 100644 --- a/lib/outputactions.php +++ b/lib/outputactions.php @@ -85,8 +85,10 @@ public function __construct($event, $jsfunction, $jsfunctionargs=array()) { * Confirm action */ class confirm_action extends component_action { - public function __construct($message, $callback=null) { - parent::__construct('click', 'M.util.show_confirm_dialog', array('message' => $message, 'callback' => $callback)); + public function __construct($message, $callback = null, $continuelabel = null, $cancellabel = null) { + parent::__construct('click', 'M.util.show_confirm_dialog', array( + 'message' => $message, 'callback' => $callback, + 'continuelabel' => $continuelabel, 'cancellabel' => $cancellabel)); } } diff --git a/lib/outputcomponents.php b/lib/outputcomponents.php index 2b18213bcc8ca..c378b6286d0a5 100644 --- a/lib/outputcomponents.php +++ b/lib/outputcomponents.php @@ -481,7 +481,7 @@ public function __construct(moodle_url $url, $label, $method='post') { * @return void */ 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)); } /**