1
0
Fork 0
mirror of https://github.com/openstf/stf synced 2025-10-06 03:50:04 +02:00

Add basic context-menu for actions.

This commit is contained in:
Gunther Brunner 2014-09-25 16:24:57 +09:00
parent c33d95ba7a
commit f705cd60a7
9 changed files with 86 additions and 4 deletions

View file

@ -39,7 +39,8 @@
"angular-hotkeys": "chieffancypants/angular-hotkeys#~1.4.5", "angular-hotkeys": "chieffancypants/angular-hotkeys#~1.4.5",
"angular-borderlayout": "https://github.com/filearts/angular-borderlayout.git", "angular-borderlayout": "https://github.com/filearts/angular-borderlayout.git",
"angular-ui-bootstrap": "~0.11.0", "angular-ui-bootstrap": "~0.11.0",
"angular-ladda": "~0.1.6" "angular-ladda": "~0.1.6",
"ng-context-menu": "~1.0.0"
}, },
"private": true, "private": true,
"resolutions": { "resolutions": {

View file

@ -393,6 +393,10 @@ module.exports = function DeviceScreenDirective($document, ScalingService,
} }
function mouseDownListener(e) { function mouseDownListener(e) {
// Skip secondary click
if (e.which === 3) {
return
}
e.preventDefault() e.preventDefault()
fakePinch = e.altKey fakePinch = e.altKey
@ -433,6 +437,10 @@ module.exports = function DeviceScreenDirective($document, ScalingService,
} }
function mouseMoveListener(e) { function mouseMoveListener(e) {
// Skip secondary click
if (e.which === 3) {
return
}
e.preventDefault() e.preventDefault()
var addGhostFinger = !fakePinch && e.altKey var addGhostFinger = !fakePinch && e.altKey
@ -477,6 +485,10 @@ module.exports = function DeviceScreenDirective($document, ScalingService,
} }
function mouseUpListener(e) { function mouseUpListener(e) {
// Skip secondary click
if (e.which === 3) {
return
}
e.preventDefault() e.preventDefault()
control.touchUp(nextSeq(), 0) control.touchUp(nextSeq(), 0)

View file

@ -66,6 +66,7 @@ module.exports =
newWindow.onbeforeunload = function () { newWindow.onbeforeunload = function () {
// TODO: check for usage
GroupService.kick(device).then(function () { GroupService.kick(device).then(function () {
$rootScope.$digest() $rootScope.$digest()
}) })

View file

@ -22,6 +22,7 @@ module.exports =
switchCharset: function () { switchCharset: function () {
$scope.control.keyPress('switch_charset') $scope.control.keyPress('switch_charset')
}, },
// TODO: Refactor this
rotateLeft: function () { rotateLeft: function () {
var angle = 0 var angle = 0
if ($scope.device && $scope.device.display) { if ($scope.device && $scope.device.display) {

View file

@ -95,4 +95,32 @@ module.exports = function DeviceControlCtrl($scope, DeviceService, GroupService,
$scope.currentRotation = 'landscape' $scope.currentRotation = 'landscape'
} }
}) })
// TODO: Refactor this inside control and server-side
$scope.rotateLeft = function () {
var angle = 0
if ($scope.device && $scope.device.display) {
angle = $scope.device.display.rotation
}
if (angle === 0) {
angle = 270
} else {
angle -= 90
}
$scope.control.rotate(angle)
}
$scope.rotateRight = function () {
var angle = 0
if ($scope.device && $scope.device.display) {
angle = $scope.device.display.rotation
}
if (angle === 270) {
angle = 0
} else {
angle += 90
}
$scope.control.rotate(angle)
}
} }

View file

@ -36,8 +36,36 @@
i.fa.fa-times i.fa.fa-times
.as-row.fill-height .as-row.fill-height
div(ng-controller='DeviceScreenCtrl', ng-if='device', ng-file-drop='installFile($files)', ng-file-drag-over-class='dragover').fill-height
device-screen(device='device', control='control') .dropdown.context-menu(id='context-menu-{{ $index }}')
ul.dropdown-menu(role='menu')
li
a.pointer(role='menuitem', ng-click='control.back(); $event.preventDefault()')
i.fa.fa-mail-reply.fa-fw
span(translate) Back
li
a.pointer(role='menuitem', ng-click='control.home(); $event.preventDefault()')
i.fa.fa-home.fa-fw
span(translate) Home
li.divider
li
a.pointer(role='menuitem', ng-click='rotateRight(); $event.preventDefault()')
i.fa.fa-rotate-left.fa-fw
span(translate) Rotate Left
li
a.pointer(role='menuitem', ng-click='rotateLeft(); $event.preventDefault()')
i.fa.fa-rotate-right.fa-fw
span(translate) Rotate Right
li.divider
li
a.pointer(role='menuitem', ng-click='kickDevice(device); $event.preventDefault()')
i.fa.fa-sign-out.fa-fw
span(translate) Stop Using
div(ng-controller='DeviceScreenCtrl', ng-if='device',
ng-file-drop='installFile($files)', ng-file-drag-over-class='dragover').fill-height
div(context-menu, data-target='context-menu-{{ $index }}').fill-height
device-screen(device='device', control='control')
.stf-vnc-bottom.as-row(ng-hide='$root.standalone') .stf-vnc-bottom.as-row(ng-hide='$root.standalone')
.controls .controls

View file

@ -3,7 +3,8 @@ require('./device-control.css')
module.exports = angular.module('device-control', [ module.exports = angular.module('device-control', [
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('ng-context-menu').name
]) ])
.run(["$templateCache", function ($templateCache) { .run(["$templateCache", function ($templateCache) {
$templateCache.put('control-panes/device-control/device-control.jade', $templateCache.put('control-panes/device-control/device-control.jade',

View file

@ -0,0 +1,4 @@
.context-menu {
position: fixed;
z-index: 1000;
}

View file

@ -0,0 +1,6 @@
require('ng-context-menu/dist/ng-context-menu')
require('./context-menu.css')
module.exports = {
name: 'ng-context-menu'
}