- Adding Browser selection.

- Adding URL history and autocomplete.
This commit is contained in:
Gunther Brunner
2014-04-22 16:51:16 +09:00
parent 78432bbaf4
commit f831596290
4 changed files with 72 additions and 17 deletions

View File

@@ -1,3 +1,26 @@
module.exports = function BrowserCtrl($scope) {
var _ = require('lodash')
module.exports = function BrowserCtrl($scope, $rootScope) {
function setCurrentBrowser(device) {
if (device && device.browser && device.browser.apps) {
var currentBrowser = {}
var selectedBrowser = _.first(device.browser.apps, 'selected')
if (!_.isEmpty(selectedBrowser)) {
currentBrowser = selectedBrowser[0]
} else {
currentBrowser = _.first(device.browser.apps)
}
$rootScope.browser = currentBrowser
}
}
setCurrentBrowser($scope.device)
$scope.$watch('device', function (newValue, oldValue) {
if (newValue !== oldValue) {
setCurrentBrowser(newValue)
}
})
}