OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 // This Polymer element shows the custom controller for a route using extension | |
apacible
2017/05/17 21:52:17
nit: extensionview (one word)
takumif
2017/05/18 18:01:55
Done.
| |
6 // view. | |
7 Polymer({ | |
8 is: 'extension-view-wrapper', | |
9 | |
10 properties: { | |
11 /** | |
12 * The route to show the custom controller for. | |
13 * @type {?media_router.Route|undefined} | |
14 */ | |
15 route: { | |
16 type: Object, | |
17 observer: 'maybeLoadExtensionView_', | |
18 }, | |
19 | |
20 /** | |
21 * Whether the extension view is ready to be shown. | |
22 * @type {boolean} | |
23 */ | |
24 isExtensionViewReady: { | |
25 type: Boolean, | |
26 value: false, | |
27 notify: true, | |
28 }, | |
29 }, | |
30 | |
31 /** | |
32 * Loads the custom controller if the controller path for the current route is | |
33 * valid. | |
34 */ | |
35 maybeLoadExtensionView_: function() { | |
36 var extensionview = this.$['custom-controller']; | |
37 | |
38 // Do nothing if the controller path doesn't exist or is already shown in | |
39 // the extension view. | |
40 if (!this.route || | |
41 !this.route.customControllerPath || | |
42 this.route.customControllerPath == extensionview.src) { | |
43 return; | |
44 } | |
45 | |
46 var that = this; | |
47 extensionview.load(this.route.customControllerPath) | |
48 .then(function() { | |
49 // Load was successful; show the custom controller. | |
50 that.isExtensionViewReady = true; | |
51 }, function() { | |
52 // Load was unsuccessful; fall back to default view. | |
53 that.isExtensionViewReady = false; | |
54 }); | |
55 }, | |
56 | |
57 /** | |
58 * Called by Polymer when this module has loaded. | |
59 */ | |
60 ready: function() { | |
61 this.maybeLoadExtensionView_(); | |
62 }, | |
63 }); | |
OLD | NEW |