1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 | import * as tslib_1 from "tslib";
|
24 | import { MDCComponent } from '@material/base/component';
|
25 | import { MDCRipple } from '@material/ripple/component';
|
26 | import { MDCToolbarFoundation } from './foundation';
|
27 | var strings = MDCToolbarFoundation.strings;
|
28 | var MDCToolbar = (function (_super) {
|
29 | tslib_1.__extends(MDCToolbar, _super);
|
30 | function MDCToolbar() {
|
31 | return _super !== null && _super.apply(this, arguments) || this;
|
32 | }
|
33 | MDCToolbar.attachTo = function (root) {
|
34 | return new MDCToolbar(root);
|
35 | };
|
36 | MDCToolbar.prototype.initialize = function () {
|
37 | var _this = this;
|
38 | this.ripples_ = [];
|
39 | this.fixedAdjustElement_ = null;
|
40 | this.titleElement_ = this.root_.querySelector(strings.TITLE_SELECTOR);
|
41 | var firstRowElement = this.root_.querySelector(strings.FIRST_ROW_SELECTOR);
|
42 | if (!firstRowElement) {
|
43 | throw new Error("MDCToolbar: Required sub-element '" + strings.FIRST_ROW_SELECTOR + "' is missing");
|
44 | }
|
45 | this.firstRowElement_ = firstRowElement;
|
46 | [].forEach.call(this.root_.querySelectorAll(strings.ICON_SELECTOR), function (icon) {
|
47 | var ripple = MDCRipple.attachTo(icon);
|
48 | ripple.unbounded = true;
|
49 | _this.ripples_.push(ripple);
|
50 | });
|
51 | };
|
52 | MDCToolbar.prototype.destroy = function () {
|
53 | this.ripples_.forEach(function (ripple) {
|
54 | ripple.destroy();
|
55 | });
|
56 | _super.prototype.destroy.call(this);
|
57 | };
|
58 | Object.defineProperty(MDCToolbar.prototype, "fixedAdjustElement", {
|
59 | get: function () {
|
60 | return this.fixedAdjustElement_;
|
61 | },
|
62 | set: function (element) {
|
63 | this.fixedAdjustElement_ = element;
|
64 | this.foundation_.updateAdjustElementStyles();
|
65 | },
|
66 | enumerable: true,
|
67 | configurable: true
|
68 | });
|
69 | MDCToolbar.prototype.getDefaultFoundation = function () {
|
70 | var _this = this;
|
71 |
|
72 |
|
73 |
|
74 | var adapter = {
|
75 | hasClass: function (className) { return _this.root_.classList.contains(className); },
|
76 | addClass: function (className) { return _this.root_.classList.add(className); },
|
77 | removeClass: function (className) { return _this.root_.classList.remove(className); },
|
78 | registerScrollHandler: function (handler) { return window.addEventListener('scroll', handler); },
|
79 | deregisterScrollHandler: function (handler) { return window.removeEventListener('scroll', handler); },
|
80 | registerResizeHandler: function (handler) { return window.addEventListener('resize', handler); },
|
81 | deregisterResizeHandler: function (handler) { return window.removeEventListener('resize', handler); },
|
82 | getViewportWidth: function () { return window.innerWidth; },
|
83 | getViewportScrollY: function () { return window.pageYOffset; },
|
84 | getOffsetHeight: function () { return _this.root_.offsetHeight; },
|
85 | getFirstRowElementOffsetHeight: function () { return _this.firstRowElement_.offsetHeight; },
|
86 | notifyChange: function (evtData) { return _this.emit(strings.CHANGE_EVENT, evtData); },
|
87 | setStyle: function (property, value) { return _this.root_.style.setProperty(property, value); },
|
88 | setStyleForTitleElement: function (property, value) {
|
89 | if (_this.titleElement_) {
|
90 | _this.titleElement_.style.setProperty(property, value);
|
91 | }
|
92 | },
|
93 | setStyleForFlexibleRowElement: function (property, value) { return _this.firstRowElement_.style.setProperty(property, value); },
|
94 | setStyleForFixedAdjustElement: function (property, value) {
|
95 | if (_this.fixedAdjustElement) {
|
96 | _this.fixedAdjustElement.style.setProperty(property, value);
|
97 | }
|
98 | },
|
99 | };
|
100 |
|
101 | return new MDCToolbarFoundation(adapter);
|
102 | };
|
103 | return MDCToolbar;
|
104 | }(MDCComponent));
|
105 | export { MDCToolbar };
|
106 |
|
\ | No newline at end of file |