[Mobile] Consolidate BrowseTreeController

Make mobile variant of BrowseTreeController the regular version
of that controller; Browse mode has a dependency on mobile by
way of the mct-device directive anyway.
This commit is contained in:
Victor Woeltjen
2015-09-18 15:55:58 -07:00
parent 884d36ad6d
commit 1e6c4732f1
7 changed files with 108 additions and 203 deletions

View File

@@ -21,19 +21,39 @@
*****************************************************************************/
/*global define,Promise*/
define(
[],
function () {
"use strict";
/**
* Controller to provide the ability to show/hide the tree in
* Browse mode.
* @constructor
* @memberof platform/commonUI/browse
*/
function BrowseTreeController() {
function BrowseTreeController($scope, navigationService, agentService) {
var object = navigationService.getNavigation(),
self = this;
// Collapse tree when navigation changes
function changeObject(newObject) {
if (newObject !== object && agentService.isPortrait()) {
object = newObject;
self.state = false;
}
}
// On phones, trees should collapse in portrait mode
// when something is navigated-to.
if (agentService.isPhone()) {
navigationService.addListener(changeObject);
$scope.$on("$destroy", function () {
navigationService.removeListener(changeObject);
});
}
this.state = true;
}