mirror of
https://github.com/DeviceFarmer/stf.git
synced 2026-04-28 03:39:13 +02:00
Standalone now works with device screen size.
This commit is contained in:
@@ -4,7 +4,8 @@ module.exports = angular.module('device-control.standalone', [
|
|||||||
require('stf/device').name,
|
require('stf/device').name,
|
||||||
require('stf/control').name,
|
require('stf/control').name,
|
||||||
require('stf/screen').name,
|
require('stf/screen').name,
|
||||||
require('stf/settings').name
|
require('stf/settings').name,
|
||||||
|
require('stf/screen/scaling').name
|
||||||
])
|
])
|
||||||
.run(["$templateCache", function ($templateCache) {
|
.run(["$templateCache", function ($templateCache) {
|
||||||
$templateCache.put('control-panes/device-control/standalone/standalone.jade',
|
$templateCache.put('control-panes/device-control/standalone/standalone.jade',
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
module.exports =
|
module.exports =
|
||||||
function StandaloneServiceFactory($window, $rootScope, SettingsService) {
|
function StandaloneServiceFactory($window, $rootScope, SettingsService,
|
||||||
|
ScalingService, GroupService) {
|
||||||
var service = {}
|
var service = {}
|
||||||
|
|
||||||
|
service.windows = []
|
||||||
|
|
||||||
//SettingsService.sync($scope, 'ControlWindow', {
|
//SettingsService.sync($scope, 'ControlWindow', {
|
||||||
// controlWindowWidth: 600,
|
// controlWindowWidth: 600,
|
||||||
// controlWindowHeight: 900,
|
// controlWindowHeight: 900,
|
||||||
@@ -10,22 +13,31 @@ module.exports =
|
|||||||
//})
|
//})
|
||||||
|
|
||||||
var screenWidth = $window.screen.availWidth || $window.screen.width || 1024
|
var screenWidth = $window.screen.availWidth || $window.screen.width || 1024
|
||||||
var screenHeight = $window.screen.availHeight || $window.screen.height || 768
|
var screenHeight = $window.screen.availHeight || $window.screen.height ||
|
||||||
var windowSizeRatio = 1.0
|
768
|
||||||
|
var windowSizeRatio = 0.5
|
||||||
|
|
||||||
function fitDeviceInGuestScreen(device) {
|
function fitDeviceInGuestScreen(device) {
|
||||||
var projected = {
|
//console.log('device.width', device.width)
|
||||||
width: 600,
|
//console.log('device', device)
|
||||||
height: 900,
|
|
||||||
top: 50,
|
var screen = {
|
||||||
left: 50
|
scaler: ScalingService.coordinator(
|
||||||
|
device.display.width, device.display.height
|
||||||
|
),
|
||||||
|
rotation: device.display.rotation,
|
||||||
|
bounds: {
|
||||||
|
x: 0, y: 0, w: screenWidth, h: screenHeight
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var deviceWidth = device.width
|
var projectedSize = screen.scaler.projectedSize(
|
||||||
var deviceHeight = device.height
|
screen.bounds.w * windowSizeRatio,
|
||||||
var deviceRotation = device.rotation
|
screen.bounds.h * windowSizeRatio,
|
||||||
|
screen.rotation
|
||||||
|
)
|
||||||
|
|
||||||
return projected
|
return projectedSize
|
||||||
}
|
}
|
||||||
|
|
||||||
service.open = function (device) {
|
service.open = function (device) {
|
||||||
@@ -36,8 +48,8 @@ module.exports =
|
|||||||
var features = [
|
var features = [
|
||||||
'width=' + projected.width,
|
'width=' + projected.width,
|
||||||
'height=' + projected.height,
|
'height=' + projected.height,
|
||||||
'top=' + projected.top,
|
//'top=' + 0,
|
||||||
'left=' + projected.left,
|
//'left=' + 0,
|
||||||
'toolbar=no',
|
'toolbar=no',
|
||||||
'location=no',
|
'location=no',
|
||||||
'dialog=yes',
|
'dialog=yes',
|
||||||
@@ -50,14 +62,18 @@ module.exports =
|
|||||||
'resizable=yes'
|
'resizable=yes'
|
||||||
].join(',')
|
].join(',')
|
||||||
|
|
||||||
var windowOpen = $window.open(url, 'StT', features)
|
var newWindow = $window.open(url, 'STFNewWindow' + Date.now(), features)
|
||||||
|
|
||||||
//windowOpen.onbeforeunload = function () {
|
newWindow.onbeforeunload = function () {
|
||||||
// $scope.controlWindowWidth = windowOpen.innerWidth
|
|
||||||
// $scope.controlWindowHeight = windowOpen.innerHeight
|
GroupService.kick(device).then(function () {
|
||||||
// $scope.controlWindowTop = windowOpen.screenTop
|
$rootScope.$digest()
|
||||||
// $scope.controlWindowLeft = windowOpen.screenLeft
|
})
|
||||||
//}
|
// $scope.controlWindowWidth = windowOpen.innerWidth
|
||||||
|
// $scope.controlWindowHeight = windowOpen.innerHeight
|
||||||
|
// $scope.controlWindowTop = windowOpen.screenTop
|
||||||
|
// $scope.controlWindowLeft = windowOpen.screenLeft
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user