diff --git a/res/app/control-panes/control-panes-controller.js b/res/app/control-panes/control-panes-controller.js index b8a238ee..64330c11 100644 --- a/res/app/control-panes/control-panes-controller.js +++ b/res/app/control-panes/control-panes-controller.js @@ -1,9 +1,7 @@ -var ControlPanesHotkeys = require('./control-panes-hotkeys') - module.exports = function ControlPanesController($scope, $http, gettext, $routeParams, $timeout, $location, DeviceService, GroupService, ControlService, - StorageService, FatalMessageService, hotkeys, $filter) { + StorageService, FatalMessageService) { var sharedTabs = [ { @@ -183,6 +181,4 @@ module.exports = }, true) - ControlPanesHotkeys($scope, hotkeys, $filter, gettext) - } diff --git a/res/app/control-panes/control-panes-hotkeys-controller.js b/res/app/control-panes/control-panes-hotkeys-controller.js new file mode 100644 index 00000000..1880962a --- /dev/null +++ b/res/app/control-panes/control-panes-hotkeys-controller.js @@ -0,0 +1,85 @@ +module.exports = function ($scope, hotkeys, $filter, gettext, $location) { + + var actions = { + previousDevice: function () { + console.log('prev') + }, + nextDevice: function () { + console.log('next') + }, + deviceList: function () { + $location.path('/devices/') + }, + switchCharset: function () { + $scope.control.keyPress('switch_charset') + }, + rotateScreen: function () { + // TODO: Add a toggle rotate + $scope.control.rotate(90) + }, + focusUrlBar: function () { + // TODO: Switch tab and focus + console.log('focus') + }, + takeScreenShot: function () { + // TODO: Switch tab and take screenshot + $scope.takeScreenShot() + }, + pressMenu: function () { + $scope.control.menu() + }, + pressHome: function () { + $scope.control.home() + }, + pressBack: function () { + $scope.control.back() + }, + toggleDevice: function () { + $scope.showScreen = false + }, + togglePlatform: function () { + console.log('platform') + } + } + + var hotkeySet = [ + ['shift+left', gettext('Previous device'), actions.previousDevice], + ['shift+right', gettext('Next device'), actions.nextDevice], + ['shift+d', gettext('Go to Device List'), actions.deviceList], + + ['shift+space', gettext('Selects next IME'), actions.switchCharset], + ['shift+r', gettext('Rotate screen'), actions.rotateScreen], + + ['shift+l', gettext('Focus URL bar'), actions.focusUrlBar], + ['shift+s', gettext('Take screenshot'), actions.takeScreenShot], + + ['shift+m', gettext('Press Menu button'), actions.pressMenu], + ['shift+h', gettext('Press Home button'), actions.pressHome], + ['shift+b', gettext('Press Back button'), actions.pressBack], + + ['shift+i', gettext('Show/Hide device'), actions.toggleDevice], + ['shift+w', gettext('Toggle Web/Native'), actions.togglePlatform] + ] + + function hotkeyAdd(combo, desc, cb) { + hotkeys.add({ + combo: combo, + description: $filter('translate')(desc), + allowIn: ['textarea'], + callback: function (event) { + //event.preventDefault() + cb() + } + }) + } + + angular.forEach(hotkeySet, function (value) { + hotkeyAdd(value[0], value[1], value[2]) + }) + + $scope.$on('$destroy', function () { + angular.forEach(hotkeySet, function (value) { + hotkeys.del(value[0]) + }) + }) +} diff --git a/res/app/control-panes/control-panes-hotkeys.js b/res/app/control-panes/control-panes-hotkeys.js deleted file mode 100644 index 7cc2cb98..00000000 --- a/res/app/control-panes/control-panes-hotkeys.js +++ /dev/null @@ -1,52 +0,0 @@ -module.exports = function ($scope, hotkeys, $filter, gettext) { - - function hotkeyAdd(combo, desc, cb) { - hotkeys.add({ - combo: combo, - description: $filter('translate')(desc), - allowIn: ['textarea'], - callback: function (event) { - event.preventDefault() - cb() - } - }) - } - - var actions = { - switchCharset: function () { - $scope.control.keyPress('switch_charset') - }, - rotateScreen: function () { - // TODO: Add a proper rotate - $scope.control.rotate(90) - }, - focusUrlBar: function () { - console.log('action') - }, - takeScreenShot: function () { - console.log('action') - } - - } - - hotkeyAdd('shift+left', gettext('Previous device'), actions.takeScreenShot) - hotkeyAdd('shift+right', gettext('Next device'), actions.takeScreenShot) - hotkeyAdd('shift+D', gettext('Go to Device List'), actions.takeScreenShot) - - hotkeyAdd('shift+SPACE', gettext('Selects next IME in the device'), actions.switchCharset) - hotkeyAdd('shift+R', gettext('Rotate screen'), actions.rotateScreen) - - hotkeyAdd('shift+L', gettext('Focus URL bar'), actions.focusUrlBar) - hotkeyAdd('shift+S', gettext('Take screenshot'), actions.takeScreenShot) - - hotkeyAdd('shift+M', gettext('Press Menu button'), actions.takeScreenShot) - hotkeyAdd('shift+H', gettext('Press Home button'), actions.takeScreenShot) - hotkeyAdd('shift+B', gettext('Press Back button'), actions.takeScreenShot) - - hotkeyAdd('shift+I', gettext('Show/Hide device'), actions.takeScreenShot) - - hotkeyAdd('shift+W', gettext('Toggle Web/Native'), actions.takeScreenShot) - - - -} diff --git a/res/app/control-panes/control-panes.jade b/res/app/control-panes/control-panes.jade index 4995af4e..ed8aa984 100644 --- a/res/app/control-panes/control-panes.jade +++ b/res/app/control-panes/control-panes.jade @@ -3,7 +3,7 @@ div(ng-if='$root.basicMode').fill-height .remote-control.fill-height div(ng-include='"control-panes/device-control/device-control.jade"').fill-height -div(ng-if='!$root.basicMode') +div(ng-if='!$root.basicMode', ng-controller='ControlPanesHotKeysCtrl') div(fa-pane, pane-id='control-device', pane-anchor='west', pane-size='30% + 2px', pane-min='200px', pane-max='100% + 2px', pane-handle='4', pane-no-toggle='false') //.stf-catch-all-keys(ng-controller='KeysCtrl') catch-all-keys(keys-down='keysDown($event)', keys-up='keysUp($event)') diff --git a/res/app/control-panes/index.js b/res/app/control-panes/index.js index e8c5cea7..4251af0a 100644 --- a/res/app/control-panes/index.js +++ b/res/app/control-panes/index.js @@ -22,3 +22,4 @@ module.exports = angular.module('control-panes', [ }]) .factory('ControlPanesService', require('./control-panes-service')) .controller('ControlPanesCtrl', require('./control-panes-controller')) + .controller('ControlPanesHotKeysCtrl', require('./control-panes-hotkeys-controller'))