diff options
-rw-r--r-- | engine/lib/elgglib.php | 2 | ||||
-rw-r--r-- | views/default/js/walled_garden.php | 52 | ||||
-rw-r--r-- | views/default/page/layouts/walled_garden.php | 2 |
3 files changed, 35 insertions, 21 deletions
diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php index 5c444c2f5..b55958a6c 100644 --- a/engine/lib/elgglib.php +++ b/engine/lib/elgglib.php @@ -2026,6 +2026,7 @@ function elgg_walled_garden_index() { $params = array( 'content' => $content, 'class' => 'elgg-walledgarden-double', + 'id' => 'elgg-walledgarden-login', ); $body = elgg_view_layout('walled_garden', $params); echo elgg_view_page('', $body, 'walled_garden'); @@ -2046,6 +2047,7 @@ function _elgg_walled_garden_ajax_handler($page) { $params = array( 'content' => elgg_view("core/walled_garden/$view"), 'class' => 'elgg-walledgarden-single hidden', + 'id' => str_replace('_', '-', "elgg-walledgarden-$view"), ); echo elgg_view_layout('walled_garden', $params); return true; 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' => ' ', )); |