PageSourceSearch

https://www.vip.pt/old-assets/js/js_aczm2rRgH_slWBPnvD3KMrK7rwa1i99HOq8IUAb99Co.js

js vip.pt collected 2026-10-02 12:12:36 UTC 22,115 bytes, 605 lines download raw bytes

1
2/**
3 * jQuery Once Plugin v1.2
4 * http://plugins.jquery.com/project/once
5 *
6 * Dual licensed under the MIT and GPL licenses:
7 *   http://www.opensource.org/licenses/mit-license.php
8 *   http://www.gnu.org/licenses/gpl.html
9 */
10
11(function ($) {
12  var cache = {}, uuid = 0;
13
14  /**
15   * Filters elements by whether they have not yet been processed.
16   *
17   * @param id
18   *   (Optional) If this is a string, then it will be used as the CSS class
19   *   name that is applied to the elements for determining whether it has
20   *   already been processed. The elements will get a class in the form of
21   *   "id-processed".
22   *
23   *   If the id parameter is a function, it will be passed off to the fn
24   *   parameter and the id will become a unique identifier, represented as a
25   *   number.
26   *
27   *   When the id is neither a string or a function, it becomes a unique
28   *   identifier, depicted as a number. The element's class will then be
29   *   represented in the form of "jquery-once-#-processed".
30   *
31   *   Take note that the id must be valid for usage as an element's class name.
32   * @param fn
33   *   (Optional) If given, this function will be called for each element that
34   *   has not yet been processed. The function's return value follows the same
35   *   logic as $.each(). Returning true will continue to the next matched
36   *   element in the set, while returning false will entirely break the
37   *   iteration.
38   */
39  $.fn.once = function (id, fn) {
40    if (typeof id != 'string') {
41      // Generate a numeric ID if the id passed can't be used as a CSS class.
42      if (!(id in cache)) {
43        cache[id] = ++uuid;
44      }
45      // When the fn parameter is not passed, we interpret it from the id.
46      if (!fn) {
47        fn = id;
48      }
49      id = 'jquery-once-' + cache[id];
50    }
51    // Remove elements from the set that have already been processed.
52    var name = id + '-processed';
53    var elements = this.not('.' + name).addClass(name);
54
55    return $.isFunction(fn) ? elements.each(fn) : elements;
56  };
57
58  /**
59   * Filters elements that have been processed once already.
60   *
61   * @param id
62   *   A required string representing the name of the class which should be used
63   *   when filtering the elements. This only filters elements that have already
64   *   been processed by the once function. The id should be the same id that
65   *   was originally passed to the once() function.
66   * @param fn
67   *   (Optional) If given, this function will be called for each element that
68   *   has not yet been processed. The function's return value follows the same
69   *   logic as $.each(). Returning true will continue to the next matched
70   *   element in the set, while returning false will entirely break the
71   *   iteration.
72   */
73  $.fn.removeOnce = function (id, fn) {
74    var name = id + '-processed';
75    var elements = this.filter('.' + name).removeClass(name);
76
77    return $.isFunction(fn) ? elements.each(fn) : elements;
78  };
79})(jQuery);
80;
81
82var Drupal = Drupal || { 'settings': {}, 'behaviors': {}, 'locale': {} };
83
84// Allow other JavaScript libraries to use $.
85jQuery.noConflict();
86
87(function ($) {
88
89  /**
90   * Override jQuery.fn.init to guard against XSS attacks.
91   *
92   * See http://bugs.jquery.com/ticket/9521
93   */
94  var jquery_init = $.fn.init;
95  $.fn.init = function (selector, context, rootjQuery) {
96    // If the string contains a "#" before a "<", treat it as invalid HTML.
97    if (selector && typeof selector === 'string') {
98      var hash_position = selector.indexOf('#');
99      if (hash_position >= 0) {
100        var bracket_position = selector.indexOf('<');
101        if (bracket_position > hash_position) {
102          throw 'Syntax error, unrecognized expression: ' + selector;
103        }
104      }
105    }
106    return jquery_init.call(this, selector, context, rootjQuery);
107  };
108  $.fn.init.prototype = jquery_init.prototype;
109
110  /**
111   * Attach all registered behaviors to a page element.
112   *
113   * Behaviors are event-triggered actions that attach to page elements, enhancing
114   * default non-JavaScript UIs. Behaviors are registered in the Drupal.behaviors
115   * object using the method 'attach' and optionally also 'detach' as follows:
116   * @code
117   *    Drupal.behaviors.behaviorName = {
118   *      attach: function (context, settings) {
119   *        ...
120   *      },
121   *      detach: function (context, settings, trigger) {
122   *        ...
123   *      }
124   *    };
125   * @endcode
126   *
127   * Drupal.attachBehaviors is added below to the jQuery ready event and so
128   * runs on initial page load. Developers implementing AHAH/Ajax in their
129   * solutions should also call this function after new page content has been
130   * loaded, feeding in an element to be processed, in order to attach all
131   * behaviors to the new content.
132   *
133   * Behaviors should use
134   * @code
135   *   $(selector).once('behavior-name', function () {
136   *     ...
137   *   });
138   * @endcode
139   * to ensure the behavior is attached only once to a given element. (Doing so
140   * enables the reprocessing of given elements, which may be needed on occasion
141   * despite the ability to limit behavior attachment to a particular element.)
142   *
143   * @param context
144   *   An element to attach behaviors to. If none is given, the document element
145   *   is used.
146   * @param settings
147   *   An object containing settings for the current context. If none given, the
148   *   global Drupal.settings object is used.
149   */
150  Drupal.attachBehaviors = function (context, settings) {
151    context = context || document;
152    settings = settings || Drupal.settings;
153    // Execute all of them.
154    $.each(Drupal.behaviors, function () {
155      if ($.isFunction(this.attach)) {
156        this.attach(context, settings);
157      }
158    });
159  };
160
161  /**
162   * Detach registered behaviors from a page element.
163   *
164   * Developers implementing AHAH/Ajax in their solutions should call this
165   * function before page content is about to be removed, feeding in an element
166   * to be processed, in order to allow special behaviors to detach from the
167   * content.
168   *
169   * Such implementations should look for the class name that was added in their
170   * corresponding Drupal.behaviors.behaviorName.attach implementation, i.e.
171   * behaviorName-processed, to ensure the behavior is detached only from
172   * previously processed elements.
173   *
174   * @param context
175   *   An element to detach behaviors from. If none is given, the document element
176   *   is used.
177   * @param settings
178   *   An object containing settings for the current context. If none given, the
179   *   global Drupal.settings object is used.
180   * @param trigger
181   *   A string containing what's causing the behaviors to be detached. The
182   *   possible triggers are:
183   *   - unload: (default) The context element is being removed from the DOM.
184   *   - move: The element is about to be moved within the DOM (for example,
185   *     during a tabledrag row swap). After the move is completed,
186   *     Drupal.attachBehaviors() is called, so that the behavior can undo
187   *     whatever it did in response to the move. Many behaviors won't need to
188   *     do anything simply in response to the element being moved, but because
189   *     IFRAME elements reload their "src" when being moved within the DOM,
190   *     behaviors bound to IFRAME elements (like WYSIWYG editors) may need to
191   *     take some action.
192   *   - serialize: When an Ajax form is submitted, this is called with the
193   *     form as the context. This provides every behavior within the form an
194   *     opportunity to ensure that the field elements have correct content
195   *     in them before the form is serialized. The canonical use-case is so
196   *     that WYSIWYG editors can update the hidden textarea to which they are
197   *     bound.
198   *
199   * @see Drupal.attachBehaviors
200   */
201  Drupal.detachBehaviors = function (context, settings, trigger) {
202    context = context || document;
203    settings = settings || Drupal.settings;
204    trigger = trigger || 'unload';
205    // Execute all of them.
206    $.each(Drupal.behaviors, function () {
207      if ($.isFunction(this.detach)) {
208        this.detach(context, settings, trigger);
209      }
210    });
211  };
212
213  /**
214   * Encode special characters in a plain-text string for display as HTML.
215   *
216   * @ingroup sanitization
217   */
218  Drupal.checkPlain = function (str) {
219    var character, regex,
220      replace = { '&': '&amp;', '"': '&quot;', '<': '&lt;', '>': '&gt;' };
221    str = String(str);
222    for (character in replace) {
223      if (replace.hasOwnProperty(character)) {
224        regex = new RegExp(character, 'g');
225        str = str.replace(regex, replace[character]);
226      }
227    }
228    return str;
229  };
230
231  /**
232   * Replace placeholders with sanitized values in a string.
233   *
234   * @param str
235   *   A string with placeholders.
236   * @param args
237   *   An object of replacements pairs to make. Incidences of any key in this
238   *   array are replaced with the corresponding value. Based on the first
239   *   character of the key, the value is escaped and/or themed:
240   *    - !variable: inserted as is
241   *    - @variable: escape plain text to HTML (Drupal.checkPlain)
242   *    - %variable: escape text and theme as a placeholder for user-submitted
243   *      content (checkPlain + Drupal.theme('placeholder'))
244   *
245   * @see Drupal.t()
246   * @ingroup sanitization
247   */
248  Drupal.formatString = function(str, args) {
249    // Transform arguments before inserting them.
250    for (var key in args) {
251      switch (key.charAt(0)) {
252        // Escaped only.
253        case '@':
254          args[key] = Drupal.checkPlain(args[key]);
255          break;
256        // Pass-through.
257        case '!':
258          break;
259        // Escaped and placeholder.
260        case '%':
261        default:
262          args[key] = Drupal.theme('placeholder', args[key]);
263          break;
264      }
265      str = str.replace(key, args[key]);
266    }
267    return str;
268  };
269
270  /**
271   * Translate strings to the page language or a given language.
272   *
273   * See the documentation of the server-side t() function for further details.
274   *
275   * @param str
276   *   A string containing the English string to translate.
277   * @param args
278   *   An object of replacements pairs to make after translation. Incidences
279   *   of any key in this array are replaced with the corresponding value.
280   *   See Drupal.formatString().
281   *
282   * @param options
283   *   - 'context' (defaults to the empty context): The context the source string
284   *     belongs to.
285   *
286   * @return
287   *   The translated string.
288   */
289  Drupal.t = function (str, args, options) {
290    options = options || {};
291    options.context = options.context || '';
292
293    // Fetch the localized version of the string.
294    if (Drupal.locale.strings && Drupal.locale.strings[options.context] && Drupal.locale.strings[options.context][str]) {
295      str = Drupal.locale.strings[options.context][str];
296    }
297
298    if (args) {
299      str = Drupal.formatString(str, args);
300    }
301    return str;
302  };
303
304  /**
305   * Format a string containing a count of items.
306   *
307   * This function ensures that the string is pluralized correctly. Since Drupal.t() is
308   * called by this function, make sure not to pass already-localized strings to it.
309   *
310   * See the documentation of the server-side format_plural() function for further details.
311   *
312   * @param count
313   *   The item count to display.
314   * @param singular
315   *   The string for the singular case. Please make sure it is clear this is
316   *   singular, to ease translation (e.g. use "1 new comment" instead of "1 new").
317   *   Do not use @count in the singular string.
318   * @param plural
319   *   The string for the plural case. Please make sure it is clear this is plural,
320   *   to ease translation. Use @count in place of the item count, as in "@count
321   *   new comments".
322   * @param args
323   *   An object of replacements pairs to make after translation. Incidences
324   *   of any key in this array are replaced with the corresponding value.
325   *   See Drupal.formatString().
326   *   Note that you do not need to include @count in this array.
327   *   This replacement is done automatically for the plural case.
328   * @param options
329   *   The options to pass to the Drupal.t() function.
330   * @return
331   *   A translated string.
332   */
333  Drupal.formatPlural = function (count, singular, plural, args, options) {
334    var args = args || {};
335    args['@count'] = count;
336    // Determine the index of the plural form.
337    var index = Drupal.locale.pluralFormula ? Drupal.locale.pluralFormula(args['@count']) : ((args['@count'] == 1) ? 0 : 1);
338
339    if (index == 0) {
340      return Drupal.t(singular, args, options);
341    }
342    else if (index == 1) {
343      return Drupal.t(plural, args, options);
344    }
345    else {
346      args['@count[' + index + ']'] = args['@count'];
347      delete args['@count'];
348      return Drupal.t(plural.replace('@count', '@count[' + index + ']'), args, options);
349    }
350  };
351
352  /**
353   * Returns the passed in URL as an absolute URL.
354   *
355   * @param url
356   *   The URL string to be normalized to an absolute URL.
357   *
358   * @return
359   *   The normalized, absolute URL.
360   *
361   * @see https://github.com/angular/angular.js/blob/v1.4.4/src/ng/urlUtils.js
362   * @see https://grack.com/blog/2009/11/17/absolutizing-url-in-javascript
363   * @see https://github.com/jquery/jquery-ui/blob/1.11.4/ui/tabs.js#L53
364   */
365  Drupal.absoluteUrl = function (url) {
366    var urlParsingNode = document.createElement('a');
367
368    // Decode the URL first; this is required by IE <= 6. Decoding non-UTF-8
369    // strings may throw an exception.
370    try {
371      url = decodeURIComponent(url);
372    } catch (e) {}
373
374    urlParsingNode.setAttribute('href', url);
375
376    // IE <= 7 normalizes the URL when assigned to the anchor node similar to
377    // the other browsers.
378    return urlParsingNode.cloneNode(false).href;
379  };
380
381  /**
382   * Returns true if the URL is within Drupal's base path.
383   *
384   * @param url
385   *   The URL string to be tested.
386   *
387   * @return
388   *   Boolean true if local.
389   *
390   * @see https://github.com/jquery/jquery-ui/blob/1.11.4/ui/tabs.js#L58
391   */
392  Drupal.urlIsLocal = function (url) {
393    // Always use browser-derived absolute URLs in the comparison, to avoid
394    // attempts to break out of the base path using directory traversal.
395    var absoluteUrl = Drupal.absoluteUrl(url);
396    var protocol = location.protocol;
397
398    // Consider URLs that match this site's base URL but use HTTPS instead of HTTP
399    // as local as well.
400    if (protocol === 'http:' && absoluteUrl.indexOf('https:') === 0) {
401      protocol = 'https:';
402    }
403    var baseUrl = protocol + '//' + location.host + Drupal.settings.basePath.slice(0, -1);
404
405    // Decoding non-UTF-8 strings may throw an exception.
406    try {
407      absoluteUrl = decodeURIComponent(absoluteUrl);
408    } catch (e) {}
409    try {
410      baseUrl = decodeURIComponent(baseUrl);
411    } catch (e) {}
412
413    // The given URL matches the site's base URL, or has a path under the site's
414    // base URL.
415    return absoluteUrl === baseUrl || absoluteUrl.indexOf(baseUrl + '/') === 0;
416  };
417
418  /**
419   * Generate the themed representation of a Drupal object.
420   *
421   * All requests for themed output must go through this function. It examines
422   * the request and routes it to the appropriate theme function. If the current
423   * theme does not provide an override function, the generic theme function is
424   * called.
425   *
426   * For example, to retrieve the HTML for text that should be emphasized and
427   * displayed as a placeholder inside a sentence, call
428   * Drupal.theme('placeholder', text).
429   *
430   * @param func
431   *   The name of the theme function to call.
432   * @param ...
433   *   Additional arguments to pass along to the theme function.
434   * @return
435   *   Any data the theme function returns. This could be a plain HTML string,
436   *   but also a complex object.
437   */
438  Drupal.theme = function (func) {
439    var args = Array.prototype.slice.apply(arguments, [1]);
440
441    return (Drupal.theme[func] || Drupal.theme.prototype[func]).apply(this, args);
442  };
443
444  /**
445   * Freeze the current body height (as minimum height). Used to prevent
446   * unnecessary upwards scrolling when doing DOM manipulations.
447   */
448  Drupal.freezeHeight = function () {
449    Drupal.unfreezeHeight();
450    $('<div id="freeze-height"></div>').css({
451      position: 'absolute',
452      top: '0px',
453      left: '0px',
454      width: '1px',
455      height: $('body').css('height')
456    }).appendTo('body');
457  };
458
459  /**
460   * Unfreeze the body height.
461   */
462  Drupal.unfreezeHeight = function () {
463    $('#freeze-height').remove();
464  };
465
466  /**
467   * Encodes a Drupal path for use in a URL.
468   *
469   * For aesthetic reasons slashes are not escaped.
470   */
471  Drupal.encodePath = function (item, uri) {
472    uri = uri || location.href;
473    return encodeURIComponent(item).replace(/%2F/g, '/');
474  };
475
476  /**
477   * Get the text selection in a textarea.
478   */
479  Drupal.getSelection = function (element) {
480    if (typeof element.selectionStart != 'number' && document.selection) {
481      // The current selection.
482      var range1 = document.selection.createRange();
483      var range2 = range1.duplicate();
484      // Select all text.
485      range2.moveToElementText(element);
486      // Now move 'dummy' end point to end point of original range.
487      range2.setEndPoint('EndToEnd', range1);
488      // Now we can calculate start and end points.
489      var start = range2.text.length - range1.text.length;
490      var end = start + range1.text.length;
491      return { 'start': start, 'end': end };
492    }
493    return { 'start': element.selectionStart, 'end': element.selectionEnd };
494  };
495
496  /**
497   * Add a global variable which determines if the window is being unloaded.
498   *
499   * This is primarily used by Drupal.displayAjaxError().
500   */
501  Drupal.beforeUnloadCalled = false;
502  $(window).bind('beforeunload pagehide', function () {
503    Drupal.beforeUnloadCalled = true;
504  });
505
506  /**
507   * Displays a JavaScript error from an Ajax response when appropriate to do so.
508   */
509  Drupal.displayAjaxError = function (message) {
510    // Skip displaying the message if the user deliberately aborted (for example,
511    // by reloading the page or navigating to a different page) while the Ajax
512    // request was still ongoing. See, for example, the discussion at
513    // http://stackoverflow.com/questions/699941/handle-ajax-error-when-a-user-clicks-refresh.
514    if (!Drupal.beforeUnloadCalled) {
515      alert(message);
516    }
517  };
518
519  /**
520   * Build an error message from an Ajax response.
521   */
522  Drupal.ajaxError = function (xmlhttp, uri, customMessage) {
523    var statusCode, statusText, pathText, responseText, readyStateText, message;
524    if (xmlhttp.status) {
525      statusCode = "\n" + Drupal.t("An AJAX HTTP error occurred.") +  "\n" + Drupal.t("HTTP Result Code: !status", {'!status': xmlhttp.status});
526    }
527    else {
528      statusCode = "\n" + Drupal.t("An AJAX HTTP request terminated abnormally.");
529    }
530    statusCode += "\n" + Drupal.t("Debugging information follows.");
531    pathText = "\n" + Drupal.t("Path: !uri", {'!uri': uri} );
532    statusText = '';
533    // In some cases, when statusCode == 0, xmlhttp.statusText may not be defined.
534    // Unfortunately, testing for it with typeof, etc, doesn't seem to catch that
535    // and the test causes an exception. So we need to catch the exception here.
536    try {
537      statusText = "\n" + Drupal.t("StatusText: !statusText", {'!statusText': $.trim(xmlhttp.statusText)});
538    }
539    catch (e) {}
540
541    responseText = '';
542    // Again, we don't have a way to know for sure whether accessing
543    // xmlhttp.responseText is going to throw an exception. So we'll catch it.
544    try {
545      responseText = "\n" + Drupal.t("ResponseText: !responseText", {'!responseText': $.trim(xmlhttp.responseText) } );
546    } catch (e) {}
547
548    // Make the responseText more readable by stripping HTML tags and newlines.
549    responseText = responseText.replace(/<("[^"]*"|'[^']*'|[^'">])*>/gi,"");
550    responseText = responseText.replace(/[\n]+\s+/g,"\n");
551
552    // We don't need readyState except for status == 0.
553    readyStateText = xmlhttp.status == 0 ? ("\n" + Drupal.t("ReadyState: !readyState", {'!readyState': xmlhttp.readyState})) : "";
554
555    // Additional message beyond what the xmlhttp object provides.
556    customMessage = customMessage ? ("\n" + Drupal.t("CustomMessage: !customMessage", {'!customMessage': customMessage})) : "";
557
558    message = statusCode + pathText + statusText + customMessage + responseText + readyStateText;
559    return message;
560  };
561
562// Class indicating that JS is enabled; used for styling purpose.
563  $('html').addClass('js');
564
565// 'js enabled' cookie.
566  document.cookie = 'has_js=1; path=/';
567
568  /**
569   * Additions to jQuery.support.
570   */
571  $(function () {
572    /**
573     * Boolean indicating whether or not position:fixed is supported.
574     */
575    if (jQuery.support.positionFixed === undefined) {
576      var el = $('<div style="position:fixed; top:10px" />').appendTo(document.body);
577      jQuery.support.positionFixed = el[0].offsetTop === 10;
578      el.remove();
579    }
580  });
581
582//Attach all behaviors.
583  $(function () {
584    Drupal.attachBehaviors(document, Drupal.settings);
585  });
586
587  /**
588   * The default themes.
589   */
590  Drupal.theme.prototype = {
591
592    /**
593     * Formats text for emphasized display in a placeholder inside a sentence.
594     *
595     * @param str
596     *   The text to format (plain-text).
597     * @return
598     *   The formatted text (html).
599     */
600    placeholder: function (str) {
601      return '<em class="placeholder">' + Drupal.checkPlain(str) + '</em>';
602    }
603  };
604
605})(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.