diff options
Diffstat (limited to 'views/default/js')
-rw-r--r-- | views/default/js/elgg.php | 2 | ||||
-rw-r--r-- | views/default/js/languages.php | 24 | ||||
-rw-r--r-- | views/default/js/walled_garden.php | 28 |
3 files changed, 41 insertions, 13 deletions
diff --git a/views/default/js/elgg.php b/views/default/js/elgg.php index 6fe03484d..c3b56e398 100644 --- a/views/default/js/elgg.php +++ b/views/default/js/elgg.php @@ -43,7 +43,7 @@ $libs = array( foreach ($libs as $file) { include("{$CONFIG->path}js/lib/$file.js"); - // putting a new line between the files to address http://trac.elgg.org/ticket/3081 + // putting a new line between the files to address https://github.com/elgg/elgg/issues/3081 echo "\n"; } diff --git a/views/default/js/languages.php b/views/default/js/languages.php index c51d7bcb2..fcf903d4b 100644 --- a/views/default/js/languages.php +++ b/views/default/js/languages.php @@ -1,15 +1,33 @@ <?php /** * @uses $vars['language'] + * @uses $vars['lc'] if present, client will be sent long expires headers */ -global $CONFIG; $language = $vars['language']; +$lastcache = elgg_extract('lc', $vars, 0); -$translations = $CONFIG->translations['en']; +// @todo add server-side caching +if ($lastcache) { + // we're relying on lastcache changes to predict language changes + $etag = '"' . md5("$language|$lastcache") . '"'; + + header('Expires: ' . gmdate('D, d M Y H:i:s \G\M\T', strtotime("+6 months")), true); + header("Pragma: public", true); + header("Cache-Control: public", true); + header("ETag: $etag"); + + if (isset($_SERVER['HTTP_IF_NONE_MATCH']) && trim($_SERVER['HTTP_IF_NONE_MATCH']) === $etag) { + header("HTTP/1.1 304 Not Modified"); + exit; + } +} + +$all_translations = elgg_get_config('translations'); +$translations = $all_translations['en']; if ($language != 'en') { - $translations = array_merge($translations, $CONFIG->translations[$language]); + $translations = array_merge($translations, $all_translations[$language]); } echo json_encode($translations);
\ No newline at end of file diff --git a/views/default/js/walled_garden.php b/views/default/js/walled_garden.php index 7a482fe23..e228df507 100644 --- a/views/default/js/walled_garden.php +++ b/views/default/js/walled_garden.php @@ -5,12 +5,11 @@ * @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', )); -$cancel_button = trim($cancel_button); +$cancel_button = json_encode($cancel_button); if (0) { ?><script><?php } ?> @@ -23,10 +22,11 @@ elgg.walled_garden.init = function () { $('.registration_link').click(elgg.walled_garden.load('register')); $('input.elgg-button-cancel').live('click', function(event) { - if ($('.elgg-walledgarden-single').is(':visible')) { + var $wgs = $('.elgg-walledgarden-single'); + if ($wgs.is(':visible')) { $('.elgg-walledgarden-double').fadeToggle(); - $('.elgg-walledgarden-single').fadeToggle(); - $('.elgg-walledgarden-single').remove(); + $wgs.fadeToggle(); + $wgs.remove(); } event.preventDefault(); }); @@ -42,12 +42,22 @@ elgg.walled_garden.load = function(view) { return function(event) { var id = '#elgg-walledgarden-' + view; id = id.replace('_', '-'); + //@todo display some visual element that indicates that loading of content is running 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(); + var $wg = $('.elgg-body-walledgarden'); + $wg.append(data); + $(id).find('input.elgg-button-submit').after(<?php echo $cancel_button; ?>); + + if (view == 'register' && $wg.hasClass('hidden')) { + // this was a failed register, display the register form ASAP + $('#elgg-walledgarden-login').toggle(false); + $(id).toggle(); + $wg.removeClass('hidden'); + } else { + $('#elgg-walledgarden-login').fadeToggle(); + $(id).fadeToggle(); + } } }); event.preventDefault(); |