Elgg  Version 4.3
elgg.js.php
Go to the documentation of this file.
1 <?php
6 echo elgg_view('core/js/elgglib.js');
7 echo elgg_view('core/js/deprecated.js');
8 echo elgg_view('core/js/hooks.js');
9 
10 foreach (_elgg_get_js_site_data() as $expression => $value) {
11  $value = json_encode($value);
12  echo "{$expression} = {$value};" . PHP_EOL;
13 }
14 ?>
15 
16 // page data overrides site data
17 elgg.data = $.extend(true, {}, elgg.data, elgg._data);
18 delete elgg._data;
19 
20 // jQuery and UI must be loaded sync in 2.x but modules should depend on these AMD modules
21 define('jquery', function () {
22  return jQuery;
23 });
24 
25 define('elgg', ['jquery'], function($) {
26 
27  // @todo we need better documentation for this hack
28  // iOS Hover Event Class Fix
29  $('.elgg-page').attr('onclick', 'return true');
30 
31  // Allow element to be highlighted using CSS if its id is found from the URL
32  var elementId = elgg.getSelectorFromUrlFragment(document.URL);
33  $(elementId).addClass('elgg-state-highlight');
34 
35  require(['elgg/popup'], function(popup) {
36  // @todo remove the require here in Elgg 5.0
37  popup.bind($('[rel="popup"]'));
38  });
39 
53  function toggles(event) {
54  event.preventDefault();
55  var $this = $(this),
56  selector = $this.data().toggleSelector;
57 
58  if (!selector) {
59  // @todo we can switch to elgg.getSelectorFromUrlFragment() in 1.x if
60  // we also extend it to support href=".some-class"
61  selector = $this.attr('href');
62  }
63 
64  var $elements = $(selector);
65 
66  $this.toggleClass('elgg-state-active');
67 
68  $elements.each(function(index, elem) {
69  var $elem = $(elem);
70  if ($elem.data().toggleSlide != false) {
71  $elem.slideToggle('medium');
72  } else {
73  $elem.toggle();
74  }
75  });
76 
77  $this.trigger('elgg_ui_toggle', [{
78  $toggled_elements: $elements
79  }]);
80  };
81 
88  function requiresConfirmation(e) {
89  var i18n = require('elgg/i18n');
90  var confirmText = $(this).data('confirm') || i18n.echo('question:areyousure');
91  if (!confirm(confirmText)) {
92  e.preventDefault();
93  e.stopPropagation();
94  e.stopImmediatePropagation();
95  return false;
96  }
97  };
98 
99  $(document).on('click', '[rel=toggle]', toggles);
100  $(document).on('click', '*[data-confirm]', requiresConfirmation);
101 
102  return elgg;
103 });
104 
105 // @todo no longer require elgg/i18n in Elgg 5.0
106 require(['elgg', 'elgg/i18n']); // Forces the define() function to always run
107 
108 // Process queue. We have to wait until now because many modules depend on 'elgg' and we can't load
109 // it asynchronously.
110 if (!window._require_queue) {
111  if (window.console) {
112  console.log('Elgg\'s require() shim is not defined. Do not override the view "page/elements/head".');
113  }
114 } else {
115  while (_require_queue.length) {
116  require.apply(null, _require_queue.shift());
117  }
118  delete window._require_queue;
119 }
120 
121 elgg.trigger_hook('init', 'system');
122 
123 require(['elgg/lightbox', 'elgg/security']);
_elgg_get_js_site_data()
Get the site data to be merged into "elgg" in elgg.js.
Definition: views.php:1407
_require_queue
Definition: head.php:78
$value
Definition: generic.php:51
elgg require
Throw an error if the required package isn&#39;t present.
Definition: deprecated.js:176
define(['jquery', 'elgg/spinner', 'elgg/Ajax', 'elgg/system_messages', 'elgg/security', 'elgg/i18n', 'jquery-ui/widgets/sortable'], function($, spinner, Ajax, system_messages, security, i18n){function freezePlugins(){$('#elgg-plugin-list-cover').css('display', 'block');};function unfreezePlugins(){$('#elgg-plugin-list-cover').css('display', 'none');};function initPluginReordering(){$('#elgg-plugin-list >.elgg-list-container > ul').sortable({items: 'li:has(>.elgg-state-draggable)', handle: '.elgg-body', forcePlaceholderSize:true, placeholder: 'elgg-plugin-placeholder', opacity:0.8, revert:500, stop:movePlugin});};function toggleSinglePlugin(event){freezePlugins();event.preventDefault();var ajax=new Ajax();ajax.action(this.href).done(function(){ajax.path('admin_plugins_refresh').done(function(output){$('#elgg-plugin-list').html(output.list);$('.elgg-sidebar').html(output.sidebar);$(".elgg-admin-plugins-categories > li.elgg-state-selected > a").trigger('click');initPluginReordering();unfreezePlugins();});}).fail(function(){location.reload();});};function toggleAllPlugins(event){event.preventDefault();if(!confirm(i18n.echo('question:areyousure'))){return;}freezePlugins();var guids=[], state=$(this).data('desiredState'), find_state=state== 'active'? 'inactive': 'active';$('.elgg-plugin.elgg-state-'+find_state+ ':visible').each(function(){var guid=$(this).data('guid');if(guid){guids.push(guid);}});if(!guids.length){system_messages.error(i18n.echo('admin:plugins:already:'+state));unfreezePlugins();return;}spinner.start();var $form=$('< form method="post"/>');$form.prop('action', security.addToken(this.href));$form.append('< input type="hidden"name="guids"value="' + guids.join(',') + '"/>');$form.appendTo("body").submit();};function movePlugin(e, ui){freezePlugins();var pluginGuid=ui.item.attr('id');pluginGuid=pluginGuid.replace('elgg-object-', '');var ajax=new Ajax();ajax.action('admin/plugins/set_priority',{data:{plugin_guid:pluginGuid, priority:ui.item.index()+1}, success:function(){unfreezePlugins();}});};function filterPluginCategory(event){event.preventDefault();$(".elgg-admin-plugins-categories > li").removeClass("elgg-state-selected");$(".elgg-plugin").hide();$(".elgg-plugin-category-"+$(this).attr("rel")).show();$(this).closest('li').addClass("elgg-state-selected");};initPluginReordering();$(document).on('click', '.elgg-admin-plugins-categories a', filterPluginCategory);$(document).on('click', '.elgg-plugins-toggle', toggleAllPlugins);$(document).on('click', '.elgg-plugin-state-change', toggleSinglePlugin);})
elgg echo
Translates a string.
Definition: deprecated.js:530
Bundled plugins(the contents of the"/mod"directory) are available only under the GPLv2 license.The remainder of the project is available under either MIT or GPLv2.Both licenses can be found below.More info and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two distribute and or modify the software for each author s protection and we want to make certain that everyone understands that there is no warranty for this free software If the software is modified by someone else and passed on
Definition: LICENSE.txt:96
elgg_view($view, $vars=[], $viewtype= '')
Return a parsed view.
Definition: views.php:179
var elgg
Definition: elgglib.js:4