1 | var __extends = (this && this.__extends) || (function () {
|
2 | var extendStatics = Object.setPrototypeOf ||
|
3 | ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
4 | function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
5 | return function (d, b) {
|
6 | extendStatics(d, b);
|
7 | function __() { this.constructor = d; }
|
8 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
9 | };
|
10 | })();
|
11 | import { ContentChildren, Directive, ElementRef, EventEmitter, Input, NgZone, Output, Renderer, forwardRef } from '@angular/core';
|
12 | import { Ion } from '../ion';
|
13 | import { isTrueProperty } from '../../util/util';
|
14 | import { Config } from '../../config/config';
|
15 | import { Platform } from '../../platform/platform';
|
16 | var QUERY = {
|
17 | xs: '(min-width: 0px)',
|
18 | sm: '(min-width: 576px)',
|
19 | md: '(min-width: 768px)',
|
20 | lg: '(min-width: 992px)',
|
21 | xl: '(min-width: 1200px)',
|
22 | never: ''
|
23 | };
|
24 |
|
25 |
|
26 |
|
27 | var RootNode = (function () {
|
28 | function RootNode() {
|
29 | }
|
30 | return RootNode;
|
31 | }());
|
32 | export { RootNode };
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 |
|
44 |
|
45 |
|
46 |
|
47 |
|
48 |
|
49 |
|
50 |
|
51 |
|
52 |
|
53 |
|
54 |
|
55 |
|
56 |
|
57 |
|
58 |
|
59 |
|
60 |
|
61 |
|
62 |
|
63 |
|
64 |
|
65 |
|
66 |
|
67 |
|
68 |
|
69 |
|
70 |
|
71 |
|
72 |
|
73 |
|
74 |
|
75 |
|
76 |
|
77 |
|
78 |
|
79 |
|
80 |
|
81 |
|
82 |
|
83 |
|
84 |
|
85 |
|
86 |
|
87 |
|
88 |
|
89 |
|
90 |
|
91 |
|
92 |
|
93 |
|
94 |
|
95 |
|
96 |
|
97 |
|
98 |
|
99 |
|
100 |
|
101 |
|
102 |
|
103 |
|
104 |
|
105 |
|
106 |
|
107 |
|
108 |
|
109 |
|
110 |
|
111 |
|
112 |
|
113 |
|
114 |
|
115 |
|
116 |
|
117 |
|
118 |
|
119 |
|
120 |
|
121 |
|
122 |
|
123 |
|
124 |
|
125 |
|
126 |
|
127 |
|
128 |
|
129 |
|
130 |
|
131 |
|
132 |
|
133 |
|
134 |
|
135 |
|
136 |
|
137 |
|
138 |
|
139 |
|
140 |
|
141 |
|
142 |
|
143 |
|
144 |
|
145 |
|
146 |
|
147 | var SplitPane = (function (_super) {
|
148 | __extends(SplitPane, _super);
|
149 | function SplitPane(_zone, _plt, config, elementRef, renderer) {
|
150 | var _this = _super.call(this, config, elementRef, renderer, 'split-pane') || this;
|
151 | _this._zone = _zone;
|
152 | _this._plt = _plt;
|
153 | _this._init = false;
|
154 | _this._visible = false;
|
155 | _this._isEnabled = true;
|
156 | _this._mediaQuery = QUERY['md'];
|
157 | |
158 |
|
159 |
|
160 | _this.sideContent = null;
|
161 | |
162 |
|
163 |
|
164 | _this.mainContent = null;
|
165 | |
166 |
|
167 |
|
168 | _this.ionChange = new EventEmitter();
|
169 | return _this;
|
170 | }
|
171 | Object.defineProperty(SplitPane.prototype, "_setchildren", {
|
172 | |
173 |
|
174 |
|
175 | set: function (query) {
|
176 | var _this = this;
|
177 | var children = this._children = query.filter((function (child) { return child !== _this; }));
|
178 | children.forEach(function (child) {
|
179 | var isMain = child.initPane();
|
180 | _this._setPaneCSSClass(child.getElementRef(), isMain);
|
181 | });
|
182 | },
|
183 | enumerable: true,
|
184 | configurable: true
|
185 | });
|
186 | Object.defineProperty(SplitPane.prototype, "when", {
|
187 | get: function () {
|
188 | return this._mediaQuery;
|
189 | },
|
190 | |
191 |
|
192 |
|
193 |
|
194 |
|
195 | set: function (query) {
|
196 | if (typeof query === 'boolean') {
|
197 | this._mediaQuery = query;
|
198 | }
|
199 | else {
|
200 | var defaultQuery = QUERY[query];
|
201 | this._mediaQuery = (defaultQuery)
|
202 | ? defaultQuery
|
203 | : query;
|
204 | }
|
205 | this._update();
|
206 | },
|
207 | enumerable: true,
|
208 | configurable: true
|
209 | });
|
210 | Object.defineProperty(SplitPane.prototype, "enabled", {
|
211 | get: function () {
|
212 | return this._isEnabled;
|
213 | },
|
214 | |
215 |
|
216 |
|
217 |
|
218 | set: function (val) {
|
219 | this._isEnabled = isTrueProperty(val);
|
220 | this._update();
|
221 | },
|
222 | enumerable: true,
|
223 | configurable: true
|
224 | });
|
225 | |
226 |
|
227 |
|
228 | SplitPane.prototype._register = function (node, isMain, callback) {
|
229 | if (this.getElementRef().nativeElement !== node.getElementRef().nativeElement.parentNode) {
|
230 | return false;
|
231 | }
|
232 | this._setPaneCSSClass(node.getElementRef(), isMain);
|
233 | if (callback) {
|
234 | this.ionChange.subscribe(callback);
|
235 | }
|
236 | if (isMain) {
|
237 | if (this.mainContent) {
|
238 | console.error('split pane: main content was already set');
|
239 | }
|
240 | this.mainContent = node;
|
241 | }
|
242 | return true;
|
243 | };
|
244 | |
245 |
|
246 |
|
247 | SplitPane.prototype.ngAfterViewInit = function () {
|
248 | this._init = true;
|
249 | this._update();
|
250 | };
|
251 | |
252 |
|
253 |
|
254 | SplitPane.prototype._update = function () {
|
255 | var _this = this;
|
256 | if (!this._init) {
|
257 | return;
|
258 | }
|
259 |
|
260 | this._rmListener && this._rmListener();
|
261 | this._rmListener = null;
|
262 |
|
263 | if (!this._isEnabled) {
|
264 | this._setVisible(false);
|
265 | return;
|
266 | }
|
267 | var query = this._mediaQuery;
|
268 | if (typeof query === 'boolean') {
|
269 | this._setVisible(query);
|
270 | return;
|
271 | }
|
272 | if (query && query.length > 0) {
|
273 |
|
274 | var callback_1 = function (query) { return _this._setVisible(query.matches); };
|
275 | var mediaList_1 = this._plt.win().matchMedia(query);
|
276 | mediaList_1.addListener(callback_1);
|
277 | this._setVisible(mediaList_1.matches);
|
278 | this._rmListener = function () {
|
279 | mediaList_1.removeListener(callback_1);
|
280 | };
|
281 | }
|
282 | else {
|
283 | this._setVisible(false);
|
284 | }
|
285 | };
|
286 | |
287 |
|
288 |
|
289 | SplitPane.prototype._updateChildren = function () {
|
290 | this.mainContent = null;
|
291 | this.sideContent = null;
|
292 | var visible = this._visible;
|
293 | this._children.forEach(function (child) { return child.paneChanged && child.paneChanged(visible); });
|
294 | };
|
295 | |
296 |
|
297 |
|
298 | SplitPane.prototype._setVisible = function (visible) {
|
299 | var _this = this;
|
300 | if (this._visible === visible) {
|
301 | return;
|
302 | }
|
303 | this._visible = visible;
|
304 | this.setElementClass('split-pane-visible', visible);
|
305 | this._updateChildren();
|
306 | this._zone.run(function () {
|
307 | _this.ionChange.emit(_this);
|
308 | });
|
309 | };
|
310 | |
311 |
|
312 |
|
313 | SplitPane.prototype.isVisible = function () {
|
314 | return this._visible;
|
315 | };
|
316 | |
317 |
|
318 |
|
319 | SplitPane.prototype.setElementClass = function (className, add) {
|
320 | this._renderer.setElementClass(this._elementRef.nativeElement, className, add);
|
321 | };
|
322 | |
323 |
|
324 |
|
325 | SplitPane.prototype._setPaneCSSClass = function (elementRef, isMain) {
|
326 | var ele = elementRef.nativeElement;
|
327 | this._renderer.setElementClass(ele, 'split-pane-main', isMain);
|
328 | this._renderer.setElementClass(ele, 'split-pane-side', !isMain);
|
329 | };
|
330 | |
331 |
|
332 |
|
333 | SplitPane.prototype.ngOnDestroy = function () {
|
334 | (void 0) ;
|
335 | this._rmListener && this._rmListener();
|
336 | this._rmListener = null;
|
337 | };
|
338 | |
339 |
|
340 |
|
341 | SplitPane.prototype.initPane = function () {
|
342 | return true;
|
343 | };
|
344 | SplitPane.decorators = [
|
345 | { type: Directive, args: [{
|
346 | selector: 'ion-split-pane',
|
347 | providers: [{ provide: RootNode, useExisting: forwardRef(function () { return SplitPane; }) }]
|
348 | },] },
|
349 | ];
|
350 |
|
351 | SplitPane.ctorParameters = function () { return [
|
352 | { type: NgZone, },
|
353 | { type: Platform, },
|
354 | { type: Config, },
|
355 | { type: ElementRef, },
|
356 | { type: Renderer, },
|
357 | ]; };
|
358 | SplitPane.propDecorators = {
|
359 | '_setchildren': [{ type: ContentChildren, args: [RootNode, { descendants: false },] },],
|
360 | 'when': [{ type: Input },],
|
361 | 'enabled': [{ type: Input },],
|
362 | 'ionChange': [{ type: Output },],
|
363 | };
|
364 | return SplitPane;
|
365 | }(Ion));
|
366 | export { SplitPane };
|
367 |
|
\ | No newline at end of file |