Elgg  Version 1.11
walled_garden.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  $('input.elgg-button-cancel').live('click', 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);
elgg message elgg state success
Definition: admin.php:252
elgg
Definition: install.js:23
$CONFIG view
The current view type.
Definition: config.php:192
elgg_echo($message_key, $args=array(), $language="")
Given a message key, returns an appropriately translated full-text string.
Definition: languages.php:21
elgg echo
Translates a string.
Definition: languages.js:43
elgg require
Throw an error if the required package isn&#39;t present.
Definition: elgglib.js:164
elgg_view($view, $vars=array(), $bypass=false, $ignored=false, $viewtype= '')
Return a parsed view.
Definition: views.php:354
function elgg combo checkbox click(function(){if($(this).is(':checked')){$(this).prev().attr('disabled', true);$(this).prev().val('');}else{$(this).prev().attr('disabled', false);}})
$cancel_button
Walled garden JavaScript.