Elgg  Version 5.1
plugins.js
Go to the documentation of this file.
1 define(['jquery', 'elgg/spinner', 'elgg/Ajax', 'elgg/system_messages', 'elgg/security', 'elgg/i18n', 'jquery-ui/widgets/sortable'], function($, spinner, Ajax, system_messages, security, i18n) {
2  function freezePlugins() {
3  $('#elgg-plugin-list-cover').css('display', 'block');
4  };
5  function unfreezePlugins() {
6  $('#elgg-plugin-list-cover').css('display', 'none');
7  };
8 
9  function initPluginReordering() {
10  $('#elgg-plugin-list > .elgg-list-container > ul').sortable({
11  items: 'li:has(> .elgg-state-draggable)',
12  handle: '.elgg-body',
13  forcePlaceholderSize: true,
14  placeholder: 'elgg-plugin-placeholder',
15  opacity: 0.8,
16  revert: 500,
17  stop: movePlugin
18  });
19  };
20 
21  function toggleSinglePlugin() {
22  spinner.start();
23  freezePlugins();
24  };
25 
32  function toggleAllPlugins(event) {
33  event.preventDefault();
34 
35  if (!confirm(i18n.echo('question:areyousure'))) {
36  return;
37  }
38 
39  freezePlugins();
40 
41  var guids = [],
42  state = $(this).data('desiredState'),
43  find_state = state == 'active' ? 'inactive' : 'active';
44 
45  $('.elgg-plugin.elgg-state-' + find_state + ':visible').each(function () {
46  var guid = $(this).data('guid');
47  if (guid) {
48  guids.push(guid);
49  }
50  });
51 
52  if (!guids.length) {
53  system_messages.error(i18n.echo('admin:plugins:already:' + state));
54  unfreezePlugins();
55  return;
56  }
57 
58  spinner.start();
59 
60  // We create a regular form and submit it. This is the simplest way to send the
61  // data, have the page refreshed, and make sure error messages are still shown on
62  // the new page. Using ajax leads to complexity because Elgg wants to send the error
63  // messages back to the client.
64  var $form = $('<form method="post" />');
65  $form.prop('action', security.addToken(this.href));
66  $form.append('<input type="hidden" name="guids" value="' + guids.join(',') + '" />');
67  $form.appendTo("body").submit();
68  };
69 
77  function movePlugin(e, ui) {
78  freezePlugins();
79 
80  // get guid from id like elgg-object-<guid>
81  var pluginGuid = ui.item.attr('id');
82  pluginGuid = pluginGuid.replace('elgg-object-', '');
83 
84  var ajax = new Ajax();
85  ajax.action('admin/plugins/set_priority', {
86  data: {
87  plugin_guid: pluginGuid,
88  // we start at priority 1
89  priority: ui.item.index() + 1
90  },
91  success: function() {
92  unfreezePlugins();
93  }
94  });
95  };
96 
102  function filterPluginCategory(event) {
103  event.preventDefault();
104 
105  // remove selected state from all buttons
106  $(".elgg-admin-plugins-categories > li").removeClass("elgg-state-selected");
107 
108  // show plugins with the selected category
109  $(".elgg-plugin").hide();
110  $(".elgg-plugin-category-" + $(this).attr("rel")).show();
111  $(this).closest('li').addClass("elgg-state-selected");
112  };
113 
114  initPluginReordering();
115 
116  $(document).on('click', '.elgg-admin-plugins-categories a', filterPluginCategory);
117  $(document).on('click', '.elgg-plugins-toggle', toggleAllPlugins);
118  $(document).on('click', '.elgg-plugin-state-change', toggleSinglePlugin);
119 });
if(!$widget instanceof\ElggWidget) if(!$widget->canEdit()) $form
Definition: edit.php:19
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(){spinner.start();freezePlugins();};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);})
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