Elgg  Version 3.0
elgg.js.php
Go to the documentation of this file.
1 <?php
6 // We use named AMD modules and inline them here in order to save HTTP requests,
7 // as these modules will be required on each page
8 echo elgg_view('elgg/popup.js');
9 
11  // these must come first
12  'elgglib.js',
13 
14  // class definitions
15  'ElggEntity.js',
16  'ElggUser.js',
17  'ElggPriorityList.js',
18 
19  //libraries
20  'prototypes.js',
21  'hooks.js',
22  'security.js',
23  'languages.js',
24  'ajax.js',
25  'session.js',
26  'pageowner.js',
27  'configuration.js',
28 
29  //ui
30  'ui.js',
31 ];
32 
33 foreach ($core_js_views as $view) {
34  echo elgg_view("core/js/{$view}");
35  // putting a new line between the files to address https://github.com/elgg/elgg/issues/3081
36  echo PHP_EOL;
37 }
38 
39 foreach (_elgg_get_js_site_data() as $expression => $value) {
40  $value = json_encode($value);
41  echo "{$expression} = {$value};" . PHP_EOL;
42 }
43 ?>
44 //<script>
45 
46 // page data overrides site data
47 $.extend(elgg.data, elgg._data);
48 delete elgg._data;
49 
50 // jQuery and UI must be loaded sync in 2.x but modules should depend on these AMD modules
51 define('jquery', function () {
52  return jQuery;
53 });
54 define('jquery-ui');
55 
56 // The datepicker language modules depend on "../datepicker", so to avoid RequireJS from
57 // trying to load that, we define it manually here. The lang modules have names like
58 // "jquery-ui/i18n/datepicker-LANG.min" and these views are mapped in /views.php
59 define('jquery-ui/datepicker', jQuery.datepicker);
60 
61 define('elgg', ['sprintf', 'jquery', 'languages/' + elgg.get_language(), 'weakmap-polyfill', 'formdata-polyfill'], function(vsprintf, $, translations) {
62  elgg.add_translation(elgg.get_language(), translations);
63 
64  return elgg;
65 });
66 
67 require(['elgg']); // Forces the define() function to always run
68 
69 // Process queue. We have to wait until now because many modules depend on 'elgg' and we can't load
70 // it asynchronously.
71 if (!window._require_queue) {
72  if (window.console) {
73  console.log('Elgg\'s require() shim is not defined. Do not override the view "page/elements/head".');
74  }
75 } else {
76  while (_require_queue.length) {
77  require.apply(null, _require_queue.shift());
78  }
79  delete window._require_queue;
80 }
81 
82 elgg.trigger_hook('boot', 'system');
83 
84 require(['elgg/init', 'elgg/ready', 'elgg/lightbox']);
_elgg_get_js_site_data()
Get the site data to be merged into "elgg" in elgg.js.
Definition: views.php:1845
if(!$owner||!$owner->canEdit()) if(!$owner->hasIcon('master')) if(!$owner->saveIconFromElggFile($owner->getIcon('master'), 'icon', $coords)) $view
Definition: crop.php:30
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
$value
Definition: debugging.php:7
define(function(require){var $=require('jquery');var elgg=require('elgg');var spinner=require('elgg/spinner');var Ajax=require('elgg/Ajax');var ajax=new Ajax();function init(){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);$(document).on('mouseenter', '.elgg-plugin-details-screenshots.elgg-plugin-screenshot', showPluginScreenshot);};function freezePlugins(){$('#elgg-plugin-list-cover').css('display', 'block');};function unfreezePlugins(){$('#elgg-plugin-list-cover').css('display', 'none');};function initPluginReordering(){$('#elgg-plugin-list > 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(e){freezePlugins();e.preventDefault();ajax.action(this.href).done(function(output, statusText, jqXHR){if(jqXHR.AjaxData.status==-1){location.reload();return;}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();});});};function toggleAllPlugins(e){e.preventDefault();if(!confirm(elgg.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){elgg.register_error(elgg.echo('admin:plugins:already:'+state));unfreezePlugins();return;}spinner.start();var $form=$('< form method="post"/>');$form.prop('action', elgg.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-', '');elgg.action('admin/plugins/set_priority',{data:{plugin_guid:pluginGuid, priority:ui.item.index()+1}, success:function(){var priorityDep=new RegExp(elgg.echo('ElggPlugin:Dependencies:Priority'));ui.item.siblings().andSelf().each(function(){if(priorityDep.test($(this).find('.elgg-dependency-requires').text())){updatePluginView($(this));}});unfreezePlugins();}});};function updatePluginView(pluginView){var pluginGuid=pluginView.attr('id');pluginGuid=pluginGuid.replace('elgg-object-', '');elgg.get({url:elgg.config.wwwroot+"ajax/view/object/plugin/full", dataType:"html", cache:false, data:{guid:pluginGuid, display_reordering:true}, success:function(htmlData){if(htmlData.length > 0){pluginView.html(htmlData);}}});};function filterPluginCategory(e){e.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");};function showPluginScreenshot(){$(this).parent().find(".elgg-plugin-screenshot").removeClass("elgg-state-selected");$(this).addClass("elgg-state-selected");$(".elgg-plugin-details-screenshots > div > img").hide();$(".elgg-plugin-details-screenshots > div > img[rel='"+$(this).attr("rel")+"']").show();};init();})
_require_queue
Definition: head.php:38
elgg_view($view, $vars=[], $viewtype= '')
Return a parsed view.
Definition: views.php:246
var elgg
Definition: elgglib.js:4
$core_js_views
Core Elgg JavaScript file.
Definition: elgg.js.php:10