mirror of
https://github.com/DeviceFarmer/stf.git
synced 2026-04-19 00:23: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:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user