PageRenderTime 57ms CodeModel.GetById 10ms app.highlight 43ms RepoModel.GetById 1ms app.codeStats 0ms

/modules/mod_base/lib/js/modules/z.smiley.js

https://code.google.com/p/zotonic/
JavaScript | 157 lines | 128 code | 4 blank | 25 comment | 6 complexity | 7ac1ce054ff08d9685ced4fc7571df62 MD5 | raw file
  1/* z.smiley.js
  2----------------------------------------------------------
  3
  4@author Marc Worrell <marc@worrell.nl>
  5@author Ben Alman
  6
  7Incorporates code by Ben Alman:
  8http://benalman.com/projects/jquery-replacetext-plugin/
  9
 10Copyright 2011 Marc Worrell
 11Copyright 2009 Ben Alman
 12
 13Licensed under the Apache License, Version 2.0 (the "License");
 14you may not use this file except in compliance with the License.
 15You may obtain a copy of the License at
 16 
 17http://www.apache.org/licenses/LICENSE-2.0
 18 
 19Unless required by applicable law or agreed to in writing, software
 20distributed under the License is distributed on an "AS IS" BASIS,
 21WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 22See the License for the specific language governing permissions and
 23limitations under the License.
 24
 25---------------------------------------------------------- */
 26
 27$.widget("ui.smiley", {
 28	_init: function() {
 29		var html = $(this.element).html;
 30		var smileys = this.options.smileys;
 31
 32		this.element.each(function(){
 33			var node = this.firstChild, val, new_val, remove = [];
 34			if (node) {
 35				do {
 36					if ( node.nodeType === 3 ) {
 37						val = node.nodeValue;
 38						new_val = val;
 39						for (var i=0; i<smileys.length; i++) {
 40							var img = '<img src="'+smileys[i].u+'" alt="'+smileys[i].d+'"/>';
 41							new_val = new_val.replace(smileys[i].k, img);
 42						};
 43						if ( new_val !== val ) {
 44							$(node).before( new_val );
 45							remove.push( node );
 46						}
 47					}
 48				} while ( node = node.nextSibling );
 49			}
 50			remove.length && $(remove).remove();
 51		});
 52	}
 53});
 54
 55$.ui.smiley.defaults = {
 56	smileys: [
 57		{ k:'(ff)', d:"big hug", u:"/lib/images/smileys/firefox.gif" },
 58		{ k:'>:D<', d:"big hug", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/6.gif" },
 59		{ k:'#:-S', d:"whew!", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/18.gif" },
 60		{ k:'O:-)', d:"angel", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/25.gif" },
 61		{ k:'<:-P', d:"party", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/36.gif" },
 62		{ k:':-SS', d:"nail biting", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/42.gif" },
 63		{ k:'<):)', d:"cowboy", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/48.gif" },
 64		{ k:':-bd', d:"thumbs up", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/113.gif" },
 65		{ k:'^#(^', d:"it wasn't me", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/114.gif" },
 66		{ k:':ar!', d:"pirate", u:"http://l.yimg.com/a/i/us/msg/emoticons/pirate_2.gif" },
 67		{ k:':-??', d:"I don't know", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/106.gif" },
 68		{ k:'3:-O', d:"cow", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/50.gif" },
 69		{ k:':(|)', d:"monkey", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/51.gif" },
 70		{ k:'@};-', d:"rose", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/53.gif" },
 71		{ k:'**==', d:"flag", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/55.gif" },
 72		{ k:'(~~)', d:"pumpkin", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/56.gif" },
 73		{ k:'*-:)', d:"idea", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/58.gif" },
 74		{ k:'[-O<', d:"praying", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/63.gif" },
 75		{ k:':)>-', d:"peace sign", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/67.gif" },
 76		{ k:'\\:D/', d:"dancing", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/69.gif" },
 77		{ k:'^:)^', d:"not worthy", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/77.gif" },
 78		{ k:'[..]', d:"transformer", u:"http://l.yimg.com/a/i/us/msg/emoticons/transformer.gif" },
 79		{ k:';;)', d:"batting eyelashes", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/5.gif" },
 80		{ k:':-/', d:"confused", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/7.gif" },
 81		{ k:':">', d:"blushing", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/9.gif" },
 82		{ k:':-*', d:"kiss", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/11.gif" },
 83		{ k:'=((', d:"broken heart", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/12.gif" },
 84		{ k:':-O', d:"surprise", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/13.gif" },
 85		{ k:'B-)', d:"cool", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/16.gif" },
 86		{ k:':-S', d:"worried", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/17.gif" },
 87		{ k:'>:)', d:"devil", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/19.gif" },
 88		{ k:':((', d:"crying", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/20.gif" },
 89		{ k:':))', d:"laughing", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/21.gif" },
 90		{ k:'/:)', d:"raised eyebrows", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/23.gif" },
 91		{ k:'=))', d:"rolling on the floor", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/24.gif" },
 92		{ k:':-B', d:"nerd", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/26.gif" },
 93		{ k:':-c', d:"call me", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/101.gif" },
 94		{ k:':)]', d:"on the phone", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/100.gif" },
 95		{ k:'~X(', d:"at wits' end", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/102.gif" },
 96		{ k:':-h', d:"wave", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/103.gif" },
 97		{ k:':-t', d:"time out", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/104.gif" },
 98		{ k:'8->', d:"day dreaming", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/105.gif" },
 99		{ k:'I-)', d:"sleepy", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/28.gif" },
100		{ k:'8-|', d:"rolling eyes", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/29.gif" },
101		{ k:'L-)', d:"loser", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/30.gif" },
102		{ k:':-&', d:"sick", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/31.gif" },
103		{ k:':-$', d:"don't tell anyone", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/32.gif" },
104		{ k:'[-(', d:"no talking", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/33.gif" },
105		{ k:':O)', d:"clown", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/34.gif" },
106		{ k:'8-}', d:"silly", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/35.gif" },
107		{ k:'(:|', d:"yawn", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/37.gif" },
108		{ k:'=P~', d:"drooling", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/38.gif" },
109		{ k:':-?', d:"thinking", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/39.gif" },
110		{ k:'#-o', d:"d'oh", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/40.gif" },
111		{ k:'=D>', d:"applause", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/41.gif" },
112		{ k:'@-)', d:"hypnotized", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/43.gif" },
113		{ k:':^o', d:"liar", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/44.gif" },
114		{ k:':-w', d:"waiting", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/45.gif" },
115		{ k:':-<', d:"sigh", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/46.gif" },
116		{ k:'>:P', d:"phbbbbt", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/47.gif" },
117		{ k:'X_X', d:"I don't want to see", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/109.gif" },
118		{ k:':!!', d:"hurry up!", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/110.gif" },
119		{ k:'\\m/', d:"rock on!", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/111.gif" },
120		{ k:':-q', d:"thumbs down", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/112.gif" },
121		{ k:':o3', d:"puppy dog eyes", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/108.gif" },
122		{ k:'%-(', d:"not listening", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/107.gif" },
123		{ k:':@)', d:"pig", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/49.gif" },
124		{ k:'~:>', d:"chicken", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/52.gif" },
125		{ k:'%%-', d:"good luck", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/54.gif" },
126		{ k:'~O)', d:"coffee", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/57.gif" },
127		{ k:'8-X', d:"skull", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/59.gif" },
128		{ k:'=:)', d:"bug", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/60.gif" },
129		{ k:'>-)', d:"alien", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/61.gif" },
130		{ k:':-L', d:"frustrated", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/62.gif" },
131		{ k:'$-)', d:"money eyes", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/64.gif" },
132		{ k:':-"', d:"whistling", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/65.gif" },
133		{ k:'b-(', d:"feeling beat up", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/66.gif" },
134		{ k:'[-X', d:"shame on you", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/68.gif" },
135		{ k:'>:/', d:"bring it on", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/70.gif" },
136		{ k:';))', d:"hee hee", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/71.gif" },
137		{ k:':-@', d:"chatterbox", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/76.gif" },
138		{ k:':-j', d:"oh go on", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/78.gif" },
139		{ k:'(*)', d:"star", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/79.gif" },
140		{ k:'o->', d:"hiro", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/72.gif" },
141		{ k:'o=>', d:"billy", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/73.gif" },
142		{ k:'o-+', d:"april", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/74.gif" },
143		{ k:'(%)', d:"yin yang", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/75.gif" },
144		{ k:':bz', d:"bee", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/115.gif" },
145		{ k:':)', d:"happy", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/1.gif" },
146		{ k:':(', d:"sad", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/2.gif" },
147		{ k:';)', d:"winking", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/3.gif" },
148		{ k:':D', d:"big grin", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/4.gif" },
149		{ k:':x', d:"love struck", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/8.gif" },
150		{ k:':P', d:"tongue", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/10.gif" },
151		{ k:'X(', d:"angry", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/14.gif" },
152		{ k:':>', d:"smug", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/15.gif" },
153		{ k:':|', d:"straight face", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/22.gif" },
154		{ k:'=;', d:"talk to the hand", u:"http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/27.gif" }
155	]
156};
157