diff options
author | Cash Costello <cash.costello@gmail.com> | 2012-02-10 08:06:33 -0500 |
---|---|---|
committer | Cash Costello <cash.costello@gmail.com> | 2012-02-10 08:06:33 -0500 |
commit | 77c2d19bc36450ce6f5bc6ddf6b2ddea510bd19b (patch) | |
tree | 6875b10ed754f8b433fa53e61da8994a5c42431a /views/default | |
parent | 69786dcc8ad1c193f3b4fff36807e6dc92da1d8d (diff) | |
download | elgg-77c2d19bc36450ce6f5bc6ddf6b2ddea510bd19b.tar.gz elgg-77c2d19bc36450ce6f5bc6ddf6b2ddea510bd19b.tar.bz2 |
updated the walled garden js to use new js lib
Diffstat (limited to 'views/default')
-rw-r--r-- | views/default/js/walled_garden.php | 52 | ||||
-rw-r--r-- | views/default/page/layouts/walled_garden.php | 2 |
2 files changed, 33 insertions, 21 deletions
diff --git a/views/default/js/walled_garden.php b/views/default/js/walled_garden.php index e761e5869..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,27 +14,12 @@ $cancel_button = trim($cancel_button); ?> -$(document).ready(function() { +elgg.provide('elgg.walled_garden'); - $('.forgot_link').click(function(event) { - $.get('walled_garden/lost_password', function(data) { - $('.elgg-walledgarden-double').fadeToggle(); - $('.elgg-body-walledgarden').append(data); - $(".elgg-form-user-requestnewpassword").find('input.elgg-button-submit').after('<?php echo $cancel_button; ?>'); - $('.elgg-walledgarden-single').fadeToggle(); - }); - event.preventDefault(); - }); +elgg.walled_garden.init = function () { - $('.registration_link').click(function(event) { - $.get('walled_garden/register', function(data) { - $('.elgg-walledgarden-double').fadeToggle(); - $('.elgg-body-walledgarden').append(data); - $('.elgg-form-register').find('input.elgg-button-submit').after('<?php echo $cancel_button; ?>'); - $('.elgg-walledgarden-single').fadeToggle(); - }); - event.preventDefault(); - }); + $('.forgot_link').click(elgg.walled_garden.load('lost_password')); + $('.registration_link').click(elgg.walled_garden.load('register')); $('input.elgg-button-cancel').live('click', function(event) { if ($('.elgg-walledgarden-single').is(':visible')) { @@ -43,4 +29,28 @@ $(document).ready(function() { } event.preventDefault(); }); -});
\ No newline at end of file +}; + +/** + * 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(); + }; +}; + +elgg.register_hook_handler('init', 'system', elgg.walled_garden.init);
\ No newline at end of file diff --git a/views/default/page/layouts/walled_garden.php b/views/default/page/layouts/walled_garden.php index 5cddcbb77..6ecd941ef 100644 --- a/views/default/page/layouts/walled_garden.php +++ b/views/default/page/layouts/walled_garden.php @@ -4,11 +4,13 @@ * * @uses $vars['content'] Main content * @uses $vars['class'] CSS classes + * @uses $vars['id'] CSS id */ $class = elgg_extract('class', $vars, 'elgg-walledgarden-single'); echo elgg_view_module('walledgarden', '', $vars['content'], array( 'class' => $class, + 'id' => elgg_extract('id', $vars, ''), 'header' => ' ', 'footer' => ' ', )); |