Skip to content

Commit 7da974e

Browse files
committed
Merge branch 'release/0.4.2'
This fixes the-darc#10, fixes the-darc#13
2 parents 350201a + e7b52dd commit 7da974e

10 files changed

Lines changed: 123 additions & 37 deletions

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
<a name"0.4.2"></a>
2+
### 0.4.2 (2015-07-21)
3+
4+
5+
#### Bug Fixes
6+
7+
* **VKI_CONFIG:** exposes sizeAdj configuration (issue #13) ([37e5230f](https://github.com/the-darc/angular-virtual-keyboard/commit/37e5230f))
8+
* **auto-close:** auto-close others VKIs when a new one is focused (issue #10) ([8bf63d74](https://github.com/the-darc/angular-virtual-keyboard/commit/8bf63d74))
9+
* **focus:** keep input focus when keyboard buttons (like shift, alt, caps, and others..) are ([f3b4f3c0](https://github.com/the-darc/angular-virtual-keyboard/commit/f3b4f3c0))
10+
11+
112
<a name"0.4.1"></a>
213
### 0.4.1 (2015-05-11)
314

README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,12 @@ _Obs.: Required to auto-hide the keyboard interface in mobile devices or to use
3636

3737
The angular-virtual-keyboard module use an [Angular.js Constant](https://docs.angularjs.org/api/auto/service/$provide#constant) named ``VKI_CONFIG`` to handle the configurations that will be applied to all instances of the ``ng-virtual-keyboard`` directive. See list below:
3838

39-
- __Keyboard layouts configurations__ ``VKI_CONFIG.layout``: Array of Keyboard Layout configurations. See [vki-layouts.js](https://github.com/the-darc/angular-virtual-keyboard/blob/master/src/vki-layouts.js) for keyboard layout configuration examples.
39+
- __Keyboard layouts configurations__ ``VKI_CONFIG.layout`` Array of Keyboard Layout configurations. See [vki-layouts.js](https://github.com/the-darc/angular-virtual-keyboard/blob/master/src/vki-layouts.js) for keyboard layout configuration examples.
4040
- __Deadkeys configurations__ ``VKI_CONFIG.deadkey`` Array of Deadkeys configurations. See [vki-deadkeys.js](https://github.com/the-darc/angular-virtual-keyboard/blob/master/src/vki-deadkeys.js) for deadkeys configuration examples.
4141
- __Default keyboard layout__ ``VKI_CONFIG.kt`` Name of the layout configuration to be used as default (if no specific layout configuration is provided in the directive instance configuration). _Default: 'US International'_
42-
- __Relative position__ ``VKI_CONFIG.relative``: ``true`` to position the keyboard next to the input, ``false`` to place in the bottom of page. _Default: ``true``_
43-
- __i18n configuration__ ``VKI_CONFIG.i18n``: An array to replace the default labels of the keyboard interface. See example below:
42+
- __Relative position__ ``VKI_CONFIG.relative`` Use ``true`` to position the keyboard next to the input, ``false`` to place in the bottom of page. _Default: ``true``_
43+
- __Adjust keyboard size__ ``VKI_CONFIG.sizeAdj`` Allow user to adjust keyboard size. _Default: ``true``_
44+
- __i18n configuration__ ``VKI_CONFIG.i18n`` An array to replace the default labels of the keyboard interface. See example below:
4445
```javascript
4546
VKI_CONFIG.i18n = {
4647
'00': "Exibir teclado numérico",
@@ -67,11 +68,12 @@ The ``ng-virtual-keyboard`` could receive an array with the configurations that
6768
- __Number pad__ ``numberPad`` To enable de number pad button. _Default: false_
6869
- __VKI Version__ ``showVersion`` To show the VKI-core based version. _Default: false_
6970
- __Imageless mode__ ``imageURI`` By default the keyboard will be show on input field focus. Pass a image URI to add a clickable image next to inputs and replace the on focus default behavior. _Default: false_
70-
- __Keyboard size control__ ``size`` Five sizes based on font-size have been pre-programmed: 13px, 16px (default), 20px, 24px and 28px; corresponding to the sizes 1 to 5 respectively. _Default: 3_
7171
- __Show in mobile__ ``showInMobile`` True to display the interface on mobiles devices. _Default: false_
7272
- __Foce position__ ``forcePosition`` Force to position the virtual keyborad above (_use ``"top"``_) or below (_use ``"bottom"``_) the input field. Use ``false`` to let the directive choose the better position. _Default: false_
7373
- __Enter callback__ ``enterSubmit`` Define a callback function for the enter key. Use ~~true to submit forms when Enter is pressed or~~ a function to execute a custom function. _Default: false_ (See _[enterSubmit issues #5](https://github.com/the-darc/angular-virtual-keyboard/issues/5)_)
74-
- __Relative position__ ``relative``: ``true`` to position the keyboard next to the input, ``false`` to place in the bottom of page. _Default: ``true``_
74+
- __Relative position__ ``relative`` Use ``true`` to position the keyboard next to the input, and ``false`` to place in the bottom of page. _Default: ``true``_
75+
- __Keyboard size control__ ``size`` Five sizes based on font-size have been pre-programmed: 13px, 16px (default), 20px, 24px and 28px; corresponding to the sizes 1 to 5 respectively. _Default: 3_
76+
- __Adjust keyboard size__ ``sizeAdj`` Allow user to adjust keyboard size. _Default: ``true``_
7577

7678
### Example of use
7779

bower.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
{
22
"name": "angular-virtual-keyboard",
3-
"version": "0.4.1",
3+
"version": "0.4.2",
44
"homepage": "https://github.com/the-darc/angular-virtual-keyboard",
5-
"authors": [
6-
"the-darc <darc.tec@gmail.com>"
7-
],
5+
"author": "the-darc <darc.tec@gmail.com>",
86
"description": "An AngularJs Virtual Keyboard Interface based on GreyWyvern VKI",
97
"main": "release/angular-virtual-keyboard.min.js",
108
"keywords": [

demo/index.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
// };
4747

4848
// VKI_CONFIG.relative = true;
49+
// VKI_CONFIG.sizeAdj = false;
4950
}])
5051
.controller('ExampleCtrl', ['$scope', function($scope){
5152
// Your controller code comes here
@@ -141,6 +142,12 @@ <h4>E-mail field</h4>
141142
<label>Input e-mail: </label><input type='email' ng-model="t012" ng-virtual-keyboard="{kt: 'US International', numberPad: true, showVersion: true, relative: false}"/><br>
142143
<em>(Model value: {{t012}})</em>
143144
</div>
145+
146+
<h4>Textarea fields</h4>
147+
<div>
148+
<label>Input e-mail: </label><textarea ng-model="t013" ng-virtual-keyboard="{kt: 'US International', numberPad: true, showVersion: true, sizeAdj: false}"/><br>
149+
<em>(Model value: {{t013}})</em>
150+
</div>
144151
</div>
145152
</body>
146153
</html>

gulpfile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ gulp.task('build', function() {
2525
' * <%= pkg.name %>',
2626
' * <%= pkg.description %>',
2727
' * @version v<%= pkg.version %>',
28-
' * @author <%= pkg.authors[0]%>',
28+
' * @author <%= pkg.author %>',
2929
' * @link <%= pkg.homepage %>',
3030
' * @license <%= pkg.license %>',
3131
' */',

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-virtual-keyboard",
3-
"version": "0.4.1",
3+
"version": "0.4.2",
44
"description": "",
55
"main": "index.js",
66
"scripts": {

release/angular-virtual-keyboard.js

Lines changed: 47 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* angular-virtual-keyboard
33
* An AngularJs Virtual Keyboard Interface based on GreyWyvern VKI
4-
* @version v0.4.1
4+
* @version v0.4.2
55
* @author the-darc <darc.tec@gmail.com>
66
* @link https://github.com/the-darc/angular-virtual-keyboard
77
* @license MIT
@@ -79,7 +79,7 @@ var VKI = function(customConfig, layout, deadKeys, keyInputCallback) {
7979
this.VKI_kts = this.VKI_kt = config.kt || 'US International'; // Default keyboard layout
8080
this.VKI_langAdapt = !config.kt; // Use lang attribute of input to select keyboard (Will be used if no keyboard layout was defined in custom config)
8181
this.VKI_size = config.size >=1 && config.size <= 5 ? config.size : 3; // Default keyboard size (1-5)
82-
this.VKI_sizeAdj = true; // Allow user to adjust keyboard size
82+
this.VKI_sizeAdj = config.sizeAdj === false ? false : true; // Allow user to adjust keyboard size
8383
this.VKI_clearPasswords = false; // Clear password fields on focus
8484
this.VKI_imageURI = config.imageURI !== undefined ? config.imageURI : ""; // If empty string, use imageless mode
8585
this.VKI_clickless = 0; // 0 = disabled, > 0 = delay in ms
@@ -214,7 +214,7 @@ var VKI = function(customConfig, layout, deadKeys, keyInputCallback) {
214214
} else {
215215
elem.onfocus = function() {
216216
if (self.VKI_target != this) {
217-
if (self.VKI_target) self.VKI_close();
217+
if (self.VKI_target) self.VKI_close(false);
218218
self.VKI_show(this);
219219
}
220220
};
@@ -238,7 +238,10 @@ var VKI = function(customConfig, layout, deadKeys, keyInputCallback) {
238238
if (self.VKI_isMoz)
239239
elem.addEventListener('blur', function() { this.setAttribute('_scrollTop', this.scrollTop); }, false);
240240

241-
VKI_addListener(document.documentElement, 'click', function(e) { self.VKI_close(); }, false);
241+
VKI_addListener(document.documentElement, 'click', function(e) { self.VKI_close(false); }, false);
242+
243+
// Attach close event handler.
244+
angular.element(elem).bind('VKI_close', function(){self.VKI_close(false);});
242245
};
243246

244247

@@ -365,6 +368,7 @@ var VKI = function(customConfig, layout, deadKeys, keyInputCallback) {
365368
VKI_addListener(span, 'click', function() {
366369
kbNumpad.style.display = (!kbNumpad.style.display) ? "none" : "";
367370
self.VKI_position(true);
371+
self.VKI_target.focus();
368372
}, false);
369373
VKI_mouseEvents(span);
370374
th.appendChild(span);
@@ -383,6 +387,7 @@ var VKI = function(customConfig, layout, deadKeys, keyInputCallback) {
383387
VKI_addListener(small, 'click', function() {
384388
--self.VKI_size;
385389
self.VKI_kbsize();
390+
self.VKI_target.focus();
386391
}, false);
387392
VKI_mouseEvents(small);
388393
small.appendChild(document.createTextNode(this.VKI_isIElt8 ? "\u2193" : "\u21d3"));
@@ -392,6 +397,7 @@ var VKI = function(customConfig, layout, deadKeys, keyInputCallback) {
392397
VKI_addListener(big, 'click', function() {
393398
++self.VKI_size;
394399
self.VKI_kbsize();
400+
self.VKI_target.focus();
395401
}, false);
396402
VKI_mouseEvents(big);
397403
big.appendChild(document.createTextNode(this.VKI_isIElt8 ? "\u2191" : "\u21d1"));
@@ -413,7 +419,7 @@ var VKI = function(customConfig, layout, deadKeys, keyInputCallback) {
413419
var strong = document.createElement('strong');
414420
strong.appendChild(document.createTextNode('X'));
415421
strong.title = this.VKI_i18n['06'];
416-
VKI_addListener(strong, 'click', function() { self.VKI_close(); }, false);
422+
VKI_addListener(strong, 'click', function() { self.VKI_close(true); }, false);
417423
VKI_mouseEvents(strong);
418424
th.appendChild(strong);
419425

@@ -582,7 +588,7 @@ var VKI = function(customConfig, layout, deadKeys, keyInputCallback) {
582588
if (self.VKI_activeTab) {
583589
if (self.VKI_target.form) {
584590
var target = self.VKI_target, elems = target.form.elements;
585-
self.VKI_close();
591+
self.VKI_close(false);
586592
for (var z = 0, me = false, j = -1; z < elems.length; z++) {
587593
if (j == -1 && elems[z].getAttribute("VKI_attached")) j = z;
588594
if (me) {
@@ -630,7 +636,7 @@ var VKI = function(customConfig, layout, deadKeys, keyInputCallback) {
630636
if (self.VKI_target.form.elements[z].type == "submit") subm = true;
631637
if (!subm) self.VKI_target.form.submit();
632638
}
633-
self.VKI_close();
639+
self.VKI_close(false);
634640
} else self.VKI_insert("\n");
635641
return true;
636642
}, false);
@@ -686,17 +692,25 @@ var VKI = function(customConfig, layout, deadKeys, keyInputCallback) {
686692
case "Alt":
687693
case "AltGr":
688694
if (this.VKI_altgr) className.push("pressed");
695+
self.VKI_target.focus();
689696
break;
690697
case "AltLk":
691698
if (this.VKI_altgrlock) className.push("pressed");
699+
self.VKI_target.focus();
692700
break;
693701
case "Shift":
694702
if (this.VKI_shift) className.push("pressed");
703+
self.VKI_target.focus();
695704
break;
696705
case "Caps":
697706
if (this.VKI_shiftlock) className.push("pressed");
707+
self.VKI_target.focus();
698708
break;
699-
case "Tab": case "Enter": case "Bksp": break;
709+
case "Tab":
710+
case "Bksp":
711+
self.VKI_target.focus();
712+
case "Enter":
713+
break;
700714
default:
701715
if (type) {
702716
tds[y].removeChild(tds[y].firstChild);
@@ -801,9 +815,25 @@ var VKI = function(customConfig, layout, deadKeys, keyInputCallback) {
801815
if (self.VKI_isMoz || self.VKI_isWebKit) this.VKI_position(true);
802816
this.VKI_target.blur();
803817
this.VKI_target.focus();
804-
} else this.VKI_close();
818+
819+
this.VKI_closeOthers();
820+
} else this.VKI_close(false);
805821
};
806822

823+
/* ****************************************************************
824+
* For triggering close to non-focused virtual keyboard elements
825+
*
826+
*/
827+
this.VKI_closeOthers = function() {
828+
function fireCloseEvent(angularElement) {
829+
if(angularElement.getAttribute('VKI_attached') === 'true' && !angular.equals(self.VKI_target, angularElement)) {
830+
var inputChild = angular.element(angularElement);
831+
inputChild.triggerHandler('VKI_close');
832+
}
833+
}
834+
angular.forEach(angular.element(document).find('input'), fireCloseEvent);
835+
angular.forEach(angular.element(document).find('textarea'), fireCloseEvent);
836+
};
807837

808838
/* ****************************************************************
809839
* Position the keyboard
@@ -865,7 +895,7 @@ var VKI = function(customConfig, layout, deadKeys, keyInputCallback) {
865895
* Close the keyboard interface
866896
*
867897
*/
868-
this.VKI_close = function() {
898+
this.VKI_close = function(keepFocus) {
869899
if (this.VKI_target) {
870900
try {
871901
this.VKI_keyboard.parentNode.removeChild(this.VKI_keyboard);
@@ -877,7 +907,9 @@ var VKI = function(customConfig, layout, deadKeys, keyInputCallback) {
877907
this.VKI_buildKeys();
878908
} kbSelect.getElementsByTagName('ol')[0].style.display = "";;
879909
}
880-
this.VKI_target.focus();
910+
if (keepFocus) {
911+
this.VKI_target.focus();
912+
}
881913
if (this.VKI_isIE) {
882914
setTimeout(function() { self.VKI_target = false; }, 0);
883915
} else this.VKI_target = false;
@@ -957,7 +989,7 @@ var VKI = function(customConfig, layout, deadKeys, keyInputCallback) {
957989
// if (ex.nodeName == "TEXTAREA" || ex.type == "text" || ex.type == "password")
958990
// if (ex.className.indexOf("keyboardInput") > -1) self.VKI_attach(ex);
959991

960-
// VKI_addListener(document.documentElement, 'click', function(e) { self.VKI_close(); }, false);
992+
// VKI_addListener(document.documentElement, 'click', function(e) { self.VKI_close(true); }, false);
961993
// }
962994
// VKI_addListener(window, 'load', VKI_buildKeyboardInputs, false);
963995

@@ -1029,7 +1061,8 @@ angular.module('angular-virtual-keyboard', [])
10291061
'10': 'Decrease keyboard size',
10301062
'11': 'Increase keyboard size'
10311063
},
1032-
relative: true
1064+
relative: true,
1065+
sizeAdj: true
10331066
})
10341067
.service('ngVirtualKeyboardService', ['VKI_CONFIG', function(VKI_CONFIG) {
10351068
/*globals VKI */
@@ -1040,6 +1073,7 @@ angular.module('angular-virtual-keyboard', [])
10401073
config.kt = config.kt || VKI_CONFIG.kt;
10411074
config.relative = config.relative === false ? false : VKI_CONFIG.relative;
10421075
config.keyCenter = config.keyCenter || VKI_CONFIG.keyCenter;
1076+
config.sizeAdj = config.sizeAdj === false ? false : VKI_CONFIG.sizeAdj;
10431077

10441078
var vki = new VKI(config, VKI_CONFIG.layout, VKI_CONFIG.deadkey, inputCallback);
10451079
vki.attachVki(element);

release/angular-virtual-keyboard.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/angular-virtual-keyboard.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ angular.module('angular-virtual-keyboard', [])
6060
'10': 'Decrease keyboard size',
6161
'11': 'Increase keyboard size'
6262
},
63-
relative: true
63+
relative: true,
64+
sizeAdj: true
6465
})
6566
.service('ngVirtualKeyboardService', ['VKI_CONFIG', function(VKI_CONFIG) {
6667
/*globals VKI */
@@ -71,6 +72,7 @@ angular.module('angular-virtual-keyboard', [])
7172
config.kt = config.kt || VKI_CONFIG.kt;
7273
config.relative = config.relative === false ? false : VKI_CONFIG.relative;
7374
config.keyCenter = config.keyCenter || VKI_CONFIG.keyCenter;
75+
config.sizeAdj = config.sizeAdj === false ? false : VKI_CONFIG.sizeAdj;
7476

7577
var vki = new VKI(config, VKI_CONFIG.layout, VKI_CONFIG.deadkey, inputCallback);
7678
vki.attachVki(element);

0 commit comments

Comments
 (0)