/** * hangul.js * http://github.com/clee704/hangul-js * @version 1.1.2 * @copyright Copyright 2013, Choongmin Lee * @license MIT license */ var hangul=function(t){"use strict";if(!Array.prototype.indexOf){Array.prototype.indexOf=function(t){if(this===void 0||this===null)throw new TypeError;var r=Object(this);var e=r.length>>>0;if(e===0)return-1;var n=0;if(arguments.length>0){n=Number(arguments[1]);if(n!==n){n=0}else if(n!==0&&n!==Infinity&&n!==-Infinity){n=(n>0||-1)*Math.floor(Math.abs(n))}}if(n>=e)return-1;var i=n>=0?n:Math.max(e-Math.abs(n),0);for(;i0?o.get(n-1):n===0?"":t}function p(r){var e=r&&r.charAt&&r.charAt(0);if(!h(e)){return t}var n=[v(e),A(e),m(e)];if(n[2]===""){n.pop()}return n}function g(r,e,n){var u=i.inverse.get(r),s=a.inverse.get(e),c=n===t||n===""?0:o.inverse.get(n)+1,f=String.fromCharCode(44032+(u*21+s)*28+c);return h(f)?f:t}var y=new e({"ㄳ":"ㄱㅅ","ㄵ":"ㄴㅈ","ㄶ":"ㄴㅎ","ㄺ":"ㄹㄱ","ㄻ":"ㄹㅁ","ㄼ":"ㄹㅂ","ㄽ":"ㄹㅅ","ㄾ":"ㄹㅌ","ㄿ":"ㄹㅍ","ㅀ":"ㄹㅎ","ㅄ":"ㅂㅅ","ㄲ":"ㄱㄱ","ㄸ":"ㄷㄷ","ㅃ":"ㅂㅂ","ㅆ":"ㅅㅅ","ㅉ":"ㅈㅈ","ㅘ":"ㅗㅏ","ㅙ":"ㅗㅐ","ㅚ":"ㅗㅣ","ㅝ":"ㅜㅓ","ㅞ":"ㅜㅔ","ㅟ":"ㅜㅣ","ㅢ":"ㅡㅣ"});function C(t,r){return y.inverse.get(t+r)}function M(r){var e=y.get(r);return e===t?e:[e.charAt(0),e.charAt(1)]}var b=new r("ㅣ","ㅑ","ㅒ","ㅕ","ㅖ","ㅛ","ㅠ");function w(t){return b.has(t&&t.charAt&&t.charAt(0))}return{Set:r,Map:e,jamo:n,initials:i,medials:a,finals:o,isHangul:s,isSyllable:h,isJamo:c,isInitial:f,isMedial:l,isFinal:d,getInitial:v,getMedial:A,getFinal:m,decompose:p,compose:g,composeDoubleJamo:C,decomposeDoubleJamo:M,isIotizedVowel:w}}();/** * hangul-dubeol.js * http://github.com/clee704/hangul-js * @version 1.1.2 * @copyright Copyright 2013, Choongmin Lee * @license MIT license */ (function(e,t){"use strict";var o=new e.Map;o.addAll({A:"ㅁ",B:"ㅠ",C:"ㅊ",D:"ㅇ",E:"ㄸ",F:"ㄹ",G:"ㅎ",H:"ㅗ",I:"ㅑ",J:"ㅓ",K:"ㅏ",L:"ㅣ",M:"ㅡ",N:"ㅜ",O:"ㅒ",P:"ㅖ",Q:"ㅃ",R:"ㄲ",S:"ㄴ",T:"ㅆ",U:"ㅕ",V:"ㅍ",W:"ㅉ",X:"ㅌ",Y:"ㅛ",Z:"ㅋ"});o.addAll({a:"ㅁ",b:"ㅠ",c:"ㅊ",d:"ㅇ",e:"ㄷ",f:"ㄹ",g:"ㅎ",h:"ㅗ",i:"ㅑ",j:"ㅓ",k:"ㅏ",l:"ㅣ",m:"ㅡ",n:"ㅜ",o:"ㅐ",p:"ㅔ",q:"ㅂ",r:"ㄱ",s:"ㄴ",t:"ㅅ",u:"ㅕ",v:"ㅍ",w:"ㅈ",x:"ㅌ",y:"ㅛ",z:"ㅋ"});function r(e){var t=[],o=new i(t);for(var r=0;r"),">":c("."),"?":a("!"),B:a("?"),H:a("0"),I:a("7"),J:a("1"),K:a("2"),L:a("3"),M:a('"'),N:a("-"),O:a("8"),P:a("9"),U:a("6"),Y:a("5"),"[":a("("),"\\":a(":"),"]":a("<"),"^":a("="),_:a(";"),"`":a("*"),"{":a("%"),"|":a("\\"),"}":a("/"),"~":a("※")});function o(t){return i("initial",t)}function s(t){return i("medial",t)}function u(t){return i("medial-special",t)}function l(t){return i("final",t)}function a(t){return i("symbol",t)}function c(t){return i("extra",t)}function h(t){var e=[],i=new f(e);for(var n=0;n0){n=this._jamoQueue.pop();delete this._jamoBlock[this._indexes[n.type]];this._renderCurrentBlock()}else{this.output.pop()}return}if(!r.hasKey(i)){this._flush();if(i!==e)this.output.push(i);return}n=r.get(i);if(!t.isJamo(n.c)){this._flush();this.output.push(n.c);return}var o=this._indexes[n.type],s=this._jamoBlock,u=s[o];if(u){var l=t.composeDoubleJamo(u.c,n.c);if(l&&(u.type==="initial"&&!s[1]&&!s[2]&&t.isInitial(l)||u.type==="medial-special")){s[o]=this._wrappers[n.type](l);this._renderCurrentBlock();return}this._flush()}s[o]=n;this._jamoQueue.push(n);this._renderCurrentBlock()};f.prototype._flush=function(){if(this.currentBlock!==e){this.output.push(this.currentBlock);this.currentBlock=e}this._jamoBlock.length=0;this._jamoQueue.length=0};f.prototype._renderCurrentBlock=function(){var i=this._jamoBlock,n;if(i[0]){if(i[1]){if(i[2]){n=t.compose(i[0].c,i[1].c,i[2].c)}else{n=t.compose(i[0].c,i[1].c)}}else{n=i[0].c}}else if(i[1]){n=i[1].c}else if(i[2]){n=i[2].c}else{n=e}this.currentBlock=n};function p(t){var e=[];for(var i=0;ic&&(c+=a.value.length),typeof d==b&&(d=c),0>d&&(d+=a.value.length),{start:c,end:d}}function q(a,b,c){return{start:b,end:c,length:c-b,text:a.value.slice(b,c)}}function r(){return n(document,"body")?document.body:document.getElementsByTagName("body")[0]}var c,d,e,f,g,h,i,j,k,b="undefined";a(document).ready(function(){function v(a,b){return function(){var c=this.jquery?this[0]:this,d=c.nodeName.toLowerCase();if(1==c.nodeType&&("textarea"==d||"input"==d&&"text"==c.type)){var e=[c].concat(Array.prototype.slice.call(arguments)),f=a.apply(this,e);if(!b)return f}return b?this:void 0}}var s=document.createElement("textarea");if(r().appendChild(s),m(s,"selectionStart")&&m(s,"selectionEnd"))c=function(a){var b=a.selectionStart,c=a.selectionEnd;return q(a,b,c)},d=function(a,b,c){var d=p(a,b,c);a.selectionStart=d.start,a.selectionEnd=d.end},k=function(a,b){b?a.selectionEnd=a.selectionStart:a.selectionStart=a.selectionEnd};else{if(!(l(s,"createTextRange")&&n(document,"selection")&&l(document.selection,"createRange")))return r().removeChild(s),o("No means of finding text input caret position"),void 0;c=function(a){var d,e,f,g,b=0,c=0,h=document.selection.createRange();return h&&h.parentElement()==a&&(f=a.value.length,d=a.value.replace(/\r\n/g,"\n"),e=a.createTextRange(),e.moveToBookmark(h.getBookmark()),g=a.createTextRange(),g.collapse(!1),e.compareEndPoints("StartToEnd",g)>-1?b=c=f:(b=-e.moveStart("character",-f),b+=d.slice(0,b).split("\n").length-1,e.compareEndPoints("EndToEnd",g)>-1?c=f:(c=-e.moveEnd("character",-f),c+=d.slice(0,c).split("\n").length-1))),q(a,b,c)};var t=function(a,b){return b-(a.value.slice(0,b).split("\r\n").length-1)};d=function(a,b,c){var d=p(a,b,c),e=a.createTextRange(),f=t(a,d.start);e.collapse(!0),d.start==d.end?e.move("character",f):(e.moveEnd("character",t(a,d.end)),e.moveStart("character",f)),e.select()},k=function(a,b){var c=document.selection.createRange();c.collapse(b),c.select()}}r().removeChild(s),f=function(a,b,c,e){var f;b!=c&&(f=a.value,a.value=f.slice(0,b)+f.slice(c)),e&&d(a,b,b)},e=function(a){var b=c(a);f(a,b.start,b.end,!0)},j=function(a){var e,b=c(a);return b.start!=b.end&&(e=a.value,a.value=e.slice(0,b.start)+e.slice(b.end)),d(a,b.start,b.start),b.text};var u=function(a,b,c,e){var f=b+c.length;switch(e="string"==typeof e?e.toLowerCase():""){case"collapsetostart":d(a,b,b);break;case"collapsetoend":d(a,f,f);break;case"select":d(a,b,f)}};g=function(a,b,c,d){var e=a.value;a.value=e.slice(0,c)+b+e.slice(c),"boolean"==typeof d&&(d=d?"collapseToEnd":""),u(a,c,b,d)},h=function(a,b,d){var e=c(a),f=a.value;a.value=f.slice(0,e.start)+b+f.slice(e.end),u(a,e.start,b,d||"collapseToEnd")},i=function(a,d,e,f){typeof e==b&&(e=d);var g=c(a),h=a.value;a.value=h.slice(0,g.start)+d+g.text+e+h.slice(g.end);var i=g.start+d.length;u(a,i,g.text,f||"select")},a.fn.extend({getSelection:v(c,!1),setSelection:v(d,!0),collapseSelection:v(k,!0),deleteSelectedText:v(e,!0),deleteText:v(f,!0),extractSelectedText:v(j,!1),insertText:v(g,!0),replaceSelectedText:v(h,!0),surroundSelectedText:v(i,!0)})})})(jQuery);/** * jQuery Hangul IME * https://github.com/clee704/jQuery-Hangul-IME * Depends on: * jQuery (http://jquery.com/) * hangul.js, hangul-dubeol.js, hangul-sebeol.js (https://github.com/clee704/hangul-js) * rangyinputs_jquery.js (http://code.google.com/p/rangyinputs) * @version 0.2.1 * @copyright Copyright 2013, Choongmin Lee * @license MIT license */ (function(e,t,n){var r=[],i={dubeol:new t.dubeol.Automaton(r),sebeol:new t.sebeol.Automaton(r)},l=i.dubeol,u="hangul";var a={init:function(t){return this.each(function(){var n=e(this),r=n.data("hangulime");if(!r){var i=e.extend({},t),l={"keypress.hangulime":c,"keydown.hangulime":f,"mousedown.hangulime":s,"blur.hangulime":s};n.data("hangulime",{config:i}).bind(l)}})},destroy:function(){return this.each(function(){var t=e(this),n=t.data("hangulime");if(n){t.unbind(".hangulime").removeData("hangulime")}})}};e.fn.hangulime=function(t){if(a[t]){return a[t].apply(this,Array.prototype.slice.call(arguments,1))}else if(typeof t==="object"||!t){return a.init.apply(this,arguments)}else{e.error("Method "+t+" does not exist on jQuery.hangulime")}};var o={BACKSPACE:8,TAB:9,RETURN:13,PAUSE_BREAK:19,CAPS_LOCK:20,SPACE:32,PAGE_UP:33,PAGE_DOWN:34,END:35,HOME:36,LEFT_ARROW:37,UP_ARROW:38,RIGHT_ARROW:39,DOWN_ARROW:40,INSERT:45,DELETE:46,LEFT_WINDOWS:91,RIGHT_WINDOWS:92,RIGHT_COMMAND:93,F1:112,F12:123,SCROLL_LOCK:145,IME:229};function c(t){var n=e(this),r=t.which;if(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey&&r==o.SPACE||r==o.IME||r==0||r==o.BACKSPACE||r==o.TAB||r==o.PAUSE_BREAK||r==o.CAPS_LOCK||r==o.SCROLL_LOCK){return}if(u==="hangul")return E(n,t.which)}function f(t){var n=e(this),r=t.which;if(t.altKey&&t.shiftKey&&r==o.SPACE){A();return false}else if(t.shiftKey&&r==o.SPACE||r==o.IME){h();return false}else if(u==="hangul"){if(r==o.BACKSPACE){return S(n)}else if(t.metaKey||t.altKey||t.ctrlKey||r==o.TAB||r==o.PAUSE_BREAK||r==o.CAPS_LOCK||r==o.INSERT||r==o.DELETE||r==o.LEFT_WINDOWS||r==o.RIGHT_WINDOWS||r==o.SCROLL_LOCK||r>=o.PAGE_UP&&r<=o.DOWN_ARROW||r>=o.F1&&r<=o.F12){l.reset()}}}function s(){if(u==="hangul")l.reset()}function h(){u=u==="hangul"?"qwerty":"hangul";l.reset()}function A(){l=l===i.dubeol?i.sebeol:i.dubeol;l.reset()}function E(e,t){var i=false;if(l.currentBlock!==n){var u=e.getSelection();e.setSelection(u.end-1,u.end);if(e.getSelection().text!==l.currentBlock){e.setSelection(u.start,u.end)}}if(t==o.RETURN){t=10}var a=String.fromCharCode(t);l.next(a);if(r.length>0){if(r[r.length-1]===a&&l.currentBlock===n){r.pop();i=true}e.replaceSelectedText(r.join(""));r.length=0;if(i){return}}if(l.currentBlock!==n){e.replaceSelectedText(l.currentBlock)}return false}function S(e){if(l.currentBlock===n){return true}else{var t=e.getSelection();e.setSelection(t.end-1,t.end);l.next("\b");if(l.currentBlock===n){e.deleteSelectedText()}else{e.replaceSelectedText(l.currentBlock)}return false}}})(jQuery,hangul);