Skip to content

Commit

Permalink
Merge pull request mozilla-b2g#25919 from huchengtw-moz/bug-1093529-i…
Browse files Browse the repository at this point in the history
…nvoke-settings-at-home

Bug 1093529 - [Stingray] link home app to settings app, r=dwi2
  • Loading branch information
huchengtw-moz committed Nov 17, 2014
2 parents a0ff552 + 7de079c commit 83e694f
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 16 deletions.
2 changes: 1 addition & 1 deletion tv_apps/smart-home/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
</section>
<section id="commands">
<div class="command-button" data-l10n-id="edit">edit</div>
<div class="command-button" data-l10n-id="settings">settings</div>
<div id="settings-button" class="command-button" data-l10n-id="settings">settings</div>
</section>
</article>
</body>
Expand Down
49 changes: 37 additions & 12 deletions tv_apps/smart-home/js/home.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

cardListElem: document.getElementById('card-list'),
cardManager: undefined,
settingsButton: document.getElementById('settings-button'),

init: function() {
var that = this;
Expand Down Expand Up @@ -49,6 +50,11 @@
scrollable.on('focus', handleScrollableItemFocusBound);
});
that.spatialNavigator.focus();

that.settingsButton.addEventListener('click', function clickSettings() {
that.spatialNavigator.focus(that.settingsButton);
that.handleEnter('enter');
});
});
},

Expand Down Expand Up @@ -116,24 +122,36 @@
case 'down':
case 'left':
case 'right':
var focus = this.spatialNavigator.getFocusedElement();
if (focus.CLASS_NAME == 'XScrollable') {
if (focus.spatialNavigator.move(key)) {
return;
}
}
this.spatialNavigator.move(key);
this.handleMove(key)
break;
case 'enter':
var cardId = this.focusElem.dataset.cardId;
var card = this.cardManager.findCardFromCardList({cardId: cardId});
if (card) {
card.launch();
}
this.handleEnter(key);
break;
}
},

handleMove: function(key) {
var focus = this.spatialNavigator.getFocusedElement();
if (focus.CLASS_NAME == 'XScrollable') {
if (focus.spatialNavigator.move(key)) {
return;
}
}
this.spatialNavigator.move(key);
},

handleEnter: function(key) {
if (this.focusElem === this.settingsButton) {
this.openSettings();
} else {
var cardId = this.focusElem.dataset.cardId;
var card = this.cardManager.findCardFromCardList({cardId: cardId});
if (card) {
card.launch();
}
}
},

convertKeyToString: function(keyCode) {
switch (keyCode) {
case KeyEvent.DOM_VK_UP:
Expand Down Expand Up @@ -190,6 +208,13 @@
this._focus = elem;
},

openSettings: function() {
new MozActivity({
name: 'configure',
data: {}
});
},

get focusElem() {
return this._focus;
}
Expand Down
3 changes: 0 additions & 3 deletions tv_apps/smart-settings/manifest.webapp
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@
"orientation": "default",
"activities": {
"configure": {
"filters": {
"target": "device"
},
"disposition": "inline",
"href": "/index.html"
}
Expand Down

0 comments on commit 83e694f

Please sign in to comment.