Elgg  Version 2.2
 All Classes Namespaces Files Functions Variables Pages
walled_garden.js.php
Go to the documentation of this file.
1 <?php
8 $cancel_button = elgg_view('input/button', array(
9  'value' => elgg_echo('cancel'),
10  'class' => 'elgg-button-cancel mlm',
11 ));
12 $cancel_button = json_encode($cancel_button);
13 
14 if (0) { ?><script><?php }
15 ?>
16 
17 elgg.provide('elgg.walled_garden');
18 
19 elgg.walled_garden.init = function () {
20  // make sure it is loaded before using it in the click events
21  require(['elgg/spinner']);
22  $('.forgot_link').click(elgg.walled_garden.load('lost_password'));
23  $('.registration_link').click(elgg.walled_garden.load('register'));
24 
25  $(document).on('click', 'input.elgg-button-cancel', function(event) {
26  var $wgs = $('.elgg-walledgarden-single');
27  if ($wgs.is(':visible')) {
28  $('.elgg-walledgarden-double').fadeToggle();
29  $wgs.fadeToggle();
30  $wgs.remove();
31  }
32  event.preventDefault();
33  });
34 };
35 
42 elgg.walled_garden.load = function(view) {
43  return function(event) {
44  require(['elgg/spinner'], function(spinner) {
45  var id = '#elgg-walledgarden-' + view;
46  id = id.replace('_', '-');
47  // @todo display some visual element that indicates that loading of content is running
48  elgg.get('walled_garden/' + view, {
49  beforeSend: spinner.start,
50  complete: spinner.stop,
51  success: function(data) {
52  var $wg = $('.elgg-body-walledgarden');
53  $wg.append(data);
54  $(id).find('input.elgg-button-submit').after(<?php echo $cancel_button; ?>);
55 
56  if (view == 'register' && $wg.hasClass('hidden')) {
57  // this was a failed registration, display the register form ASAP
58  $('#elgg-walledgarden-login').toggle(false);
59  $(id).toggle();
60  $wg.removeClass('hidden');
61  } else {
62  $('#elgg-walledgarden-login').fadeToggle();
63  $(id).fadeToggle();
64  }
65  }
66  });
67 
68  });
69 
70  event.preventDefault();
71  };
72 };
73 
74 elgg.register_hook_handler('init', 'system', elgg.walled_garden.init);
$CONFIG view
The current view type.
Definition: config.php:149
elgg_echo($message_key, $args=array(), $language="")
Given a message key, returns an appropriately translated full-text string.
Definition: languages.php:21
$cancel_button
Walled garden JavaScript.
elgg_view($view, $vars=array(), $ignore1=false, $ignore2=false, $viewtype= '')
Return a parsed view.
Definition: views.php:342
const elgg
Definition: elgg.js.php:92