Commit 4431c2c8d85175f546d6785d9343da9227725477
1 parent
9cd8fd0b88
Exists in
master
and in
1 other branch
Cambios según codereview.
Showing
1 changed file
with
23 additions
and
14 deletions
Show diff stats
src/js/angular-on-screen-keyboard-directive.js
| ... | ... | @@ -15,11 +15,11 @@ angular.module('onScreenKeyboard', ['ngSanitize']) |
| 15 | 15 | |
| 16 | 16 | if (!ctrl.rows) { |
| 17 | 17 | ctrl.rows = [ |
| 18 | - ['1', '2', '3','4','5','6','7','8', '9', '0', { | |
| 18 | + ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0', { | |
| 19 | 19 | type: 'erase', colspan: 2, text: '⇐' |
| 20 | 20 | }], |
| 21 | - ['q','w','e','r','t','y','u','i','o','p','@'], | |
| 22 | - ['a','s','d','f','g','h','j','k','l','-','_', {type: 'margin'}], | |
| 21 | + ['q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', '@'], | |
| 22 | + ['a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', '-', '_', {type: 'margin'}], | |
| 23 | 23 | [ |
| 24 | 24 | {type: 'shift', upperCase: '⇓', lowerCase: '⇑'}, |
| 25 | 25 | 'z', 'x', 'c', 'v', 'b', 'n', 'm', ',', '.', |
| ... | ... | @@ -30,23 +30,28 @@ angular.module('onScreenKeyboard', ['ngSanitize']) |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | ctrl.getText = function(key) { |
| 33 | - if (key.type === 'margin') | |
| 33 | + if (key.type === 'margin') { | |
| 34 | 34 | return ''; |
| 35 | + } | |
| 35 | 36 | |
| 36 | 37 | var val = ''; |
| 37 | 38 | |
| 38 | - if (key.text) | |
| 39 | + if (key.text) { | |
| 39 | 40 | val = key.text; |
| 40 | - else if (key.lowerCase && !ctrl.isUpperCase) | |
| 41 | + } | |
| 42 | + else if (key.lowerCase && !ctrl.isUpperCase) { | |
| 41 | 43 | val = key.lowerCase; |
| 42 | - else if (key.upperCase && ctrl.isUpperCase) | |
| 44 | + } | |
| 45 | + else if (key.upperCase && ctrl.isUpperCase) { | |
| 43 | 46 | val = key.upperCase; |
| 47 | + } | |
| 44 | 48 | else { |
| 45 | 49 | val = ctrl.isUpperCase ? key.toUpperCase() : key.toLowerCase(); |
| 46 | 50 | } |
| 47 | 51 | |
| 48 | - if (val && val.indexOf('&') > -1) | |
| 52 | + if (val && val.indexOf('&') > -1) { | |
| 49 | 53 | return $sce.trustAsHtml(val); |
| 54 | + } | |
| 50 | 55 | |
| 51 | 56 | return val; |
| 52 | 57 | }; |
| ... | ... | @@ -66,8 +71,9 @@ angular.module('onScreenKeyboard', ['ngSanitize']) |
| 66 | 71 | |
| 67 | 72 | ctrl.printKeyStroke = function(key, event) { |
| 68 | 73 | |
| 69 | - if (!ctrl.lastInputCtrl) | |
| 74 | + if (!ctrl.lastInputCtrl) { | |
| 70 | 75 | return; |
| 76 | + } | |
| 71 | 77 | |
| 72 | 78 | ctrl.startPos = ctrl.lastInputCtrl.selectionStart; |
| 73 | 79 | ctrl.endPos = ctrl.lastInputCtrl.selectionEnd; |
| ... | ... | @@ -101,8 +107,9 @@ angular.module('onScreenKeyboard', ['ngSanitize']) |
| 101 | 107 | }; |
| 102 | 108 | |
| 103 | 109 | ctrl.eraseKeyStroke = function() { |
| 104 | - if (!ctrl.lastInputCtrl) | |
| 110 | + if (!ctrl.lastInputCtrl) { | |
| 105 | 111 | return; |
| 112 | + } | |
| 106 | 113 | |
| 107 | 114 | var hasSel = ctrl.startPos !== ctrl.endPos; |
| 108 | 115 | |
| ... | ... | @@ -132,16 +139,18 @@ angular.module('onScreenKeyboard', ['ngSanitize']) |
| 132 | 139 | ctrl.isUpperCase = true; |
| 133 | 140 | return; |
| 134 | 141 | } |
| 135 | - else if (ctrl.lastInputCtrl.className && ctrl.isUpperCase) | |
| 142 | + else if (ctrl.lastInputCtrl.className && ctrl.isUpperCase) { | |
| 136 | 143 | ctrl.isUpperCase = true; |
| 144 | + } | |
| 137 | 145 | else if (angular.element(ctrl.lastInputCtrl).val().length === 0) { |
| 138 | 146 | ctrl.isUpperCase = true; |
| 139 | 147 | } |
| 140 | 148 | else if ( |
| 141 | 149 | angular.element(ctrl.lastInputCtrl).val().slice(-1) === ' ' && |
| 142 | 150 | !ctrl.isUpperCase && attr.uppercaseAllWords !== undefined |
| 143 | - ) | |
| 151 | + ) { | |
| 144 | 152 | ctrl.isUpperCase = true; |
| 153 | + } | |
| 145 | 154 | else{ |
| 146 | 155 | ctrl.isUpperCase = true; |
| 147 | 156 | } |
| ... | ... | @@ -183,8 +192,8 @@ angular.module('onScreenKeyboard', ['ngSanitize']) |
| 183 | 192 | |
| 184 | 193 | $timeout(function() { |
| 185 | 194 | ctrl.isUpperCase = true; |
| 186 | - },0); | |
| 195 | + }, 0); | |
| 187 | 196 | }, |
| 188 | 197 | templateUrl: 'src/views/angular-on-screen-keyboard.html' |
| 189 | 198 | }; |
| 190 | - }]); | |
| 191 | 199 | \ No newline at end of file |
| 200 | + }]); |