PageSourceSearch

https://arquitectes.cat/sites/default/files/js/js_85BdsZbkD7lQZbc1lMiJicfZIA2X8EwYmaDR-wthP_g.js

js arquitectes.cat collected 2026-09-24 09:32:09 UTC 30,398 bytes, 697 lines download raw bytes

1/*! jQuery Migrate v1.2.1 | (c) 2005, 2013 jQuery Foundation, Inc. and other contributors | jquery.org/license */
2jQuery.migrateMute===void 0&&(jQuery.migrateMute=!0),function(e,t,n){function r(n){var r=t.console;i[n]||(i[n]=!0,e.migrateWarnings.push(n),r&&r.warn&&!e.migrateMute&&(r.warn("JQMIGRATE: "+n),e.migrateTrace&&r.trace&&r.trace()))}function a(t,a,i,o){if(Object.defineProperty)try{return Object.defineProperty(t,a,{configurable:!0,enumerable:!0,get:function(){return r(o),i},set:function(e){r(o),i=e}}),n}catch(s){}e._definePropertyBroken=!0,t[a]=i}var i={};e.migrateWarnings=[],!e.migrateMute&&t.console&&t.console.log&&t.console.log("JQMIGRATE: Logging is active"),e.migrateTrace===n&&(e.migrateTrace=!0),e.migrateReset=function(){i={},e.migrateWarnings.length=0},"BackCompat"===document.compatMode&&r("jQuery is not compatible with Quirks Mode");var o=e("<input/>",{size:1}).attr("size")&&e.attrFn,s=e.attr,u=e.attrHooks.value&&e.attrHooks.value.get||function(){return null},c=e.attrHooks.value&&e.attrHooks.value.set||function(){return n},l=/^(?:input|button)$/i,d=/^[238]$/,p=/^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i,f=/^(?:checked|selected)$/i;a(e,"attrFn",o||{},"jQuery.attrFn is deprecated"),e.attr=function(t,a,i,u){var c=a.toLowerCase(),g=t&&t.nodeType;return u&&(4>s.length&&r("jQuery.fn.attr( props, pass ) is deprecated"),t&&!d.test(g)&&(o?a in o:e.isFunction(e.fn[a])))?e(t)[a](i):("type"===a&&i!==n&&l.test(t.nodeName)&&t.parentNode&&r("Can't change the 'type' of an input or button in IE 6/7/8"),!e.attrHooks[c]&&p.test(c)&&(e.attrHooks[c]={get:function(t,r){var a,i=e.prop(t,r);return i===!0||"boolean"!=typeof i&&(a=t.getAttributeNode(r))&&a.nodeValue!==!1?r.toLowerCase():n},set:function(t,n,r){var a;return n===!1?e.removeAttr(t,r):(a=e.propFix[r]||r,a in t&&(t[a]=!0),t.setAttribute(r,r.toLowerCase())),r}},f.test(c)&&r("jQuery.fn.attr('"+c+"') may use property instead of attribute")),s.call(e,t,a,i))},e.attrHooks.value={get:function(e,t){var n=(e.nodeName||"").toLowerCase();return"button"===n?u.apply(this,arguments):("input"!==n&&"option"!==n&&r("jQuery.fn.attr('value') no longer gets properties"),t in e?e.value:null)},set:function(e,t){var a=(e.nodeName||"").toLowerCase();return"button"===a?c.apply(this,arguments):("input"!==a&&"option"!==a&&r("jQuery.fn.attr('value', val) no longer sets properties"),e.value=t,n)}};var g,h,v=e.fn.init,m=e.parseJSON,y=/^([^<]*)(<[\w\W]+>)([^>]*)$/;e.fn.init=function(t,n,a){var i;return t&&"string"==typeof t&&!e.isPlainObject(n)&&(i=y.exec(e.trim(t)))&&i[0]&&("<"!==t.charAt(0)&&r("$(html) HTML strings must start with '<' character"),i[3]&&r("$(html) HTML text after last tag is ignored"),"#"===i[0].charAt(0)&&(r("HTML string cannot start with a '#' character"),e.error("JQMIGRATE: Invalid selector string (XSS)")),n&&n.context&&(n=n.context),e.parseHTML)?v.call(this,e.parseHTML(i[2],n,!0),n,a):v.apply(this,arguments)},e.fn.init.prototype=e.fn,e.parseJSON=function(e){return e||null===e?m.apply(this,arguments):(r("jQuery.parseJSON requires a valid JSON string"),null)},e.uaMatch=function(e){e=e.toLowerCase();var t=/(chrome)[ \/]([\w.]+)/.exec(e)||/(webkit)[ \/]([\w.]+)/.exec(e)||/(opera)(?:.*version|)[ \/]([\w.]+)/.exec(e)||/(msie) ([\w.]+)/.exec(e)||0>e.indexOf("compatible")&&/(mozilla)(?:.*? rv:([\w.]+)|)/.exec(e)||[];return{browser:t[1]||"",version:t[2]||"0"}},e.browser||(g=e.uaMatch(navigator.userAgent),h={},g.browser&&(h[g.browser]=!0,h.version=g.version),h.chrome?h.webkit=!0:h.webkit&&(h.safari=!0),e.browser=h),a(e,"browser",e.browser,"jQuery.browser is deprecated"),e.sub=function(){function t(e,n){return new t.fn.init(e,n)}e.extend(!0,t,this),t.superclass=this,t.fn=t.prototype=this(),t.fn.constructor=t,t.sub=this.sub,t.fn.init=function(r,a){return a&&a instanceof e&&!(a instanceof t)&&(a=t(a)),e.fn.init.call(this,r,a,n)},t.fn.init.prototype=t.fn;var n=t(document);return r("jQuery.sub() is deprecated"),t},e.ajaxSetup({converters:{"text json":e.parseJSON}});var b=e.fn.data;e.fn.data=function(t){var a,i,o=this[0];return!o||"events"!==t||1!==arguments.length||(a=e.data(o,t),i=e._data(o,t),a!==n&&a!==i||i===n)?b.apply(this,arguments):(r("Use of jQuery.fn.data('events') is deprecated"),i)};var j=/\/(java|ecma)script/i,w=e.fn.andSelf||e.fn.addBack;e.fn.andSelf=function(){return r("jQuery.fn.andSelf() replaced by jQuery.fn.addBack()"),w.apply(this,arguments)},e.clean||(e.clean=function(t,a,i,o){a=a||document,a=!a.nodeType&&a[0]||a,a=a.ownerDocument||a,r("jQuery.clean() is deprecated");var s,u,c,l,d=[];if(e.merge(d,e.buildFragment(t,a).childNodes),i)for(c=function(e){return!e.type||j.test(e.type)?o?o.push(e.parentNode?e.parentNode.removeChild(e):e):i.appendChild(e):n},s=0;null!=(u=d[s]);s++)e.nodeName(u,"script")&&c(u)||(i.appendChild(u),u.getElementsByTagName!==n&&(l=e.grep(e.merge([],u.getElementsByTagName("script")),c),d.splice.apply(d,[s+1,0].c
2oncat(l)),s+=l.length));return d});var Q=e.event.add,x=e.event.remove,k=e.event.trigger,N=e.fn.toggle,T=e.fn.live,M=e.fn.die,S="ajaxStart|ajaxStop|ajaxSend|ajaxComplete|ajaxError|ajaxSuccess",C=RegExp("\\b(?:"+S+")\\b"),H=/(?:^|\s)hover(\.\S+|)\b/,A=function(t){return"string"!=typeof t||e.event.special.hover?t:(H.test(t)&&r("'hover' pseudo-event is deprecated, use 'mouseenter mouseleave'"),t&&t.replace(H,"mouseenter$1 mouseleave$1"))};e.event.props&&"attrChange"!==e.event.props[0]&&e.event.props.unshift("attrChange","attrName","relatedNode","srcElement"),e.event.dispatch&&a(e.event,"handle",e.event.dispatch,"jQuery.event.handle is undocumented and deprecated"),e.event.add=function(e,t,n,a,i){e!==document&&C.test(t)&&r("AJAX events should be attached to document: "+t),Q.call(this,e,A(t||""),n,a,i)},e.event.remove=function(e,t,n,r,a){x.call(this,e,A(t)||"",n,r,a)},e.fn.error=function(){var e=Array.prototype.slice.call(arguments,0);return r("jQuery.fn.error() is deprecated"),e.splice(0,0,"error"),arguments.length?this.bind.apply(this,e):(this.triggerHandler.apply(this,e),this)},e.fn.toggle=function(t,n){if(!e.isFunction(t)||!e.isFunction(n))return N.apply(this,arguments);r("jQuery.fn.toggle(handler, handler...) is deprecated");var a=arguments,i=t.guid||e.guid++,o=0,s=function(n){var r=(e._data(this,"lastToggle"+t.guid)||0)%o;return e._data(this,"lastToggle"+t.guid,r+1),n.preventDefault(),a[r].apply(this,arguments)||!1};for(s.guid=i;a.length>o;)a[o++].guid=i;return this.click(s)},e.fn.live=function(t,n,a){return r("jQuery.fn.live() is deprecated"),T?T.apply(this,arguments):(e(this.context).on(t,this.selector,n,a),this)},e.fn.die=function(t,n){return r("jQuery.fn.die() is deprecated"),M?M.apply(this,arguments):(e(this.context).off(t,this.selector||"**",n),this)},e.event.trigger=function(e,t,n,a){return n||C.test(e)||r("Global events are undocumented and deprecated"),k.call(this,e,t,n||document,a)},e.each(S.split("|"),function(t,n){e.event.special[n]={setup:function(){var t=this;return t!==document&&(e.event.add(document,n+"."+e.guid,function(){e.event.trigger(n,null,t,!0)}),e._data(this,n,e.guid++)),!1},teardown:function(){return this!==document&&e.event.remove(document,n+"."+e._data(this,n)),!1}}})}(jQuery,window);;
3
4/**
5 * jQuery Once Plugin v1.2
6 * http://plugins.jquery.com/project/once
7 *
8 * Dual licensed under the MIT and GPL licenses:
9 *   http://www.opensource.org/licenses/mit-license.php
10 *   http://www.gnu.org/licenses/gpl.html
11 */
12
13(function ($) {
14  var cache = {}, uuid = 0;
15
16  /**
17   * Filters elements by whether they have not yet been processed.
18   *
19   * @param id
20   *   (Optional) If this is a string, then it will be used as the CSS class
21   *   name that is applied to the elements for determining whether it has
22   *   already been processed. The elements will get a class in the form of
23   *   "id-processed".
24   *
25   *   If the id parameter is a function, it will be passed off to the fn
26   *   parameter and the id will become a unique identifier, represented as a
27   *   number.
28   *
29   *   When the id is neither a string or a function, it becomes a unique
30   *   identifier, depicted as a number. The element's class will then be
31   *   represented in the form of "jquery-once-#-processed".
32   *
33   *   Take note that the id must be valid for usage as an element's class name.
34   * @param fn
35   *   (Optional) If given, this function will be called for each element that
36   *   has not yet been processed. The function's return value follows the same
37   *   logic as $.each(). Returning true will continue to the next matched
38   *   element in the set, while returning false will entirely break the
39   *   iteration.
40   */
41  $.fn.once = function (id, fn) {
42    if (typeof id != 'string') {
43      // Generate a numeric ID if the id passed can't be used as a CSS class.
44      if (!(id in cache)) {
45        cache[id] = ++uuid;
46      }
47      // When the fn parameter is not passed, we interpret it from the id.
48      if (!fn) {
49        fn = id;
50      }
51      id = 'jquery-once-' + cache[id];
52    }
53    // Remove elements from the set that have already been processed.
54    var name = id + '-processed';
55    var elements = this.not('.' + name).addClass(name);
56
57    return $.isFunction(fn) ? elements.each(fn) : elements;
58  };
59
60  /**
61   * Filters elements that have been processed once already.
62   *
63   * @param id
64   *   A required string representing the name of the class which should be used
65   *   when filtering the elements. This only filters elements that have already
66   *   been processed by the once function. The id should be the same id that
67   *   was originally passed to the once() function.
68   * @param fn
69   *   (Optional) If given, this function will be called for each element that
70   *   has not yet been processed. The function's return value follows the same
71   *   logic as $.each(). Returning true will continue to the next matched
72   *   element in the set, while returning false will entirely break the
73   *   iteration.
74   */
75  $.fn.removeOnce = function (id, fn) {
76    var name = id + '-processed';
77    var elements = this.filter('.' + name).removeClass(name);
78
79    return $.isFunction(fn) ? elements.each(fn) : elements;
80  };
81})(jQuery);
82;
83
84var Drupal = Drupal || { 'settings': {}, 'behaviors': {}, 'locale': {} };
85
86// Allow other JavaScript libraries to use $.
87jQuery.noConflict();
88
89(function ($) {
90
91/**
92 * Override jQuery.fn.init to guard against XSS attacks.
93 *
94 * See http://bugs.jquery.com/ticket/9521
95 */
96var jquery_init = $.fn.init;
97$.fn.init = function (selector, context, rootjQuery) {
98  // If the string contains a "#" before a "<", treat it as invali
98d HTML.
99  if (selector && typeof selector === 'string') {
100    var hash_position = selector.indexOf('#');
101    if (hash_position >= 0) {
102      var bracket_position = selector.indexOf('<');
103      if (bracket_position > hash_position) {
104        throw 'Syntax error, unrecognized expression: ' + selector;
105      }
106    }
107  }
108  return jquery_init.call(this, selector, context, rootjQuery);
109};
110$.fn.init.prototype = jquery_init.prototype;
111
112/**
113 * Pre-filter Ajax requests to guard against XSS attacks.
114 *
115 * See https://github.com/jquery/jquery/issues/2432
116 */
117if ($.ajaxPrefilter) {
118  // For newer versions of jQuery, use an Ajax prefilter to prevent
119  // auto-executing script tags from untrusted domains. This is similar to the
120  // fix that is built in to jQuery 3.0 and higher.
121  $.ajaxPrefilter(function (s) {
122    if (s.crossDomain) {
123      s.contents.script = false;
124    }
125  });
126}
127else if ($.httpData) {
128  // For the version of jQuery that ships with Drupal core, override
129  // jQuery.httpData to prevent auto-detecting "script" data types from
130  // untrusted domains.
131  var jquery_httpData = $.httpData;
132  $.httpData = function (xhr, type, s) {
133    // @todo Consider backporting code from newer jQuery versions to check for
134    //   a cross-domain request here, rather than using Drupal.urlIsLocal() to
135    //   block scripts from all URLs that are not on the same site.
136    if (!type && !Drupal.urlIsLocal(s.url)) {
137      var content_type = xhr.getResponseHeader('content-type') || '';
138      if (content_type.indexOf('javascript') >= 0) {
139        // Default to a safe data type.
140        type = 'text';
141      }
142    }
143    return jquery_httpData.call(this, xhr, type, s);
144  };
145  $.httpData.prototype = jquery_httpData.prototype;
146}
147
148/**
149 * Attach all registered behaviors to a page element.
150 *
151 * Behaviors are event-triggered actions that attach to page elements, enhancing
152 * default non-JavaScript UIs. Behaviors are registered in the Drupal.behaviors
153 * object using the method 'attach' and optionally also 'detach' as follows:
154 * @code
155 *    Drupal.behaviors.behaviorName = {
156 *      attach: function (context, settings) {
157 *        ...
158 *      },
159 *      detach: function (context, settings, trigger) {
160 *        ...
161 *      }
162 *    };
163 * @endcode
164 *
165 * Drupal.attachBehaviors is added below to the jQuery ready event and so
166 * runs on initial page load. Developers implementing AHAH/Ajax in their
167 * solutions should also call this function after new page content has been
168 * loaded, feeding in an element to be processed, in order to attach all
169 * behaviors to the new content.
170 *
171 * Behaviors should use
172 * @code
173 *   $(selector).once('behavior-name', function () {
174 *     ...
175 *   });
176 * @endcode
177 * to ensure the behavior is attached only once to a given element. (Doing so
178 * enables the reprocessing of given elements, which may be needed on occasion
179 * despite the ability to limit behavior attachment to a particular element.)
180 *
181 * @param context
182 *   An element to attach behaviors to. If none is given, the document element
183 *   is used.
184 * @param settings
185 *   An object containing settings for the current context. If none given, the
186 *   global Drupal.settings object is used.
187 */
188Drupal.attachBehaviors = function (context, settings) {
189  context = context || document;
190  settings = settings || Drupal.settings;
191  // Execute all of them.
192  $.each(Drupal.behaviors, function () {
193    if ($.isFunction(this.attach)) {
194      this.attach(context, settings);
195    }
196  });
197};
198
199/**
200 * Detach registered behaviors from a page element.
201 *
202 * Developers implementing AHAH/Ajax in their solutions should call this
203 * function before page content is about to be removed, feeding in an element
204 * to be processed, in order to allow special behaviors to detach from the
205 * content.
206 *
207 * Such implementations should look for the class name that was added in their
208 * corresponding Drupal.behaviors.behaviorName.attach implementation, i.e.
209 * behaviorName-processed, to ensure the behavior is detached only from
210 * previously processed elements.
211 *
212 * @param context
213 *   An element to detach behaviors from. If none is given, the document element
214 *   is used.
215 * @param settings
216 *   An object containing settings for the current context. If none given, the
217 *   global Drupal.settings object is used.
218 * @param trigger
219 *   A string containing what's causing the behaviors to be detached. The
220 *   possible triggers are:
221 *   - unload: (default) The context element is being removed from the DOM.
222 *   - move: The element is about to be moved within the DOM (for example,
223 *     during a tabledrag row swap). After the move is completed,
224 *     Drupal.attachBehaviors() is called, so that the behavior can undo
225 *     whatever it did in response to the move. Many behaviors won't need to
226 *     do anything simply in response to the element being moved, but because
227 *     IFRAME elements reload their "src" when being moved within the DOM,
228 *     behaviors bound to IFRAME elements (like WYSIWYG editors) may need to
229 *     take some action.
230 *   - serialize: When an Ajax form is submitted, this is called with the
231 *     form as the context. This provides every behavior within the form an
232 *     opportunity to ensure that the field elements have correct content
233 *     in them before the form is serialized. The canonical use-case is so
234 *     that WYSIWYG editors can update the hidden textarea to which they are
235 *     bound.
236 *
237 * @see Drupal.attachBehaviors
238 */
239Drupal.detachBehaviors = function (context, settings, trigger) {
240  context = context || document;
241  settings = settings || Drupal.settings;
242  trigger = trigger || 'unload';
243  // Execute all of them.
244  $.each(Drupal.behaviors, function () {
245    if ($.isFunction(this.detach)) {
246      this.detach(context, settings, trigger);
247    }
248  });
249};
250
251/**
252 * Encode special characters in a plain-text string for display as HTML.
253 *
254 * @ingroup sanitization
255 */
256Drupal.checkPlain = function (str) {
257  var character, regex,
258      replace = { '&': '&amp;', "'": '&#39;', '"': '&quot;', '<': '&lt;', '>': '&gt;' };
259  str = String(str);
260  for (character in replace) {
261    if (replace.hasOwnProperty(character)) {
262      regex = new RegExp(character, 'g');
263      str = str.replace(regex, replace[character]);
264    }
265  }
266  return str;
267};
268
269/**
270 * Replace placeholders with sanitized values in a string.
271 *
272 * @param str
273 *   A string with placeholders.
274 * @param args
275 *   An object of replacements pairs to make. Incidences of any key in this
276 *   array are replaced with the corresponding value. Based on the first
277 *   character of the key, the value is escaped and/or themed:
278 *    - !variable: inserted as is
279 *    - @variable: escape plain text to HTML (Drupal.checkPlain)
280 *    - %variable: escape text and theme as a placeholder for user-submitted
281 *      content (checkPlain + Drupal.theme('placeholder'))
282 *
283 * @see Drupal.t()
284 * @ingroup sanitization
285 */
286Drupal.formatString = function(str, args) {
287  // Transform arguments before inserting them.
288  for (var key in args) {
289    if (args.hasOwnProperty(key)) {
290      switch (key.charAt(0)) {
291        // Escaped only.
292        case '@':
293          args[key] = Drupal.checkPlain(args[key]);
294          break;
295        // Pass-through.
296        case '!':
297          break;
298        // Escaped and placeholder.
299        default:
300          args[key] = Drupal.theme('placeholder', args[key]);
301          break;
302      }
303    }
304  }
305
306  return Drupal.stringReplace(str, args, null);
307};
308
309/**
310 * Replace substring.
311 *
312 * The longest keys will be tried first. Once a substring has been replaced,
313 * its new value will not be searched again.
314 *
315 * @param {String} str
316 *   A string with placeholders.
317 * @param {Object} args
318 *   Key-value pairs.
319 * @param {Array|null} keys
320 *   Array of keys from the "args".  Internal use only.
321 *
322 * @return {String}
323 *   Returns the replaced string.
324 */
325Drupal.stringReplace = function (str, args, keys) {
326  if (str.length === 0) {
327    return str;
328  }
329
330  // If the array of keys is not passed then collect the keys from the args.
331  if (!$.isArray(keys)) {
332    keys = [];
333    for (var k in args) {
334      if (args.hasOwnProperty(k)) {
335        keys.push(k);
336      }
337    }
338
339    // Order the keys by the character length. The shortest one is the first.
340    keys.sort(function (a, b) { return a.length - b.length; });
341  }
342
343  if (keys.length === 0) {
344    return str;
345  }
346
347  // Take next longest one from the end.
348  var key = keys.pop();
349  var fragments = str.split(key);
350
351  if (keys.length) {
352    for (var i = 0; i < fragments.length; i++) {
353      // Process each fragment with a copy of remaining keys.
354      fragments[i] = Drupal.stringReplace(fragments[i], args, keys.slice(0));
355    }
356  }
357
358  return fragments.join(args[key]);
359};
360
361/**
362 * Translate strings to the page language or a given language.
363 *
364 * See the documentation of the server-side t() function for further details.
365 *
366 * @param str
367 *   A string containing the English string to translate.
368 * @param args
369 *   An object of replacements pairs to make after translation. Incidences
370 *   of any key in this array are replaced with the corresponding value.
371 *   See Drupal.formatString().
372 *
373 * @param options
374 *   - 'context' (defaults to the empty context): The context the source string
375 *     belongs to.
376 *
377 * @return
378 *   The translated string.
379 */
380Drupal.t = function (str, args, options) {
381  options = options || {};
382  options.context = options.context || '';
383
384  // Fetch the localized version of the string.
385  if (Drupal.locale.strings && Drupal.locale.strings[options.context] && Drupal.locale.strings[options.context][str]) {
386    str = Drupal.locale.strings[options.context][str];
387  }
388
389  if (args) {
390    str = Drupal.formatString(str, args);
391  }
392  return str;
393};
394
395/**
396 * Format a string containing a count of items.
397 *
398 * This function ensures that the string is pluralized correctly. Since Drupal.t() is
399 * called by this function, make sure not to pass already-localized strings to it.
400 *
401 * See the documentation of the server-side format_plural() function for further details.
402 *
403 * @param count
404 *   The item count to display.
405 * @param singular
406 *   The string for the singular case. Please make sure it is clear this is
407 *   singular, to ease translation (e.g. use "1 new comment" instead of "1 new").
408 *   Do not use @count in the singular string.
409 * @param plural
410 *   The string for the plural case. Please make sure it is clear this is plural,
411 *   to ease translation. Use @count in place of the item count, as in "@count
412 *   new comments".
413 * @param args
414 *   An object of replacements pairs to make after translation. Incidences
415 *   of any key in this array are replaced with the corresponding value.
416 *   See Drupal.formatString().
417 *   Note that you do not need to include @count in this array.
418 *   This replacement is done automatically for the plural case.
419 * @param options
420 *   The options to pass to the Drupal.t() function.
421 * @return
422 *   A translated string.
423 */
424Drupal.formatPlural = function (count, singular, plural, args, options) {
425  args = args || {};
426  args['@count'] = count;
427  // Determine the index of the plural form.
428  var index = Drupal.locale.pluralFormula ? Drupal.locale.pluralFormula(args['@count']) : ((args['@count'] == 1) ? 0 : 1);
429
430  if (index == 0) {
431    return Drupal.t(singular, args, options);
432  }
433  else if (index == 1) {
434    return Drupal.t(plural, args, options);
435  }
436  else {
437    args['@count[' + index + ']'] = args['@count'];
438    delete args['@count'];
439    return Drupal.t(plural.replace('@count', '@count[' + index + ']'), args, options);
440  }
441};
442
443/**
444 * Returns the passed in URL as an absolute URL.
445 *
446 * @param url
447 *   The URL string to be normalized to an absolute URL.
448 *
449 * @return
450 *   The normalized, absolute URL.
451 *
452 * @see https://github.com/angular/angular.js/blob/v1.4.4/src/ng/urlUtils.js
453 * @see https://grack.com/blog/2009/11/17/absolutizing-url-in-javascript
454 * @see https://github.com/jquery/jquery-ui/blob/1.11.4/ui/tabs.js#L53
455 */
456Drupal.absoluteUrl = function (url) {
457  var urlParsingNode = document.createElement('a');
458
459  // Decode the URL first; this is required by IE <= 6. Decoding non-UTF-8
460  // strings may throw an exception.
461  try {
462    url = decodeURIComponent(url);
463  } catch (e) {}
464
465  urlParsingNode.setAttribute('href', url);
466
467  // IE <= 7 normalizes the URL when assigned to the anchor node similar to
468  // the other browsers.
469  return urlParsingNode.cloneNode(false).href;
470};
471
472/**
473 * Returns true if the URL is within Drupal's base path.
474 *
475 * @param url
476 *   The URL string to be tested.
477 *
478 * @return
479 *   Boolean true if local.
480 *
481 * @see https://github.com/jquery/jquery-ui/blob/1.11.4/ui/tabs.js#L58
482 */
483Drupal.urlIsLocal = function (url) {
484  // Always use browser-derived absolute URLs in the comparison, to avoid
485  // attempts to break out of the base path using directory traversal.
486  var absoluteUrl = Drupal.absoluteUrl(url);
487  var protocol = location.protocol;
488
489  // Consider URLs that match this site's base URL but use HTTPS instead of HTTP
490  // as local as well.
491  if (protocol === 'http:' && absoluteUrl.indexOf('https:') === 0) {
492    protocol = 'https:';
493  }
494  var baseUrl = protocol + '//' + location.host + Drupal.settings.basePath.slice(0, -1);
495
496  // Decoding non-UTF-8 strings may throw an exception.
497  try {
498    absoluteUrl = decodeURIComponent(absoluteUrl);
499  } catch (e) {}
500  try {
501    baseUrl = decodeURIComponent(baseUrl);
502  } catch (e) {}
503
504  // The given URL matches the site's base URL, or has a path under the site's
505  // base URL.
506  return absoluteUrl === baseUrl || absoluteUrl.indexOf(baseUrl + '/') === 0;
507};
508
509/**
510 * Generate the themed representation of a Drupal object.
511 *
512 * All requests for themed output must go through this function. It examines
513 * the request and routes it to the appropriate theme function. If the current
514 * theme does not provide an override function, the generic theme function is
515 * called.
516 *
517 * For example, to retrieve the HTML for text that should be emphasized and
518 * displayed as a placeholder inside a sentence, call
519 * Drupal.theme('placeholder', text).
520 *
521 * @param func
522 *   The name of the theme function to call.
523 * @param ...
524 *   Additional arguments to pass along to the theme function.
525 * @return
526 *   Any data the theme function returns. This could be a plain HTML string,
527 *   but also a complex object.
528 */
529Drupal.theme = function (func) {
530  var args = Array.prototype.slice.apply(arguments, [1]);
531
532  return (Drupal.theme[func] || Drupal.theme.prototype[func]).apply(this, args);
533};
534
535/**
536 * Freeze the current body height (as minimum height). Used to prevent
537 * unnecessary upwards scrolling when doing DOM manipulations.
538 */
539Drupal.freezeHeight = function () {
540  Drupal.unfreezeHeight();
541  $('<div id="freeze-height"></div>').css({
542    position: 'absolute',
543    top: '0px',
544    left: '0px',
545    width: '1px',
546    height: $('body').css('height')
547  }).appendTo('body');
548};
549
550/**
551 * Unfreeze the body height.
552 */
553Drupal.unfreezeHeight = function () {
554  $('#freeze-height').remove();
555};
556
557/**
558 * Encodes a Drupal path for use in a URL.
559 *
560 * For aesthetic reasons slashes are not escaped.
561 */
562Drupal.encodePath = function (item, uri) {
563  uri = uri || location.href;
564  return encodeURIComponent(item).replace(/%2F/g, '/');
565};
566
567/**
568 * Get the text selection in a textarea.
569 */
570Drupal.getSelection = function (element) {
571  if (typeof element.selectionStart != 'number' && document.selection) {
572    // The current selection.
573    var range1 = document.selection.createRange();
574    var range2 = range1.duplicate();
575    // Select all text.
576    range2.moveToElementText(element);
577    // Now move 'dummy' end point to end point of original range.
578    range2.setEndPoint('EndToEnd', range1);
579    // Now we can calculate start and end points.
580    var start = range2.text.length - range1.text.length;
581    var end = start + range1.text.length;
582    return { 'start': start, 'end': end };
583  }
584  return { 'start': element.selectionStart, 'end': element.selectionEnd };
585};
586
587/**
588 * Add a global variable which determines if the window is being unloaded.
589 *
590 * This is primarily used by Drupal.displayAjaxError().
591 */
592Drupal.beforeUnloadCalled = false;
593$(window).bind('beforeunload pagehide', function () {
594    Drupal.beforeUnloadCalled = true;
595});
596
597/**
598 * Displays a JavaScript error from an Ajax response when appropriate to do so.
599 */
600Drupal.displayAjaxError = function (message) {
601  // Skip displaying the message if the user deliberately aborted (for example,
602  // by reloading the page or navigating to a different page) while the Ajax
603  // request was still ongoing. See, for example, the discussion at
604  // http://stackoverflow.com/questions/699941/handle-ajax-error-when-a-user-clicks-refresh.
605  if (!Drupal.beforeUnloadCalled) {
606    alert(message);
607  }
608};
609
610/**
611 * Build an error message from an Ajax response.
612 */
613Drupal.ajaxError = function (xmlhttp, uri, customMessage) {
614  var statusCode, statusText, pathText, responseText, readyStateText, message;
615  if (xmlhttp.status) {
616    statusCode = "\n" + Drupal.t("An AJAX HTTP error occurred.") +  "\n" + Drupal.t("HTTP Result Code: !status", {'!status': xmlhttp.status});
617  }
618  else {
619    statusCode = "\n" + Drupal.t("An AJAX HTTP request terminated abnormally.");
620  }
621  statusCode += "\n" + Drupal.t("Debugging information follows.");
622  pathText = "\n" + Drupal.t("Path: !uri", {'!uri': uri} );
623  statusText = '';
624  // In some cases, when statusCode == 0, xmlhttp.statusText may not be defined.
625  // Unfortunately, testing for it with typeof, etc, doesn't seem to catch that
626  // and the test causes an exception. So we need to catch the exception here.
627  try {
628    statusText = "\n" + Drupal.t("StatusText: !statusText", {'!statusText': $.trim(xmlhttp.statusText)});
629  }
630  catch (e) {}
631
632  responseText = '';
633  // Again, we don't have a way to know for sure whether accessing
634  // xmlhttp.responseText is going to throw an exception. So we'll catch it.
635  try {
636    responseText = "\n" + Drupal.t("ResponseText: !responseText", {'!responseText': $.trim(xmlhttp.responseText) } );
637  } catch (e) {}
638
639  // Make the responseText more readable by stripping HTML tags and newlines.
640  responseText = responseText.replace(/<("[^"]*"|'[^']*'|[^'">])*>/gi,"");
641  responseText = responseText.replace(/[\n]+\s+/g,"\n");
642
643  // We don't need readyState except for status == 0.
644  readyStateText = xmlhttp.status == 0 ? ("\n" + Drupal.t("ReadyState: !readyState", {'!readyState': xmlhttp.readyState})) : "";
645
646  // Additional message beyond what the xmlhttp object provides.
647  customMessage = customMessage ? ("\n" + Drupal.t("CustomMessage: !customMessage", {'!customMessage': customMessage})) : "";
648
649  message = statusCode + pathText + statusText + customMessage + responseText + readyStateText;
650  return message;
651};
652
653// Class indicating that JS is enabled; used for styling purpose.
654$('html').addClass('js');
655
656// 'js enabled' cookie.
657document.cookie = 'has_js=1; path=/';
658
659/**
660 * Additions to jQuery.support.
661 */
662$(function () {
663  /**
664   * Boolean indicating whether or not position:fixed is supported.
665   */
666  if (jQuery.support.positionFixed === undefined) {
667    var el = $('<div style="position:fixed; top:10px" />').appendTo(document.body);
668    jQuery.support.positionFixed = el[0].offsetTop === 10;
669    el.remove();
670  }
671});
672
673//Attach all behaviors.
674$(function () {
675  Drupal.attachBehaviors(document, Drupal.settings);
676});
677
678/**
679 * The default themes.
680 */
681Drupal.theme.prototype = {
682
683  /**
684   * Formats text for emphasized display in a placeholder inside a sentence.
685   *
686   * @param str
687   *   The text to format (plain-text).
688   * @return
689   *   The formatted text (html).
690   */
691  placeholder: function (str) {
692    return '<em class="placeholder">' + Drupal.checkPlain(str) + '</em>';
693  }
694};
695
696})(jQuery);
697;

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.