1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 | (function webpackUniversalModuleDefinition(root, factory) {
|
9 | if (typeof exports === "object" && typeof module === "object") module.exports = factory(); else if (typeof define === "function" && define.amd) define([], factory); else if (typeof exports === "object") exports["tabs"] = factory(); else root["mdc"] = root["mdc"] || {},
|
10 | root["mdc"]["tabs"] = factory();
|
11 | })(this, function() {
|
12 | return function(modules) {
|
13 | var installedModules = {};
|
14 | function __webpack_require__(moduleId) {
|
15 | if (installedModules[moduleId]) {
|
16 | return installedModules[moduleId].exports;
|
17 | }
|
18 | var module = installedModules[moduleId] = {
|
19 | i: moduleId,
|
20 | l: false,
|
21 | exports: {}
|
22 | };
|
23 | modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
24 | module.l = true;
|
25 | return module.exports;
|
26 | }
|
27 | __webpack_require__.m = modules;
|
28 | __webpack_require__.c = installedModules;
|
29 | __webpack_require__.d = function(exports, name, getter) {
|
30 | if (!__webpack_require__.o(exports, name)) {
|
31 | Object.defineProperty(exports, name, {
|
32 | configurable: false,
|
33 | enumerable: true,
|
34 | get: getter
|
35 | });
|
36 | }
|
37 | };
|
38 | __webpack_require__.n = function(module) {
|
39 | var getter = module && module.__esModule ? function getDefault() {
|
40 | return module["default"];
|
41 | } : function getModuleExports() {
|
42 | return module;
|
43 | };
|
44 | __webpack_require__.d(getter, "a", getter);
|
45 | return getter;
|
46 | };
|
47 | __webpack_require__.o = function(object, property) {
|
48 | return Object.prototype.hasOwnProperty.call(object, property);
|
49 | };
|
50 | __webpack_require__.p = "";
|
51 | return __webpack_require__(__webpack_require__.s = 163);
|
52 | }({
|
53 | 0: function(module, exports, __webpack_require__) {
|
54 | "use strict";
|
55 | Object.defineProperty(exports, "__esModule", {
|
56 | value: true
|
57 | });
|
58 | var MDCFoundation = function() {
|
59 | function MDCFoundation(adapter) {
|
60 | if (adapter === void 0) {
|
61 | adapter = {};
|
62 | }
|
63 | this.adapter_ = adapter;
|
64 | }
|
65 | Object.defineProperty(MDCFoundation, "cssClasses", {
|
66 | get: function get() {
|
67 | return {};
|
68 | },
|
69 | enumerable: true,
|
70 | configurable: true
|
71 | });
|
72 | Object.defineProperty(MDCFoundation, "strings", {
|
73 | get: function get() {
|
74 | return {};
|
75 | },
|
76 | enumerable: true,
|
77 | configurable: true
|
78 | });
|
79 | Object.defineProperty(MDCFoundation, "numbers", {
|
80 | get: function get() {
|
81 | return {};
|
82 | },
|
83 | enumerable: true,
|
84 | configurable: true
|
85 | });
|
86 | Object.defineProperty(MDCFoundation, "defaultAdapter", {
|
87 | get: function get() {
|
88 | return {};
|
89 | },
|
90 | enumerable: true,
|
91 | configurable: true
|
92 | });
|
93 | MDCFoundation.prototype.init = function() {};
|
94 | MDCFoundation.prototype.destroy = function() {};
|
95 | return MDCFoundation;
|
96 | }();
|
97 | exports.MDCFoundation = MDCFoundation;
|
98 | exports.default = MDCFoundation;
|
99 | },
|
100 | 1: function(module, exports, __webpack_require__) {
|
101 | "use strict";
|
102 | var __read = this && this.__read || function(o, n) {
|
103 | var m = typeof Symbol === "function" && o[Symbol.iterator];
|
104 | if (!m) return o;
|
105 | var i = m.call(o), r, ar = [], e;
|
106 | try {
|
107 | while ((n === void 0 || n-- > 0) && !(r = i.next()).done) {
|
108 | ar.push(r.value);
|
109 | }
|
110 | } catch (error) {
|
111 | e = {
|
112 | error: error
|
113 | };
|
114 | } finally {
|
115 | try {
|
116 | if (r && !r.done && (m = i["return"])) m.call(i);
|
117 | } finally {
|
118 | if (e) throw e.error;
|
119 | }
|
120 | }
|
121 | return ar;
|
122 | };
|
123 | var __spread = this && this.__spread || function() {
|
124 | for (var ar = [], i = 0; i < arguments.length; i++) {
|
125 | ar = ar.concat(__read(arguments[i]));
|
126 | }
|
127 | return ar;
|
128 | };
|
129 | Object.defineProperty(exports, "__esModule", {
|
130 | value: true
|
131 | });
|
132 | var foundation_1 = __webpack_require__(0);
|
133 | var MDCComponent = function() {
|
134 | function MDCComponent(root, foundation) {
|
135 | var args = [];
|
136 | for (var _i = 2; _i < arguments.length; _i++) {
|
137 | args[_i - 2] = arguments[_i];
|
138 | }
|
139 | this.root_ = root;
|
140 | this.initialize.apply(this, __spread(args));
|
141 | this.foundation_ = foundation === undefined ? this.getDefaultFoundation() : foundation;
|
142 | this.foundation_.init();
|
143 | this.initialSyncWithDOM();
|
144 | }
|
145 | MDCComponent.attachTo = function(root) {
|
146 | return new MDCComponent(root, new foundation_1.MDCFoundation({}));
|
147 | };
|
148 | MDCComponent.prototype.initialize = function() {
|
149 | var _args = [];
|
150 | for (var _i = 0; _i < arguments.length; _i++) {
|
151 | _args[_i] = arguments[_i];
|
152 | }
|
153 | };
|
154 | MDCComponent.prototype.getDefaultFoundation = function() {
|
155 | throw new Error("Subclasses must override getDefaultFoundation to return a properly configured " + "foundation class");
|
156 | };
|
157 | MDCComponent.prototype.initialSyncWithDOM = function() {};
|
158 | MDCComponent.prototype.destroy = function() {
|
159 | this.foundation_.destroy();
|
160 | };
|
161 | MDCComponent.prototype.listen = function(evtType, handler) {
|
162 | this.root_.addEventListener(evtType, handler);
|
163 | };
|
164 | MDCComponent.prototype.unlisten = function(evtType, handler) {
|
165 | this.root_.removeEventListener(evtType, handler);
|
166 | };
|
167 | MDCComponent.prototype.emit = function(evtType, evtData, shouldBubble) {
|
168 | if (shouldBubble === void 0) {
|
169 | shouldBubble = false;
|
170 | }
|
171 | var evt;
|
172 | if (typeof CustomEvent === "function") {
|
173 | evt = new CustomEvent(evtType, {
|
174 | bubbles: shouldBubble,
|
175 | detail: evtData
|
176 | });
|
177 | } else {
|
178 | evt = document.createEvent("CustomEvent");
|
179 | evt.initCustomEvent(evtType, shouldBubble, false, evtData);
|
180 | }
|
181 | this.root_.dispatchEvent(evt);
|
182 | };
|
183 | return MDCComponent;
|
184 | }();
|
185 | exports.MDCComponent = MDCComponent;
|
186 | exports.default = MDCComponent;
|
187 | },
|
188 | 11: function(module, exports, __webpack_require__) {
|
189 | "use strict";
|
190 | Object.defineProperty(exports, "__esModule", {
|
191 | value: true
|
192 | });
|
193 | var cssPropertyNameMap = {
|
194 | animation: {
|
195 | prefixed: "-webkit-animation",
|
196 | standard: "animation"
|
197 | },
|
198 | transform: {
|
199 | prefixed: "-webkit-transform",
|
200 | standard: "transform"
|
201 | },
|
202 | transition: {
|
203 | prefixed: "-webkit-transition",
|
204 | standard: "transition"
|
205 | }
|
206 | };
|
207 | var jsEventTypeMap = {
|
208 | animationend: {
|
209 | cssProperty: "animation",
|
210 | prefixed: "webkitAnimationEnd",
|
211 | standard: "animationend"
|
212 | },
|
213 | animationiteration: {
|
214 | cssProperty: "animation",
|
215 | prefixed: "webkitAnimationIteration",
|
216 | standard: "animationiteration"
|
217 | },
|
218 | animationstart: {
|
219 | cssProperty: "animation",
|
220 | prefixed: "webkitAnimationStart",
|
221 | standard: "animationstart"
|
222 | },
|
223 | transitionend: {
|
224 | cssProperty: "transition",
|
225 | prefixed: "webkitTransitionEnd",
|
226 | standard: "transitionend"
|
227 | }
|
228 | };
|
229 | function isWindow(windowObj) {
|
230 | return Boolean(windowObj.document) && typeof windowObj.document.createElement === "function";
|
231 | }
|
232 | function getCorrectPropertyName(windowObj, cssProperty) {
|
233 | if (isWindow(windowObj) && cssProperty in cssPropertyNameMap) {
|
234 | var el = windowObj.document.createElement("div");
|
235 | var _a = cssPropertyNameMap[cssProperty], standard = _a.standard, prefixed = _a.prefixed;
|
236 | var isStandard = standard in el.style;
|
237 | return isStandard ? standard : prefixed;
|
238 | }
|
239 | return cssProperty;
|
240 | }
|
241 | exports.getCorrectPropertyName = getCorrectPropertyName;
|
242 | function getCorrectEventName(windowObj, eventType) {
|
243 | if (isWindow(windowObj) && eventType in jsEventTypeMap) {
|
244 | var el = windowObj.document.createElement("div");
|
245 | var _a = jsEventTypeMap[eventType], standard = _a.standard, prefixed = _a.prefixed, cssProperty = _a.cssProperty;
|
246 | var isStandard = cssProperty in el.style;
|
247 | return isStandard ? standard : prefixed;
|
248 | }
|
249 | return eventType;
|
250 | }
|
251 | exports.getCorrectEventName = getCorrectEventName;
|
252 | },
|
253 | 163: function(module, exports, __webpack_require__) {
|
254 | "use strict";
|
255 | function __export(m) {
|
256 | for (var p in m) {
|
257 | if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
258 | }
|
259 | }
|
260 | Object.defineProperty(exports, "__esModule", {
|
261 | value: true
|
262 | });
|
263 | __export(__webpack_require__(164));
|
264 | __export(__webpack_require__(165));
|
265 | __export(__webpack_require__(166));
|
266 | },
|
267 | 164: function(module, exports, __webpack_require__) {
|
268 | "use strict";
|
269 | function __export(m) {
|
270 | for (var p in m) {
|
271 | if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
272 | }
|
273 | }
|
274 | Object.defineProperty(exports, "__esModule", {
|
275 | value: true
|
276 | });
|
277 | __export(__webpack_require__(93));
|
278 | __export(__webpack_require__(51));
|
279 | var constants_1 = __webpack_require__(50);
|
280 | exports.tabCssClasses = constants_1.cssClasses;
|
281 | exports.tabStrings = constants_1.strings;
|
282 | },
|
283 | 165: function(module, exports, __webpack_require__) {
|
284 | "use strict";
|
285 | function __export(m) {
|
286 | for (var p in m) {
|
287 | if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
288 | }
|
289 | }
|
290 | Object.defineProperty(exports, "__esModule", {
|
291 | value: true
|
292 | });
|
293 | __export(__webpack_require__(94));
|
294 | __export(__webpack_require__(95));
|
295 | var constants_1 = __webpack_require__(96);
|
296 | exports.tabBarCssClasses = constants_1.cssClasses;
|
297 | exports.tabBarStrings = constants_1.strings;
|
298 | },
|
299 | 166: function(module, exports, __webpack_require__) {
|
300 | "use strict";
|
301 | function __export(m) {
|
302 | for (var p in m) {
|
303 | if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
304 | }
|
305 | }
|
306 | Object.defineProperty(exports, "__esModule", {
|
307 | value: true
|
308 | });
|
309 | __export(__webpack_require__(167));
|
310 | __export(__webpack_require__(97));
|
311 | var constants_1 = __webpack_require__(98);
|
312 | exports.tabBarScrollerCssClasses = constants_1.cssClasses;
|
313 | exports.tabBarScrollerStrings = constants_1.strings;
|
314 | },
|
315 | 167: function(module, exports, __webpack_require__) {
|
316 | "use strict";
|
317 | var __extends = this && this.__extends || function() {
|
318 | var _extendStatics = function extendStatics(d, b) {
|
319 | _extendStatics = Object.setPrototypeOf || {
|
320 | __proto__: []
|
321 | } instanceof Array && function(d, b) {
|
322 | d.__proto__ = b;
|
323 | } || function(d, b) {
|
324 | for (var p in b) {
|
325 | if (b.hasOwnProperty(p)) d[p] = b[p];
|
326 | }
|
327 | };
|
328 | return _extendStatics(d, b);
|
329 | };
|
330 | return function(d, b) {
|
331 | _extendStatics(d, b);
|
332 | function __() {
|
333 | this.constructor = d;
|
334 | }
|
335 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
336 | };
|
337 | }();
|
338 | Object.defineProperty(exports, "__esModule", {
|
339 | value: true
|
340 | });
|
341 | var util_1 = __webpack_require__(11);
|
342 | var component_1 = __webpack_require__(1);
|
343 | var component_2 = __webpack_require__(94);
|
344 | var foundation_1 = __webpack_require__(97);
|
345 | var MDCTabBarScroller = function(_super) {
|
346 | __extends(MDCTabBarScroller, _super);
|
347 | function MDCTabBarScroller() {
|
348 | return _super !== null && _super.apply(this, arguments) || this;
|
349 | }
|
350 | MDCTabBarScroller.attachTo = function(root) {
|
351 | return new MDCTabBarScroller(root);
|
352 | };
|
353 | Object.defineProperty(MDCTabBarScroller.prototype, "tabBar", {
|
354 | get: function get() {
|
355 | return this.tabBar_;
|
356 | },
|
357 | enumerable: true,
|
358 | configurable: true
|
359 | });
|
360 | MDCTabBarScroller.prototype.initialize = function(tabBarFactory) {
|
361 | if (tabBarFactory === void 0) {
|
362 | tabBarFactory = function tabBarFactory(el) {
|
363 | return new component_2.MDCTabBar(el);
|
364 | };
|
365 | }
|
366 | this.scrollFrame_ = this.root_.querySelector(foundation_1.MDCTabBarScrollerFoundation.strings.FRAME_SELECTOR);
|
367 | this.tabBarEl_ = this.root_.querySelector(foundation_1.MDCTabBarScrollerFoundation.strings.TABS_SELECTOR);
|
368 | this.forwardIndicator_ = this.root_.querySelector(foundation_1.MDCTabBarScrollerFoundation.strings.INDICATOR_FORWARD_SELECTOR);
|
369 | this.backIndicator_ = this.root_.querySelector(foundation_1.MDCTabBarScrollerFoundation.strings.INDICATOR_BACK_SELECTOR);
|
370 | this.tabBar_ = tabBarFactory(this.tabBarEl_);
|
371 | };
|
372 | MDCTabBarScroller.prototype.getDefaultFoundation = function() {
|
373 | var _this = this;
|
374 | var adapter = {
|
375 | addClass: function addClass(className) {
|
376 | return _this.root_.classList.add(className);
|
377 | },
|
378 | removeClass: function removeClass(className) {
|
379 | return _this.root_.classList.remove(className);
|
380 | },
|
381 | eventTargetHasClass: function eventTargetHasClass(target, className) {
|
382 | return target.classList.contains(className);
|
383 | },
|
384 | addClassToForwardIndicator: function addClassToForwardIndicator(className) {
|
385 | return _this.forwardIndicator_.classList.add(className);
|
386 | },
|
387 | removeClassFromForwardIndicator: function removeClassFromForwardIndicator(className) {
|
388 | return _this.forwardIndicator_.classList.remove(className);
|
389 | },
|
390 | addClassToBackIndicator: function addClassToBackIndicator(className) {
|
391 | return _this.backIndicator_.classList.add(className);
|
392 | },
|
393 | removeClassFromBackIndicator: function removeClassFromBackIndicator(className) {
|
394 | return _this.backIndicator_.classList.remove(className);
|
395 | },
|
396 | isRTL: function isRTL() {
|
397 | return getComputedStyle(_this.root_).getPropertyValue("direction") === "rtl";
|
398 | },
|
399 | registerBackIndicatorClickHandler: function registerBackIndicatorClickHandler(handler) {
|
400 | return _this.backIndicator_.addEventListener("click", handler);
|
401 | },
|
402 | deregisterBackIndicatorClickHandler: function deregisterBackIndicatorClickHandler(handler) {
|
403 | return _this.backIndicator_.removeEventListener("click", handler);
|
404 | },
|
405 | registerForwardIndicatorClickHandler: function registerForwardIndicatorClickHandler(handler) {
|
406 | return _this.forwardIndicator_.addEventListener("click", handler);
|
407 | },
|
408 | deregisterForwardIndicatorClickHandler: function deregisterForwardIndicatorClickHandler(handler) {
|
409 | return _this.forwardIndicator_.removeEventListener("click", handler);
|
410 | },
|
411 | registerCapturedInteractionHandler: function registerCapturedInteractionHandler(evt, handler) {
|
412 | return _this.root_.addEventListener(evt, handler, true);
|
413 | },
|
414 | deregisterCapturedInteractionHandler: function deregisterCapturedInteractionHandler(evt, handler) {
|
415 | return _this.root_.removeEventListener(evt, handler, true);
|
416 | },
|
417 | registerWindowResizeHandler: function registerWindowResizeHandler(handler) {
|
418 | return window.addEventListener("resize", handler);
|
419 | },
|
420 | deregisterWindowResizeHandler: function deregisterWindowResizeHandler(handler) {
|
421 | return window.removeEventListener("resize", handler);
|
422 | },
|
423 | getNumberOfTabs: function getNumberOfTabs() {
|
424 | return _this.tabBar.tabs.length;
|
425 | },
|
426 | getComputedWidthForTabAtIndex: function getComputedWidthForTabAtIndex(index) {
|
427 | return _this.tabBar.tabs[index].computedWidth;
|
428 | },
|
429 | getComputedLeftForTabAtIndex: function getComputedLeftForTabAtIndex(index) {
|
430 | return _this.tabBar.tabs[index].computedLeft;
|
431 | },
|
432 | getOffsetWidthForScrollFrame: function getOffsetWidthForScrollFrame() {
|
433 | return _this.scrollFrame_.offsetWidth;
|
434 | },
|
435 | getScrollLeftForScrollFrame: function getScrollLeftForScrollFrame() {
|
436 | return _this.scrollFrame_.scrollLeft;
|
437 | },
|
438 | setScrollLeftForScrollFrame: function setScrollLeftForScrollFrame(scrollLeftAmount) {
|
439 | return _this.scrollFrame_.scrollLeft = scrollLeftAmount;
|
440 | },
|
441 | getOffsetWidthForTabBar: function getOffsetWidthForTabBar() {
|
442 | return _this.tabBarEl_.offsetWidth;
|
443 | },
|
444 | setTransformStyleForTabBar: function setTransformStyleForTabBar(value) {
|
445 | _this.tabBarEl_.style.setProperty(util_1.getCorrectPropertyName(window, "transform"), value);
|
446 | },
|
447 | getOffsetLeftForEventTarget: function getOffsetLeftForEventTarget(target) {
|
448 | return target.offsetLeft;
|
449 | },
|
450 | getOffsetWidthForEventTarget: function getOffsetWidthForEventTarget(target) {
|
451 | return target.offsetWidth;
|
452 | }
|
453 | };
|
454 | return new foundation_1.MDCTabBarScrollerFoundation(adapter);
|
455 | };
|
456 | MDCTabBarScroller.prototype.layout = function() {
|
457 | this.foundation_.layout();
|
458 | };
|
459 | return MDCTabBarScroller;
|
460 | }(component_1.MDCComponent);
|
461 | exports.MDCTabBarScroller = MDCTabBarScroller;
|
462 | },
|
463 | 2: function(module, exports, __webpack_require__) {
|
464 | "use strict";
|
465 | Object.defineProperty(exports, "__esModule", {
|
466 | value: true
|
467 | });
|
468 | function closest(element, selector) {
|
469 | if (element.closest) {
|
470 | return element.closest(selector);
|
471 | }
|
472 | var el = element;
|
473 | while (el) {
|
474 | if (matches(el, selector)) {
|
475 | return el;
|
476 | }
|
477 | el = el.parentElement;
|
478 | }
|
479 | return null;
|
480 | }
|
481 | exports.closest = closest;
|
482 | function matches(element, selector) {
|
483 | var nativeMatches = element.matches || element.webkitMatchesSelector || element.msMatchesSelector;
|
484 | return nativeMatches.call(element, selector);
|
485 | }
|
486 | exports.matches = matches;
|
487 | },
|
488 | 3: function(module, exports, __webpack_require__) {
|
489 | "use strict";
|
490 | Object.defineProperty(exports, "__esModule", {
|
491 | value: true
|
492 | });
|
493 | var supportsCssVariables_;
|
494 | var supportsPassive_;
|
495 | function detectEdgePseudoVarBug(windowObj) {
|
496 | var document = windowObj.document;
|
497 | var node = document.createElement("div");
|
498 | node.className = "mdc-ripple-surface--test-edge-var-bug";
|
499 | document.body.appendChild(node);
|
500 | var computedStyle = windowObj.getComputedStyle(node);
|
501 | var hasPseudoVarBug = computedStyle !== null && computedStyle.borderTopStyle === "solid";
|
502 | if (node.parentNode) {
|
503 | node.parentNode.removeChild(node);
|
504 | }
|
505 | return hasPseudoVarBug;
|
506 | }
|
507 | function supportsCssVariables(windowObj, forceRefresh) {
|
508 | if (forceRefresh === void 0) {
|
509 | forceRefresh = false;
|
510 | }
|
511 | var CSS = windowObj.CSS;
|
512 | var supportsCssVars = supportsCssVariables_;
|
513 | if (typeof supportsCssVariables_ === "boolean" && !forceRefresh) {
|
514 | return supportsCssVariables_;
|
515 | }
|
516 | var supportsFunctionPresent = CSS && typeof CSS.supports === "function";
|
517 | if (!supportsFunctionPresent) {
|
518 | return false;
|
519 | }
|
520 | var explicitlySupportsCssVars = CSS.supports("--css-vars", "yes");
|
521 | var weAreFeatureDetectingSafari10plus = CSS.supports("(--css-vars: yes)") && CSS.supports("color", "#00000000");
|
522 | if (explicitlySupportsCssVars || weAreFeatureDetectingSafari10plus) {
|
523 | supportsCssVars = !detectEdgePseudoVarBug(windowObj);
|
524 | } else {
|
525 | supportsCssVars = false;
|
526 | }
|
527 | if (!forceRefresh) {
|
528 | supportsCssVariables_ = supportsCssVars;
|
529 | }
|
530 | return supportsCssVars;
|
531 | }
|
532 | exports.supportsCssVariables = supportsCssVariables;
|
533 | function applyPassive(globalObj, forceRefresh) {
|
534 | if (globalObj === void 0) {
|
535 | globalObj = window;
|
536 | }
|
537 | if (forceRefresh === void 0) {
|
538 | forceRefresh = false;
|
539 | }
|
540 | if (supportsPassive_ === undefined || forceRefresh) {
|
541 | var isSupported_1 = false;
|
542 | try {
|
543 | globalObj.document.addEventListener("test", function() {
|
544 | return undefined;
|
545 | }, {
|
546 | get passive() {
|
547 | isSupported_1 = true;
|
548 | return isSupported_1;
|
549 | }
|
550 | });
|
551 | } catch (e) {}
|
552 | supportsPassive_ = isSupported_1;
|
553 | }
|
554 | return supportsPassive_ ? {
|
555 | passive: true
|
556 | } : false;
|
557 | }
|
558 | exports.applyPassive = applyPassive;
|
559 | function getNormalizedEventCoords(evt, pageOffset, clientRect) {
|
560 | if (!evt) {
|
561 | return {
|
562 | x: 0,
|
563 | y: 0
|
564 | };
|
565 | }
|
566 | var x = pageOffset.x, y = pageOffset.y;
|
567 | var documentX = x + clientRect.left;
|
568 | var documentY = y + clientRect.top;
|
569 | var normalizedX;
|
570 | var normalizedY;
|
571 | if (evt.type === "touchstart") {
|
572 | var touchEvent = evt;
|
573 | normalizedX = touchEvent.changedTouches[0].pageX - documentX;
|
574 | normalizedY = touchEvent.changedTouches[0].pageY - documentY;
|
575 | } else {
|
576 | var mouseEvent = evt;
|
577 | normalizedX = mouseEvent.pageX - documentX;
|
578 | normalizedY = mouseEvent.pageY - documentY;
|
579 | }
|
580 | return {
|
581 | x: normalizedX,
|
582 | y: normalizedY
|
583 | };
|
584 | }
|
585 | exports.getNormalizedEventCoords = getNormalizedEventCoords;
|
586 | },
|
587 | 4: function(module, exports, __webpack_require__) {
|
588 | "use strict";
|
589 | var __extends = this && this.__extends || function() {
|
590 | var _extendStatics = function extendStatics(d, b) {
|
591 | _extendStatics = Object.setPrototypeOf || {
|
592 | __proto__: []
|
593 | } instanceof Array && function(d, b) {
|
594 | d.__proto__ = b;
|
595 | } || function(d, b) {
|
596 | for (var p in b) {
|
597 | if (b.hasOwnProperty(p)) d[p] = b[p];
|
598 | }
|
599 | };
|
600 | return _extendStatics(d, b);
|
601 | };
|
602 | return function(d, b) {
|
603 | _extendStatics(d, b);
|
604 | function __() {
|
605 | this.constructor = d;
|
606 | }
|
607 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
608 | };
|
609 | }();
|
610 | var __assign = this && this.__assign || function() {
|
611 | __assign = Object.assign || function(t) {
|
612 | for (var s, i = 1, n = arguments.length; i < n; i++) {
|
613 | s = arguments[i];
|
614 | for (var p in s) {
|
615 | if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
616 | }
|
617 | }
|
618 | return t;
|
619 | };
|
620 | return __assign.apply(this, arguments);
|
621 | };
|
622 | Object.defineProperty(exports, "__esModule", {
|
623 | value: true
|
624 | });
|
625 | var foundation_1 = __webpack_require__(0);
|
626 | var constants_1 = __webpack_require__(5);
|
627 | var util_1 = __webpack_require__(3);
|
628 | var ACTIVATION_EVENT_TYPES = [ "touchstart", "pointerdown", "mousedown", "keydown" ];
|
629 | var POINTER_DEACTIVATION_EVENT_TYPES = [ "touchend", "pointerup", "mouseup", "contextmenu" ];
|
630 | var activatedTargets = [];
|
631 | var MDCRippleFoundation = function(_super) {
|
632 | __extends(MDCRippleFoundation, _super);
|
633 | function MDCRippleFoundation(adapter) {
|
634 | var _this = _super.call(this, __assign({}, MDCRippleFoundation.defaultAdapter, adapter)) || this;
|
635 | _this.activationAnimationHasEnded_ = false;
|
636 | _this.activationTimer_ = 0;
|
637 | _this.fgDeactivationRemovalTimer_ = 0;
|
638 | _this.fgScale_ = "0";
|
639 | _this.frame_ = {
|
640 | width: 0,
|
641 | height: 0
|
642 | };
|
643 | _this.initialSize_ = 0;
|
644 | _this.layoutFrame_ = 0;
|
645 | _this.maxRadius_ = 0;
|
646 | _this.unboundedCoords_ = {
|
647 | left: 0,
|
648 | top: 0
|
649 | };
|
650 | _this.activationState_ = _this.defaultActivationState_();
|
651 | _this.activationTimerCallback_ = function() {
|
652 | _this.activationAnimationHasEnded_ = true;
|
653 | _this.runDeactivationUXLogicIfReady_();
|
654 | };
|
655 | _this.activateHandler_ = function(e) {
|
656 | return _this.activate_(e);
|
657 | };
|
658 | _this.deactivateHandler_ = function() {
|
659 | return _this.deactivate_();
|
660 | };
|
661 | _this.focusHandler_ = function() {
|
662 | return _this.handleFocus();
|
663 | };
|
664 | _this.blurHandler_ = function() {
|
665 | return _this.handleBlur();
|
666 | };
|
667 | _this.resizeHandler_ = function() {
|
668 | return _this.layout();
|
669 | };
|
670 | return _this;
|
671 | }
|
672 | Object.defineProperty(MDCRippleFoundation, "cssClasses", {
|
673 | get: function get() {
|
674 | return constants_1.cssClasses;
|
675 | },
|
676 | enumerable: true,
|
677 | configurable: true
|
678 | });
|
679 | Object.defineProperty(MDCRippleFoundation, "strings", {
|
680 | get: function get() {
|
681 | return constants_1.strings;
|
682 | },
|
683 | enumerable: true,
|
684 | configurable: true
|
685 | });
|
686 | Object.defineProperty(MDCRippleFoundation, "numbers", {
|
687 | get: function get() {
|
688 | return constants_1.numbers;
|
689 | },
|
690 | enumerable: true,
|
691 | configurable: true
|
692 | });
|
693 | Object.defineProperty(MDCRippleFoundation, "defaultAdapter", {
|
694 | get: function get() {
|
695 | return {
|
696 | addClass: function addClass() {
|
697 | return undefined;
|
698 | },
|
699 | browserSupportsCssVars: function browserSupportsCssVars() {
|
700 | return true;
|
701 | },
|
702 | computeBoundingRect: function computeBoundingRect() {
|
703 | return {
|
704 | top: 0,
|
705 | right: 0,
|
706 | bottom: 0,
|
707 | left: 0,
|
708 | width: 0,
|
709 | height: 0
|
710 | };
|
711 | },
|
712 | containsEventTarget: function containsEventTarget() {
|
713 | return true;
|
714 | },
|
715 | deregisterDocumentInteractionHandler: function deregisterDocumentInteractionHandler() {
|
716 | return undefined;
|
717 | },
|
718 | deregisterInteractionHandler: function deregisterInteractionHandler() {
|
719 | return undefined;
|
720 | },
|
721 | deregisterResizeHandler: function deregisterResizeHandler() {
|
722 | return undefined;
|
723 | },
|
724 | getWindowPageOffset: function getWindowPageOffset() {
|
725 | return {
|
726 | x: 0,
|
727 | y: 0
|
728 | };
|
729 | },
|
730 | isSurfaceActive: function isSurfaceActive() {
|
731 | return true;
|
732 | },
|
733 | isSurfaceDisabled: function isSurfaceDisabled() {
|
734 | return true;
|
735 | },
|
736 | isUnbounded: function isUnbounded() {
|
737 | return true;
|
738 | },
|
739 | registerDocumentInteractionHandler: function registerDocumentInteractionHandler() {
|
740 | return undefined;
|
741 | },
|
742 | registerInteractionHandler: function registerInteractionHandler() {
|
743 | return undefined;
|
744 | },
|
745 | registerResizeHandler: function registerResizeHandler() {
|
746 | return undefined;
|
747 | },
|
748 | removeClass: function removeClass() {
|
749 | return undefined;
|
750 | },
|
751 | updateCssVariable: function updateCssVariable() {
|
752 | return undefined;
|
753 | }
|
754 | };
|
755 | },
|
756 | enumerable: true,
|
757 | configurable: true
|
758 | });
|
759 | MDCRippleFoundation.prototype.init = function() {
|
760 | var _this = this;
|
761 | var supportsPressRipple = this.supportsPressRipple_();
|
762 | this.registerRootHandlers_(supportsPressRipple);
|
763 | if (supportsPressRipple) {
|
764 | var _a = MDCRippleFoundation.cssClasses, ROOT_1 = _a.ROOT, UNBOUNDED_1 = _a.UNBOUNDED;
|
765 | requestAnimationFrame(function() {
|
766 | _this.adapter_.addClass(ROOT_1);
|
767 | if (_this.adapter_.isUnbounded()) {
|
768 | _this.adapter_.addClass(UNBOUNDED_1);
|
769 | _this.layoutInternal_();
|
770 | }
|
771 | });
|
772 | }
|
773 | };
|
774 | MDCRippleFoundation.prototype.destroy = function() {
|
775 | var _this = this;
|
776 | if (this.supportsPressRipple_()) {
|
777 | if (this.activationTimer_) {
|
778 | clearTimeout(this.activationTimer_);
|
779 | this.activationTimer_ = 0;
|
780 | this.adapter_.removeClass(MDCRippleFoundation.cssClasses.FG_ACTIVATION);
|
781 | }
|
782 | if (this.fgDeactivationRemovalTimer_) {
|
783 | clearTimeout(this.fgDeactivationRemovalTimer_);
|
784 | this.fgDeactivationRemovalTimer_ = 0;
|
785 | this.adapter_.removeClass(MDCRippleFoundation.cssClasses.FG_DEACTIVATION);
|
786 | }
|
787 | var _a = MDCRippleFoundation.cssClasses, ROOT_2 = _a.ROOT, UNBOUNDED_2 = _a.UNBOUNDED;
|
788 | requestAnimationFrame(function() {
|
789 | _this.adapter_.removeClass(ROOT_2);
|
790 | _this.adapter_.removeClass(UNBOUNDED_2);
|
791 | _this.removeCssVars_();
|
792 | });
|
793 | }
|
794 | this.deregisterRootHandlers_();
|
795 | this.deregisterDeactivationHandlers_();
|
796 | };
|
797 | MDCRippleFoundation.prototype.activate = function(evt) {
|
798 | this.activate_(evt);
|
799 | };
|
800 | MDCRippleFoundation.prototype.deactivate = function() {
|
801 | this.deactivate_();
|
802 | };
|
803 | MDCRippleFoundation.prototype.layout = function() {
|
804 | var _this = this;
|
805 | if (this.layoutFrame_) {
|
806 | cancelAnimationFrame(this.layoutFrame_);
|
807 | }
|
808 | this.layoutFrame_ = requestAnimationFrame(function() {
|
809 | _this.layoutInternal_();
|
810 | _this.layoutFrame_ = 0;
|
811 | });
|
812 | };
|
813 | MDCRippleFoundation.prototype.setUnbounded = function(unbounded) {
|
814 | var UNBOUNDED = MDCRippleFoundation.cssClasses.UNBOUNDED;
|
815 | if (unbounded) {
|
816 | this.adapter_.addClass(UNBOUNDED);
|
817 | } else {
|
818 | this.adapter_.removeClass(UNBOUNDED);
|
819 | }
|
820 | };
|
821 | MDCRippleFoundation.prototype.handleFocus = function() {
|
822 | var _this = this;
|
823 | requestAnimationFrame(function() {
|
824 | return _this.adapter_.addClass(MDCRippleFoundation.cssClasses.BG_FOCUSED);
|
825 | });
|
826 | };
|
827 | MDCRippleFoundation.prototype.handleBlur = function() {
|
828 | var _this = this;
|
829 | requestAnimationFrame(function() {
|
830 | return _this.adapter_.removeClass(MDCRippleFoundation.cssClasses.BG_FOCUSED);
|
831 | });
|
832 | };
|
833 | MDCRippleFoundation.prototype.supportsPressRipple_ = function() {
|
834 | return this.adapter_.browserSupportsCssVars();
|
835 | };
|
836 | MDCRippleFoundation.prototype.defaultActivationState_ = function() {
|
837 | return {
|
838 | activationEvent: undefined,
|
839 | hasDeactivationUXRun: false,
|
840 | isActivated: false,
|
841 | isProgrammatic: false,
|
842 | wasActivatedByPointer: false,
|
843 | wasElementMadeActive: false
|
844 | };
|
845 | };
|
846 | MDCRippleFoundation.prototype.registerRootHandlers_ = function(supportsPressRipple) {
|
847 | var _this = this;
|
848 | if (supportsPressRipple) {
|
849 | ACTIVATION_EVENT_TYPES.forEach(function(evtType) {
|
850 | _this.adapter_.registerInteractionHandler(evtType, _this.activateHandler_);
|
851 | });
|
852 | if (this.adapter_.isUnbounded()) {
|
853 | this.adapter_.registerResizeHandler(this.resizeHandler_);
|
854 | }
|
855 | }
|
856 | this.adapter_.registerInteractionHandler("focus", this.focusHandler_);
|
857 | this.adapter_.registerInteractionHandler("blur", this.blurHandler_);
|
858 | };
|
859 | MDCRippleFoundation.prototype.registerDeactivationHandlers_ = function(evt) {
|
860 | var _this = this;
|
861 | if (evt.type === "keydown") {
|
862 | this.adapter_.registerInteractionHandler("keyup", this.deactivateHandler_);
|
863 | } else {
|
864 | POINTER_DEACTIVATION_EVENT_TYPES.forEach(function(evtType) {
|
865 | _this.adapter_.registerDocumentInteractionHandler(evtType, _this.deactivateHandler_);
|
866 | });
|
867 | }
|
868 | };
|
869 | MDCRippleFoundation.prototype.deregisterRootHandlers_ = function() {
|
870 | var _this = this;
|
871 | ACTIVATION_EVENT_TYPES.forEach(function(evtType) {
|
872 | _this.adapter_.deregisterInteractionHandler(evtType, _this.activateHandler_);
|
873 | });
|
874 | this.adapter_.deregisterInteractionHandler("focus", this.focusHandler_);
|
875 | this.adapter_.deregisterInteractionHandler("blur", this.blurHandler_);
|
876 | if (this.adapter_.isUnbounded()) {
|
877 | this.adapter_.deregisterResizeHandler(this.resizeHandler_);
|
878 | }
|
879 | };
|
880 | MDCRippleFoundation.prototype.deregisterDeactivationHandlers_ = function() {
|
881 | var _this = this;
|
882 | this.adapter_.deregisterInteractionHandler("keyup", this.deactivateHandler_);
|
883 | POINTER_DEACTIVATION_EVENT_TYPES.forEach(function(evtType) {
|
884 | _this.adapter_.deregisterDocumentInteractionHandler(evtType, _this.deactivateHandler_);
|
885 | });
|
886 | };
|
887 | MDCRippleFoundation.prototype.removeCssVars_ = function() {
|
888 | var _this = this;
|
889 | var rippleStrings = MDCRippleFoundation.strings;
|
890 | var keys = Object.keys(rippleStrings);
|
891 | keys.forEach(function(key) {
|
892 | if (key.indexOf("VAR_") === 0) {
|
893 | _this.adapter_.updateCssVariable(rippleStrings[key], null);
|
894 | }
|
895 | });
|
896 | };
|
897 | MDCRippleFoundation.prototype.activate_ = function(evt) {
|
898 | var _this = this;
|
899 | if (this.adapter_.isSurfaceDisabled()) {
|
900 | return;
|
901 | }
|
902 | var activationState = this.activationState_;
|
903 | if (activationState.isActivated) {
|
904 | return;
|
905 | }
|
906 | var previousActivationEvent = this.previousActivationEvent_;
|
907 | var isSameInteraction = previousActivationEvent && evt !== undefined && previousActivationEvent.type !== evt.type;
|
908 | if (isSameInteraction) {
|
909 | return;
|
910 | }
|
911 | activationState.isActivated = true;
|
912 | activationState.isProgrammatic = evt === undefined;
|
913 | activationState.activationEvent = evt;
|
914 | activationState.wasActivatedByPointer = activationState.isProgrammatic ? false : evt !== undefined && (evt.type === "mousedown" || evt.type === "touchstart" || evt.type === "pointerdown");
|
915 | var hasActivatedChild = evt !== undefined && activatedTargets.length > 0 && activatedTargets.some(function(target) {
|
916 | return _this.adapter_.containsEventTarget(target);
|
917 | });
|
918 | if (hasActivatedChild) {
|
919 | this.resetActivationState_();
|
920 | return;
|
921 | }
|
922 | if (evt !== undefined) {
|
923 | activatedTargets.push(evt.target);
|
924 | this.registerDeactivationHandlers_(evt);
|
925 | }
|
926 | activationState.wasElementMadeActive = this.checkElementMadeActive_(evt);
|
927 | if (activationState.wasElementMadeActive) {
|
928 | this.animateActivation_();
|
929 | }
|
930 | requestAnimationFrame(function() {
|
931 | activatedTargets = [];
|
932 | if (!activationState.wasElementMadeActive && evt !== undefined && (evt.key === " " || evt.keyCode === 32)) {
|
933 | activationState.wasElementMadeActive = _this.checkElementMadeActive_(evt);
|
934 | if (activationState.wasElementMadeActive) {
|
935 | _this.animateActivation_();
|
936 | }
|
937 | }
|
938 | if (!activationState.wasElementMadeActive) {
|
939 | _this.activationState_ = _this.defaultActivationState_();
|
940 | }
|
941 | });
|
942 | };
|
943 | MDCRippleFoundation.prototype.checkElementMadeActive_ = function(evt) {
|
944 | return evt !== undefined && evt.type === "keydown" ? this.adapter_.isSurfaceActive() : true;
|
945 | };
|
946 | MDCRippleFoundation.prototype.animateActivation_ = function() {
|
947 | var _this = this;
|
948 | var _a = MDCRippleFoundation.strings, VAR_FG_TRANSLATE_START = _a.VAR_FG_TRANSLATE_START, VAR_FG_TRANSLATE_END = _a.VAR_FG_TRANSLATE_END;
|
949 | var _b = MDCRippleFoundation.cssClasses, FG_DEACTIVATION = _b.FG_DEACTIVATION, FG_ACTIVATION = _b.FG_ACTIVATION;
|
950 | var DEACTIVATION_TIMEOUT_MS = MDCRippleFoundation.numbers.DEACTIVATION_TIMEOUT_MS;
|
951 | this.layoutInternal_();
|
952 | var translateStart = "";
|
953 | var translateEnd = "";
|
954 | if (!this.adapter_.isUnbounded()) {
|
955 | var _c = this.getFgTranslationCoordinates_(), startPoint = _c.startPoint, endPoint = _c.endPoint;
|
956 | translateStart = startPoint.x + "px, " + startPoint.y + "px";
|
957 | translateEnd = endPoint.x + "px, " + endPoint.y + "px";
|
958 | }
|
959 | this.adapter_.updateCssVariable(VAR_FG_TRANSLATE_START, translateStart);
|
960 | this.adapter_.updateCssVariable(VAR_FG_TRANSLATE_END, translateEnd);
|
961 | clearTimeout(this.activationTimer_);
|
962 | clearTimeout(this.fgDeactivationRemovalTimer_);
|
963 | this.rmBoundedActivationClasses_();
|
964 | this.adapter_.removeClass(FG_DEACTIVATION);
|
965 | this.adapter_.computeBoundingRect();
|
966 | this.adapter_.addClass(FG_ACTIVATION);
|
967 | this.activationTimer_ = setTimeout(function() {
|
968 | return _this.activationTimerCallback_();
|
969 | }, DEACTIVATION_TIMEOUT_MS);
|
970 | };
|
971 | MDCRippleFoundation.prototype.getFgTranslationCoordinates_ = function() {
|
972 | var _a = this.activationState_, activationEvent = _a.activationEvent, wasActivatedByPointer = _a.wasActivatedByPointer;
|
973 | var startPoint;
|
974 | if (wasActivatedByPointer) {
|
975 | startPoint = util_1.getNormalizedEventCoords(activationEvent, this.adapter_.getWindowPageOffset(), this.adapter_.computeBoundingRect());
|
976 | } else {
|
977 | startPoint = {
|
978 | x: this.frame_.width / 2,
|
979 | y: this.frame_.height / 2
|
980 | };
|
981 | }
|
982 | startPoint = {
|
983 | x: startPoint.x - this.initialSize_ / 2,
|
984 | y: startPoint.y - this.initialSize_ / 2
|
985 | };
|
986 | var endPoint = {
|
987 | x: this.frame_.width / 2 - this.initialSize_ / 2,
|
988 | y: this.frame_.height / 2 - this.initialSize_ / 2
|
989 | };
|
990 | return {
|
991 | startPoint: startPoint,
|
992 | endPoint: endPoint
|
993 | };
|
994 | };
|
995 | MDCRippleFoundation.prototype.runDeactivationUXLogicIfReady_ = function() {
|
996 | var _this = this;
|
997 | var FG_DEACTIVATION = MDCRippleFoundation.cssClasses.FG_DEACTIVATION;
|
998 | var _a = this.activationState_, hasDeactivationUXRun = _a.hasDeactivationUXRun, isActivated = _a.isActivated;
|
999 | var activationHasEnded = hasDeactivationUXRun || !isActivated;
|
1000 | if (activationHasEnded && this.activationAnimationHasEnded_) {
|
1001 | this.rmBoundedActivationClasses_();
|
1002 | this.adapter_.addClass(FG_DEACTIVATION);
|
1003 | this.fgDeactivationRemovalTimer_ = setTimeout(function() {
|
1004 | _this.adapter_.removeClass(FG_DEACTIVATION);
|
1005 | }, constants_1.numbers.FG_DEACTIVATION_MS);
|
1006 | }
|
1007 | };
|
1008 | MDCRippleFoundation.prototype.rmBoundedActivationClasses_ = function() {
|
1009 | var FG_ACTIVATION = MDCRippleFoundation.cssClasses.FG_ACTIVATION;
|
1010 | this.adapter_.removeClass(FG_ACTIVATION);
|
1011 | this.activationAnimationHasEnded_ = false;
|
1012 | this.adapter_.computeBoundingRect();
|
1013 | };
|
1014 | MDCRippleFoundation.prototype.resetActivationState_ = function() {
|
1015 | var _this = this;
|
1016 | this.previousActivationEvent_ = this.activationState_.activationEvent;
|
1017 | this.activationState_ = this.defaultActivationState_();
|
1018 | setTimeout(function() {
|
1019 | return _this.previousActivationEvent_ = undefined;
|
1020 | }, MDCRippleFoundation.numbers.TAP_DELAY_MS);
|
1021 | };
|
1022 | MDCRippleFoundation.prototype.deactivate_ = function() {
|
1023 | var _this = this;
|
1024 | var activationState = this.activationState_;
|
1025 | if (!activationState.isActivated) {
|
1026 | return;
|
1027 | }
|
1028 | var state = __assign({}, activationState);
|
1029 | if (activationState.isProgrammatic) {
|
1030 | requestAnimationFrame(function() {
|
1031 | return _this.animateDeactivation_(state);
|
1032 | });
|
1033 | this.resetActivationState_();
|
1034 | } else {
|
1035 | this.deregisterDeactivationHandlers_();
|
1036 | requestAnimationFrame(function() {
|
1037 | _this.activationState_.hasDeactivationUXRun = true;
|
1038 | _this.animateDeactivation_(state);
|
1039 | _this.resetActivationState_();
|
1040 | });
|
1041 | }
|
1042 | };
|
1043 | MDCRippleFoundation.prototype.animateDeactivation_ = function(_a) {
|
1044 | var wasActivatedByPointer = _a.wasActivatedByPointer, wasElementMadeActive = _a.wasElementMadeActive;
|
1045 | if (wasActivatedByPointer || wasElementMadeActive) {
|
1046 | this.runDeactivationUXLogicIfReady_();
|
1047 | }
|
1048 | };
|
1049 | MDCRippleFoundation.prototype.layoutInternal_ = function() {
|
1050 | var _this = this;
|
1051 | this.frame_ = this.adapter_.computeBoundingRect();
|
1052 | var maxDim = Math.max(this.frame_.height, this.frame_.width);
|
1053 | var getBoundedRadius = function getBoundedRadius() {
|
1054 | var hypotenuse = Math.sqrt(Math.pow(_this.frame_.width, 2) + Math.pow(_this.frame_.height, 2));
|
1055 | return hypotenuse + MDCRippleFoundation.numbers.PADDING;
|
1056 | };
|
1057 | this.maxRadius_ = this.adapter_.isUnbounded() ? maxDim : getBoundedRadius();
|
1058 | this.initialSize_ = Math.floor(maxDim * MDCRippleFoundation.numbers.INITIAL_ORIGIN_SCALE);
|
1059 | this.fgScale_ = "" + this.maxRadius_ / this.initialSize_;
|
1060 | this.updateLayoutCssVars_();
|
1061 | };
|
1062 | MDCRippleFoundation.prototype.updateLayoutCssVars_ = function() {
|
1063 | var _a = MDCRippleFoundation.strings, VAR_FG_SIZE = _a.VAR_FG_SIZE, VAR_LEFT = _a.VAR_LEFT, VAR_TOP = _a.VAR_TOP, VAR_FG_SCALE = _a.VAR_FG_SCALE;
|
1064 | this.adapter_.updateCssVariable(VAR_FG_SIZE, this.initialSize_ + "px");
|
1065 | this.adapter_.updateCssVariable(VAR_FG_SCALE, this.fgScale_);
|
1066 | if (this.adapter_.isUnbounded()) {
|
1067 | this.unboundedCoords_ = {
|
1068 | left: Math.round(this.frame_.width / 2 - this.initialSize_ / 2),
|
1069 | top: Math.round(this.frame_.height / 2 - this.initialSize_ / 2)
|
1070 | };
|
1071 | this.adapter_.updateCssVariable(VAR_LEFT, this.unboundedCoords_.left + "px");
|
1072 | this.adapter_.updateCssVariable(VAR_TOP, this.unboundedCoords_.top + "px");
|
1073 | }
|
1074 | };
|
1075 | return MDCRippleFoundation;
|
1076 | }(foundation_1.MDCFoundation);
|
1077 | exports.MDCRippleFoundation = MDCRippleFoundation;
|
1078 | exports.default = MDCRippleFoundation;
|
1079 | },
|
1080 | 5: function(module, exports, __webpack_require__) {
|
1081 | "use strict";
|
1082 | Object.defineProperty(exports, "__esModule", {
|
1083 | value: true
|
1084 | });
|
1085 | exports.cssClasses = {
|
1086 | BG_FOCUSED: "mdc-ripple-upgraded--background-focused",
|
1087 | FG_ACTIVATION: "mdc-ripple-upgraded--foreground-activation",
|
1088 | FG_DEACTIVATION: "mdc-ripple-upgraded--foreground-deactivation",
|
1089 | ROOT: "mdc-ripple-upgraded",
|
1090 | UNBOUNDED: "mdc-ripple-upgraded--unbounded"
|
1091 | };
|
1092 | exports.strings = {
|
1093 | VAR_FG_SCALE: "--mdc-ripple-fg-scale",
|
1094 | VAR_FG_SIZE: "--mdc-ripple-fg-size",
|
1095 | VAR_FG_TRANSLATE_END: "--mdc-ripple-fg-translate-end",
|
1096 | VAR_FG_TRANSLATE_START: "--mdc-ripple-fg-translate-start",
|
1097 | VAR_LEFT: "--mdc-ripple-left",
|
1098 | VAR_TOP: "--mdc-ripple-top"
|
1099 | };
|
1100 | exports.numbers = {
|
1101 | DEACTIVATION_TIMEOUT_MS: 225,
|
1102 | FG_DEACTIVATION_MS: 150,
|
1103 | INITIAL_ORIGIN_SCALE: .6,
|
1104 | PADDING: 10,
|
1105 | TAP_DELAY_MS: 300
|
1106 | };
|
1107 | },
|
1108 | 50: function(module, exports, __webpack_require__) {
|
1109 | "use strict";
|
1110 | Object.defineProperty(exports, "__esModule", {
|
1111 | value: true
|
1112 | });
|
1113 | exports.cssClasses = {
|
1114 | ACTIVE: "mdc-tab--active"
|
1115 | };
|
1116 | exports.strings = {
|
1117 | SELECTED_EVENT: "MDCTab:selected"
|
1118 | };
|
1119 | },
|
1120 | 51: function(module, exports, __webpack_require__) {
|
1121 | "use strict";
|
1122 | var __extends = this && this.__extends || function() {
|
1123 | var _extendStatics = function extendStatics(d, b) {
|
1124 | _extendStatics = Object.setPrototypeOf || {
|
1125 | __proto__: []
|
1126 | } instanceof Array && function(d, b) {
|
1127 | d.__proto__ = b;
|
1128 | } || function(d, b) {
|
1129 | for (var p in b) {
|
1130 | if (b.hasOwnProperty(p)) d[p] = b[p];
|
1131 | }
|
1132 | };
|
1133 | return _extendStatics(d, b);
|
1134 | };
|
1135 | return function(d, b) {
|
1136 | _extendStatics(d, b);
|
1137 | function __() {
|
1138 | this.constructor = d;
|
1139 | }
|
1140 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
1141 | };
|
1142 | }();
|
1143 | var __assign = this && this.__assign || function() {
|
1144 | __assign = Object.assign || function(t) {
|
1145 | for (var s, i = 1, n = arguments.length; i < n; i++) {
|
1146 | s = arguments[i];
|
1147 | for (var p in s) {
|
1148 | if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
1149 | }
|
1150 | }
|
1151 | return t;
|
1152 | };
|
1153 | return __assign.apply(this, arguments);
|
1154 | };
|
1155 | Object.defineProperty(exports, "__esModule", {
|
1156 | value: true
|
1157 | });
|
1158 | var foundation_1 = __webpack_require__(0);
|
1159 | var constants_1 = __webpack_require__(50);
|
1160 | var MDCTabFoundation = function(_super) {
|
1161 | __extends(MDCTabFoundation, _super);
|
1162 | function MDCTabFoundation(adapter) {
|
1163 | var _this = _super.call(this, __assign({}, MDCTabFoundation.defaultAdapter, adapter)) || this;
|
1164 | _this.computedWidth_ = 0;
|
1165 | _this.computedLeft_ = 0;
|
1166 | _this.isActive_ = false;
|
1167 | _this.preventDefaultOnClick_ = false;
|
1168 | _this.clickHandler_ = function(evt) {
|
1169 | if (_this.preventDefaultOnClick_) {
|
1170 | evt.preventDefault();
|
1171 | }
|
1172 | _this.adapter_.notifySelected();
|
1173 | };
|
1174 | _this.keydownHandler_ = function(evt) {
|
1175 | if (evt.key === "Enter" || evt.keyCode === 13) {
|
1176 | _this.adapter_.notifySelected();
|
1177 | }
|
1178 | };
|
1179 | return _this;
|
1180 | }
|
1181 | Object.defineProperty(MDCTabFoundation, "cssClasses", {
|
1182 | get: function get() {
|
1183 | return constants_1.cssClasses;
|
1184 | },
|
1185 | enumerable: true,
|
1186 | configurable: true
|
1187 | });
|
1188 | Object.defineProperty(MDCTabFoundation, "strings", {
|
1189 | get: function get() {
|
1190 | return constants_1.strings;
|
1191 | },
|
1192 | enumerable: true,
|
1193 | configurable: true
|
1194 | });
|
1195 | Object.defineProperty(MDCTabFoundation, "defaultAdapter", {
|
1196 | get: function get() {
|
1197 | return {
|
1198 | addClass: function addClass() {
|
1199 | return undefined;
|
1200 | },
|
1201 | removeClass: function removeClass() {
|
1202 | return undefined;
|
1203 | },
|
1204 | registerInteractionHandler: function registerInteractionHandler() {
|
1205 | return undefined;
|
1206 | },
|
1207 | deregisterInteractionHandler: function deregisterInteractionHandler() {
|
1208 | return undefined;
|
1209 | },
|
1210 | getOffsetWidth: function getOffsetWidth() {
|
1211 | return 0;
|
1212 | },
|
1213 | getOffsetLeft: function getOffsetLeft() {
|
1214 | return 0;
|
1215 | },
|
1216 | notifySelected: function notifySelected() {
|
1217 | return undefined;
|
1218 | }
|
1219 | };
|
1220 | },
|
1221 | enumerable: true,
|
1222 | configurable: true
|
1223 | });
|
1224 | MDCTabFoundation.prototype.init = function() {
|
1225 | this.adapter_.registerInteractionHandler("click", this.clickHandler_);
|
1226 | this.adapter_.registerInteractionHandler("keydown", this.keydownHandler_);
|
1227 | };
|
1228 | MDCTabFoundation.prototype.destroy = function() {
|
1229 | this.adapter_.deregisterInteractionHandler("click", this.clickHandler_);
|
1230 | this.adapter_.deregisterInteractionHandler("keydown", this.keydownHandler_);
|
1231 | };
|
1232 | MDCTabFoundation.prototype.getComputedWidth = function() {
|
1233 | return this.computedWidth_;
|
1234 | };
|
1235 | MDCTabFoundation.prototype.getComputedLeft = function() {
|
1236 | return this.computedLeft_;
|
1237 | };
|
1238 | MDCTabFoundation.prototype.isActive = function() {
|
1239 | return this.isActive_;
|
1240 | };
|
1241 | MDCTabFoundation.prototype.setActive = function(isActive) {
|
1242 | this.isActive_ = isActive;
|
1243 | if (this.isActive_) {
|
1244 | this.adapter_.addClass(constants_1.cssClasses.ACTIVE);
|
1245 | } else {
|
1246 | this.adapter_.removeClass(constants_1.cssClasses.ACTIVE);
|
1247 | }
|
1248 | };
|
1249 | MDCTabFoundation.prototype.preventsDefaultOnClick = function() {
|
1250 | return this.preventDefaultOnClick_;
|
1251 | };
|
1252 | MDCTabFoundation.prototype.setPreventDefaultOnClick = function(preventDefaultOnClick) {
|
1253 | this.preventDefaultOnClick_ = preventDefaultOnClick;
|
1254 | };
|
1255 | MDCTabFoundation.prototype.measureSelf = function() {
|
1256 | this.computedWidth_ = this.adapter_.getOffsetWidth();
|
1257 | this.computedLeft_ = this.adapter_.getOffsetLeft();
|
1258 | };
|
1259 | return MDCTabFoundation;
|
1260 | }(foundation_1.MDCFoundation);
|
1261 | exports.MDCTabFoundation = MDCTabFoundation;
|
1262 | exports.default = MDCTabFoundation;
|
1263 | },
|
1264 | 6: function(module, exports, __webpack_require__) {
|
1265 | "use strict";
|
1266 | var __extends = this && this.__extends || function() {
|
1267 | var _extendStatics = function extendStatics(d, b) {
|
1268 | _extendStatics = Object.setPrototypeOf || {
|
1269 | __proto__: []
|
1270 | } instanceof Array && function(d, b) {
|
1271 | d.__proto__ = b;
|
1272 | } || function(d, b) {
|
1273 | for (var p in b) {
|
1274 | if (b.hasOwnProperty(p)) d[p] = b[p];
|
1275 | }
|
1276 | };
|
1277 | return _extendStatics(d, b);
|
1278 | };
|
1279 | return function(d, b) {
|
1280 | _extendStatics(d, b);
|
1281 | function __() {
|
1282 | this.constructor = d;
|
1283 | }
|
1284 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
1285 | };
|
1286 | }();
|
1287 | var __importStar = this && this.__importStar || function(mod) {
|
1288 | if (mod && mod.__esModule) return mod;
|
1289 | var result = {};
|
1290 | if (mod != null) for (var k in mod) {
|
1291 | if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
1292 | }
|
1293 | result["default"] = mod;
|
1294 | return result;
|
1295 | };
|
1296 | Object.defineProperty(exports, "__esModule", {
|
1297 | value: true
|
1298 | });
|
1299 | var component_1 = __webpack_require__(1);
|
1300 | var ponyfill_1 = __webpack_require__(2);
|
1301 | var foundation_1 = __webpack_require__(4);
|
1302 | var util = __importStar(__webpack_require__(3));
|
1303 | var MDCRipple = function(_super) {
|
1304 | __extends(MDCRipple, _super);
|
1305 | function MDCRipple() {
|
1306 | var _this = _super !== null && _super.apply(this, arguments) || this;
|
1307 | _this.disabled = false;
|
1308 | return _this;
|
1309 | }
|
1310 | MDCRipple.attachTo = function(root, opts) {
|
1311 | if (opts === void 0) {
|
1312 | opts = {
|
1313 | isUnbounded: undefined
|
1314 | };
|
1315 | }
|
1316 | var ripple = new MDCRipple(root);
|
1317 | if (opts.isUnbounded !== undefined) {
|
1318 | ripple.unbounded = opts.isUnbounded;
|
1319 | }
|
1320 | return ripple;
|
1321 | };
|
1322 | MDCRipple.createAdapter = function(instance) {
|
1323 | return {
|
1324 | addClass: function addClass(className) {
|
1325 | return instance.root_.classList.add(className);
|
1326 | },
|
1327 | browserSupportsCssVars: function browserSupportsCssVars() {
|
1328 | return util.supportsCssVariables(window);
|
1329 | },
|
1330 | computeBoundingRect: function computeBoundingRect() {
|
1331 | return instance.root_.getBoundingClientRect();
|
1332 | },
|
1333 | containsEventTarget: function containsEventTarget(target) {
|
1334 | return instance.root_.contains(target);
|
1335 | },
|
1336 | deregisterDocumentInteractionHandler: function deregisterDocumentInteractionHandler(evtType, handler) {
|
1337 | return document.documentElement.removeEventListener(evtType, handler, util.applyPassive());
|
1338 | },
|
1339 | deregisterInteractionHandler: function deregisterInteractionHandler(evtType, handler) {
|
1340 | return instance.root_.removeEventListener(evtType, handler, util.applyPassive());
|
1341 | },
|
1342 | deregisterResizeHandler: function deregisterResizeHandler(handler) {
|
1343 | return window.removeEventListener("resize", handler);
|
1344 | },
|
1345 | getWindowPageOffset: function getWindowPageOffset() {
|
1346 | return {
|
1347 | x: window.pageXOffset,
|
1348 | y: window.pageYOffset
|
1349 | };
|
1350 | },
|
1351 | isSurfaceActive: function isSurfaceActive() {
|
1352 | return ponyfill_1.matches(instance.root_, ":active");
|
1353 | },
|
1354 | isSurfaceDisabled: function isSurfaceDisabled() {
|
1355 | return Boolean(instance.disabled);
|
1356 | },
|
1357 | isUnbounded: function isUnbounded() {
|
1358 | return Boolean(instance.unbounded);
|
1359 | },
|
1360 | registerDocumentInteractionHandler: function registerDocumentInteractionHandler(evtType, handler) {
|
1361 | return document.documentElement.addEventListener(evtType, handler, util.applyPassive());
|
1362 | },
|
1363 | registerInteractionHandler: function registerInteractionHandler(evtType, handler) {
|
1364 | return instance.root_.addEventListener(evtType, handler, util.applyPassive());
|
1365 | },
|
1366 | registerResizeHandler: function registerResizeHandler(handler) {
|
1367 | return window.addEventListener("resize", handler);
|
1368 | },
|
1369 | removeClass: function removeClass(className) {
|
1370 | return instance.root_.classList.remove(className);
|
1371 | },
|
1372 | updateCssVariable: function updateCssVariable(varName, value) {
|
1373 | return instance.root_.style.setProperty(varName, value);
|
1374 | }
|
1375 | };
|
1376 | };
|
1377 | Object.defineProperty(MDCRipple.prototype, "unbounded", {
|
1378 | get: function get() {
|
1379 | return Boolean(this.unbounded_);
|
1380 | },
|
1381 | set: function set(unbounded) {
|
1382 | this.unbounded_ = Boolean(unbounded);
|
1383 | this.setUnbounded_();
|
1384 | },
|
1385 | enumerable: true,
|
1386 | configurable: true
|
1387 | });
|
1388 | MDCRipple.prototype.activate = function() {
|
1389 | this.foundation_.activate();
|
1390 | };
|
1391 | MDCRipple.prototype.deactivate = function() {
|
1392 | this.foundation_.deactivate();
|
1393 | };
|
1394 | MDCRipple.prototype.layout = function() {
|
1395 | this.foundation_.layout();
|
1396 | };
|
1397 | MDCRipple.prototype.getDefaultFoundation = function() {
|
1398 | return new foundation_1.MDCRippleFoundation(MDCRipple.createAdapter(this));
|
1399 | };
|
1400 | MDCRipple.prototype.initialSyncWithDOM = function() {
|
1401 | var root = this.root_;
|
1402 | this.unbounded = "mdcRippleIsUnbounded" in root.dataset;
|
1403 | };
|
1404 | MDCRipple.prototype.setUnbounded_ = function() {
|
1405 | this.foundation_.setUnbounded(Boolean(this.unbounded_));
|
1406 | };
|
1407 | return MDCRipple;
|
1408 | }(component_1.MDCComponent);
|
1409 | exports.MDCRipple = MDCRipple;
|
1410 | },
|
1411 | 93: function(module, exports, __webpack_require__) {
|
1412 | "use strict";
|
1413 | var __extends = this && this.__extends || function() {
|
1414 | var _extendStatics = function extendStatics(d, b) {
|
1415 | _extendStatics = Object.setPrototypeOf || {
|
1416 | __proto__: []
|
1417 | } instanceof Array && function(d, b) {
|
1418 | d.__proto__ = b;
|
1419 | } || function(d, b) {
|
1420 | for (var p in b) {
|
1421 | if (b.hasOwnProperty(p)) d[p] = b[p];
|
1422 | }
|
1423 | };
|
1424 | return _extendStatics(d, b);
|
1425 | };
|
1426 | return function(d, b) {
|
1427 | _extendStatics(d, b);
|
1428 | function __() {
|
1429 | this.constructor = d;
|
1430 | }
|
1431 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
1432 | };
|
1433 | }();
|
1434 | Object.defineProperty(exports, "__esModule", {
|
1435 | value: true
|
1436 | });
|
1437 | var component_1 = __webpack_require__(1);
|
1438 | var component_2 = __webpack_require__(6);
|
1439 | var constants_1 = __webpack_require__(50);
|
1440 | var foundation_1 = __webpack_require__(51);
|
1441 | var MDCTab = function(_super) {
|
1442 | __extends(MDCTab, _super);
|
1443 | function MDCTab() {
|
1444 | var _this = _super !== null && _super.apply(this, arguments) || this;
|
1445 | _this.ripple_ = component_2.MDCRipple.attachTo(_this.root_);
|
1446 | return _this;
|
1447 | }
|
1448 | MDCTab.attachTo = function(root) {
|
1449 | return new MDCTab(root);
|
1450 | };
|
1451 | Object.defineProperty(MDCTab.prototype, "computedWidth", {
|
1452 | get: function get() {
|
1453 | return this.foundation_.getComputedWidth();
|
1454 | },
|
1455 | enumerable: true,
|
1456 | configurable: true
|
1457 | });
|
1458 | Object.defineProperty(MDCTab.prototype, "computedLeft", {
|
1459 | get: function get() {
|
1460 | return this.foundation_.getComputedLeft();
|
1461 | },
|
1462 | enumerable: true,
|
1463 | configurable: true
|
1464 | });
|
1465 | Object.defineProperty(MDCTab.prototype, "isActive", {
|
1466 | get: function get() {
|
1467 | return this.foundation_.isActive();
|
1468 | },
|
1469 | set: function set(isActive) {
|
1470 | this.foundation_.setActive(isActive);
|
1471 | },
|
1472 | enumerable: true,
|
1473 | configurable: true
|
1474 | });
|
1475 | Object.defineProperty(MDCTab.prototype, "preventDefaultOnClick", {
|
1476 | get: function get() {
|
1477 | return this.foundation_.preventsDefaultOnClick();
|
1478 | },
|
1479 | set: function set(preventDefaultOnClick) {
|
1480 | this.foundation_.setPreventDefaultOnClick(preventDefaultOnClick);
|
1481 | },
|
1482 | enumerable: true,
|
1483 | configurable: true
|
1484 | });
|
1485 | MDCTab.prototype.destroy = function() {
|
1486 | this.ripple_.destroy();
|
1487 | _super.prototype.destroy.call(this);
|
1488 | };
|
1489 | MDCTab.prototype.getDefaultFoundation = function() {
|
1490 | var _this = this;
|
1491 | var adapter = {
|
1492 | addClass: function addClass(className) {
|
1493 | return _this.root_.classList.add(className);
|
1494 | },
|
1495 | removeClass: function removeClass(className) {
|
1496 | return _this.root_.classList.remove(className);
|
1497 | },
|
1498 | registerInteractionHandler: function registerInteractionHandler(type, handler) {
|
1499 | return _this.listen(type, handler);
|
1500 | },
|
1501 | deregisterInteractionHandler: function deregisterInteractionHandler(type, handler) {
|
1502 | return _this.unlisten(type, handler);
|
1503 | },
|
1504 | getOffsetWidth: function getOffsetWidth() {
|
1505 | return _this.root_.offsetWidth;
|
1506 | },
|
1507 | getOffsetLeft: function getOffsetLeft() {
|
1508 | return _this.root_.offsetLeft;
|
1509 | },
|
1510 | notifySelected: function notifySelected() {
|
1511 | return _this.emit(foundation_1.MDCTabFoundation.strings.SELECTED_EVENT, {
|
1512 | tab: _this
|
1513 | }, true);
|
1514 | }
|
1515 | };
|
1516 | return new foundation_1.MDCTabFoundation(adapter);
|
1517 | };
|
1518 | MDCTab.prototype.initialSyncWithDOM = function() {
|
1519 | this.isActive = this.root_.classList.contains(constants_1.cssClasses.ACTIVE);
|
1520 | };
|
1521 | MDCTab.prototype.measureSelf = function() {
|
1522 | this.foundation_.measureSelf();
|
1523 | };
|
1524 | return MDCTab;
|
1525 | }(component_1.MDCComponent);
|
1526 | exports.MDCTab = MDCTab;
|
1527 | },
|
1528 | 94: function(module, exports, __webpack_require__) {
|
1529 | "use strict";
|
1530 | var __extends = this && this.__extends || function() {
|
1531 | var _extendStatics = function extendStatics(d, b) {
|
1532 | _extendStatics = Object.setPrototypeOf || {
|
1533 | __proto__: []
|
1534 | } instanceof Array && function(d, b) {
|
1535 | d.__proto__ = b;
|
1536 | } || function(d, b) {
|
1537 | for (var p in b) {
|
1538 | if (b.hasOwnProperty(p)) d[p] = b[p];
|
1539 | }
|
1540 | };
|
1541 | return _extendStatics(d, b);
|
1542 | };
|
1543 | return function(d, b) {
|
1544 | _extendStatics(d, b);
|
1545 | function __() {
|
1546 | this.constructor = d;
|
1547 | }
|
1548 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
1549 | };
|
1550 | }();
|
1551 | Object.defineProperty(exports, "__esModule", {
|
1552 | value: true
|
1553 | });
|
1554 | var component_1 = __webpack_require__(1);
|
1555 | var component_2 = __webpack_require__(93);
|
1556 | var foundation_1 = __webpack_require__(51);
|
1557 | var foundation_2 = __webpack_require__(95);
|
1558 | var strings = foundation_2.MDCTabBarFoundation.strings;
|
1559 | var MDCTabBar = function(_super) {
|
1560 | __extends(MDCTabBar, _super);
|
1561 | function MDCTabBar() {
|
1562 | return _super !== null && _super.apply(this, arguments) || this;
|
1563 | }
|
1564 | MDCTabBar.attachTo = function(root) {
|
1565 | return new MDCTabBar(root);
|
1566 | };
|
1567 | Object.defineProperty(MDCTabBar.prototype, "tabs", {
|
1568 | get: function get() {
|
1569 | return this.tabs_;
|
1570 | },
|
1571 | enumerable: true,
|
1572 | configurable: true
|
1573 | });
|
1574 | Object.defineProperty(MDCTabBar.prototype, "activeTab", {
|
1575 | get: function get() {
|
1576 | var activeIndex = this.foundation_.getActiveTabIndex();
|
1577 | return this.tabs[activeIndex];
|
1578 | },
|
1579 | set: function set(tab) {
|
1580 | this.setActiveTab_(tab, false);
|
1581 | },
|
1582 | enumerable: true,
|
1583 | configurable: true
|
1584 | });
|
1585 | Object.defineProperty(MDCTabBar.prototype, "activeTabIndex", {
|
1586 | get: function get() {
|
1587 | return this.foundation_.getActiveTabIndex();
|
1588 | },
|
1589 | set: function set(index) {
|
1590 | this.setActiveTabIndex_(index, false);
|
1591 | },
|
1592 | enumerable: true,
|
1593 | configurable: true
|
1594 | });
|
1595 | MDCTabBar.prototype.initialize = function(tabFactory) {
|
1596 | var _this = this;
|
1597 | if (tabFactory === void 0) {
|
1598 | tabFactory = function tabFactory(el) {
|
1599 | return new component_2.MDCTab(el);
|
1600 | };
|
1601 | }
|
1602 | this.indicator_ = this.root_.querySelector(strings.INDICATOR_SELECTOR);
|
1603 | this.tabs_ = this.gatherTabs_(tabFactory);
|
1604 | this.tabSelectedHandler_ = function(_a) {
|
1605 | var detail = _a.detail;
|
1606 | var tab = detail.tab;
|
1607 | _this.setActiveTab_(tab, true);
|
1608 | };
|
1609 | };
|
1610 | MDCTabBar.prototype.getDefaultFoundation = function() {
|
1611 | var _this = this;
|
1612 | var adapter = {
|
1613 | addClass: function addClass(className) {
|
1614 | return _this.root_.classList.add(className);
|
1615 | },
|
1616 | removeClass: function removeClass(className) {
|
1617 | return _this.root_.classList.remove(className);
|
1618 | },
|
1619 | bindOnMDCTabSelectedEvent: function bindOnMDCTabSelectedEvent() {
|
1620 | return _this.listen(foundation_1.MDCTabFoundation.strings.SELECTED_EVENT, _this.tabSelectedHandler_);
|
1621 | },
|
1622 | unbindOnMDCTabSelectedEvent: function unbindOnMDCTabSelectedEvent() {
|
1623 | return _this.unlisten(foundation_1.MDCTabFoundation.strings.SELECTED_EVENT, _this.tabSelectedHandler_);
|
1624 | },
|
1625 | registerResizeHandler: function registerResizeHandler(handler) {
|
1626 | return window.addEventListener("resize", handler);
|
1627 | },
|
1628 | deregisterResizeHandler: function deregisterResizeHandler(handler) {
|
1629 | return window.removeEventListener("resize", handler);
|
1630 | },
|
1631 | getOffsetWidth: function getOffsetWidth() {
|
1632 | return _this.root_.offsetWidth;
|
1633 | },
|
1634 | setStyleForIndicator: function setStyleForIndicator(propertyName, value) {
|
1635 | return _this.indicator_.style.setProperty(propertyName, value);
|
1636 | },
|
1637 | getOffsetWidthForIndicator: function getOffsetWidthForIndicator() {
|
1638 | return _this.indicator_.offsetWidth;
|
1639 | },
|
1640 | notifyChange: function notifyChange(evtData) {
|
1641 | return _this.emit(strings.CHANGE_EVENT, evtData);
|
1642 | },
|
1643 | getNumberOfTabs: function getNumberOfTabs() {
|
1644 | return _this.tabs.length;
|
1645 | },
|
1646 | isTabActiveAtIndex: function isTabActiveAtIndex(index) {
|
1647 | return _this.tabs[index].isActive;
|
1648 | },
|
1649 | setTabActiveAtIndex: function setTabActiveAtIndex(index, isActive) {
|
1650 | _this.tabs[index].isActive = isActive;
|
1651 | },
|
1652 | isDefaultPreventedOnClickForTabAtIndex: function isDefaultPreventedOnClickForTabAtIndex(index) {
|
1653 | return _this.tabs[index].preventDefaultOnClick;
|
1654 | },
|
1655 | setPreventDefaultOnClickForTabAtIndex: function setPreventDefaultOnClickForTabAtIndex(index, preventDefaultOnClick) {
|
1656 | _this.tabs[index].preventDefaultOnClick = preventDefaultOnClick;
|
1657 | },
|
1658 | measureTabAtIndex: function measureTabAtIndex(index) {
|
1659 | return _this.tabs[index].measureSelf();
|
1660 | },
|
1661 | getComputedWidthForTabAtIndex: function getComputedWidthForTabAtIndex(index) {
|
1662 | return _this.tabs[index].computedWidth;
|
1663 | },
|
1664 | getComputedLeftForTabAtIndex: function getComputedLeftForTabAtIndex(index) {
|
1665 | return _this.tabs[index].computedLeft;
|
1666 | }
|
1667 | };
|
1668 | return new foundation_2.MDCTabBarFoundation(adapter);
|
1669 | };
|
1670 | MDCTabBar.prototype.layout = function() {
|
1671 | this.foundation_.layout();
|
1672 | };
|
1673 | MDCTabBar.prototype.gatherTabs_ = function(tabFactory) {
|
1674 | var tabElements = [].slice.call(this.root_.querySelectorAll(strings.TAB_SELECTOR));
|
1675 | return tabElements.map(function(el) {
|
1676 | return tabFactory(el);
|
1677 | });
|
1678 | };
|
1679 | MDCTabBar.prototype.setActiveTabIndex_ = function(activeTabIndex, notifyChange) {
|
1680 | this.foundation_.switchToTabAtIndex(activeTabIndex, notifyChange);
|
1681 | };
|
1682 | MDCTabBar.prototype.setActiveTab_ = function(activeTab, notifyChange) {
|
1683 | var indexOfTab = this.tabs.indexOf(activeTab);
|
1684 | if (indexOfTab < 0) {
|
1685 | throw new Error("Invalid tab component given as activeTab: Tab not found within this component's tab list");
|
1686 | }
|
1687 | this.setActiveTabIndex_(indexOfTab, notifyChange);
|
1688 | };
|
1689 | return MDCTabBar;
|
1690 | }(component_1.MDCComponent);
|
1691 | exports.MDCTabBar = MDCTabBar;
|
1692 | },
|
1693 | 95: function(module, exports, __webpack_require__) {
|
1694 | "use strict";
|
1695 | var __extends = this && this.__extends || function() {
|
1696 | var _extendStatics = function extendStatics(d, b) {
|
1697 | _extendStatics = Object.setPrototypeOf || {
|
1698 | __proto__: []
|
1699 | } instanceof Array && function(d, b) {
|
1700 | d.__proto__ = b;
|
1701 | } || function(d, b) {
|
1702 | for (var p in b) {
|
1703 | if (b.hasOwnProperty(p)) d[p] = b[p];
|
1704 | }
|
1705 | };
|
1706 | return _extendStatics(d, b);
|
1707 | };
|
1708 | return function(d, b) {
|
1709 | _extendStatics(d, b);
|
1710 | function __() {
|
1711 | this.constructor = d;
|
1712 | }
|
1713 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
1714 | };
|
1715 | }();
|
1716 | var __assign = this && this.__assign || function() {
|
1717 | __assign = Object.assign || function(t) {
|
1718 | for (var s, i = 1, n = arguments.length; i < n; i++) {
|
1719 | s = arguments[i];
|
1720 | for (var p in s) {
|
1721 | if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
1722 | }
|
1723 | }
|
1724 | return t;
|
1725 | };
|
1726 | return __assign.apply(this, arguments);
|
1727 | };
|
1728 | Object.defineProperty(exports, "__esModule", {
|
1729 | value: true
|
1730 | });
|
1731 | var util_1 = __webpack_require__(11);
|
1732 | var foundation_1 = __webpack_require__(0);
|
1733 | var constants_1 = __webpack_require__(96);
|
1734 | var MDCTabBarFoundation = function(_super) {
|
1735 | __extends(MDCTabBarFoundation, _super);
|
1736 | function MDCTabBarFoundation(adapter) {
|
1737 | var _this = _super.call(this, __assign({}, MDCTabBarFoundation.defaultAdapter, adapter)) || this;
|
1738 | _this.isIndicatorShown_ = false;
|
1739 | _this.activeTabIndex_ = 0;
|
1740 | _this.layoutFrame_ = 0;
|
1741 | return _this;
|
1742 | }
|
1743 | Object.defineProperty(MDCTabBarFoundation, "cssClasses", {
|
1744 | get: function get() {
|
1745 | return constants_1.cssClasses;
|
1746 | },
|
1747 | enumerable: true,
|
1748 | configurable: true
|
1749 | });
|
1750 | Object.defineProperty(MDCTabBarFoundation, "strings", {
|
1751 | get: function get() {
|
1752 | return constants_1.strings;
|
1753 | },
|
1754 | enumerable: true,
|
1755 | configurable: true
|
1756 | });
|
1757 | Object.defineProperty(MDCTabBarFoundation, "defaultAdapter", {
|
1758 | get: function get() {
|
1759 | return {
|
1760 | addClass: function addClass() {
|
1761 | return undefined;
|
1762 | },
|
1763 | removeClass: function removeClass() {
|
1764 | return undefined;
|
1765 | },
|
1766 | bindOnMDCTabSelectedEvent: function bindOnMDCTabSelectedEvent() {
|
1767 | return undefined;
|
1768 | },
|
1769 | unbindOnMDCTabSelectedEvent: function unbindOnMDCTabSelectedEvent() {
|
1770 | return undefined;
|
1771 | },
|
1772 | registerResizeHandler: function registerResizeHandler() {
|
1773 | return undefined;
|
1774 | },
|
1775 | deregisterResizeHandler: function deregisterResizeHandler() {
|
1776 | return undefined;
|
1777 | },
|
1778 | getOffsetWidth: function getOffsetWidth() {
|
1779 | return 0;
|
1780 | },
|
1781 | setStyleForIndicator: function setStyleForIndicator() {
|
1782 | return undefined;
|
1783 | },
|
1784 | getOffsetWidthForIndicator: function getOffsetWidthForIndicator() {
|
1785 | return 0;
|
1786 | },
|
1787 | notifyChange: function notifyChange() {
|
1788 | return undefined;
|
1789 | },
|
1790 | getNumberOfTabs: function getNumberOfTabs() {
|
1791 | return 0;
|
1792 | },
|
1793 | isTabActiveAtIndex: function isTabActiveAtIndex() {
|
1794 | return false;
|
1795 | },
|
1796 | setTabActiveAtIndex: function setTabActiveAtIndex() {
|
1797 | return undefined;
|
1798 | },
|
1799 | isDefaultPreventedOnClickForTabAtIndex: function isDefaultPreventedOnClickForTabAtIndex() {
|
1800 | return false;
|
1801 | },
|
1802 | setPreventDefaultOnClickForTabAtIndex: function setPreventDefaultOnClickForTabAtIndex() {
|
1803 | return undefined;
|
1804 | },
|
1805 | measureTabAtIndex: function measureTabAtIndex() {
|
1806 | return undefined;
|
1807 | },
|
1808 | getComputedWidthForTabAtIndex: function getComputedWidthForTabAtIndex() {
|
1809 | return 0;
|
1810 | },
|
1811 | getComputedLeftForTabAtIndex: function getComputedLeftForTabAtIndex() {
|
1812 | return 0;
|
1813 | }
|
1814 | };
|
1815 | },
|
1816 | enumerable: true,
|
1817 | configurable: true
|
1818 | });
|
1819 | MDCTabBarFoundation.prototype.init = function() {
|
1820 | var _this = this;
|
1821 | this.resizeHandler_ = function() {
|
1822 | return _this.layout();
|
1823 | };
|
1824 | this.adapter_.addClass(constants_1.cssClasses.UPGRADED);
|
1825 | this.adapter_.bindOnMDCTabSelectedEvent();
|
1826 | this.adapter_.registerResizeHandler(this.resizeHandler_);
|
1827 | var activeTabIndex = this.findActiveTabIndex_();
|
1828 | if (activeTabIndex >= 0) {
|
1829 | this.activeTabIndex_ = activeTabIndex;
|
1830 | }
|
1831 | this.layout();
|
1832 | };
|
1833 | MDCTabBarFoundation.prototype.destroy = function() {
|
1834 | this.adapter_.removeClass(constants_1.cssClasses.UPGRADED);
|
1835 | this.adapter_.unbindOnMDCTabSelectedEvent();
|
1836 | this.adapter_.deregisterResizeHandler(this.resizeHandler_);
|
1837 | };
|
1838 | MDCTabBarFoundation.prototype.layout = function() {
|
1839 | var _this = this;
|
1840 | if (this.layoutFrame_) {
|
1841 | cancelAnimationFrame(this.layoutFrame_);
|
1842 | }
|
1843 | this.layoutFrame_ = requestAnimationFrame(function() {
|
1844 | _this.layoutInternal_();
|
1845 | _this.layoutFrame_ = 0;
|
1846 | });
|
1847 | };
|
1848 | MDCTabBarFoundation.prototype.switchToTabAtIndex = function(index, shouldNotify) {
|
1849 | var _this = this;
|
1850 | if (index === this.activeTabIndex_) {
|
1851 | return;
|
1852 | }
|
1853 | if (index < 0 || index >= this.adapter_.getNumberOfTabs()) {
|
1854 | throw new Error("Out of bounds index specified for tab: " + index);
|
1855 | }
|
1856 | var prevActiveTabIndex = this.activeTabIndex_;
|
1857 | this.activeTabIndex_ = index;
|
1858 | requestAnimationFrame(function() {
|
1859 | if (prevActiveTabIndex >= 0) {
|
1860 | _this.adapter_.setTabActiveAtIndex(prevActiveTabIndex, false);
|
1861 | }
|
1862 | _this.adapter_.setTabActiveAtIndex(_this.activeTabIndex_, true);
|
1863 | _this.layoutIndicator_();
|
1864 | if (shouldNotify) {
|
1865 | _this.adapter_.notifyChange({
|
1866 | activeTabIndex: _this.activeTabIndex_
|
1867 | });
|
1868 | }
|
1869 | });
|
1870 | };
|
1871 | MDCTabBarFoundation.prototype.getActiveTabIndex = function() {
|
1872 | return this.findActiveTabIndex_();
|
1873 | };
|
1874 | MDCTabBarFoundation.prototype.layoutInternal_ = function() {
|
1875 | var _this = this;
|
1876 | this.forEachTabIndex_(function(index) {
|
1877 | return _this.adapter_.measureTabAtIndex(index);
|
1878 | });
|
1879 | this.layoutIndicator_();
|
1880 | };
|
1881 | MDCTabBarFoundation.prototype.layoutIndicator_ = function() {
|
1882 | var isIndicatorFirstRender = !this.isIndicatorShown_;
|
1883 | if (isIndicatorFirstRender) {
|
1884 | this.adapter_.setStyleForIndicator("transition", "none");
|
1885 | }
|
1886 | var translateAmtForActiveTabLeft = this.adapter_.getComputedLeftForTabAtIndex(this.activeTabIndex_);
|
1887 | var scaleAmtForActiveTabWidth = this.adapter_.getComputedWidthForTabAtIndex(this.activeTabIndex_) / this.adapter_.getOffsetWidth();
|
1888 | var transformValue = "translateX(" + translateAmtForActiveTabLeft + "px) scale(" + scaleAmtForActiveTabWidth + ", 1)";
|
1889 | this.adapter_.setStyleForIndicator(util_1.getCorrectPropertyName(window, "transform"), transformValue);
|
1890 | if (isIndicatorFirstRender) {
|
1891 | this.adapter_.getOffsetWidthForIndicator();
|
1892 | this.adapter_.setStyleForIndicator("transition", "");
|
1893 | this.adapter_.setStyleForIndicator("visibility", "visible");
|
1894 | this.isIndicatorShown_ = true;
|
1895 | }
|
1896 | };
|
1897 | MDCTabBarFoundation.prototype.findActiveTabIndex_ = function() {
|
1898 | var _this = this;
|
1899 | var activeTabIndex = -1;
|
1900 | this.forEachTabIndex_(function(index) {
|
1901 | if (_this.adapter_.isTabActiveAtIndex(index)) {
|
1902 | activeTabIndex = index;
|
1903 | return true;
|
1904 | }
|
1905 | });
|
1906 | return activeTabIndex;
|
1907 | };
|
1908 | MDCTabBarFoundation.prototype.forEachTabIndex_ = function(iterator) {
|
1909 | var numTabs = this.adapter_.getNumberOfTabs();
|
1910 | for (var index = 0; index < numTabs; index++) {
|
1911 | var shouldBreak = iterator(index);
|
1912 | if (shouldBreak) {
|
1913 | break;
|
1914 | }
|
1915 | }
|
1916 | };
|
1917 | return MDCTabBarFoundation;
|
1918 | }(foundation_1.MDCFoundation);
|
1919 | exports.MDCTabBarFoundation = MDCTabBarFoundation;
|
1920 | exports.default = MDCTabBarFoundation;
|
1921 | },
|
1922 | 96: function(module, exports, __webpack_require__) {
|
1923 | "use strict";
|
1924 | Object.defineProperty(exports, "__esModule", {
|
1925 | value: true
|
1926 | });
|
1927 | exports.cssClasses = {
|
1928 | UPGRADED: "mdc-tab-bar-upgraded"
|
1929 | };
|
1930 | exports.strings = {
|
1931 | CHANGE_EVENT: "MDCTabBar:change",
|
1932 | INDICATOR_SELECTOR: ".mdc-tab-bar__indicator",
|
1933 | TAB_SELECTOR: ".mdc-tab"
|
1934 | };
|
1935 | },
|
1936 | 97: function(module, exports, __webpack_require__) {
|
1937 | "use strict";
|
1938 | var __extends = this && this.__extends || function() {
|
1939 | var _extendStatics = function extendStatics(d, b) {
|
1940 | _extendStatics = Object.setPrototypeOf || {
|
1941 | __proto__: []
|
1942 | } instanceof Array && function(d, b) {
|
1943 | d.__proto__ = b;
|
1944 | } || function(d, b) {
|
1945 | for (var p in b) {
|
1946 | if (b.hasOwnProperty(p)) d[p] = b[p];
|
1947 | }
|
1948 | };
|
1949 | return _extendStatics(d, b);
|
1950 | };
|
1951 | return function(d, b) {
|
1952 | _extendStatics(d, b);
|
1953 | function __() {
|
1954 | this.constructor = d;
|
1955 | }
|
1956 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
1957 | };
|
1958 | }();
|
1959 | var __assign = this && this.__assign || function() {
|
1960 | __assign = Object.assign || function(t) {
|
1961 | for (var s, i = 1, n = arguments.length; i < n; i++) {
|
1962 | s = arguments[i];
|
1963 | for (var p in s) {
|
1964 | if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
1965 | }
|
1966 | }
|
1967 | return t;
|
1968 | };
|
1969 | return __assign.apply(this, arguments);
|
1970 | };
|
1971 | Object.defineProperty(exports, "__esModule", {
|
1972 | value: true
|
1973 | });
|
1974 | var foundation_1 = __webpack_require__(0);
|
1975 | var constants_1 = __webpack_require__(98);
|
1976 | var INTERACTION_EVENTS = [ "touchstart", "mousedown", "focus" ];
|
1977 | var MDCTabBarScrollerFoundation = function(_super) {
|
1978 | __extends(MDCTabBarScrollerFoundation, _super);
|
1979 | function MDCTabBarScrollerFoundation(adapter) {
|
1980 | var _this = _super.call(this, __assign({}, MDCTabBarScrollerFoundation.defaultAdapter, adapter)) || this;
|
1981 | _this.pointerDownRecognized_ = false;
|
1982 | _this.currentTranslateOffset_ = 0;
|
1983 | _this.focusedTarget_ = null;
|
1984 | _this.layoutFrame_ = 0;
|
1985 | _this.scrollFrameScrollLeft_ = 0;
|
1986 | _this.forwardIndicatorClickHandler_ = function(evt) {
|
1987 | return _this.scrollForward(evt);
|
1988 | };
|
1989 | _this.backIndicatorClickHandler_ = function(evt) {
|
1990 | return _this.scrollBack(evt);
|
1991 | };
|
1992 | _this.resizeHandler_ = function() {
|
1993 | return _this.layout();
|
1994 | };
|
1995 | _this.interactionHandler_ = function(evt) {
|
1996 | if (evt.type === "touchstart" || evt.type === "mousedown") {
|
1997 | _this.pointerDownRecognized_ = true;
|
1998 | }
|
1999 | _this.handlePossibleTabKeyboardFocus_(evt);
|
2000 | if (evt.type === "focus") {
|
2001 | _this.pointerDownRecognized_ = false;
|
2002 | }
|
2003 | };
|
2004 | return _this;
|
2005 | }
|
2006 | Object.defineProperty(MDCTabBarScrollerFoundation, "cssClasses", {
|
2007 | get: function get() {
|
2008 | return constants_1.cssClasses;
|
2009 | },
|
2010 | enumerable: true,
|
2011 | configurable: true
|
2012 | });
|
2013 | Object.defineProperty(MDCTabBarScrollerFoundation, "strings", {
|
2014 | get: function get() {
|
2015 | return constants_1.strings;
|
2016 | },
|
2017 | enumerable: true,
|
2018 | configurable: true
|
2019 | });
|
2020 | Object.defineProperty(MDCTabBarScrollerFoundation, "defaultAdapter", {
|
2021 | get: function get() {
|
2022 | return {
|
2023 | addClass: function addClass() {
|
2024 | return undefined;
|
2025 | },
|
2026 | removeClass: function removeClass() {
|
2027 | return undefined;
|
2028 | },
|
2029 | eventTargetHasClass: function eventTargetHasClass() {
|
2030 | return false;
|
2031 | },
|
2032 | addClassToForwardIndicator: function addClassToForwardIndicator() {
|
2033 | return undefined;
|
2034 | },
|
2035 | removeClassFromForwardIndicator: function removeClassFromForwardIndicator() {
|
2036 | return undefined;
|
2037 | },
|
2038 | addClassToBackIndicator: function addClassToBackIndicator() {
|
2039 | return undefined;
|
2040 | },
|
2041 | removeClassFromBackIndicator: function removeClassFromBackIndicator() {
|
2042 | return undefined;
|
2043 | },
|
2044 | isRTL: function isRTL() {
|
2045 | return false;
|
2046 | },
|
2047 | registerBackIndicatorClickHandler: function registerBackIndicatorClickHandler() {
|
2048 | return undefined;
|
2049 | },
|
2050 | deregisterBackIndicatorClickHandler: function deregisterBackIndicatorClickHandler() {
|
2051 | return undefined;
|
2052 | },
|
2053 | registerForwardIndicatorClickHandler: function registerForwardIndicatorClickHandler() {
|
2054 | return undefined;
|
2055 | },
|
2056 | deregisterForwardIndicatorClickHandler: function deregisterForwardIndicatorClickHandler() {
|
2057 | return undefined;
|
2058 | },
|
2059 | registerCapturedInteractionHandler: function registerCapturedInteractionHandler() {
|
2060 | return undefined;
|
2061 | },
|
2062 | deregisterCapturedInteractionHandler: function deregisterCapturedInteractionHandler() {
|
2063 | return undefined;
|
2064 | },
|
2065 | registerWindowResizeHandler: function registerWindowResizeHandler() {
|
2066 | return undefined;
|
2067 | },
|
2068 | deregisterWindowResizeHandler: function deregisterWindowResizeHandler() {
|
2069 | return undefined;
|
2070 | },
|
2071 | getNumberOfTabs: function getNumberOfTabs() {
|
2072 | return 0;
|
2073 | },
|
2074 | getComputedWidthForTabAtIndex: function getComputedWidthForTabAtIndex() {
|
2075 | return 0;
|
2076 | },
|
2077 | getComputedLeftForTabAtIndex: function getComputedLeftForTabAtIndex() {
|
2078 | return 0;
|
2079 | },
|
2080 | getOffsetWidthForScrollFrame: function getOffsetWidthForScrollFrame() {
|
2081 | return 0;
|
2082 | },
|
2083 | getScrollLeftForScrollFrame: function getScrollLeftForScrollFrame() {
|
2084 | return 0;
|
2085 | },
|
2086 | setScrollLeftForScrollFrame: function setScrollLeftForScrollFrame() {
|
2087 | return undefined;
|
2088 | },
|
2089 | getOffsetWidthForTabBar: function getOffsetWidthForTabBar() {
|
2090 | return 0;
|
2091 | },
|
2092 | setTransformStyleForTabBar: function setTransformStyleForTabBar() {
|
2093 | return undefined;
|
2094 | },
|
2095 | getOffsetLeftForEventTarget: function getOffsetLeftForEventTarget() {
|
2096 | return 0;
|
2097 | },
|
2098 | getOffsetWidthForEventTarget: function getOffsetWidthForEventTarget() {
|
2099 | return 0;
|
2100 | }
|
2101 | };
|
2102 | },
|
2103 | enumerable: true,
|
2104 | configurable: true
|
2105 | });
|
2106 | MDCTabBarScrollerFoundation.prototype.init = function() {
|
2107 | var _this = this;
|
2108 | this.adapter_.registerBackIndicatorClickHandler(this.backIndicatorClickHandler_);
|
2109 | this.adapter_.registerForwardIndicatorClickHandler(this.forwardIndicatorClickHandler_);
|
2110 | this.adapter_.registerWindowResizeHandler(this.resizeHandler_);
|
2111 | INTERACTION_EVENTS.forEach(function(evtType) {
|
2112 | _this.adapter_.registerCapturedInteractionHandler(evtType, _this.interactionHandler_);
|
2113 | });
|
2114 | this.layout();
|
2115 | };
|
2116 | MDCTabBarScrollerFoundation.prototype.destroy = function() {
|
2117 | var _this = this;
|
2118 | this.adapter_.deregisterBackIndicatorClickHandler(this.backIndicatorClickHandler_);
|
2119 | this.adapter_.deregisterForwardIndicatorClickHandler(this.forwardIndicatorClickHandler_);
|
2120 | this.adapter_.deregisterWindowResizeHandler(this.resizeHandler_);
|
2121 | INTERACTION_EVENTS.forEach(function(evtType) {
|
2122 | _this.adapter_.deregisterCapturedInteractionHandler(evtType, _this.interactionHandler_);
|
2123 | });
|
2124 | };
|
2125 | MDCTabBarScrollerFoundation.prototype.scrollBack = function(evt) {
|
2126 | if (evt) {
|
2127 | evt.preventDefault();
|
2128 | }
|
2129 | var tabWidthAccumulator = 0;
|
2130 | var scrollTargetIndex = 0;
|
2131 | for (var i = this.adapter_.getNumberOfTabs() - 1; i > 0; i--) {
|
2132 | var tabOffsetLeft = this.adapter_.getComputedLeftForTabAtIndex(i);
|
2133 | var tabBarWidthLessTabOffsetLeft = this.adapter_.getOffsetWidthForTabBar() - tabOffsetLeft;
|
2134 | var tabIsNotOccluded = tabOffsetLeft > this.currentTranslateOffset_;
|
2135 | if (this.isRTL_()) {
|
2136 | tabIsNotOccluded = tabBarWidthLessTabOffsetLeft > this.currentTranslateOffset_;
|
2137 | }
|
2138 | if (tabIsNotOccluded) {
|
2139 | continue;
|
2140 | }
|
2141 | tabWidthAccumulator += this.adapter_.getComputedWidthForTabAtIndex(i);
|
2142 | var scrollTargetDetermined = tabWidthAccumulator > this.adapter_.getOffsetWidthForScrollFrame();
|
2143 | if (scrollTargetDetermined) {
|
2144 | scrollTargetIndex = this.isRTL_() ? i + 1 : i;
|
2145 | break;
|
2146 | }
|
2147 | }
|
2148 | this.scrollToTabAtIndex(scrollTargetIndex);
|
2149 | };
|
2150 | MDCTabBarScrollerFoundation.prototype.scrollForward = function(evt) {
|
2151 | if (evt) {
|
2152 | evt.preventDefault();
|
2153 | }
|
2154 | var scrollFrameOffsetWidth = this.adapter_.getOffsetWidthForScrollFrame() + this.currentTranslateOffset_;
|
2155 | var scrollTargetIndex = 0;
|
2156 | for (var i = 0; i < this.adapter_.getNumberOfTabs(); i++) {
|
2157 | var tabOffsetLeftAndWidth = this.adapter_.getComputedLeftForTabAtIndex(i) + this.adapter_.getComputedWidthForTabAtIndex(i);
|
2158 | var scrollTargetDetermined = tabOffsetLeftAndWidth > scrollFrameOffsetWidth;
|
2159 | if (this.isRTL_()) {
|
2160 | var frameOffsetAndTabWidth = scrollFrameOffsetWidth - this.adapter_.getComputedWidthForTabAtIndex(i);
|
2161 | var tabRightOffset = this.adapter_.getOffsetWidthForTabBar() - tabOffsetLeftAndWidth;
|
2162 | scrollTargetDetermined = tabRightOffset > frameOffsetAndTabWidth;
|
2163 | }
|
2164 | if (scrollTargetDetermined) {
|
2165 | scrollTargetIndex = i;
|
2166 | break;
|
2167 | }
|
2168 | }
|
2169 | this.scrollToTabAtIndex(scrollTargetIndex);
|
2170 | };
|
2171 | MDCTabBarScrollerFoundation.prototype.layout = function() {
|
2172 | var _this = this;
|
2173 | cancelAnimationFrame(this.layoutFrame_);
|
2174 | this.scrollFrameScrollLeft_ = this.adapter_.getScrollLeftForScrollFrame();
|
2175 | this.layoutFrame_ = requestAnimationFrame(function() {
|
2176 | return _this.layout_();
|
2177 | });
|
2178 | };
|
2179 | MDCTabBarScrollerFoundation.prototype.scrollToTabAtIndex = function(index) {
|
2180 | var _this = this;
|
2181 | var scrollTargetOffsetLeft = this.adapter_.getComputedLeftForTabAtIndex(index);
|
2182 | var scrollTargetOffsetWidth = this.adapter_.getComputedWidthForTabAtIndex(index);
|
2183 | this.currentTranslateOffset_ = this.normalizeForRTL_(scrollTargetOffsetLeft, scrollTargetOffsetWidth);
|
2184 | requestAnimationFrame(function() {
|
2185 | return _this.shiftFrame_();
|
2186 | });
|
2187 | };
|
2188 | MDCTabBarScrollerFoundation.prototype.layout_ = function() {
|
2189 | var frameWidth = this.adapter_.getOffsetWidthForScrollFrame();
|
2190 | var isOverflowing = this.adapter_.getOffsetWidthForTabBar() > frameWidth;
|
2191 | if (!isOverflowing) {
|
2192 | this.currentTranslateOffset_ = 0;
|
2193 | }
|
2194 | this.shiftFrame_();
|
2195 | this.updateIndicatorEnabledStates_();
|
2196 | };
|
2197 | MDCTabBarScrollerFoundation.prototype.shiftFrame_ = function() {
|
2198 | var shiftAmount = this.isRTL_() ? this.currentTranslateOffset_ : -this.currentTranslateOffset_;
|
2199 | this.adapter_.setTransformStyleForTabBar("translateX(" + shiftAmount + "px)");
|
2200 | this.updateIndicatorEnabledStates_();
|
2201 | };
|
2202 | MDCTabBarScrollerFoundation.prototype.handlePossibleTabKeyboardFocus_ = function(evt) {
|
2203 | var target = evt.target;
|
2204 | if (!this.adapter_.eventTargetHasClass(target, constants_1.cssClasses.TAB) || this.pointerDownRecognized_) {
|
2205 | return;
|
2206 | }
|
2207 | var resetAmt = this.isRTL_() ? this.scrollFrameScrollLeft_ : 0;
|
2208 | this.adapter_.setScrollLeftForScrollFrame(resetAmt);
|
2209 | this.focusedTarget_ = target;
|
2210 | var scrollFrameWidth = this.adapter_.getOffsetWidthForScrollFrame();
|
2211 | var tabBarWidth = this.adapter_.getOffsetWidthForTabBar();
|
2212 | var leftEdge = this.adapter_.getOffsetLeftForEventTarget(this.focusedTarget_);
|
2213 | var rightEdge = leftEdge + this.adapter_.getOffsetWidthForEventTarget(this.focusedTarget_);
|
2214 | var shouldScrollBack = rightEdge <= this.currentTranslateOffset_;
|
2215 | var shouldScrollForward = rightEdge > this.currentTranslateOffset_ + scrollFrameWidth;
|
2216 | if (this.isRTL_()) {
|
2217 | var normalizedLeftOffset = tabBarWidth - leftEdge;
|
2218 | shouldScrollBack = leftEdge >= tabBarWidth - this.currentTranslateOffset_;
|
2219 | shouldScrollForward = normalizedLeftOffset > scrollFrameWidth + this.currentTranslateOffset_;
|
2220 | }
|
2221 | if (shouldScrollForward) {
|
2222 | this.scrollForward();
|
2223 | } else if (shouldScrollBack) {
|
2224 | this.scrollBack();
|
2225 | }
|
2226 | this.pointerDownRecognized_ = false;
|
2227 | };
|
2228 | MDCTabBarScrollerFoundation.prototype.updateIndicatorEnabledStates_ = function() {
|
2229 | var INDICATOR_ENABLED = constants_1.cssClasses.INDICATOR_ENABLED;
|
2230 | if (this.currentTranslateOffset_ === 0) {
|
2231 | this.adapter_.removeClassFromBackIndicator(INDICATOR_ENABLED);
|
2232 | } else {
|
2233 | this.adapter_.addClassToBackIndicator(INDICATOR_ENABLED);
|
2234 | }
|
2235 | var remainingTabBarWidth = this.adapter_.getOffsetWidthForTabBar() - this.currentTranslateOffset_;
|
2236 | if (remainingTabBarWidth > this.adapter_.getOffsetWidthForScrollFrame()) {
|
2237 | this.adapter_.addClassToForwardIndicator(INDICATOR_ENABLED);
|
2238 | } else {
|
2239 | this.adapter_.removeClassFromForwardIndicator(INDICATOR_ENABLED);
|
2240 | }
|
2241 | };
|
2242 | MDCTabBarScrollerFoundation.prototype.normalizeForRTL_ = function(left, width) {
|
2243 | return this.isRTL_() ? this.adapter_.getOffsetWidthForTabBar() - (left + width) : left;
|
2244 | };
|
2245 | MDCTabBarScrollerFoundation.prototype.isRTL_ = function() {
|
2246 | return this.adapter_.isRTL();
|
2247 | };
|
2248 | return MDCTabBarScrollerFoundation;
|
2249 | }(foundation_1.MDCFoundation);
|
2250 | exports.MDCTabBarScrollerFoundation = MDCTabBarScrollerFoundation;
|
2251 | exports.default = MDCTabBarScrollerFoundation;
|
2252 | },
|
2253 | 98: function(module, exports, __webpack_require__) {
|
2254 | "use strict";
|
2255 | Object.defineProperty(exports, "__esModule", {
|
2256 | value: true
|
2257 | });
|
2258 | exports.cssClasses = {
|
2259 | INDICATOR_BACK: "mdc-tab-bar-scroller__indicator--back",
|
2260 | INDICATOR_ENABLED: "mdc-tab-bar-scroller__indicator--enabled",
|
2261 | INDICATOR_FORWARD: "mdc-tab-bar-scroller__indicator--forward",
|
2262 | TAB: "mdc-tab"
|
2263 | };
|
2264 | exports.strings = {
|
2265 | FRAME_SELECTOR: ".mdc-tab-bar-scroller__scroll-frame",
|
2266 | INDICATOR_BACK_SELECTOR: ".mdc-tab-bar-scroller__indicator--back",
|
2267 | INDICATOR_FORWARD_SELECTOR: ".mdc-tab-bar-scroller__indicator--forward",
|
2268 | TABS_SELECTOR: ".mdc-tab-bar-scroller__scroll-frame__tabs",
|
2269 | TAB_SELECTOR: ".mdc-tab"
|
2270 | };
|
2271 | }
|
2272 | });
|
2273 | });
|
2274 |
|
\ | No newline at end of file |