diff --git a/web/pgadmin/preferences/static/css/preferences.css b/web/pgadmin/preferences/static/css/preferences.css index 9f8de62..cf90e7d 100644 --- a/web/pgadmin/preferences/static/css/preferences.css +++ b/web/pgadmin/preferences/static/css/preferences.css @@ -25,10 +25,6 @@ div.pgadmin-preference-body div.ajs-content { bottom: 0px !important; } -.preferences_content .control-label, .preferences_content .pgadmin-controls { - min-width: 100px !important; -} - .pgadmin-preference-body { min-width: 300px !important; min-height: 400px !important; diff --git a/web/pgadmin/preferences/static/js/preferences.js b/web/pgadmin/preferences/static/js/preferences.js index d025be1..f487782 100644 --- a/web/pgadmin/preferences/static/js/preferences.js +++ b/web/pgadmin/preferences/static/js/preferences.js @@ -256,6 +256,8 @@ define('pgadmin.preferences', [ return 'textarea'; case 'switch': return 'switch'; + case 'keyboardshortcut': + return 'keyboardshortcut'; default: if (console && console.warn) { // Warning for developer only. diff --git a/web/pgadmin/static/js/backform.pgadmin.js b/web/pgadmin/static/js/backform.pgadmin.js index 4f3b144..f75270a 100644 --- a/web/pgadmin/static/js/backform.pgadmin.js +++ b/web/pgadmin/static/js/backform.pgadmin.js @@ -79,9 +79,11 @@ define([ return type; }; - var BackformControlInit = Backform.Control.prototype.initialize, - BackformControlRemove = Backform.Control.prototype.remove; + BackformControlRemove = Backform.Control.prototype.remove, + capitalizeFirstLetter = function(text) { + return text[0].toUpperCase() + text.slice(1); + }; // Override the Backform.Control to allow to track changes in dependencies, // and rerender the View element @@ -2504,5 +2506,213 @@ define([ }, }); + var KeyboardshortcutControl = Backform.KeyboardshortcutControl = Backform.Control.extend({ + default:{key_codes:{ + 3 : "break", + 8 : "backspace / delete", + 9 : "tab", + 12 : 'clear', + 13 : "enter", + 19 : "pause/break", + 20 : "caps lock", + 27 : "escape", + 32 : "spacebar", + 33 : "page up", + 34 : "page down", + 35 : "end", + 36 : "home", + 37 : "left arrow", + 38 : "up arrow", + 39 : "right arrow", + 40 : "down arrow", + 41 : "select", + 43 : "execute", + 44 : "Print Screen", + 45 : "insert", + 46 : "delete", + 47 : "help", + 48 : "0", + 49 : "1", + 50 : "2", + 51 : "3", + 52 : "4", + 53 : "5", + 54 : "6", + 55 : "7", + 56 : "8", + 57 : "9", + 58 : ":", + 59 : "semicolon (;)", + 60 : "<", + 61 : "equals (=)", + 65 : "a", + 66 : "b", + 67 : "c", + 68 : "d", + 69 : "e", + 70 : "f", + 71 : "g", + 72 : "h", + 73 : "i", + 74 : "j", + 75 : "k", + 76 : "l", + 77 : "m", + 78 : "n", + 79 : "o", + 80 : "p", + 81 : "q", + 82 : "r", + 83 : "s", + 84 : "t", + 85 : "u", + 86 : "v", + 87 : "w", + 88 : "x", + 89 : "y", + 90 : "z", + 91 : "Windows Key / Left ⌘ / Chromebook Search key", + 92 : "right window key", + 93 : "Windows Menu / Right ⌘", + 95: "sleep", + 96 : "numpad 0", + 97 : "numpad 1", + 98 : "numpad 2", + 99 : "numpad 3", + 100 : "numpad 4", + 101 : "numpad 5", + 102 : "numpad 6", + 103 : "numpad 7", + 104 : "numpad 8", + 105 : "numpad 9", + 106 : "multiply", + 107 : "add", + 108 : "numpad period (.)", + 109 : "subtract", + 110 : "decimal point", + 111 : "divide", + 112 : "f1", + 113 : "f2", + 114 : "f3", + 115 : "f4", + 116 : "f5", + 117 : "f6", + 118 : "f7", + 119 : "f8", + 120 : "f9", + 121 : "f10", + 122 : "f11", + 123 : "f12", + 144 : "num lock", + 145 : "scroll lock", + 166 : "page backward", + 167 : "page forward", + 172 : "home key", + 191 : "forward slash", + 219 : "open bracket", + 220 : "back slash", + 221 : "close bracket", + 222 : "single quote", + 223 : "`", + 225 : "altgr", + 240 : "alphanumeric" + }}, + initialize: function() { + + Backform.Control.prototype.initialize.apply(this, arguments); + + var self = this, + initial_value = {}, + value = self.model.get(self.field.get('name')); + + var fields = self.field.get('fields') + + if (fields == null || fields == undefined) { + throw new ReferenceError('"fields" not found in keyboard shortcut'); + } + + _.each(fields, function(field) { + initial_value[field['name']] = value[field['name']]; + }); + + self.innerModel = new Backbone.Model(initial_value); + + self.innerModel.on('change', function() { + var val = _.clone(self.model.get('value')); + if ('key_code' in val) { + val['key_code'] = parseInt(val['key_code']) + } + self.model.set('value', + _.extend(val, this.toJSON()) + ); + }); + + self.controls = []; + }, + cleanup: function() { + _.each(this.controls, function(c) { + c.remove(); + }); + this.controls.length = 0; + }, + template: _.template([ + '', + '