Как добавить лайк VK в warp.js ?

Тема в разделе "JavaScript", создана пользователем Spirt51, 5 окт 2014.

Модераторы: ZiX
  1. Spirt51

    Spirt51 Постоялец

    Регистр.:
    3 авг 2009
    Сообщения:
    78
    Симпатии:
    16
    Имеется вот такой вот Код:

    Код:
    /* Copyright (C) YOOtheme GmbH, http://www.gnu.org/licenses/gpl.html GNU/GPL */
    
    (function(e){var g={},a,c=!1,b=document.documentElement,c=b.firstElementChild||b.firstChild,d=document.createElement("div");d.style.cssText="position:absolute;top:-100em;width:1.1px";b.insertBefore(d,c);c=0!==(d.getBoundingClientRect().width||1)%1;b.removeChild(d);c||(b=/msie ([\w.]+)/.exec(navigator.userAgent.toLowerCase()))&&(c=8==parseInt(b[1],10)||9==parseInt(b[1],10));a=c;e.fn.socialButtons=function(a){a=e.extend({wrapper:'<div class="socialbuttons clearfix" />'},a);if(!a.twitter&&!a.plusone&&
    !a.facebook)return this;a.twitter&&!g.twitter&&(g.twitter=e.getScript("//platform.twitter.com/widgets.js"));a.plusone&&!g.plusone&&(g.plusone=e.getScript("//apis.google.com/js/plusone.js"));if(!window.FB&&a.facebook&&!g.facebook){e("body").append('<div id="fb-root"></div>');var b,c=document.getElementsByTagName("script")[0];document.getElementById("facebook-jssdk")||(b=document.createElement("script"),b.id="facebook-jssdk",b.src="//connect.facebook.net/en_US/all.js#xfbml=1",c.parentNode.insertBefore(b,
    c));g.facebook=!0}return this.each(function(){var b=e(this).data("permalink"),c=e(a.wrapper).appendTo(this);a.twitter&&c.append('<div><a href="http://twitter.com/share" class="twitter-share-button" data-url="'+b+'" data-count="none">Tweet</a></div>');a.plusone&&c.append('<div><div class="g-plusone" data-size="medium" data-annotation="none" data-href="'+b+'"></div></div>');a.facebook&&c.append('<div><div class="fb-like" data-href="'+b+'" data-send="false" data-layout="button_count" data-width="100" data-show-faces="false"></div></div>')})};
    var f={};e.matchHeight=function(a,b,c){var d=e(window),g=a&&f[a];if(!g){var g=f[a]={id:a,elements:b,deepest:c,match:function(){var a=this.revert(),b=0;e(this.elements).each(function(){b=Math.max(b,e(this).outerHeight())}).each(function(c){var d="outerHeight";"border-box"==a[c].css("box-sizing")&&(d="height");var f=e(this),c=a[c],d=c.height()+(b-f[d]());c.css("min-height",d+"px")})},revert:function(){var a=[],b=this.deepest;e(this.elements).each(function(){var c=b?e(this).find(b+":first"):e(this);
    a.push(c.css("min-height",""))});return a},remove:function(){d.unbind("resize orientationchange",i);this.revert();delete f[this.id]}},i=function(){g.match()};d.bind("resize orientationchange",i)}return g};e.matchWidth=function(b,c,d){var g=e(window),j=b&&f[b];if(!j){if(a)return f[b]={match:function(){},revert:function(){},remove:function(){}},f[b];var j=f[b]={id:b,elements:c,selector:d,match:function(){this.revert();e(this.elements).each(function(){var a=e(this),b=a.width(),c=a.children(d),f=0;c.each(function(a){a<
    c.length-1?f+=e(this).width():e(this).width(b-f)})})},revert:function(){e(c).children(d).css("width","")},remove:function(){g.unbind("resize orientationchange",i);this.revert();delete f[this.id]}},i=function(){j.match()};g.bind("resize orientationchange",i)}return j};e.fn.matchHeight=function(a){var b=0,c=[];this.each(function(){var b=a?e(this).find(a+":first"):e(this);c.push(b);b.css("min-height","")});this.each(function(){b=Math.max(b,e(this).outerHeight())});return this.each(function(a){var d=
    e(this),a=c[a],d=a.height()+(b-d.outerHeight());a.css("min-height",d+"px")})};e.fn.matchWidth=function(a){return this.each(function(){var b=e(this),c=b.children(a),d=0;c.width(function(a,f){return a<c.length-1?(d+=f,f):b.width()-d})})};e.fn.smoothScroller=function(a){a=e.extend({duration:1E3,transition:"easeOutExpo"},a);return this.each(function(){e(this).bind("click",function(){var b=this.hash,c=e(this.hash).offset().top;if(window.location.href.replace(window.location.hash,"")+b==this)return e("html:not(:animated),body:not(:animated)").animate({scrollTop:c},
    a.duration,a.transition,function(){window.location.hash=b.replace("#","")}),!1})})}})(jQuery);
    (function(e){e.easing.jswing=e.easing.swing;e.extend(e.easing,{def:"easeOutQuad",swing:function(g,a,c,b,d){return e.easing[e.easing.def](g,a,c,b,d)},easeInQuad:function(g,a,c,b,d){return b*(a/=d)*a+c},easeOutQuad:function(g,a,c,b,d){return-b*(a/=d)*(a-2)+c},easeInOutQuad:function(g,a,c,b,d){return 1>(a/=d/2)?b/2*a*a+c:-b/2*(--a*(a-2)-1)+c},easeInCubic:function(g,a,c,b,d){return b*(a/=d)*a*a+c},easeOutCubic:function(g,a,c,b,d){return b*((a=a/d-1)*a*a+1)+c},easeInOutCubic:function(g,a,c,b,d){return 1>
    (a/=d/2)?b/2*a*a*a+c:b/2*((a-=2)*a*a+2)+c},easeInQuart:function(g,a,c,b,d){return b*(a/=d)*a*a*a+c},easeOutQuart:function(g,a,c,b,d){return-b*((a=a/d-1)*a*a*a-1)+c},easeInOutQuart:function(g,a,c,b,d){return 1>(a/=d/2)?b/2*a*a*a*a+c:-b/2*((a-=2)*a*a*a-2)+c},easeInQuint:function(g,a,c,b,d){return b*(a/=d)*a*a*a*a+c},easeOutQuint:function(g,a,c,b,d){return b*((a=a/d-1)*a*a*a*a+1)+c},easeInOutQuint:function(g,a,c,b,d){return 1>(a/=d/2)?b/2*a*a*a*a*a+c:b/2*((a-=2)*a*a*a*a+2)+c},easeInSine:function(g,a,
    c,b,d){return-b*Math.cos(a/d*(Math.PI/2))+b+c},easeOutSine:function(g,a,c,b,d){return b*Math.sin(a/d*(Math.PI/2))+c},easeInOutSine:function(g,a,c,b,d){return-b/2*(Math.cos(Math.PI*a/d)-1)+c},easeInExpo:function(g,a,c,b,d){return 0==a?c:b*Math.pow(2,10*(a/d-1))+c},easeOutExpo:function(g,a,c,b,d){return a==d?c+b:b*(-Math.pow(2,-10*a/d)+1)+c},easeInOutExpo:function(g,a,c,b,d){return 0==a?c:a==d?c+b:1>(a/=d/2)?b/2*Math.pow(2,10*(a-1))+c:b/2*(-Math.pow(2,-10*--a)+2)+c},easeInCirc:function(g,a,c,b,d){return-b*
    (Math.sqrt(1-(a/=d)*a)-1)+c},easeOutCirc:function(g,a,c,b,d){return b*Math.sqrt(1-(a=a/d-1)*a)+c},easeInOutCirc:function(g,a,c,b,d){return 1>(a/=d/2)?-b/2*(Math.sqrt(1-a*a)-1)+c:b/2*(Math.sqrt(1-(a-=2)*a)+1)+c},easeInElastic:function(g,a,c,b,d){var g=1.70158,f=0,e=b;if(0==a)return c;if(1==(a/=d))return c+b;f||(f=0.3*d);e<Math.abs(b)?(e=b,g=f/4):g=f/(2*Math.PI)*Math.asin(b/e);return-(e*Math.pow(2,10*(a-=1))*Math.sin((a*d-g)*2*Math.PI/f))+c},easeOutElastic:function(g,a,c,b,d){var g=1.70158,f=0,e=b;
    if(0==a)return c;if(1==(a/=d))return c+b;f||(f=0.3*d);e<Math.abs(b)?(e=b,g=f/4):g=f/(2*Math.PI)*Math.asin(b/e);return e*Math.pow(2,-10*a)*Math.sin((a*d-g)*2*Math.PI/f)+b+c},easeInOutElastic:function(e,a,c,b,d){var e=1.70158,f=0,h=b;if(0==a)return c;if(2==(a/=d/2))return c+b;f||(f=d*0.3*1.5);h<Math.abs(b)?(h=b,e=f/4):e=f/(2*Math.PI)*Math.asin(b/h);return 1>a?-0.5*h*Math.pow(2,10*(a-=1))*Math.sin((a*d-e)*2*Math.PI/f)+c:0.5*h*Math.pow(2,-10*(a-=1))*Math.sin((a*d-e)*2*Math.PI/f)+b+c},easeInBack:function(e,
    a,c,b,d,f){void 0==f&&(f=1.70158);return b*(a/=d)*a*((f+1)*a-f)+c},easeOutBack:function(e,a,c,b,d,f){void 0==f&&(f=1.70158);return b*((a=a/d-1)*a*((f+1)*a+f)+1)+c},easeInOutBack:function(e,a,c,b,d,f){void 0==f&&(f=1.70158);return 1>(a/=d/2)?b/2*a*a*(((f*=1.525)+1)*a-f)+c:b/2*((a-=2)*a*(((f*=1.525)+1)*a+f)+2)+c},easeInBounce:function(g,a,c,b,d){return b-e.easing.easeOutBounce(g,d-a,0,b,d)+c},easeOutBounce:function(e,a,c,b,d){return(a/=d)<1/2.75?b*7.5625*a*a+c:a<2/2.75?b*(7.5625*(a-=1.5/2.75)*a+0.75)+
    c:a<2.5/2.75?b*(7.5625*(a-=2.25/2.75)*a+0.9375)+c:b*(7.5625*(a-=2.625/2.75)*a+0.984375)+c},easeInOutBounce:function(g,a,c,b,d){return a<d/2?0.5*e.easing.easeInBounce(g,2*a,0,b,d)+c:0.5*e.easing.easeOutBounce(g,2*a-d,0,b,d)+0.5*b+c}})})(jQuery);
    (function(e){function g(a){var b={},c=/^jQuery\d+$/;e.each(a.attributes,function(a,d){d.specified&&!c.test(d.name)&&(b[d.name]=d.value)});return b}function a(){var a=e(this);a.val()===a.attr("placeholder")&&a.hasClass("placeholder")&&(a.data("placeholder-password")?a.hide().next().show().focus():a.val("").removeClass("placeholder"))}function c(){var b,c=e(this);if(""===c.val()||c.val()===c.attr("placeholder")){if(c.is(":password")){if(!c.data("placeholder-textinput")){try{b=c.clone().attr({type:"text"})}catch(d){b=
    e("<input>").attr(e.extend(g(c[0]),{type:"text"}))}b.removeAttr("name").data("placeholder-password",!0).bind("focus.placeholder",a);c.data("placeholder-textinput",b).before(b)}c=c.hide().prev().show()}c.addClass("placeholder").val(c.attr("placeholder"))}else c.removeClass("placeholder")}var b="placeholder"in document.createElement("input"),d="placeholder"in document.createElement("textarea");e.fn.placeholder=b&&d?function(){return this}:function(){return this.filter((b?"textarea":":input")+"[placeholder]").bind("focus.placeholder",
    a).bind("blur.placeholder",c).trigger("blur.placeholder").end()};e(function(){e("form").bind("submit.placeholder",function(){var b=e(".placeholder",this).each(a);setTimeout(function(){b.each(c)},10)})});e(window).bind("unload.placeholder",function(){e(".placeholder").val("")})})(jQuery);
    
    Помогите пожалуйста пихнуть сюда лайк VK с счётчиком лайков.
    В JS не дум-дум.
     
  2. Andersol

    Andersol Постоялец

    Регистр.:
    1 окт 2012
    Сообщения:
    55
    Симпатии:
    28
  3. Spirt51

    Spirt51 Постоялец

    Регистр.:
    3 авг 2009
    Сообщения:
    78
    Симпатии:
    16
    А смысл отдельно? Все соц закладки нормально в ряд, а VK где-то сбоку получиться.
     
  4. Aglok

    Aglok ∞³

    Регистр.:
    9 янв 2012
    Сообщения:
    160
    Симпатии:
    46
    Найди функцию e.fn.socialButtons = function(a){}; и замени полностью на приведённый ниже код. Только тебе еще нужно будет вставить в коде номер своего apiId.
    Код:
        
         e.fn.socialButtons = function(a) {
            var user_id = 112334;//Свой номер api id
            a = e.extend({
                wrapper: '<div class="socialbuttons clearfix" />'
            }, a);
            if (!a.twitter && !a.plusone &&
                !a.facebook && !a.vk) return this;
            a.twitter && !g.twitter && (g.twitter = e.getScript("//platform.twitter.com/widgets.js"));
            a.plusone && !g.plusone && (g.plusone = e.getScript("//apis.google.com/js/plusone.js"));
            a.vk && !g.vk && (
                g.vk = e.getScript("//vk.com/js/api/openapi.js?115"),
                e("head").append('<script>VK.init({apiId: '+user_id+', onlyWidgets: true});</script>')
            );
            if (!window.FB && a.facebook && !g.facebook) {
                e("body").append('<div id="fb-root"></div>');
                var b, c = document.getElementsByTagName("script")[0];
                document.getElementById("facebook-jssdk") || (b = document.createElement("script"), b.id = "facebook-jssdk", b.src = "//connect.facebook.net/en_US/all.js#xfbml=1", c.parentNode.insertBefore(b,
                    c));
                g.facebook = !0
            }
    
            return this.each(function() {
                var b = e(this).data("permalink"),
                    c = e(a.wrapper).appendTo(this);
                a.twitter && c.append('<div><a href="http://twitter.com/share" class="twitter-share-button" data-url="' + b + '" data-count="none">Tweet</a></div>');
                a.plusone && c.append('<div><div class="g-plusone" data-size="medium" data-annotation="none" data-href="' + b + '"></div></div>');
                a.facebook && c.append('<div><div class="fb-like" data-href="' + b + '" data-send="false" data-layout="button_count" data-width="100" data-show-faces="false"></div></div>')
                a.vk && c.append('<div id="vk_like"></div><script type="text/javascript">VK.Widgets.Like("vk_like", {type: "button"});</script>')
            })
        };