diff options
author | brettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2011-02-19 03:46:50 +0000 |
---|---|---|
committer | brettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2011-02-19 03:46:50 +0000 |
commit | b4e5f49e7569563e369566fcf144f8b7c3840ac1 (patch) | |
tree | 74cc262caaacefd57911be096a67573db12c0eef /js | |
parent | b7e83f5641f559b0eb19d7648bd0369412973488 (diff) | |
download | elgg-b4e5f49e7569563e369566fcf144f8b7c3840ac1.tar.gz elgg-b4e5f49e7569563e369566fcf144f8b7c3840ac1.tar.bz2 |
Pulled the confirm link output view's JS into elgg.us. Any links with elgg-requires-confirmation will get a confirm box with the title of the anchor tag as the question, or the default "Are you sure?" if that doesn't exist.
git-svn-id: http://code.elgg.org/elgg/trunk@8310 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'js')
-rw-r--r-- | js/lib/ui.js | 29 |
1 files changed, 22 insertions, 7 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 |