PageSourceSearch

https://www.cestadomu.cz/sites/all/modules/absolute_messages/absolute_messages.js?tlvfc7

js cestadomu.cz collected 2026-09-24 19:01:49 UTC 9,572 bytes, 228 lines download raw bytes

1Drupal.absolute_messages = Drupal.absolute_messages || {};
2
3(function ($) {
4
5  Drupal.absolute_messages.initialize = function(){
6
7    Drupal.absolute_messages.timeouts = new Array();
8    if ($("#absolute-messages-messages").length > 0) {
9      // Move messages from closure to right after opening of body tag.
10      $("body").prepend($("#absolute-messages-messages"));
11      
12      if (Drupal.absolute_messages.max_lines) {
13        Drupal.absolute_messages.checkHeights();
14      }
15      
16      // Bind all required events.
17      Drupal.absolute_messages.bindEvents();
18
19      // Show all messages.
20      $(".absolute-messages-message").not(".absolute-messages-dismiss-all").slideDown(600);
21      Drupal.absolute_messages.checkIcons();
22    }
23
24    // Move any additional messages addad by Ajax calls 
25    // after the page was generated.
26    $(document).ajaxComplete(function(){
27      Drupal.absolute_messages.checkNewMessages();
28    });
29
30  };
31
32  Drupal.absolute_messages.checkHeights = function(){
33    var line_height;
34    var current_height;
35    // display-none elements do not have height, so we need to display
36    // them first  (although hidden) to be able to get their height.
37    // Also, force-set height to avoid "jumpy" animation.
38    $(".absolute-messages-message").each(function(){
39      if ($(this).css("display") == "none") {
40        $(this).css({'visibility':'hidden', 'display':'block'})
41               .css("height", $(this).height());
42        line_height = parseInt($(".absolute-messages-message .content").css("line-height"));
43        current_height = $(".content", this).height();
44        if (current_height > line_height * Drupal.absolute_messages.max_lines) {
45          $(".content", this).css("max-height", line_height * Drupal.absolute_messages.max_lines)
46                             .addClass("collapsed")
47                             .parents(".absolute-messages-message")
48                             .addClass("collapsible")
49                             .attr("title", "Click to see the whole message");
50        }
51        // And hide them again so we still can manage them using jQuery sliding.
52        $(this).removeAttr('style');
53      }
54    });
55  };
56  
57  Drupal.absolute_messages.checkIcons = function(){
58    var visible_messages = $(".absolute-messages-message:visible").not(".absolute-messages-dismiss-all").size();
59    // If no messages are displayed, remove "Dismiss all" icon
60    // and show "Show dismissed messages" icon.
61    if (visible_messages == 0) {
62      $("div.absolute-messages-dismiss-all").hide();
63      $("#absolute-messages-show").show();
64    };
65    // Show "Dismiss all messages" icon if number of visible
66    // messages is higher that configured in module settings.
67    if (Drupal.absolute_messages.dismiss_all_count && visible_messages > Drupal.absolute_messages.dismiss_all_count) {
68      $("div.absolute-messages-dismiss-all").show();
69    }
70  };
71
72  Drupal.absolute_messages.checkTopOffset = function(){
73    // Let's wait for fully generated #admin-menu if it's not ready yet.
74    if ($("#admin-menu").height() == null) {
75      setTimeout("Drupal.absolute_messages.checkTopOffset()", 100);
76    }
77    var top_offset = 0;
78    if ($(window).scrollTop() < $("#admin-menu").height()) {
79      top_offset = $("#admin-menu").height() - $(window).scrollTop();
80    }
81    $("#absolute-messages-messages").css("top", top_offset + "px");
82  };
83  
84  Drupal.absolute_messages.bindEvents = function(){
85    // First try to unbind all previously bound events, to avoid multiple calls
86    // after bindings are refreshed when adding new messages on ajaxComplete.
87    
88    // Fix message bar to the top of browser's viewport.
89    if ($("#absolute-messages-messages").css("position") == "fixed") {
90      // #toolbar div has fixed position too, no need then to check it when scrolling.
91      if ($("#toolbar").length > 0) {
92        $("#absolute-messages-messages").css("top", $("#toolbar").height() + "px");
93      }
94      // #admin-menu could be not ready at page load yet, so "length" property
95      // will not work as expected. Therefore let's check body class instead.
96      else if ($("body").hasClass("admin-menu")) {
97        Drupal.absolute_messages.checkTopOffset();
98        $(window).scroll(function(){
99          Drupal.absolute_messages.checkTopOffset();
100        });
101      }
102    }
103    
104    // Dismiss single message.
105    $("a.absolute-messages-dismiss").unbind("click").bind("click", function(){
106      // Unbind "click" event first to avoid accidental collapsing/expanding.
107      $(this).parents(".absolute-messages-message").unbind("click").slide
107Up(300, function(){
108        Drupal.absolute_messages.checkIcons();
109      });
110    });
111
112    // Dismiss all messages.
113    $("a.absolute-messages-dismiss-all").unbind("click").bind("click", function(){
114      $(".absolute-messages-message").slideUp(300, function(){
115        Drupal.absolute_messages.checkIcons();
116      });
117    });
118
119    // Show cursor as pointer when hovering over 'show dismissed messages' icon.
120    // This is mainly for IE, as it does not want to change the cursor through CSS
121    // over the whole element when containing element has width and height of 0px.
122    $("#absolute-messages-show").unbind("mouseenter").bind("mouseenter", function(){
123      $(this).css("cursor", "pointer");
124    }).unbind("mouseleave").bind("mouseleave", function(){
125      $(this).css("cursor", "auto");
126    });
127
128    // Show all previously dismissed messages after clicking on 'show dismissed' icon.
129    $("#absolute-messages-show").unbind("click").bind("click", function(){
130      $(this).hide();
131      $(".absolute-messages-message").not(".absolute-messages-dismiss-all").slideDown(300, function(){
132        Drupal.absolute_messages.checkIcons();
133      });
134    });
135
136    // Automatic dismiss messages after specified time.
137    $.each(Drupal.absolute_messages.dismiss, function(index, value){
138      if (value == 1) {
139        Drupal.absolute_messages.timeouts[index] = setTimeout(function(){
140          $(".absolute-messages-"+index).slideUp(600, function(){
141            Drupal.absolute_messages.checkIcons();
142          });
143        }, Drupal.absolute_messages.dismiss_time[index] * 1000);
144      }
145    });
146
147    // Clear all timeouts on mouseover and set them again on mouseout.
148    $("#absolute-messages-messages").unbind("mouseenter").bind("mouseenter", function(){
149      Drupal.absolute_messages.clearTimeouts();
150    }).unbind("mouseleave").bind("mouseleave", function(){
151      Drupal.absolute_messages.setTimeouts();
152    });
153
154    // Expand/collapse long messages.
155    $(".absolute-messages-message.collapsible").unbind("click").bind("click", function(){
156      if ($(".content", this).hasClass("collapsed")) {
157        Drupal.absolute_messages.messageExpand($(".content", this));
158      } else {
159        Drupal.absolute_messages.messageCollapse($(".content", this));
160      }
161    });
162
163  };
164  
165  Drupal.absolute_messages.setTimeouts = function(){
166    $.each(Drupal.absolute_messages.dismiss, function(index, value){
167      if (value == 1) {
168        Drupal.absolute_messages.timeouts[index] = setTimeout(function(){
169          $(".absolute-messages-"+index).slideUp(600, function(){
170            Drupal.absolute_messages.checkIcons();
171          });
172        }, Drupal.absolute_messages.dismiss_time[index] * 1000);
173      }
174    });
175  };
176
177  Drupal.absolute_messages.clearTimeouts = function(){
178    $.each(Drupal.absolute_messages.dismiss, function(index, value){
179      clearTimeout(Drupal.absolute_messages.timeouts[index]);
180    });
181  };
182  
183  Drupal.absolute_messages.messageCollapse = function(element){
184    $(element).css("max-height", parseInt($(element).css("line-height")) * Drupal.absolute_messages.max_lines)
185              .removeClass("expanded")
186              .addClass("collapsed");
187  };
188
189  Drupal.absolute_messages.messageExpand = function(element){
190    $(element).css("max-height", "")
191              .removeClass("collapsed")
192              .addClass("expanded");
193  };
194
195  Drupal.absolute_messages.checkNewMessages = function(){
196    Drupal.absolute_messages.clearTimeouts();
197    // Search for any #absolute-messages-messages divs
198    // which are not direct children of <body> tag.
199    $("body").children().find("#absolute-messages-messages").each(function(index){
200      if (Drupal.absolute_messages.max_lines) {
201        Drupal.absolute_messages.checkHeights();
202      }
203      // If #absolute-messages-messages dix does not exist yet right after
204      // the body tag, let's just move the freshly created one there.
205      if ($("body > #absolute-messages-messages").length == 0) {
206        $("body").prepend($(this));
207        $(".absolute-messages-message").not(".absolute-messages-dismiss-all").slideDown(600);
208      }
209      // On the other hand, if it already exists there, let's move all
210      // new messages only and add them right before "Dismiss all messages"
211      // icon, then remove the new #absolute-messages-messages div completely.
212      else {
213        $("#absolute-messages-show").hide();
214        $("div.absolute-messages-dismiss-all", "body > #absolute-messages-messages").before($(".absolute-messages-message", this)
215                                                                                    .not(".absolute-messages-dismiss-all", this)
216                                                                                    .slideDown(600));
217        $(this).remove();
218      }
219      Drupal.absolute_messages.bindEvents();
220      Drupal.absolute_messages.checkIcons();
221    });
222  };
223  
224  $(document).ready(function(){
225    Drupal.absolute_messages.initialize();
226  });
227
228})(jQuery);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.