GUAC-1170: Load keyboard layout within guacOsk directive. Update translation to point to new JSON layout. Remove old XML layouts.

This commit is contained in:
Michael Jumper
2015-04-28 14:56:00 -07:00
parent 29a0bc6387
commit ee83060bb5
4 changed files with 40 additions and 835 deletions

View File

@@ -40,8 +40,13 @@ angular.module('osk').directive('guacOsk', [function guacOsk() {
},
templateUrl: 'app/osk/templates/guacOsk.html',
controller: ['$scope', '$rootScope', '$window', '$element',
function guacOsk($scope, $rootScope, $window, $element) {
controller: ['$scope', '$injector', '$element',
function guacOsk($scope, $injector, $element) {
// Required services
var $http = $injector.get('$http');
var $rootScope = $injector.get('$rootScope');
var cacheService = $injector.get('cacheService');
/**
* The current on-screen keyboard, if any.
@@ -67,7 +72,7 @@ angular.module('osk').directive('guacOsk', [function guacOsk() {
};
// Set layout whenever URL changes
$scope.$watch("layout", function setLayout(layout) {
$scope.$watch("layout", function setLayout(url) {
// Remove current keyboard
if (keyboard) {
@@ -76,24 +81,40 @@ angular.module('osk').directive('guacOsk', [function guacOsk() {
}
// Load new keyboard
if (layout) {
if (url) {
// Add OSK element
keyboard = new Guacamole.OnScreenKeyboard(layout);
main.appendChild(keyboard.getElement());
// Retrieve layout JSON
$http({
cache : cacheService.languages,
method : 'GET',
url : url
})
// Init size
keyboard.resize(main.offsetWidth);
// Build OSK with retrieved layout
.success(function layoutRetrieved(layout) {
// Broadcast keydown for each key pressed
keyboard.onkeydown = function(keysym) {
$rootScope.$broadcast('guacSyntheticKeydown', keysym);
};
// Broadcast keydown for each key released
keyboard.onkeyup = function(keysym) {
$rootScope.$broadcast('guacSyntheticKeyup', keysym);
};
// Abort if the layout changed while we were waiting for a response
if ($scope.layout !== url)
return;
// Add OSK element
keyboard = new Guacamole.OnScreenKeyboard(layout);
main.appendChild(keyboard.getElement());
// Init size
keyboard.resize(main.offsetWidth);
// Broadcast keydown for each key pressed
keyboard.onkeydown = function(keysym) {
$rootScope.$broadcast('guacSyntheticKeydown', keysym);
};
// Broadcast keydown for each key released
keyboard.onkeyup = function(keysym) {
$rootScope.$broadcast('guacSyntheticKeyup', keysym);
};
});
}