Elgg  Version 5.1
system_messages.js
Go to the documentation of this file.
1 define(['jquery', 'elgg'], function ($, elgg) {
2 
3  // hide the current messages
4  $('.elgg-system-messages .elgg-message').each(function () {
5  var $message = $(this);
6 
7  var delay = $message.data().ttl;
8  if (delay === 0) {
9  // 0 means an explicit persistent message
10  return;
11  }
12 
13  if (!delay && !$message.hasClass('elgg-message-error')) {
14  delay = elgg.config.message_delay;
15  }
16 
17  if (!delay) {
18  return;
19  }
20 
21  var $list_item = $message.parent();
22  $list_item.animate({opacity: '1.0'}, delay).fadeOut('slow');
23  });
24 
25  // if the user clicks the before pseudo selector of a system message, make it disappear
26  $(document).on('click', '.elgg-system-messages .elgg-message', function(e) {
27  var $this = $(this);
28 
29  // slideUp allows dismissals without notices shifting around unpredictably
30  $this.clearQueue().slideUp(100, function () {
31  $this.remove();
32  });
33  });
34 
35  $(document).on('click', '.elgg-system-messages .elgg-message .elgg-inner', function(e) {
36  // prevent clicks from bubbling to top so 'closing' a message only works with before pseudo selector content
37  e.stopImmediatePropagation();
38  });
39 
47  function showMessage(msgs, delay, type) {
48  if (msgs === undefined) {
49  return;
50  }
51 
52  //Handle non-arrays
53  if (!Array.isArray(msgs)) {
54  msgs = [msgs];
55  }
56 
57  var classes = ['elgg-message'];
58  if (type) {
59  classes.push('elgg-message-' + type);
60  }
61 
62  // validate delay. Must be a positive integer.
63  delay = (typeof delay === 'string') ? parseInt(delay, 10) : delay;
64  if (isNaN(delay) || delay < 0) {
65  delay = 0;
66  }
67 
68  var messages_html = [];
69  msgs.forEach(function(msg) {
70  messages_html.push('<li><div class="' + classes.join(' ') + '"><div class="elgg-inner"><div class="elgg-body">' + msg + '</div></div></div></li>');
71  });
72 
73  var $new_messages = $(messages_html.join('')).appendTo($('ul.elgg-system-messages'));
74  if (delay > 0) {
75  $new_messages.animate({opacity: '1.0'}, delay).fadeOut('slow')
76  }
77  };
78 
79  return {
83  clear: function () {
84  $('ul.elgg-system-messages').empty();
85  },
86 
93  success: function (message, delay) {
94  delay = parseInt(delay || elgg.config.message_delay, 10);
95 
96  showMessage(message, delay, 'success');
97  },
98 
105  error: function (message, delay) {
106  showMessage(message, delay, 'error');
107  }
108  };
109 });
$result message
$result error
define(['jquery', 'elgg'], function($, elgg){$('.elgg-system-messages.elgg-message').each(function(){var $message=$(this);var delay=$message.data().ttl;if(delay===0){return;}if(!delay &&!$message.hasClass('elgg-message-error')){delay=elgg.config.message_delay;}if(!delay){return;}var $list_item=$message.parent();$list_item.animate({opacity: '1.0'}, delay).fadeOut('slow');});$(document).on('click', '.elgg-system-messages.elgg-message', function(e){var $this=$(this);$this.clearQueue().slideUp(100, function(){$this.remove();});});$(document).on('click', '.elgg-system-messages.elgg-message.elgg-inner', function(e){e.stopImmediatePropagation();});function showMessage(msgs, delay, type){if(msgs===undefined){return;}if(!Array.isArray(msgs)){msgs=[msgs];}var classes=['elgg-message'];if(type){classes.push('elgg-message-'+type);}delay=(typeof delay=== 'string')?parseInt(delay, 10):delay;if(isNaN(delay)||delay< 0){delay=0;}var messages_html=[];msgs.forEach(function(msg){messages_html.push('< li >< div class="' + classes.join(' ') + '">< div class="elgg-inner">< div class="elgg-body">'+msg+ '</div ></div ></div ></li >');});var $new_messages=$(messages_html.join('')).appendTo($('ul.elgg-system-messages'));if(delay > 0){$new_messages.animate({opacity: '1.0'}, delay).fadeOut('slow')}};return{clear:function(){$('ul.elgg-system-messages').empty();}, success:function(message, delay){delay=parseInt(delay||elgg.config.message_delay, 10);showMessage(message, delay, 'success');}, error:function(message, delay){showMessage(message, delay, 'error');}};})
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