WordPress.org

Ready to get started?Download WordPress

Forums

WP Socializer
Pinterest - Button does not popup, it takes current tab/window (My Fix) (2 posts)

  1. alegadpen
    Member
    Posted 2 years ago #

    Howdy! I noticed that when you click the pinterest button it does not open a popup, but takes the whole current tab/window to display the pin it functionality.
    However, I made this work! =) YAY!!
    Case: Template Tags
    I wrapped the button template tag code into a div which has a class .social-button-pinit, now in a jQuery/javascript init file (ya know, the one that you place all your custom jquery code) i inserted this...

    $j(".social-button-pinit").click(function(){
         var pinitlink = $(this).find("a").attr("href");
    		 window.open(pinitlink, 'Pinterest', 'width=600,height=280,scrollbars=no,toolbar=no,location=no,menubar=no');
         	return false;
    		});

    And now you can see the button working like a charm!!
    The site I made this fix: Vidal
    Follow me on Twitter: @alegadpen

    http://wordpress.org/extend/plugins/wp-socializer/

  2. stevelacey
    Member
    Posted 2 years ago #

    I doubt this is appropriate here considering the button code provided by Pinterest doesn't open in a popup, regardless, made a slight improvement to your code for my own uses, slightly more efficient selector (no need to wrap in div), closure, and popup opens in center of window.

    $('.pin-it-button').click(function (e) {
      (function (url, title, w, h) {
        var left = (screen.width/2)-(w/2);
        var top = (screen.height/2)-(h/2);
        return window.open(url, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width='+w+', height='+h+', top='+top+', left='+left);
      })($(this).attr('href'), 'Pinterest', 600, 280);
    
      e.preventDefault();
    });

    Also note: Don't use return false to preventDefault action, that will also prevent event bubbling in jQuery and could potentially break other things.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic