jquery-cssemoticons-rails 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5cd47f92793b68d10a3f5fc81064a2bea14c480a
4
- data.tar.gz: caaa6116e427ea94a725a8ece3903043cfd90119
3
+ metadata.gz: 5936e7938f84171878a1607fa519118fe0c4d3d9
4
+ data.tar.gz: d5b84abeffc178640666b6ad851f1dee8e736fc7
5
5
  SHA512:
6
- metadata.gz: 7b76f62636554668e180e816c96f6d813e8ec4621cc08ade8be495697e0cc54d9e06c9afa78a63c3a0e63e5d8618cedd0418caaa244a3511eb3ea7168b54f94d
7
- data.tar.gz: c20f11c40145923a126183e5adf3acf21f65efa54b5de36f3b0caec13a371c4f1432be3d0bfd61c4f67f51615a02d3462631db45adbc9efd3b89ef0912bfa0a7
6
+ metadata.gz: ad0cb8b6a9b76f78d90b9e657fdf3646281a1b49c9e757a35b98c1461f4f44d889f6cc96621131bb31447b070b94385b31882457ca476db20cb6d0e020fe5e24
7
+ data.tar.gz: d6fdde10c5d324746789e3b15dc0a818c54229a3470274deba50f9ae4976670affe9ee828d83bfa7e538869c82cf69f98d5ba8b5bcde1c2cdb3476c23aa31d52
@@ -1,5 +1,5 @@
1
1
  module JqueryCSSEmoticons
2
2
  module Rails
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
@@ -0,0 +1,134 @@
1
+ /*
2
+ * jQuery CSSEmoticons plugin 0.2.9
3
+ *
4
+ * Copyright (c) 2010 Steve Schwartz (JangoSteve)
5
+ *
6
+ * Dual licensed under the MIT and GPL licenses:
7
+ * http://www.opensource.org/licenses/mit-license.php
8
+ * http://www.gnu.org/licenses/gpl.html
9
+ *
10
+ * Date: Sun Oct 22 1:00:00 2010 -0500
11
+ */
12
+ (function($) {
13
+ $.fn.emoticonize = function(options) {
14
+
15
+ var opts = $.extend({}, $.fn.emoticonize.defaults, options);
16
+
17
+ var escapeCharacters = [ ")", "(", "*", "[", "]", "{", "}", "|", "^", "<", ">", "\\", "?", "+", "=", "." ];
18
+
19
+ var threeCharacterEmoticons = [
20
+ // really weird bug if you have :{ and then have :{) in the same container anywhere *after* :{ then :{ doesn't get matched, e.g. :] :{ :) :{) :) :-) will match everything except :{
21
+ // But if you take out the :{) or even just move :{ to the right of :{) then everything works fine. This has something to do with the preMatch string below I think, because
22
+ // it'll work again if you set preMatch equal to '()'
23
+ // So for now, we'll just remove :{) from the emoticons, because who actually uses this mustache man anyway?
24
+ // ":{)",
25
+ ":-)", ":o)", ":c)", ":^)", ":-D", ":-(", ":-9", ";-)", ":-P", ":-p", ":-Þ", ":-b", ":-O", ":-/", ":-X", ":-#", ":'(", "B-)", "8-)", ";*(", ":-*", ":-\\",
26
+ "?-)", // <== This is my own invention, it's a smiling pirate (with an eye-patch)!
27
+ // and the twoCharacterEmoticons from below, but with a space inserted
28
+ ": )", ": ]", "= ]", "= )", "8 )", ": }", ": D", "8 D", "X D", "x D", "= D", ": (", ": [", ": {", "= (", "; )", "; ]", "; D", ": P", ": p", "= P", "= p", ": b", ": Þ", ": O", "8 O", ": /", "= /", ": S", ": #", ": X", "B )", ": |", ": \\", "= \\", ": *", ": &gt;", ": &lt;"//, "* )"
29
+ ];
30
+
31
+ var twoCharacterEmoticons = [ // separate these out so that we can add a letter-spacing between the characters for better proportions
32
+ ":)", ":]", "=]", "=)", "8)", ":}", ":D", ":(", ":[", ":{", "=(", ";)", ";]", ";D", ":P", ":p", "=P", "=p", ":b", ":Þ", ":O", ":/", "=/", ":S", ":#", ":X", "B)", ":|", ":\\", "=\\", ":*", ":&gt;", ":&lt;"//, "*)"
33
+ ];
34
+
35
+ var specialEmoticons = { // emoticons to be treated with a special class, hash specifies the additional class to add, along with standard css-emoticon class
36
+ "&gt;:)": { cssClass: "red-emoticon small-emoticon spaced-emoticon" },
37
+ "&gt;;)": { cssClass: "red-emoticon small-emoticon spaced-emoticon"},
38
+ "&gt;:(": { cssClass: "red-emoticon small-emoticon spaced-emoticon" },
39
+ "&gt;: )": { cssClass: "red-emoticon small-emoticon" },
40
+ "&gt;; )": { cssClass: "red-emoticon small-emoticon"},
41
+ "&gt;: (": { cssClass: "red-emoticon small-emoticon" },
42
+ ";(": { cssClass: "red-emoticon spaced-emoticon" },
43
+ "&lt;3": { cssClass: "pink-emoticon counter-rotated" },
44
+ "O_O": { cssClass: "no-rotate" },
45
+ "o_o": { cssClass: "no-rotate" },
46
+ "0_o": { cssClass: "no-rotate" },
47
+ "O_o": { cssClass: "no-rotate" },
48
+ "T_T": { cssClass: "no-rotate" },
49
+ "^_^": { cssClass: "no-rotate" },
50
+ "O:)": { cssClass: "small-emoticon spaced-emoticon" },
51
+ "O: )": { cssClass: "small-emoticon" },
52
+ "8D": { cssClass: "small-emoticon spaced-emoticon" },
53
+ "XD": { cssClass: "small-emoticon spaced-emoticon" },
54
+ "xD": { cssClass: "small-emoticon spaced-emoticon" },
55
+ "=D": { cssClass: "small-emoticon spaced-emoticon" },
56
+ "8O": { cssClass: "small-emoticon spaced-emoticon" },
57
+ "[+=..]": { cssClass: "no-rotate nintendo-controller" }
58
+ //"OwO": { cssClass: "no-rotate" }, // these emoticons overflow and look weird even if they're made even smaller, could probably fix this with some more css trickery
59
+ //"O-O": { cssClass: "no-rotate" },
60
+ //"O=)": { cssClass: "small-emoticon" }
61
+ }
62
+
63
+ var specialRegex = new RegExp( '(\\' + escapeCharacters.join('|\\') + ')', 'g' );
64
+ // One of these characters must be present before the matched emoticon, or the matched emoticon must be the first character in the container HTML
65
+ // This is to ensure that the characters in the middle of HTML properties or URLs are not matched as emoticons
66
+ // Below matches ^ (first character in container HTML), \s (whitespace like space or tab), or \0 (NULL character)
67
+ // (<\\S+.*>) matches <\\S+.*> (matches an HTML tag like <span> or <div>), but haven't quite gotten it working yet, need to push this fix now
68
+ var preMatch = '(^|[\\s\\0])';
69
+
70
+ for ( var i=threeCharacterEmoticons.length-1; i>=0; --i ){
71
+ threeCharacterEmoticons[i] = threeCharacterEmoticons[i].replace(specialRegex,'\\$1');
72
+ threeCharacterEmoticons[i] = new RegExp( preMatch+'(' + threeCharacterEmoticons[i] + ')', 'g' );
73
+ }
74
+
75
+ for ( var i=twoCharacterEmoticons.length-1; i>=0; --i ){
76
+ twoCharacterEmoticons[i] = twoCharacterEmoticons[i].replace(specialRegex,'\\$1');
77
+ twoCharacterEmoticons[i] = new RegExp( preMatch+'(' + twoCharacterEmoticons[i] + ')', 'g' );
78
+ }
79
+
80
+ for ( var emoticon in specialEmoticons ){
81
+ specialEmoticons[emoticon].regexp = emoticon.replace(specialRegex,'\\$1');
82
+ specialEmoticons[emoticon].regexp = new RegExp( preMatch+'(' + specialEmoticons[emoticon].regexp + ')', 'g' );
83
+ }
84
+
85
+ var exclude = 'span.css-emoticon';
86
+ if(opts.exclude){ exclude += ','+opts.exclude; }
87
+ var excludeArray = exclude.split(',')
88
+
89
+ return this.not(exclude).each(function() {
90
+ var container = $(this);
91
+ var cssClass = 'css-emoticon'
92
+ if(opts.animate){ cssClass += ' un-transformed-emoticon animated-emoticon'; }
93
+
94
+ for( var emoticon in specialEmoticons ){
95
+ specialCssClass = cssClass + " " + specialEmoticons[emoticon].cssClass;
96
+ container.html(container.html().replace(specialEmoticons[emoticon].regexp,"$1<span class='" + specialCssClass + "'>$2</span>"));
97
+ }
98
+ $(threeCharacterEmoticons).each(function(){
99
+ container.html(container.html().replace(this,"$1<span class='" + cssClass + "'>$2</span>"));
100
+ });
101
+ $(twoCharacterEmoticons).each(function(){
102
+ container.html(container.html().replace(this,"$1<span class='" + cssClass + " spaced-emoticon'>$2</span>"));
103
+ });
104
+ // fix emoticons that got matched more then once (where one emoticon is a subset of another emoticon), and thus got nested spans
105
+ $.each(excludeArray,function(index,item){
106
+ container.find($.trim(item)+" span.css-emoticon").each(function(){
107
+ $(this).replaceWith($(this).text());
108
+ });
109
+ });
110
+ if(opts.animate){
111
+ setTimeout(function(){$('.un-transformed-emoticon').removeClass('un-transformed-emoticon');}, opts.delay);
112
+ }
113
+ });
114
+ }
115
+
116
+ $.fn.unemoticonize = function(options) {
117
+ var opts = $.extend({}, $.fn.emoticonize.defaults, options);
118
+ return this.each(function() {
119
+ var container = $(this);
120
+ container.find('span.css-emoticon').each(function(){
121
+ // add delay equal to animate speed if animate is not false
122
+ var span = $(this);
123
+ if(opts.animate){
124
+ span.addClass('un-transformed-emoticon');
125
+ setTimeout(function(){span.replaceWith(span.text());}, opts.delay);
126
+ }else{
127
+ span.replaceWith(span.text());
128
+ }
129
+ });
130
+ });
131
+ }
132
+
133
+ $.fn.emoticonize.defaults = {animate: true, delay: 500, exclude: 'pre,code,.no-emoticons'}
134
+ })(jQuery);
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jquery-cssemoticons-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kainage
@@ -52,7 +52,7 @@ files:
52
52
  - jquery-cssemoticons-rails.gemspec
53
53
  - lib/jquery-cssemoticons-rails.rb
54
54
  - lib/jquery-cssemoticons-rails/version.rb
55
- - vendor/assets/javascripts/jquery.cssemoticons.min.js
55
+ - vendor/assets/javascripts/jquery.cssemoticons.js
56
56
  - vendor/assets/stylesheets/jquery.cssemoticons.css
57
57
  homepage: http://github.com/kainage/jquery-cssemoticons-rails
58
58
  licenses: []
@@ -1,11 +0,0 @@
1
- /*
2
- * jQuery CSSEmoticons plugin 0.2.9
3
- *
4
- * Copyright (c) 2010 Steve Schwartz (JangoSteve)
5
- *
6
- * Dual licensed under the MIT and GPL licenses:
7
- * http://www.opensource.org/licenses/mit-license.php
8
- * http://www.gnu.org/licenses/gpl.html
9
- *
10
- * Date: Sun Oct 22 1:00:00 2010 -0500
11
- */(function(a){a.fn.emoticonize=function(m){var c=a.extend({},a.fn.emoticonize.defaults,m);var d=[")","(","*","[","]","{","}","|","^","<",">","\\","?","+","=","."];var l=[":-)",":o)",":c)",":^)",":-D",":-(",":-9",";-)",":-P",":-p",":-Þ",":-b",":-O",":-/",":-X",":-#",":'(","B-)","8-)",";*(",":-*",":-\\","?-)",": )",": ]","= ]","= )","8 )",": }",": D","8 D","X D","x D","= D",": (",": [",": {","= (","; )","; ]","; D",": P",": p","= P","= p",": b",": Þ",": O","8 O",": /","= /",": S",": #",": X","B )",": |",": \\","= \\",": *",": &gt;",": &lt;"];var j=[":)",":]","=]","=)","8)",":}",":D",":(",":[",":{","=(",";)",";]",";D",":P",":p","=P","=p",":b",":Þ",":O",":/","=/",":S",":#",":X","B)",":|",":\\","=\\",":*",":&gt;",":&lt;"];var h={"&gt;:)":{cssClass:"red-emoticon small-emoticon spaced-emoticon"},"&gt;;)":{cssClass:"red-emoticon small-emoticon spaced-emoticon"},"&gt;:(":{cssClass:"red-emoticon small-emoticon spaced-emoticon"},"&gt;: )":{cssClass:"red-emoticon small-emoticon"},"&gt;; )":{cssClass:"red-emoticon small-emoticon"},"&gt;: (":{cssClass:"red-emoticon small-emoticon"},";(":{cssClass:"red-emoticon spaced-emoticon"},"&lt;3":{cssClass:"pink-emoticon counter-rotated"},O_O:{cssClass:"no-rotate"},o_o:{cssClass:"no-rotate"},"0_o":{cssClass:"no-rotate"},O_o:{cssClass:"no-rotate"},T_T:{cssClass:"no-rotate"},"^_^":{cssClass:"no-rotate"},"O:)":{cssClass:"small-emoticon spaced-emoticon"},"O: )":{cssClass:"small-emoticon"},"8D":{cssClass:"small-emoticon spaced-emoticon"},XD:{cssClass:"small-emoticon spaced-emoticon"},xD:{cssClass:"small-emoticon spaced-emoticon"},"=D":{cssClass:"small-emoticon spaced-emoticon"},"8O":{cssClass:"small-emoticon spaced-emoticon"},"[+=..]":{cssClass:"no-rotate nintendo-controller"}};var f=new RegExp("(\\"+d.join("|\\")+")","g");var n="(^|[\\s\\0])";for(var g=l.length-1;g>=0;--g){l[g]=l[g].replace(f,"\\$1");l[g]=new RegExp(n+"("+l[g]+")","g")}for(var g=j.length-1;g>=0;--g){j[g]=j[g].replace(f,"\\$1");j[g]=new RegExp(n+"("+j[g]+")","g")}for(var k in h){h[k].regexp=k.replace(f,"\\$1");h[k].regexp=new RegExp(n+"("+h[k].regexp+")","g")}var e="span.css-emoticon";if(c.exclude){e+=","+c.exclude}var b=e.split(",");return this.not(e).each(function(){var o=a(this);var i="css-emoticon";if(c.animate){i+=" un-transformed-emoticon animated-emoticon"}for(var p in h){specialCssClass=i+" "+h[p].cssClass;o.html(o.html().replace(h[p].regexp,"$1<span class='"+specialCssClass+"'>$2</span>"))}a(l).each(function(){o.html(o.html().replace(this,"$1<span class='"+i+"'>$2</span>"))});a(j).each(function(){o.html(o.html().replace(this,"$1<span class='"+i+" spaced-emoticon'>$2</span>"))});a.each(b,function(q,r){o.find(a.trim(r)+" span.css-emoticon").each(function(){a(this).replaceWith(a(this).text())})});if(c.animate){setTimeout(function(){a(".un-transformed-emoticon").removeClass("un-transformed-emoticon")},c.delay)}})};a.fn.unemoticonize=function(b){var c=a.extend({},a.fn.emoticonize.defaults,b);return this.each(function(){var d=a(this);d.find("span.css-emoticon").each(function(){var e=a(this);if(c.animate){e.addClass("un-transformed-emoticon");setTimeout(function(){e.replaceWith(e.text())},c.delay)}else{e.replaceWith(e.text())}})})};a.fn.emoticonize.defaults={animate:true,delay:500,exclude:"pre,code,.no-emoticons"}})(jQuery);