diff options
Diffstat (limited to 'views')
-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' => ' ', )); |