Browse files

invalid inputs won't break the keyboard

  • Loading branch information...
1 parent 2b6f83a commit 02c5d67dc14ff6639f9dc9c1bb64ee1455678614 @Mottie committed Apr 30, 2012
Showing with 16 additions and 63 deletions.
  1. +7 −57 README.markdown
  2. +5 −2 js/jquery.keyboard.js
  3. +3 −3 js/jquery.keyboard.min.js
  4. +1 −1 package.json
View
64 README.markdown
@@ -72,6 +72,13 @@ Moved to the Wiki Pages: [Home](https://github.com/Mottie/Keyboard/wiki/Home) |
Only the latest changes will be shown below, see the wiki log to view older versions.
+### Version 1.9.16 (4/30/2012)
+
+* Caret position is now better retained in older IE. Fix for [issue #61](https://github.com/Mottie/Keyboard/issues/61).
+* Invalid input should now revert back to the last valid input instead of breaking the keyboard. Fix for [issue #62](https://github.com/Mottie/Keyboard/issues/62).
+* The repeating key obtained by holding down the mouse on a virtual key can now be disabled by setting the `repeatRate` to `0` (zero). Fix for [issue #63](https://github.com/Mottie/Keyboard/issues/63).
+* Clicking on a virtual keyboard key will no longer submit a form - fix for [issue #64](https://github.com/Mottie/Keyboard/issues/64).
+
### Version 1.9.15
* Updated Mobile demo
@@ -91,60 +98,3 @@ Only the latest changes will be shown below, see the wiki log to view older vers
### Version 1.9.12.1
* Updated jquery.mousewheel.js, as the it was only scrolling in one direction.
-
-### Version 1.9.12
-
-* Fixed an issue with an internal caret positioning flag not being set correctly. This change also fixes [issue #57](https://github.com/Mottie/Keyboard/issues/57).
-
-### Version 1.9.11
-
-* Updated mobile extension
- * It now works with jQuery Mobile v1.0.1.
- * The extension no longer uses the mobile buttonMarkup function, it just applies the css class names.
- * Added a hover button option and theme selector.
- * I don't think I'll support the Mobile theme selector because it's not a bookmarklet like I thought it would be. But please feel free to point the mobile stylesheet to a custom mobile theme. The extension will support any of the theme letters (A through whatever).
-* Caret position is now saved
- * This started as a fix for all versions of IE, but now applies to Firefox and Opera. It's not working in Webkit (Chrome & Safari) for some reason.
- * When clicking in an input, the keyboard will now open with a new preview window showing or with the existing input with the caret in the position where it was clicked in the text.
- * Hidden inputs will remember the last caret position when revealed.
- * Fix for the new issue added into [issue #24](https://github.com/Mottie/Keyboard/issues/24).
-
-### Version 1.9.10
-
-* Fixed an issue with using `jQuery.noConflict()` in older IE. Fix for [issue #55](https://github.com/Mottie/Keyboard/issues/55).
-* Added two Hungarian (Magyar) keyboard layouts. Thanks to Tóth Gergely for sharing - from [issue #48](https://github.com/Mottie/Keyboard/issues/48).
-* Fixed a problem with IE8 and hidden inputs. Apparently the original IE8 and not IE9 in compatibility mode has this problem. Thanks to Chris Mullins in [issue #56](https://github.com/Mottie/Keyboard/issues/56).
-
-### Version 1.9.9
-
-* Fixed an issue with the enter key that was introduced in 1.9.8 - sorry!
-* The way the key spacer `{sp:#}` is added has changed:
- * In older versions, a span of zero dimensions with a side margin of #em was added, i.e. `{sp:1}` would add a "margin: 0 1em" which adds 1em to the left and right making it 2em wide.
- * Because newer versions of Firefox do not seem to render a zero dimension span at all, the plugin now sets the span width.
- * A `{sp:1}` setting now becomes a span of "2em" width, to keep this consistent with the way this method worked previously.
- * In case this causes problems, one additional change was made so the space can now be set using pixels: `{sp:20px}` which makes the width 20 pixels.
- * Additionally, non-western formats are now supported. Using `{sp:1,5}` or `{sp:1,5em}` will set the span to 3em's in width.
- * This will fix the problem brought up in [issue #48](https://github.com/Mottie/Keyboard/issues/48).
-
-### Version 1.9.8
-
-* Pressing the real keyboard enter key will now use the `$.keyboard.keyaction.enter` function. Discussed in [issue #47](https://github.com/Mottie/Keyboard/issues/47).
-* Updated all demos to use jQuery 1.7+.
-
-### Version 1.9.7
-
-* Fixed a problem with the mouse up event not returning focus to the input, possible fix for [issue #45](https://github.com/Mottie/Keyboard/issues/45).
-* Changed `acceptValid` default value from `true` to `false`.
-* Updated link to jQuery Mobile from 1.0rc1 to 1.0.
-* Added package.json in anticipation of the [jQuery plugin](http://plugins.jquery.com/) site.
-
-### Version 1.9.6
-
-* Added `acceptValid` option
- * When true, all input is continually checked using the `validate` callback function, if valid, then the accept button is enabled; otherwise it is disabled.
- * When false, the input is not checked after each input; but the `validate` callback is still called when the input is accepted.
- * Added a "disabled" class to the css which is applied to the accept button when disabled.
-* Changed the `validate` callback function
- * It no longer automatically triggers the "canceled" event, you can do that within the callback.
- * If the input is invalid and the keyboard is closed/canceled, the `validate` callback will no longer abort the close.
- * Added an `isClosing` variable which is only `true` when the content was accepted. The `isClosing` variable is `false` when the validate callback is called during input.
View
7 js/jquery.keyboard.js
@@ -1,6 +1,6 @@
/*!
jQuery UI Virtual Keyboard
-Version 1.9.15
+Version 1.9.16
Author: Jeremy Satterfield
Modified: Rob Garrison (Mottie on github)
@@ -731,7 +731,10 @@ $.keyboard = function(el, options){
clearTimeout(base.throttled);
var val = (accepted) ? base.checkCombos() : base.originalContent;
// validate input if accepted
- if (accepted && o.validate && typeof(o.validate) === "function" && !o.validate(base, val, true)) { return; }
+ if (accepted && o.validate && typeof(o.validate) === "function" && !o.validate(base, val, true)) {
+ val = base.originalContent;
+ accepted = false;
+ }
base.isCurrent = false;
base.$el
.removeClass('ui-keyboard-input-current')
View
6 js/jquery.keyboard.min.js
@@ -1,6 +1,6 @@
/*!
jQuery UI Virtual Keyboard
-Version 1.9.15 minified
+Version 1.9.16 minified
Author: Jeremy Satterfield
Modified: Rob Garrison (Mottie on github)
@@ -12,6 +12,6 @@ Licensed under the MIT License:
http://www.opensource.org/licenses/mit-license.php
-----------------------------------------
*/
-;(function(c){c.keyboard=function(f,l){var a=this,d;a.$el=c(f);a.el=f;a.$el.data("keyboard",a);a.init=function(){a.options=d=c.extend(!0,{},c.keyboard.defaultOptions,l);a.shiftActive=a.altActive=a.metaActive=a.sets=a.capsLock=!1;a.lastKeyset=[!1,!1,!1];a.rows=["","-shift","-alt","-alt-shift"];a.acceptedKeys=[];a.mappedKeys={};c('<\!--[if lte IE 8]><script>jQuery("body").addClass("oldie");<\/script><![endif]--\><\!--[if IE]><script>jQuery("body").addClass("ie");<\/script><![endif]--\>').appendTo("body").remove(); a.msie=c("body").hasClass("oldie");a.allie=c("body").hasClass("ie");a.inPlaceholder=a.$el.attr("placeholder")||"";a.watermark="undefined"!==typeof document.createElement("input").placeholder&&""!==a.inPlaceholder;a.regex=c.keyboard.comboRegex;a.decimal=/^\./.test(d.display.dec)?!0:!1;a.repeatTime=1E3/d.repeatRate;a.temp=c('<input style="position:absolute;left:-9999em;top:-9999em;" type="text" value="testing">').appendTo("body").caret(3,3);a.checkCaret=d.lockInput||3!==a.temp.hide().show().caret().start? !0:!1;a.temp.remove();a.lastCaret={start:0,end:0};a.temp=["",0,0];c.each("initialized,visible,change,hidden,canceled,accepted,beforeClose".split(","),function(b,e){c.isFunction(d[e])&&a.$el.bind(e+".keyboard",d[e])});d.alwaysOpen&&(d.stayOpen=!0);d.stayOpen||c(document).bind("mousedown.keyboard keyup.keyboard",function(b){a.escClose(b)});a.$el.addClass("ui-keyboard-input "+d.css.input).attr({"aria-haspopup":"true",role:"textbox"});(a.$el.is(":disabled")||a.$el.attr("readonly"))&&a.$el.addClass("ui-keyboard-nokeyboard"); d.openOn&&a.$el.bind(d.openOn+".keyboard",function(){a.focusOn()});!a.watermark&&""===a.$el.val()&&""!==a.inPlaceholder&&""!==a.$el.attr("placeholder")&&a.$el.addClass("ui-keyboard-placeholder").val(a.inPlaceholder);a.$el.trigger("initialized.keyboard",[a,a.el]);d.alwaysOpen&&a.reveal()};a.focusOn=function(){a.$el.is(":visible")&&(a.lastCaret=a.$el.caret());if(!a.isVisible||d.alwaysOpen)clearTimeout(a.timer),a.reveal(),setTimeout(function(){a.$preview.focus()},100)};a.reveal=function(){c(".ui-keyboard:not(.ui-keyboard-always-open)").hide(); if(a.$el.is(":disabled")||a.$el.attr("readonly"))a.$el.addClass("ui-keyboard-nokeyboard");else{a.$el.removeClass("ui-keyboard-nokeyboard");a.$el.unbind(d.openOn?d.openOn+".keyboard":"");"undefined"===typeof a.$keyboard&&a.startup();c(".ui-keyboard-has-focus").removeClass("ui-keyboard-has-focus");c(".ui-keyboard-input-current").removeClass("ui-keyboard-input-current");a.$el.addClass("ui-keyboard-input-current");a.isCurrent=!0;!a.watermark&&a.el.value===a.inPlaceholder&&a.$el.removeClass("ui-keyboard-placeholder").val(""); a.originalContent=a.$el.val();a.$preview.val(a.originalContent);d.acceptValid&&a.checkValid();var b,e=d.position;e.of=e.of||a.$el.data("keyboardPosition")||a.$el;e.collision=d.usePreview?e.collision||"fit fit":"flip flip";a.$keyboard.css({position:"absolute",left:0,top:0}).addClass("ui-keyboard-has-focus").show();d.usePreview&&a.msie&&("undefined"===typeof a.width&&(a.$preview.hide(),a.width=Math.ceil(a.$keyboard.width()),a.$preview.show()),a.$preview.width(a.width));a.$keyboard.position(e);c(window).resize(function(){a.isVisible&& a.$keyboard.position(e)});a.$preview.focus();a.isVisible=!0;a.checkDecimal();a.lineHeight=parseInt(a.$preview.css("lineHeight"),10)||parseInt(a.$preview.css("font-size"),10)+4;if(a.allie&&(b=a.lastCaret.start||a.originalContent.length,b={start:b,end:b},a.lastCaret||(a.lastCaret=b),0===a.lastCaret.end&&0<a.lastCaret.start&&(a.lastCaret.end=a.lastCaret.start),0>a.lastCaret.start))a.lastCaret=b;a.$preview.caret(a.lastCaret.start,a.lastCaret.end);a.$el.trigger("visible.keyboard",[a,a.el]);return a}}; a.startup=function(){a.$keyboard=a.buildKeyboard();a.$allKeys=a.$keyboard.find("button.ui-keyboard-button");a.$preview=d.usePreview?a.$keyboard.find(".ui-keyboard-preview"):a.$el;a.preview=a.$preview[0];a.$decBtn=a.$keyboard.find(".ui-keyboard-dec");a.wheel=c.isFunction(c.fn.mousewheel);a.alwaysAllowed=[20,33,34,35,36,37,38,39,40,45,46];d.enterNavigation&&a.alwaysAllowed.push(13);a.$preview.bind("keypress.keyboard",function(b){var e=String.fromCharCode(b.charCode||b.which);a.checkCaret&&(a.lastCaret= a.$preview.caret());a.capsLock=65<=e&&90>=e&&!b.shiftKey||97<=e&&122>=e&&b.shiftKey?!0:!1;if(d.restrictInput){if((8===b.which||0===b.which)&&c.inArray(b.keyCode,a.alwaysAllowed))return;-1===c.inArray(e,a.acceptedKeys)&&b.preventDefault()}else if((b.ctrlKey||b.metaKey)&&(97===b.which||99===b.which||118===b.which||120<=b.which&&122>=b.which))return;a.hasMappedKeys&&a.mappedKeys.hasOwnProperty(e)&&(a.insertText(a.mappedKeys[e]),b.preventDefault());a.checkMaxLength()}).bind("keyup.keyboard",function(b){switch(b.which){case 9:a.tab&& !d.lockInput?(c.keyboard.keyaction.tab(a),a.tab=!1):b.preventDefault();break;case 27:return a.close(),!1}clearTimeout(a.throttled);a.throttled=setTimeout(function(){a.checkCombos()},100);a.checkMaxLength();a.$el.trigger("change.keyboard",[a,a.el])}).bind("keydown.keyboard",function(b){switch(b.which){case 9:if(d.tabNavigation)return!0;a.tab=!0;return!1;case 13:c.keyboard.keyaction.enter(a,null,b);break;case 20:a.shiftActive=a.capsLock=!a.capsLock;a.showKeySet(this);break;case 86:if(b.ctrlKey||b.metaKey){if(d.preventPaste){b.preventDefault(); break}a.checkCombos()}}}).bind("mouseup.keyboard",function(){a.checkCaret&&(a.lastCaret=a.$preview.caret())}).bind("blur.keyboard",function(b){if(d.alwaysOpen&&a.isCurrent)return b.target===a.el||c(b.target).closest(".ui-keyboard")[0]===a.$keyboard[0]?a.close(d.autoAccept):a.$preview.focus(),!1});d.preventPaste&&(a.$preview.bind("contextmenu.keyboard",function(a){a.preventDefault()}),a.$el.bind("contextmenu.keyboard",function(a){a.preventDefault()}));d.appendLocally?a.$el.after(a.$keyboard):a.$keyboard.appendTo("body"); a.$allKeys.bind(d.keyBinding.split(" ").join(".keyboard ")+".keyboard repeater.keyboard",function(b){var e;e=c.data(this,"key");var k=e.action.split(":")[0];a.$preview.focus();a.checkCaret&&a.$preview.caret(a.lastCaret.start,a.lastCaret.end);k.match("meta")&&(k="meta");if(c.keyboard.keyaction.hasOwnProperty(k)&&c(this).hasClass("ui-keyboard-actionkey")){if(c.keyboard.keyaction[k](a,this,b)===false)return}else if(typeof e.action!=="undefined"){e=a.wheel&&!c(this).hasClass("ui-keyboard-actionkey")? e.curTxt:e.action;a.insertText(e);if(!a.capsLock&&!d.stickyShift&&!b.shiftKey){a.shiftActive=false;a.showKeySet(this)}}a.checkCombos();a.checkMaxLength();a.$el.trigger("change.keyboard",[a,a.el]);a.$preview.focus();b.preventDefault()}).bind("mouseenter.keyboard mouseleave.keyboard",function(b){var e=c(this),k=c.data(this,"key");b.type==="mouseenter"&&a.el.type!=="password"&&e.addClass(d.css.buttonHover).attr("title",function(b,e){return a.wheel&&e===""&&a.sets?d.wheelMessage:e});if(b.type==="mouseleave"){k.curTxt= k.original;k.curNum=0;c.data(this,"key",k);e.removeClass(a.el.type==="password"?"":d.css.buttonHover).attr("title",function(a,b){return b===d.wheelMessage?"":b}).find("span").text(k.original)}}).bind("mousewheel.keyboard",function(b,e){if(a.wheel){var d,f=c(this),g=c.data(this,"key");d=g.layers||a.getLayers(f);g.curNum=g.curNum+(e>0?-1:1);if(g.curNum>d.length-1)g.curNum=0;if(g.curNum<0)g.curNum=d.length-1;g.layers=d;g.curTxt=d[g.curNum];c.data(this,"key",g);f.find("span").text(d[g.curNum]);return false}}).bind("mouseup.keyboard mouseleave.kb touchend.kb touchmove.kb touchcancel.kb", function(){a.isVisible&&a.isCurrent&&a.$preview.focus();a.mouseRepeat=[false,""];return false}).filter(":not(.ui-keyboard-actionkey)").add(".ui-keyboard-tab, .ui-keyboard-bksp, .ui-keyboard-space, .ui-keyboard-enter",a.$keyboard).bind("mousedown.kb touchstart.kb",function(){var b=c(this);a.mouseRepeat=[true,b];setTimeout(function(){a.mouseRepeat[0]&&a.mouseRepeat[1]===b&&a.repeatKey(b)},d.repeatDelay);return false})};a.insertText=function(b){var d,f;f=a.$preview.val();var c=a.$preview.caret(),g=a.$preview.scrollLeft(); d=a.$preview.scrollTop();var h=f.length;c.end<c.start&&(c.end=c.start);c.start>h&&(c.end=c.start=h);"TEXTAREA"===a.preview.tagName&&(a.msie&&"\n"===f.substr(c.start,1)&&(c.start+=1,c.end+=1),f=f.split("\n").length-1,a.preview.scrollTop=0<f?a.lineHeight*f:d);d="bksp"===b&&c.start===c.end?!0:!1;b="bksp"===b?"":b;f=c.start+(d?-1:b.length);g+=parseInt(a.$preview.css("fontSize"),10)*("bksp"===b?-1:1);a.$preview.val(a.$preview.val().substr(0,c.start-(d?1:0))+b+a.$preview.val().substr(c.end)).caret(f,f).scrollLeft(g); a.checkCaret&&(a.lastCaret={start:f,end:f})};a.checkMaxLength=function(){var b,e=a.$preview.val();!1!==d.maxLength&&e.length>d.maxLength&&(b=Math.min(a.$preview.caret().start,d.maxLength),a.$preview.val(e.substring(0,d.maxLength)),a.$preview.caret(b,b),a.lastCaret={start:b,end:b});a.$decBtn.length&&a.checkDecimal()};a.repeatKey=function(b){b.trigger("repeater.keyboard");a.mouseRepeat[0]&&setTimeout(function(){a.repeatKey(b)},a.repeatTime)};a.showKeySet=function(b){var e="",c=(a.shiftActive?1:0)+(a.altActive? 2:0);a.shiftActive||(a.capsLock=!1);if(a.metaActive){if(e=b&&b.name&&/meta/.test(b.name)?b.name:"",""===e?e=!0===a.metaActive?"":a.metaActive:a.metaActive=e,!d.stickyShift&&a.lastKeyset[2]!==a.metaActive||(a.shiftActive||a.altActive)&&!a.$keyboard.find(".ui-keyboard-keyset-"+e+a.rows[c]).length)a.shiftActive=a.altActive=!1}else!d.stickyShift&&a.lastKeyset[2]!==a.metaActive&&a.shiftActive&&(a.shiftActive=a.altActive=!1);c=(a.shiftActive?1:0)+(a.altActive?2:0);e=0===c&&!a.metaActive?"-default":""=== e?"":"-"+e;a.$keyboard.find(".ui-keyboard-keyset"+e+a.rows[c]).length?(a.$keyboard.find(".ui-keyboard-alt, .ui-keyboard-shift, .ui-keyboard-actionkey[class*=meta]").removeClass(d.css.buttonAction).end().find(".ui-keyboard-alt")[a.altActive?"addClass":"removeClass"](d.css.buttonAction).end().find(".ui-keyboard-shift")[a.shiftActive?"addClass":"removeClass"](d.css.buttonAction).end().find(".ui-keyboard-lock")[a.capsLock?"addClass":"removeClass"](d.css.buttonAction).end().find(".ui-keyboard-keyset").hide().end().find(".ui-keyboard-keyset"+ e+a.rows[c]).show().end().find(".ui-keyboard-actionkey.ui-keyboard"+e).addClass(d.css.buttonAction),a.lastKeyset=[a.shiftActive,a.altActive,a.metaActive]):(a.shiftActive=a.lastKeyset[0],a.altActive=a.lastKeyset[1],a.metaActive=a.lastKeyset[2])};a.checkCombos=function(){var b,e,c,f,g=a.$preview.val(),h=a.$preview.caret(),j=g.length;h.end<h.start&&(h.end=h.start);h.start>j&&(h.end=h.start=j);a.msie&&"\n"===g.substr(h.start,1)&&(h.start+=1,h.end+=1);d.useCombos&&(g=g.replace(a.regex,function(a,b,e){return d.combos.hasOwnProperty(b)? d.combos[b][e]||a:a}));if(d.restrictInput&&""!==g){c=g;e=a.acceptedKeys.length;for(b=0;b<e;b++)""!==c&&(f=a.acceptedKeys[b],0<=g.indexOf(f)&&(/[\[|\]|\\|\^|\$|\.|\||\?|\*|\+|\(|\)|\{|\}]/g.test(f)&&(f="\\"+f),c=c.replace(RegExp(f,"g"),"")));""!==c&&(g=g.replace(c,""))}h.start+=g.length-j;h.end+=g.length-j;a.$preview.val(g);a.$preview.caret(h.start,h.end);a.preview.scrollTop=a.lineHeight*(g.substring(0,h.start).split("\n").length-1);a.lastCaret={start:h.start,end:h.end};d.acceptValid&&a.checkValid(); return g};a.checkValid=function(){var b=!0;d.validate&&"function"===typeof d.validate&&(b=d.validate(a,a.$preview.val(),!1));a.$keyboard.find(".ui-keyboard-accept")[b?"removeClass":"addClass"]("disabled")[b?"removeAttr":"attr"]("disabled","disabled").attr("aria-disabled",!b)};a.checkDecimal=function(){a.decimal&&/\./g.test(a.preview.value)||!a.decimal&&/\,/g.test(a.preview.value)?a.$decBtn.attr({disabled:"disabled","aria-disabled":"true"}).removeClass(d.css.buttonDefault+" "+d.css.buttonHover).addClass(d.css.buttonDisabled): a.$decBtn.removeAttr("disabled").attr({"aria-disabled":"false"}).addClass(d.css.buttonDefault).removeClass(d.css.buttonDisabled)};a.getLayers=function(a){var d;d=a.attr("data-pos");return a.closest(".ui-keyboard").find('button[data-pos="'+d+'"]').map(function(){return c(this).find("> span").text()}).get()};a.switchInput=function(b,e){if("function"===typeof d.switchInput)d.switchInput(a,b,e);else{a.close(e);var f=c(".ui-keyboard-input"),i=f.index(a.$el)+(b?1:-1);i>f.length-1&&(i=0);f.eq(i).focus()}return!1}; a.close=function(b){if(a.isVisible){clearTimeout(a.throttled);var e=b?a.checkCombos():a.originalContent;if(b&&d.validate&&"function"===typeof d.validate&&!d.validate(a,e,!0))return;a.isCurrent=!1;a.$el.removeClass("ui-keyboard-input-current").trigger(d.alwaysOpen?"":"beforeClose.keyboard",[a,a.el,b||!1]).val(e).scrollTop(a.el.scrollHeight).blur().trigger(b?"accepted.keyboard":"canceled.keyboard",[a,a.el]).trigger(d.alwaysOpen?"inactive.keyboard":"hidden.keyboard",[a,a.el]);d.openOn&&a.$el.bind(d.openOn+ ".keyboard",function(){a.focusOn()});d.alwaysOpen||(a.$keyboard.hide(),a.isVisible=!1);!a.watermark&&""===a.el.value&&""!==a.inPlaceholder&&a.$el.addClass("ui-keyboard-placeholder").val(a.inPlaceholder)}return!1};a.accept=function(){a.close(!0)};a.escClose=function(b){a.isVisible&&("keyup"===b.type&&27===b.which&&a.close(),"mousedown"===b.type&&b.target!==a.el&&c(b.target).closest(".ui-keyboard")[0]!==a.$keyboard[0]&&(a.allie&&b.preventDefault(),a.close(d.autoAccept)))};a.keyBtn=c("<button />").attr({role:"button", "aria-disabled":"false",tabindex:"-1"}).addClass("ui-keyboard-button");a.addKey=function(b,e,f){var i,g,h,e=!0===f?b:d.display[e]||b,j=!0===f?b.charCodeAt(0):b;/\(.+\)/.test(e)&&(g=e.replace(/\(([^()]+)\)/,""),i=e.match(/\(([^()]+)\)/)[1],e=g,h=g.split(":"),g=""!==h[0]&&1<h.length?h[0]:g,a.mappedKeys[i]=g);h=e.split(":");""===h[0]&&""===h[1]&&(e=":");e=""!==h[0]&&1<h.length?c.trim(h[0]):e;i=1<h.length?c.trim(h[1]).replace(/_/g," ")||"":"";g=1<e.length?" ui-keyboard-widekey":"";g+=f?"":" ui-keyboard-actionkey"; return a.keyBtn.clone().attr({"data-value":e,name:j,"data-pos":a.temp[1]+","+a.temp[2],title:i}).data("key",{action:b,original:e,curTxt:e,curNum:0}).addClass("ui-keyboard-"+j+g+" "+d.css.buttonDefault).html("<span>"+e+"</span>").appendTo(a.temp[0])};a.buildKeyboard=function(){var b,e,f,i,g,h,j,l=0,o=c("<div />").addClass("ui-keyboard "+d.css.container+(d.alwaysOpen?" ui-keyboard-always-open":"")).attr({role:"textbox"}).hide();d.usePreview?a.$preview=a.$el.clone(!1).removeAttr("id").removeClass("ui-keyboard-placeholder ui-keyboard-input").addClass("ui-keyboard-preview "+ d.css.input).attr("tabindex","-1").show():(a.$preview=a.$el,d.position.at=d.position.at2);a.$preview.attr(d.lockInput?{readonly:"readonly"}:{});d.usePreview&&c("<div />").addClass("ui-keyboard-preview-wrapper").append(a.$preview).appendTo(o);if("custom"===d.layout||!c.keyboard.layouts.hasOwnProperty(d.layout))d.layout="custom",c.keyboard.layouts.custom=d.customLayout||{"default":["{cancel}"]};c.each(c.keyboard.layouts[d.layout],function(n,p){if(n!==""){l++;f=c("<div />").attr("name",n).addClass("ui-keyboard-keyset ui-keyboard-keyset-"+ n).appendTo(o)[n==="default"?"show":"hide"]();for(e=0;e<p.length;e++){i=c.trim(p[e]).replace(/\{(\.?)[\s+]?:[\s+]?(\.?)\}/g,"{$1:$2}");h=i.split(/\s+/);for(g=0;g<h.length;g++){a.temp=[f,e,g];if(h[g].length!==0)if(/^\{\S+\}$/.test(h[g])){b=h[g].match(/^\{(\S+)\}$/)[1].toLowerCase();if(/^sp:((\d+)?([\.|,]\d+)?)(em|px)?$/.test(b)){j=parseFloat(b.replace(/,/,".").match(/^sp:((\d+)?([\.|,]\d+)?)(em|px)?$/)[1]||0);c("<span>&nbsp;</span>").width(b.match("px")?j+"px":j*2+"em").addClass("ui-keyboard-button ui-keyboard-spacer").appendTo(f)}if(/^meta\d+\:?(\w+)?/.test(b))a.addKey(b, b);else switch(b){case "a":case "accept":a.addKey("accept",b).addClass(d.css.buttonAction);break;case "alt":case "altgr":a.addKey("alt","alt");break;case "b":case "bksp":a.addKey("bksp",b);break;case "c":case "cancel":a.addKey("cancel",b).addClass(d.css.buttonAction);break;case "combo":a.addKey("combo","combo").addClass(d.css.buttonAction);break;case "dec":a.acceptedKeys.push(a.decimal?".":",");a.addKey("dec","dec");break;case "e":case "enter":a.addKey("enter",b).addClass(d.css.buttonAction);break; case "s":case "shift":a.addKey("shift",b);break;case "sign":a.acceptedKeys.push("-");a.addKey("sign","sign");break;case "space":a.acceptedKeys.push(" ");a.addKey("space","space");break;case "t":case "tab":a.addKey("tab",b);break;default:c.keyboard.keyaction.hasOwnProperty(b)&&a.addKey(b,b)}}else{a.acceptedKeys.push(h[g].split(":")[0]);a.addKey(h[g],h[g],true)}}f.find(".ui-keyboard-button:last").after('<br class="ui-keyboard-button-endrow">')}}});1<l&&(a.sets=!0);a.hasMappedKeys=!c.isEmptyObject(a.mappedKeys); return o};a.destroy=function(){c(document).unbind("mousedown.keyboard keyup.keyboard");a.$keyboard&&a.$keyboard.remove();var b=d.openOn+",accepted,beforeClose,blur,canceled,change,contextmenu,hidden,initialized,keydown,keypress,keyup,visible".split(",").join(".keyboard ");a.$el.removeClass("ui-keyboard-input ui-keyboard-placeholder ui-keyboard-notallowed ui-keyboard-always-open "+d.css.input).removeAttr("aria-haspopup").removeAttr("role").unbind(b+".keyboard").removeData("keyboard")};a.init()};c.keyboard.keyaction= {accept:function(f){f.close(!0);return!1},alt:function(f,c){f.altActive=!f.altActive;f.showKeySet(c)},bksp:function(f){f.insertText("bksp")},cancel:function(f){f.close();return!1},clear:function(f){f.$preview.val("")},combo:function(f){var c=!f.options.useCombos;f.options.useCombos=c;f.$keyboard.find(".ui-keyboard-combo")[c?"addClass":"removeClass"](f.options.css.buttonAction);c&&f.checkCombos();return!1},dec:function(c){c.insertText(c.decimal?".":",")},enter:function(f,l,a){var l=f.el.tagName,d= f.options;if(a.shiftKey)return d.enterNavigation?f.switchInput(!a[d.enterMod],!0):f.close(!0);if(d.enterNavigation&&("TEXTAREA"!==l||a[d.enterMod]))return f.switchInput(!a[d.enterMod],d.autoAccept);"TEXTAREA"===l&&c(a.target).closest("button").length&&f.insertText("\n")},lock:function(c,l){c.lastKeyset[0]=c.shiftActive=c.capsLock=!c.capsLock;c.showKeySet(l)},meta:function(f,l){f.metaActive=c(l).hasClass(f.options.css.buttonAction)?!1:!0;f.showKeySet(l)},shift:function(c,l){c.lastKeyset[0]=c.shiftActive= !c.shiftActive;c.showKeySet(l)},sign:function(c){/^\-?\d*\.?\d*$/.test(c.$preview.val())&&c.$preview.val(-1*c.$preview.val())},space:function(c){c.insertText(" ")},tab:function(c){if("INPUT"===c.el.tagName)return!1;c.insertText("\t")}};c.keyboard.layouts={alpha:{"default":["` 1 2 3 4 5 6 7 8 9 0 - = {bksp}","{tab} a b c d e f g h i j [ ] \\","k l m n o p q r s ; ' {enter}","{shift} t u v w x y z , . / {shift}","{accept} {space} {cancel}"],shift:["~ ! @ # $ % ^ & * ( ) _ + {bksp}","{tab} A B C D E F G H I J { } |", 'K L M N O P Q R S : " {enter}',"{shift} T U V W X Y Z < > ? {shift}","{accept} {space} {cancel}"]},qwerty:{"default":["` 1 2 3 4 5 6 7 8 9 0 - = {bksp}","{tab} q w e r t y u i o p [ ] \\","a s d f g h j k l ; ' {enter}","{shift} z x c v b n m , . / {shift}","{accept} {space} {cancel}"],shift:["~ ! @ # $ % ^ & * ( ) _ + {bksp}","{tab} Q W E R T Y U I O P { } |",'A S D F G H J K L : " {enter}',"{shift} Z X C V B N M < > ? {shift}","{accept} {space} {cancel}"]},international:{"default":["` 1 2 3 4 5 6 7 8 9 0 - = {bksp}", "{tab} q w e r t y u i o p [ ] \\","a s d f g h j k l ; ' {enter}","{shift} z x c v b n m , . / {shift}","{accept} {alt} {space} {alt} {cancel}"],shift:["~ ! @ # $ % ^ & * ( ) _ + {bksp}","{tab} Q W E R T Y U I O P { } |",'A S D F G H J K L : " {enter}',"{shift} Z X C V B N M < > ? {shift}","{accept} {alt} {space} {alt} {cancel}"],alt:["~ \u00a1 \u00b2 \u00b3 \u00a4 \u20ac \u00bc \u00bd \u00be \u2018 \u2019 \u00a5 \u00d7 {bksp}","{tab} \u00e4 \u00e5 \u00e9 \u00ae \u00fe \u00fc \u00fa \u00ed \u00f3 \u00f6 \u00ab \u00bb \u00ac", "\u00e1 \u00df \u00f0 f g h j k \u00f8 \u00b6 \u00b4 {enter}","{shift} \u00e6 x \u00a9 v b \u00f1 \u00b5 \u00e7 > \u00bf {shift}","{accept} {alt} {space} {alt} {cancel}"],"alt-shift":["~ \u00b9 \u00b2 \u00b3 \u00a3 \u20ac \u00bc \u00bd \u00be \u2018 \u2019 \u00a5 \u00f7 {bksp}","{tab} \u00c4 \u00c5 \u00c9 \u00ae \u00de \u00dc \u00da \u00cd \u00d3 \u00d6 \u00ab \u00bb \u00a6","\u00c4 \u00a7 \u00d0 F G H J K \u00d8 \u00b0 \u00a8 {enter}","{shift} \u00c6 X \u00a2 V B \u00d1 \u00b5 \u00c7 . \u00bf {shift}", "{accept} {alt} {space} {alt} {cancel}"]},dvorak:{"default":["` 1 2 3 4 5 6 7 8 9 0 [ ] {bksp}","{tab} ' , . p y f g c r l / = \\","a o e u i d h t n s - {enter}","{shift} ; q j k x b m w v z {shift}","{accept} {space} {cancel}"],shift:["~ ! @ # $ % ^ & * ( ) { } {bksp}",'{tab} " < > P Y F G C R L ? + |',"A O E U I D H T N S _ {enter}","{shift} : Q J K X B M W V Z {shift}","{accept} {space} {cancel}"]},num:{"default":"= ( ) {b},{clear} / * -,7 8 9 +,4 5 6 {sign},1 2 3 %,0 . {a} {c}".split(",")}}; c.keyboard.defaultOptions={layout:"qwerty",customLayout:null,position:{of:null,my:"center top",at:"center top",at2:"center bottom"},usePreview:!0,alwaysOpen:!1,stayOpen:!1,display:{a:"\u2714:Accept (Shift-Enter)",accept:"Accept:Accept (Shift-Enter)",alt:"AltGr:Alternate Graphemes",b:"\u2190:Backspace",bksp:"Bksp:Backspace",c:"\u2716:Cancel (Esc)",cancel:"Cancel:Cancel (Esc)",clear:"C:Clear",combo:"\u00f6:Toggle Combo Keys",dec:".:Decimal",e:"\u21b5:Enter",enter:"Enter:Enter",lock:"\u21ea Lock:Caps Lock", s:"\u21e7:Shift",shift:"Shift:Shift",sign:"\u00b1:Change Sign",space:"&nbsp;:Space",t:"\u21e5:Tab",tab:"\u21e5 Tab:Tab"},wheelMessage:"Use mousewheel to see other keys",css:{input:"ui-widget-content ui-corner-all",container:"ui-widget-content ui-widget ui-corner-all ui-helper-clearfix",buttonDefault:"ui-state-default ui-corner-all",buttonHover:"ui-state-hover",buttonAction:"ui-state-active",buttonDisabled:"ui-state-disabled"},autoAccept:!1,lockInput:!1,restrictInput:!1,acceptValid:!1,tabNavigation:!1, enterNavigation:!1,enterMod:"altKey",appendLocally:!1,stickyShift:!0,preventPaste:!1,maxLength:!1,repeatDelay:500,repeatRate:20,openOn:"focus",keyBinding:"mousedown",useCombos:!0,combos:{"`":{a:"\u00e0",A:"\u00c0",e:"\u00e8",E:"\u00c8",i:"\u00ec",I:"\u00cc",o:"\u00f2",O:"\u00d2",u:"\u00f9",U:"\u00d9",y:"\u1ef3",Y:"\u1ef2"},"'":{a:"\u00e1",A:"\u00c1",e:"\u00e9",E:"\u00c9",i:"\u00ed",I:"\u00cd",o:"\u00f3",O:"\u00d3",u:"\u00fa",U:"\u00da",y:"\u00fd",Y:"\u00dd"},'"':{a:"\u00e4",A:"\u00c4",e:"\u00eb", E:"\u00cb",i:"\u00ef",I:"\u00cf",o:"\u00f6",O:"\u00d6",u:"\u00fc",U:"\u00dc",y:"\u00ff",Y:"\u0178"},"^":{a:"\u00e2",A:"\u00c2",e:"\u00ea",E:"\u00ca",i:"\u00ee",I:"\u00ce",o:"\u00f4",O:"\u00d4",u:"\u00fb",U:"\u00db",y:"\u0177",Y:"\u0176"},"~":{a:"\u00e3",A:"\u00c3",e:"\u1ebd",E:"\u1ebc",i:"\u0129",I:"\u0128",o:"\u00f5",O:"\u00d5",u:"\u0169",U:"\u0168",y:"\u1ef9",Y:"\u1ef8",n:"\u00f1",N:"\u00d1"}},validate:function(){return!0}};c.keyboard.comboRegex=/([`\'~\^\"ao])([a-z])/mig;c.fn.keyboard=function(f){return this.each(function(){c(this).data("keyboard")|| new c.keyboard(this,f)})};c.fn.getkeyboard=function(){return this.data("keyboard")}})(jQuery);
+;(function(c){c.keyboard=function(f,l){var a=this,d;a.$el=c(f);a.el=f;a.$el.data("keyboard",a);a.init=function(){a.options=d=c.extend(!0,{},c.keyboard.defaultOptions,l);a.shiftActive=a.altActive=a.metaActive=a.sets=a.capsLock=!1;a.lastKeyset=[!1,!1,!1];a.rows=["","-shift","-alt","-alt-shift"];a.acceptedKeys=[];a.mappedKeys={};c('<\!--[if lte IE 8]><script>jQuery("body").addClass("oldie");<\/script><![endif]--\><\!--[if IE]><script>jQuery("body").addClass("ie");<\/script><![endif]--\>').appendTo("body").remove(); a.msie=c("body").hasClass("oldie");a.allie=c("body").hasClass("ie");a.inPlaceholder=a.$el.attr("placeholder")||"";a.watermark="undefined"!==typeof document.createElement("input").placeholder&&""!==a.inPlaceholder;a.regex=c.keyboard.comboRegex;a.decimal=/^\./.test(d.display.dec)?!0:!1;a.repeatTime=1E3/(d.repeatRate||20);a.temp=c('<input style="position:absolute;left:-9999em;top:-9999em;" type="text" value="testing">').appendTo("body").caret(3,3);a.checkCaret=d.lockInput||3!==a.temp.hide().show().caret().start? !0:!1;a.temp.remove();a.lastCaret={start:0,end:0};a.temp=["",0,0];c.each("initialized,visible,change,hidden,canceled,accepted,beforeClose".split(","),function(b,e){c.isFunction(d[e])&&a.$el.bind(e+".keyboard",d[e])});d.alwaysOpen&&(d.stayOpen=!0);d.stayOpen||c(document).bind("mousedown.keyboard keyup.keyboard",function(b){a.escClose(b)});a.$el.addClass("ui-keyboard-input "+d.css.input).attr({"aria-haspopup":"true",role:"textbox"});(a.$el.is(":disabled")||a.$el.attr("readonly"))&&a.$el.addClass("ui-keyboard-nokeyboard"); d.openOn&&a.$el.bind(d.openOn+".keyboard",function(){a.focusOn()});!a.watermark&&""===a.$el.val()&&""!==a.inPlaceholder&&""!==a.$el.attr("placeholder")&&a.$el.addClass("ui-keyboard-placeholder").val(a.inPlaceholder);a.$el.trigger("initialized.keyboard",[a,a.el]);d.alwaysOpen&&a.reveal()};a.focusOn=function(){a.$el.is(":visible")&&(a.lastCaret=a.$el.caret());if(!a.isVisible||d.alwaysOpen)clearTimeout(a.timer),a.reveal(),setTimeout(function(){a.$preview.focus()},100)};a.reveal=function(){c(".ui-keyboard:not(.ui-keyboard-always-open)").hide(); if(a.$el.is(":disabled")||a.$el.attr("readonly"))a.$el.addClass("ui-keyboard-nokeyboard");else{a.$el.removeClass("ui-keyboard-nokeyboard");a.$el.unbind(d.openOn?d.openOn+".keyboard":"");"undefined"===typeof a.$keyboard&&a.startup();c(".ui-keyboard-has-focus").removeClass("ui-keyboard-has-focus");c(".ui-keyboard-input-current").removeClass("ui-keyboard-input-current");a.$el.addClass("ui-keyboard-input-current");a.isCurrent=!0;!a.watermark&&a.el.value===a.inPlaceholder&&a.$el.removeClass("ui-keyboard-placeholder").val(""); a.originalContent=a.$el.val();a.$preview.val(a.originalContent);d.acceptValid&&a.checkValid();var b,e=d.position;e.of=e.of||a.$el.data("keyboardPosition")||a.$el;e.collision=d.usePreview?e.collision||"fit fit":"flip flip";a.$keyboard.css({position:"absolute",left:0,top:0}).addClass("ui-keyboard-has-focus").show();d.usePreview&&a.msie&&("undefined"===typeof a.width&&(a.$preview.hide(),a.width=Math.ceil(a.$keyboard.width()),a.$preview.show()),a.$preview.width(a.width));a.$keyboard.position(e);c(window).resize(function(){a.isVisible&& a.$keyboard.position(e)});a.$preview.focus();a.isVisible=!0;a.checkDecimal();a.lineHeight=parseInt(a.$preview.css("lineHeight"),10)||parseInt(a.$preview.css("font-size"),10)+4;if(a.allie&&(b=a.lastCaret.start||a.originalContent.length,b={start:b,end:b},a.lastCaret||(a.lastCaret=b),0===a.lastCaret.end&&0<a.lastCaret.start&&(a.lastCaret.end=a.lastCaret.start),0>a.lastCaret.start))a.lastCaret=b;a.$preview.caret(a.lastCaret.start,a.lastCaret.end);a.$el.trigger("visible.keyboard",[a,a.el]);return a}}; a.startup=function(){a.$keyboard=a.buildKeyboard();a.$allKeys=a.$keyboard.find("button.ui-keyboard-button");a.$preview=d.usePreview?a.$keyboard.find(".ui-keyboard-preview"):a.$el;a.preview=a.$preview[0];a.$decBtn=a.$keyboard.find(".ui-keyboard-dec");a.wheel=c.isFunction(c.fn.mousewheel);a.alwaysAllowed=[20,33,34,35,36,37,38,39,40,45,46];d.enterNavigation&&a.alwaysAllowed.push(13);a.$preview.bind("keypress.keyboard",function(b){var e=String.fromCharCode(b.charCode||b.which);a.checkCaret&&(a.lastCaret= a.$preview.caret());a.capsLock=65<=e&&90>=e&&!b.shiftKey||97<=e&&122>=e&&b.shiftKey?!0:!1;if(d.restrictInput){if((8===b.which||0===b.which)&&c.inArray(b.keyCode,a.alwaysAllowed))return;-1===c.inArray(e,a.acceptedKeys)&&b.preventDefault()}else if((b.ctrlKey||b.metaKey)&&(97===b.which||99===b.which||118===b.which||120<=b.which&&122>=b.which))return;a.hasMappedKeys&&a.mappedKeys.hasOwnProperty(e)&&(a.insertText(a.mappedKeys[e]),b.preventDefault());a.checkMaxLength()}).bind("keyup.keyboard",function(b){switch(b.which){case 9:a.tab&& !d.lockInput?(c.keyboard.keyaction.tab(a),a.tab=!1):b.preventDefault();break;case 27:return a.close(),!1}clearTimeout(a.throttled);a.throttled=setTimeout(function(){a.checkCombos()},100);a.checkMaxLength();a.$el.trigger("change.keyboard",[a,a.el])}).bind("keydown.keyboard",function(b){switch(b.which){case 9:if(d.tabNavigation)return!0;a.tab=!0;return!1;case 13:c.keyboard.keyaction.enter(a,null,b);break;case 20:a.shiftActive=a.capsLock=!a.capsLock;a.showKeySet(this);break;case 86:if(b.ctrlKey||b.metaKey){if(d.preventPaste){b.preventDefault(); break}a.checkCombos()}}}).bind("mouseup.keyboard",function(){a.checkCaret&&(a.lastCaret=a.$preview.caret())}).bind("blur.keyboard",function(b){if(d.alwaysOpen&&a.isCurrent)return b.target===a.el||c(b.target).closest(".ui-keyboard")[0]===a.$keyboard[0]?a.close(d.autoAccept):a.$preview.focus(),!1});d.preventPaste&&(a.$preview.bind("contextmenu.keyboard",function(a){a.preventDefault()}),a.$el.bind("contextmenu.keyboard",function(a){a.preventDefault()}));d.appendLocally?a.$el.after(a.$keyboard):a.$keyboard.appendTo("body"); a.$allKeys.bind(d.keyBinding.split(" ").join(".keyboard ")+".keyboard repeater.keyboard",function(b){var e;e=c.data(this,"key");var k=e.action.split(":")[0];a.$preview.focus();a.checkCaret&&a.$preview.caret(a.lastCaret.start,a.lastCaret.end);k.match("meta")&&(k="meta");if(c.keyboard.keyaction.hasOwnProperty(k)&&c(this).hasClass("ui-keyboard-actionkey")){if(c.keyboard.keyaction[k](a,this,b)===false)return}else if(typeof e.action!=="undefined"){e=a.wheel&&!c(this).hasClass("ui-keyboard-actionkey")? e.curTxt:e.action;a.insertText(e);if(!a.capsLock&&!d.stickyShift&&!b.shiftKey){a.shiftActive=false;a.showKeySet(this)}}a.checkCombos();a.checkMaxLength();a.$el.trigger("change.keyboard",[a,a.el]);a.$preview.focus();b.preventDefault()}).bind("mouseenter.keyboard mouseleave.keyboard",function(b){var e=c(this),k=c.data(this,"key");b.type==="mouseenter"&&a.el.type!=="password"&&e.addClass(d.css.buttonHover).attr("title",function(b,e){return a.wheel&&e===""&&a.sets?d.wheelMessage:e});if(b.type==="mouseleave"){k.curTxt= k.original;k.curNum=0;c.data(this,"key",k);e.removeClass(a.el.type==="password"?"":d.css.buttonHover).attr("title",function(a,b){return b===d.wheelMessage?"":b}).find("span").text(k.original)}}).bind("mousewheel.keyboard",function(b,e){if(a.wheel){var d,f=c(this),g=c.data(this,"key");d=g.layers||a.getLayers(f);g.curNum=g.curNum+(e>0?-1:1);if(g.curNum>d.length-1)g.curNum=0;if(g.curNum<0)g.curNum=d.length-1;g.layers=d;g.curTxt=d[g.curNum];c.data(this,"key",g);f.find("span").text(d[g.curNum]);return false}}).bind("mouseup.keyboard mouseleave.kb touchend.kb touchmove.kb touchcancel.kb", function(){a.isVisible&&a.isCurrent&&a.$preview.focus();a.mouseRepeat=[false,""];clearTimeout(a.repeater);a.checkCaret&&a.$preview.caret(a.lastCaret.start,a.lastCaret.end);return false}).bind("click.keyboard",function(){return false}).filter(":not(.ui-keyboard-actionkey)").add(".ui-keyboard-tab, .ui-keyboard-bksp, .ui-keyboard-space, .ui-keyboard-enter",a.$keyboard).bind("mousedown.kb touchstart.kb",function(){if(d.repeatRate!==0){var b=c(this);a.mouseRepeat=[true,b];setTimeout(function(){a.mouseRepeat[0]&& a.mouseRepeat[1]===b&&a.repeatKey(b)},d.repeatDelay)}return false})};a.insertText=function(b){var d,f;f=a.$preview.val();var c=a.$preview.caret(),g=a.$preview.scrollLeft();d=a.$preview.scrollTop();var h=f.length;c.end<c.start&&(c.end=c.start);c.start>h&&(c.end=c.start=h);"TEXTAREA"===a.preview.tagName&&(a.msie&&"\n"===f.substr(c.start,1)&&(c.start+=1,c.end+=1),f=f.split("\n").length-1,a.preview.scrollTop=0<f?a.lineHeight*f:d);d="bksp"===b&&c.start===c.end?!0:!1;b="bksp"===b?"":b;f=c.start+(d?-1:b.length); g+=parseInt(a.$preview.css("fontSize"),10)*("bksp"===b?-1:1);a.$preview.val(a.$preview.val().substr(0,c.start-(d?1:0))+b+a.$preview.val().substr(c.end)).caret(f,f).scrollLeft(g);a.checkCaret&&(a.lastCaret={start:f,end:f})};a.checkMaxLength=function(){var b,e=a.$preview.val();!1!==d.maxLength&&e.length>d.maxLength&&(b=Math.min(a.$preview.caret().start,d.maxLength),a.$preview.val(e.substring(0,d.maxLength)),a.$preview.caret(b,b),a.lastCaret={start:b,end:b});a.$decBtn.length&&a.checkDecimal()};a.repeatKey= function(b){b.trigger("repeater.keyboard");a.mouseRepeat[0]&&(a.repeater=setTimeout(function(){a.repeatKey(b)},a.repeatTime))};a.showKeySet=function(b){var e="",c=(a.shiftActive?1:0)+(a.altActive?2:0);a.shiftActive||(a.capsLock=!1);if(a.metaActive){if(e=b&&b.name&&/meta/.test(b.name)?b.name:"",""===e?e=!0===a.metaActive?"":a.metaActive:a.metaActive=e,!d.stickyShift&&a.lastKeyset[2]!==a.metaActive||(a.shiftActive||a.altActive)&&!a.$keyboard.find(".ui-keyboard-keyset-"+e+a.rows[c]).length)a.shiftActive= a.altActive=!1}else!d.stickyShift&&a.lastKeyset[2]!==a.metaActive&&a.shiftActive&&(a.shiftActive=a.altActive=!1);c=(a.shiftActive?1:0)+(a.altActive?2:0);e=0===c&&!a.metaActive?"-default":""===e?"":"-"+e;a.$keyboard.find(".ui-keyboard-keyset"+e+a.rows[c]).length?(a.$keyboard.find(".ui-keyboard-alt, .ui-keyboard-shift, .ui-keyboard-actionkey[class*=meta]").removeClass(d.css.buttonAction).end().find(".ui-keyboard-alt")[a.altActive?"addClass":"removeClass"](d.css.buttonAction).end().find(".ui-keyboard-shift")[a.shiftActive? "addClass":"removeClass"](d.css.buttonAction).end().find(".ui-keyboard-lock")[a.capsLock?"addClass":"removeClass"](d.css.buttonAction).end().find(".ui-keyboard-keyset").hide().end().find(".ui-keyboard-keyset"+e+a.rows[c]).show().end().find(".ui-keyboard-actionkey.ui-keyboard"+e).addClass(d.css.buttonAction),a.lastKeyset=[a.shiftActive,a.altActive,a.metaActive]):(a.shiftActive=a.lastKeyset[0],a.altActive=a.lastKeyset[1],a.metaActive=a.lastKeyset[2])};a.checkCombos=function(){var b,e,c,f,g=a.$preview.val(), h=a.$preview.caret(),j=g.length;h.end<h.start&&(h.end=h.start);h.start>j&&(h.end=h.start=j);a.msie&&"\n"===g.substr(h.start,1)&&(h.start+=1,h.end+=1);d.useCombos&&(g=g.replace(a.regex,function(a,b,e){return d.combos.hasOwnProperty(b)?d.combos[b][e]||a:a}));if(d.restrictInput&&""!==g){c=g;e=a.acceptedKeys.length;for(b=0;b<e;b++)""!==c&&(f=a.acceptedKeys[b],0<=g.indexOf(f)&&(/[\[|\]|\\|\^|\$|\.|\||\?|\*|\+|\(|\)|\{|\}]/g.test(f)&&(f="\\"+f),c=c.replace(RegExp(f,"g"),"")));""!==c&&(g=g.replace(c,""))}h.start+= g.length-j;h.end+=g.length-j;a.$preview.val(g);a.$preview.caret(h.start,h.end);a.preview.scrollTop=a.lineHeight*(g.substring(0,h.start).split("\n").length-1);a.lastCaret={start:h.start,end:h.end};d.acceptValid&&a.checkValid();return g};a.checkValid=function(){var b=!0;d.validate&&"function"===typeof d.validate&&(b=d.validate(a,a.$preview.val(),!1));a.$keyboard.find(".ui-keyboard-accept")[b?"removeClass":"addClass"]("disabled")[b?"removeAttr":"attr"]("disabled","disabled").attr("aria-disabled",!b)}; a.checkDecimal=function(){a.decimal&&/\./g.test(a.preview.value)||!a.decimal&&/\,/g.test(a.preview.value)?a.$decBtn.attr({disabled:"disabled","aria-disabled":"true"}).removeClass(d.css.buttonDefault+" "+d.css.buttonHover).addClass(d.css.buttonDisabled):a.$decBtn.removeAttr("disabled").attr({"aria-disabled":"false"}).addClass(d.css.buttonDefault).removeClass(d.css.buttonDisabled)};a.getLayers=function(a){var d;d=a.attr("data-pos");return a.closest(".ui-keyboard").find('button[data-pos="'+d+'"]').map(function(){return c(this).find("> span").text()}).get()}; a.switchInput=function(b,e){if("function"===typeof d.switchInput)d.switchInput(a,b,e);else{a.close(e);var f=c(".ui-keyboard-input"),i=f.index(a.$el)+(b?1:-1);i>f.length-1&&(i=0);f.eq(i).focus()}return!1};a.close=function(b){if(a.isVisible){clearTimeout(a.throttled);var e=b?a.checkCombos():a.originalContent;b&&d.validate&&"function"===typeof d.validate&&!d.validate(a,e,!0)&&(e=a.originalContent,b=!1);a.isCurrent=!1;a.$el.removeClass("ui-keyboard-input-current").trigger(d.alwaysOpen?"":"beforeClose.keyboard", [a,a.el,b||!1]).val(e).scrollTop(a.el.scrollHeight).blur().trigger(b?"accepted.keyboard":"canceled.keyboard",[a,a.el]).trigger(d.alwaysOpen?"inactive.keyboard":"hidden.keyboard",[a,a.el]);d.openOn&&a.$el.bind(d.openOn+".keyboard",function(){a.focusOn()});d.alwaysOpen||(a.$keyboard.hide(),a.isVisible=!1);!a.watermark&&""===a.el.value&&""!==a.inPlaceholder&&a.$el.addClass("ui-keyboard-placeholder").val(a.inPlaceholder)}return!1};a.accept=function(){a.close(!0)};a.escClose=function(b){a.isVisible&&("keyup"=== b.type&&27===b.which&&a.close(),"mousedown"===b.type&&b.target!==a.el&&c(b.target).closest(".ui-keyboard")[0]!==a.$keyboard[0]&&(a.allie&&b.preventDefault(),a.close(d.autoAccept)))};a.keyBtn=c("<button />").attr({role:"button","aria-disabled":"false",tabindex:"-1"}).addClass("ui-keyboard-button");a.addKey=function(b,e,f){var i,g,h,e=!0===f?b:d.display[e]||b,j=!0===f?b.charCodeAt(0):b;/\(.+\)/.test(e)&&(g=e.replace(/\(([^()]+)\)/,""),i=e.match(/\(([^()]+)\)/)[1],e=g,h=g.split(":"),g=""!==h[0]&&1<h.length? h[0]:g,a.mappedKeys[i]=g);h=e.split(":");""===h[0]&&""===h[1]&&(e=":");e=""!==h[0]&&1<h.length?c.trim(h[0]):e;i=1<h.length?c.trim(h[1]).replace(/_/g," ")||"":"";g=1<e.length?" ui-keyboard-widekey":"";g+=f?"":" ui-keyboard-actionkey";return a.keyBtn.clone().attr({"data-value":e,name:j,"data-pos":a.temp[1]+","+a.temp[2],title:i}).data("key",{action:b,original:e,curTxt:e,curNum:0}).addClass("ui-keyboard-"+j+g+" "+d.css.buttonDefault).html("<span>"+e+"</span>").appendTo(a.temp[0])};a.buildKeyboard=function(){var b, e,f,i,g,h,j,l=0,o=c("<div />").addClass("ui-keyboard "+d.css.container+(d.alwaysOpen?" ui-keyboard-always-open":"")).attr({role:"textbox"}).hide();d.usePreview?a.$preview=a.$el.clone(!1).removeAttr("id").removeClass("ui-keyboard-placeholder ui-keyboard-input").addClass("ui-keyboard-preview "+d.css.input).attr("tabindex","-1").show():(a.$preview=a.$el,d.position.at=d.position.at2);a.$preview.attr(d.lockInput?{readonly:"readonly"}:{});d.usePreview&&c("<div />").addClass("ui-keyboard-preview-wrapper").append(a.$preview).appendTo(o); if("custom"===d.layout||!c.keyboard.layouts.hasOwnProperty(d.layout))d.layout="custom",c.keyboard.layouts.custom=d.customLayout||{"default":["{cancel}"]};c.each(c.keyboard.layouts[d.layout],function(n,p){if(n!==""){l++;f=c("<div />").attr("name",n).addClass("ui-keyboard-keyset ui-keyboard-keyset-"+n).appendTo(o)[n==="default"?"show":"hide"]();for(e=0;e<p.length;e++){i=c.trim(p[e]).replace(/\{(\.?)[\s+]?:[\s+]?(\.?)\}/g,"{$1:$2}");h=i.split(/\s+/);for(g=0;g<h.length;g++){a.temp=[f,e,g];if(h[g].length!== 0)if(/^\{\S+\}$/.test(h[g])){b=h[g].match(/^\{(\S+)\}$/)[1].toLowerCase();if(/^sp:((\d+)?([\.|,]\d+)?)(em|px)?$/.test(b)){j=parseFloat(b.replace(/,/,".").match(/^sp:((\d+)?([\.|,]\d+)?)(em|px)?$/)[1]||0);c("<span>&nbsp;</span>").width(b.match("px")?j+"px":j*2+"em").addClass("ui-keyboard-button ui-keyboard-spacer").appendTo(f)}if(/^meta\d+\:?(\w+)?/.test(b))a.addKey(b,b);else switch(b){case "a":case "accept":a.addKey("accept",b).addClass(d.css.buttonAction);break;case "alt":case "altgr":a.addKey("alt", "alt");break;case "b":case "bksp":a.addKey("bksp",b);break;case "c":case "cancel":a.addKey("cancel",b).addClass(d.css.buttonAction);break;case "combo":a.addKey("combo","combo").addClass(d.css.buttonAction);break;case "dec":a.acceptedKeys.push(a.decimal?".":",");a.addKey("dec","dec");break;case "e":case "enter":a.addKey("enter",b).addClass(d.css.buttonAction);break;case "s":case "shift":a.addKey("shift",b);break;case "sign":a.acceptedKeys.push("-");a.addKey("sign","sign");break;case "space":a.acceptedKeys.push(" "); a.addKey("space","space");break;case "t":case "tab":a.addKey("tab",b);break;default:c.keyboard.keyaction.hasOwnProperty(b)&&a.addKey(b,b)}}else{a.acceptedKeys.push(h[g].split(":")[0]);a.addKey(h[g],h[g],true)}}f.find(".ui-keyboard-button:last").after('<br class="ui-keyboard-button-endrow">')}}});1<l&&(a.sets=!0);a.hasMappedKeys=!c.isEmptyObject(a.mappedKeys);return o};a.destroy=function(){c(document).unbind("mousedown.keyboard keyup.keyboard");a.$keyboard&&a.$keyboard.remove();var b=d.openOn+",accepted,beforeClose,blur,canceled,change,contextmenu,hidden,initialized,keydown,keypress,keyup,visible".split(",").join(".keyboard "); a.$el.removeClass("ui-keyboard-input ui-keyboard-placeholder ui-keyboard-notallowed ui-keyboard-always-open "+d.css.input).removeAttr("aria-haspopup").removeAttr("role").unbind(b+".keyboard").removeData("keyboard")};a.init()};c.keyboard.keyaction={accept:function(f){f.close(!0);return!1},alt:function(f,c){f.altActive=!f.altActive;f.showKeySet(c)},bksp:function(f){f.insertText("bksp")},cancel:function(f){f.close();return!1},clear:function(f){f.$preview.val("")},combo:function(f){var c=!f.options.useCombos; f.options.useCombos=c;f.$keyboard.find(".ui-keyboard-combo")[c?"addClass":"removeClass"](f.options.css.buttonAction);c&&f.checkCombos();return!1},dec:function(c){c.insertText(c.decimal?".":",")},enter:function(f,l,a){var l=f.el.tagName,d=f.options;if(a.shiftKey)return d.enterNavigation?f.switchInput(!a[d.enterMod],!0):f.close(!0);if(d.enterNavigation&&("TEXTAREA"!==l||a[d.enterMod]))return f.switchInput(!a[d.enterMod],d.autoAccept);"TEXTAREA"===l&&c(a.target).closest("button").length&&f.insertText("\n")}, lock:function(c,l){c.lastKeyset[0]=c.shiftActive=c.capsLock=!c.capsLock;c.showKeySet(l)},meta:function(f,l){f.metaActive=c(l).hasClass(f.options.css.buttonAction)?!1:!0;f.showKeySet(l)},shift:function(c,l){c.lastKeyset[0]=c.shiftActive=!c.shiftActive;c.showKeySet(l)},sign:function(c){/^\-?\d*\.?\d*$/.test(c.$preview.val())&&c.$preview.val(-1*c.$preview.val())},space:function(c){c.insertText(" ")},tab:function(c){if("INPUT"===c.el.tagName)return!1;c.insertText("\t")}};c.keyboard.layouts={alpha:{"default":["` 1 2 3 4 5 6 7 8 9 0 - = {bksp}", "{tab} a b c d e f g h i j [ ] \\","k l m n o p q r s ; ' {enter}","{shift} t u v w x y z , . / {shift}","{accept} {space} {cancel}"],shift:["~ ! @ # $ % ^ & * ( ) _ + {bksp}","{tab} A B C D E F G H I J { } |",'K L M N O P Q R S : " {enter}',"{shift} T U V W X Y Z < > ? {shift}","{accept} {space} {cancel}"]},qwerty:{"default":["` 1 2 3 4 5 6 7 8 9 0 - = {bksp}","{tab} q w e r t y u i o p [ ] \\","a s d f g h j k l ; ' {enter}","{shift} z x c v b n m , . / {shift}","{accept} {space} {cancel}"],shift:["~ ! @ # $ % ^ & * ( ) _ + {bksp}", "{tab} Q W E R T Y U I O P { } |",'A S D F G H J K L : " {enter}',"{shift} Z X C V B N M < > ? {shift}","{accept} {space} {cancel}"]},international:{"default":["` 1 2 3 4 5 6 7 8 9 0 - = {bksp}","{tab} q w e r t y u i o p [ ] \\","a s d f g h j k l ; ' {enter}","{shift} z x c v b n m , . / {shift}","{accept} {alt} {space} {alt} {cancel}"],shift:["~ ! @ # $ % ^ & * ( ) _ + {bksp}","{tab} Q W E R T Y U I O P { } |",'A S D F G H J K L : " {enter}',"{shift} Z X C V B N M < > ? {shift}","{accept} {alt} {space} {alt} {cancel}"], alt:["~ \u00a1 \u00b2 \u00b3 \u00a4 \u20ac \u00bc \u00bd \u00be \u2018 \u2019 \u00a5 \u00d7 {bksp}","{tab} \u00e4 \u00e5 \u00e9 \u00ae \u00fe \u00fc \u00fa \u00ed \u00f3 \u00f6 \u00ab \u00bb \u00ac","\u00e1 \u00df \u00f0 f g h j k \u00f8 \u00b6 \u00b4 {enter}","{shift} \u00e6 x \u00a9 v b \u00f1 \u00b5 \u00e7 > \u00bf {shift}","{accept} {alt} {space} {alt} {cancel}"],"alt-shift":["~ \u00b9 \u00b2 \u00b3 \u00a3 \u20ac \u00bc \u00bd \u00be \u2018 \u2019 \u00a5 \u00f7 {bksp}","{tab} \u00c4 \u00c5 \u00c9 \u00ae \u00de \u00dc \u00da \u00cd \u00d3 \u00d6 \u00ab \u00bb \u00a6", "\u00c4 \u00a7 \u00d0 F G H J K \u00d8 \u00b0 \u00a8 {enter}","{shift} \u00c6 X \u00a2 V B \u00d1 \u00b5 \u00c7 . \u00bf {shift}","{accept} {alt} {space} {alt} {cancel}"]},dvorak:{"default":["` 1 2 3 4 5 6 7 8 9 0 [ ] {bksp}","{tab} ' , . p y f g c r l / = \\","a o e u i d h t n s - {enter}","{shift} ; q j k x b m w v z {shift}","{accept} {space} {cancel}"],shift:["~ ! @ # $ % ^ & * ( ) { } {bksp}",'{tab} " < > P Y F G C R L ? + |',"A O E U I D H T N S _ {enter}","{shift} : Q J K X B M W V Z {shift}", "{accept} {space} {cancel}"]},num:{"default":"= ( ) {b},{clear} / * -,7 8 9 +,4 5 6 {sign},1 2 3 %,0 . {a} {c}".split(",")}};c.keyboard.defaultOptions={layout:"qwerty",customLayout:null,position:{of:null,my:"center top",at:"center top",at2:"center bottom"},usePreview:!0,alwaysOpen:!1,stayOpen:!1,display:{a:"\u2714:Accept (Shift-Enter)",accept:"Accept:Accept (Shift-Enter)",alt:"AltGr:Alternate Graphemes",b:"\u2190:Backspace",bksp:"Bksp:Backspace",c:"\u2716:Cancel (Esc)",cancel:"Cancel:Cancel (Esc)", clear:"C:Clear",combo:"\u00f6:Toggle Combo Keys",dec:".:Decimal",e:"\u21b5:Enter",enter:"Enter:Enter",lock:"\u21ea Lock:Caps Lock",s:"\u21e7:Shift",shift:"Shift:Shift",sign:"\u00b1:Change Sign",space:"&nbsp;:Space",t:"\u21e5:Tab",tab:"\u21e5 Tab:Tab"},wheelMessage:"Use mousewheel to see other keys",css:{input:"ui-widget-content ui-corner-all",container:"ui-widget-content ui-widget ui-corner-all ui-helper-clearfix",buttonDefault:"ui-state-default ui-corner-all",buttonHover:"ui-state-hover",buttonAction:"ui-state-active", buttonDisabled:"ui-state-disabled"},autoAccept:!1,lockInput:!1,restrictInput:!1,acceptValid:!1,tabNavigation:!1,enterNavigation:!1,enterMod:"altKey",appendLocally:!1,stickyShift:!0,preventPaste:!1,maxLength:!1,repeatDelay:500,repeatRate:20,openOn:"focus",keyBinding:"mousedown",useCombos:!0,combos:{"`":{a:"\u00e0",A:"\u00c0",e:"\u00e8",E:"\u00c8",i:"\u00ec",I:"\u00cc",o:"\u00f2",O:"\u00d2",u:"\u00f9",U:"\u00d9",y:"\u1ef3",Y:"\u1ef2"},"'":{a:"\u00e1",A:"\u00c1",e:"\u00e9",E:"\u00c9",i:"\u00ed",I:"\u00cd", o:"\u00f3",O:"\u00d3",u:"\u00fa",U:"\u00da",y:"\u00fd",Y:"\u00dd"},'"':{a:"\u00e4",A:"\u00c4",e:"\u00eb",E:"\u00cb",i:"\u00ef",I:"\u00cf",o:"\u00f6",O:"\u00d6",u:"\u00fc",U:"\u00dc",y:"\u00ff",Y:"\u0178"},"^":{a:"\u00e2",A:"\u00c2",e:"\u00ea",E:"\u00ca",i:"\u00ee",I:"\u00ce",o:"\u00f4",O:"\u00d4",u:"\u00fb",U:"\u00db",y:"\u0177",Y:"\u0176"},"~":{a:"\u00e3",A:"\u00c3",e:"\u1ebd",E:"\u1ebc",i:"\u0129",I:"\u0128",o:"\u00f5",O:"\u00d5",u:"\u0169",U:"\u0168",y:"\u1ef9",Y:"\u1ef8",n:"\u00f1",N:"\u00d1"}}, validate:function(){return!0}};c.keyboard.comboRegex=/([`\'~\^\"ao])([a-z])/mig;c.fn.keyboard=function(f){return this.each(function(){c(this).data("keyboard")||new c.keyboard(this,f)})};c.fn.getkeyboard=function(){return this.data("keyboard")}})(jQuery);
-(function(c,f,l,a){c.fn.caret=function(c,b){if("undefined"===typeof this[0]||this.is(":hidden")||"hidden"===this.css("visibility"))return this;var e,k,i,g,h,j;e=document.selection;var m=this[0],o=m.scrollTop;j=window.opera&&"[object Opera]"===window.opera.toString();var n="undefined"!==typeof m.selectionStart;"number"===typeof c&&"number"===typeof b&&(i=c,h=b);if("undefined"!==typeof i)return n?("TEXTAREA"===m.tagName&&j&&(j=this.val(),e=j.substring(0,i).split("\n")[f]-1,i+=0<e?e:0,h+=0<e?e:0),m.selectionStart= i,m.selectionEnd=h):(e=m.createTextRange(),e.collapse(!0),e.moveStart("character",i),e.moveEnd("character",h-i),e.select()),(this.is(":visible")||"hidden"!==this.css("visibility"))&&this.focus(),m.scrollTop=o,this;n?(k=m.selectionStart,g=m.selectionEnd,"TEXTAREA"===m.tagName&&j&&(j=this.val(),e=j.substring(0,k).split("\n")[f]-1,k+=0<e?-e:0,g+=0<e?-e:0)):"TEXTAREA"===m.tagName?(j=this.val(),i=e[l](),h=i[a](),h.moveToElementText(m),h.setEndPoint("EndToEnd",i),k=h.text.replace(/\r\n/g,"\r")[f],g=k+i.text.replace(/\r\n/g, "\r")[f]):(j=this.val().replace(/\r\n/g,"\r"),i=e[l]()[a](),i.moveEnd("character",j[f]),k=""===i.text?j[f]:j.lastIndexOf(i.text),i=e[l]()[a](),i.moveStart("character",-j[f]),g=i.text[f]);i=m.value.substring(k,g);return{start:k,end:g,text:i,replace:function(a){return m.value.substring(0,k)+a+m.value.substring(g,m.value[f])}}}})(jQuery,"length","createRange","duplicate");
+(function(c,f,l,a){c.fn.caret=function(c,b){if("undefined"===typeof this[0]||this.is(":hidden")||"hidden"===this.css("visibility"))return this;var e,k,i,g,h,j;e=document.selection;var m=this[0],o=m.scrollTop;j=window.opera&&"[object Opera]"===window.opera.toString();var n="undefined"!==typeof m.selectionStart;"number"===typeof c&&"number"===typeof b&&(i=c,h=b);if("undefined"!==typeof i)return n?("TEXTAREA"===m.tagName&&j&&(j=this.val(),e=j.substring(0,i).split("\n")[f]-1,i+=0<e?e:0,h+=0<e?e:0),m.selectionStart= i,m.selectionEnd=h):(e=m.createTextRange(),e.collapse(!0),e.moveStart("character",i),e.moveEnd("character",h-i),e.select()),(this.is(":visible")||"hidden"!==this.css("visibility"))&&this.focus(),m.scrollTop=o,this;n?(k=m.selectionStart,g=m.selectionEnd,"TEXTAREA"===m.tagName&&j&&(j=this.val(),e=j.substring(0,k).split("\n")[f]-1,k+=0<e?-e:0,g+=0<e?-e:0)):"TEXTAREA"===m.tagName?(j=this.val(),i=e[l](),h=i[a](),h.moveToElementText(m),h.setEndPoint("EndToEnd",i),k=h.text.replace(/\r\n/g,"\r")[f],g=k+i.text.replace(/\r\n/g, "\r")[f]):(j=this.val().replace(/\r\n/g,"\r"),i=e[l]()[a](),i.moveEnd("character",j[f]),k=""===i.text?j[f]:j.lastIndexOf(i.text),i=e[l]()[a](),i.moveStart("character",-j[f]),g=i.text[f]);i=m.value.substring(k,g);return{start:k,end:g,text:i,replace:function(a){return m.value.substring(0,k)+a+m.value.substring(g,m.value[f])}}}})(jQuery,"length","createRange","duplicate");
View
2 package.json
@@ -1,6 +1,6 @@
{
"name": "Keyboard",
- "version": "1.9.15",
+ "version": "1.9.16",
"title": "Keyboard",
"author": {
"name": "Jeremy Satterfield",

0 comments on commit 02c5d67

Please sign in to comment.