1
0
Fork 0
mirror of https://github.com/openstf/stf synced 2025-10-05 10:39:25 +02:00

Added favicon resolving to URL input.

Added blur event after entering URL.
Focus screen after entering URL.
This commit is contained in:
Gunther Brunner 2014-07-31 20:30:43 +09:00
parent 8696f833c2
commit 4edcb387d4
15 changed files with 201 additions and 10 deletions

View file

@ -2,6 +2,26 @@ var _ = require('lodash')
module.exports = function NavigationCtrl($scope, $rootScope) {
var faviconIsSet = false
function setUrlFavicon(url) {
var FAVICON_BASE_URL = '//www.google.com/s2/favicons?domain_url='
$scope.urlFavicon = FAVICON_BASE_URL + url
faviconIsSet = true
}
function resetFavicon() {
$scope.urlFavicon = require('./default-favicon.png')
faviconIsSet = false
}
resetFavicon()
$scope.textUrlChanged = function () {
if (faviconIsSet) {
resetFavicon()
}
}
function addHttp(textUrl) {
if (textUrl.indexOf(':') === -1 && textUrl.indexOf('.') !== -1) {
return 'http://' + textUrl
@ -9,11 +29,15 @@ module.exports = function NavigationCtrl($scope, $rootScope) {
return textUrl
}
$scope.openURL = function () {
return $scope.control.openBrowser(
addHttp($scope.textURL),
$scope.browser
)
$scope.blurUrl = false
$scope.openURL = function ($event) {
$scope.blurUrl = true
$rootScope.screenFocus = true
var url = addHttp($scope.textURL)
setUrlFavicon(url)
return $scope.control.openBrowser(url, $scope.browser)
}
function setCurrentBrowser(browser) {