-
Notifications
You must be signed in to change notification settings - Fork 7
/
jemoji.min.js
1 lines (1 loc) · 17.1 KB
/
jemoji.min.js
1
if("undefined"==typeof jQuery)throw new Error("jEmoji requires jQuery");!function(e){var a=function(a,o){function i(a,o){return function(){if("ontouchstart"in document.documentElement){var i=e(this),n=null;if(/input/i.test(i.prop("tagName"))?n=i:e("input",i).size()>0&&(n=e(e("input",i).get(0))),n){var t=n.val(),r=null;n.focus(function(e){clearInterval(r),r=setInterval(function(){if(n.val()!=t){var e=jQuery.Event(o);t=n.val(),e.which=e.keyCode=t&&t.length>0?t.charCodeAt(t.length-1):"",n.trigger(e)}},30)}),n.blur(function(){clearInterval(r)})}}return a.apply(this,arguments)}}var n=this;this._icons=["+1","-1","100","1234","8ball","a","ab","abc","abcd","accept","aerial_tramway","airplane","alarm_clock","alien","ambulance","anchor","angel","anger","angry","anguished","ant","apple","aquarius","aries","arrow_backward","arrow_double_down","arrow_double_up","arrow_down","arrow_down_small","arrow_forward","arrow_heading_down","arrow_heading_up","arrow_left","arrow_lower_left","arrow_lower_right","arrow_right","arrow_right_hook","arrow_up","arrow_up_down","arrow_up_small","arrow_upper_left","arrow_upper_right","arrows_clockwise","arrows_counterclockwise","art","articulated_lorry","astonished","atm","b","baby","baby_bottle","baby_chick","baby_symbol","back","baggage_claim","balloon","ballot_box_with_check","bamboo","banana","bangbang","bank","bar_chart","barber","baseball","basketball","bath","bathtub","battery","bear","bee","beer","beers","beetle","beginner","bell","bento","bicyclist","bike","bikini","bird","birthday","black_circle","black_joker","black_medium_small_square","black_medium_square","black_nib","black_small_square","black_square","black_square_button","blossom","blowfish","blue_book","blue_car","blue_heart","blush","boar","boat","bomb","book","bookmark","bookmark_tabs","books","boom","boot","bouquet","bow","bowling","bowtie","boy","bread","bride_with_veil","bridge_at_night","briefcase","broken_heart","bug","bulb","bullettrain_front","bullettrain_side","bus","busstop","bust_in_silhouette","busts_in_silhouette","cactus","cake","calendar","calling","camel","camera","cancer","candy","capital_abcd","capricorn","car","card_index","carousel_horse","cat","cat2","cd","chart","chart_with_downwards_trend","chart_with_upwards_trend","checkered_flag","cherries","cherry_blossom","chestnut","chicken","children_crossing","chocolate_bar","christmas_tree","church","cinema","circus_tent","city_sunrise","city_sunset","cl","clap","clapper","clipboard","clock1","clock10","clock1030","clock11","clock1130","clock12","clock1230","clock130","clock2","clock230","clock3","clock330","clock4","clock430","clock5","clock530","clock6","clock630","clock7","clock730","clock8","clock830","clock9","clock930","closed_book","closed_lock_with_key","closed_umbrella","cloud","clubs","cn","cocktail","coffee","cold_sweat","collision","computer","confetti_ball","confounded","confused","congratulations","construction","construction_worker","convenience_store","cookie","cool","cop","copyright","corn","couple","couple_with_heart","couplekiss","cow","cow2","credit_card","crescent_moon","crocodile","crossed_flags","crown","cry","crying_cat_face","crystal_ball","cupid","curly_loop","currency_exchange","curry","custard","customs","cyclone","dancer","dancers","dango","dart","dash","date","de","deciduous_tree","department_store","diamond_shape_with_a_dot_inside","diamonds","disappointed","disappointed_relieved","dizzy","dizzy_face","do_not_litter","dog","dog2","dollar","dolls","dolphin","donut","door","doughnut","dragon","dragon_face","dress","dromedary_camel","droplet","dvd","e-mail","ear","ear_of_rice","earth_africa","earth_americas","earth_asia","egg","eggplant","eight","eight_pointed_black_star","eight_spoked_asterisk","electric_plug","elephant","email","end","envelope","es","euro","european_castle","european_post_office","evergreen_tree","exclamation","expressionless","eyeglasses","eyes","facepunch","factory","fallen_leaf","family","fast_forward","fax","fearful","feelsgood","feet","ferris_wheel","file_folder","finnadie","fire","fire_engine","fireworks","first_quarter_moon","first_quarter_moon_with_face","fish","fish_cake","fishing_pole_and_fish","fist","five","flags","flashlight","floppy_disk","flower_playing_cards","flushed","foggy","football","fork_and_knife","fountain","four","four_leaf_clover","fr","free","fried_shrimp","fries","frog","frowning","fu","fuelpump","full_moon","full_moon_with_face","game_die","gb","gem","gemini","ghost","gift","gift_heart","girl","globe_with_meridians","goat","goberserk","godmode","golf","grapes","green_apple","green_book","green_heart","grey_exclamation","grey_question","grimacing","grin","grinning","guardsman","guitar","gun","haircut","hamburger","hammer","hamster","hand","handbag","hankey","hash","hatched_chick","hatching_chick","headphones","hear_no_evil","heart","heart_decoration","heart_eyes","heart_eyes_cat","heartbeat","heartpulse","hearts","heavy_check_mark","heavy_division_sign","heavy_dollar_sign","heavy_exclamation_mark","heavy_minus_sign","heavy_multiplication_x","heavy_plus_sign","helicopter","herb","hibiscus","high_brightness","high_heel","hocho","honey_pot","honeybee","horse","horse_racing","hospital","hotel","hotsprings","hourglass","hourglass_flowing_sand","house","house_with_garden","hurtrealbad","hushed","ice_cream","icecream","id","ideograph_advantage","imp","inbox_tray","incoming_envelope","information_desk_person","information_source","innocent","interrobang","iphone","it","izakaya_lantern","jack_o_lantern","japan","japanese_castle","japanese_goblin","japanese_ogre","jeans","joy","joy_cat","jp","key","keycap_ten","kimono","kiss","kissing","kissing_cat","kissing_closed_eyes","kissing_face","kissing_heart","kissing_smiling_eyes","koala","koko","kr","large_blue_circle","large_blue_diamond","large_orange_diamond","last_quarter_moon","last_quarter_moon_with_face","laughing","leaves","ledger","left_luggage","left_right_arrow","leftwards_arrow_with_hook","lemon","leo","leopard","libra","light_rail","link","lips","lipstick","lock","lock_with_ink_pen","lollipop","loop","loudspeaker","love_hotel","love_letter","low_brightness","m","mag","mag_right","mahjong","mailbox","mailbox_closed","mailbox_with_mail","mailbox_with_no_mail","man","man_with_gua_pi_mao","man_with_turban","mans_shoe","maple_leaf","mask","massage","meat_on_bone","mega","melon","memo","mens","metal","metro","microphone","microscope","milky_way","minibus","minidisc","mobile_phone_off","money_with_wings","moneybag","monkey","monkey_face","monorail","mortar_board","mount_fuji","mountain_bicyclist","mountain_cableway","mountain_railway","mouse","mouse2","movie_camera","moyai","muscle","mushroom","musical_keyboard","musical_note","musical_score","mute","nail_care","name_badge","neckbeard","necktie","negative_squared_cross_mark","neutral_face","new","new_moon","new_moon_with_face","newspaper","ng","nine","no_bell","no_bicycles","no_entry","no_entry_sign","no_good","no_mobile_phones","no_mouth","no_pedestrians","no_smoking","non-potable_water","nose","notebook","notebook_with_decorative_cover","notes","nut_and_bolt","o","o2","ocean","octocat","octopus","oden","office","ok","ok_hand","ok_woman","older_man","older_woman","on","oncoming_automobile","oncoming_bus","oncoming_police_car","oncoming_taxi","one","open_file_folder","open_hands","open_mouth","ophiuchus","orange_book","outbox_tray","ox","package","page_facing_up","page_with_curl","pager","palm_tree","panda_face","paperclip","parking","part_alternation_mark","partly_sunny","passport_control","paw_prints","peach","pear","pencil","pencil2","penguin","pensive","performing_arts","persevere","person_frowning","person_with_blond_hair","person_with_pouting_face","phone","pig","pig2","pig_nose","pill","pineapple","pisces","pizza","plus1","point_down","point_left","point_right","point_up","point_up_2","police_car","poodle","poop","post_office","postal_horn","postbox","potable_water","pouch","poultry_leg","pound","pouting_cat","pray","princess","punch","purple_heart","purse","pushpin","put_litter_in_its_place","question","rabbit","rabbit2","racehorse","radio","radio_button","rage","rage1","rage2","rage3","rage4","railway_car","rainbow","raised_hand","raised_hands","raising_hand","ram","ramen","rat","recycle","red_car","red_circle","registered","relaxed","relieved","repeat","repeat_one","restroom","revolving_hearts","rewind","ribbon","rice","rice_ball","rice_cracker","rice_scene","ring","rocket","roller_coaster","rooster","rose","rotating_light","round_pushpin","rowboat","ru","rugby_football","runner","running","running_shirt_with_sash","sa","sagittarius","sailboat","sake","sandal","santa","satellite","satisfied","saxophone","school","school_satchel","scissors","scorpius","scream","scream_cat","scroll","seat","secret","see_no_evil","seedling","seven","shaved_ice","sheep","shell","ship","shipit","shirt","shit","shoe","shower","signal_strength","six","six_pointed_star","ski","skull","sleeping","sleepy","slot_machine","small_blue_diamond","small_orange_diamond","small_red_triangle","small_red_triangle_down","smile","smile_cat","smiley","smiley_cat","smiling_imp","smirk","smirk_cat","smoking","snail","snake","snowboarder","snowflake","snowman","sob","soccer","soon","sos","sound","space_invader","spades","spaghetti","sparkle","sparkler","sparkles","sparkling_heart","speak_no_evil","speaker","speech_balloon","speedboat","squirrel","star","star2","stars","station","statue_of_liberty","steam_locomotive","stew","straight_ruler","strawberry","stuck_out_tongue","stuck_out_tongue_closed_eyes","stuck_out_tongue_winking_eye","sun_with_face","sunflower","sunglasses","sunny","sunrise","sunrise_over_mountains","surfer","sushi","suspect","suspension_railway","sweat","sweat_drops","sweat_smile","sweet_potato","swimmer","symbols","syringe","tada","tanabata_tree","tangerine","taurus","taxi","tea","telephone","telephone_receiver","telescope","tennis","tent","thought_balloon","three","thumbsdown","thumbsup","ticket","tiger","tiger2","tired_face","tm","toilet","tokyo_tower","tomato","tongue","top","tophat","tractor","traffic_light","train","train2","tram","triangular_flag_on_post","triangular_ruler","trident","triumph","trolleybus","trollface","trophy","tropical_drink","tropical_fish","truck","trumpet","tshirt","tulip","turtle","tv","twisted_rightwards_arrows","two","two_hearts","two_men_holding_hands","two_women_holding_hands","u5272","u5408","u55b6","u6307","u6708","u6709","u6e80","u7121","u7533","u7981","u7a7a","uk","umbrella","unamused","underage","unlock","up","us","v","vertical_traffic_light","vhs","vibration_mode","video_camera","video_game","violin","virgo","volcano","vs","walking","waning_crescent_moon","waning_gibbous_moon","warning","watch","water_buffalo","watermelon","wave","wavy_dash","waxing_crescent_moon","waxing_gibbous_moon","wc","weary","wedding","whale","whale2","wheelchair","white_check_mark","white_circle","white_flower","white_large_square","white_medium_small_square","white_medium_square","white_small_square","white_square_button","wind_chime","wine_glass","wink","wolf","woman","womans_clothes","womans_hat","womens","worried","wrench","x","yellow_heart","yen","yum","zap","zero","zzz"],this._language={es:{arrow:"← / → para navegar",select:"↵ para seleccionar",esc:"esc para cerrar",close:"Cerrar"},en:{arrow:"← / → to navigate",select:"↵ to select",esc:"esc to dismiss",close:"Close"}},this._defaults={icons:void 0,extension:"png",folder:"images/emojis/",container:void 0,btn:void 0,navigation:!0,language:"en",theme:"blue",resize:void 0},this._options=e.extend(!0,{},this._defaults,o),"undefined"!=typeof this._options.icons&&(this._icons=this._options.icons),this.options=function(a){return a?e.extend(!0,this._options,a):this._options},this.isOpen=function(){return e(r).is(":visible")},this.open=function(){e(r).show();var o=e(r).find(".jemoji-icons");if(""===o.html()){var i=this._defaults.folder;this._options.folder&&(i=this._options.folder);for(var t=o[0],s="",l=this._options.extension,c=0,_=100;_>c;c++){var h=n._icons[c],d="";""===s&&(d='class="active"'),s+="<div "+d+'><img src="'+i+h+"."+l+'" alt="'+h+'" /><span>:'+h+":</span></div>"}t.innerHTML=s,a.data("jemojiclick").call();var u=0;o.on("scroll",function(){if(e(this).scrollTop()+e(this).innerHeight()>=e(this)[0].scrollHeight&&100*++u<n._icons.length){for(var o="",r=100*u,s=100+100*u;s>r;r++){var c=n._icons[r];c&&(o+='<div><img src="'+i+c+"."+l+'" alt="'+c+'" /><span>:'+c+":</span></div>")}t.innerHTML+=o,a.data("jemojiclick").call()}})}},this.close=function(){e(r).hide()};var t=function(){if(0===a.length)return 0;var e=a[0],o=e.value.length;try{if(e.createTextRange){var i=document.selection.createRange().duplicate();i.moveEnd("character",e.value.length),""===i.text&&(o=e.value.length),o=e.value.lastIndexOf(i.text)}else"undefined"!=typeof e.selectionStart&&(o=e.selectionStart)}catch(n){}return o};e.fn.jemojiKeyup=i(e.fn.keyup,"keyup"),e.fn.jemojiKeydown=i(e.fn.keydown,"keydown"),e.fn.jemojiKeypress=i(e.fn.keypress,"keypress"),a.data("jemojiclick",function(){e(l).find("div").off("click").on("click",function(){var o=e(this).find("img").attr("alt"),i=t(),r=a.val();r=r.slice(0,r.lastIndexOf(":",i))+":"+o+": "+r.slice(i),a.val(r),a.focus(),b=!1,y="",n.close()})});var r=document.createElement("div"),s=e(r);this._options.theme?r.className="jemoji-menu "+this._options.theme:r.className="jemoji-menu "+this._defaults.theme;var l=document.createElement("div");l.className="jemoji-icons",a.after(e(l));var c=document.createElement("div");c.className="jemoji-menu-arrow up",e(l).before(e(c)),s.append(e(l));var _=document.createElement("div");_.className="jemoji-info";var h=this._language[this._options.language];"undefined"==typeof h&&(h=this._language[this._defaults.language]);var d="undefined"!=typeof this._options.navigation?this._options.navigation:this._defaults.navigation;if(d){h=jQuery.map(h,function(e){return e}),_.innerHTML="";for(var u=0,p=h.length-1;p>u;u++)_.innerHTML+="<div>"+h[u]+"</div>";_.innerHTML+='<div class="jemoji-close">'+h[h.length-1]+"</div>"}else _.innerHTML='<div class="jemoji-close">'+h.close+"</div>";s.prepend(e(_)),e(_).css("width",a.css("width")),e(_).find(".jemoji-close").on("click",function(){n.close()}),s.prepend(e(c)),s.css("width",a.css("width")),e(l).css("width",a.css("width"));var m="undefined"!=typeof this._options.container?this._options.container:this._defaults.container;m?(m instanceof jQuery||(m=e(m)),m.append(s)):a.after(s);var g,f,b=!1,w=!1,v="undefined"!=typeof this._options.btn?this._options.btn:this._defaults.btn;v&&(v instanceof jQuery||(v=e(v)),v.on("click",function(){n.isOpen()?n.close():n.open(),a.focus()})),e(window).on("resize",function(){if(n.resize)n.resize();else{var o=a.css("width");e(l).css("width",o),e(r).css("width",o),e(_).css("width",o)}});var k,y="",j=function(){if(y.length>=2){var o=new RegExp("^([a-zA-Z0-9]|_?)*"+y.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")+"([a-zA-Z0-9]|_?)*"),i=e(l),t=i[0],r=n._defaults.folder;n._options.folder&&(r=n._options.folder);for(var s="",c=n._options.extension,_=0,h=n._icons.length;h>_;_++)if(k=n._icons[_],o.test(k)){var d="";""===s&&(d='class="active"'),s+="<div "+d+'><img src="'+r+k+"."+c+'" alt="'+k+'" /><span>:'+k+":</span></div>"}t.innerHTML=s,a.data("jemojiContainer",i.closest(".jemoji-menu")[0]),0===t.innerHTML.length?(n.close(),y="",b=!1):(a.data("jemojiclick").call(),n.open())}};a.jemojiKeydown(function(o){if(27===o.which&&n.isOpen())return n.close(),void(g=f=-1);if(b){var i=a.val(),r=e(l).find("div"),s=r.index(e(l).find("div.active"));if(n.isOpen()){if(37===o.which||38===o.which)return void(d&&(r.removeClass("active"),s>0?e(r.get(s-1)).addClass("active"):e(r.get(r.length-1)).addClass("active"),k=e(l).find("div.active img").attr("alt"),-1===g&&(g=t()),-1===f&&(f=t()),i=i.slice(0,i.lastIndexOf(":",g))+":"+k+": "+i.slice(f),a.val(i),f=i.indexOf(":",g)+2,w=!0,y="",o.preventDefault()));if(39===o.which||40===o.which||9===o.which)return void(d&&(r.removeClass("active"),s<r.length-1?e(r.get(s+1)).addClass("active"):e(r.get(0)).addClass("active"),k=e(l).find("div.active img").attr("alt"),-1===g&&(g=t()),-1===f&&(f=t()),i=i.slice(0,i.lastIndexOf(":",g))+":"+k+": "+i.slice(f),a.val(i),f=i.indexOf(":",g)+2,w=!0,y="",o.preventDefault()))}if(8===o.which){y=y.slice(0,-1);var i=a.val(),r=e(l).find("div"),s=r.index(e(l).find("div.active"));8===o.which&&(y=y.slice(0,-1),j())}}}),a.jemojiKeypress(function(o){if(13===o.which&&n.isOpen())return a.focus(),n.close(),b=!1,y="",g=f=-1,w||(k=e(l).find("div.active img").attr("alt"),-1===g&&(g=t()),-1===f&&(f=t()),i=a.val(),i=i.slice(0,i.lastIndexOf(":",g))+":"+k+": "+i.slice(f),a.val(i)),e(r).find(".jemoji-icons").html(""),void o.preventDefault();if(58===o.which)return void(b||(b=!0,y="",g=f=-1));if(b){var i=a.val(),s=e(l).find("div");s.index(e(l).find("div.active"));y+=String.fromCharCode(o.which).toLowerCase(),j()}})};e.fn.jemoji=function(o){function i(){var a=e(this),o=a.data("jemoji");s.push(o)}function n(e){var a=s[e];if(!a)return console.warn("$.jemoji not instantiated yet"),console.info(this),void c.push(void 0);if("function"==typeof a[r]){var o=a[r].apply(a,l);c.push(o)}else console.warn("Method '"+r+"' not defined in $.jemoji")}function t(){var o=e(this),i=new a(o,_);o.data("jemoji",i)}var r="string"==typeof o?o:void 0;if(r){var s=[];this.each(i);var l=arguments.length>1?Array.prototype.slice.call(arguments,1):void 0,c=[];return this.each(n),c.length>1?c:c[0]}var _="object"==typeof o?o:void 0;return this.each(t)}}(jQuery);