-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcuba-app-aware-behavior.html
More file actions
45 lines (40 loc) · 1010 Bytes
/
cuba-app-aware-behavior.html
File metadata and controls
45 lines (40 loc) · 1010 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<script>
(function() {
/**
* @polymerBehavior CubaAppAwareBehavior
*/
CubaAppAwareBehavior = {
properties: {
/**
* @type {cuba.CubaApp}
*/
app: {
type: Object,
notify: true,
readOnly: true
},
appName: {
type: String,
value: '',
observer: '_appNameChanged'
}
},
_appNameChanged: function(appName) {
if (this.app && this.app.name === appName) {
return;
}
var _this = this;
var app = cuba.getApp(appName);
if (app != null) {
this._setApp(app);
} else { // wait until app initalized
window.addEventListener('cuba-app-initialized',
function cubaAppInitialized(event) {
window.removeEventListener('cuba-app-initialized', cubaAppInitialized);
_this._appNameChanged(_this.appName);
});
}
}
}
})();
</script>