Chris@0
|
1 /**
|
Chris@0
|
2 * DO NOT EDIT THIS FILE.
|
Chris@0
|
3 * See the following change record for more information,
|
Chris@0
|
4 * https://www.drupal.org/node/2815083
|
Chris@0
|
5 * @preserve
|
Chris@0
|
6 **/
|
Chris@0
|
7
|
Chris@0
|
8 window.Drupal = { behaviors: {}, locale: {} };
|
Chris@0
|
9
|
Chris@0
|
10 (function (Drupal, drupalSettings, drupalTranslations) {
|
Chris@0
|
11 Drupal.throwError = function (error) {
|
Chris@0
|
12 setTimeout(function () {
|
Chris@0
|
13 throw error;
|
Chris@0
|
14 }, 0);
|
Chris@0
|
15 };
|
Chris@0
|
16
|
Chris@0
|
17 Drupal.attachBehaviors = function (context, settings) {
|
Chris@0
|
18 context = context || document;
|
Chris@0
|
19 settings = settings || drupalSettings;
|
Chris@0
|
20 var behaviors = Drupal.behaviors;
|
Chris@0
|
21
|
Chris@14
|
22 Object.keys(behaviors || {}).forEach(function (i) {
|
Chris@14
|
23 if (typeof behaviors[i].attach === 'function') {
|
Chris@0
|
24 try {
|
Chris@0
|
25 behaviors[i].attach(context, settings);
|
Chris@0
|
26 } catch (e) {
|
Chris@0
|
27 Drupal.throwError(e);
|
Chris@0
|
28 }
|
Chris@0
|
29 }
|
Chris@14
|
30 });
|
Chris@0
|
31 };
|
Chris@0
|
32
|
Chris@0
|
33 Drupal.detachBehaviors = function (context, settings, trigger) {
|
Chris@0
|
34 context = context || document;
|
Chris@0
|
35 settings = settings || drupalSettings;
|
Chris@0
|
36 trigger = trigger || 'unload';
|
Chris@0
|
37 var behaviors = Drupal.behaviors;
|
Chris@0
|
38
|
Chris@14
|
39 Object.keys(behaviors || {}).forEach(function (i) {
|
Chris@14
|
40 if (typeof behaviors[i].detach === 'function') {
|
Chris@0
|
41 try {
|
Chris@0
|
42 behaviors[i].detach(context, settings, trigger);
|
Chris@0
|
43 } catch (e) {
|
Chris@0
|
44 Drupal.throwError(e);
|
Chris@0
|
45 }
|
Chris@0
|
46 }
|
Chris@14
|
47 });
|
Chris@0
|
48 };
|
Chris@0
|
49
|
Chris@0
|
50 Drupal.checkPlain = function (str) {
|
Chris@12
|
51 str = str.toString().replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, ''');
|
Chris@0
|
52 return str;
|
Chris@0
|
53 };
|
Chris@0
|
54
|
Chris@0
|
55 Drupal.formatString = function (str, args) {
|
Chris@0
|
56 var processedArgs = {};
|
Chris@0
|
57
|
Chris@14
|
58 Object.keys(args || {}).forEach(function (key) {
|
Chris@14
|
59 switch (key.charAt(0)) {
|
Chris@14
|
60 case '@':
|
Chris@14
|
61 processedArgs[key] = Drupal.checkPlain(args[key]);
|
Chris@14
|
62 break;
|
Chris@0
|
63
|
Chris@14
|
64 case '!':
|
Chris@14
|
65 processedArgs[key] = args[key];
|
Chris@14
|
66 break;
|
Chris@0
|
67
|
Chris@14
|
68 default:
|
Chris@14
|
69 processedArgs[key] = Drupal.theme('placeholder', args[key]);
|
Chris@14
|
70 break;
|
Chris@0
|
71 }
|
Chris@14
|
72 });
|
Chris@0
|
73
|
Chris@0
|
74 return Drupal.stringReplace(str, processedArgs, null);
|
Chris@0
|
75 };
|
Chris@0
|
76
|
Chris@0
|
77 Drupal.stringReplace = function (str, args, keys) {
|
Chris@0
|
78 if (str.length === 0) {
|
Chris@0
|
79 return str;
|
Chris@0
|
80 }
|
Chris@0
|
81
|
Chris@0
|
82 if (!Array.isArray(keys)) {
|
Chris@14
|
83 keys = Object.keys(args || {});
|
Chris@0
|
84
|
Chris@0
|
85 keys.sort(function (a, b) {
|
Chris@0
|
86 return a.length - b.length;
|
Chris@0
|
87 });
|
Chris@0
|
88 }
|
Chris@0
|
89
|
Chris@0
|
90 if (keys.length === 0) {
|
Chris@0
|
91 return str;
|
Chris@0
|
92 }
|
Chris@0
|
93
|
Chris@0
|
94 var key = keys.pop();
|
Chris@0
|
95 var fragments = str.split(key);
|
Chris@0
|
96
|
Chris@0
|
97 if (keys.length) {
|
Chris@0
|
98 for (var i = 0; i < fragments.length; i++) {
|
Chris@0
|
99 fragments[i] = Drupal.stringReplace(fragments[i], args, keys.slice(0));
|
Chris@0
|
100 }
|
Chris@0
|
101 }
|
Chris@0
|
102
|
Chris@0
|
103 return fragments.join(args[key]);
|
Chris@0
|
104 };
|
Chris@0
|
105
|
Chris@0
|
106 Drupal.t = function (str, args, options) {
|
Chris@0
|
107 options = options || {};
|
Chris@0
|
108 options.context = options.context || '';
|
Chris@0
|
109
|
Chris@0
|
110 if (typeof drupalTranslations !== 'undefined' && drupalTranslations.strings && drupalTranslations.strings[options.context] && drupalTranslations.strings[options.context][str]) {
|
Chris@0
|
111 str = drupalTranslations.strings[options.context][str];
|
Chris@0
|
112 }
|
Chris@0
|
113
|
Chris@0
|
114 if (args) {
|
Chris@0
|
115 str = Drupal.formatString(str, args);
|
Chris@0
|
116 }
|
Chris@0
|
117 return str;
|
Chris@0
|
118 };
|
Chris@0
|
119
|
Chris@0
|
120 Drupal.url = function (path) {
|
Chris@0
|
121 return drupalSettings.path.baseUrl + drupalSettings.path.pathPrefix + path;
|
Chris@0
|
122 };
|
Chris@0
|
123
|
Chris@0
|
124 Drupal.url.toAbsolute = function (url) {
|
Chris@0
|
125 var urlParsingNode = document.createElement('a');
|
Chris@0
|
126
|
Chris@0
|
127 try {
|
Chris@0
|
128 url = decodeURIComponent(url);
|
Chris@0
|
129 } catch (e) {}
|
Chris@0
|
130
|
Chris@0
|
131 urlParsingNode.setAttribute('href', url);
|
Chris@0
|
132
|
Chris@0
|
133 return urlParsingNode.cloneNode(false).href;
|
Chris@0
|
134 };
|
Chris@0
|
135
|
Chris@0
|
136 Drupal.url.isLocal = function (url) {
|
Chris@0
|
137 var absoluteUrl = Drupal.url.toAbsolute(url);
|
Chris@17
|
138 var protocol = window.location.protocol;
|
Chris@0
|
139
|
Chris@0
|
140 if (protocol === 'http:' && absoluteUrl.indexOf('https:') === 0) {
|
Chris@0
|
141 protocol = 'https:';
|
Chris@0
|
142 }
|
Chris@17
|
143 var baseUrl = protocol + '//' + window.location.host + drupalSettings.path.baseUrl.slice(0, -1);
|
Chris@0
|
144
|
Chris@0
|
145 try {
|
Chris@0
|
146 absoluteUrl = decodeURIComponent(absoluteUrl);
|
Chris@0
|
147 } catch (e) {}
|
Chris@0
|
148 try {
|
Chris@0
|
149 baseUrl = decodeURIComponent(baseUrl);
|
Chris@0
|
150 } catch (e) {}
|
Chris@0
|
151
|
Chris@0
|
152 return absoluteUrl === baseUrl || absoluteUrl.indexOf(baseUrl + '/') === 0;
|
Chris@0
|
153 };
|
Chris@0
|
154
|
Chris@0
|
155 Drupal.formatPlural = function (count, singular, plural, args, options) {
|
Chris@0
|
156 args = args || {};
|
Chris@0
|
157 args['@count'] = count;
|
Chris@0
|
158
|
Chris@0
|
159 var pluralDelimiter = drupalSettings.pluralDelimiter;
|
Chris@0
|
160 var translations = Drupal.t(singular + pluralDelimiter + plural, args, options).split(pluralDelimiter);
|
Chris@0
|
161 var index = 0;
|
Chris@0
|
162
|
Chris@0
|
163 if (typeof drupalTranslations !== 'undefined' && drupalTranslations.pluralFormula) {
|
Chris@0
|
164 index = count in drupalTranslations.pluralFormula ? drupalTranslations.pluralFormula[count] : drupalTranslations.pluralFormula.default;
|
Chris@0
|
165 } else if (args['@count'] !== 1) {
|
Chris@0
|
166 index = 1;
|
Chris@0
|
167 }
|
Chris@0
|
168
|
Chris@0
|
169 return translations[index];
|
Chris@0
|
170 };
|
Chris@0
|
171
|
Chris@0
|
172 Drupal.encodePath = function (item) {
|
Chris@0
|
173 return window.encodeURIComponent(item).replace(/%2F/g, '/');
|
Chris@0
|
174 };
|
Chris@0
|
175
|
Chris@0
|
176 Drupal.theme = function (func) {
|
Chris@0
|
177 if (func in Drupal.theme) {
|
Chris@14
|
178 var _Drupal$theme;
|
Chris@14
|
179
|
Chris@14
|
180 for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
Chris@14
|
181 args[_key - 1] = arguments[_key];
|
Chris@14
|
182 }
|
Chris@14
|
183
|
Chris@14
|
184 return (_Drupal$theme = Drupal.theme)[func].apply(_Drupal$theme, args);
|
Chris@0
|
185 }
|
Chris@0
|
186 };
|
Chris@0
|
187
|
Chris@0
|
188 Drupal.theme.placeholder = function (str) {
|
Chris@0
|
189 return '<em class="placeholder">' + Drupal.checkPlain(str) + '</em>';
|
Chris@0
|
190 };
|
Chris@0
|
191 })(Drupal, window.drupalSettings, window.drupalTranslations); |