diff options
author | Sem <sembrestels@riseup.net> | 2012-04-25 19:09:22 +0200 |
---|---|---|
committer | Sem <sembrestels@riseup.net> | 2012-04-25 19:09:22 +0200 |
commit | 9fe063022e08a4b6fa5f5935f8f185d5d95814a4 (patch) | |
tree | 87377f7b889efc639935508556beb9baf010e821 /views/default/js | |
parent | 24690ed95198c093e6fbb91a94b5d0544c740f89 (diff) | |
download | elgg-9fe063022e08a4b6fa5f5935f8f185d5d95814a4.tar.gz elgg-9fe063022e08a4b6fa5f5935f8f185d5d95814a4.tar.bz2 |
Upgraded to Elgg 1.8.4.
Diffstat (limited to 'views/default/js')
-rw-r--r-- | views/default/js/walled_garden.php | 54 |
1 files changed, 35 insertions, 19 deletions
diff --git a/views/default/js/walled_garden.php b/views/default/js/walled_garden.php index 46c2934ff..13ec83c04 100644 --- a/views/default/js/walled_garden.php +++ b/views/default/js/walled_garden.php @@ -2,9 +2,10 @@ /** * Walled garden JavaScript * - * @todo update for new JS lib + * @since 1.8 */ +// note that this assumes the button view is not using single quotes $cancel_button = elgg_view('input/button', array( 'value' => elgg_echo('cancel'), 'class' => 'elgg-button-cancel mlm', @@ -13,28 +14,43 @@ $cancel_button = trim($cancel_button); ?> -$(document).ready(function() { +elgg.provide('elgg.walled_garden'); - // add cancel button to inline forms - $(".elgg-walledgarden-password").find('input.elgg-button-submit').after('<?php echo $cancel_button; ?>'); - $('.elgg-walledgarden-register').find('input.elgg-button-submit').after('<?php echo $cancel_button; ?>'); +elgg.walled_garden.init = function () { - $(".forgot_link").click(function(event) { - event.preventDefault(); - $(".elgg-walledgarden-password").fadeToggle(); - }); + $('.forgot_link').click(elgg.walled_garden.load('lost_password')); + $('.registration_link').click(elgg.walled_garden.load('register')); - $(".registration_link").click(function(event) { + $('input.elgg-button-cancel').live('click', function(event) { + if ($('.elgg-walledgarden-single').is(':visible')) { + $('.elgg-walledgarden-double').fadeToggle(); + $('.elgg-walledgarden-single').fadeToggle(); + $('.elgg-walledgarden-single').remove(); + } event.preventDefault(); - $(".elgg-walledgarden-register").fadeToggle(); }); +}; - $('input.elgg-button-cancel').click(function(event) { - if ($(".elgg-walledgarden-password").is(':visible')) { - $(".forgot_link").click(); - } else if ($('.elgg-walledgarden-register').is(':visible')) { - $(".registration_link").click(); - } +/** + * Creates a closure for loading walled garden content through ajax + * + * @param {String} view Name of the walled garden view + * @return {Object} + */ +elgg.walled_garden.load = function(view) { + return function(event) { + var id = '#elgg-walledgarden-' + view; + id = id.replace('_', '-'); + elgg.get('walled_garden/' + view, { + 'success' : function(data) { + $('.elgg-body-walledgarden').append(data); + $(id).find('input.elgg-button-submit').after('<?php echo $cancel_button; ?>'); + $('#elgg-walledgarden-login').fadeToggle(); + $(id).fadeToggle(); + }, + }); event.preventDefault(); - }); -});
\ No newline at end of file + }; +}; + +elgg.register_hook_handler('init', 'system', elgg.walled_garden.init);
\ No newline at end of file |