##// END OF EJS Templates
components: completed rhodecode-toggle for notification settings
lisaq -
r727:912a8f06 default
parent child Browse files
Show More
@@ -0,0 +1,14 b''
1 @import '../../../../css/variables';
2
3 .rc-toggle {
4 float: left;
5 position: relative;
6
7 paper-spinner {
8 position: absolute;
9 top: 0;
10 left: -30px;
11 width: 20px;
12 height: 20px;
13 }
14 } No newline at end of file
This diff has been collapsed as it changes many lines, (2505 lines changed) Show them Hide them
@@ -0,0 +1,2505 b''
1 /**
2 * @license
3 * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
4 * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
5 * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
6 * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
7 * Code distributed by Google as part of the polymer project is also
8 * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
9 */
10 // @version 0.7.22
11 (function() {
12 window.WebComponents = window.WebComponents || {
13 flags: {}
14 };
15 var file = "webcomponents-lite.js";
16 var script = document.querySelector('script[src*="' + file + '"]');
17 var flags = {};
18 if (!flags.noOpts) {
19 location.search.slice(1).split("&").forEach(function(option) {
20 var parts = option.split("=");
21 var match;
22 if (parts[0] && (match = parts[0].match(/wc-(.+)/))) {
23 flags[match[1]] = parts[1] || true;
24 }
25 });
26 if (script) {
27 for (var i = 0, a; a = script.attributes[i]; i++) {
28 if (a.name !== "src") {
29 flags[a.name] = a.value || true;
30 }
31 }
32 }
33 if (flags.log && flags.log.split) {
34 var parts = flags.log.split(",");
35 flags.log = {};
36 parts.forEach(function(f) {
37 flags.log[f] = true;
38 });
39 } else {
40 flags.log = {};
41 }
42 }
43 if (flags.register) {
44 window.CustomElements = window.CustomElements || {
45 flags: {}
46 };
47 window.CustomElements.flags.register = flags.register;
48 }
49 WebComponents.flags = flags;
50 })();
51
52 (function(scope) {
53 "use strict";
54 var hasWorkingUrl = false;
55 if (!scope.forceJURL) {
56 try {
57 var u = new URL("b", "http://a");
58 u.pathname = "c%20d";
59 hasWorkingUrl = u.href === "http://a/c%20d";
60 } catch (e) {}
61 }
62 if (hasWorkingUrl) return;
63 var relative = Object.create(null);
64 relative["ftp"] = 21;
65 relative["file"] = 0;
66 relative["gopher"] = 70;
67 relative["http"] = 80;
68 relative["https"] = 443;
69 relative["ws"] = 80;
70 relative["wss"] = 443;
71 var relativePathDotMapping = Object.create(null);
72 relativePathDotMapping["%2e"] = ".";
73 relativePathDotMapping[".%2e"] = "..";
74 relativePathDotMapping["%2e."] = "..";
75 relativePathDotMapping["%2e%2e"] = "..";
76 function isRelativeScheme(scheme) {
77 return relative[scheme] !== undefined;
78 }
79 function invalid() {
80 clear.call(this);
81 this._isInvalid = true;
82 }
83 function IDNAToASCII(h) {
84 if ("" == h) {
85 invalid.call(this);
86 }
87 return h.toLowerCase();
88 }
89 function percentEscape(c) {
90 var unicode = c.charCodeAt(0);
91 if (unicode > 32 && unicode < 127 && [ 34, 35, 60, 62, 63, 96 ].indexOf(unicode) == -1) {
92 return c;
93 }
94 return encodeURIComponent(c);
95 }
96 function percentEscapeQuery(c) {
97 var unicode = c.charCodeAt(0);
98 if (unicode > 32 && unicode < 127 && [ 34, 35, 60, 62, 96 ].indexOf(unicode) == -1) {
99 return c;
100 }
101 return encodeURIComponent(c);
102 }
103 var EOF = undefined, ALPHA = /[a-zA-Z]/, ALPHANUMERIC = /[a-zA-Z0-9\+\-\.]/;
104 function parse(input, stateOverride, base) {
105 function err(message) {
106 errors.push(message);
107 }
108 var state = stateOverride || "scheme start", cursor = 0, buffer = "", seenAt = false, seenBracket = false, errors = [];
109 loop: while ((input[cursor - 1] != EOF || cursor == 0) && !this._isInvalid) {
110 var c = input[cursor];
111 switch (state) {
112 case "scheme start":
113 if (c && ALPHA.test(c)) {
114 buffer += c.toLowerCase();
115 state = "scheme";
116 } else if (!stateOverride) {
117 buffer = "";
118 state = "no scheme";
119 continue;
120 } else {
121 err("Invalid scheme.");
122 break loop;
123 }
124 break;
125
126 case "scheme":
127 if (c && ALPHANUMERIC.test(c)) {
128 buffer += c.toLowerCase();
129 } else if (":" == c) {
130 this._scheme = buffer;
131 buffer = "";
132 if (stateOverride) {
133 break loop;
134 }
135 if (isRelativeScheme(this._scheme)) {
136 this._isRelative = true;
137 }
138 if ("file" == this._scheme) {
139 state = "relative";
140 } else if (this._isRelative && base && base._scheme == this._scheme) {
141 state = "relative or authority";
142 } else if (this._isRelative) {
143 state = "authority first slash";
144 } else {
145 state = "scheme data";
146 }
147 } else if (!stateOverride) {
148 buffer = "";
149 cursor = 0;
150 state = "no scheme";
151 continue;
152 } else if (EOF == c) {
153 break loop;
154 } else {
155 err("Code point not allowed in scheme: " + c);
156 break loop;
157 }
158 break;
159
160 case "scheme data":
161 if ("?" == c) {
162 this._query = "?";
163 state = "query";
164 } else if ("#" == c) {
165 this._fragment = "#";
166 state = "fragment";
167 } else {
168 if (EOF != c && " " != c && "\n" != c && "\r" != c) {
169 this._schemeData += percentEscape(c);
170 }
171 }
172 break;
173
174 case "no scheme":
175 if (!base || !isRelativeScheme(base._scheme)) {
176 err("Missing scheme.");
177 invalid.call(this);
178 } else {
179 state = "relative";
180 continue;
181 }
182 break;
183
184 case "relative or authority":
185 if ("/" == c && "/" == input[cursor + 1]) {
186 state = "authority ignore slashes";
187 } else {
188 err("Expected /, got: " + c);
189 state = "relative";
190 continue;
191 }
192 break;
193
194 case "relative":
195 this._isRelative = true;
196 if ("file" != this._scheme) this._scheme = base._scheme;
197 if (EOF == c) {
198 this._host = base._host;
199 this._port = base._port;
200 this._path = base._path.slice();
201 this._query = base._query;
202 this._username = base._username;
203 this._password = base._password;
204 break loop;
205 } else if ("/" == c || "\\" == c) {
206 if ("\\" == c) err("\\ is an invalid code point.");
207 state = "relative slash";
208 } else if ("?" == c) {
209 this._host = base._host;
210 this._port = base._port;
211 this._path = base._path.slice();
212 this._query = "?";
213 this._username = base._username;
214 this._password = base._password;
215 state = "query";
216 } else if ("#" == c) {
217 this._host = base._host;
218 this._port = base._port;
219 this._path = base._path.slice();
220 this._query = base._query;
221 this._fragment = "#";
222 this._username = base._username;
223 this._password = base._password;
224 state = "fragment";
225 } else {
226 var nextC = input[cursor + 1];
227 var nextNextC = input[cursor + 2];
228 if ("file" != this._scheme || !ALPHA.test(c) || nextC != ":" && nextC != "|" || EOF != nextNextC && "/" != nextNextC && "\\" != nextNextC && "?" != nextNextC && "#" != nextNextC) {
229 this._host = base._host;
230 this._port = base._port;
231 this._username = base._username;
232 this._password = base._password;
233 this._path = base._path.slice();
234 this._path.pop();
235 }
236 state = "relative path";
237 continue;
238 }
239 break;
240
241 case "relative slash":
242 if ("/" == c || "\\" == c) {
243 if ("\\" == c) {
244 err("\\ is an invalid code point.");
245 }
246 if ("file" == this._scheme) {
247 state = "file host";
248 } else {
249 state = "authority ignore slashes";
250 }
251 } else {
252 if ("file" != this._scheme) {
253 this._host = base._host;
254 this._port = base._port;
255 this._username = base._username;
256 this._password = base._password;
257 }
258 state = "relative path";
259 continue;
260 }
261 break;
262
263 case "authority first slash":
264 if ("/" == c) {
265 state = "authority second slash";
266 } else {
267 err("Expected '/', got: " + c);
268 state = "authority ignore slashes";
269 continue;
270 }
271 break;
272
273 case "authority second slash":
274 state = "authority ignore slashes";
275 if ("/" != c) {
276 err("Expected '/', got: " + c);
277 continue;
278 }
279 break;
280
281 case "authority ignore slashes":
282 if ("/" != c && "\\" != c) {
283 state = "authority";
284 continue;
285 } else {
286 err("Expected authority, got: " + c);
287 }
288 break;
289
290 case "authority":
291 if ("@" == c) {
292 if (seenAt) {
293 err("@ already seen.");
294 buffer += "%40";
295 }
296 seenAt = true;
297 for (var i = 0; i < buffer.length; i++) {
298 var cp = buffer[i];
299 if (" " == cp || "\n" == cp || "\r" == cp) {
300 err("Invalid whitespace in authority.");
301 continue;
302 }
303 if (":" == cp && null === this._password) {
304 this._password = "";
305 continue;
306 }
307 var tempC = percentEscape(cp);
308 null !== this._password ? this._password += tempC : this._username += tempC;
309 }
310 buffer = "";
311 } else if (EOF == c || "/" == c || "\\" == c || "?" == c || "#" == c) {
312 cursor -= buffer.length;
313 buffer = "";
314 state = "host";
315 continue;
316 } else {
317 buffer += c;
318 }
319 break;
320
321 case "file host":
322 if (EOF == c || "/" == c || "\\" == c || "?" == c || "#" == c) {
323 if (buffer.length == 2 && ALPHA.test(buffer[0]) && (buffer[1] == ":" || buffer[1] == "|")) {
324 state = "relative path";
325 } else if (buffer.length == 0) {
326 state = "relative path start";
327 } else {
328 this._host = IDNAToASCII.call(this, buffer);
329 buffer = "";
330 state = "relative path start";
331 }
332 continue;
333 } else if (" " == c || "\n" == c || "\r" == c) {
334 err("Invalid whitespace in file host.");
335 } else {
336 buffer += c;
337 }
338 break;
339
340 case "host":
341 case "hostname":
342 if (":" == c && !seenBracket) {
343 this._host = IDNAToASCII.call(this, buffer);
344 buffer = "";
345 state = "port";
346 if ("hostname" == stateOverride) {
347 break loop;
348 }
349 } else if (EOF == c || "/" == c || "\\" == c || "?" == c || "#" == c) {
350 this._host = IDNAToASCII.call(this, buffer);
351 buffer = "";
352 state = "relative path start";
353 if (stateOverride) {
354 break loop;
355 }
356 continue;
357 } else if (" " != c && "\n" != c && "\r" != c) {
358 if ("[" == c) {
359 seenBracket = true;
360 } else if ("]" == c) {
361 seenBracket = false;
362 }
363 buffer += c;
364 } else {
365 err("Invalid code point in host/hostname: " + c);
366 }
367 break;
368
369 case "port":
370 if (/[0-9]/.test(c)) {
371 buffer += c;
372 } else if (EOF == c || "/" == c || "\\" == c || "?" == c || "#" == c || stateOverride) {
373 if ("" != buffer) {
374 var temp = parseInt(buffer, 10);
375 if (temp != relative[this._scheme]) {
376 this._port = temp + "";
377 }
378 buffer = "";
379 }
380 if (stateOverride) {
381 break loop;
382 }
383 state = "relative path start";
384 continue;
385 } else if (" " == c || "\n" == c || "\r" == c) {
386 err("Invalid code point in port: " + c);
387 } else {
388 invalid.call(this);
389 }
390 break;
391
392 case "relative path start":
393 if ("\\" == c) err("'\\' not allowed in path.");
394 state = "relative path";
395 if ("/" != c && "\\" != c) {
396 continue;
397 }
398 break;
399
400 case "relative path":
401 if (EOF == c || "/" == c || "\\" == c || !stateOverride && ("?" == c || "#" == c)) {
402 if ("\\" == c) {
403 err("\\ not allowed in relative path.");
404 }
405 var tmp;
406 if (tmp = relativePathDotMapping[buffer.toLowerCase()]) {
407 buffer = tmp;
408 }
409 if (".." == buffer) {
410 this._path.pop();
411 if ("/" != c && "\\" != c) {
412 this._path.push("");
413 }
414 } else if ("." == buffer && "/" != c && "\\" != c) {
415 this._path.push("");
416 } else if ("." != buffer) {
417 if ("file" == this._scheme && this._path.length == 0 && buffer.length == 2 && ALPHA.test(buffer[0]) && buffer[1] == "|") {
418 buffer = buffer[0] + ":";
419 }
420 this._path.push(buffer);
421 }
422 buffer = "";
423 if ("?" == c) {
424 this._query = "?";
425 state = "query";
426 } else if ("#" == c) {
427 this._fragment = "#";
428 state = "fragment";
429 }
430 } else if (" " != c && "\n" != c && "\r" != c) {
431 buffer += percentEscape(c);
432 }
433 break;
434
435 case "query":
436 if (!stateOverride && "#" == c) {
437 this._fragment = "#";
438 state = "fragment";
439 } else if (EOF != c && " " != c && "\n" != c && "\r" != c) {
440 this._query += percentEscapeQuery(c);
441 }
442 break;
443
444 case "fragment":
445 if (EOF != c && " " != c && "\n" != c && "\r" != c) {
446 this._fragment += c;
447 }
448 break;
449 }
450 cursor++;
451 }
452 }
453 function clear() {
454 this._scheme = "";
455 this._schemeData = "";
456 this._username = "";
457 this._password = null;
458 this._host = "";
459 this._port = "";
460 this._path = [];
461 this._query = "";
462 this._fragment = "";
463 this._isInvalid = false;
464 this._isRelative = false;
465 }
466 function jURL(url, base) {
467 if (base !== undefined && !(base instanceof jURL)) base = new jURL(String(base));
468 this._url = url;
469 clear.call(this);
470 var input = url.replace(/^[ \t\r\n\f]+|[ \t\r\n\f]+$/g, "");
471 parse.call(this, input, null, base);
472 }
473 jURL.prototype = {
474 toString: function() {
475 return this.href;
476 },
477 get href() {
478 if (this._isInvalid) return this._url;
479 var authority = "";
480 if ("" != this._username || null != this._password) {
481 authority = this._username + (null != this._password ? ":" + this._password : "") + "@";
482 }
483 return this.protocol + (this._isRelative ? "//" + authority + this.host : "") + this.pathname + this._query + this._fragment;
484 },
485 set href(href) {
486 clear.call(this);
487 parse.call(this, href);
488 },
489 get protocol() {
490 return this._scheme + ":";
491 },
492 set protocol(protocol) {
493 if (this._isInvalid) return;
494 parse.call(this, protocol + ":", "scheme start");
495 },
496 get host() {
497 return this._isInvalid ? "" : this._port ? this._host + ":" + this._port : this._host;
498 },
499 set host(host) {
500 if (this._isInvalid || !this._isRelative) return;
501 parse.call(this, host, "host");
502 },
503 get hostname() {
504 return this._host;
505 },
506 set hostname(hostname) {
507 if (this._isInvalid || !this._isRelative) return;
508 parse.call(this, hostname, "hostname");
509 },
510 get port() {
511 return this._port;
512 },
513 set port(port) {
514 if (this._isInvalid || !this._isRelative) return;
515 parse.call(this, port, "port");
516 },
517 get pathname() {
518 return this._isInvalid ? "" : this._isRelative ? "/" + this._path.join("/") : this._schemeData;
519 },
520 set pathname(pathname) {
521 if (this._isInvalid || !this._isRelative) return;
522 this._path = [];
523 parse.call(this, pathname, "relative path start");
524 },
525 get search() {
526 return this._isInvalid || !this._query || "?" == this._query ? "" : this._query;
527 },
528 set search(search) {
529 if (this._isInvalid || !this._isRelative) return;
530 this._query = "?";
531 if ("?" == search[0]) search = search.slice(1);
532 parse.call(this, search, "query");
533 },
534 get hash() {
535 return this._isInvalid || !this._fragment || "#" == this._fragment ? "" : this._fragment;
536 },
537 set hash(hash) {
538 if (this._isInvalid) return;
539 this._fragment = "#";
540 if ("#" == hash[0]) hash = hash.slice(1);
541 parse.call(this, hash, "fragment");
542 },
543 get origin() {
544 var host;
545 if (this._isInvalid || !this._scheme) {
546 return "";
547 }
548 switch (this._scheme) {
549 case "data":
550 case "file":
551 case "javascript":
552 case "mailto":
553 return "null";
554 }
555 host = this.host;
556 if (!host) {
557 return "";
558 }
559 return this._scheme + "://" + host;
560 }
561 };
562 var OriginalURL = scope.URL;
563 if (OriginalURL) {
564 jURL.createObjectURL = function(blob) {
565 return OriginalURL.createObjectURL.apply(OriginalURL, arguments);
566 };
567 jURL.revokeObjectURL = function(url) {
568 OriginalURL.revokeObjectURL(url);
569 };
570 }
571 scope.URL = jURL;
572 })(self);
573
574 if (typeof WeakMap === "undefined") {
575 (function() {
576 var defineProperty = Object.defineProperty;
577 var counter = Date.now() % 1e9;
578 var WeakMap = function() {
579 this.name = "__st" + (Math.random() * 1e9 >>> 0) + (counter++ + "__");
580 };
581 WeakMap.prototype = {
582 set: function(key, value) {
583 var entry = key[this.name];
584 if (entry && entry[0] === key) entry[1] = value; else defineProperty(key, this.name, {
585 value: [ key, value ],
586 writable: true
587 });
588 return this;
589 },
590 get: function(key) {
591 var entry;
592 return (entry = key[this.name]) && entry[0] === key ? entry[1] : undefined;
593 },
594 "delete": function(key) {
595 var entry = key[this.name];
596 if (!entry || entry[0] !== key) return false;
597 entry[0] = entry[1] = undefined;
598 return true;
599 },
600 has: function(key) {
601 var entry = key[this.name];
602 if (!entry) return false;
603 return entry[0] === key;
604 }
605 };
606 window.WeakMap = WeakMap;
607 })();
608 }
609
610 (function(global) {
611 if (global.JsMutationObserver) {
612 return;
613 }
614 var registrationsTable = new WeakMap();
615 var setImmediate;
616 if (/Trident|Edge/.test(navigator.userAgent)) {
617 setImmediate = setTimeout;
618 } else if (window.setImmediate) {
619 setImmediate = window.setImmediate;
620 } else {
621 var setImmediateQueue = [];
622 var sentinel = String(Math.random());
623 window.addEventListener("message", function(e) {
624 if (e.data === sentinel) {
625 var queue = setImmediateQueue;
626 setImmediateQueue = [];
627 queue.forEach(function(func) {
628 func();
629 });
630 }
631 });
632 setImmediate = function(func) {
633 setImmediateQueue.push(func);
634 window.postMessage(sentinel, "*");
635 };
636 }
637 var isScheduled = false;
638 var scheduledObservers = [];
639 function scheduleCallback(observer) {
640 scheduledObservers.push(observer);
641 if (!isScheduled) {
642 isScheduled = true;
643 setImmediate(dispatchCallbacks);
644 }
645 }
646 function wrapIfNeeded(node) {
647 return window.ShadowDOMPolyfill && window.ShadowDOMPolyfill.wrapIfNeeded(node) || node;
648 }
649 function dispatchCallbacks() {
650 isScheduled = false;
651 var observers = scheduledObservers;
652 scheduledObservers = [];
653 observers.sort(function(o1, o2) {
654 return o1.uid_ - o2.uid_;
655 });
656 var anyNonEmpty = false;
657 observers.forEach(function(observer) {
658 var queue = observer.takeRecords();
659 removeTransientObserversFor(observer);
660 if (queue.length) {
661 observer.callback_(queue, observer);
662 anyNonEmpty = true;
663 }
664 });
665 if (anyNonEmpty) dispatchCallbacks();
666 }
667 function removeTransientObserversFor(observer) {
668 observer.nodes_.forEach(function(node) {
669 var registrations = registrationsTable.get(node);
670 if (!registrations) return;
671 registrations.forEach(function(registration) {
672 if (registration.observer === observer) registration.removeTransientObservers();
673 });
674 });
675 }
676 function forEachAncestorAndObserverEnqueueRecord(target, callback) {
677 for (var node = target; node; node = node.parentNode) {
678 var registrations = registrationsTable.get(node);
679 if (registrations) {
680 for (var j = 0; j < registrations.length; j++) {
681 var registration = registrations[j];
682 var options = registration.options;
683 if (node !== target && !options.subtree) continue;
684 var record = callback(options);
685 if (record) registration.enqueue(record);
686 }
687 }
688 }
689 }
690 var uidCounter = 0;
691 function JsMutationObserver(callback) {
692 this.callback_ = callback;
693 this.nodes_ = [];
694 this.records_ = [];
695 this.uid_ = ++uidCounter;
696 }
697 JsMutationObserver.prototype = {
698 observe: function(target, options) {
699 target = wrapIfNeeded(target);
700 if (!options.childList && !options.attributes && !options.characterData || options.attributeOldValue && !options.attributes || options.attributeFilter && options.attributeFilter.length && !options.attributes || options.characterDataOldValue && !options.characterData) {
701 throw new SyntaxError();
702 }
703 var registrations = registrationsTable.get(target);
704 if (!registrations) registrationsTable.set(target, registrations = []);
705 var registration;
706 for (var i = 0; i < registrations.length; i++) {
707 if (registrations[i].observer === this) {
708 registration = registrations[i];
709 registration.removeListeners();
710 registration.options = options;
711 break;
712 }
713 }
714 if (!registration) {
715 registration = new Registration(this, target, options);
716 registrations.push(registration);
717 this.nodes_.push(target);
718 }
719 registration.addListeners();
720 },
721 disconnect: function() {
722 this.nodes_.forEach(function(node) {
723 var registrations = registrationsTable.get(node);
724 for (var i = 0; i < registrations.length; i++) {
725 var registration = registrations[i];
726 if (registration.observer === this) {
727 registration.removeListeners();
728 registrations.splice(i, 1);
729 break;
730 }
731 }
732 }, this);
733 this.records_ = [];
734 },
735 takeRecords: function() {
736 var copyOfRecords = this.records_;
737 this.records_ = [];
738 return copyOfRecords;
739 }
740 };
741 function MutationRecord(type, target) {
742 this.type = type;
743 this.target = target;
744 this.addedNodes = [];
745 this.removedNodes = [];
746 this.previousSibling = null;
747 this.nextSibling = null;
748 this.attributeName = null;
749 this.attributeNamespace = null;
750 this.oldValue = null;
751 }
752 function copyMutationRecord(original) {
753 var record = new MutationRecord(original.type, original.target);
754 record.addedNodes = original.addedNodes.slice();
755 record.removedNodes = original.removedNodes.slice();
756 record.previousSibling = original.previousSibling;
757 record.nextSibling = original.nextSibling;
758 record.attributeName = original.attributeName;
759 record.attributeNamespace = original.attributeNamespace;
760 record.oldValue = original.oldValue;
761 return record;
762 }
763 var currentRecord, recordWithOldValue;
764 function getRecord(type, target) {
765 return currentRecord = new MutationRecord(type, target);
766 }
767 function getRecordWithOldValue(oldValue) {
768 if (recordWithOldValue) return recordWithOldValue;
769 recordWithOldValue = copyMutationRecord(currentRecord);
770 recordWithOldValue.oldValue = oldValue;
771 return recordWithOldValue;
772 }
773 function clearRecords() {
774 currentRecord = recordWithOldValue = undefined;
775 }
776 function recordRepresentsCurrentMutation(record) {
777 return record === recordWithOldValue || record === currentRecord;
778 }
779 function selectRecord(lastRecord, newRecord) {
780 if (lastRecord === newRecord) return lastRecord;
781 if (recordWithOldValue && recordRepresentsCurrentMutation(lastRecord)) return recordWithOldValue;
782 return null;
783 }
784 function Registration(observer, target, options) {
785 this.observer = observer;
786 this.target = target;
787 this.options = options;
788 this.transientObservedNodes = [];
789 }
790 Registration.prototype = {
791 enqueue: function(record) {
792 var records = this.observer.records_;
793 var length = records.length;
794 if (records.length > 0) {
795 var lastRecord = records[length - 1];
796 var recordToReplaceLast = selectRecord(lastRecord, record);
797 if (recordToReplaceLast) {
798 records[length - 1] = recordToReplaceLast;
799 return;
800 }
801 } else {
802 scheduleCallback(this.observer);
803 }
804 records[length] = record;
805 },
806 addListeners: function() {
807 this.addListeners_(this.target);
808 },
809 addListeners_: function(node) {
810 var options = this.options;
811 if (options.attributes) node.addEventListener("DOMAttrModified", this, true);
812 if (options.characterData) node.addEventListener("DOMCharacterDataModified", this, true);
813 if (options.childList) node.addEventListener("DOMNodeInserted", this, true);
814 if (options.childList || options.subtree) node.addEventListener("DOMNodeRemoved", this, true);
815 },
816 removeListeners: function() {
817 this.removeListeners_(this.target);
818 },
819 removeListeners_: function(node) {
820 var options = this.options;
821 if (options.attributes) node.removeEventListener("DOMAttrModified", this, true);
822 if (options.characterData) node.removeEventListener("DOMCharacterDataModified", this, true);
823 if (options.childList) node.removeEventListener("DOMNodeInserted", this, true);
824 if (options.childList || options.subtree) node.removeEventListener("DOMNodeRemoved", this, true);
825 },
826 addTransientObserver: function(node) {
827 if (node === this.target) return;
828 this.addListeners_(node);
829 this.transientObservedNodes.push(node);
830 var registrations = registrationsTable.get(node);
831 if (!registrations) registrationsTable.set(node, registrations = []);
832 registrations.push(this);
833 },
834 removeTransientObservers: function() {
835 var transientObservedNodes = this.transientObservedNodes;
836 this.transientObservedNodes = [];
837 transientObservedNodes.forEach(function(node) {
838 this.removeListeners_(node);
839 var registrations = registrationsTable.get(node);
840 for (var i = 0; i < registrations.length; i++) {
841 if (registrations[i] === this) {
842 registrations.splice(i, 1);
843 break;
844 }
845 }
846 }, this);
847 },
848 handleEvent: function(e) {
849 e.stopImmediatePropagation();
850 switch (e.type) {
851 case "DOMAttrModified":
852 var name = e.attrName;
853 var namespace = e.relatedNode.namespaceURI;
854 var target = e.target;
855 var record = new getRecord("attributes", target);
856 record.attributeName = name;
857 record.attributeNamespace = namespace;
858 var oldValue = e.attrChange === MutationEvent.ADDITION ? null : e.prevValue;
859 forEachAncestorAndObserverEnqueueRecord(target, function(options) {
860 if (!options.attributes) return;
861 if (options.attributeFilter && options.attributeFilter.length && options.attributeFilter.indexOf(name) === -1 && options.attributeFilter.indexOf(namespace) === -1) {
862 return;
863 }
864 if (options.attributeOldValue) return getRecordWithOldValue(oldValue);
865 return record;
866 });
867 break;
868
869 case "DOMCharacterDataModified":
870 var target = e.target;
871 var record = getRecord("characterData", target);
872 var oldValue = e.prevValue;
873 forEachAncestorAndObserverEnqueueRecord(target, function(options) {
874 if (!options.characterData) return;
875 if (options.characterDataOldValue) return getRecordWithOldValue(oldValue);
876 return record;
877 });
878 break;
879
880 case "DOMNodeRemoved":
881 this.addTransientObserver(e.target);
882
883 case "DOMNodeInserted":
884 var changedNode = e.target;
885 var addedNodes, removedNodes;
886 if (e.type === "DOMNodeInserted") {
887 addedNodes = [ changedNode ];
888 removedNodes = [];
889 } else {
890 addedNodes = [];
891 removedNodes = [ changedNode ];
892 }
893 var previousSibling = changedNode.previousSibling;
894 var nextSibling = changedNode.nextSibling;
895 var record = getRecord("childList", e.target.parentNode);
896 record.addedNodes = addedNodes;
897 record.removedNodes = removedNodes;
898 record.previousSibling = previousSibling;
899 record.nextSibling = nextSibling;
900 forEachAncestorAndObserverEnqueueRecord(e.relatedNode, function(options) {
901 if (!options.childList) return;
902 return record;
903 });
904 }
905 clearRecords();
906 }
907 };
908 global.JsMutationObserver = JsMutationObserver;
909 if (!global.MutationObserver) {
910 global.MutationObserver = JsMutationObserver;
911 JsMutationObserver._isPolyfilled = true;
912 }
913 })(self);
914
915 (function() {
916 var needsTemplate = typeof HTMLTemplateElement === "undefined";
917 if (/Trident/.test(navigator.userAgent)) {
918 (function() {
919 var importNode = document.importNode;
920 document.importNode = function() {
921 var n = importNode.apply(document, arguments);
922 if (n.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
923 var f = document.createDocumentFragment();
924 f.appendChild(n);
925 return f;
926 } else {
927 return n;
928 }
929 };
930 })();
931 }
932 var needsCloning = function() {
933 if (!needsTemplate) {
934 var t = document.createElement("template");
935 var t2 = document.createElement("template");
936 t2.content.appendChild(document.createElement("div"));
937 t.content.appendChild(t2);
938 var clone = t.cloneNode(true);
939 return clone.content.childNodes.length === 0 || clone.content.firstChild.content.childNodes.length === 0;
940 }
941 }();
942 var TEMPLATE_TAG = "template";
943 var TemplateImpl = function() {};
944 if (needsTemplate) {
945 var contentDoc = document.implementation.createHTMLDocument("template");
946 var canDecorate = true;
947 var templateStyle = document.createElement("style");
948 templateStyle.textContent = TEMPLATE_TAG + "{display:none;}";
949 var head = document.head;
950 head.insertBefore(templateStyle, head.firstElementChild);
951 TemplateImpl.prototype = Object.create(HTMLElement.prototype);
952 TemplateImpl.decorate = function(template) {
953 if (template.content) {
954 return;
955 }
956 template.content = contentDoc.createDocumentFragment();
957 var child;
958 while (child = template.firstChild) {
959 template.content.appendChild(child);
960 }
961 template.cloneNode = function(deep) {
962 return TemplateImpl.cloneNode(this, deep);
963 };
964 if (canDecorate) {
965 try {
966 Object.defineProperty(template, "innerHTML", {
967 get: function() {
968 var o = "";
969 for (var e = this.content.firstChild; e; e = e.nextSibling) {
970 o += e.outerHTML || escapeData(e.data);
971 }
972 return o;
973 },
974 set: function(text) {
975 contentDoc.body.innerHTML = text;
976 TemplateImpl.bootstrap(contentDoc);
977 while (this.content.firstChild) {
978 this.content.removeChild(this.content.firstChild);
979 }
980 while (contentDoc.body.firstChild) {
981 this.content.appendChild(contentDoc.body.firstChild);
982 }
983 },
984 configurable: true
985 });
986 } catch (err) {
987 canDecorate = false;
988 }
989 }
990 TemplateImpl.bootstrap(template.content);
991 };
992 TemplateImpl.bootstrap = function(doc) {
993 var templates = doc.querySelectorAll(TEMPLATE_TAG);
994 for (var i = 0, l = templates.length, t; i < l && (t = templates[i]); i++) {
995 TemplateImpl.decorate(t);
996 }
997 };
998 document.addEventListener("DOMContentLoaded", function() {
999 TemplateImpl.bootstrap(document);
1000 });
1001 var createElement = document.createElement;
1002 document.createElement = function() {
1003 "use strict";
1004 var el = createElement.apply(document, arguments);
1005 if (el.localName === "template") {
1006 TemplateImpl.decorate(el);
1007 }
1008 return el;
1009 };
1010 var escapeDataRegExp = /[&\u00A0<>]/g;
1011 function escapeReplace(c) {
1012 switch (c) {
1013 case "&":
1014 return "&amp;";
1015
1016 case "<":
1017 return "&lt;";
1018
1019 case ">":
1020 return "&gt;";
1021
1022 case " ":
1023 return "&nbsp;";
1024 }
1025 }
1026 function escapeData(s) {
1027 return s.replace(escapeDataRegExp, escapeReplace);
1028 }
1029 }
1030 if (needsTemplate || needsCloning) {
1031 var nativeCloneNode = Node.prototype.cloneNode;
1032 TemplateImpl.cloneNode = function(template, deep) {
1033 var clone = nativeCloneNode.call(template, false);
1034 if (this.decorate) {
1035 this.decorate(clone);
1036 }
1037 if (deep) {
1038 clone.content.appendChild(nativeCloneNode.call(template.content, true));
1039 this.fixClonedDom(clone.content, template.content);
1040 }
1041 return clone;
1042 };
1043 TemplateImpl.fixClonedDom = function(clone, source) {
1044 if (!source.querySelectorAll) return;
1045 var s$ = source.querySelectorAll(TEMPLATE_TAG);
1046 var t$ = clone.querySelectorAll(TEMPLATE_TAG);
1047 for (var i = 0, l = t$.length, t, s; i < l; i++) {
1048 s = s$[i];
1049 t = t$[i];
1050 if (this.decorate) {
1051 this.decorate(s);
1052 }
1053 t.parentNode.replaceChild(s.cloneNode(true), t);
1054 }
1055 };
1056 var originalImportNode = document.importNode;
1057 Node.prototype.cloneNode = function(deep) {
1058 var dom = nativeCloneNode.call(this, deep);
1059 if (deep) {
1060 TemplateImpl.fixClonedDom(dom, this);
1061 }
1062 return dom;
1063 };
1064 document.importNode = function(element, deep) {
1065 if (element.localName === TEMPLATE_TAG) {
1066 return TemplateImpl.cloneNode(element, deep);
1067 } else {
1068 var dom = originalImportNode.call(document, element, deep);
1069 if (deep) {
1070 TemplateImpl.fixClonedDom(dom, element);
1071 }
1072 return dom;
1073 }
1074 };
1075 if (needsCloning) {
1076 HTMLTemplateElement.prototype.cloneNode = function(deep) {
1077 return TemplateImpl.cloneNode(this, deep);
1078 };
1079 }
1080 }
1081 if (needsTemplate) {
1082 window.HTMLTemplateElement = TemplateImpl;
1083 }
1084 })();
1085
1086 (function(scope) {
1087 "use strict";
1088 if (!window.performance) {
1089 var start = Date.now();
1090 window.performance = {
1091 now: function() {
1092 return Date.now() - start;
1093 }
1094 };
1095 }
1096 if (!window.requestAnimationFrame) {
1097 window.requestAnimationFrame = function() {
1098 var nativeRaf = window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame;
1099 return nativeRaf ? function(callback) {
1100 return nativeRaf(function() {
1101 callback(performance.now());
1102 });
1103 } : function(callback) {
1104 return window.setTimeout(callback, 1e3 / 60);
1105 };
1106 }();
1107 }
1108 if (!window.cancelAnimationFrame) {
1109 window.cancelAnimationFrame = function() {
1110 return window.webkitCancelAnimationFrame || window.mozCancelAnimationFrame || function(id) {
1111 clearTimeout(id);
1112 };
1113 }();
1114 }
1115 var workingDefaultPrevented = function() {
1116 var e = document.createEvent("Event");
1117 e.initEvent("foo", true, true);
1118 e.preventDefault();
1119 return e.defaultPrevented;
1120 }();
1121 if (!workingDefaultPrevented) {
1122 var origPreventDefault = Event.prototype.preventDefault;
1123 Event.prototype.preventDefault = function() {
1124 if (!this.cancelable) {
1125 return;
1126 }
1127 origPreventDefault.call(this);
1128 Object.defineProperty(this, "defaultPrevented", {
1129 get: function() {
1130 return true;
1131 },
1132 configurable: true
1133 });
1134 };
1135 }
1136 var isIE = /Trident/.test(navigator.userAgent);
1137 if (!window.CustomEvent || isIE && typeof window.CustomEvent !== "function") {
1138 window.CustomEvent = function(inType, params) {
1139 params = params || {};
1140 var e = document.createEvent("CustomEvent");
1141 e.initCustomEvent(inType, Boolean(params.bubbles), Boolean(params.cancelable), params.detail);
1142 return e;
1143 };
1144 window.CustomEvent.prototype = window.Event.prototype;
1145 }
1146 if (!window.Event || isIE && typeof window.Event !== "function") {
1147 var origEvent = window.Event;
1148 window.Event = function(inType, params) {
1149 params = params || {};
1150 var e = document.createEvent("Event");
1151 e.initEvent(inType, Boolean(params.bubbles), Boolean(params.cancelable));
1152 return e;
1153 };
1154 window.Event.prototype = origEvent.prototype;
1155 }
1156 })(window.WebComponents);
1157
1158 window.HTMLImports = window.HTMLImports || {
1159 flags: {}
1160 };
1161
1162 (function(scope) {
1163 var IMPORT_LINK_TYPE = "import";
1164 var useNative = Boolean(IMPORT_LINK_TYPE in document.createElement("link"));
1165 var hasShadowDOMPolyfill = Boolean(window.ShadowDOMPolyfill);
1166 var wrap = function(node) {
1167 return hasShadowDOMPolyfill ? window.ShadowDOMPolyfill.wrapIfNeeded(node) : node;
1168 };
1169 var rootDocument = wrap(document);
1170 var currentScriptDescriptor = {
1171 get: function() {
1172 var script = window.HTMLImports.currentScript || document.currentScript || (document.readyState !== "complete" ? document.scripts[document.scripts.length - 1] : null);
1173 return wrap(script);
1174 },
1175 configurable: true
1176 };
1177 Object.defineProperty(document, "_currentScript", currentScriptDescriptor);
1178 Object.defineProperty(rootDocument, "_currentScript", currentScriptDescriptor);
1179 var isIE = /Trident/.test(navigator.userAgent);
1180 function whenReady(callback, doc) {
1181 doc = doc || rootDocument;
1182 whenDocumentReady(function() {
1183 watchImportsLoad(callback, doc);
1184 }, doc);
1185 }
1186 var requiredReadyState = isIE ? "complete" : "interactive";
1187 var READY_EVENT = "readystatechange";
1188 function isDocumentReady(doc) {
1189 return doc.readyState === "complete" || doc.readyState === requiredReadyState;
1190 }
1191 function whenDocumentReady(callback, doc) {
1192 if (!isDocumentReady(doc)) {
1193 var checkReady = function() {
1194 if (doc.readyState === "complete" || doc.readyState === requiredReadyState) {
1195 doc.removeEventListener(READY_EVENT, checkReady);
1196 whenDocumentReady(callback, doc);
1197 }
1198 };
1199 doc.addEventListener(READY_EVENT, checkReady);
1200 } else if (callback) {
1201 callback();
1202 }
1203 }
1204 function markTargetLoaded(event) {
1205 event.target.__loaded = true;
1206 }
1207 function watchImportsLoad(callback, doc) {
1208 var imports = doc.querySelectorAll("link[rel=import]");
1209 var parsedCount = 0, importCount = imports.length, newImports = [], errorImports = [];
1210 function checkDone() {
1211 if (parsedCount == importCount && callback) {
1212 callback({
1213 allImports: imports,
1214 loadedImports: newImports,
1215 errorImports: errorImports
1216 });
1217 }
1218 }
1219 function loadedImport(e) {
1220 markTargetLoaded(e);
1221 newImports.push(this);
1222 parsedCount++;
1223 checkDone();
1224 }
1225 function errorLoadingImport(e) {
1226 errorImports.push(this);
1227 parsedCount++;
1228 checkDone();
1229 }
1230 if (importCount) {
1231 for (var i = 0, imp; i < importCount && (imp = imports[i]); i++) {
1232 if (isImportLoaded(imp)) {
1233 newImports.push(this);
1234 parsedCount++;
1235 checkDone();
1236 } else {
1237 imp.addEventListener("load", loadedImport);
1238 imp.addEventListener("error", errorLoadingImport);
1239 }
1240 }
1241 } else {
1242 checkDone();
1243 }
1244 }
1245 function isImportLoaded(link) {
1246 return useNative ? link.__loaded || link.import && link.import.readyState !== "loading" : link.__importParsed;
1247 }
1248 if (useNative) {
1249 new MutationObserver(function(mxns) {
1250 for (var i = 0, l = mxns.length, m; i < l && (m = mxns[i]); i++) {
1251 if (m.addedNodes) {
1252 handleImports(m.addedNodes);
1253 }
1254 }
1255 }).observe(document.head, {
1256 childList: true
1257 });
1258 function handleImports(nodes) {
1259 for (var i = 0, l = nodes.length, n; i < l && (n = nodes[i]); i++) {
1260 if (isImport(n)) {
1261 handleImport(n);
1262 }
1263 }
1264 }
1265 function isImport(element) {
1266 return element.localName === "link" && element.rel === "import";
1267 }
1268 function handleImport(element) {
1269 var loaded = element.import;
1270 if (loaded) {
1271 markTargetLoaded({
1272 target: element
1273 });
1274 } else {
1275 element.addEventListener("load", markTargetLoaded);
1276 element.addEventListener("error", markTargetLoaded);
1277 }
1278 }
1279 (function() {
1280 if (document.readyState === "loading") {
1281 var imports = document.querySelectorAll("link[rel=import]");
1282 for (var i = 0, l = imports.length, imp; i < l && (imp = imports[i]); i++) {
1283 handleImport(imp);
1284 }
1285 }
1286 })();
1287 }
1288 whenReady(function(detail) {
1289 window.HTMLImports.ready = true;
1290 window.HTMLImports.readyTime = new Date().getTime();
1291 var evt = rootDocument.createEvent("CustomEvent");
1292 evt.initCustomEvent("HTMLImportsLoaded", true, true, detail);
1293 rootDocument.dispatchEvent(evt);
1294 });
1295 scope.IMPORT_LINK_TYPE = IMPORT_LINK_TYPE;
1296 scope.useNative = useNative;
1297 scope.rootDocument = rootDocument;
1298 scope.whenReady = whenReady;
1299 scope.isIE = isIE;
1300 })(window.HTMLImports);
1301
1302 (function(scope) {
1303 var modules = [];
1304 var addModule = function(module) {
1305 modules.push(module);
1306 };
1307 var initializeModules = function() {
1308 modules.forEach(function(module) {
1309 module(scope);
1310 });
1311 };
1312 scope.addModule = addModule;
1313 scope.initializeModules = initializeModules;
1314 })(window.HTMLImports);
1315
1316 window.HTMLImports.addModule(function(scope) {
1317 var CSS_URL_REGEXP = /(url\()([^)]*)(\))/g;
1318 var CSS_IMPORT_REGEXP = /(@import[\s]+(?!url\())([^;]*)(;)/g;
1319 var path = {
1320 resolveUrlsInStyle: function(style, linkUrl) {
1321 var doc = style.ownerDocument;
1322 var resolver = doc.createElement("a");
1323 style.textContent = this.resolveUrlsInCssText(style.textContent, linkUrl, resolver);
1324 return style;
1325 },
1326 resolveUrlsInCssText: function(cssText, linkUrl, urlObj) {
1327 var r = this.replaceUrls(cssText, urlObj, linkUrl, CSS_URL_REGEXP);
1328 r = this.replaceUrls(r, urlObj, linkUrl, CSS_IMPORT_REGEXP);
1329 return r;
1330 },
1331 replaceUrls: function(text, urlObj, linkUrl, regexp) {
1332 return text.replace(regexp, function(m, pre, url, post) {
1333 var urlPath = url.replace(/["']/g, "");
1334 if (linkUrl) {
1335 urlPath = new URL(urlPath, linkUrl).href;
1336 }
1337 urlObj.href = urlPath;
1338 urlPath = urlObj.href;
1339 return pre + "'" + urlPath + "'" + post;
1340 });
1341 }
1342 };
1343 scope.path = path;
1344 });
1345
1346 window.HTMLImports.addModule(function(scope) {
1347 var xhr = {
1348 async: true,
1349 ok: function(request) {
1350 return request.status >= 200 && request.status < 300 || request.status === 304 || request.status === 0;
1351 },
1352 load: function(url, next, nextContext) {
1353 var request = new XMLHttpRequest();
1354 if (scope.flags.debug || scope.flags.bust) {
1355 url += "?" + Math.random();
1356 }
1357 request.open("GET", url, xhr.async);
1358 request.addEventListener("readystatechange", function(e) {
1359 if (request.readyState === 4) {
1360 var redirectedUrl = null;
1361 try {
1362 var locationHeader = request.getResponseHeader("Location");
1363 if (locationHeader) {
1364 redirectedUrl = locationHeader.substr(0, 1) === "/" ? location.origin + locationHeader : locationHeader;
1365 }
1366 } catch (e) {
1367 console.error(e.message);
1368 }
1369 next.call(nextContext, !xhr.ok(request) && request, request.response || request.responseText, redirectedUrl);
1370 }
1371 });
1372 request.send();
1373 return request;
1374 },
1375 loadDocument: function(url, next, nextContext) {
1376 this.load(url, next, nextContext).responseType = "document";
1377 }
1378 };
1379 scope.xhr = xhr;
1380 });
1381
1382 window.HTMLImports.addModule(function(scope) {
1383 var xhr = scope.xhr;
1384 var flags = scope.flags;
1385 var Loader = function(onLoad, onComplete) {
1386 this.cache = {};
1387 this.onload = onLoad;
1388 this.oncomplete = onComplete;
1389 this.inflight = 0;
1390 this.pending = {};
1391 };
1392 Loader.prototype = {
1393 addNodes: function(nodes) {
1394 this.inflight += nodes.length;
1395 for (var i = 0, l = nodes.length, n; i < l && (n = nodes[i]); i++) {
1396 this.require(n);
1397 }
1398 this.checkDone();
1399 },
1400 addNode: function(node) {
1401 this.inflight++;
1402 this.require(node);
1403 this.checkDone();
1404 },
1405 require: function(elt) {
1406 var url = elt.src || elt.href;
1407 elt.__nodeUrl = url;
1408 if (!this.dedupe(url, elt)) {
1409 this.fetch(url, elt);
1410 }
1411 },
1412 dedupe: function(url, elt) {
1413 if (this.pending[url]) {
1414 this.pending[url].push(elt);
1415 return true;
1416 }
1417 var resource;
1418 if (this.cache[url]) {
1419 this.onload(url, elt, this.cache[url]);
1420 this.tail();
1421 return true;
1422 }
1423 this.pending[url] = [ elt ];
1424 return false;
1425 },
1426 fetch: function(url, elt) {
1427 flags.load && console.log("fetch", url, elt);
1428 if (!url) {
1429 setTimeout(function() {
1430 this.receive(url, elt, {
1431 error: "href must be specified"
1432 }, null);
1433 }.bind(this), 0);
1434 } else if (url.match(/^data:/)) {
1435 var pieces = url.split(",");
1436 var header = pieces[0];
1437 var body = pieces[1];
1438 if (header.indexOf(";base64") > -1) {
1439 body = atob(body);
1440 } else {
1441 body = decodeURIComponent(body);
1442 }
1443 setTimeout(function() {
1444 this.receive(url, elt, null, body);
1445 }.bind(this), 0);
1446 } else {
1447 var receiveXhr = function(err, resource, redirectedUrl) {
1448 this.receive(url, elt, err, resource, redirectedUrl);
1449 }.bind(this);
1450 xhr.load(url, receiveXhr);
1451 }
1452 },
1453 receive: function(url, elt, err, resource, redirectedUrl) {
1454 this.cache[url] = resource;
1455 var $p = this.pending[url];
1456 for (var i = 0, l = $p.length, p; i < l && (p = $p[i]); i++) {
1457 this.onload(url, p, resource, err, redirectedUrl);
1458 this.tail();
1459 }
1460 this.pending[url] = null;
1461 },
1462 tail: function() {
1463 --this.inflight;
1464 this.checkDone();
1465 },
1466 checkDone: function() {
1467 if (!this.inflight) {
1468 this.oncomplete();
1469 }
1470 }
1471 };
1472 scope.Loader = Loader;
1473 });
1474
1475 window.HTMLImports.addModule(function(scope) {
1476 var Observer = function(addCallback) {
1477 this.addCallback = addCallback;
1478 this.mo = new MutationObserver(this.handler.bind(this));
1479 };
1480 Observer.prototype = {
1481 handler: function(mutations) {
1482 for (var i = 0, l = mutations.length, m; i < l && (m = mutations[i]); i++) {
1483 if (m.type === "childList" && m.addedNodes.length) {
1484 this.addedNodes(m.addedNodes);
1485 }
1486 }
1487 },
1488 addedNodes: function(nodes) {
1489 if (this.addCallback) {
1490 this.addCallback(nodes);
1491 }
1492 for (var i = 0, l = nodes.length, n, loading; i < l && (n = nodes[i]); i++) {
1493 if (n.children && n.children.length) {
1494 this.addedNodes(n.children);
1495 }
1496 }
1497 },
1498 observe: function(root) {
1499 this.mo.observe(root, {
1500 childList: true,
1501 subtree: true
1502 });
1503 }
1504 };
1505 scope.Observer = Observer;
1506 });
1507
1508 window.HTMLImports.addModule(function(scope) {
1509 var path = scope.path;
1510 var rootDocument = scope.rootDocument;
1511 var flags = scope.flags;
1512 var isIE = scope.isIE;
1513 var IMPORT_LINK_TYPE = scope.IMPORT_LINK_TYPE;
1514 var IMPORT_SELECTOR = "link[rel=" + IMPORT_LINK_TYPE + "]";
1515 var importParser = {
1516 documentSelectors: IMPORT_SELECTOR,
1517 importsSelectors: [ IMPORT_SELECTOR, "link[rel=stylesheet]:not([type])", "style:not([type])", "script:not([type])", 'script[type="application/javascript"]', 'script[type="text/javascript"]' ].join(","),
1518 map: {
1519 link: "parseLink",
1520 script: "parseScript",
1521 style: "parseStyle"
1522 },
1523 dynamicElements: [],
1524 parseNext: function() {
1525 var next = this.nextToParse();
1526 if (next) {
1527 this.parse(next);
1528 }
1529 },
1530 parse: function(elt) {
1531 if (this.isParsed(elt)) {
1532 flags.parse && console.log("[%s] is already parsed", elt.localName);
1533 return;
1534 }
1535 var fn = this[this.map[elt.localName]];
1536 if (fn) {
1537 this.markParsing(elt);
1538 fn.call(this, elt);
1539 }
1540 },
1541 parseDynamic: function(elt, quiet) {
1542 this.dynamicElements.push(elt);
1543 if (!quiet) {
1544 this.parseNext();
1545 }
1546 },
1547 markParsing: function(elt) {
1548 flags.parse && console.log("parsing", elt);
1549 this.parsingElement = elt;
1550 },
1551 markParsingComplete: function(elt) {
1552 elt.__importParsed = true;
1553 this.markDynamicParsingComplete(elt);
1554 if (elt.__importElement) {
1555 elt.__importElement.__importParsed = true;
1556 this.markDynamicParsingComplete(elt.__importElement);
1557 }
1558 this.parsingElement = null;
1559 flags.parse && console.log("completed", elt);
1560 },
1561 markDynamicParsingComplete: function(elt) {
1562 var i = this.dynamicElements.indexOf(elt);
1563 if (i >= 0) {
1564 this.dynamicElements.splice(i, 1);
1565 }
1566 },
1567 parseImport: function(elt) {
1568 elt.import = elt.__doc;
1569 if (window.HTMLImports.__importsParsingHook) {
1570 window.HTMLImports.__importsParsingHook(elt);
1571 }
1572 if (elt.import) {
1573 elt.import.__importParsed = true;
1574 }
1575 this.markParsingComplete(elt);
1576 if (elt.__resource && !elt.__error) {
1577 elt.dispatchEvent(new CustomEvent("load", {
1578 bubbles: false
1579 }));
1580 } else {
1581 elt.dispatchEvent(new CustomEvent("error", {
1582 bubbles: false
1583 }));
1584 }
1585 if (elt.__pending) {
1586 var fn;
1587 while (elt.__pending.length) {
1588 fn = elt.__pending.shift();
1589 if (fn) {
1590 fn({
1591 target: elt
1592 });
1593 }
1594 }
1595 }
1596 this.parseNext();
1597 },
1598 parseLink: function(linkElt) {
1599 if (nodeIsImport(linkElt)) {
1600 this.parseImport(linkElt);
1601 } else {
1602 linkElt.href = linkElt.href;
1603 this.parseGeneric(linkElt);
1604 }
1605 },
1606 parseStyle: function(elt) {
1607 var src = elt;
1608 elt = cloneStyle(elt);
1609 src.__appliedElement = elt;
1610 elt.__importElement = src;
1611 this.parseGeneric(elt);
1612 },
1613 parseGeneric: function(elt) {
1614 this.trackElement(elt);
1615 this.addElementToDocument(elt);
1616 },
1617 rootImportForElement: function(elt) {
1618 var n = elt;
1619 while (n.ownerDocument.__importLink) {
1620 n = n.ownerDocument.__importLink;
1621 }
1622 return n;
1623 },
1624 addElementToDocument: function(elt) {
1625 var port = this.rootImportForElement(elt.__importElement || elt);
1626 port.parentNode.insertBefore(elt, port);
1627 },
1628 trackElement: function(elt, callback) {
1629 var self = this;
1630 var done = function(e) {
1631 elt.removeEventListener("load", done);
1632 elt.removeEventListener("error", done);
1633 if (callback) {
1634 callback(e);
1635 }
1636 self.markParsingComplete(elt);
1637 self.parseNext();
1638 };
1639 elt.addEventListener("load", done);
1640 elt.addEventListener("error", done);
1641 if (isIE && elt.localName === "style") {
1642 var fakeLoad = false;
1643 if (elt.textContent.indexOf("@import") == -1) {
1644 fakeLoad = true;
1645 } else if (elt.sheet) {
1646 fakeLoad = true;
1647 var csr = elt.sheet.cssRules;
1648 var len = csr ? csr.length : 0;
1649 for (var i = 0, r; i < len && (r = csr[i]); i++) {
1650 if (r.type === CSSRule.IMPORT_RULE) {
1651 fakeLoad = fakeLoad && Boolean(r.styleSheet);
1652 }
1653 }
1654 }
1655 if (fakeLoad) {
1656 setTimeout(function() {
1657 elt.dispatchEvent(new CustomEvent("load", {
1658 bubbles: false
1659 }));
1660 });
1661 }
1662 }
1663 },
1664 parseScript: function(scriptElt) {
1665 var script = document.createElement("script");
1666 script.__importElement = scriptElt;
1667 script.src = scriptElt.src ? scriptElt.src : generateScriptDataUrl(scriptElt);
1668 scope.currentScript = scriptElt;
1669 this.trackElement(script, function(e) {
1670 if (script.parentNode) {
1671 script.parentNode.removeChild(script);
1672 }
1673 scope.currentScript = null;
1674 });
1675 this.addElementToDocument(script);
1676 },
1677 nextToParse: function() {
1678 this._mayParse = [];
1679 return !this.parsingElement && (this.nextToParseInDoc(rootDocument) || this.nextToParseDynamic());
1680 },
1681 nextToParseInDoc: function(doc, link) {
1682 if (doc && this._mayParse.indexOf(doc) < 0) {
1683 this._mayParse.push(doc);
1684 var nodes = doc.querySelectorAll(this.parseSelectorsForNode(doc));
1685 for (var i = 0, l = nodes.length, n; i < l && (n = nodes[i]); i++) {
1686 if (!this.isParsed(n)) {
1687 if (this.hasResource(n)) {
1688 return nodeIsImport(n) ? this.nextToParseInDoc(n.__doc, n) : n;
1689 } else {
1690 return;
1691 }
1692 }
1693 }
1694 }
1695 return link;
1696 },
1697 nextToParseDynamic: function() {
1698 return this.dynamicElements[0];
1699 },
1700 parseSelectorsForNode: function(node) {
1701 var doc = node.ownerDocument || node;
1702 return doc === rootDocument ? this.documentSelectors : this.importsSelectors;
1703 },
1704 isParsed: function(node) {
1705 return node.__importParsed;
1706 },
1707 needsDynamicParsing: function(elt) {
1708 return this.dynamicElements.indexOf(elt) >= 0;
1709 },
1710 hasResource: function(node) {
1711 if (nodeIsImport(node) && node.__doc === undefined) {
1712 return false;
1713 }
1714 return true;
1715 }
1716 };
1717 function nodeIsImport(elt) {
1718 return elt.localName === "link" && elt.rel === IMPORT_LINK_TYPE;
1719 }
1720 function generateScriptDataUrl(script) {
1721 var scriptContent = generateScriptContent(script);
1722 return "data:text/javascript;charset=utf-8," + encodeURIComponent(scriptContent);
1723 }
1724 function generateScriptContent(script) {
1725 return script.textContent + generateSourceMapHint(script);
1726 }
1727 function generateSourceMapHint(script) {
1728 var owner = script.ownerDocument;
1729 owner.__importedScripts = owner.__importedScripts || 0;
1730 var moniker = script.ownerDocument.baseURI;
1731 var num = owner.__importedScripts ? "-" + owner.__importedScripts : "";
1732 owner.__importedScripts++;
1733 return "\n//# sourceURL=" + moniker + num + ".js\n";
1734 }
1735 function cloneStyle(style) {
1736 var clone = style.ownerDocument.createElement("style");
1737 clone.textContent = style.textContent;
1738 path.resolveUrlsInStyle(clone);
1739 return clone;
1740 }
1741 scope.parser = importParser;
1742 scope.IMPORT_SELECTOR = IMPORT_SELECTOR;
1743 });
1744
1745 window.HTMLImports.addModule(function(scope) {
1746 var flags = scope.flags;
1747 var IMPORT_LINK_TYPE = scope.IMPORT_LINK_TYPE;
1748 var IMPORT_SELECTOR = scope.IMPORT_SELECTOR;
1749 var rootDocument = scope.rootDocument;
1750 var Loader = scope.Loader;
1751 var Observer = scope.Observer;
1752 var parser = scope.parser;
1753 var importer = {
1754 documents: {},
1755 documentPreloadSelectors: IMPORT_SELECTOR,
1756 importsPreloadSelectors: [ IMPORT_SELECTOR ].join(","),
1757 loadNode: function(node) {
1758 importLoader.addNode(node);
1759 },
1760 loadSubtree: function(parent) {
1761 var nodes = this.marshalNodes(parent);
1762 importLoader.addNodes(nodes);
1763 },
1764 marshalNodes: function(parent) {
1765 return parent.querySelectorAll(this.loadSelectorsForNode(parent));
1766 },
1767 loadSelectorsForNode: function(node) {
1768 var doc = node.ownerDocument || node;
1769 return doc === rootDocument ? this.documentPreloadSelectors : this.importsPreloadSelectors;
1770 },
1771 loaded: function(url, elt, resource, err, redirectedUrl) {
1772 flags.load && console.log("loaded", url, elt);
1773 elt.__resource = resource;
1774 elt.__error = err;
1775 if (isImportLink(elt)) {
1776 var doc = this.documents[url];
1777 if (doc === undefined) {
1778 doc = err ? null : makeDocument(resource, redirectedUrl || url);
1779 if (doc) {
1780 doc.__importLink = elt;
1781 this.bootDocument(doc);
1782 }
1783 this.documents[url] = doc;
1784 }
1785 elt.__doc = doc;
1786 }
1787 parser.parseNext();
1788 },
1789 bootDocument: function(doc) {
1790 this.loadSubtree(doc);
1791 this.observer.observe(doc);
1792 parser.parseNext();
1793 },
1794 loadedAll: function() {
1795 parser.parseNext();
1796 }
1797 };
1798 var importLoader = new Loader(importer.loaded.bind(importer), importer.loadedAll.bind(importer));
1799 importer.observer = new Observer();
1800 function isImportLink(elt) {
1801 return isLinkRel(elt, IMPORT_LINK_TYPE);
1802 }
1803 function isLinkRel(elt, rel) {
1804 return elt.localName === "link" && elt.getAttribute("rel") === rel;
1805 }
1806 function hasBaseURIAccessor(doc) {
1807 return !!Object.getOwnPropertyDescriptor(doc, "baseURI");
1808 }
1809 function makeDocument(resource, url) {
1810 var doc = document.implementation.createHTMLDocument(IMPORT_LINK_TYPE);
1811 doc._URL = url;
1812 var base = doc.createElement("base");
1813 base.setAttribute("href", url);
1814 if (!doc.baseURI && !hasBaseURIAccessor(doc)) {
1815 Object.defineProperty(doc, "baseURI", {
1816 value: url
1817 });
1818 }
1819 var meta = doc.createElement("meta");
1820 meta.setAttribute("charset", "utf-8");
1821 doc.head.appendChild(meta);
1822 doc.head.appendChild(base);
1823 doc.body.innerHTML = resource;
1824 if (window.HTMLTemplateElement && HTMLTemplateElement.bootstrap) {
1825 HTMLTemplateElement.bootstrap(doc);
1826 }
1827 return doc;
1828 }
1829 if (!document.baseURI) {
1830 var baseURIDescriptor = {
1831 get: function() {
1832 var base = document.querySelector("base");
1833 return base ? base.href : window.location.href;
1834 },
1835 configurable: true
1836 };
1837 Object.defineProperty(document, "baseURI", baseURIDescriptor);
1838 Object.defineProperty(rootDocument, "baseURI", baseURIDescriptor);
1839 }
1840 scope.importer = importer;
1841 scope.importLoader = importLoader;
1842 });
1843
1844 window.HTMLImports.addModule(function(scope) {
1845 var parser = scope.parser;
1846 var importer = scope.importer;
1847 var dynamic = {
1848 added: function(nodes) {
1849 var owner, parsed, loading;
1850 for (var i = 0, l = nodes.length, n; i < l && (n = nodes[i]); i++) {
1851 if (!owner) {
1852 owner = n.ownerDocument;
1853 parsed = parser.isParsed(owner);
1854 }
1855 loading = this.shouldLoadNode(n);
1856 if (loading) {
1857 importer.loadNode(n);
1858 }
1859 if (this.shouldParseNode(n) && parsed) {
1860 parser.parseDynamic(n, loading);
1861 }
1862 }
1863 },
1864 shouldLoadNode: function(node) {
1865 return node.nodeType === 1 && matches.call(node, importer.loadSelectorsForNode(node));
1866 },
1867 shouldParseNode: function(node) {
1868 return node.nodeType === 1 && matches.call(node, parser.parseSelectorsForNode(node));
1869 }
1870 };
1871 importer.observer.addCallback = dynamic.added.bind(dynamic);
1872 var matches = HTMLElement.prototype.matches || HTMLElement.prototype.matchesSelector || HTMLElement.prototype.webkitMatchesSelector || HTMLElement.prototype.mozMatchesSelector || HTMLElement.prototype.msMatchesSelector;
1873 });
1874
1875 (function(scope) {
1876 var initializeModules = scope.initializeModules;
1877 var isIE = scope.isIE;
1878 if (scope.useNative) {
1879 return;
1880 }
1881 initializeModules();
1882 var rootDocument = scope.rootDocument;
1883 function bootstrap() {
1884 window.HTMLImports.importer.bootDocument(rootDocument);
1885 }
1886 if (document.readyState === "complete" || document.readyState === "interactive" && !window.attachEvent) {
1887 bootstrap();
1888 } else {
1889 document.addEventListener("DOMContentLoaded", bootstrap);
1890 }
1891 })(window.HTMLImports);
1892
1893 window.CustomElements = window.CustomElements || {
1894 flags: {}
1895 };
1896
1897 (function(scope) {
1898 var flags = scope.flags;
1899 var modules = [];
1900 var addModule = function(module) {
1901 modules.push(module);
1902 };
1903 var initializeModules = function() {
1904 modules.forEach(function(module) {
1905 module(scope);
1906 });
1907 };
1908 scope.addModule = addModule;
1909 scope.initializeModules = initializeModules;
1910 scope.hasNative = Boolean(document.registerElement);
1911 scope.isIE = /Trident/.test(navigator.userAgent);
1912 scope.useNative = !flags.register && scope.hasNative && !window.ShadowDOMPolyfill && (!window.HTMLImports || window.HTMLImports.useNative);
1913 })(window.CustomElements);
1914
1915 window.CustomElements.addModule(function(scope) {
1916 var IMPORT_LINK_TYPE = window.HTMLImports ? window.HTMLImports.IMPORT_LINK_TYPE : "none";
1917 function forSubtree(node, cb) {
1918 findAllElements(node, function(e) {
1919 if (cb(e)) {
1920 return true;
1921 }
1922 forRoots(e, cb);
1923 });
1924 forRoots(node, cb);
1925 }
1926 function findAllElements(node, find, data) {
1927 var e = node.firstElementChild;
1928 if (!e) {
1929 e = node.firstChild;
1930 while (e && e.nodeType !== Node.ELEMENT_NODE) {
1931 e = e.nextSibling;
1932 }
1933 }
1934 while (e) {
1935 if (find(e, data) !== true) {
1936 findAllElements(e, find, data);
1937 }
1938 e = e.nextElementSibling;
1939 }
1940 return null;
1941 }
1942 function forRoots(node, cb) {
1943 var root = node.shadowRoot;
1944 while (root) {
1945 forSubtree(root, cb);
1946 root = root.olderShadowRoot;
1947 }
1948 }
1949 function forDocumentTree(doc, cb) {
1950 _forDocumentTree(doc, cb, []);
1951 }
1952 function _forDocumentTree(doc, cb, processingDocuments) {
1953 doc = window.wrap(doc);
1954 if (processingDocuments.indexOf(doc) >= 0) {
1955 return;
1956 }
1957 processingDocuments.push(doc);
1958 var imports = doc.querySelectorAll("link[rel=" + IMPORT_LINK_TYPE + "]");
1959 for (var i = 0, l = imports.length, n; i < l && (n = imports[i]); i++) {
1960 if (n.import) {
1961 _forDocumentTree(n.import, cb, processingDocuments);
1962 }
1963 }
1964 cb(doc);
1965 }
1966 scope.forDocumentTree = forDocumentTree;
1967 scope.forSubtree = forSubtree;
1968 });
1969
1970 window.CustomElements.addModule(function(scope) {
1971 var flags = scope.flags;
1972 var forSubtree = scope.forSubtree;
1973 var forDocumentTree = scope.forDocumentTree;
1974 function addedNode(node, isAttached) {
1975 return added(node, isAttached) || addedSubtree(node, isAttached);
1976 }
1977 function added(node, isAttached) {
1978 if (scope.upgrade(node, isAttached)) {
1979 return true;
1980 }
1981 if (isAttached) {
1982 attached(node);
1983 }
1984 }
1985 function addedSubtree(node, isAttached) {
1986 forSubtree(node, function(e) {
1987 if (added(e, isAttached)) {
1988 return true;
1989 }
1990 });
1991 }
1992 var hasThrottledAttached = window.MutationObserver._isPolyfilled && flags["throttle-attached"];
1993 scope.hasPolyfillMutations = hasThrottledAttached;
1994 scope.hasThrottledAttached = hasThrottledAttached;
1995 var isPendingMutations = false;
1996 var pendingMutations = [];
1997 function deferMutation(fn) {
1998 pendingMutations.push(fn);
1999 if (!isPendingMutations) {
2000 isPendingMutations = true;
2001 setTimeout(takeMutations);
2002 }
2003 }
2004 function takeMutations() {
2005 isPendingMutations = false;
2006 var $p = pendingMutations;
2007 for (var i = 0, l = $p.length, p; i < l && (p = $p[i]); i++) {
2008 p();
2009 }
2010 pendingMutations = [];
2011 }
2012 function attached(element) {
2013 if (hasThrottledAttached) {
2014 deferMutation(function() {
2015 _attached(element);
2016 });
2017 } else {
2018 _attached(element);
2019 }
2020 }
2021 function _attached(element) {
2022 if (element.__upgraded__ && !element.__attached) {
2023 element.__attached = true;
2024 if (element.attachedCallback) {
2025 element.attachedCallback();
2026 }
2027 }
2028 }
2029 function detachedNode(node) {
2030 detached(node);
2031 forSubtree(node, function(e) {
2032 detached(e);
2033 });
2034 }
2035 function detached(element) {
2036 if (hasThrottledAttached) {
2037 deferMutation(function() {
2038 _detached(element);
2039 });
2040 } else {
2041 _detached(element);
2042 }
2043 }
2044 function _detached(element) {
2045 if (element.__upgraded__ && element.__attached) {
2046 element.__attached = false;
2047 if (element.detachedCallback) {
2048 element.detachedCallback();
2049 }
2050 }
2051 }
2052 function inDocument(element) {
2053 var p = element;
2054 var doc = window.wrap(document);
2055 while (p) {
2056 if (p == doc) {
2057 return true;
2058 }
2059 p = p.parentNode || p.nodeType === Node.DOCUMENT_FRAGMENT_NODE && p.host;
2060 }
2061 }
2062 function watchShadow(node) {
2063 if (node.shadowRoot && !node.shadowRoot.__watched) {
2064 flags.dom && console.log("watching shadow-root for: ", node.localName);
2065 var root = node.shadowRoot;
2066 while (root) {
2067 observe(root);
2068 root = root.olderShadowRoot;
2069 }
2070 }
2071 }
2072 function handler(root, mutations) {
2073 if (flags.dom) {
2074 var mx = mutations[0];
2075 if (mx && mx.type === "childList" && mx.addedNodes) {
2076 if (mx.addedNodes) {
2077 var d = mx.addedNodes[0];
2078 while (d && d !== document && !d.host) {
2079 d = d.parentNode;
2080 }
2081 var u = d && (d.URL || d._URL || d.host && d.host.localName) || "";
2082 u = u.split("/?").shift().split("/").pop();
2083 }
2084 }
2085 console.group("mutations (%d) [%s]", mutations.length, u || "");
2086 }
2087 var isAttached = inDocument(root);
2088 mutations.forEach(function(mx) {
2089 if (mx.type === "childList") {
2090 forEach(mx.addedNodes, function(n) {
2091 if (!n.localName) {
2092 return;
2093 }
2094 addedNode(n, isAttached);
2095 });
2096 forEach(mx.removedNodes, function(n) {
2097 if (!n.localName) {
2098 return;
2099 }
2100 detachedNode(n);
2101 });
2102 }
2103 });
2104 flags.dom && console.groupEnd();
2105 }
2106 function takeRecords(node) {
2107 node = window.wrap(node);
2108 if (!node) {
2109 node = window.wrap(document);
2110 }
2111 while (node.parentNode) {
2112 node = node.parentNode;
2113 }
2114 var observer = node.__observer;
2115 if (observer) {
2116 handler(node, observer.takeRecords());
2117 takeMutations();
2118 }
2119 }
2120 var forEach = Array.prototype.forEach.call.bind(Array.prototype.forEach);
2121 function observe(inRoot) {
2122 if (inRoot.__observer) {
2123 return;
2124 }
2125 var observer = new MutationObserver(handler.bind(this, inRoot));
2126 observer.observe(inRoot, {
2127 childList: true,
2128 subtree: true
2129 });
2130 inRoot.__observer = observer;
2131 }
2132 function upgradeDocument(doc) {
2133 doc = window.wrap(doc);
2134 flags.dom && console.group("upgradeDocument: ", doc.baseURI.split("/").pop());
2135 var isMainDocument = doc === window.wrap(document);
2136 addedNode(doc, isMainDocument);
2137 observe(doc);
2138 flags.dom && console.groupEnd();
2139 }
2140 function upgradeDocumentTree(doc) {
2141 forDocumentTree(doc, upgradeDocument);
2142 }
2143 var originalCreateShadowRoot = Element.prototype.createShadowRoot;
2144 if (originalCreateShadowRoot) {
2145 Element.prototype.createShadowRoot = function() {
2146 var root = originalCreateShadowRoot.call(this);
2147 window.CustomElements.watchShadow(this);
2148 return root;
2149 };
2150 }
2151 scope.watchShadow = watchShadow;
2152 scope.upgradeDocumentTree = upgradeDocumentTree;
2153 scope.upgradeDocument = upgradeDocument;
2154 scope.upgradeSubtree = addedSubtree;
2155 scope.upgradeAll = addedNode;
2156 scope.attached = attached;
2157 scope.takeRecords = takeRecords;
2158 });
2159
2160 window.CustomElements.addModule(function(scope) {
2161 var flags = scope.flags;
2162 function upgrade(node, isAttached) {
2163 if (node.localName === "template") {
2164 if (window.HTMLTemplateElement && HTMLTemplateElement.decorate) {
2165 HTMLTemplateElement.decorate(node);
2166 }
2167 }
2168 if (!node.__upgraded__ && node.nodeType === Node.ELEMENT_NODE) {
2169 var is = node.getAttribute("is");
2170 var definition = scope.getRegisteredDefinition(node.localName) || scope.getRegisteredDefinition(is);
2171 if (definition) {
2172 if (is && definition.tag == node.localName || !is && !definition.extends) {
2173 return upgradeWithDefinition(node, definition, isAttached);
2174 }
2175 }
2176 }
2177 }
2178 function upgradeWithDefinition(element, definition, isAttached) {
2179 flags.upgrade && console.group("upgrade:", element.localName);
2180 if (definition.is) {
2181 element.setAttribute("is", definition.is);
2182 }
2183 implementPrototype(element, definition);
2184 element.__upgraded__ = true;
2185 created(element);
2186 if (isAttached) {
2187 scope.attached(element);
2188 }
2189 scope.upgradeSubtree(element, isAttached);
2190 flags.upgrade && console.groupEnd();
2191 return element;
2192 }
2193 function implementPrototype(element, definition) {
2194 if (Object.__proto__) {
2195 element.__proto__ = definition.prototype;
2196 } else {
2197 customMixin(element, definition.prototype, definition.native);
2198 element.__proto__ = definition.prototype;
2199 }
2200 }
2201 function customMixin(inTarget, inSrc, inNative) {
2202 var used = {};
2203 var p = inSrc;
2204 while (p !== inNative && p !== HTMLElement.prototype) {
2205 var keys = Object.getOwnPropertyNames(p);
2206 for (var i = 0, k; k = keys[i]; i++) {
2207 if (!used[k]) {
2208 Object.defineProperty(inTarget, k, Object.getOwnPropertyDescriptor(p, k));
2209 used[k] = 1;
2210 }
2211 }
2212 p = Object.getPrototypeOf(p);
2213 }
2214 }
2215 function created(element) {
2216 if (element.createdCallback) {
2217 element.createdCallback();
2218 }
2219 }
2220 scope.upgrade = upgrade;
2221 scope.upgradeWithDefinition = upgradeWithDefinition;
2222 scope.implementPrototype = implementPrototype;
2223 });
2224
2225 window.CustomElements.addModule(function(scope) {
2226 var isIE = scope.isIE;
2227 var upgradeDocumentTree = scope.upgradeDocumentTree;
2228 var upgradeAll = scope.upgradeAll;
2229 var upgradeWithDefinition = scope.upgradeWithDefinition;
2230 var implementPrototype = scope.implementPrototype;
2231 var useNative = scope.useNative;
2232 function register(name, options) {
2233 var definition = options || {};
2234 if (!name) {
2235 throw new Error("document.registerElement: first argument `name` must not be empty");
2236 }
2237 if (name.indexOf("-") < 0) {
2238 throw new Error("document.registerElement: first argument ('name') must contain a dash ('-'). Argument provided was '" + String(name) + "'.");
2239 }
2240 if (isReservedTag(name)) {
2241 throw new Error("Failed to execute 'registerElement' on 'Document': Registration failed for type '" + String(name) + "'. The type name is invalid.");
2242 }
2243 if (getRegisteredDefinition(name)) {
2244 throw new Error("DuplicateDefinitionError: a type with name '" + String(name) + "' is already registered");
2245 }
2246 if (!definition.prototype) {
2247 definition.prototype = Object.create(HTMLElement.prototype);
2248 }
2249 definition.__name = name.toLowerCase();
2250 if (definition.extends) {
2251 definition.extends = definition.extends.toLowerCase();
2252 }
2253 definition.lifecycle = definition.lifecycle || {};
2254 definition.ancestry = ancestry(definition.extends);
2255 resolveTagName(definition);
2256 resolvePrototypeChain(definition);
2257 overrideAttributeApi(definition.prototype);
2258 registerDefinition(definition.__name, definition);
2259 definition.ctor = generateConstructor(definition);
2260 definition.ctor.prototype = definition.prototype;
2261 definition.prototype.constructor = definition.ctor;
2262 if (scope.ready) {
2263 upgradeDocumentTree(document);
2264 }
2265 return definition.ctor;
2266 }
2267 function overrideAttributeApi(prototype) {
2268 if (prototype.setAttribute._polyfilled) {
2269 return;
2270 }
2271 var setAttribute = prototype.setAttribute;
2272 prototype.setAttribute = function(name, value) {
2273 changeAttribute.call(this, name, value, setAttribute);
2274 };
2275 var removeAttribute = prototype.removeAttribute;
2276 prototype.removeAttribute = function(name) {
2277 changeAttribute.call(this, name, null, removeAttribute);
2278 };
2279 prototype.setAttribute._polyfilled = true;
2280 }
2281 function changeAttribute(name, value, operation) {
2282 name = name.toLowerCase();
2283 var oldValue = this.getAttribute(name);
2284 operation.apply(this, arguments);
2285 var newValue = this.getAttribute(name);
2286 if (this.attributeChangedCallback && newValue !== oldValue) {
2287 this.attributeChangedCallback(name, oldValue, newValue);
2288 }
2289 }
2290 function isReservedTag(name) {
2291 for (var i = 0; i < reservedTagList.length; i++) {
2292 if (name === reservedTagList[i]) {
2293 return true;
2294 }
2295 }
2296 }
2297 var reservedTagList = [ "annotation-xml", "color-profile", "font-face", "font-face-src", "font-face-uri", "font-face-format", "font-face-name", "missing-glyph" ];
2298 function ancestry(extnds) {
2299 var extendee = getRegisteredDefinition(extnds);
2300 if (extendee) {
2301 return ancestry(extendee.extends).concat([ extendee ]);
2302 }
2303 return [];
2304 }
2305 function resolveTagName(definition) {
2306 var baseTag = definition.extends;
2307 for (var i = 0, a; a = definition.ancestry[i]; i++) {
2308 baseTag = a.is && a.tag;
2309 }
2310 definition.tag = baseTag || definition.__name;
2311 if (baseTag) {
2312 definition.is = definition.__name;
2313 }
2314 }
2315 function resolvePrototypeChain(definition) {
2316 if (!Object.__proto__) {
2317 var nativePrototype = HTMLElement.prototype;
2318 if (definition.is) {
2319 var inst = document.createElement(definition.tag);
2320 nativePrototype = Object.getPrototypeOf(inst);
2321 }
2322 var proto = definition.prototype, ancestor;
2323 var foundPrototype = false;
2324 while (proto) {
2325 if (proto == nativePrototype) {
2326 foundPrototype = true;
2327 }
2328 ancestor = Object.getPrototypeOf(proto);
2329 if (ancestor) {
2330 proto.__proto__ = ancestor;
2331 }
2332 proto = ancestor;
2333 }
2334 if (!foundPrototype) {
2335 console.warn(definition.tag + " prototype not found in prototype chain for " + definition.is);
2336 }
2337 definition.native = nativePrototype;
2338 }
2339 }
2340 function instantiate(definition) {
2341 return upgradeWithDefinition(domCreateElement(definition.tag), definition);
2342 }
2343 var registry = {};
2344 function getRegisteredDefinition(name) {
2345 if (name) {
2346 return registry[name.toLowerCase()];
2347 }
2348 }
2349 function registerDefinition(name, definition) {
2350 registry[name] = definition;
2351 }
2352 function generateConstructor(definition) {
2353 return function() {
2354 return instantiate(definition);
2355 };
2356 }
2357 var HTML_NAMESPACE = "http://www.w3.org/1999/xhtml";
2358 function createElementNS(namespace, tag, typeExtension) {
2359 if (namespace === HTML_NAMESPACE) {
2360 return createElement(tag, typeExtension);
2361 } else {
2362 return domCreateElementNS(namespace, tag);
2363 }
2364 }
2365 function createElement(tag, typeExtension) {
2366 if (tag) {
2367 tag = tag.toLowerCase();
2368 }
2369 if (typeExtension) {
2370 typeExtension = typeExtension.toLowerCase();
2371 }
2372 var definition = getRegisteredDefinition(typeExtension || tag);
2373 if (definition) {
2374 if (tag == definition.tag && typeExtension == definition.is) {
2375 return new definition.ctor();
2376 }
2377 if (!typeExtension && !definition.is) {
2378 return new definition.ctor();
2379 }
2380 }
2381 var element;
2382 if (typeExtension) {
2383 element = createElement(tag);
2384 element.setAttribute("is", typeExtension);
2385 return element;
2386 }
2387 element = domCreateElement(tag);
2388 if (tag.indexOf("-") >= 0) {
2389 implementPrototype(element, HTMLElement);
2390 }
2391 return element;
2392 }
2393 var domCreateElement = document.createElement.bind(document);
2394 var domCreateElementNS = document.createElementNS.bind(document);
2395 var isInstance;
2396 if (!Object.__proto__ && !useNative) {
2397 isInstance = function(obj, ctor) {
2398 if (obj instanceof ctor) {
2399 return true;
2400 }
2401 var p = obj;
2402 while (p) {
2403 if (p === ctor.prototype) {
2404 return true;
2405 }
2406 p = p.__proto__;
2407 }
2408 return false;
2409 };
2410 } else {
2411 isInstance = function(obj, base) {
2412 return obj instanceof base;
2413 };
2414 }
2415 function wrapDomMethodToForceUpgrade(obj, methodName) {
2416 var orig = obj[methodName];
2417 obj[methodName] = function() {
2418 var n = orig.apply(this, arguments);
2419 upgradeAll(n);
2420 return n;
2421 };
2422 }
2423 wrapDomMethodToForceUpgrade(Node.prototype, "cloneNode");
2424 wrapDomMethodToForceUpgrade(document, "importNode");
2425 document.registerElement = register;
2426 document.createElement = createElement;
2427 document.createElementNS = createElementNS;
2428 scope.registry = registry;
2429 scope.instanceof = isInstance;
2430 scope.reservedTagList = reservedTagList;
2431 scope.getRegisteredDefinition = getRegisteredDefinition;
2432 document.register = document.registerElement;
2433 });
2434
2435 (function(scope) {
2436 var useNative = scope.useNative;
2437 var initializeModules = scope.initializeModules;
2438 var isIE = scope.isIE;
2439 if (useNative) {
2440 var nop = function() {};
2441 scope.watchShadow = nop;
2442 scope.upgrade = nop;
2443 scope.upgradeAll = nop;
2444 scope.upgradeDocumentTree = nop;
2445 scope.upgradeSubtree = nop;
2446 scope.takeRecords = nop;
2447 scope.instanceof = function(obj, base) {
2448 return obj instanceof base;
2449 };
2450 } else {
2451 initializeModules();
2452 }
2453 var upgradeDocumentTree = scope.upgradeDocumentTree;
2454 var upgradeDocument = scope.upgradeDocument;
2455 if (!window.wrap) {
2456 if (window.ShadowDOMPolyfill) {
2457 window.wrap = window.ShadowDOMPolyfill.wrapIfNeeded;
2458 window.unwrap = window.ShadowDOMPolyfill.unwrapIfNeeded;
2459 } else {
2460 window.wrap = window.unwrap = function(node) {
2461 return node;
2462 };
2463 }
2464 }
2465 if (window.HTMLImports) {
2466 window.HTMLImports.__importsParsingHook = function(elt) {
2467 if (elt.import) {
2468 upgradeDocument(wrap(elt.import));
2469 }
2470 };
2471 }
2472 function bootstrap() {
2473 upgradeDocumentTree(window.wrap(document));
2474 window.CustomElements.ready = true;
2475 var requestAnimationFrame = window.requestAnimationFrame || function(f) {
2476 setTimeout(f, 16);
2477 };
2478 requestAnimationFrame(function() {
2479 setTimeout(function() {
2480 window.CustomElements.readyTime = Date.now();
2481 if (window.HTMLImports) {
2482 window.CustomElements.elapsed = window.CustomElements.readyTime - window.HTMLImports.readyTime;
2483 }
2484 document.dispatchEvent(new CustomEvent("WebComponentsReady", {
2485 bubbles: true
2486 }));
2487 });
2488 });
2489 }
2490 if (document.readyState === "complete" || scope.flags.eager) {
2491 bootstrap();
2492 } else if (document.readyState === "interactive" && !window.attachEvent && (!window.HTMLImports || window.HTMLImports.ready)) {
2493 bootstrap();
2494 } else {
2495 var loadEvent = window.HTMLImports && !window.HTMLImports.ready ? "HTMLImportsLoaded" : "DOMContentLoaded";
2496 window.addEventListener(loadEvent, bootstrap);
2497 }
2498 })(window.CustomElements);
2499
2500 (function(scope) {
2501 var style = document.createElement("style");
2502 style.textContent = "" + "body {" + "transition: opacity ease-in 0.2s;" + " } \n" + "body[unresolved] {" + "opacity: 0; display: block; overflow: hidden; position: relative;" + " } \n";
2503 var head = document.querySelector("head");
2504 head.insertBefore(style, head.firstChild);
2505 })(window.WebComponents); No newline at end of file
@@ -1,14 +1,21 b''
1 1 <link rel="import" href="../../../../../../bower_components/paper-toggle-button/paper-toggle-button.html">
2 <link rel="import" href="../../../../../../bower_components/paper-spinner/paper-spinner.html">
3 <link rel="import" href="../../../../../../bower_components/paper-tooltip/paper-tooltip.html">
2 4
3 5 <dom-module id="rhodecode-toggle">
4 <template>
6
5 7 <style include="shared-styles"></style>
6 <!--<link rel="stylesheet" href="rhodecode-toggle.css">-->
7 FOOBAR
8 <paper-toggle-button>
9 toggle
10 </paper-toggle-button>
8 <link rel="stylesheet" href="rhodecode-toggle.css">
9
10 <template>
11 <div class="rc-toggle">
12 <paper-toggle-button checked={{checked}}>[[labelStatus(checked)]]</paper-toggle-button>
13 <paper-tooltip>[[tooltipText]]</paper-tooltip>
14 <template is="dom-if" if="[[shouldShow(noSpinner)]]">
15 <paper-spinner active=[[active]]></paper-spinner>
16 </template>
17 </div>
11 18 </template>
12 19
13 20 <script src="rhodecode-toggle.js"></script>
14 </dom-module>
21 </dom-module> No newline at end of file
@@ -1,3 +1,16 b''
1 1 Polymer({
2 is: 'rhodecode-toggle'
3 });
2 is: 'rhodecode-toggle',
3 properties: {
4 noSpinner: { type: Boolean, value: false, reflectToAttribute:true},
5 tooltipText: { type: String, value: "Click to toggle", reflectToAttribute:true},
6 checked: { type: Boolean, value: false, reflectToAttribute:true},
7 active: { type: Boolean, value: false, reflectToAttribute:true, notify:true}
8 },
9 shouldShow: function(){
10 return !this.noSpinner
11 },
12 labelStatus: function(isActive){
13 return this.checked? 'Enabled' : "Disabled"
14 }
15
16 }); No newline at end of file
@@ -18,18 +18,13 b''
18 18 <p class="hidden">Status of browser notifications permission: <strong id="browser-notification-status"></strong></p>
19 19
20 20 <div class="form">
21 <!-- fields -->
22 21 <div class="fields">
23 22 <div class="field">
24 23 <div class="label">
25 24 <label for="new_email">${_('Notifications Status')}:</label>
26 25 </div>
27 26 <div class="checkboxes">
28 <paper-toggle-button class="paper-toggle-button" on-change="toggleNotifications" ${'checked' if c.rhodecode_user.get_instance().user_data.get('notification_status') else ''}></paper-toggle-button>
29 <paper-tooltip>Toggle your notifications on/off globally.</paper-tooltip>
30 <template is="dom-if" if="{{changeNotificationsLoading}}">
31 <paper-spinner active class="toggle-ajax-spinner"></paper-spinner>
32 </template>
27 <rhodecode-toggle id="live-notifications" active="[[changeNotificationsLoading]]" on-change="toggleNotifications" ${'checked' if c.rhodecode_user.get_instance().user_data.get('notification_status') else ''}></rhodecode-toggle>
33 28 </div>
34 29 </div>
35 30 <div class="buttons">
@@ -55,7 +50,7 b''
55 50 ajax.generateRequest();
56 51 };
57 52 ctrlr.handleNotifications = function(event){
58 $('paper-toggle-button')[0].active = event.detail.response;
53 $('#live-notifications')[0].active = event.detail.response;
59 54 };
60 55
61 56 function checkBrowserStatus(){
General Comments 0
You need to be logged in to leave comments. Login now