2 lines
45 KiB
JavaScript
2 lines
45 KiB
JavaScript
/*! jQuery UI Virtual Keyboard v1.27.3 */
|
||
!function(e){"function"==typeof define&&define.amd?define(["jquery"],e):"object"==typeof module&&"object"==typeof module.exports?module.exports=e(require("jquery")):e(jQuery)}(function(e){"use strict";var t=e.keyboard=function(a,i){var n,s=this;s.version="1.27.3",s.$el=e(a),s.el=a,s.$el.data("keyboard",s),s.init=function(){s.initialized=!1;var a,o,r,l=t.css,c=t.events;s.settings=i||{},i&&i.position&&(o=e.extend({},i.position),i.position=null),s.options=n=e.extend(!0,{},t.defaultOptions,i),o&&(n.position=o,i.position=o),s.el.active=!0,s.namespace=".keyboard"+Math.random().toString(16).slice(2),s.extensionNamespace=[],s.shiftActive=s.altActive=s.metaActive=s.sets=s.capsLock=!1,s.rows=["","-shift","-alt","-alt-shift"],s.inPlaceholder=s.$el.attr("placeholder")||"",s.watermark=t.watermark&&""!==s.inPlaceholder,s.repeatTime=1e3/(n.repeatRate||20),n.preventDoubleEventTime=n.preventDoubleEventTime||100,s.isOpen=!1,s.wheel=e.isFunction(e.fn.mousewheel),s.escapeRegex=/[-\/\\^$*+?.()|[\]{}]/g,s.isContentEditable=!/(input|textarea)/i.test(s.el.nodeName)&&s.el.isContentEditable,a=t.keyCodes,s.alwaysAllowed=[a.capsLock,a.pageUp,a.pageDown,a.end,a.home,a.left,a.up,a.right,a.down,a.insert,a.delete],s.$keyboard=[],s.enabled=!0,s.checkCaret=n.lockInput||t.checkCaretSupport(),s.isContentEditable&&(n.usePreview=!1),s.last={start:0,end:0,key:"",val:"",preVal:"",layout:"",virtual:!0,keyset:[!1,!1,!1],wheel_$Keys:null,wheelIndex:0,wheelLayers:[]},s.temp=["",0,0],e.each([c.kbInit,c.kbBeforeVisible,c.kbVisible,c.kbHidden,c.inputCanceled,c.inputAccepted,c.kbBeforeClose,c.inputRestricted],function(t,a){e.isFunction(n[a])&&s.$el.bind(a+s.namespace+"callbacks",n[a])}),n.alwaysOpen&&(n.stayOpen=!0),r=e(document),s.el.ownerDocument!==document&&(r=r.add(s.el.ownerDocument));var d="keyup checkkeyboard mousedown touchstart ";n.closeByClickEvent&&(d+="click "),r.bind(d.split(" ").join(s.namespace+" "),function(e){clearTimeout(s.timer3),s.timer3=setTimeout(function(){s.checkClose(e)},1)}),s.$el.addClass(l.input+" "+n.css.input).attr({"aria-haspopup":"true",role:"textbox"}),(n.lockInput||s.el.readOnly)&&(n.lockInput=!0,s.$el.addClass(l.locked).attr({readonly:"readonly"})),(s.$el.is(":disabled")||s.$el.attr("readonly")&&!s.$el.hasClass(l.locked))&&s.$el.addClass(l.noKeyboard),n.openOn&&s.bindFocus(),s.watermark||""!==s.getValue(s.$el)||""===s.inPlaceholder||""===s.$el.attr("placeholder")||(s.$el.addClass(l.placeholder),s.setValue(s.inPlaceholder,s.$el)),s.$el.trigger(c.kbInit,[s,s.el]),n.alwaysOpen&&s.reveal(),s.initialized=!0},s.toggle=function(){if(s.hasKeyboard()){var e=s.$keyboard.find("."+t.css.keyToggle),a=!s.enabled;return s.preview.readonly=a||s.options.lockInput,s.$keyboard.toggleClass(t.css.keyDisabled,a).find("."+t.css.keyButton).not(e).attr("aria-disabled",a).each(function(){this.disabled=a}),e.toggleClass(t.css.keyDisabled,a),a&&s.typing_options&&(s.typing_options.text=""),s}},s.setCurrent=function(){var a=t.css,i=e("."+a.isCurrent),n=i.data("keyboard");e.isEmptyObject(n)||n.el===s.el||n.close(!!n.options.autoAccept&&"true"),i.removeClass(a.isCurrent),e("."+a.hasFocus).removeClass(a.hasFocus),s.$el.addClass(a.isCurrent),s.$keyboard.addClass(a.hasFocus),s.isCurrent(!0),s.isOpen=!0},s.isCurrent=function(e){var a=t.currentKeyboard||!1;return e?a=t.currentKeyboard=s.el:!1===e&&a===s.el&&(a=t.currentKeyboard=""),a===s.el},s.hasKeyboard=function(){return s.$keyboard&&s.$keyboard.length>0},s.isVisible=function(){return!!s.hasKeyboard()&&s.$keyboard.is(":visible")},s.setFocus=function(){var e=s.$preview||s.$el;n.noFocus||e.focus(),s.isContentEditable?t.setEditableCaret(e,s.last.start,s.last.end):t.caret(e,s.last)},s.focusOn=function(){!s&&s.el.active||(s.isVisible()?s.setCurrent():(clearTimeout(s.timer),s.reveal()))},s.redraw=function(e){return e&&(s.options.layout=e),s.$keyboard.length&&(s.last.preVal=""+s.last.val,s.saveLastChange(),s.setValue(s.last.val,s.$el),s.removeKeyboard(),s.shiftActive=s.altActive=s.metaActive=!1),s.isOpen=n.alwaysOpen,s.reveal(!0),s},s.reveal=function(a){var i,o=s.isOpen,r=t.css;if(s.opening=!o,e("."+r.keyboard).not("."+r.alwaysOpen).each(function(){var t=e(this).data("keyboard");e.isEmptyObject(t)||t.close(!!t.options.autoAccept&&"true")}),!(s.$el.is(":disabled")||s.$el.attr("readonly")&&!s.$el.hasClass(r.locked)))return s.$el.removeClass(r.noKeyboard),n.openOn&&s.$el.unbind(e.trim((n.openOn+" ").split(/\s+/).join(s.namespace+" "))),s.$keyboard&&(!s.$keyboard||s.$keyboard.length&&!e.contains(s.el.ownerDocument.body,s.$keyboard[0]))||s.startup(),s.watermark||s.getValue()!==s.inPlaceholder||(s.$el.removeClass(r.placeholder),s.setValue("",s.$el)),s.originalContent=s.isContentEditable?s.$el.html():s.getValue(s.$el),s.el===s.preview||s.isContentEditable||s.setValue(s.originalContent),n.acceptValid&&s.checkValid(),n.resetDefault&&(s.shiftActive=s.altActive=s.metaActive=!1),s.showSet(),s.isVisible()||s.$el.trigger(t.events.kbBeforeVisible,[s,s.el]),(s.initialized||n.initialFocus||!n.initialFocus&&s.$el.hasClass(t.css.initialFocus))&&s.setCurrent(),s.toggle(),s.$keyboard.show(),n.usePreview&&t.msie&&(void 0===s.width&&(s.$preview.hide(),s.width=Math.ceil(s.$keyboard.width()),s.$preview.show()),s.$preview.width(s.width)),s.reposition(),s.checkDecimal(),s.lineHeight=parseInt(s.$preview.css("lineHeight"),10)||parseInt(s.$preview.css("font-size"),10)+4,n.caretToEnd&&(i=s.isContentEditable?t.getEditableLength(s.el):s.originalContent.length,s.saveCaret(i,i)),t.allie&&(0===s.last.end&&s.last.start>0&&(s.last.end=s.last.start),s.last.start<0&&(s.last.start=s.last.end=s.originalContent.length)),o||a?(t.caret(s.$preview,s.last),s):(s.timer2=setTimeout(function(){s.opening=!1,/(number|email)/i.test(s.el.type)||n.caretToEnd||s.saveCaret(void 0,void 0,s.$el),(n.initialFocus||s.$el.hasClass(t.css.initialFocus))&&t.caret(s.$preview,s.last),s.last.eventTime=(new Date).getTime(),s.$el.trigger(t.events.kbVisible,[s,s.el]),s.timer=setTimeout(function(){s&&s.saveCaret()},200)},10),s);s.$el.addClass(r.noKeyboard)},s.updateLanguage=function(){var a=t.layouts,i=n.language||a[n.layout]&&a[n.layout].lang&&a[n.layout].lang||[n.language||"en"],o=t.language;i=e.isArray(i)?i[0]:i,s.language=i,i=i.split("-")[0],n.display=e.extend(!0,{},o.en.display,o[i]&&o[i].display||{},s.settings.display),n.combos=e.extend(!0,{},o.en.combos,o[i]&&o[i].combos||{},s.settings.combos),n.wheelMessage=o[i]&&o[i].wheelMessage||o.en.wheelMessage,n.rtl=a[n.layout]&&a[n.layout].rtl||o[i]&&o[i].rtl||!1,s.regex=o[i]&&o[i].comboRegex||t.comboRegex,s.decimal=/^\./.test(n.display.dec),s.$el.toggleClass("rtl",n.rtl).css("direction",n.rtl?"rtl":"")},s.startup=function(){var a=t.css;(n.alwaysOpen||n.userClosed)&&s.$preview||s.makePreview(),s.hasKeyboard()||("custom"===n.layout&&(n.layoutHash="custom"+s.customHash()),s.layout="custom"===n.layout?n.layoutHash:n.layout,s.last.layout=s.layout,s.updateLanguage(),void 0===t.builtLayouts[s.layout]&&(e.isFunction(n.create)?s.$keyboard=n.create(s):s.$keyboard.length||s.buildKeyboard(s.layout,!0)),s.$keyboard=t.builtLayouts[s.layout].$keyboard.clone(),s.$keyboard.data("keyboard",s),""!==(s.el.id||"")&&s.$keyboard.attr("id",s.el.id+t.css.idSuffix),s.makePreview()),s.$keyboard.attr("data-"+a.keyboard+"-layout",n.layout).attr("data-"+a.keyboard+"-language",s.language),s.$decBtn=s.$keyboard.find("."+a.keyPrefix+"dec"),(n.enterNavigation||"TEXTAREA"===s.el.nodeName)&&s.alwaysAllowed.push(13),s.bindKeyboard(),s.$keyboard.appendTo(n.appendLocally?s.$el.parent():n.appendTo||"body"),s.bindKeys(),n.reposition&&e.ui&&e.ui.position&&"body"==n.appendTo&&e(window).bind("resize"+s.namespace,function(){s.reposition()})},s.reposition=function(){return s.position=!e.isEmptyObject(n.position)&&n.position,e.ui&&e.ui.position&&s.position&&(s.position.of=s.position.of||s.$el.data("keyboardPosition")||s.$el,s.position.collision=s.position.collision||"flipfit flipfit",s.position.at=n.usePreview?n.position.at:n.position.at2,s.isVisible()&&s.$keyboard.position(s.position)),s},s.makePreview=function(){if(n.usePreview){var a,i,o,r,l=t.css;for(s.$preview=s.$el.clone(!1).data("keyboard",s).removeClass(l.placeholder+" "+l.input).addClass(l.preview+" "+n.css.input).attr("tabindex","-1").show(),s.preview=s.$preview[0],"number"===s.preview.type&&(s.preview.type="text"),r=/^(data-|id|aria-haspopup)/i,a=(i=s.$preview.get(0).attributes).length-1;a>=0;a--)o=i[a]&&i[a].name,r.test(o)&&s.preview.removeAttribute(o);e("<div />").addClass(l.wrapper).append(s.$preview).prependTo(s.$keyboard)}else s.$preview=s.$el,s.preview=s.el},s.caret=function(a,i){var n=t.caret(s.$preview,a,i);return n instanceof e?(s.saveCaret(n.start,n.end),s):n},s.saveCaret=function(e,a,i){if(s.isCurrent()){var n;n=void 0===e?t.caret(i||s.$preview):t.caret(i||s.$preview,e,a),s.last.start=void 0===e?n.start:e,s.last.end=void 0===a?n.end:a}},s.saveLastChange=function(e){s.last.val=e||s.getValue(s.$preview||s.$el),s.isContentEditable&&(s.last.elms=s.el.cloneNode(!0))},s.setScroll=function(){if(!s.isContentEditable&&s.last.virtual){var e,a,i,o,r="TEXTAREA"===s.preview.nodeName,l=s.last.val.substring(0,Math.max(s.last.start,s.last.end));s.$previewCopy||(s.$previewCopy=s.$preview.clone().removeAttr("id").css({position:"absolute",left:0,zIndex:-10,visibility:"hidden"}).addClass(t.css.inputClone),s.$previewCopy[0].disabled=!0,r||s.$previewCopy.css({"white-space":"pre",width:0}),n.usePreview?s.$preview.after(s.$previewCopy):s.$keyboard.prepend(s.$previewCopy)),r?(s.$previewCopy.height(s.lineHeight).val(l),s.preview.scrollTop=s.lineHeight*(Math.floor(s.$previewCopy[0].scrollHeight/s.lineHeight)-1)):(s.$previewCopy.val(l.replace(/\s/g," ")),i=/c/i.test(n.scrollAdjustment)?s.preview.clientWidth/2:n.scrollAdjustment,e=s.$previewCopy[0].scrollWidth-1,void 0===s.last.scrollWidth&&(s.last.scrollWidth=e,s.last.direction=!0),o=s.last.scrollWidth===e?s.last.direction:s.last.scrollWidth<e,a=s.preview.clientWidth-i,o?s.preview.scrollLeft=e<a?0:e-a:e>=s.preview.scrollWidth-a?s.preview.scrollLeft=s.preview.scrollWidth-i:s.preview.scrollLeft=e-i>0?e-i:0,s.last.scrollWidth=e,s.last.direction=o)}},s.bindFocus=function(){n.openOn&&s&&s.el.active&&(s.$el.bind(n.openOn+s.namespace,function(){s.focusOn()}),e(":focus")[0]===s.el&&s.$el.blur())},s.bindKeyboard=function(){var a,i=t.keyCodes,o=t.builtLayouts[s.layout],r=s.namespace+"keybindings";s.$preview.unbind(s.namespace).bind("click"+r+" touchstart"+r,function(){n.alwaysOpen&&!s.isCurrent()&&s.reveal(),s.timer2=setTimeout(function(){s&&s.saveCaret()},150)}).bind("keypress"+r,function(r){if(n.lockInput)return!1;if(s.isCurrent()){var l=r.charCode||r.which,c=l>=i.A&&l<=i.Z,d=l>=i.a&&l<=i.z,u=s.last.key=String.fromCharCode(l);if(!(l<i.space)){if(s.last.virtual=!1,s.last.event=r,s.last.$key=[],s.checkCaret&&s.saveCaret(),l!==i.capsLock&&(c||d)&&(s.capsLock=c&&!r.shiftKey||d&&r.shiftKey,s.capsLock&&!s.shiftActive&&(s.shiftActive=!0,s.showSet())),n.restrictInput){if((r.which===i.backSpace||0===r.which)&&e.inArray(r.keyCode,s.alwaysAllowed))return;-1===e.inArray(u,o.acceptedKeys)&&(r.preventDefault(),(a=e.extend({},r)).type=t.events.inputRestricted,s.$el.trigger(a,[s,s.el]))}else if((r.ctrlKey||r.metaKey)&&(r.which===i.A||r.which===i.C||r.which===i.V||r.which>=i.X&&r.which<=i.Z))return;o.hasMappedKeys&&o.mappedKeys.hasOwnProperty(u)&&(s.last.key=o.mappedKeys[u],s.insertText(s.last.key),r.preventDefault()),"function"==typeof n.beforeInsert&&(s.insertText(s.last.key),r.preventDefault()),s.checkMaxLength()}}}).bind("keyup"+r,function(a){if(s.isCurrent()){switch(s.last.virtual=!1,a.which){case i.tab:if(s.tab&&n.tabNavigation&&!n.lockInput){s.shiftActive=a.shiftKey;var o=t.keyaction.tab(s);if(s.tab=!1,!o)return!1}else a.preventDefault();break;case i.escape:return n.ignoreEsc||s.close(!(!n.autoAccept||!n.autoAcceptOnEsc)&&"true"),!1}clearTimeout(s.throttled),s.throttled=setTimeout(function(){s&&s.isVisible()&&s.checkCombos()},100),s.checkMaxLength(),s.last.preVal=""+s.last.val,s.saveLastChange();var r=e.Event(t.events.kbChange);if(r.action=s.last.key,s.$el.trigger(r,[s,s.el]),e.isFunction(n.change))return r.type=t.events.inputChange,n.change(r,s,s.el),!1;n.acceptValid&&n.autoAcceptOnValid&&e.isFunction(n.validate)&&n.validate(s,s.getValue(s.$preview))&&(s.$preview.blur(),s.accept())}}).bind("keydown"+r,function(e){if(s.last.keyPress=e.which,n.alwaysOpen&&!s.isCurrent()&&s.reveal(),e.which===i.tab)return s.tab=!0,!1;if(n.lockInput)return!1;switch(s.last.virtual=!1,e.which){case i.backSpace:t.keyaction.bksp(s,null,e),e.preventDefault();break;case i.enter:t.keyaction.enter(s,null,e);break;case i.capsLock:s.shiftActive=s.capsLock=!s.capsLock,s.showSet();break;case i.V:if(e.ctrlKey||e.metaKey){if(n.preventPaste)return void e.preventDefault();s.checkCombos()}}}).bind("mouseup touchend ".split(" ").join(r+" "),function(){s.last.virtual=!0,s.saveCaret()}),s.$keyboard.bind("mousedown click touchstart ".split(" ").join(s.namespace+" "),function(t){t.stopPropagation(),s.isCurrent()||(s.reveal(),e(s.el.ownerDocument).trigger("checkkeyboard"+s.namespace)),s.setFocus()}),n.preventPaste&&(s.$preview.bind("contextmenu"+s.namespace,function(e){e.preventDefault()}),s.$el.bind("contextmenu"+s.namespace,function(e){e.preventDefault()}))},s.bindKeys=function(){var a=t.css;s.$allKeys=s.$keyboard.find("button."+a.keyButton).unbind(s.namespace+" "+s.namespace+"kb").bind("mouseenter mouseleave touchstart ".split(" ").join(s.namespace+" "),function(t){if(!n.alwaysOpen&&!n.userClosed||"mouseleave"===t.type||s.isCurrent()||(s.reveal(),s.setFocus()),s.isCurrent()&&!this.disabled){var a,i,o=s.last,r=e(this),l=t.type;n.useWheel&&s.wheel&&(a=s.getLayers(r),i=(a.length?a.map(function(){return e(this).attr("data-value")||""}).get():"")||[r.text()],o.wheel_$Keys=a,o.wheelLayers=i,o.wheelIndex=e.inArray(r.attr("data-value"),i)),"mouseenter"!==l&&"touchstart"!==l||"password"===s.el.type||r.hasClass(n.css.buttonDisabled)||(r.addClass(n.css.buttonHover),n.useWheel&&s.wheel&&r.attr("title",function(e,t){return s.wheel&&""===t&&s.sets&&i.length>1&&"touchstart"!==l?n.wheelMessage:t})),"mouseleave"===l&&(r.removeClass("password"===s.el.type?"":n.css.buttonHover),n.useWheel&&s.wheel&&(o.wheelIndex=0,o.wheelLayers=[],o.wheel_$Keys=null,r.attr("title",function(e,t){return t===n.wheelMessage?"":t}).html(r.attr("data-html"))))}}).bind(n.keyBinding.split(" ").join(s.namespace+" ")+s.namespace+" "+t.events.kbRepeater,function(i){if(i.preventDefault(),!s.$keyboard.is(":visible")||this.disabled)return!1;var o,r,l=s.last,c=e(this),d=(new Date).getTime();if(n.useWheel&&s.wheel&&(c=(r=l.wheel_$Keys)&&l.wheelIndex>-1?r.eq(l.wheelIndex):c),o=c.attr("data-action"),!(d-(l.eventTime||0)<n.preventDoubleEventTime)){if(l.eventTime=d,l.event=i,l.virtual=!0,l.$key=c,l.key=c.attr("data-value"),l.keyPress="",s.setFocus(),/^meta/.test(o)&&(o="meta"),o===l.key&&"string"==typeof t.keyaction[o])l.key=o=t.keyaction[o];else if(o in t.keyaction&&e.isFunction(t.keyaction[o])){if(!1===t.keyaction[o](s,this,i))return!1;o=null}return!!s.hasKeyboard()&&(void 0!==o&&null!==o&&(l.key=e(this).hasClass(a.keyAction)?o:l.key,s.insertText(l.key),s.capsLock||n.stickyShift||i.shiftKey||(s.shiftActive=!1,s.showSet(c.attr("data-name")))),t.caret(s.$preview,l),s.checkCombos(),i.type=t.events.kbChange,i.action=l.key,s.$el.trigger(i,[s,s.el]),l.preVal=""+l.val,s.saveLastChange(),e.isFunction(n.change)?(i.type=t.events.inputChange,n.change(i,s,s.el),!1):void 0)}}).bind("mouseup"+s.namespace+" "+"mouseleave touchend touchmove touchcancel ".split(" ").join(s.namespace+"kb "),function(a){s.last.virtual=!0;var i,o=e(this);if("touchmove"===a.type){if(i=o.offset(),i.right=i.left+o.outerWidth(),i.bottom=i.top+o.outerHeight(),a.originalEvent.touches[0].pageX>=i.left&&a.originalEvent.touches[0].pageX<i.right&&a.originalEvent.touches[0].pageY>=i.top&&a.originalEvent.touches[0].pageY<i.bottom)return!0}else/(mouseleave|touchend|touchcancel)/i.test(a.type)?o.removeClass(n.css.buttonHover):(!n.noFocus&&s.isCurrent()&&s.isVisible()&&s.$preview.focus(),s.checkCaret&&t.caret(s.$preview,s.last));return s.mouseRepeat=[!1,""],clearTimeout(s.repeater),n.acceptValid&&n.autoAcceptOnValid&&e.isFunction(n.validate)&&n.validate(s,s.getValue())&&(s.$preview.blur(),s.accept()),!1}).bind("click"+s.namespace,function(){return!1}).not("."+a.keyAction).bind("mousewheel"+s.namespace,function(t,a){if(n.useWheel&&s.wheel){a=a||t.deltaY;var i,o=s.last.wheelLayers||[];return o.length>1?((i=s.last.wheelIndex+(a>0?-1:1))>o.length-1&&(i=0),i<0&&(i=o.length-1)):i=0,s.last.wheelIndex=i,e(this).html(o[i]),!1}}).add("."+a.keyPrefix+"tab bksp space enter".split(" ").join(",."+a.keyPrefix),s.$keyboard).bind("mousedown touchstart ".split(" ").join(s.namespace+"kb "),function(){if(0!==n.repeatRate){var t=e(this);s.mouseRepeat=[!0,t],setTimeout(function(){s&&s.mouseRepeat[0]&&s.mouseRepeat[1]===t&&!t[0].disabled&&s.repeatKey(t)},n.repeatDelay)}return!1})},s.execCommand=function(e,t){s.el.ownerDocument.execCommand(e,!1,t),s.el.normalize(),n.reposition&&s.reposition()},s.getValue=function(e){return(e=e||s.$preview)[s.isContentEditable?"text":"val"]()},s.setValue=function(e,a){return a=a||s.$preview,s.isContentEditable?e!==a.text()&&(t.replaceContent(a,e),s.saveCaret()):a.val(e),s},s.insertText=function(e){if(!s.$preview)return s;if("function"==typeof n.beforeInsert&&(e=n.beforeInsert(s.last.event,s,s.el,e)),void 0===e||!1===e)return s.last.key="",s;if(s.isContentEditable)return s.insertContentEditable(e);var a,i=!1,o="\b"===e,r=s.getValue(),l=t.caret(s.$preview),c=r.length;return l.end<l.start&&(l.end=l.start),l.start>c&&(l.end=l.start=c),"TEXTAREA"===s.preview.nodeName&&t.msie&&"\n"===r.substr(l.start,1)&&(l.start+=1,l.end+=1),a=l.start,"{d}"===e&&(e="",l.end+=1),o&&(e="",i=o&&a===l.end&&a>0),r=r.substr(0,a-(i?1:0))+e+r.substr(l.end),a+=i?-1:e.length,s.setValue(r),s.saveCaret(a,a),s.setScroll(),s},s.insertContentEditable=function(e){return s.$preview.focus(),s.execCommand("insertText",e),s.saveCaret(),s},s.checkMaxLength=function(){if(s.$preview){var e,a,i=s.getValue(),o=s.isContentEditable?t.getEditableLength(s.el):i.length;return!1!==n.maxLength&&o>n.maxLength&&(e=t.caret(s.$preview).start,a=Math.min(e,n.maxLength),n.maxInsert||(i=s.last.val,a=e-1),s.setValue(i.substring(0,n.maxLength)),s.saveCaret(a,a)),s.$decBtn.length&&s.checkDecimal(),s}},s.repeatKey=function(e){e.trigger(t.events.kbRepeater),s.mouseRepeat[0]&&(s.repeater=setTimeout(function(){s&&s.repeatKey(e)},s.repeatTime))},s.getKeySet=function(){var e=[];return s.altActive&&e.push("alt"),s.shiftActive&&e.push("shift"),s.metaActive&&e.push(s.metaActive),e.length?e.join("+"):"normal"},s.showKeySet=function(e){return"string"==typeof e?(s.last.keyset=[s.shiftActive,s.altActive,s.metaActive],s.shiftActive=/shift/i.test(e),s.altActive=/alt/i.test(e),/\bmeta/.test(e)?(s.metaActive=!0,s.showSet(e.match(/\bmeta[\w-]+/i)[0])):(s.metaActive=!1,s.showSet())):s.showSet(e),s},s.showSet=function(e){if(s.hasKeyboard()){n=s.options;var a=t.css,i="."+a.keyPrefix,o=n.css.buttonActive,r="",l=(s.shiftActive?1:0)+(s.altActive?2:0);if(s.shiftActive||(s.capsLock=!1),s.metaActive?(s.shiftActive&&(e=(e||"").replace("-shift","")),s.altActive&&(e=(e||"").replace("-alt","")),""===(r=/^meta/i.test(e)?e:"")?r=!0===s.metaActive?"":s.metaActive:s.metaActive=r,(!n.stickyShift&&s.last.keyset[2]!==s.metaActive||(s.shiftActive||s.altActive)&&!s.$keyboard.find("."+a.keySet+"-"+r+s.rows[l]).length)&&(s.shiftActive=s.altActive=!1)):!n.stickyShift&&s.last.keyset[2]!==s.metaActive&&s.shiftActive&&(s.shiftActive=s.altActive=!1),l=(s.shiftActive?1:0)+(s.altActive?2:0),r=0!==l||s.metaActive?""===r?"":"-"+r:"-normal",!s.$keyboard.find("."+a.keySet+r+s.rows[l]).length)return s.shiftActive=s.last.keyset[0],s.altActive=s.last.keyset[1],void(s.metaActive=s.last.keyset[2]);s.$keyboard.find(i+"alt,"+i+"shift,."+a.keyAction+"[class*=meta]").removeClass(o).end().find(i+"alt").toggleClass(o,s.altActive).end().find(i+"shift").toggleClass(o,s.shiftActive).end().find(i+"lock").toggleClass(o,s.capsLock).end().find("."+a.keySet).hide().end().find("."+(a.keyAction+i+r).replace("--","-")).addClass(o),s.$keyboard.find("."+a.keySet+r+s.rows[l])[0].style.display="inline-block",s.metaActive&&s.$keyboard.find(i+s.metaActive).toggleClass(o,!1!==s.metaActive),s.last.keyset=[s.shiftActive,s.altActive,s.metaActive],s.$el.trigger(t.events.kbKeysetChange,[s,s.el]),n.reposition&&s.reposition()}},s.checkCombos=function(){if(!(s.isVisible()||s.hasKeyboard()&&s.$keyboard.hasClass(t.css.hasFocus)))return s.getValue(s.$preview||s.$el);var i,o,r,l,c=s.getValue(),d=t.caret(s.$preview),u=t.builtLayouts[s.layout],p=s.isContentEditable?t.getEditableLength(s.el):c.length,h=p;return""===c?(n.acceptValid&&s.checkValid(),c):(d.end<d.start&&(d.end=d.start),d.start>h&&(d.end=d.start=h),t.msie&&"\n"===c.substr(d.start,1)&&(d.start+=1,d.end+=1),n.useCombos&&(t.msie?c=c.replace(s.regex,function(e,t,a){return n.combos.hasOwnProperty(t)?n.combos[t][a]||e:e}):s.$preview.length&&(o=d.start-(d.start-2>=0?2:0),t.caret(s.$preview,o,d.end),r=(l=function(e){return(e||"").replace(s.regex,function(e,t,a){return n.combos.hasOwnProperty(t)?n.combos[t][a]||e:e})})((o=t.caret(s.$preview)).text),o&&o.replaceStr&&r!==o.text&&(s.isContentEditable?t.replaceContent(a,l):s.setValue(o.replaceStr(r))),c=s.getValue())),n.restrictInput&&""!==c&&(o=u.acceptedKeys.length,(i=u.acceptedKeysRegex)||(r=e.map(u.acceptedKeys,function(e){return e.replace(s.escapeRegex,"\\$&")}),i=u.acceptedKeysRegex=new RegExp("("+r.join("|")+")","g")),(r=c.match(i))?c=r.join(""):(c="",h=0)),d.start+=p-h,d.end+=p-h,s.setValue(c),s.saveCaret(d.start,d.end),s.setScroll(),s.checkMaxLength(),n.acceptValid&&s.checkValid(),c)},s.checkValid=function(){var a=t.css,i=s.$keyboard.find("."+a.keyPrefix+"accept"),o=!0;e.isFunction(n.validate)&&(o=n.validate(s,s.getValue(),!1)),i.toggleClass(a.inputInvalid,!o).toggleClass(a.inputValid,o).attr("title",i.attr("data-title")+" ("+n.display[o?"valid":"invalid"]+")")},s.checkDecimal=function(){s.decimal&&/\./g.test(s.preview.value)||!s.decimal&&/\,/g.test(s.preview.value)?s.$decBtn.attr({disabled:"disabled","aria-disabled":"true"}).removeClass(n.css.buttonHover).addClass(n.css.buttonDisabled):s.$decBtn.removeAttr("disabled").attr({"aria-disabled":"false"}).addClass(n.css.buttonDefault).removeClass(n.css.buttonDisabled)},s.getLayers=function(a){var i=t.css,n=a.attr("data-pos");return a.closest("."+i.keyboard).find('button[data-pos="'+n+'"]').filter(function(){return""!==e(this).find("."+i.keyText).text()}).add(a)},s.switchInput=function(t,a){if(e.isFunction(n.switchInput))n.switchInput(s,t,a);else{s.$keyboard.length&&s.$keyboard.hide();var i,o=!1,r=e("button, input, select, textarea, a, [contenteditable]").filter(":visible").not(":disabled"),l=r.index(s.$el)+(t?1:-1);if(s.$keyboard.length&&s.$keyboard.show(),l>r.length-1&&(o=n.stopAtEnd,l=0),l<0&&(o=n.stopAtEnd,l=r.length-1),!o){if(!(a=s.close(a)))return;(i=r.eq(l).data("keyboard"))&&i.options.openOn.length?i.focusOn():r.eq(l).focus()}}return!1},s.close=function(a){if(s.isOpen&&s.$keyboard.length){clearTimeout(s.throttled);var i=t.css,o=t.events,r=a?s.checkCombos():s.originalContent;if(a&&e.isFunction(n.validate)&&!n.validate(s,r,!0)&&(r=s.originalContent,a=!1,n.cancelClose))return;s.isCurrent(!1),s.isOpen=n.alwaysOpen||n.userClosed,s.isContentEditable&&!a?s.$el.html(r):s.setValue(r,s.$el),s.$el.removeClass(i.isCurrent+" "+i.inputAutoAccepted).addClass(a?!0===a?"":i.inputAutoAccepted:"").trigger(o.inputChange),n.alwaysOpen||s.$el.trigger(o.kbBeforeClose,[s,s.el,a||!1]),t.caret(s.$preview,s.last),s.$el.trigger(a?o.inputAccepted:o.inputCanceled,[s,s.el]).trigger(n.alwaysOpen?o.kbInactive:o.kbHidden,[s,s.el]).blur(),s&&(s.last.eventTime=(new Date).getTime(),n.alwaysOpen||n.userClosed&&"true"===a||!s.$keyboard.length||(s.removeKeyboard(),s.timer=setTimeout(function(){s&&s.bindFocus()},500)),s.watermark||""!==s.el.value||""===s.inPlaceholder||(s.$el.addClass(i.placeholder),s.setValue(s.inPlaceholder,s.$el)))}return!!a},s.accept=function(){return s.close(!0)},s.checkClose=function(t){if(!s.opening){var a=e.keyboard.css,i=t.target.nodeName,o="INPUT"===i||"TEXTAREA"===i?e(t.target):e(t.target).closest("[contenteditable]");if(s.escClose(t,o),o.hasClass(a.input)){var r=o.data("keyboard");r!==s&&!r.$el.hasClass(a.isCurrent)&&r.options.openOn&&t.type===n.openOn&&r.focusOn()}}},s.escCloseCallback={keepOpen:function(e){return!s.isOpen}},s.escClose=function(a,i){if(a&&"keyup"===a.type)return a.which!==t.keyCodes.escape||n.ignoreEsc?"":s.close(!(!n.autoAccept||!n.autoAcceptOnEsc)&&"true");var o=!1,r=i||e(a.target);if(e.each(s.escCloseCallback,function(e,t){"function"==typeof t&&(o=o||t(r))}),!o&&(!s.isCurrent()&&s.isOpen||s.isOpen&&r[0]!==s.el)){if((n.stayOpen||n.userClosed)&&!r.hasClass(t.css.input))return;if(t.allie&&a.preventDefault(),n.closeByClickEvent){var l=r[0]&&r[0].nodeName.toLowerCase();"input"!==l&&"textarea"!==l&&"click"!==a.type||s.close(!!n.autoAccept&&"true")}else s.close(!!n.autoAccept&&"true")}},s.keyBtn=e("<button />").attr({role:"button",type:"button","aria-disabled":"false",tabindex:"-1"}).addClass(t.css.keyButton),s.processName=function(e){var t,a,i=(e||"").replace(/[^a-z0-9-_]/gi,""),n=i.length,s=[];if(n>1&&e===i)return e;if(n=e.length){for(t=0;t<n;t++)a=e[t],s.push(/[a-z0-9-_]/i.test(a)?/[-_]/.test(a)&&0!==t?"":a:(0===t?"":"-")+a.charCodeAt(0));return s.join("")}return e},s.processKeys=function(t){var a,i=t.split(":"),n={name:null,map:"",title:""};return/\(.+\)/.test(i[0])||/^:\(.+\)/.test(t)||/\([(:)]\)/.test(t)?/\([(:)]\)/.test(t)?(a=i[0].match(/([^(]+)\((.+)\)/))&&a.length?(n.name=a[1],n.map=a[2],n.title=i.length>1?i.slice(1).join(":"):""):(n.name=t.match(/([^(]+)/)[0],":"===n.name&&(i=i.slice(1)),null===a&&(n.map=":",i=i.slice(2)),n.title=i.length?i.join(":"):""):(n.map=t.match(/\(([^()]+?)\)/)[1],""===(a=(t=t.replace(/\(([^()]+)\)/,"")).split(":"))[0]?(n.name=":",i=i.slice(1)):n.name=a[0],n.title=i.length>1?i.slice(1).join(":"):""):(""!==t&&""===i[0]?(n.name=":",i=i.slice(1)):n.name=i[0],n.title=i.length>1?i.slice(1).join(":"):""),n.title=e.trim(n.title).replace(/_/g," "),n},s.addKey=function(e,a,i){var o,r,l,c={},d=s.processKeys(i?e:a),u=t.css;return!i&&n.display[d.name]?(l=s.processKeys(n.display[d.name])).action=s.processKeys(e).name:(l=d).action=d.name,c.name=s.processName(d.name),""!==l.name&&(""!==l.map?(t.builtLayouts[s.layout].mappedKeys[l.map]=l.name,t.builtLayouts[s.layout].acceptedKeys.push(l.name)):i&&t.builtLayouts[s.layout].acceptedKeys.push(l.name)),o=i?""===c.name?"":u.keyPrefix+c.name:u.keyAction+" "+u.keyPrefix+l.action,o+=(l.name.length>2?" "+u.keyWide:"")+" "+n.css.buttonDefault,c.html='<span class="'+u.keyText+'">'+l.name.replace(/[\u00A0-\u9999]/gim,function(e){return"&#"+e.charCodeAt(0)+";"})+"</span>",c.$key=s.keyBtn.clone().attr({"data-value":i?l.name:l.action,"data-name":l.action,"data-pos":s.temp[1]+","+s.temp[2],"data-action":l.action,"data-html":c.html}).addClass(o).html(c.html).appendTo(s.temp[0]),l.map&&c.$key.attr("data-mapped",l.map),(l.title||d.title)&&c.$key.attr({"data-title":d.title||l.title,title:d.title||l.title}),"function"==typeof n.buildKey&&(r=(c=n.buildKey(s,c)).$key.html(),c.$key.attr("data-html",r)),c.$key},s.customHash=function(e){var t,a,i,s,o=[],r=[];e=void 0===e?n.customLayout:e;for(a in e)e.hasOwnProperty(a)&&o.push(e[a]);if(r=r.concat.apply(r,o).join(" "),i=0,0===(s=r.length))return i;for(t=0;t<s;t++)i=(i<<5)-i+r.charCodeAt(t),i&=i;return i},s.buildKeyboard=function(a,i){e.isEmptyObject(n.display)&&s.updateLanguage();var o,r,l,c,d=t.css,u=0,p=t.builtLayouts[a||s.layout||n.layout]={mappedKeys:{},acceptedKeys:[]},h=p.acceptedKeys=n.restrictInclude?(""+n.restrictInclude).split(/\s+/)||[]:[],y=d.keyboard+" "+n.css.popup+" "+n.css.container+(n.alwaysOpen||n.userClosed?" "+d.alwaysOpen:""),b=e("<div />").addClass(y).attr({role:"textbox"}).hide();return(o=e.inArray("{space}",h))>-1&&(h[o]=" "),i&&"custom"===n.layout||!t.layouts.hasOwnProperty(n.layout)?(n.layout="custom",y=t.layouts.custom=n.customLayout||{normal:["{cancel}"]}):y=t.layouts[i?n.layout:a||s.layout||n.layout],e.each(y,function(t,a){if(""!==t&&!/^(name|lang|rtl)$/i.test(t))for("default"===t&&(t="normal"),u++,l=e("<div />").attr("name",t).addClass(d.keySet+" "+d.keySet+"-"+t).appendTo(b).toggle("normal"===t),r=0;r<a.length;r++)c=e.trim(a[r]).replace(/\{(\.?)[\s+]?:[\s+]?(\.?)\}/g,"{$1:$2}"),s.buildRow(l,r,c.split(/\s+/),h),l.find("."+d.keyButton+",."+d.keySpacer).filter(":last").after('<br class="'+d.endRow+'"/>')}),u>1&&(s.sets=!0),p.hasMappedKeys=!e.isEmptyObject(p.mappedKeys),p.$keyboard=b,b},s.buildRow=function(a,i,o,r){var l,c,d,u,p,h,y=t.css;for(d=0;d<o.length;d++)if(s.temp=[a,i,d],u=!1,0!==o[d].length)if(/^\{\S+\}$/.test(o[d])){if(p=o[d].match(/^\{(\S+)\}$/)[1],/\!\!/.test(p)&&(p=p.replace("!!",""),u=!0),/^sp:((\d+)?([\.|,]\d+)?)(em|px)?$/i.test(p)&&(h=parseFloat(p.replace(/,/,".").match(/^sp:((\d+)?([\.|,]\d+)?)(em|px)?$/i)[1]||0),e('<span class="'+y.keyText+'"></span>').width(p.match(/px/i)?h+"px":2*h+"em").addClass(y.keySpacer).appendTo(a)),/^empty(:((\d+)?([\.|,]\d+)?)(em|px)?)?$/i.test(p)){h=/:/.test(p)?parseFloat(p.replace(/,/,".").match(/^empty:((\d+)?([\.|,]\d+)?)(em|px)?$/i)[1]||0):"",s.addKey(""," ",!0).addClass(n.css.buttonDisabled+" "+n.css.buttonEmpty).attr("aria-disabled",!0).width(h?p.match("px")?h+"px":2*h+"em":"");continue}if(/^meta[\w-]+\:?(\w+)?/i.test(p)){s.addKey(p.split(":")[0],p).addClass(y.keyHasActive);continue}switch((c=p.split(":"))[0].toLowerCase()){case"a":case"accept":s.addKey("accept",p).addClass(n.css.buttonAction+" "+y.keyAction);break;case"alt":case"altgr":s.addKey("alt",p).addClass(y.keyHasActive);break;case"b":case"bksp":s.addKey("bksp",p);break;case"c":case"cancel":s.addKey("cancel",p).addClass(n.css.buttonAction+" "+y.keyAction);break;case"combo":s.addKey("combo",p).addClass(y.keyHasActive).attr("title",function(e,t){return t+" "+n.display[n.useCombos?"active":"disabled"]}).toggleClass(n.css.buttonActive,n.useCombos);break;case"dec":r.push(s.decimal?".":","),s.addKey("dec",p);break;case"e":case"enter":s.addKey("enter",p).addClass(n.css.buttonAction+" "+y.keyAction);break;case"lock":s.addKey("lock",p).addClass(y.keyHasActive);break;case"s":case"shift":s.addKey("shift",p).addClass(y.keyHasActive);break;case"sign":r.push("-"),s.addKey("sign",p);break;case"space":r.push(" "),s.addKey("space",p);break;case"t":case"tab":s.addKey("tab",p);break;default:t.keyaction.hasOwnProperty(c[0])&&s.addKey(c[0],p).toggleClass(n.css.buttonAction+" "+y.keyAction,u)}}else l=o[d],s.addKey(l,l,!0)},s.removeBindings=function(t){e(document).unbind(t),s.el.ownerDocument!==document&&e(s.el.ownerDocument).unbind(t),e(window).unbind(t),s.$el.unbind(t)},s.removeKeyboard=function(){s.$allKeys=[],s.$decBtn=[],n.usePreview&&s.$preview.removeData("keyboard"),s.$preview.unbind(s.namespace+"keybindings"),s.preview=null,s.$preview=null,s.$previewCopy=null,s.$keyboard.removeData("keyboard"),s.$keyboard.remove(),s.$keyboard=[],s.isOpen=!1,s.isCurrent(!1)},s.destroy=function(e){var a,i=t.css,o=s.extensionNamespace.length,r=[i.input,i.locked,i.placeholder,i.noKeyboard,i.alwaysOpen,n.css.input,i.isCurrent].join(" ");for(clearTimeout(s.timer),clearTimeout(s.timer2),clearTimeout(s.timer3),s.$keyboard.length&&s.removeKeyboard(),s.removeBindings(s.namespace),s.removeBindings(s.namespace+"callbacks"),a=0;a<o;a++)s.removeBindings(s.extensionNamespace[a]);s.el.active=!1,s.$el.removeClass(r).removeAttr("aria-haspopup").removeAttr("role").removeData("keyboard"),s=null,"function"==typeof e&&e()},s.init()};return t.keyCodes={backSpace:8,tab:9,enter:13,capsLock:20,escape:27,space:32,pageUp:33,pageDown:34,end:35,home:36,left:37,up:38,right:39,down:40,insert:45,delete:46,A:65,Z:90,V:86,C:67,X:88,a:97,z:122},t.css={idSuffix:"_keyboard",initialFocus:"keyboard-init-focus",input:"ui-keyboard-input",inputClone:"ui-keyboard-preview-clone",wrapper:"ui-keyboard-preview-wrapper",preview:"ui-keyboard-preview",keyboard:"ui-keyboard",keySet:"ui-keyboard-keyset",keyButton:"ui-keyboard-button",keyWide:"ui-keyboard-widekey",keyPrefix:"ui-keyboard-",keyText:"ui-keyboard-text",keyHasActive:"ui-keyboard-hasactivestate",keyAction:"ui-keyboard-actionkey",keySpacer:"ui-keyboard-spacer",keyToggle:"ui-keyboard-toggle",keyDisabled:"ui-keyboard-disabled",divWrapperCE:"ui-keyboard-div-wrapper",locked:"ui-keyboard-lockedinput",alwaysOpen:"ui-keyboard-always-open",noKeyboard:"ui-keyboard-nokeyboard",placeholder:"ui-keyboard-placeholder",hasFocus:"ui-keyboard-has-focus",isCurrent:"ui-keyboard-input-current",inputValid:"ui-keyboard-valid-input",inputInvalid:"ui-keyboard-invalid-input",inputAutoAccepted:"ui-keyboard-autoaccepted",endRow:"ui-keyboard-button-endrow"},t.events={kbChange:"keyboardChange",kbBeforeClose:"beforeClose",kbBeforeVisible:"beforeVisible",kbVisible:"visible",kbInit:"initialized",kbInactive:"inactive",kbHidden:"hidden",kbRepeater:"repeater",kbKeysetChange:"keysetChange",inputAccepted:"accepted",inputCanceled:"canceled",inputChange:"change",inputRestricted:"restricted"},t.keyaction={accept:function(e){return e.close(!0),!1},alt:function(e){e.altActive=!e.altActive,e.showSet()},bksp:function(e){e.isContentEditable?(e.execCommand("delete"),e.saveCaret()):e.insertText("\b")},cancel:function(e){return e.close(),!1},clear:function(e){e.$preview[e.isContentEditable?"text":"val"](""),e.$decBtn.length&&e.checkDecimal()},combo:function(e){var a=e.options,i=!a.useCombos,n=e.$keyboard.find("."+t.css.keyPrefix+"combo");return a.useCombos=i,n.toggleClass(a.css.buttonActive,i).attr("title",n.attr("data-title")+" ("+a.display[i?"active":"disabled"]+")"),i&&e.checkCombos(),!1},dec:function(e){e.insertText(e.decimal?".":",")},del:function(e){e.isContentEditable?e.execCommand("forwardDelete"):e.insertText("{d}")},default:function(e){e.shiftActive=e.altActive=e.metaActive=!1,e.showSet()},enter:function(a,i,n){var s=a.el.nodeName,o=a.options;return n.shiftKey?o.enterNavigation?a.switchInput(!n[o.enterMod],!0):a.close(!0):o.enterNavigation&&("TEXTAREA"!==s||n[o.enterMod])?a.switchInput(!n[o.enterMod],!!o.autoAccept&&"true"):("TEXTAREA"===s&&e(n.target).closest("button").length&&a.insertText((t.msie?" ":"")+"\n"),void(a.isContentEditable&&!o.enterNavigation&&(a.execCommand("insertHTML",'<div><br class="'+t.css.divWrapperCE+'"></div>'),setTimeout(function(){t.keyaction.right(a),a.saveCaret()},0))))},lock:function(e){e.last.keyset[0]=e.shiftActive=e.capsLock=!e.capsLock,e.showSet()},left:function(e){var a=t.caret(e.$preview);a.start-1>=0&&(e.last.start=e.last.end=a.start-1,t.caret(e.$preview,e.last),e.setScroll())},meta:function(t,a){var i=e(a);t.metaActive=!i.hasClass(t.options.css.buttonActive),t.showSet(i.attr("data-name"))},next:function(e){return e.switchInput(!0,e.options.autoAccept),!1},normal:function(e){e.shiftActive=e.altActive=e.metaActive=!1,e.showSet()},prev:function(e){return e.switchInput(!1,e.options.autoAccept),!1},right:function(e){var a=t.caret(e.$preview),i=e.isContentEditable?t.getEditableLength(e.el):e.getValue().length;a.end+1<=i&&(e.last.start=e.last.end=a.end+1,t.caret(e.$preview,e.last),e.setScroll())},shift:function(e){e.last.keyset[0]=e.shiftActive=!e.shiftActive,e.showSet()},sign:function(e){if(/^[+-]?\d*\.?\d*$/.test(e.getValue())){var a,i=t.caret(e.$preview),n=e.getValue(),s=e.isContentEditable?t.getEditableLength(e.el):n.length;e.setValue(-1*n),a=s-n.length,e.last.start=i.start+a,e.last.end=i.end+a,t.caret(e.$preview,e.last),e.setScroll()}},space:function(e){e.insertText(" ")},tab:function(e){var t=e.el.nodeName,a=e.options;if("TEXTAREA"!==t){if(a.tabNavigation)return e.switchInput(!e.shiftActive,!0);if("INPUT"===t)return!1}e.insertText("\t")},toggle:function(e){e.enabled=!e.enabled,e.toggle()},NBSP:" ",ZWSP:"",ZWNJ:"",ZWJ:"",LRM:"",RLM:""},t.builtLayouts={},t.layouts={alpha:{normal:["` 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:{normal:["` 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:{normal:["` 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:["~ ¡ ² ³ ¤ € ¼ ½ ¾ ‘ ’ ¥ × {bksp}","{tab} ä å é ® þ ü ú í ó ö « » ¬","á ß ð f g h j k ø ¶ ´ {enter}","{shift} æ x © v b ñ µ ç > ¿ {shift}","{accept} {alt} {space} {alt} {cancel}"],"alt-shift":["~ ¹ ² ³ £ € ¼ ½ ¾ ‘ ’ ¥ ÷ {bksp}","{tab} Ä Å É ® Þ Ü Ú Í Ó Ö « » ¦","Ä § Ð F G H J K Ø ° ¨ {enter}","{shift} Æ X ¢ V B Ñ µ Ç . ¿ {shift}","{accept} {alt} {space} {alt} {cancel}"]},colemak:{normal:["` 1 2 3 4 5 6 7 8 9 0 - = {bksp}","{tab} q w f p g j l u y ; [ ] \\","{bksp} a r s t d h n e i o ' {enter}","{shift} z x c v b k m , . / {shift}","{accept} {space} {cancel}"],shift:["~ ! @ # $ % ^ & * ( ) _ + {bksp}","{tab} Q W F P G J L U Y : { } |",'{bksp} A R S T D H N E I O " {enter}',"{shift} Z X C V B K M < > ? {shift}","{accept} {space} {cancel}"]},dvorak:{normal:["` 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:{normal:["= ( ) {b}","{clear} / * -","7 8 9 +","4 5 6 {sign}","1 2 3 %","0 {dec} {a} {c}"]}},t.language={en:{display:{a:"✔:Accept (Shift+Enter)",accept:"Accept:Accept (Shift+Enter)",alt:"Alt:⌥ AltGr",b:"⌫:Backspace",bksp:"Bksp:Backspace",c:"✖:Cancel (Esc)",cancel:"Cancel:Cancel (Esc)",clear:"C:Clear",combo:"ö:Toggle Combo Keys",dec:".:Decimal",e:"⏎:Enter",empty:" ",enter:"Enter:Enter ⏎",left:"←",lock:"Lock:⇪ Caps Lock",next:"Next ⇨",prev:"⇦ Prev",right:"→",s:"⇧:Shift",shift:"Shift:Shift",sign:"±:Change Sign",space:" :Space",t:"⇥:Tab",tab:"⇥ Tab:Tab",toggle:" ",valid:"valid",invalid:"invalid",active:"active",disabled:"disabled"},wheelMessage:"Use mousewheel to see other keys",comboRegex:/([`\'~\^\"ao])([a-z])/gim,combos:{"`":{a:"à",A:"À",e:"è",E:"È",i:"ì",I:"Ì",o:"ò",O:"Ò",u:"ù",U:"Ù",y:"ỳ",Y:"Ỳ"},"'":{a:"á",A:"Á",e:"é",E:"É",i:"í",I:"Í",o:"ó",O:"Ó",u:"ú",U:"Ú",y:"ý",Y:"Ý"},'"':{a:"ä",A:"Ä",e:"ë",E:"Ë",i:"ï",I:"Ï",o:"ö",O:"Ö",u:"ü",U:"Ü",y:"ÿ",Y:"Ÿ"},"^":{a:"â",A:"Â",e:"ê",E:"Ê",i:"î",I:"Î",o:"ô",O:"Ô",u:"û",U:"Û",y:"ŷ",Y:"Ŷ"},"~":{a:"ã",A:"Ã",e:"ẽ",E:"Ẽ",i:"ĩ",I:"Ĩ",o:"õ",O:"Õ",u:"ũ",U:"Ũ",y:"ỹ",Y:"Ỹ",n:"ñ",N:"Ñ"}}}},t.defaultOptions={language:null,rtl:!1,layout:"qwerty",customLayout:null,position:{of:null,my:"center top",at:"center top",at2:"center bottom"},reposition:!0,usePreview:!0,alwaysOpen:!1,initialFocus:!0,noFocus:!1,stayOpen:!1,userClosed:!1,ignoreEsc:!1,closeByClickEvent:!1,css:{input:"ui-widget-content ui-corner-all",container:"ui-widget-content ui-widget ui-corner-all ui-helper-clearfix",popup:"",buttonDefault:"ui-state-default ui-corner-all",buttonHover:"ui-state-hover",buttonAction:"ui-state-active",buttonActive:"ui-state-active",buttonDisabled:"ui-state-disabled",buttonEmpty:"ui-keyboard-empty"},autoAccept:!1,autoAcceptOnEsc:!1,lockInput:!1,restrictInput:!1,restrictInclude:"",acceptValid:!1,autoAcceptOnValid:!1,cancelClose:!0,tabNavigation:!1,enterNavigation:!1,enterMod:"altKey",stopAtEnd:!0,appendLocally:!1,appendTo:"body",wrapBRs:!0,stickyShift:!0,preventPaste:!1,caretToEnd:!1,scrollAdjustment:10,maxLength:!1,maxInsert:!0,repeatDelay:500,repeatRate:20,resetDefault:!0,openOn:"focus",keyBinding:"mousedown touchstart",useWheel:!0,useCombos:!0,validate:function(e,t,a){return!0}},t.comboRegex=/([`\'~\^\"ao])([a-z])/gim,t.currentKeyboard="",e('\x3c!--[if lte IE 8]><script>jQuery("body").addClass("oldie");<\/script><![endif]--\x3e\x3c!--[if IE]><script>jQuery("body").addClass("ie");<\/script><![endif]--\x3e').appendTo("body").remove(),t.msie=e("body").hasClass("oldie"),t.allie=e("body").hasClass("ie"),t.watermark=void 0!==document.createElement("input").placeholder,t.checkCaretSupport=function(){if("boolean"!=typeof t.checkCaret){var a=e('<div style="height:0px;width:0px;overflow:hidden;position:fixed;top:0;left:-100px;"><input type="text" value="testing"/></div>').prependTo("body");t.caret(a.find("input"),3,3),t.checkCaret=3!==t.caret(a.find("input").hide().show()).start,a.remove()}return t.checkCaret},t.caret=function(e,a,i){if(!e.length||e.is(":hidden")||"hidden"===e.css("visibility"))return{};var n,s,o,r,l=e.data("keyboard"),c=l&&l.options.noFocus,d=/(textarea|input)/i.test(e[0].nodeName);return c||e.focus(),void 0!==a?("object"==typeof a&&"start"in a&&"end"in a?(n=a.start,s=a.end):void 0===i&&(i=a),"number"==typeof a&&"number"==typeof i?(n=a,s=i):"start"===a?n=s=0:"string"==typeof a&&(n=s="end"),d?e.caret(n,s,c):t.setEditableCaret(e,n,s)):(r=d?e.caret():t.getEditableCaret(e[0]),n=r.start,s=r.end,o=d&&e[0].value||e.text()||"",{start:n,end:s,text:o.substring(n,s),replaceStr:function(e){return o.substring(0,n)+e+o.substring(s,o.length)}})},t.isTextNode=function(e){return e&&3===e.nodeType},t.isBlock=function(e,t){var a=e.ownerDocument.defaultView;return t&&1===t.nodeType&&t!==e&&"block"===a.getComputedStyle(t).display?1:0},t.wrapBRs=function(a){var i=e(a).find("br:not(."+t.css.divWrapperCE+")");i.length&&e.each(i,function(i,n){var s=n.parentNode.childNodes.length;(1!==s||1===s&&!t.isBlock(a,n.parentNode))&&e(n).addClass(t.css.divWrapperCE).wrap("<div>")})},t.getEditableCaret=function(a){function i(i,n){function s(e){e&&(u+=e,c+=o&&o.replaceCR||"\n")}for(var r,l,c="",d=!1,u=0,p=e.makeArray(a.childNodes);!d&&p.length;){if((r=p.shift())===i&&(d=!0),l=t.isBlock(a,r.previousSibling),s(l),t.isTextNode(r)){if(u+=d?n:r.length,c+=r.textContent,d)return{position:u,text:c}}else!d&&r.childNodes&&(p=e.makeArray(r.childNodes).concat(p));s(l=t.isTextNode(r.previousSibling)&&t.isBlock(a,r))}return{position:u,text:c}}if(!(a=e(a)[0]).isContentEditable)return{};var n,s,o=(e(a).data("keyboard")||{}).options,r=a.ownerDocument.getSelection().getRangeAt(0),l=i(r.startContainer,r.startOffset),c=l.position;return!1!==o.wrapBRs&&t.wrapBRs(a),r.endContainer===r.startContainer&&r.endOffset===r.startOffset?(n=c,s=""):(n=(l=i(r.endContainer,r.endOffset)).position,s=l.text.substring(c,n)),{start:c,end:n,text:s}},t.getEditableLength=function(e){var a=t.setEditableCaret(e,"getMax");return"number"==typeof a?a:null},t.setEditableCaret=function(a,i,n){function s(i){function n(e){return l+=e?c&&c.replaceCR||"\n":"",e>0}function s(e){var t=u+e;return p=h,h+=e,i-t>=0?(u=t,i-u<=0):i-t<=0}"end"===i?i=a.innerHTML.length:i<0&&(i=0);for(var o,r,l="",d=!1,u=0,p=0,h=0,y=e.makeArray(a.childNodes);!d&&y.length;)if(o=y.shift(),r=t.isBlock(a,o.previousSibling),n(r)&&s(r)&&(d=!0),r=t.isTextNode(o.previousSibling)&&t.isBlock(a,o),n(r)&&s(r)&&(d=!0),t.isTextNode(o)){if(l+=o.textContent,s(o.length))return r=i-u==0&&u-p>=1?o.length:i-u,{node:o,offset:r,position:i,text:l}}else!d&&o.childNodes&&(y=e.makeArray(o.childNodes).concat(y));return y.length?{node:o,offset:i-u,position:i,text:l}:{node:o,offset:o&&o.length||0,position:h,text:l}}if(!(a=e(a)[0]).isContentEditable)return{};var o=a.ownerDocument,r=o.createRange(),l=o.getSelection(),c=(e(a).data("keyboard")||{}).options,d=i,u=n,p="",h=s("getMax"===i?"end":i);if(h.node){if(d=h.position,"getMax"===i)return d;r.setStart(h.node,h.offset),void 0!==n&&n!==i&&(h=s(n)),h.node&&(u=h.position,r.setEnd(h.node,h.offset),p=d===u?"":h.text.substring(d,u)),l.removeAllRanges(),l.addRange(r)}return{start:d,end:u,text:p}},t.replaceContent=function(a,i){a=e(a)[0];for(var n,s,o,r=typeof i,l=t.getEditableCaret(a).start,c=0,d=[a];n=d.pop();)if(t.isTextNode(n))"function"===r?l>=c&&l<=c+n.length&&(n.textContent=i(n.textContent)):"string"===r&&(o=i.substring(c,c+n.length))!==n.textContent&&(n.textContent=o),c+=n.length;else if(n&&n.childNodes)for(s=n.childNodes.length;s--;)d.push(n.childNodes[s]);s=t.getEditableCaret(a),t.setEditableCaret(a,s.start,s.start)},e.fn.keyboard=function(t){return this.each(function(){e(this).data("keyboard")||new e.keyboard(this,t)})},e.fn.getkeyboard=function(){return this.data("keyboard")},e.fn.caret=function(e,t,a){if(void 0===this[0]||this.is(":hidden")||"hidden"===this.css("visibility")||!/(INPUT|TEXTAREA)/.test(this[0].nodeName))return this;var i,n,s,o,r,l=this,c=l[0],d=c.ownerDocument.selection,u=c.scrollTop,p=!1,h=!0;try{p="selectionStart"in c}catch(e){h=!1}return h&&void 0!==e?(/(email|number)/i.test(c.type)||(p?(c.selectionStart=e,c.selectionEnd=t):((i=c.createTextRange()).collapse(!0),i.moveStart("character",e),i.moveEnd("character",t-e),i.select())),a||!l.is(":visible")&&"hidden"===l.css("visibility")||c.focus(),c.scrollTop=u,this):(/(email|number)/i.test(c.type)?e=t=l.val().length:p?(e=c.selectionStart,t=c.selectionEnd):d?"TEXTAREA"===c.nodeName?(r=l.val(),(s=(n=d.createRange()).duplicate()).moveToElementText(c),s.setEndPoint("EndToEnd",n),e=s.text.replace(/\r/g,"\n").length,t=e+n.text.replace(/\r/g,"\n").length):(r=l.val().replace(/\r/g,"\n"),(n=d.createRange().duplicate()).moveEnd("character",r.length),e=""===n.text?r.length:r.lastIndexOf(n.text),(n=d.createRange().duplicate()).moveStart("character",-r.length),t=n.text.length):e=t=(c.value||"").length,o=c.value||"",{start:e,end:t,text:o.substring(e,t),replace:function(a){return o.substring(0,e)+a+o.substring(t,o.length)}})},t}); |