Skip to content
This repository was archived by the owner on Apr 3, 2020. It is now read-only.

Commit 4f3fd4c

Browse files
committed
Updated to 0.2.1
1 parent 374f81b commit 4f3fd4c

File tree

5 files changed

+91
-18
lines changed

5 files changed

+91
-18
lines changed

app/launcher/application.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,10 @@
66
background: #fff;
77
color: #000;
88
}
9+
10+
.embedding {
11+
overflow:hidden;
12+
position: absolute;
13+
height: 100%;
14+
width: 100%
15+
}

app/launcher/application.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,19 @@ launcher.Application.prototype._backOnEmptyHistory = function() {
8080

8181

8282
/**
83+
* Rewrites original method to restricts current resolution to HD
8384
* @inheritDoc
8485
*/
8586
launcher.Application.prototype._appendScreenSizeClass = function() {
86-
this._body.classList.add('zb-hd');
87+
var currentResolution = zb.device.ResolutionInfo[this.device.info.osdResolutionType()];
88+
var maxSupportedResolution = zb.device.ResolutionInfo[zb.device.Resolution.HD];
89+
90+
if (!currentResolution || currentResolution.width > maxSupportedResolution.width) {
91+
currentResolution = maxSupportedResolution;
92+
}
93+
94+
this._body.classList.add('zb-' + currentResolution.name);
95+
this._appendViewportSize(currentResolution);
8796
};
8897

8998

app/launcher/services/app-list.js

Lines changed: 70 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
goog.provide('launcher.services.AppList');
2+
goog.require('zb.http');
23

34

45

@@ -86,18 +87,23 @@ launcher.services.AppList.prototype.removeApp = function(url) {
8687
*/
8788
launcher.services.AppList.prototype.executeApp = function(url) {
8889
this._logEvent('app-execute');
89-
var app = this._apps[this._findAppByUrl(url)];
90+
var appToExecute = this._apps[this._findAppByUrl(url)];
9091

91-
if (app) {
92-
app.launchCount++;
93-
this._touchApp(app);
92+
if (appToExecute) {
93+
appToExecute.launchCount++;
94+
this._touchApp(appToExecute);
9495
this._saveApps();
9596
}
9697

97-
return new Promise(function(resolve, reject) {
98-
// never resolve promise while new page is not loaded
99-
this._replaceUrl(url);
98+
return new Promise(function() {
99+
// Never resolve promise while new page is not loaded
100+
if (app.isDeviceTizen()) {
101+
this._openEmbedding(url);
102+
} else {
103+
this._replaceUrl(url);
104+
}
100105
}.bind(this));
106+
101107
};
102108

103109

@@ -223,7 +229,63 @@ launcher.services.AppList.prototype._compareTime = function(appA, appB) {
223229
* @private
224230
*/
225231
launcher.services.AppList.prototype._replaceUrl = function(url) {
226-
location.href = url;
232+
/**
233+
* @param {Object.<string, *>} from
234+
* @param {Object.<string, *>} to
235+
* @return {Object.<string, *>}
236+
*/
237+
function mergeObjects(from, to) {
238+
Object
239+
.keys(from || {})
240+
.forEach(function(key) {
241+
to[key] = from[key];
242+
});
243+
244+
return to;
245+
}
246+
247+
var urlParts = url.split('?');
248+
var mergedQueryParams = mergeObjects(
249+
zb.http.decodeParams(window.location.search.replace('?', '')),
250+
zb.http.decodeParams(urlParts[1] || '')
251+
);
252+
253+
location.href = zb.http.buildQueryString(urlParts[0], mergedQueryParams);
254+
};
255+
256+
257+
/**
258+
* @param {string} url
259+
* @private
260+
*/
261+
launcher.services.AppList.prototype._openEmbedding = function(url) {
262+
var embedding = document.createElement('iframe');
263+
var launcher = document.getElementsByClassName('zb-body')[0];
264+
265+
embedding.style.display = 'none';
266+
embedding.setAttribute('frameborder', '0');
267+
embedding.setAttribute('class', 'embedding');
268+
embedding.src = url;
269+
270+
document.body.appendChild(embedding);
271+
272+
embedding.contentWindow.addEventListener('DOMContentLoaded', function() {
273+
launcher.style.display = 'none';
274+
embedding.style.display = 'block';
275+
embedding.focus();
276+
});
277+
278+
try {
279+
if (app.device.proxyContext) {
280+
app.device.proxyContext(embedding.contentWindow);
281+
}
282+
} catch (error) {
283+
if (error instanceof DOMException) {
284+
zb.console.error('CSP blocked access to embedding context');
285+
}
286+
287+
document.body.removeChild(embedding);
288+
}
227289
};
228290

229291

package.json

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "appLauncher",
3-
"version": "0.2.0",
3+
"version": "0.2.1",
44
"description": "AppLauncher allows running Smart TV and STB application avoiding standard installation process.",
55
"homepage": "https://github.com/ifaced/app-launcher",
66
"repository": {
@@ -36,10 +36,6 @@
3636
{
3737
"name": "Dmitry Zubarev",
3838
"email": "zubrolet@interfaced.ru"
39-
},
40-
{
41-
"name": "Alex Babenko",
42-
"email": "babenkoalex@ifaced.ru"
4339
}
4440
],
4541
"license": "Apache-2.0",
@@ -52,6 +48,7 @@
5248
"zombiebox-platform-mag250": "0.0.35",
5349
"zombiebox-platform-samsung": "0.0.40",
5450
"zombiebox-platform-tvip": "0.0.12",
55-
"zombiebox-platform-webos": "0.0.11"
51+
"zombiebox-platform-webos": "0.0.11",
52+
"zombiebox-platform-tizen": "0.0.16"
5653
}
5754
}

templates/index.html.tpl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,5 @@
2020
print('<script>' + inlineScripts.join('</script>\n\t<script>') + '</script>');
2121
} %>
2222
</head>
23-
<body>
24-
25-
</body>
23+
<body></body>
2624
</html>

0 commit comments

Comments
 (0)