aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--js/lib/ui.js29
-rw-r--r--views/default/output/confirmlink.php12
2 files changed, 32 insertions, 9 deletions
diff --git a/js/lib/ui.js b/js/lib/ui.js
index 7b67c5586..3448d6b35 100644
--- a/js/lib/ui.js
+++ b/js/lib/ui.js
@@ -3,7 +3,7 @@ elgg.provide('elgg.ui');
elgg.ui.init = function () {
elgg.ui.initHoverMenu();
-
+
//if the user clicks a system message, make it disappear
$('.elgg-system-messages li').live('click', function() {
$(this).stop().fadeOut('fast');
@@ -14,11 +14,13 @@ elgg.ui.init = function () {
$('.elgg-toggle').live('click', elgg.ui.toggle);
$('.elgg-toggler').live('click', elgg.ui.toggles);
-
+
$('.elgg-menu-page .elgg-menu-parent').live('click', elgg.ui.toggleMenu);
$('.elgg-like-toggle').live('click', elgg.ui.toggleLikes);
-}
+
+ $('.elgg-requires-confirmation').live('click', elgg.ui.requiresConfirmation);
+}
/**
* Toggles an element based on clicking a separate element
@@ -32,9 +34,9 @@ elgg.ui.init = function () {
*/
elgg.ui.toggle = function(event) {
event.preventDefault();
-
+
var id = $(this).toggleClass('elgg-state-active').attr('id').replace('toggler', 'togglee');
-
+
$('#' + id).slideToggle('medium');
}
@@ -42,9 +44,9 @@ elgg.ui.toggles = function(event) {
event.preventDefault();
$(this).toggleClass('elgg-state-active');
-
+
var togglees = $(this).attr('class').match(/elgg-toggles-[^ ]*/i);
-
+
$('#' + togglees[0].replace('elgg-toggles-', '')).slideToggle('medium');
}
@@ -134,4 +136,17 @@ elgg.ui.initHoverMenu = function(parent) {
});
}
+/**
+ * Calls a confirm() and prevents default if denied.
+ *
+ * @param {Object} event
+ * @return void
+ */
+elgg.ui.requiresConfirmation = function(e) {
+ var confirmText = $(this).attr('title') || elgg.echo('question:areyousure');
+ if (!confirm(confirmText)) {
+ e.preventDefault();
+ }
+};
+
elgg.register_event_handler('init', 'system', elgg.ui.init); \ No newline at end of file
diff --git a/views/default/output/confirmlink.php b/views/default/output/confirmlink.php
index aef33ab1f..20431e5a7 100644
--- a/views/default/output/confirmlink.php
+++ b/views/default/output/confirmlink.php
@@ -13,7 +13,6 @@
*/
$confirm = elgg_extract('confirm', $vars, elgg_echo('question:areyousure'));
-
$encode = elgg_extract('text_encode', $vars, true);
// always generate missing action tokens
@@ -24,7 +23,16 @@ if ($encode) {
$text = htmlspecialchars($text, ENT_QUOTES, 'UTF-8', false);
}
-$vars['onclick'] = "return confirm('" . addslashes($confirm) . "')";
+$vars['title'] = addslashes($confirm);
+if (isset($vars['class'])) {
+ if (!is_array($vars['class'])) {
+ $vars['class'] = array($vars['class']);
+ }
+ $vars['class'][] = 'elgg-requires-confirmation';
+} else {
+ $vars['class'] = 'elgg-requires-confirmation';
+}
+//$vars['onclick'] = "return confirm('" . addslashes($confirm) . "')";
unset($vars['encode_text']);
unset($vars['text']);