1/* 2 * jQuery Fancylike plugin 3 * @version: 0.0.7 4 * @release: 2013-08-19 5 * 6 * Copyright 2013, Tiziano Treccani<[email protected]> 7 * Copyright 2015, Evgeniy Fitsner<[email protected]> 8 * Dual licensed under the LGPL Version 3 license. 9*/ 10(function( $ ) { 11 12 var transformLikeButton = function(likeButton, opts){ 13 14 var likeButtonWidth = likeButton.width(); 15 var likeButtonHeight = likeButton.height(); 16 var numX = Math.ceil(likeButtonWidth / $.fn.fancylike.defaults.fb_like_width); 17 var numY = Math.ceil(likeButtonHeight / $.fn.fancylike.defaults.fb_like_height); 18 var numTot = numX * numY; 19 20 // css normalization 21 likeButton.css({ 22 "overflow": "hidden", 23 "padding" : "0" 24 }); 25 26 var params = { 27 "href" : opts.page_url, 28 "width" : opts.fb_like_width, 29 "height" : opts.fb_like_height, 30 "colorscheme" : "light", 31 "layout" : "button", 32 "action" : "like", 33 "show_faces" : "false", 34 "send" : "false", 35 "appId" : "131787130251431" 36 }; 37 38 var fbLikeIframe = $("<iframe/>").attr({ 39 "src" : opts.fb_like_url + "?" + $.param(params), 40 "frameborder": "no" 41 }).css({ 42 "border": "none", 43 "width" : Math.floor(likeButtonWidth / numX), 44 "height" : Math.floor(likeButtonHeight / numY), 45 "-ms-filter" : "progid:DXImageTransform.Microsoft.Alpha(Opacity=100)", 46 "filter" : "alpha(opacity=100)", 47 "opacity": "0" 48 }); 49 50 // fill space inside div 51 for(var i = 0; i < numTot; i++){ 52 likeButton.append(fbLikeIframe.clone()); 53 } 54 }; 55 56 $.fn.fancylike = function(options) { 57 58 var self = $(this); 59 60 var opts = $.extend( {}, $.fn.fancylike.defaults, options); 61 62 self.each(function(){ 63 64 var likeButton = $(this); 65 66 var likeButtonWidth = likeButton.width(); 67 var likeButtonHeight = likeButton.height(); 68 var numX = Math.ceil(likeButtonWidth / opts.fb_like_width); 69 var numY = Math.ceil(likeButtonHeight / opts.fb_like_height); 70 var numTot = numX * numY; 71 72 // replace the img tag with a div 73 if(likeButton.is("img")){ 74 var img = new Image(); 75 img.src = likeButton.attr("src"); 76 img.onload = function(){ 77 78 var wrapper = $("<div/>").css({ 79 "width" : img.width, 80 "height" : img.height, 81 "margin" : likeButton.css("margin"), 82 "display" : "inline-block", 83 "background" : "transparent url('" + img.src + "') center center no-repeat" 84 }); 85 likeButton.after(wrapper); 86 likeButton.remove(); 87 likeButton = wrapper; 88 89 transformLikeButton(likeButton, opts); 90 91 } 92 } 93 else { 94 transformLikeButton(likeButton, opts); 95 } 96 97 }); 98 99 return self; 100 }; 101 102 // Plugin defaults 103 $.fn.fancylike.defaults = { 104 fb_like_url : "http://www.facebook.com/plugins/like.php", 105 fb_like_height : 20, 106 fb_like_width : 47, 107 page_url : window.location.href 108 }; 109 110}( 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.