UNPKG

5.07 kBJavaScriptView Raw
1/**
2 * @license
3 * Copyright 2017 Google Inc.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to deal
7 * in the Software without restriction, including without limitation the rights
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 * copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 * THE SOFTWARE.
22 */
23import { __extends } from "tslib";
24import { MDCComponent } from '@material/base/component';
25import { MDCLinearProgressFoundation } from './foundation';
26var MDCLinearProgress = /** @class */ (function (_super) {
27 __extends(MDCLinearProgress, _super);
28 function MDCLinearProgress() {
29 return _super !== null && _super.apply(this, arguments) || this;
30 }
31 MDCLinearProgress.attachTo = function (root) {
32 return new MDCLinearProgress(root);
33 };
34 Object.defineProperty(MDCLinearProgress.prototype, "determinate", {
35 set: function (value) {
36 this.foundation.setDeterminate(value);
37 },
38 enumerable: false,
39 configurable: true
40 });
41 Object.defineProperty(MDCLinearProgress.prototype, "progress", {
42 set: function (value) {
43 this.foundation.setProgress(value);
44 },
45 enumerable: false,
46 configurable: true
47 });
48 Object.defineProperty(MDCLinearProgress.prototype, "buffer", {
49 set: function (value) {
50 this.foundation.setBuffer(value);
51 },
52 enumerable: false,
53 configurable: true
54 });
55 MDCLinearProgress.prototype.open = function () {
56 this.foundation.open();
57 };
58 MDCLinearProgress.prototype.close = function () {
59 this.foundation.close();
60 };
61 MDCLinearProgress.prototype.initialSyncWithDOM = function () {
62 var _this = this;
63 this.root.addEventListener('transitionend', function () {
64 _this.foundation.handleTransitionEnd();
65 });
66 };
67 MDCLinearProgress.prototype.getDefaultFoundation = function () {
68 var _this = this;
69 // DO NOT INLINE this variable. For backward compatibility, foundations take
70 // a Partial<MDCFooAdapter>. To ensure we don't accidentally omit any
71 // methods, we need a separate, strongly typed adapter variable.
72 var adapter = {
73 addClass: function (className) {
74 _this.root.classList.add(className);
75 },
76 forceLayout: function () {
77 _this.root.getBoundingClientRect();
78 },
79 setBufferBarStyle: function (styleProperty, value) {
80 var bufferBar = _this.root.querySelector(MDCLinearProgressFoundation.strings.BUFFER_BAR_SELECTOR);
81 if (bufferBar) {
82 bufferBar.style.setProperty(styleProperty, value);
83 }
84 },
85 setPrimaryBarStyle: function (styleProperty, value) {
86 var primaryBar = _this.root.querySelector(MDCLinearProgressFoundation.strings.PRIMARY_BAR_SELECTOR);
87 if (primaryBar) {
88 primaryBar.style.setProperty(styleProperty, value);
89 }
90 },
91 hasClass: function (className) { return _this.root.classList.contains(className); },
92 removeAttribute: function (attributeName) {
93 _this.root.removeAttribute(attributeName);
94 },
95 removeClass: function (className) {
96 _this.root.classList.remove(className);
97 },
98 setAttribute: function (attributeName, value) {
99 _this.root.setAttribute(attributeName, value);
100 },
101 setStyle: function (name, value) {
102 _this.root.style.setProperty(name, value);
103 },
104 attachResizeObserver: function (callback) {
105 var RO = window.ResizeObserver;
106 if (RO) {
107 var ro = new RO(callback);
108 ro.observe(_this.root);
109 return ro;
110 }
111 return null;
112 },
113 getWidth: function () { return _this.root.offsetWidth; },
114 };
115 return new MDCLinearProgressFoundation(adapter);
116 };
117 return MDCLinearProgress;
118}(MDCComponent));
119export { MDCLinearProgress };
120//# sourceMappingURL=component.js.map
\No newline at end of file