forked from ajaaibu/thaanaKeyboard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjquery.thaana.min.js
1 lines (1 loc) · 2.38 KB
/
jquery.thaana.min.js
1
!function(t){t.fn.thaana=function(n){var e={keyboard:"phonetic"};return this.each(function(){n&&t.extend(e,n);var i={phonetic:{33:"!",34:'"',35:"#",36:"$",37:"%",38:"&",39:"'",40:")",41:"(",42:"*",43:"+",44:"،",45:"-",46:".",47:"/",58:":",59:"؛",60:">",61:"=",62:"<",63:"؟",64:"@",65:"ާ",66:"ޞ",67:"ޝ",68:"ޑ",69:"ޭ",70:"ﷲ",71:"ޣ",72:"ޙ",73:"ީ",74:"ޛ",75:"ޚ",76:"ޅ",77:"ޟ",78:"ޏ",79:"ޯ",80:"÷",81:"ޤ",82:"ޜ",83:"ށ",84:"ޓ",85:"ޫ",86:"ޥ",87:"ޢ",88:"ޘ",89:"ޠ",90:"ޡ",91:"]",92:"\\",93:"[",94:"^",95:"_",96:"`",97:"ަ",98:"ބ",99:"ޗ",100:"ދ",101:"ެ",102:"ފ",103:"ގ",104:"ހ",105:"ި",106:"ޖ",107:"ކ",108:"ލ",109:"މ",110:"ނ",111:"ޮ",112:"ޕ",113:"ް",114:"ރ",115:"ސ",116:"ތ",117:"ު",118:"ވ",119:"އ",120:"×",121:"ޔ",122:"ޒ",123:"}",124:"|",125:"{",126:"~"},typewriter:{33:"!",34:"؛",35:"#",36:"$",37:"%",38:"&",39:"ﷲ",40:")",41:"(",42:"*",43:"+",44:"ށ",45:"-",46:"ޓ",47:"ޯ",58:"ޡ",59:"ފ",60:"\\",61:"=",62:"ޞ",63:"؟",64:"@",65:"<",66:"ޟ",67:"ޏ",68:".",69:"“",70:"،",71:'"',72:"ޥ",73:"ޣ",74:"ޢ",75:"ޘ",76:"ޚ",77:"ޝ",78:"ޛ",79:"ޠ",80:"ޙ",81:"×",82:"/",83:">",84:":",85:"ޜ",86:"ޗ",87:"’",88:"ޕ",89:"ޤ",90:"ޖ",91:"ލ",92:"]",93:"[",94:"^",95:"_",96:"`",97:"ި",98:"ޅ",99:"ސ",100:"ް",101:"ާ",102:"ަ",103:"ެ",104:"ވ",105:"މ",106:"އ",107:"ނ",108:"ކ",109:"ބ",110:"ދ",111:"ތ",112:"ހ",113:"ޫ",114:"ީ",115:"ު",116:"ޭ",117:"ރ",118:"ޔ",119:"ޮ",120:"ޑ",121:"ގ",122:"ޒ",123:"÷",124:"}",125:"{",126:"~"}},h=function(){var n,h=t(this).val(),s=!1,a=0;this.selectionEnd<h.length&&this.selectionEnd>0?(s=!0,a=this.selectionEnd,n=h.substring(this.selectionEnd-1,this.selectionEnd)):n=h.substring(h.length-1);var r=n.charCodeAt(0),o=t(this).attr("data-length")?t(this).attr("data-length"):0,l=h.length-o;"undefined"!=typeof i[e.keyboard][r]&&(1==l||h.length<o)&&(1==s?current=t(this).val().substr(0,this.selectionStart-1)+i[e.keyboard][r]+t(this).val().substr(this.selectionStart):(current=t(this).val().substr(0,h.length-1),current+=i[e.keyboard][r]),t(this).val(current),s&&(this.selectionStart=a,this.selectionEnd=a),t(this).trigger("change"))};t(this).on("keydown",function(n){n.ctrlKey||n.metaKey||8==n.which||46==n.which?t(this).off("input"):"undefined"==typeof t._data(this,"events").input&&t(this).on("input",h),t(this).attr("data-length",t(this).val().length)}).on("keyup",function(n){t(this).attr("data-length",t(this).val().length)})})}}(jQuery);