mirror of
https://github.com/openstf/stf
synced 2025-10-05 10:39:25 +02:00
Standalone now works with device screen size.
This commit is contained in:
parent
33fad24ed4
commit
c33d95ba7a
2 changed files with 39 additions and 22 deletions
|
@ -4,7 +4,8 @@ module.exports = angular.module('device-control.standalone', [
|
|||
require('stf/device').name,
|
||||
require('stf/control').name,
|
||||
require('stf/screen').name,
|
||||
require('stf/settings').name
|
||||
require('stf/settings').name,
|
||||
require('stf/screen/scaling').name
|
||||
])
|
||||
.run(["$templateCache", function ($templateCache) {
|
||||
$templateCache.put('control-panes/device-control/standalone/standalone.jade',
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
module.exports =
|
||||
function StandaloneServiceFactory($window, $rootScope, SettingsService) {
|
||||
function StandaloneServiceFactory($window, $rootScope, SettingsService,
|
||||
ScalingService, GroupService) {
|
||||
var service = {}
|
||||
|
||||
service.windows = []
|
||||
|
||||
//SettingsService.sync($scope, 'ControlWindow', {
|
||||
// controlWindowWidth: 600,
|
||||
// controlWindowHeight: 900,
|
||||
|
@ -10,22 +13,31 @@ module.exports =
|
|||
//})
|
||||
|
||||
var screenWidth = $window.screen.availWidth || $window.screen.width || 1024
|
||||
var screenHeight = $window.screen.availHeight || $window.screen.height || 768
|
||||
var windowSizeRatio = 1.0
|
||||
var screenHeight = $window.screen.availHeight || $window.screen.height ||
|
||||
768
|
||||
var windowSizeRatio = 0.5
|
||||
|
||||
function fitDeviceInGuestScreen(device) {
|
||||
var projected = {
|
||||
width: 600,
|
||||
height: 900,
|
||||
top: 50,
|
||||
left: 50
|
||||
//console.log('device.width', device.width)
|
||||
//console.log('device', device)
|
||||
|
||||
var screen = {
|
||||
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 deviceHeight = device.height
|
||||
var deviceRotation = device.rotation
|
||||
var projectedSize = screen.scaler.projectedSize(
|
||||
screen.bounds.w * windowSizeRatio,
|
||||
screen.bounds.h * windowSizeRatio,
|
||||
screen.rotation
|
||||
)
|
||||
|
||||
return projected
|
||||
return projectedSize
|
||||
}
|
||||
|
||||
service.open = function (device) {
|
||||
|
@ -36,8 +48,8 @@ module.exports =
|
|||
var features = [
|
||||
'width=' + projected.width,
|
||||
'height=' + projected.height,
|
||||
'top=' + projected.top,
|
||||
'left=' + projected.left,
|
||||
//'top=' + 0,
|
||||
//'left=' + 0,
|
||||
'toolbar=no',
|
||||
'location=no',
|
||||
'dialog=yes',
|
||||
|
@ -50,14 +62,18 @@ module.exports =
|
|||
'resizable=yes'
|
||||
].join(',')
|
||||
|
||||
var windowOpen = $window.open(url, 'StT', features)
|
||||
var newWindow = $window.open(url, 'STFNewWindow' + Date.now(), features)
|
||||
|
||||
//windowOpen.onbeforeunload = function () {
|
||||
// $scope.controlWindowWidth = windowOpen.innerWidth
|
||||
// $scope.controlWindowHeight = windowOpen.innerHeight
|
||||
// $scope.controlWindowTop = windowOpen.screenTop
|
||||
// $scope.controlWindowLeft = windowOpen.screenLeft
|
||||
//}
|
||||
newWindow.onbeforeunload = function () {
|
||||
|
||||
GroupService.kick(device).then(function () {
|
||||
$rootScope.$digest()
|
||||
})
|
||||
// $scope.controlWindowWidth = windowOpen.innerWidth
|
||||
// $scope.controlWindowHeight = windowOpen.innerHeight
|
||||
// $scope.controlWindowTop = windowOpen.screenTop
|
||||
// $scope.controlWindowLeft = windowOpen.screenLeft
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue