1/*! 2 @package Facebook-Reactions-JS - A jQuery Plugin to generate Facebook Style Reactions. 3 @version version: 1.0 4 @developer github: https://github.com/99points/Facebook-Reactions-JS 5 6 @developed by: Zeeshan Rasool. [Founder @ http://www.99points.info & http://wallscriptclone.com] 7 8 @license Licensed under the MIT licenses: http://www.opensource.org/licenses/mit-license.php 9*/ 10(function($) { 11 12 $.fn.facebookReactions = function(options) { 13 14 var settings = $.extend({ 15 16 postUrl: false, // once user will select an emoji, lets save this selection via ajax to DB. 17 defaultText: "Ãrtékelések", // default text for button 18 postID: null 19 20 }, options); 21 22 var emoji_value; 23 24 var postOwner = this.selector.replace("#", ""); 25 26 var _react_html = '<div style="position:absolute; z-index: 1;" class="fbreactdiv _bar" data-status="hidden"><div class="_inner">'; 27 28 var faces = '<img src="/static/images/emojis/zorba.svg" title="Zorba" class="emojireact emojireact-'+postOwner+'" data-emoji-value="Zorba" style="" />'; 29 30 faces = faces + '<img src="/static/images/emojis/buddha.svg" title="Buddha" class="emojireact emojireact-'+postOwner+'" data-emoji-value="Buddha" style="" />'; 31 32 faces = faces + '<img src="/static/images/emojis/harcos.svg" title="Harcos" class="emojireact emojireact-'+postOwner+'" data-emoji-value="Harcos" style="" />'; 33 34 _react_html = _react_html + faces; 35 36 _react_html = _react_html + '<br clear="all" /></div></div>'; 37 38 if (!$(".fbreactdiv").length) { 39 $(_react_html).appendTo($('body')); 40 } 41 42 var _bar = $('._bar'); 43 var _inner = $('._inner'); 44 45 // on click emotions 46 $('.emojireact-'+postOwner).on("click", function(e) { 47 48 if (e.target !== e.currentTarget) return; 49 50 var base = $(this).parent().parent().parent(); 51 var move_emoji = $(this); 52 53 // on complete reaction 54 emoji_value = move_emoji.data('emoji-value'); 55 56 // $(this.selector).css("background", "url(../../images/emojis/"+emoji_value.toLowerCase()+".svg)"); 57 58 $('#fb-react-'+base.attr("data-unique-id")).css({"background-image": "url(/static/images/emojis/"+emoji_value.toLowerCase()+".svg)"}); 59 60 if (move_emoji) { 61 62 var cloneemoji = move_emoji.clone().offset({ 63 top: move_emoji.offset().top, 64 left: move_emoji.offset().left 65 }).css({ 66 'height': '40px', 67 'width': '40px', 68 'opacity': '0.9', 69 'position': 'absolute', 70 'z-index': '99' 71 }).appendTo($('body')).animate({ 72 'top': base.offset().top + 5, 73 'left': base.offset().left + 10, 74 'width': 30, 75 'height': 30 76 }, 300, 'easeInBack'); 77 78 cloneemoji.animate({ 79 'width': 27, 80 'height': 27 81 }, 100, function() { 82 83 var _imgicon = $(this); 84 85 _imgicon.fadeOut(100, function() { 86 _imgicon.detach(); 87 // add icon class 88 base.attr("data-emoji-class", emoji_value); 89 // change text 90 base.find('span').html(emoji_value); 91 92 if (settings.postUrl) { 93 94 __ajax(base.attr("data-unique-id"), emoji_value); 95 } 96 }); 97 }); 98 } 99 100 return false; 101 }); 102 103 // ajax 104 function __ajax(control_id, value) { 105 106 // here we have control id and value. We need to save them into db. You can change it according to yours requirements. 107 var formData = "control_id=" + control_id + "&value=" + value; 108 109 $.ajax({ 110 type: 'POST', // define the type of HTTP verb we want to use (POST for our form) 111 url: settings.postUrl, // the url where we want to POST 112 data: formData, // our data object 113 success: function(data) { 114 115 // nothing requires here but you can add something here. 116 }, 117 error: function() { 118 119 alert('<p>An error has occurred</p>'); 120 } 121 }); 122 } 123 124 return this.each(function() { 125 126 var _this = $(this); 127 window.tmr; 128 window.selector = _this.get(0).className; 129 130 // $(this).find('span').click(function(e) { 131 // 132 // if (e.target !== e.currentTarget) return; 133 // var isLiked = $(this).parent().attr("data-emoji-class"); 134 // var control_id = $(this).parent().attr("data-unique-id"); 135 //
136 // $(this).html(settings.defaultText); 137 // 138 // if (isLiked) { 139 // $(this).parent().attr("data-emoji-class", ""); 140 // 141 // if (settings.postUrl) 142 // __ajax(control_id, null); 143 // } else { 144 // $(this).parent().attr("data-emoji-class", "like"); 145 // 146 // if (settings.postUrl) 147 // __ajax(control_id, "like"); 148 // } 149 // }); 150 151 $(this).hover(function() { 152 153 if ($(this).hasClass("emoji")) { 154 return false; 155 } 156 157 if ($(this).hasClass("open") === true) { 158 clearTimeout(window.tmr); 159 return false; 160 } 161 162 $('.' + window.selector).each(function() { 163 164 __hide(this); 165 }); 166 167 if (_bar.attr('data-status') != 'active') { 168 169 __show(this); 170 } 171 }, function() { 172 var _this = this; 173 174 window.tmr = setTimeout(function() { 175 176 __hide(_this); 177 178 }, 1000); 179 }); 180 181 // functions 182 function __hide(_this) { 183 184 _bar.attr('data-status', 'hidden'); 185 186 _bar.hide(); 187 188 $('.open').removeClass("open"); 189 190 _inner.removeClass('ov_visi'); 191 } 192 193 function __show(_this) { 194 195 clearTimeout(window.tmr); 196 197 $(_this).append(_bar.fadeIn()); 198 199 _bar.attr('data-status', 'active'); 200 201 _inner.addClass('ov_visi'); 202 203 $(_this).addClass("open"); 204 205 // vertical or horizontal 206 var position = $(_this).data('reactions-type'); 207 208 if (position == 'horizontal') { 209 _inner.css('width', '120px'); 210 // Set main bar position top: -50px; left:0px; 211 _bar.css({ 212 'top': '-50px', 213 'left': '0px', 214 'right': 'auto' 215 }); 216 } else { 217 _inner.css('width', '41px'); 218 _bar.css({ 219 'top': '-6px', 220 'right': '-48px', 221 'left': 'auto' 222 }); 223 } 224 } 225 }); 226 }; 227 228})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.