Elgg  Version 5.1
add_panel.js
Go to the documentation of this file.
1 define(['jquery', 'elgg', 'elgg/Ajax'], function($, elgg, Ajax) {
2 
11  function addWidget(event) {
12  event.preventDefault();
13 
14  var $item = $(this).closest('li');
15 
16  // if multiple instances not allow, disable this widget type add button
17  if (!$item.is('.elgg-widget-multiple')) {
18  $item.toggleClass('elgg-state-unavailable elgg-state-available');
19  }
20 
21  var href = $(this).attr('href');
22  var ajax = new Ajax();
23 
24  ajax.path(href).done(function(output) {
25  var query_parts = elgg.parse_url(href, 'query', true);
26  var selector = '';
27  var context = query_parts['context'];
28  var page_owner_guid = query_parts['page_owner_guid'];
29  var new_widget_column = query_parts['new_widget_column'] || 1;
30  var new_widget_position = query_parts['new_widget_position'] || 'top';
31 
32  if (context && page_owner_guid) {
33  // target the correct widget layout
34  selector = '.elgg-layout-widgets-' + context + '[data-page-owner-guid="' + page_owner_guid + '"] .elgg-widget-col-' + new_widget_column;
35  } else {
36  selector = '.elgg-widget-col-' + new_widget_column;
37  }
38 
39  if (new_widget_position === 'top') {
40  $(selector).prepend(output);
41  } else {
42  $(selector).append(output);
43  }
44  });
45  };
46 
47  $(document).on('click', '.elgg-widgets-add-panel .elgg-widgets-add-actions .elgg-button-submit', addWidget);
48 
49  $(document).on('keyup', '.elgg-widgets-add-panel input[name="widget_search"]', function() {
50  var $container = $('.elgg-widgets-add-panel');
51  var $items = $container.find('> .elgg-body > ul > li');
52  var q = $(this).val();
53 
54  if (q === '') {
55  $items.show();
56  } else {
57  $items.hide();
58  $items.filter(function () {
59  return $(this).text().toUpperCase().indexOf(q.toUpperCase()) >= 0;
60  }).show();
61  }
62  });
63 });
if(!$items) $item
Definition: delete.php:13
$items
Definition: delete.php:8
define(['jquery', 'elgg', 'elgg/Ajax'], function($, elgg, Ajax){function addWidget(event){event.preventDefault();var $item=$(this).closest('li');if(!$item.is('.elgg-widget-multiple')){$item.toggleClass('elgg-state-unavailable elgg-state-available');}var href=$(this).attr('href');var ajax=new Ajax();ajax.path(href).done(function(output){var query_parts=elgg.parse_url(href, 'query', true);var selector= '';var context=query_parts['context'];var page_owner_guid=query_parts['page_owner_guid'];var new_widget_column=query_parts['new_widget_column']||1;var new_widget_position=query_parts['new_widget_position']|| 'top';if(context &&page_owner_guid){selector= '.elgg-layout-widgets-'+context+ '[data-page-owner-guid="' + page_owner_guid + '"].elgg-widget-col-'+new_widget_column;}else{selector= '.elgg-widget-col-'+new_widget_column;}if(new_widget_position=== 'top'){$(selector).prepend(output);}else{$(selector).append(output);}});};$(document).on('click', '.elgg-widgets-add-panel.elgg-widgets-add-actions.elgg-button-submit', addWidget);$(document).on('keyup', '.elgg-widgets-add-panel input[name="widget_search"]', function(){var $container=$('.elgg-widgets-add-panel');var $items=$container.find('>.elgg-body > ul > li');var q=$(this).val();if(q=== ''){$items.show();}else{$items.hide();$items.filter(function(){return $(this).text().toUpperCase().indexOf(q.toUpperCase()) >=0;}).show();}});})
$container
Definition: delete.php:24
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
var elgg
Definition: elgglib.js:4