@ -0,0 +1,40 @@
@@ -0,0 +1,40 @@
|
||||
# Emotions: a jQuery plugin |
||||
|
||||
Emotions is a jQuery plugin that makes it easy to convert some emotion text to images. ( e.g. 8) => img ) |
||||
|
||||
## Usage |
||||
|
||||
First, load css, jQuery and the plugin: |
||||
|
||||
```html |
||||
<link rel="stylesheet" href="jquery.emotions.icq.css"> |
||||
<script src="jquery.min.js" type="text/javascript"></script> |
||||
<script src="jquery.emotions.js" type="text/javascript"></script> |
||||
``` |
||||
|
||||
Now, let's attach it to your dom elements: |
||||
|
||||
```html |
||||
<script type="text/javascript"> |
||||
jQuery(document).ready(function() { |
||||
$(".txt").emotions(); |
||||
}); |
||||
</script> |
||||
``` |
||||
|
||||
Create dom elements which text should be transformed: |
||||
|
||||
```html |
||||
<div class="txt">Some text with smile 8)</div> |
||||
<div class="txt">o.O o.O o.O :D :D :D</div> |
||||
<div class="txt">o:) o.O 3:) :D <3 :* :) 8| :/ ;) :'( :( 8) >:( :p</div> |
||||
``` |
||||
|
||||
## Links |
||||
[Смайлы в чате как в Facebook или ICQ c помощью JQuery](http://www.itlessons.info/javascript/facebook-or-icq-jquery-emotions-plugin/) |
||||
|
||||
## Author |
||||
[itlessons](http://www.itlessons.info) ([@itlessonsinfo](http://twitter.com/itlessonsinfo)) |
||||
|
||||
## Other |
||||
[MIT License](http://www.opensource.org/licenses/mit-license.php) |
After Width: | Height: | Size: 43 B |
After Width: | Height: | Size: 598 B |
After Width: | Height: | Size: 578 B |
After Width: | Height: | Size: 593 B |
After Width: | Height: | Size: 376 B |
After Width: | Height: | Size: 586 B |
After Width: | Height: | Size: 582 B |
After Width: | Height: | Size: 583 B |
After Width: | Height: | Size: 592 B |
After Width: | Height: | Size: 224 B |
After Width: | Height: | Size: 589 B |
After Width: | Height: | Size: 587 B |
After Width: | Height: | Size: 578 B |
After Width: | Height: | Size: 587 B |
After Width: | Height: | Size: 583 B |
After Width: | Height: | Size: 590 B |
After Width: | Height: | Size: 6.0 KiB |
After Width: | Height: | Size: 4.3 KiB |
After Width: | Height: | Size: 13 KiB |
After Width: | Height: | Size: 7.9 KiB |
After Width: | Height: | Size: 2.3 KiB |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 622 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 4.9 KiB |
After Width: | Height: | Size: 2.3 KiB |
After Width: | Height: | Size: 4.7 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 6.0 KiB |
After Width: | Height: | Size: 2.3 KiB |
@ -0,0 +1,71 @@
@@ -0,0 +1,71 @@
|
||||
.emotions { |
||||
width: 14px; |
||||
height: 14px; |
||||
background: url("emotions/blank.gif") no-repeat center center; |
||||
display: inline-block; |
||||
vertical-align: top; |
||||
} |
||||
|
||||
.emo-angel { |
||||
background: url("emotions/fb/angel.gif"); |
||||
width: 16px; |
||||
height: 15px; |
||||
} |
||||
|
||||
.emo-confused { |
||||
background: url("emotions/fb/confused.gif"); |
||||
} |
||||
|
||||
.emo-devil { |
||||
background: url("emotions/fb/devil.gif"); |
||||
height: 15px; |
||||
} |
||||
|
||||
.emo-grin { |
||||
background: url("emotions/fb/grin.gif"); |
||||
} |
||||
|
||||
.emo-heart { |
||||
background: url("emotions/fb/heart.gif"); |
||||
width: 15px; |
||||
} |
||||
|
||||
.emo-kiss { |
||||
background: url("emotions/fb/kiss.gif"); |
||||
} |
||||
|
||||
.emo-smile { |
||||
background: url("emotions/fb/smile.gif"); |
||||
} |
||||
|
||||
.emo-sunglasses { |
||||
background: url("emotions/fb/sunglasses.gif"); |
||||
} |
||||
|
||||
.emo-unsure { |
||||
background: url("emotions/fb/unsure.gif"); |
||||
} |
||||
|
||||
.emo-wink { |
||||
background: url("emotions/fb/wink.gif"); |
||||
} |
||||
|
||||
.emo-cry { |
||||
background: url("emotions/fb/cry.gif"); |
||||
} |
||||
|
||||
.emo-glasses { |
||||
background: url("emotions/fb/glasses.gif"); |
||||
} |
||||
|
||||
.emo-grumpy { |
||||
background: url("emotions/fb/grumpy.gif"); |
||||
} |
||||
|
||||
.emo-tongue { |
||||
background: url("emotions/fb/tongue.gif"); |
||||
} |
||||
|
||||
.emo-frown { |
||||
background: url("emotions/fb/frown.gif"); |
||||
} |
@ -0,0 +1,67 @@
@@ -0,0 +1,67 @@
|
||||
.emotions { |
||||
width: 20px; |
||||
height: 20px; |
||||
background: url("emotions/blank.gif") no-repeat center center; |
||||
display: inline-block; |
||||
vertical-align: bottom; |
||||
} |
||||
|
||||
.emo-angel { |
||||
background: url("emotions/icq/angel.gif"); |
||||
} |
||||
|
||||
.emo-confused { |
||||
background: url("emotions/icq/confused.gif"); |
||||
} |
||||
|
||||
.emo-devil { |
||||
background: url("emotions/icq/devil.gif"); |
||||
} |
||||
|
||||
.emo-grin { |
||||
background: url("emotions/icq/grin.gif"); |
||||
} |
||||
|
||||
.emo-heart { |
||||
background: url("emotions/icq/heart.gif"); |
||||
} |
||||
|
||||
.emo-kiss { |
||||
background: url("emotions/icq/kiss.gif"); |
||||
} |
||||
|
||||
.emo-smile { |
||||
background: url("emotions/icq/smile.gif"); |
||||
} |
||||
|
||||
.emo-sunglasses { |
||||
background: url("emotions/icq/sunglasses.gif"); |
||||
} |
||||
|
||||
.emo-unsure { |
||||
background: url("emotions/icq/unsure.gif"); |
||||
} |
||||
|
||||
.emo-wink { |
||||
background: url("emotions/icq/wink.gif"); |
||||
} |
||||
|
||||
.emo-cry { |
||||
background: url("emotions/icq/cry.gif"); |
||||
} |
||||
|
||||
.emo-glasses { |
||||
background: url("emotions/icq/glasses.gif"); |
||||
} |
||||
|
||||
.emo-grumpy { |
||||
background: url("emotions/icq/grumpy.gif"); |
||||
} |
||||
|
||||
.emo-tongue { |
||||
background: url("emotions/icq/tongue.gif"); |
||||
} |
||||
|
||||
.emo-frown { |
||||
background: url("emotions/icq/frown.gif"); |
||||
} |
@ -0,0 +1,97 @@
@@ -0,0 +1,97 @@
|
||||
/** |
||||
* Emotions is a jQuery plugin that makes it easy to convert some emotion text to images (e.g 8) ) |
||||
* |
||||
* @name emotions |
||||
* @version 0.0.1 |
||||
* @requires jQuery v1.2.3+ |
||||
* @license MIT License - http://www.opensource.org/licenses/mit-license.php
|
||||
* |
||||
* For usage and examples, visit: |
||||
* https://github.com/itlessons/jquery-emotions
|
||||
* http://www.itlessons.info/javascript/facebook-or-icq-jquery-emotions-plugin/
|
||||
* |
||||
* Copyright (c) 2013, www.itlessons.info |
||||
*/ |
||||
(function ($) { |
||||
|
||||
$.emotions = function (text) { |
||||
return $.emotions.parse(text); |
||||
}; |
||||
|
||||
var $t = $.emotions; |
||||
|
||||
$.extend($.emotions, { |
||||
|
||||
settings: { |
||||
replacement: '<span class="emotions emo-{eId}"></span>', |
||||
map: { |
||||
"o:)": "angel", |
||||
"o.O": "confused", |
||||
"3:)": "devil", |
||||
"<3": "heart", |
||||
":*": "kiss", |
||||
":-)": "smile", |
||||
":]": "smile", |
||||
"8|": "sunglasses", |
||||
":/": "unsure", |
||||
";)": "wink", |
||||
":'(": "cry", |
||||
">:(": "grumpy", |
||||
":(": "frown", |
||||
"8)": "glasses", |
||||
":p": "tongue", |
||||
":)": "smile", |
||||
"=)": "smile", |
||||
":D": "grin" |
||||
} |
||||
}, |
||||
shortcode: function(eId){ |
||||
var $s = $t.settings; |
||||
for (var pattern in $s.map) { |
||||
if($s.map[pattern] == eId) |
||||
return pattern; |
||||
} |
||||
|
||||
return ""; |
||||
}, |
||||
parse: function (text) { |
||||
|
||||
var $s = $t.settings; |
||||
|
||||
for (var pattern in $s.map) { |
||||
|
||||
var encPattent = $t.encode(pattern); |
||||
|
||||
if (text.indexOf(pattern) < 0 && text.indexOf(encPattent) < 0) { |
||||
continue; |
||||
} |
||||
|
||||
var rep = $s.replacement |
||||
.replace(/\{eId\}/g, $s.map[pattern]); |
||||
|
||||
text = text |
||||
.replace(new RegExp($t.quote(pattern), "g"), rep) |
||||
.replace(new RegExp($t.quote(encPattent), "g"), rep); |
||||
} |
||||
|
||||
return text; |
||||
}, |
||||
encode: function (str) { |
||||
return (str + '') |
||||
.replace(/&/g, '&') |
||||
.replace(/</g, '<') |
||||
.replace(/>/g, '>') |
||||
.replace(/"/g, '"'); |
||||
}, |
||||
quote: function (str) { |
||||
return (str + '').replace(/([.?*+^$[\]\\(){}|-])/g, "\\$1"); |
||||
} |
||||
}); |
||||
|
||||
$.fn.emotions = function (action, options) { |
||||
this.each(function () { |
||||
var el = $(this); |
||||
el.html($.emotions(el.html())); |
||||
}); |
||||
}; |
||||
})(jQuery); |