jQuery Pin It Button for Images - Version 1.21

Version Description

  • Released 2014-02-22
  • Fixed one issue from the previous release
Download this release

Release Info

Developer mrsztuczkens
Plugin Icon wp plugin jQuery Pin It Button for Images
Version 1.21
Comparing to
See all releases

Code changes from version 1.20 to 1.21

jquery-pin-it-button-for-images.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: jQuery Pin It Button For Images
4
  Plugin URI: http://mrsztuczkens.me/jpibfi/
5
  Description: Highlights images on hover and adds a "Pin It" button over them for easy pinning.
6
  Author: Marcin Skrzypiec
7
- Version: 1.20
8
  Author URI: http://mrsztuczkens.me/
9
  */
10
 
@@ -18,7 +18,7 @@ if ( ! function_exists( 'add_action' ) ) {
18
  * CONSTANTS
19
  *
20
  */
21
- define( "JPIBFI_VERSION", "1.20" );
22
  define( "JPIBFI_VERSION_MINOR", "a" );
23
  define( "JPIBFI_METADATA", "jpibfi_meta" );
24
  define( "JPIBFI_UPDATE_OPTIONS", "jpibfi_update_options");
4
  Plugin URI: http://mrsztuczkens.me/jpibfi/
5
  Description: Highlights images on hover and adds a "Pin It" button over them for easy pinning.
6
  Author: Marcin Skrzypiec
7
+ Version: 1.21
8
  Author URI: http://mrsztuczkens.me/
9
  */
10
 
18
  * CONSTANTS
19
  *
20
  */
21
+ define( "JPIBFI_VERSION", "1.21" );
22
  define( "JPIBFI_VERSION_MINOR", "a" );
23
  define( "JPIBFI_METADATA", "jpibfi_meta" );
24
  define( "JPIBFI_UPDATE_OPTIONS", "jpibfi_update_options");
js/script.js CHANGED
@@ -36,23 +36,26 @@
36
  .not( '[data-jpibfi-indexer]' )
37
  .filter( filterSelector );
38
 
39
- $elements.each( function () { $( this ).attr('data-jpibfi-indexer', imageMaxIndex); imageMaxIndex++; } );
 
 
 
40
  jpibfiLog( 'Images caught by selectors: ' + imageMaxIndex );
41
  return $elements;
42
  };
43
 
44
  jpibfi.prepareImages = function ( $elements ) {
45
  jpibfiLog( '>>Add Elements' );
46
-
 
 
47
  var imageCount = 0;
48
  $elements.each(function () {
49
  var $image = $(this);
50
-
51
  if ( this.clientWidth < settings.minImageWidth || this.clientHeight < settings.minImageHeight ) {
52
  $image.removeAttr( 'data-jpibfi-indexer' );
53
  return;
54
  }
55
-
56
  if ( settings.mode == 'static' )
57
  jpibfiCreateAndShowOverlayDiv( $image, settings.buttonPosition );
58
 
@@ -350,9 +353,11 @@
350
  $(document).ready( function() {
351
  jpibfi.init( jpibfi_options );
352
 
353
- var $elements = jpibfi.addImages( jpibfi_options.image_selector );
354
 
355
- $(window).load( jpibfi.prepareImages( $elements ) );
 
 
356
 
357
  $(window).resize ( function() {
358
  jpibfi.removeAllImages();
36
  .not( '[data-jpibfi-indexer]' )
37
  .filter( filterSelector );
38
 
39
+ $elements.each( function () {
40
+ $( this ).attr('data-jpibfi-indexer', imageMaxIndex);
41
+ imageMaxIndex++;
42
+ });
43
  jpibfiLog( 'Images caught by selectors: ' + imageMaxIndex );
44
  return $elements;
45
  };
46
 
47
  jpibfi.prepareImages = function ( $elements ) {
48
  jpibfiLog( '>>Add Elements' );
49
+ jpibfiLog( 'Elements: ' + $elements.length );
50
+ jpibfiLog( 'Min width:' + settings.minImageWidth);
51
+ jpibfiLog( 'Min height:' + settings.minImageHeight);
52
  var imageCount = 0;
53
  $elements.each(function () {
54
  var $image = $(this);
 
55
  if ( this.clientWidth < settings.minImageWidth || this.clientHeight < settings.minImageHeight ) {
56
  $image.removeAttr( 'data-jpibfi-indexer' );
57
  return;
58
  }
 
59
  if ( settings.mode == 'static' )
60
  jpibfiCreateAndShowOverlayDiv( $image, settings.buttonPosition );
61
 
353
  $(document).ready( function() {
354
  jpibfi.init( jpibfi_options );
355
 
356
+ jpibfi.addImages( jpibfi_options.image_selector );
357
 
358
+ $(window).load( function() {
359
+ jpibfi.prepareImages( $('img[data-jpibfi-indexer]') );
360
+ });
361
 
362
  $(window).resize ( function() {
363
  jpibfi.removeAllImages();
js/script.min.js CHANGED
@@ -1 +1 @@
1
- (function(e){"use strict";window.jpibfi=function(){function f(t){var r=jQuery("<a/>",{href:"#","class":"pinit-button","data-jpibfi-indexer":t,text:"Pin It"});r.click(function(t){d("Pin In button clicked");var r=e(this).data("jpibfi-indexer");var i=e('img[data-jpibfi-indexer="'+r+'"]');var s="",o="",u="";if(n.usePostUrl){var f=i.closest("div.jpibfi_container").find("input.jpibfi").first();if(f.length){o=f.data("jpibfi-description");u=f.data("jpibfi-url")}}u=u||n.pageUrl;if(n.descriptionOption==3)s=i.attr("title")||i.attr("alt");else if(n.descriptionOption==2)s=o||n.pageDescription;else if(n.descriptionOption==4)s=n.siteTitle;else if(n.descriptionOption==5)s=i.data("jpibfi-description");s=s||o||n.pageTitle;var l="http://pinterest.com/pin/create/bookmarklet/?is_video="+encodeURIComponent("false")+"&url="+encodeURIComponent(u)+"&media="+encodeURIComponent(a.fn.getImageUrl(i))+"&description="+encodeURIComponent(s);window.open(l,"Pinterest","width=632,height=253,status=0,toolbar=0,menubar=0,location=1,scrollbars=1");return false});return r}function l(e,t){var n=e.offset();var r=c(e,t);e.after(r);r.css({height:e.get(0).clientHeight+"px",width:e.get(0).clientWidth+"px"}).show().offset({left:n.left,top:n.top});return r}function c(e,t){var n=e.data("jpibfi-indexer");return jQuery("<div/>",{"class":"pinit-overlay","data-jpibfi-indexer":n,title:e.attr("title")||"",html:f(n).addClass(h(t))})}function h(e){switch(e){case"0":return"pinit-top-left";case"1":return"pinit-top-right";case"2":return"pinit-bottom-left";case"3":return"pinit-bottom-right";case"4":return"pinit-middle";default:return""}}function p(e){var t=e.split(";");var n="";for(var r=0;r<t.length;r++){if(t[r])n+="."+t[r]+","}if(n)n=n.substr(0,n.length-1);return n}function d(e){if(t&&console&&console.log){if("string"==typeof e||e instanceof String){console.log("jpibfi debug: "+e)}else if("object"==typeof e&&typeof JSON!=="undefined"&&typeof JSON.stringify==="function"){console.log("jpibfi debug: "+JSON.stringify(e,null,4))}else if("object"==typeof e){var n="";for(var r in e)n+=r+": "+e[r]+"\n";console.log("jpibfi debug: "+n)}}}var t=false;var n={};var r={};var i={};var s="";var o="*";var u=0;var a={};a.fn={};a.fn.getImageUrl=function(e){return e.data("media")||e.attr("src")};a.addImages=function(t){d(">>addImages");var n=e(t).not(s).not("[data-jpibfi-indexer]").filter(o);n.each(function(){e(this).attr("data-jpibfi-indexer",u);u++});d("Images caught by selectors: "+u);return n};a.prepareImages=function(t){d(">>Add Elements");var r=0;t.each(function(){var t=e(this);if(this.clientWidth<n.minImageWidth||this.clientHeight<n.minImageHeight){t.removeAttr("data-jpibfi-indexer");return}if(n.mode=="static")l(t,n.buttonPosition);r++});d("Images caught after filtering: "+r)};a.removeAllImages=function(){d("Remove Elements called");e("div.pinit-overlay").remove()};a.init=function(u){n={pageUrl:document.URL,pageTitle:document.title,pageDescription:e('meta[name="description"]').attr("content")||"",siteTitle:u.site_title,disabledClasses:u.disabled_classes,enabledClasses:u.enabled_classes,descriptionOption:u.description_option,usePostUrl:u.use_post_url=="1",minImageHeight:u.min_image_height,minImageWidth:u.min_image_width,mode:u.mode,buttonPosition:u.button_position};r={height:parseInt(u.pin_image_height),width:parseInt(u.pin_image_width)};i={top:parseInt(u.button_margin_top),right:parseInt(u.button_margin_right),bottom:parseInt(u.button_margin_bottom),left:parseInt(u.button_margin_left)};t="1"==u.debug;d(n);d(r);d(i);var a=e(".jpibfi").closest("div").addClass("jpibfi_container");d("Number of containers added: "+a.length);s=p(n.disabledClasses);o=p(n.enabledClasses)||"*";d("Filter selector: "+o);d("Not selector: "+s);if("static"==n.mode){d("Adding static mode delegates");e(document).delegate("div.pinit-overlay","hover",function(t){var n=t.type==="mouseenter";var r=e(this).data("jpibfi-indexer");e('.pinit-button[data-jpibfi-indexer="'+r+'"]').toggle(n);e('img[data-jpibfi-indexer="'+r+'"]').toggleClass("pinit-hover",n)})}else if("dynamic"==n.mode){d("Adding dynamic mode delegates");e(document).delegate("a.pinit-button","mouseenter",function(){var t=e(this);clearTimeout(t.data("jpibfi-timeoutId"))});e(document).delegate("a.pinit-button","mouseleave",function(){var t=e(this);var n=setTimeout(function(){t.remove();e('img[data-jpibfi-indexer="'+t.data("jpibfi-indexer")+'"]').removeClass("pinit-hover")},100);t.data("jpibfi-timeoutId",n)});e(document).delegate("img[data-jpibfi-indexer]","mouseenter",function(){var t=e(this);var s=t.data("jpibfi-indexer");var o=e('a.pinit-button[data-jpibfi-indexer="'+s+'"]');if(o.length==0){var o=f(s);var u=t.offset();var a={width:t.get(0).clientWidth,height:t.get(0).clientHeight};switch(n.buttonPosition){case"0":u.left+=i.left;u.top+=i.top;break;case"1":u.top+=i.top;u.left=u.left+a.width-i.right-r.width;break;case"2":u.left+=i.left;u.top=u.top+a.height-i.bottom-r.height;break;case"3":u.left=u.left+a.width-i.right-r.width;u.top=u.top+a.height-i.bottom-r.height;break;case"4":u.left=Math.round(u.left+a.width/2-r.width/2);u.top=Math.round(u.top+a.height/2-r.height/2);break}t.after(o);o.show().offset({left:u.left,top:u.top})}else{clearTimeout(o.data("jpibfi-timeoutId"))}t.addClass("pinit-hover")});e(document).delegate("img[data-jpibfi-indexer]","mouseleave",function(){var t=e(this).data("jpibfi-indexer");var n=e('a.pinit-button[data-jpibfi-indexer="'+t+'"]');var r=setTimeout(function(){n.remove();e('img[data-jpibfi-indexer="'+n.data("jpibfi-indexer")+'"]').removeClass("pinit-hover")},100);n.data("jpibfi-timeoutId",r)})}};return a;}()})(jQuery);(function(e){"use strict";e(document).ready(function(){jpibfi.init(jpibfi_options);var t=jpibfi.addImages(jpibfi_options.image_selector);e(window).load(jpibfi.prepareImages(t));e(window).resize(function(){jpibfi.removeAllImages();jpibfi.prepareImages(e("img[data-jpibfi-indexer]"))})})})(jQuery)
1
+ (function(e){"use strict";window.jpibfi=function(){function f(t){var r=jQuery("<a/>",{href:"#","class":"pinit-button","data-jpibfi-indexer":t,text:"Pin It"});r.click(function(t){d("Pin In button clicked");var r=e(this).data("jpibfi-indexer");var i=e('img[data-jpibfi-indexer="'+r+'"]');var s="",o="",u="";if(n.usePostUrl){var f=i.closest("div.jpibfi_container").find("input.jpibfi").first();if(f.length){o=f.data("jpibfi-description");u=f.data("jpibfi-url")}}u=u||n.pageUrl;if(n.descriptionOption==3)s=i.attr("title")||i.attr("alt");else if(n.descriptionOption==2)s=o||n.pageDescription;else if(n.descriptionOption==4)s=n.siteTitle;else if(n.descriptionOption==5)s=i.data("jpibfi-description");s=s||o||n.pageTitle;var l="http://pinterest.com/pin/create/bookmarklet/?is_video="+encodeURIComponent("false")+"&url="+encodeURIComponent(u)+"&media="+encodeURIComponent(a.fn.getImageUrl(i))+"&description="+encodeURIComponent(s);window.open(l,"Pinterest","width=632,height=253,status=0,toolbar=0,menubar=0,location=1,scrollbars=1");return false});return r}function l(e,t){var n=e.offset();var r=c(e,t);e.after(r);r.css({height:e.get(0).clientHeight+"px",width:e.get(0).clientWidth+"px"}).show().offset({left:n.left,top:n.top});return r}function c(e,t){var n=e.data("jpibfi-indexer");return jQuery("<div/>",{"class":"pinit-overlay","data-jpibfi-indexer":n,title:e.attr("title")||"",html:f(n).addClass(h(t))})}function h(e){switch(e){case"0":return"pinit-top-left";case"1":return"pinit-top-right";case"2":return"pinit-bottom-left";case"3":return"pinit-bottom-right";case"4":return"pinit-middle";default:return""}}function p(e){var t=e.split(";");var n="";for(var r=0;r<t.length;r++){if(t[r])n+="."+t[r]+","}if(n)n=n.substr(0,n.length-1);return n}function d(e){if(t&&console&&console.log){if("string"==typeof e||e instanceof String){console.log("jpibfi debug: "+e)}else if("object"==typeof e&&typeof JSON!=="undefined"&&typeof JSON.stringify==="function"){console.log("jpibfi debug: "+JSON.stringify(e,null,4))}else if("object"==typeof e){var n="";for(var r in e)n+=r+": "+e[r]+"\n";console.log("jpibfi debug: "+n)}}}var t=false;var n={};var r={};var i={};var s="";var o="*";var u=0;var a={};a.fn={};a.fn.getImageUrl=function(e){return e.data("media")||e.attr("src")};a.addImages=function(t){d(">>addImages");var n=e(t).not(s).not("[data-jpibfi-indexer]").filter(o);n.each(function(){e(this).attr("data-jpibfi-indexer",u);u++});d("Images caught by selectors: "+u);return n};a.prepareImages=function(t){d(">>Add Elements");d("Elements: "+t.length);d("Min width:"+n.minImageWidth);d("Min height:"+n.minImageHeight);var r=0;t.each(function(){var t=e(this);if(this.clientWidth<n.minImageWidth||this.clientHeight<n.minImageHeight){t.removeAttr("data-jpibfi-indexer");return}if(n.mode=="static")l(t,n.buttonPosition);r++});d("Images caught after filtering: "+r)};a.removeAllImages=function(){d("Remove Elements called");e("div.pinit-overlay").remove()};a.init=function(u){n={pageUrl:document.URL,pageTitle:document.title,pageDescription:e('meta[name="description"]').attr("content")||"",siteTitle:u.site_title,disabledClasses:u.disabled_classes,enabledClasses:u.enabled_classes,descriptionOption:u.description_option,usePostUrl:u.use_post_url=="1",minImageHeight:u.min_image_height,minImageWidth:u.min_image_width,mode:u.mode,buttonPosition:u.button_position};r={height:parseInt(u.pin_image_height),width:parseInt(u.pin_image_width)};i={top:parseInt(u.button_margin_top),right:parseInt(u.button_margin_right),bottom:parseInt(u.button_margin_bottom),left:parseInt(u.button_margin_left)};t="1"==u.debug;d(n);d(r);d(i);var a=e(".jpibfi").closest("div").addClass("jpibfi_container");d("Number of containers added: "+a.length);s=p(n.disabledClasses);o=p(n.enabledClasses)||"*";d("Filter selector: "+o);d("Not selector: "+s);if("static"==n.mode){d("Adding static mode delegates");e(document).delegate("div.pinit-overlay","hover",function(t){var n=t.type==="mouseenter";var r=e(this).data("jpibfi-indexer");e('.pinit-button[data-jpibfi-indexer="'+r+'"]').toggle(n);e('img[data-jpibfi-indexer="'+r+'"]').toggleClass("pinit-hover",n)})}else if("dynamic"==n.mode){d("Adding dynamic mode delegates");e(document).delegate("a.pinit-button","mouseenter",function(){var t=e(this);clearTimeout(t.data("jpibfi-timeoutId"))});e(document).delegate("a.pinit-button","mouseleave",function(){var t=e(this);var n=setTimeout(function(){t.remove();e('img[data-jpibfi-indexer="'+t.data("jpibfi-indexer")+'"]').removeClass("pinit-hover")},100);t.data("jpibfi-timeoutId",n)});e(document).delegate("img[data-jpibfi-indexer]","mouseenter",function(){var t=e(this);var s=t.data("jpibfi-indexer");var o=e('a.pinit-button[data-jpibfi-indexer="'+s+'"]');if(o.length==0){var o=f(s);var u=t.offset();var a={width:t.get(0).clientWidth,height:t.get(0).clientHeight};switch(n.buttonPosition){case"0":u.left+=i.left;u.top+=i.top;break;case"1":u.top+=i.top;u.left=u.left+a.width-i.right-r.width;break;case"2":u.left+=i.left;u.top=u.top+a.height-i.bottom-r.height;break;case"3":u.left=u.left+a.width-i.right-r.width;u.top=u.top+a.height-i.bottom-r.height;break;case"4":u.left=Math.round(u.left+a.width/2-r.width/2);u.top=Math.round(u.top+a.height/2-r.height/2);break}t.after(o);o.show().offset({left:u.left,top:u.top})}else{clearTimeout(o.data("jpibfi-timeoutId"))}t.addClass("pinit-hover")});e(document).delegate("img[data-jpibfi-indexer]","mouseleave",function(){var t=e(this).data("jpibfi-indexer");var n=e('a.pinit-button[data-jpibfi-indexer="'+t+'"]');var r=setTimeout(function(){n.remove();e('img[data-jpibfi-indexer="'+n.data("jpibfi-indexer")+'"]').removeClass("pinit-hover")},100);n.data("jpibfi-timeoutId",r)})}};return a;}()})(jQuery);(function(e){"use strict";e(document).ready(function(){jpibfi.init(jpibfi_options);jpibfi.addImages(jpibfi_options.image_selector);e(window).load(function(){jpibfi.prepareImages(e("img[data-jpibfi-indexer]"))});e(window).resize(function(){jpibfi.removeAllImages();jpibfi.prepareImages(e("img[data-jpibfi-indexer]"))})})})(jQuery)
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://bit.ly/Uw2mEP
4
  Tags: pinterest, pin it, button, image, images, pinit, social media, hover, click, photo, photos
5
  Requires at least: 3.3.0
6
  Tested up to: 3.6.1
7
- Stable tag: 1.20
8
  License: GPLv2 or later
9
 
10
  Highlights images on hover and adds a Pinterest "Pin It" button over them for easy pinning.
@@ -76,6 +76,10 @@ Please report them in the plugin's support forum on Wordpress.org.
76
 
77
  == Changelog ==
78
 
 
 
 
 
79
  = 1.20 =
80
  * Released 2014-02-16
81
  * Major JavaScript code redesign
@@ -185,6 +189,9 @@ Please report them in the plugin's support forum on Wordpress.org.
185
 
186
  == Upgrade Notice ==
187
 
 
 
 
188
  = 1.20 =
189
  Just code redesign.
190
 
4
  Tags: pinterest, pin it, button, image, images, pinit, social media, hover, click, photo, photos
5
  Requires at least: 3.3.0
6
  Tested up to: 3.6.1
7
+ Stable tag: 1.21
8
  License: GPLv2 or later
9
 
10
  Highlights images on hover and adds a Pinterest "Pin It" button over them for easy pinning.
76
 
77
  == Changelog ==
78
 
79
+ = 1.21 =
80
+ * Released 2014-02-22
81
+ * Fixed one issue from the previous release
82
+
83
  = 1.20 =
84
  * Released 2014-02-16
85
  * Major JavaScript code redesign
189
 
190
  == Upgrade Notice ==
191
 
192
+ = 1.21 =
193
+ Fixed one issue from the previous release.
194
+
195
  = 1.20 =
196
  Just code redesign.
197