diff --git a/README.md b/README.md index 26de326..2d57174 100644 --- a/README.md +++ b/README.md @@ -306,3 +306,7 @@ In this release I have addressed several issues related to how the keyboard hand #### Version 1.1.5 * Revised code to search local languages first, then pull from CDN. + +#### Version 1.1.6 + +* Corrected .klc file name typo of "azeri-lstin" -> "azeri-latin". Left mispelled file also for legacy support. diff --git a/dist/main.js b/dist/main.js index 3506cc2..751e57c 100644 --- a/dist/main.js +++ b/dist/main.js @@ -1 +1 @@ -"use strict";function _slicedToArray(e,t){return _arrayWithHoles(e)||_iterableToArrayLimit(e,t)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}function _iterableToArrayLimit(e,t){var a=[],r=!0,o=!1,l=void 0;try{for(var n,c=e[Symbol.iterator]();!(r=(n=c.next()).done)&&(a.push(n.value),!t||a.length!==t);r=!0);}catch(e){o=!0,l=e}finally{try{r||null==c.return||c.return()}finally{if(o)throw l}}return a}function _arrayWithHoles(e){if(Array.isArray(e))return e}$.fn.keyboard=function(e){var y,r,n,k,b,t,a,o,l,c,i,s,d,p,u,h,g,f,v,w,m,x,C,E,K,T,A,S,_,O,F,L,q,R,D,P,N,I,Y,j,M,U,H,J,B,G,W,z,Q,V,X,Z,ee,te,ae,re,oe,le,ne,ce,ie=["ar-SA","fa-IR","he-IL","ur-PK"],se={29:0,"02":1,"03":2,"04":3,"05":4,"06":5,"07":6,"08":7,"09":8,"0a":9,"0b":10,"0c":11,"0d":12,10:13,11:14,12:15,13:16,14:17,15:18,16:19,17:20,18:21,19:22,"1a":23,"1b":24,"2b":25,"1e":26,"1f":27,20:28,21:29,22:30,23:31,24:32,25:33,26:34,27:35,28:36,"2c":37,"2d":38,"2e":39,"2f":40,30:41,31:42,32:43,33:44,34:45,35:46},de="",pe=!1,ye="text",ke={shift:!1,caps:!1,altgrp:!1,shift_altgrp:""},be="text",ue=!1,he=0,ge="",fe=$(this),ve=!1,we={keyboardFile:"",arrayPosition:""},$e="LTR",me="Language",xe=":",Ce="triggerKeyboard",Ee="https://cdn.jsdelivr.net/npm/mok-project@".concat("1.1.5","/dist/languages"),Ke=(i=(c=e).acceptColor,s=void 0===i?"#2ECC71":i,d=c.acceptTextColor,p=void 0===d?"#FFFFFF":d,u=c.allowEnterAccept,h=void 0===u||u,g=c.allowEscapeCancel,f=void 0===g||g,v=c.altKey,w=void 0===v?"":v,m=c.blackoutColor,x=void 0===m?"25, 25, 25, 0.9":m,C=c.cancelColor,E=void 0===C?"#E74C3C":C,K=c.cancelTextColor,T=void 0===K?"#FFFFFF":K,A=c.capsLightColor,S=void 0===A?"#3498DB":A,_=c.ctrlKey,O=void 0===_?"":_,F=c.directEnter,L=void 0!==F&&F,q=c.enterKey,R=void 0===q?"":q,D=c.inputFieldRegex,P=void 0===D?{number:/^(-)?(((\d+)|(\d+\.(\d+)?)|(\.(\d+)?))([eE]([-+])?(\d+)?)?)?$/}:D,N=c.inputType,I=void 0===N?"":N,Y=c.keyCharacterRegex,j=void 0===Y?{number:/[0-9]|[eE]|\.|\+|-/,tel:/[0-9]|\.|\+|-|#|\(|\)/}:Y,M=c.keyColor,U=void 0===M?"#E0E0E0":M,H=c.keyTextColor,J=void 0===H?"#555555":H,B=c.keyboardPosition,G=void 0===B?"bottom":B,W=c.language,z=void 0===W?"":W,Q=c.languageKey,V=void 0===Q?"":Q,X=c.languageKeyTextColor,Z=void 0===X?"#3498db":X,ee=c.showSelectedLanguage,te=void 0!==ee&&ee,ae=c.spareKey,re=void 0===ae?"":ae,oe=c.specifiedFieldsOnly,le=void 0!==oe&&oe,ne=c.tabKey,ce=void 0===ne?"":ne,{acceptColor:s,acceptTextColor:p,allowEnterAccept:h,allowEscapeCancel:f,altKey:w,blackoutColor:x,cancelColor:E,cancelTextColor:T,capsLightColor:S,ctrlKey:O,directEnter:L,enterKey:R,inputFieldRegex:P,inputType:(a=I,o=new Array,l="",l=void 0!==a&&""!=a?(o=a.trim().split(","),$.each(o,function(e,t){"contenteditable"==t.trim().toString()?l+='[contenteditable="true"], ':"textarea"==t.trim().toString()?l+="textarea, ":l+='input[type="'+t.trim().toString()+'"], '}),l.slice(0,-2)):'input[type="text"], input[type="number"], input[type="password"], input[type="search"], input[type="tel"], input[type="url"], textarea, [contenteditable="true"]'),keyboardPosition:G,keyCharacterRegex:j,keyColor:U,keyTextColor:J,language:(t=z,t.split(",").map(function(e){return e.trim()})),languageKey:V,languageKeyTextColor:Z,showSelectedLanguage:te,spareKey:re,specifiedFieldsOnly:le,tabKey:ce}),Te={disabled:"",readonly:"",maxlength:"",min:"",max:"",placeholder:""};function Ae(){var t=Ke.language[he].split(xe)[0].trim();if(""!=we.keyboardFile&&we.arrayPosition==he)Se(t,we.keyboardFile);else{var a=function(e){we.keyboardFile=e,we.arrayPosition=he,Se(t,e)};$.get("./languages/".concat(t,".klc")).done(function(e){a(e)}).fail(function(){$.get("".concat(Ee,"/").concat(t,".klc"),function(e){a(e)})})}}function Se(e,t){var a,r,o,l,n,c,i,s,d=new Array;k=y=b="",a=(t=t.replace(/\u0000/g,"")).match(/\d(\w)?\s+\w+\s+\d\s+(-1|\w+@?|%%)\s+(-1|\w+@?|%%)\s+(-1|\w+@?|%%)(\s+(-1|\w+@?|%%))?(\s+(-1|\w+@?|%%))?(\s+(-1|\w+@?|%%))?\s+\/\//g);var p=_slicedToArray(t.match(/LOCALENAME\s+".*"/),1)[0];ge=p.replace(/LOCALENAME\s+"(.*)"/,"$1"),0<(o=t.indexOf("SHIFTSTATE"))&&((r=t.slice(o,t.indexOf("LAYOUT")).trim().split(/\n/g)).splice(0,2),$.each(r,function(e,t){-1==t.indexOf(":")?b+='"default": ':-1!=t.indexOf("Shft Ctrl Alt")?b+='"shift_altgrp": ':-1!=t.indexOf("Shft Ctrl")?b+='"ctrl_shift": ':-1!=t.indexOf("Ctrl Alt")?b+='"altgrp": ':-1!=t.indexOf("Ctrl")?b+='"ctrl": ':-1!=t.indexOf("Shft")&&(b+='"shift": '),b+=t.match(/\w{6}\s[0-9]/).toString().slice(-1)+", "}),b=JSON.parse("{"+b.toString().slice(0,-2)+"}")),0<(n=t.indexOf("DEADKEY"))&&((l=t.slice(n,t.indexOf("KEYNAME")).trim().split("DEADKEY")).splice(0,1),$.each(l,function(e,t){(d=t.split(/\n/g)).splice(0,2),s="",$.each(d,function(e,t){s+='"'+t.trim().slice(0,4)+'": "'+t.trim().slice(5,9)+'", '}),s="{"+s.slice(0,-2)+"}",y+='"'+t.trim().slice(0,4)+'": '+s+", "}),y=JSON.parse("{"+y.slice(0,-2)+"}")),0<(i=t.indexOf("LIGATURE"))&&((c=t.slice(i,t.indexOf("KEYNAME")).trim().split(/\n/g)).splice(0,5),$.each(c,function(a,e){0'),Ke.directEnter||$("body").prepend('
'),!1);_e(r.slice(0,13)),_e(r.slice(13,26)),_e(r.slice(26,37)),_e(r.slice(37,47)),Fe("default"),function(){var a=Ke.language,e=Ke.languageKeyTextColor,t=Ke.showSelectedLanguage,r=t?function(){var e=a[he].split(xe),t="";switch(e.length){case 1:t=e[0].toLowerCase().replace(/^\w/,function(e){return e.toUpperCase()});break;case 2:t=e[1].trim();break;default:t=me}return t}():me;$(".keyboard-action-wrapper").length||Ke.directEnter||$(".keyboard-wrapper").prepend('
'),$(".keyboard-row:eq(0)").append(''),$(".keyboard-row:eq(1)").prepend(''),$(".keyboard-row:eq(2)").prepend(''),$(".keyboard-row:eq(2)").append(''),$(".keyboard-row:eq(3)").prepend(''),$(".keyboard-row:eq(3)").append(''),$(".keyboard-wrapper").append('
'),$(".keyboard-row:eq(4)").append(''),$(".keyboard-row:eq(4)").append('")),$(".keyboard-row:eq(4)").append(''),$(".keyboard-row:eq(4)").append(''),$(".keyboard-row:eq(4)").append(''),$(".keyboard-row:eq(4)").append(''),$(".keyboard-row:eq(4)").append('')}(),function(){var e,t,a,r,o=$(".keyboard-row").width(),l=2*$(".keyboard-key").css("margin-right").match(/[0-9]/),n=(o-15*l)/15,c=o/3;$(".keyboard-row").each(function(){e=$(this).children(".keyboard-key-sm").length,t=$(this).children(".keyboard-key-lg").length,a=$(this).children(".keyboard-key-xl").length,r=(o-(e+t+a)*l-e*n-a*c)/t,$(this).children(".keyboard-key-sm").css("cssText","width: ".concat(n,"px")),$(this).children(".keyboard-key-lg").css("cssText","width: ".concat(r,"px")),$(this).children(".keyboard-key-xl").css("cssText","width: ".concat(c,"px"))})}(),function(){var e=$(window).width(),t=$(window).height(),a=$(".keyboard-wrapper").height(),r=$(".keyboard-wrapper").width();switch($(".keyboard-key").css("background-color",Ke.keyColor),$(".keyboard-key").css("color",Ke.keyTextColor),Ke.directEnter||($(".keyboard-cancel-button").css("background-color",Ke.cancelColor),$(".keyboard-cancel-button").css("color",Ke.cancelTextColor),$(".keyboard-accept-button").css("background-color",Ke.acceptColor),$(".keyboard-accept-button").css("color",Ke.acceptTextColor),$(".keyboard-blackout-background").css("background-color","rgba("+Ke.blackoutColor+")")),Ke.keyboardPosition){case"top":$(".keyboard-wrapper").css("top","20px");break;case"middle":$(".keyboard-wrapper").css("top",((t-a)/2).toString()+"px");break;default:$(".keyboard-wrapper").css("bottom","20px")}$(".keyboard-wrapper").css("left",((e-r)/2).toString()+"px")}(),ue||(Ke.directEnter||$(".keyboard-blackout-background").hide(),$(".keyboard-wrapper").hide())}(a)}function _e(e){$(".keyboard-wrapper").append('
'),$.each(e,function(e,t){!function(e){$(".keyboard-row:last").append(''),$(".keyboard-key:last").data("keyDataObject",e)}(void 0!==t?{default:Oe(t[b.default-1],t[1]),shift:Oe(t[b.shift-1],t[1]),altgrp:Oe(t[b.altgrp-1],t[1]),shift_altgrp:Oe(t[b.shift_altgrp-1],t[1])}:{default:"-1",shift:"-1",altgrp:"-1",shift_altgrp:"-1"})})}function Oe(e,t){var a=e;return"%%"==e?a=k[t]:void 0===e&&(a="-1"),a}function Fe(e){var t,a,r="";!ke.caps||ke.shift||ke.altgrp?ke.caps||ke.shift||ke.altgrp||(e="default"):(e="default",$(".caps-lock-key").addClass("caps-lock-key-active")),ke.caps||$(".caps-lock-key").removeClass("caps-lock-key-active"),""!=ke.shift_altgrp&&"shift_altgrp"!=e&&(ke.shift_altgrp=""),$(".keyboard-key").each(function(){r="";try{t=$(this),4==(a=t.data("keyDataObject"))[e].length?(t.html("&#x"+a[e]+";"),t.data("keyval",t.html())):5==a[e].length&&a[e].match("@")?(t.html("&#x"+a[e].replace("@","")+";"),t.data("keyval",t.html())):a[e].constructor===Array?($.each(a[e],function(e,t){r+="&#x"+t+";"}),t.html(r),t.data("keyval",t.html())):"-1"==a[e]||"%%"==a[e]||0==a[e].length?(t.html(" "),t.data("keyval","")):(t.html(a[e]),t.data("keyval",t.html())),ke.shift||!ke.caps||ke.altgrp||(t.html(1==t.html().length?t.html().toUpperCase():t.html()),t.data("keyval",1==t.html().length?t.html():t.data("keyval")))}catch(e){}})}function Le(){n.val(""),Re(),ue=!1,Ae()}function qe(){r.is("input")?r.val(n.val()):r.html(n.val()),n.val(""),Re(),ue=!1,Ae()}function Re(){for(var e in ke)ke.hasOwnProperty(e)&&(ke[e]=!1)}Ae(),fe.on("click touch",Ke.inputType,function(){var e=Ke.specifiedFieldsOnly;if("keyboard-input-field"!=$(this).prop("class")){var t=$(this);if(e){var a=t.data(Ce)||!1;if(!a)return}$.each(Te,function(e){Te[e]=void 0===t.prop(e)?"":t.prop(e)}),Te.disabled||Te.readonly||(r=$(this),n=r,Ke.directEnter||(n=$(".keyboard-input-field"),r.is("input")?(ye=r.prop("type"),be="password"==ye?"password":"text",n.prop("placeholder",Te.placeholder),n.val(r.val()),n.prop("type",be)):(ye="text",n.val(r.html()),n.prop("type","text")),$(".keyboard-blackout-background").show()),$(".keyboard-wrapper").show(),ue=!0,n.focus())}}),$("body").on("click touch",".keyboard-key",function(){var e=$(this).data("keyval");!function(e){var t=("0000"+e.charCodeAt(0).toString(16)).slice(-4),a=n[0].selectionStart;if(2<(e=e.replace("<","<").replace(">",">").replace(/\bspace/," ")).length)switch(de="",e){case"shift":ke.shift=!ke.shift,ke.caps=!1,ke.altgrp=!1,"altgrp"==ke.shift_altgrp?(Fe("shift_altgrp"),ke.shift_altgrp=""):"shift"==ke.shift_altgrp?(Fe("shift"),ke.shift_altgrp=""):(Fe("shift"),ke.shift_altgrp="shift");break;case"caps lock":ke.shift=!1,ke.caps=!ke.caps,ke.altgrp=!1,Fe("caps");break;case"alt grp":ke.shift=!1,ke.caps=!1,ke.altgrp=!ke.altgrp,"shift"==ke.shift_altgrp?(Fe("shift_altgrp"),ke.shift_altgrp=""):"altgrp"==ke.shift_altgrp?(Fe("altgrp"),ke.shift_altgrp=""):(Fe("altgrp"),ke.shift_altgrp="altgrp");break;case"backspace":n.val(n.val().slice(0,a-1)+n.val().slice(a)),a-=1,n.focus(),n[0].selectionStart=a,n[0].selectionEnd=a;break;case"space":break;case"enter":Ke.enterKey&&"function"==typeof Ke.enterKey&&Ke.enterKey();break;case"tab":Ke.tabKey&&"function"==typeof Ke.tabKey&&Ke.tabKey();break;case"ctrl":Ke.ctrlKey&&"function"==typeof Ke.ctrlKey&&Ke.ctrlKey();break;case"alt":Ke.altKey&&"function"==typeof Ke.altKey&&Ke.altKey();break;case"language":he+1<=Ke.language.length-1?he++:he=0,Re(),Ae(),Ke.languageKey&&"function"==typeof Ke.languageKey&&Ke.languageKey();break;case"spare":Ke.spareKey&&Ke.spareKey}else{if(ke.shift=!1,ke.altgrp=!1,Fe("default"),(de=y[t])||pe){if(e="",void 0===de&&pe){var r=String.fromCharCode("0x"+pe[t]);r&&void 0!==pe[t]&&(e=r)}pe=de}n.attr("dir",$e);var o,l=n.val();n.val(n.val().slice(0,a)+e+n.val().slice(a)),o=n.val(),("-1"!=Te.maxlength&&""!=Te.maxlength&&o.length>Te.maxlength||"number"==ye&&""!=Te.max&&"-1"!=Te.max&&1*o>1*Te.max||"number"==ye&&""!=Te.min&&"-1"!=Te.min&&1*o<1*Te.min||e.search(Ke.keyCharacterRegex[ye])<0||o.search(Ke.inputFieldRegex[ye])<0)&&(n.val(l),a--),a+=e.length,n.focus(),n[0].selectionStart=a,n[0].selectionEnd=a}}(e)}),$(document).on("click touch",".keyboard-cancel-button",function(){Le()}),$(document).on("click touch",".keyboard-accept-button",function(){qe()}),$(document).on("click touch","*",function(e){if(e.stopPropagation(),ue&&Ke.directEnter){var t=$(this);if(Ke.inputType.search(t.attr("type"))<1&&Ke.inputType.search(t.prop("tagName").toLowerCase())<1&&"true"!=t.prop("contenteditable")){for(;t.parent().length&&!t.hasClass("keyboard-wrapper");)t=t.parent();t.hasClass("keyboard-wrapper")||(Re(),ue=!1,Ae())}}}),$(document).on("keydown",function(e){!function(e){if($(".keyboard-wrapper").is(":visible"))switch(e.which){case 13:Ke.allowEnterAccept&&(qe(),e.preventDefault());break;case 27:Ke.allowEscapeCancel&&(Le(),e.preventDefault())}}(e)}),$(window).resize(function(){ve||(ve=!0,setTimeout(function(){Ae(),ve=!1},500))})}; \ No newline at end of file +"use strict";function _slicedToArray(e,t){return _arrayWithHoles(e)||_iterableToArrayLimit(e,t)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}function _iterableToArrayLimit(e,t){var a=[],r=!0,o=!1,l=void 0;try{for(var n,c=e[Symbol.iterator]();!(r=(n=c.next()).done)&&(a.push(n.value),!t||a.length!==t);r=!0);}catch(e){o=!0,l=e}finally{try{r||null==c.return||c.return()}finally{if(o)throw l}}return a}function _arrayWithHoles(e){if(Array.isArray(e))return e}$.fn.keyboard=function(e){var y,r,n,k,b,t,a,o,l,c,i,s,d,p,u,h,g,f,v,w,m,x,C,E,K,T,A,S,_,O,F,L,q,R,D,P,N,I,Y,j,M,U,H,J,B,G,W,z,Q,V,X,Z,ee,te,ae,re,oe,le,ne,ce,ie=["ar-SA","fa-IR","he-IL","ur-PK"],se={29:0,"02":1,"03":2,"04":3,"05":4,"06":5,"07":6,"08":7,"09":8,"0a":9,"0b":10,"0c":11,"0d":12,10:13,11:14,12:15,13:16,14:17,15:18,16:19,17:20,18:21,19:22,"1a":23,"1b":24,"2b":25,"1e":26,"1f":27,20:28,21:29,22:30,23:31,24:32,25:33,26:34,27:35,28:36,"2c":37,"2d":38,"2e":39,"2f":40,30:41,31:42,32:43,33:44,34:45,35:46},de="",pe=!1,ye="text",ke={shift:!1,caps:!1,altgrp:!1,shift_altgrp:""},be="text",ue=!1,he=0,ge="",fe=$(this),ve=!1,we={keyboardFile:"",arrayPosition:""},$e="LTR",me="Language",xe=":",Ce="triggerKeyboard",Ee="https://cdn.jsdelivr.net/npm/mok-project@".concat("1.1.6","/dist/languages"),Ke=(i=(c=e).acceptColor,s=void 0===i?"#2ECC71":i,d=c.acceptTextColor,p=void 0===d?"#FFFFFF":d,u=c.allowEnterAccept,h=void 0===u||u,g=c.allowEscapeCancel,f=void 0===g||g,v=c.altKey,w=void 0===v?"":v,m=c.blackoutColor,x=void 0===m?"25, 25, 25, 0.9":m,C=c.cancelColor,E=void 0===C?"#E74C3C":C,K=c.cancelTextColor,T=void 0===K?"#FFFFFF":K,A=c.capsLightColor,S=void 0===A?"#3498DB":A,_=c.ctrlKey,O=void 0===_?"":_,F=c.directEnter,L=void 0!==F&&F,q=c.enterKey,R=void 0===q?"":q,D=c.inputFieldRegex,P=void 0===D?{number:/^(-)?(((\d+)|(\d+\.(\d+)?)|(\.(\d+)?))([eE]([-+])?(\d+)?)?)?$/}:D,N=c.inputType,I=void 0===N?"":N,Y=c.keyCharacterRegex,j=void 0===Y?{number:/[0-9]|[eE]|\.|\+|-/,tel:/[0-9]|\.|\+|-|#|\(|\)/}:Y,M=c.keyColor,U=void 0===M?"#E0E0E0":M,H=c.keyTextColor,J=void 0===H?"#555555":H,B=c.keyboardPosition,G=void 0===B?"bottom":B,W=c.language,z=void 0===W?"":W,Q=c.languageKey,V=void 0===Q?"":Q,X=c.languageKeyTextColor,Z=void 0===X?"#3498db":X,ee=c.showSelectedLanguage,te=void 0!==ee&&ee,ae=c.spareKey,re=void 0===ae?"":ae,oe=c.specifiedFieldsOnly,le=void 0!==oe&&oe,ne=c.tabKey,ce=void 0===ne?"":ne,{acceptColor:s,acceptTextColor:p,allowEnterAccept:h,allowEscapeCancel:f,altKey:w,blackoutColor:x,cancelColor:E,cancelTextColor:T,capsLightColor:S,ctrlKey:O,directEnter:L,enterKey:R,inputFieldRegex:P,inputType:(a=I,o=new Array,l="",l=void 0!==a&&""!=a?(o=a.trim().split(","),$.each(o,function(e,t){"contenteditable"==t.trim().toString()?l+='[contenteditable="true"], ':"textarea"==t.trim().toString()?l+="textarea, ":l+='input[type="'+t.trim().toString()+'"], '}),l.slice(0,-2)):'input[type="text"], input[type="number"], input[type="password"], input[type="search"], input[type="tel"], input[type="url"], textarea, [contenteditable="true"]'),keyboardPosition:G,keyCharacterRegex:j,keyColor:U,keyTextColor:J,language:(t=z,t.split(",").map(function(e){return e.trim()})),languageKey:V,languageKeyTextColor:Z,showSelectedLanguage:te,spareKey:re,specifiedFieldsOnly:le,tabKey:ce}),Te={disabled:"",readonly:"",maxlength:"",min:"",max:"",placeholder:""};function Ae(){var t=Ke.language[he].split(xe)[0].trim();if(""!=we.keyboardFile&&we.arrayPosition==he)Se(t,we.keyboardFile);else{var a=function(e){we.keyboardFile=e,we.arrayPosition=he,Se(t,e)};$.get("./languages/".concat(t,".klc")).done(function(e){a(e)}).fail(function(){$.get("".concat(Ee,"/").concat(t,".klc"),function(e){a(e)})})}}function Se(e,t){var a,r,o,l,n,c,i,s,d=new Array;k=y=b="",a=(t=t.replace(/\u0000/g,"")).match(/\d(\w)?\s+\w+\s+\d\s+(-1|\w+@?|%%)\s+(-1|\w+@?|%%)\s+(-1|\w+@?|%%)(\s+(-1|\w+@?|%%))?(\s+(-1|\w+@?|%%))?(\s+(-1|\w+@?|%%))?\s+\/\//g);var p=_slicedToArray(t.match(/LOCALENAME\s+".*"/),1)[0];ge=p.replace(/LOCALENAME\s+"(.*)"/,"$1"),0<(o=t.indexOf("SHIFTSTATE"))&&((r=t.slice(o,t.indexOf("LAYOUT")).trim().split(/\n/g)).splice(0,2),$.each(r,function(e,t){-1==t.indexOf(":")?b+='"default": ':-1!=t.indexOf("Shft Ctrl Alt")?b+='"shift_altgrp": ':-1!=t.indexOf("Shft Ctrl")?b+='"ctrl_shift": ':-1!=t.indexOf("Ctrl Alt")?b+='"altgrp": ':-1!=t.indexOf("Ctrl")?b+='"ctrl": ':-1!=t.indexOf("Shft")&&(b+='"shift": '),b+=t.match(/\w{6}\s[0-9]/).toString().slice(-1)+", "}),b=JSON.parse("{"+b.toString().slice(0,-2)+"}")),0<(n=t.indexOf("DEADKEY"))&&((l=t.slice(n,t.indexOf("KEYNAME")).trim().split("DEADKEY")).splice(0,1),$.each(l,function(e,t){(d=t.split(/\n/g)).splice(0,2),s="",$.each(d,function(e,t){s+='"'+t.trim().slice(0,4)+'": "'+t.trim().slice(5,9)+'", '}),s="{"+s.slice(0,-2)+"}",y+='"'+t.trim().slice(0,4)+'": '+s+", "}),y=JSON.parse("{"+y.slice(0,-2)+"}")),0<(i=t.indexOf("LIGATURE"))&&((c=t.slice(i,t.indexOf("KEYNAME")).trim().split(/\n/g)).splice(0,5),$.each(c,function(a,e){0'),Ke.directEnter||$("body").prepend('
'),!1);_e(r.slice(0,13)),_e(r.slice(13,26)),_e(r.slice(26,37)),_e(r.slice(37,47)),Fe("default"),function(){var a=Ke.language,e=Ke.languageKeyTextColor,t=Ke.showSelectedLanguage,r=t?function(){var e=a[he].split(xe),t="";switch(e.length){case 1:t=e[0].toLowerCase().replace(/^\w/,function(e){return e.toUpperCase()});break;case 2:t=e[1].trim();break;default:t=me}return t}():me;$(".keyboard-action-wrapper").length||Ke.directEnter||$(".keyboard-wrapper").prepend('
'),$(".keyboard-row:eq(0)").append(''),$(".keyboard-row:eq(1)").prepend(''),$(".keyboard-row:eq(2)").prepend(''),$(".keyboard-row:eq(2)").append(''),$(".keyboard-row:eq(3)").prepend(''),$(".keyboard-row:eq(3)").append(''),$(".keyboard-wrapper").append('
'),$(".keyboard-row:eq(4)").append(''),$(".keyboard-row:eq(4)").append('")),$(".keyboard-row:eq(4)").append(''),$(".keyboard-row:eq(4)").append(''),$(".keyboard-row:eq(4)").append(''),$(".keyboard-row:eq(4)").append(''),$(".keyboard-row:eq(4)").append('')}(),function(){var e,t,a,r,o=$(".keyboard-row").width(),l=2*$(".keyboard-key").css("margin-right").match(/[0-9]/),n=(o-15*l)/15,c=o/3;$(".keyboard-row").each(function(){e=$(this).children(".keyboard-key-sm").length,t=$(this).children(".keyboard-key-lg").length,a=$(this).children(".keyboard-key-xl").length,r=(o-(e+t+a)*l-e*n-a*c)/t,$(this).children(".keyboard-key-sm").css("cssText","width: ".concat(n,"px")),$(this).children(".keyboard-key-lg").css("cssText","width: ".concat(r,"px")),$(this).children(".keyboard-key-xl").css("cssText","width: ".concat(c,"px"))})}(),function(){var e=$(window).width(),t=$(window).height(),a=$(".keyboard-wrapper").height(),r=$(".keyboard-wrapper").width();switch($(".keyboard-key").css("background-color",Ke.keyColor),$(".keyboard-key").css("color",Ke.keyTextColor),Ke.directEnter||($(".keyboard-cancel-button").css("background-color",Ke.cancelColor),$(".keyboard-cancel-button").css("color",Ke.cancelTextColor),$(".keyboard-accept-button").css("background-color",Ke.acceptColor),$(".keyboard-accept-button").css("color",Ke.acceptTextColor),$(".keyboard-blackout-background").css("background-color","rgba("+Ke.blackoutColor+")")),Ke.keyboardPosition){case"top":$(".keyboard-wrapper").css("top","20px");break;case"middle":$(".keyboard-wrapper").css("top",((t-a)/2).toString()+"px");break;default:$(".keyboard-wrapper").css("bottom","20px")}$(".keyboard-wrapper").css("left",((e-r)/2).toString()+"px")}(),ue||(Ke.directEnter||$(".keyboard-blackout-background").hide(),$(".keyboard-wrapper").hide())}(a)}function _e(e){$(".keyboard-wrapper").append('
'),$.each(e,function(e,t){!function(e){$(".keyboard-row:last").append(''),$(".keyboard-key:last").data("keyDataObject",e)}(void 0!==t?{default:Oe(t[b.default-1],t[1]),shift:Oe(t[b.shift-1],t[1]),altgrp:Oe(t[b.altgrp-1],t[1]),shift_altgrp:Oe(t[b.shift_altgrp-1],t[1])}:{default:"-1",shift:"-1",altgrp:"-1",shift_altgrp:"-1"})})}function Oe(e,t){var a=e;return"%%"==e?a=k[t]:void 0===e&&(a="-1"),a}function Fe(e){var t,a,r="";!ke.caps||ke.shift||ke.altgrp?ke.caps||ke.shift||ke.altgrp||(e="default"):(e="default",$(".caps-lock-key").addClass("caps-lock-key-active")),ke.caps||$(".caps-lock-key").removeClass("caps-lock-key-active"),""!=ke.shift_altgrp&&"shift_altgrp"!=e&&(ke.shift_altgrp=""),$(".keyboard-key").each(function(){r="";try{t=$(this),4==(a=t.data("keyDataObject"))[e].length?(t.html("&#x"+a[e]+";"),t.data("keyval",t.html())):5==a[e].length&&a[e].match("@")?(t.html("&#x"+a[e].replace("@","")+";"),t.data("keyval",t.html())):a[e].constructor===Array?($.each(a[e],function(e,t){r+="&#x"+t+";"}),t.html(r),t.data("keyval",t.html())):"-1"==a[e]||"%%"==a[e]||0==a[e].length?(t.html(" "),t.data("keyval","")):(t.html(a[e]),t.data("keyval",t.html())),ke.shift||!ke.caps||ke.altgrp||(t.html(1==t.html().length?t.html().toUpperCase():t.html()),t.data("keyval",1==t.html().length?t.html():t.data("keyval")))}catch(e){}})}function Le(){n.val(""),Re(),ue=!1,Ae()}function qe(){r.is("input")?r.val(n.val()):r.html(n.val()),n.val(""),Re(),ue=!1,Ae()}function Re(){for(var e in ke)ke.hasOwnProperty(e)&&(ke[e]=!1)}Ae(),fe.on("click touch",Ke.inputType,function(){var e=Ke.specifiedFieldsOnly;if("keyboard-input-field"!=$(this).prop("class")){var t=$(this);if(e){var a=t.data(Ce)||!1;if(!a)return}$.each(Te,function(e){Te[e]=void 0===t.prop(e)?"":t.prop(e)}),Te.disabled||Te.readonly||(r=$(this),n=r,Ke.directEnter||(n=$(".keyboard-input-field"),r.is("input")?(ye=r.prop("type"),be="password"==ye?"password":"text",n.prop("placeholder",Te.placeholder),n.val(r.val()),n.prop("type",be)):(ye="text",n.val(r.html()),n.prop("type","text")),$(".keyboard-blackout-background").show()),$(".keyboard-wrapper").show(),ue=!0,n.focus())}}),$("body").on("click touch",".keyboard-key",function(){var e=$(this).data("keyval");!function(e){var t=("0000"+e.charCodeAt(0).toString(16)).slice(-4),a=n[0].selectionStart;if(2<(e=e.replace("<","<").replace(">",">").replace(/\bspace/," ")).length)switch(de="",e){case"shift":ke.shift=!ke.shift,ke.caps=!1,ke.altgrp=!1,"altgrp"==ke.shift_altgrp?(Fe("shift_altgrp"),ke.shift_altgrp=""):"shift"==ke.shift_altgrp?(Fe("shift"),ke.shift_altgrp=""):(Fe("shift"),ke.shift_altgrp="shift");break;case"caps lock":ke.shift=!1,ke.caps=!ke.caps,ke.altgrp=!1,Fe("caps");break;case"alt grp":ke.shift=!1,ke.caps=!1,ke.altgrp=!ke.altgrp,"shift"==ke.shift_altgrp?(Fe("shift_altgrp"),ke.shift_altgrp=""):"altgrp"==ke.shift_altgrp?(Fe("altgrp"),ke.shift_altgrp=""):(Fe("altgrp"),ke.shift_altgrp="altgrp");break;case"backspace":n.val(n.val().slice(0,a-1)+n.val().slice(a)),a-=1,n.focus(),n[0].selectionStart=a,n[0].selectionEnd=a;break;case"space":break;case"enter":Ke.enterKey&&"function"==typeof Ke.enterKey&&Ke.enterKey();break;case"tab":Ke.tabKey&&"function"==typeof Ke.tabKey&&Ke.tabKey();break;case"ctrl":Ke.ctrlKey&&"function"==typeof Ke.ctrlKey&&Ke.ctrlKey();break;case"alt":Ke.altKey&&"function"==typeof Ke.altKey&&Ke.altKey();break;case"language":he+1<=Ke.language.length-1?he++:he=0,Re(),Ae(),Ke.languageKey&&"function"==typeof Ke.languageKey&&Ke.languageKey();break;case"spare":Ke.spareKey&&Ke.spareKey}else{if(ke.shift=!1,ke.altgrp=!1,Fe("default"),(de=y[t])||pe){if(e="",void 0===de&&pe){var r=String.fromCharCode("0x"+pe[t]);r&&void 0!==pe[t]&&(e=r)}pe=de}n.attr("dir",$e);var o,l=n.val();n.val(n.val().slice(0,a)+e+n.val().slice(a)),o=n.val(),("-1"!=Te.maxlength&&""!=Te.maxlength&&o.length>Te.maxlength||"number"==ye&&""!=Te.max&&"-1"!=Te.max&&1*o>1*Te.max||"number"==ye&&""!=Te.min&&"-1"!=Te.min&&1*o<1*Te.min||e.search(Ke.keyCharacterRegex[ye])<0||o.search(Ke.inputFieldRegex[ye])<0)&&(n.val(l),a--),a+=e.length,n.focus(),n[0].selectionStart=a,n[0].selectionEnd=a}}(e)}),$(document).on("click touch",".keyboard-cancel-button",function(){Le()}),$(document).on("click touch",".keyboard-accept-button",function(){qe()}),$(document).on("click touch","*",function(e){if(e.stopPropagation(),ue&&Ke.directEnter){var t=$(this);if(Ke.inputType.search(t.attr("type"))<1&&Ke.inputType.search(t.prop("tagName").toLowerCase())<1&&"true"!=t.prop("contenteditable")){for(;t.parent().length&&!t.hasClass("keyboard-wrapper");)t=t.parent();t.hasClass("keyboard-wrapper")||(Re(),ue=!1,Ae())}}}),$(document).on("keydown",function(e){!function(e){if($(".keyboard-wrapper").is(":visible"))switch(e.which){case 13:Ke.allowEnterAccept&&(qe(),e.preventDefault());break;case 27:Ke.allowEscapeCancel&&(Le(),e.preventDefault())}}(e)}),$(window).resize(function(){ve||(ve=!0,setTimeout(function(){Ae(),ve=!1},500))})}; \ No newline at end of file diff --git a/package.json b/package.json index 2416267..c2de983 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mok-project", - "version": "1.1.5", + "version": "1.1.6", "description": "A jQuery plugin providing multilingual onscreen keyboard for terminals and kiosks.", "main": "index.js", "scripts": { diff --git a/src/js/keyboard.js b/src/js/keyboard.js index 11695e4..f0e2f5d 100644 --- a/src/js/keyboard.js +++ b/src/js/keyboard.js @@ -7,7 +7,7 @@ //* GitHub: https://github.com/srm985/mok-project * //* * //* Started: March 2017 * -//* Version: 1.1.3 * +//* Version: 1.1.6 * //* * //* License: MIT (https://opensource.org/licenses/MIT) * //* * @@ -42,7 +42,7 @@ $.fn.keyboard = function (passedOptions) { let storedKeyboardObject = { keyboardFile: '', arrayPosition: '' }; let textFlowDirection = 'LTR'; - const KEYBOARD_VERSION = '1.1.5'; + const KEYBOARD_VERSION = '1.1.6'; const LANGUAGE_KEY_DEFAULT = 'Language'; const LANGUAGE_MAP_SPLIT_CHAR = ':'; const TRIGGER_KEYBOARD_FLAG = 'triggerKeyboard';