Elgg  Version 2.2
admin.js
Go to the documentation of this file.
1 
6 define(function(require) {
7  var $ = require('jquery');
8  var ui = require('jquery-ui');
9  var elgg = require('elgg');
10  var spinner = require('elgg/spinner');
11 
12  function init () {
13  // system messages do not fade in admin area, instead slide up when clicked
14  $('.elgg-system-messages li').stop(true);
15  $(document).off('click', '.elgg-system-messages li');
16  $(document).on('click', '.elgg-system-messages li', function(e) {
17  if (!$(e.target).is('a')) {
18  $(this).stop().slideUp('medium');
19  }
20  });
21 
22  // draggable plugin reordering
23  $('#elgg-plugin-list > ul').sortable({
24  items: 'li:has(> .elgg-state-draggable)',
25  handle: '.elgg-head',
26  forcePlaceholderSize: true,
27  placeholder: 'elgg-widget-placeholder',
28  opacity: 0.8,
29  revert: 500,
30  stop: movePlugin
31  });
32 
33  // in-line editing for custom profile fields.
34  // @note this requires jquery.jeditable plugin
35  $(".elgg-state-editable").editable(editProfileField, {
36  type: 'text',
37  onblur: 'submit',
38  width: '300px',
39  height: 'none',
40  style: 'display:inline;'
41  });
42 
43  // draggable profile field reordering.
44  $('#elgg-profile-fields').sortable({
45  items: 'li',
46  handle: 'span.elgg-state-draggable',
47  stop: moveProfileField
48  });
49 
50  // admin notices delete ajax
51  $('a.elgg-admin-notice').click(deleteNotice);
52 
53  // disable checkboxes (readonly does not work for them)
54  $(document).on('click', 'input:checkbox.elgg-state-disabled, label.elgg-state-disabled > input:checkbox', function() {
55  return false;
56  });
57 
58  // disable simple cache compress settings if simple cache is off
59  $('[name=simplecache_enabled]').click(simplecacheToggle);
60 
61  // plugin category filtering
62  $(document).on('click', '.elgg-admin-plugins-categories a', filterPluginCategory);
63 
64  // plugin details selection
65  $(document).on('click', '.elgg-plugin-details-container > ul a', showPluginDetails);
66 
67  $(document).on('click', '.elgg-plugins-toggle', toggleAllPlugins);
68 
69  // plugin screenshots
70  $(document).on('mouseenter', '.elgg-plugin-details-screenshots .elgg-plugin-screenshot', showPluginScreenshot);
71  }
72 
79  function toggleAllPlugins(e) {
80  e.preventDefault();
81 
82  if (!confirm(elgg.echo('question:areyousure'))) {
83  return;
84  }
85 
86  var guids = [],
87  state = $(this).data('desiredState'),
88  find_state = state == 'active' ? 'inactive' : 'active';
89 
90  $('.elgg-plugin.elgg-state-' + find_state + ':visible').each(function () {
91  var guid = $(this).data('guid');
92  if (guid) {
93  guids.push(guid);
94  }
95  });
96 
97  if (!guids.length) {
98  elgg.register_error(elgg.echo('admin:plugins:already:' + state));
99  return;
100  }
101 
102  spinner.start();
103 
104  // We create a regular form and submit it. This is the simplest way to send the
105  // data, have the page refreshed, and make sure error messages are still shown on
106  // the new page. Using ajax leads to complexity because Elgg wants to send the error
107  // messages back to the client.
108  var $form = $('<form method="post" />');
109  $form.prop('action', elgg.security.addToken(this.href));
110  $form.append('<input type="hidden" name="guids" value="' + guids.join(',') + '" />');
111  $form.appendTo("body").submit();
112  }
113 
121  function movePlugin (e, ui) {
122  // get guid from id like elgg-object-<guid>
123  var pluginGuid = ui.item.attr('id');
124  pluginGuid = pluginGuid.replace('elgg-object-', '');
125 
126  elgg.action('admin/plugins/set_priority', {
127  data: {
128  plugin_guid: pluginGuid,
129  // we start at priority 1
130  priority: ui.item.index() + 1
131  },
132  success: function() {
133  // update plugins with priority dependences
134  var priorityDep = new RegExp(elgg.echo('ElggPlugin:Dependencies:Priority'));
135  ui.item.siblings().andSelf().each(function() {
136  if (priorityDep.test($(this).find('.elgg-dependency-requires').text())) {
137  updatePluginView($(this));
138  }
139  });
140  }
141  });
142  }
143 
150  function updatePluginView (pluginView) {
151  // get guid from id like elgg-object-<guid>
152  var pluginGuid = pluginView.attr('id');
153  pluginGuid = pluginGuid.replace('elgg-object-', '');
154 
155  elgg.get({
156  url: elgg.config.wwwroot + "ajax/view/object/plugin/full",
157  dataType: "html",
158  cache: false,
159  data: {
160  guid: pluginGuid,
161  display_reordering: true
162  },
163  success: function(htmlData) {
164  if (htmlData.length > 0) {
165  pluginView.html(htmlData);
166  }
167  }
168  });
169  }
170 
178  function editProfileField (value, settings) {
179  var id = $(this).attr('id');
180  id = id.replace('elgg-profile-field-', '');
181 
182  var data = {
183  id: id,
184  label: value
185  };
186 
187  elgg.action('profile/fields/edit', data);
188  return value;
189  }
190 
198  function moveProfileField (e, ui) {
199  var orderArr = $('#elgg-profile-fields').sortable('toArray');
200  var orderStr = orderArr.join(',');
201 
202  elgg.action('profile/fields/reorder', {
203  fieldorder: orderStr
204  });
205  }
206 
212  function deleteNotice (e) {
213  e.preventDefault();
214  var $container = $(this).closest('p');
215 
216  elgg.action($(this).attr('href'), {
217  success: function(json) {
218  $container.slideUp('medium');
219  }
220  });
221  }
222 
228  function simplecacheToggle () {
229  // when the checkbox is disabled, do not toggle the compression checkboxes
230  if (!$(this).hasClass('elgg-state-disabled')) {
231  var names = ['simplecache_minify_js', 'simplecache_minify_css', 'cache_symlink_enabled'];
232  for (var i = 0; i < names.length; i++) {
233  var $input = $('input[type!=hidden][name="' + names[i] + '"]');
234  if ($input.length) {
235  $input.parent().toggleClass('elgg-state-disabled');
236  }
237  }
238  }
239  }
240 
246  function filterPluginCategory (e) {
247  e.preventDefault();
248 
249  // remove selected state from all buttons
250  $(".elgg-admin-plugins-categories > li").removeClass("elgg-state-selected");
251 
252  // show plugins with the selected category
253  $(".elgg-plugin").hide();
254  $(".elgg-plugin-category-" + $(this).attr("rel")).show();
255  $(this).closest('li').addClass("elgg-state-selected");
256  }
257 
263  function showPluginDetails () {
264  // remove selected state from all buttons
265  $(".elgg-plugin-details-container > ul > li").removeClass("elgg-state-selected");
266 
267  // must use .hide/show() to work with elgg-tabs
268  $(".elgg-plugin-details-container > div > div").hide();
269  $(".elgg-plugin-details-container ." + $(this).attr("rel")).show();
270 
271  $(this).parent().addClass("elgg-state-selected");
272  }
273 
279  function showPluginScreenshot () {
280  $(this).parent().find(".elgg-plugin-screenshot").removeClass("elgg-state-selected");
281  $(this).addClass("elgg-state-selected");
282 
283  // must use .hide/show() to work with elgg-tabs
284  $(".elgg-plugin-details-screenshots > div > img").hide();
285  $(".elgg-plugin-details-screenshots > div > img[rel='" + $(this).attr("rel") + "']").show();
286  }
287 
288  init();
289 });
elgg
Definition: install.js:23
elgg comments init
Initialize comment inline editing.
Definition: comments.js:118
elgg module widget elgg state draggable elgg widget handle
Definition: admin.css.php:1238
if(!$owner||!($owner instanceof ElggUser)||!$owner->canEdit()) $input
Definition: edit.php:19
line height
Definition: admin.css.php:82
function editable
define(function(require){var $=require('jquery');var ui=require('jquery-ui');var elgg=require('elgg');var spinner=require('elgg/spinner');function init(){$('.elgg-system-messages li').stop(true);$(document).off('click', '.elgg-system-messages li');$(document).on('click', '.elgg-system-messages li', function(e){if(!$(e.target).is('a')){$(this).stop().slideUp('medium');}});$('#elgg-plugin-list > ul').sortable({items: 'li:has(>.elgg-state-draggable)', handle: '.elgg-head', forcePlaceholderSize:true, placeholder: 'elgg-widget-placeholder', opacity:0.8, revert:500, stop:movePlugin});$(".elgg-state-editable").editable(editProfileField,{type: 'text', onblur: 'submit', width: '300px', height: 'none', style: 'display:inline;'});$('#elgg-profile-fields').sortable({items: 'li', handle: 'span.elgg-state-draggable', stop:moveProfileField});$('a.elgg-admin-notice').click(deleteNotice);$(document).on('click', 'input:checkbox.elgg-state-disabled, label.elgg-state-disabled > input:checkbox', function(){return false;});$('[name=simplecache_enabled]').click(simplecacheToggle);$(document).on('click', '.elgg-admin-plugins-categories a', filterPluginCategory);$(document).on('click', '.elgg-plugin-details-container > ul a', showPluginDetails);$(document).on('click', '.elgg-plugins-toggle', toggleAllPlugins);$(document).on('mouseenter', '.elgg-plugin-details-screenshots.elgg-plugin-screenshot', showPluginScreenshot);}function toggleAllPlugins(e){e.preventDefault();if(!confirm(elgg.echo('question:areyousure'))){return;}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));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){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));}});}});}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 editProfileField(value, settings){var id=$(this).attr('id');id=id.replace('elgg-profile-field-', '');var data={id:id, label:value};elgg.action('profile/fields/edit', data);return value;}function moveProfileField(e, ui){var orderArr=$('#elgg-profile-fields').sortable('toArray');var orderStr=orderArr.join(',');elgg.action('profile/fields/reorder',{fieldorder:orderStr});}function deleteNotice(e){e.preventDefault();var $container=$(this).closest('p');elgg.action($(this).attr('href'),{success:function(json){$container.slideUp('medium');}});}function simplecacheToggle(){if(!$(this).hasClass('elgg-state-disabled')){var names=['simplecache_minify_js', 'simplecache_minify_css', 'cache_symlink_enabled'];for(var i=0;i< names.length;i++){var $input=$('input[type!=hidden][name="' + names[i] + '"]');if($input.length){$input.parent().toggleClass('elgg-state-disabled');}}}}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 showPluginDetails(){$(".elgg-plugin-details-container > ul > li").removeClass("elgg-state-selected");$(".elgg-plugin-details-container > div > div").hide();$(".elgg-plugin-details-container ."+$(this).attr("rel")).show();$(this).parent().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();})
Admin-area specific javascript functions.
elgg form settings
Definition: admin.css.php:596
list style type
Definition: admin.css.php:777
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: GPL-LICENSE.txt:43
$form
Definition: settings.php:18
$container
Definition: delete.php:29
label
Definition: admin.css.php:464
elgg require
Throw an error if the required package isn&#39;t present.
Definition: elgglib.js:164
function elgg combo checkbox click(function(){if($(this).is(':checked')){$(this).prev().attr('disabled', true);$(this).prev().val('');}else{$(this).prev().attr('disabled', false);}})
list style
Definition: admin.css.php:1203
GNU GENERAL PUBLIC LICENSE June Free Software Inc Franklin Fifth MA USA Everyone is permitted to copy and distribute verbatim copies of this license document
Definition: GPL-LICENSE.txt:4
min width
Definition: admin.css.php:166
elgg message elgg state success
Definition: admin.css.php:252
if(!$site) if(!($site instanceof ElggSite)) $site url
elgg widget placeholder
Definition: admin.css.php:1277
i
Definition: admin.css.php:47