VulpesOS/gaia/tv_apps/dashboard/js/app_widget.js
OverSu b38dea0597 Publish Vulpes Preview 15 sources for desktop, Android and Tundra
Share Gaia assets and adapters, keep private profiles and development documents local, and update both public READMEs.
2026-09-30 23:13:03 +02:00

44 lines
1.3 KiB
JavaScript
Executable file

'use strict';
(function(exports) {
function AppWidget(config) {
this.manifestURL = config.manifestURL;
this.widget = config.widget;
this.launchPath = config.url;
this.position = config.position;
this.isExpanded = false;
var browser = document.createElement('iframe');
// XXX: Change the following property and dashboard App permission to
// widget-specific one after widget path bug is fixed. See bug 1167063.
browser.setAttribute('mozbrowser', 'true');
browser.setAttribute('remote', 'true');
browser.setAttribute('mozapp', config.manifestURL);
browser.src = config.url;
this.iframe = browser;
this.container = document.getElementById(this.position + '-panel');
this.container.appendChild(this.iframe);
}
AppWidget.prototype = {
_setHash: function aw_setHash(hash) {
// Note: The '#' should always present to prevent reload
this.iframe.src = this.iframe.src.split('#')[0] + '#' + hash;
},
toggleExpand: function aw_setExpand(value) {
if(typeof value !== 'undefined') {
this.isExpanded = ! this.isExpanded;
} else {
this.isExpanded = value;
}
this._setHash(this.isExpanded ? 'expand' : '');
},
focus: function aw_focus() {
this.iframe.focus();
}
};
exports.AppWidget = AppWidget;
}(window));