mirror of
https://github.com/DeviceFarmer/stf.git
synced 2026-04-19 00:23:25 +02:00
- Adding Browser selection.
- Adding URL history and autocomplete.
This commit is contained in:
@@ -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)
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
.widget-container.fluid-height
|
||||
.widget-container.fluid-height(ng-controller='BrowserCtrl')
|
||||
.heading
|
||||
i.fa.fa-gear
|
||||
span(translate) Browser
|
||||
@@ -13,9 +13,11 @@
|
||||
button.btn.btn-default-outline.dropdown-toggle
|
||||
//img(ng-src='/img/platforms/{{$root.browser}}.png').browser-icon
|
||||
//| {{$root.browser | browserName}}
|
||||
span {{$root.browser.type}}
|
||||
span.caret
|
||||
ul.dropdown-menu
|
||||
li(ng-repeat='b in browsers')
|
||||
a(ng-click='selectBrowser(b)').pointer
|
||||
li(ng-repeat='b in device.browser.apps')
|
||||
a(ng-click='$root.browser = b').pointer
|
||||
span {{b.type}}
|
||||
//img(ng-src='/img/platforms/{{b}}.png').browser-icon.pointer
|
||||
//| {{ b | browserName }}
|
||||
@@ -1,10 +1,46 @@
|
||||
module.exports = function NavigationCtrl($scope) {
|
||||
$scope.activeBrowser = null
|
||||
var _ = require('lodash')
|
||||
|
||||
module.exports = function NavigationCtrl($scope) {
|
||||
|
||||
$scope.urlHistory = []
|
||||
|
||||
function addToHistory() {
|
||||
const HISTORY_LIMIT = 20
|
||||
|
||||
var history = $scope.urlHistory
|
||||
history.unshift($scope.textURL)
|
||||
if (history.length > HISTORY_LIMIT) {
|
||||
history.pop()
|
||||
}
|
||||
$scope.urlHistory = _.uniq(history)
|
||||
}
|
||||
|
||||
function addHttp() {
|
||||
if ($scope.textURL.indexOf(':') === -1) {
|
||||
$scope.textURL = 'http://' + $scope.textURL
|
||||
}
|
||||
}
|
||||
|
||||
$scope.openURL = function () {
|
||||
addHttp()
|
||||
addToHistory()
|
||||
|
||||
$scope.openURL = function() {
|
||||
return $scope.control.openBrowser(
|
||||
$scope.textURL
|
||||
, $scope.activeBrowser
|
||||
$scope.textURL,
|
||||
$scope.browser
|
||||
)
|
||||
}
|
||||
|
||||
$scope.clearHistory = function () {
|
||||
$scope.urlHistory = []
|
||||
}
|
||||
|
||||
$scope.hasHistory = function () {
|
||||
return $scope.urlHistory.length > 0
|
||||
}
|
||||
|
||||
$scope.insertURL = function ($url) {
|
||||
$scope.textURL = $url
|
||||
$scope.openURL()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,14 +8,8 @@
|
||||
i.fa.fa-step-backward.pull-right(ng-click='back()', title='{{"Go Back"|translate}}', ng-if='$root.browser == "webview"')
|
||||
.widget-content.padded
|
||||
form
|
||||
ul
|
||||
li(ng-repeat='browser in device.browser.apps')
|
||||
label
|
||||
input(type='radio', ng-model='activeBrowser', ng-value='browser')
|
||||
span {{ browser.type }}
|
||||
|
||||
.input-group
|
||||
input(type='text', placeholder='http://...', autocomplete='off', ng-model='textURL',
|
||||
input.form-control(type='text', placeholder='http://...', autocomplete='off', ng-model='textURL',
|
||||
typeahead='url for url in urlHistory | filter:$viewValue').form-control
|
||||
.input-group-btn
|
||||
button(ng-click='openURL()', ng-disabled='!textURL', translate).btn.btn-primary-outline Open
|
||||
|
||||
Reference in New Issue
Block a user