Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var c;
- (c = jQuery).fn.thaana = function (t) {
- var e = {
- keyboard: 'phonetic'
- };
- return this.each(function () {
- t && c.extend(e, t);
- var n = {
- 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: '~'
- }
- },
- i = function () {
- var t,
- i = c(this).val(),
- r = !1,
- o = 0;
- this.selectionEnd < i.length && this.selectionEnd > 0 ? (r = !0, o = this.selectionEnd, t = i.substring(this.selectionEnd - 1, this.selectionEnd)) : t = i.substring(i.length - 1);
- var s = t.charCodeAt(0),
- a = c(this).attr('data-length') ? c(this).attr('data-length') : 0,
- l = i.length - a;
- void 0 !== n[e.keyboard][s] && (1 == l || i.length < a) && (1 == r ? current = c(this).val().substr(0, this.selectionStart - 1) + n[e.keyboard][s] + c(this).val().substr(this.selectionStart) : (current = c(this).val().substr(0, i.length - 1), current += n[e.keyboard][s]), c(this).val(current), r && (this.selectionStart = o, this.selectionEnd = o), c(this).trigger('change'))
- };
- c(this).on('keydown', function (t) {
- t.ctrlKey || t.metaKey || 8 == t.which || 46 == t.which ? c(this).off('input') : void 0 === c._data(this, 'events').input && c(this).on('input', i),
- c(this).attr('data-length', c(this).val().length)
- }).on('keyup', function (t) {
- c(this).attr('data-length', c(this).val().length)
- })
- })
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement