jQuery Pin It Button for Images - Version 1.20

Version Description

  • Released 2014-02-16
  • Major JavaScript code redesign
Download this release

Release Info

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

Code changes from version 1.17 to 1.20

Files changed (4) hide show
  1. jquery-pin-it-button-for-images.php +13 -27
  2. js/script.js +266 -219
  3. js/script.min.js +1 -1
  4. readme.txt +8 -1
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.17
8
  Author URI: http://mrsztuczkens.me/
9
  */
10
 
@@ -18,9 +18,10 @@ if ( ! function_exists( 'add_action' ) ) {
18
  * CONSTANTS
19
  *
20
  */
21
- define( "JPIBFI_VERSION", "1.17" );
22
  define( "JPIBFI_VERSION_MINOR", "a" );
23
  define( "JPIBFI_METADATA", "jpibfi_meta" );
 
24
  define( "JPIBFI_SELECTION_OPTIONS", "jpibfi_selection_options" );
25
  define( "JPIBFI_VISUAL_OPTIONS", "jpibfi_visual_options" );
26
  define( "JPIBFI_ADVANCED_OPTIONS", "jpibfi_advanced_options" );
@@ -113,7 +114,8 @@ function jpibfi_add_plugin_scripts() {
113
  'button_margin_right' => $visual_options[ 'button_margin_right' ]
114
  );
115
 
116
- wp_localize_script( 'jquery-pin-it-button-script', 'jpibfi_options', $parameters_array );
 
117
  }
118
 
119
  add_action( 'wp_enqueue_scripts', 'jpibfi_add_plugin_scripts' );
@@ -383,7 +385,7 @@ function jpibfi_update_plugin() {
383
  if( false == get_option( JPIBFI_ADVANCED_OPTIONS ) )
384
  add_option( JPIBFI_ADVANCED_OPTIONS, jpibfi_default_advanced_options() );
385
 
386
- } else if ( (float)$version < (float)JPIBFI_VERSION ) { //if the plugins version is older than current, we need to update options with new defaults
387
 
388
  $option = get_option( JPIBFI_VISUAL_OPTIONS );
389
  $option['button_position'] = '5' == $option['button_position'] ? '0' : $option['button_position'];
@@ -527,10 +529,10 @@ function jpibfi_print_admin_page() {
527
 
528
  <p>
529
  <?php
530
- printf( __('If you would like to support development of the plugin, please %sdonate%s.', 'jpibfi') . ' ', '<a href="http://bit.ly/Uw2mEP" target="_blank" rel="nofollow"><b>', '</b></a>' );
531
- printf( __('If you experience issues with the plugin, check out the %ssupport forum%s.', 'jpibfi') . ' ', '<a href="http://wordpress.org/support/plugin/jquery-pin-it-button-for-images" target="_blank" rel="nofollow"><b>', '</b></a>' );
532
- printf( __('To help promote the plugin, %sleave a review%s.', 'jpibfi') . ' ', '<a href="http://wordpress.org/support/view/plugin-reviews/jquery-pin-it-button-for-images" target="_blank" rel="nofollow"><b>', '</b></a>' );
533
- printf( __('If you have any suggestions for improvements, %suse the feedback form%s.', 'jpibfi') . ' ', '<a href="http://mrsztuczkens.me/jquery-pin-it-button-for-images-feedback-form/" target="_blank" rel="nofollow"><b>', '</b></a>' );
534
  ?>
535
  </p>
536
  <form method="post" action="options.php" ng-app="jpibfiApp" ng-controller="jpibfiController">
@@ -584,7 +586,7 @@ function jpibfi_default_selection_options() {
584
  'show_on_blog' => '1'
585
  );
586
 
587
- return $defaults;
588
  }
589
 
590
  /*
@@ -882,7 +884,7 @@ function jpibfi_default_visual_options() {
882
  'retina_friendly' => '0'
883
  );
884
 
885
- return $defaults;
886
  }
887
 
888
  /*
@@ -1225,7 +1227,7 @@ function jpibfi_default_advanced_options() {
1225
  'debug' => '0'
1226
  );
1227
 
1228
- return $defaults;
1229
  }
1230
 
1231
  /*
@@ -1396,22 +1398,6 @@ function jpibfi_get_options( $name ) {
1396
  $options = get_option( $name . '_errors' );
1397
 
1398
  return false == $options ? get_option( $name ) : $options;
1399
-
1400
- //the code below is a much better error management solution, but doesn't work in WP 3.3
1401
- // if ( JPIBFI_SELECTION_OPTIONS == $name )
1402
- // $settings_list = jpibfi_default_selection_options();
1403
- // else
1404
- // $settings_list = jpibfi_default_visual_options();
1405
- //
1406
- // $errors = false;
1407
- //
1408
- // foreach( $settings_list as $key => $value) {
1409
- // if ( count( get_settings_errors( $key ) ) > 0 ) {
1410
- // $errors = true;
1411
- // break;
1412
- // }
1413
- // }
1414
- // return $errors ? get_option( $name . '_errors' ) : get_option( $name );
1415
  }
1416
 
1417
  /*
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
  * 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");
25
  define( "JPIBFI_SELECTION_OPTIONS", "jpibfi_selection_options" );
26
  define( "JPIBFI_VISUAL_OPTIONS", "jpibfi_visual_options" );
27
  define( "JPIBFI_ADVANCED_OPTIONS", "jpibfi_advanced_options" );
114
  'button_margin_right' => $visual_options[ 'button_margin_right' ]
115
  );
116
 
117
+ wp_localize_script( 'jquery-pin-it-button-script', 'jpibfi_options',
118
+ apply_filters('jpibfi_javascript_parameters',$parameters_array, $selection_options, $visual_options, $advanced_options ) );
119
  }
120
 
121
  add_action( 'wp_enqueue_scripts', 'jpibfi_add_plugin_scripts' );
385
  if( false == get_option( JPIBFI_ADVANCED_OPTIONS ) )
386
  add_option( JPIBFI_ADVANCED_OPTIONS, jpibfi_default_advanced_options() );
387
 
388
+ } else if ( (float)$version < (float)JPIBFI_VERSION || get_option( JPIBFI_UPDATE_OPTIONS ) ) { //if the plugins version is older than current, we need to update options with new defaults
389
 
390
  $option = get_option( JPIBFI_VISUAL_OPTIONS );
391
  $option['button_position'] = '5' == $option['button_position'] ? '0' : $option['button_position'];
529
 
530
  <p>
531
  <?php
532
+ printf( '<a href="http://mrsztuczkens.me/jquery-pin-it-button-for-images-customization/" class="button" target="_blank" rel="nofollow"><b>' . __( 'Plugin Customization', 'jpibfi' ) . '</b></a>' );
533
+ printf( '<a href="http://bit.ly/Uw2mEP" class="button" target="_blank" rel="nofollow"><b>' . __( 'Donate', 'jpibfi' ) . '</b></a>' );
534
+ printf( '<a href="http://wordpress.org/support/plugin/jquery-pin-it-button-for-images" class="button" target="_blank" rel="nofollow"><b>' . __( 'Support forum', 'jpibfi' ) . '</b></a>' );
535
+ printf( '<a href="http://wordpress.org/support/view/plugin-reviews/jquery-pin-it-button-for-images" class="button" target="_blank" rel="nofollow"><b>'. __( 'Leave a review', 'jpibfi' ) . '</b></a>' );
536
  ?>
537
  </p>
538
  <form method="post" action="options.php" ng-app="jpibfiApp" ng-controller="jpibfiController">
586
  'show_on_blog' => '1'
587
  );
588
 
589
+ return apply_filters('jpibfi_default_selection_options', $defaults);
590
  }
591
 
592
  /*
884
  'retina_friendly' => '0'
885
  );
886
 
887
+ return apply_filters( 'jpibfi_default_visual_options', $defaults );
888
  }
889
 
890
  /*
1227
  'debug' => '0'
1228
  );
1229
 
1230
+ return apply_filters( 'jpibfi_default_advanced_options', $defaults );
1231
  }
1232
 
1233
  /*
1398
  $options = get_option( $name . '_errors' );
1399
 
1400
  return false == $options ? get_option( $name ) : $options;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1401
  }
1402
 
1403
  /*
js/script.js CHANGED
@@ -1,220 +1,215 @@
1
- ;(function($){
2
  "use strict";
3
 
4
- var jpibfi_debug = false;
5
-
6
- $(document).ready( function() {
7
-
8
- var settings = {
9
- pageUrl : document.URL,
10
- pageTitle : document.title,
11
- pageDescription : $('meta[name="description"]').attr('content') || "",
12
- siteTitle : jpibfi_options.site_title,
13
- imageSelector : jpibfi_options.image_selector,
14
- disabledClasses : jpibfi_options.disabled_classes,
15
- enabledClasses : jpibfi_options.enabled_classes,
16
- descriptionOption : jpibfi_options.description_option,
17
- usePostUrl : jpibfi_options.use_post_url == "1",
18
- minImageHeight : jpibfi_options.min_image_height,
19
- minImageWidth : jpibfi_options.min_image_width,
20
- mode : jpibfi_options.mode,
21
- buttonPosition : jpibfi_options.button_position
22
- }
23
-
24
- var pinButtonDimensions = {
25
- height: parseInt( jpibfi_options.pin_image_height ),
26
- width: parseInt( jpibfi_options.pin_image_width )
27
- }
28
-
29
- var pinButtonMargins = {
30
- top: parseInt( jpibfi_options.button_margin_top ),
31
- right: parseInt( jpibfi_options.button_margin_right ),
32
- bottom: parseInt( jpibfi_options.button_margin_bottom ),
33
- left: parseInt( jpibfi_options.button_margin_left )
34
- }
35
 
36
- jpibfi_debug = '1' == jpibfi_options.debug;
 
37
 
38
- jpibfiLog( settings );
39
- jpibfiLog( pinButtonDimensions );
40
- jpibfiLog( pinButtonMargins );
 
41
 
42
- var $containers = $('.jpibfi').closest('div').addClass('jpibfi_container');
 
43
 
44
- jpibfiLog( 'Number of containers added: ' + $containers.length );
 
45
 
46
- var notSelector = createSelectorFromList( settings.disabledClasses );
47
- //in case of no enabled classes, we need a selector that takes all elements
48
- var filterSelector = createSelectorFromList( settings.enabledClasses ) || "*";
49
 
50
- jpibfiLog( 'Image selector: ' + settings.imageSelector );
51
- jpibfiLog( 'Filter selector: ' + filterSelector );
52
- jpibfiLog( 'Not selector: ' + notSelector );
53
 
54
- var imageCount = 0;
55
- $( settings.imageSelector )
56
- .not( notSelector )
57
- .filter( filterSelector )
58
- .each( function (i) { $( this ).attr('data-jpibfi-indexer', i); imageCount++; } );
59
- jpibfiLog( 'Images caught by selectors: ' + imageCount );
60
 
61
- //EVENT HANDLING
62
 
63
- if ( 'static' == settings.mode) {
 
64
 
65
- jpibfiLog( 'Adding static mode delegates');
66
-
67
- $( document).delegate( 'div.pinit-overlay', 'hover', function( event ) {
68
- var hover = event.type === 'mouseenter';
69
- var indexer = $(this).attr("data-jpibfi-indexer");
70
- $('.pinit-button[data-jpibfi-indexer="' + indexer + '"]').toggle( hover );
71
- $('img[data-jpibfi-indexer="' + indexer + '"]').toggleClass( 'pinit-hover', hover );
72
- });
73
-
74
- } else if ( 'dynamic' == settings.mode ) {
75
-
76
- jpibfiLog( 'Adding dynamic mode delegates');
77
-
78
- $( document ).delegate( 'a.pinit-button', 'mouseenter', function() {
79
- var $button = $( this );
80
- clearTimeout( $button.data('jpibfi-timeoutId') );
81
- });
82
-
83
- $( document ).delegate( 'a.pinit-button', 'mouseleave', function() {
84
- var $button = $( this );
85
- var timeoutId = setTimeout( function(){
86
- $button.remove();
87
- $('img[data-jpibfi-indexer="' + $button.attr( 'data-jpibfi-indexer' ) + '"]').removeClass( 'pinit-hover' );
88
- }, 100 );
89
- $button.data('jpibfi-timeoutId', timeoutId);
90
- });
91
 
92
- $( document ).delegate( 'img[data-jpibfi-indexer]', 'mouseenter', function() {
93
- var $image = $( this );
94
- var indexer = $image.attr( 'data-jpibfi-indexer' );
 
95
 
96
- var $button = $('a.pinit-button[data-jpibfi-indexer="' + indexer + '"]');
97
-
98
- if ( $button.length == 0 ) {
99
- //button doesn't exist so we need to create it
100
- var $button = jpibfiCreatePinitButton( indexer );
101
- var position = $image.offset();
102
- var imageDimensions = {
103
- width: $image.get(0).clientWidth,
104
- height: $image.get(0).clientHeight
105
- }
106
-
107
- switch( settings.buttonPosition ){
108
- case '0': //top-left
109
- position.left += pinButtonMargins.left;
110
- position.top += pinButtonMargins.top;
111
- break;
112
- case '1': //top-right
113
- position.top += pinButtonMargins.top;
114
- position.left = position.left + imageDimensions.width - pinButtonMargins.right - pinButtonDimensions.width;
115
- break;
116
- case '2': //bottom-left;
117
- position.left += pinButtonMargins.left;
118
- position.top = position.top + imageDimensions.height - pinButtonMargins.bottom - pinButtonDimensions.height;
119
- break;
120
- case '3': //bottom-right
121
- position.left = position.left + imageDimensions.width - pinButtonMargins.right - pinButtonDimensions.width;
122
- position.top = position.top + imageDimensions.height - pinButtonMargins.bottom - pinButtonDimensions.height;
123
- break;
124
- case '4': //middle
125
- position.left = Math.round( position.left + imageDimensions.width / 2 - pinButtonDimensions.width / 2 );
126
- position.top = Math.round( position.top + imageDimensions.height / 2 - pinButtonDimensions.height / 2 );
127
- break;
128
- }
129
-
130
- $image.after( $button );
131
- $button
132
- .show()
133
- .offset({ left: position.left, top: position.top });
134
- } else {
135
- //button exists, we need to clear the timeout that has to remove it
136
- clearTimeout( $button.data('jpibfi-timeoutId') );
137
- }
138
-
139
- $( 'img[data-jpibfi-indexer="' + $button.attr( 'data-jpibfi-indexer' ) + '"]' ).addClass( 'pinit-hover' );
140
- });
141
-
142
- $( document).delegate( 'img[data-jpibfi-indexer]', 'mouseleave', function() {
143
- var indexer = $(this).attr("data-jpibfi-indexer");
144
- var $button = $('a.pinit-button[data-jpibfi-indexer="' + indexer + '"]');
145
-
146
- var timeoutId = setTimeout(function(){
147
- $button.remove();
148
- $('img[data-jpibfi-indexer="' + $button.attr( 'data-jpibfi-indexer' ) + '"]').removeClass( 'pinit-hover' );
149
- }, 100 );
150
- $button.data('jpibfi-timeoutId', timeoutId);
151
- });
152
-
153
- }
154
-
155
- function jpibfiAddElements() {
156
- jpibfiLog( 'Add Elements called' );
157
 
158
  var imageCount = 0;
159
- $("img[data-jpibfi-indexer]").each(function () {
160
  var $image = $(this);
161
 
162
  if ( this.clientWidth < settings.minImageWidth || this.clientHeight < settings.minImageHeight ) {
163
  $image.removeAttr( 'data-jpibfi-indexer' );
164
  return;
165
  }
 
166
  if ( settings.mode == 'static' )
167
  jpibfiCreateAndShowOverlayDiv( $image, settings.buttonPosition );
168
 
169
  imageCount++;
170
  });
171
  jpibfiLog( 'Images caught after filtering: ' + imageCount );
172
- }
173
 
174
- function jpibfiRemoveElements() {
175
  jpibfiLog( 'Remove Elements called' );
176
  $( 'div.pinit-overlay' ).remove();
177
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
178
 
179
- $(window).load( jpibfiAddElements );
 
 
 
180
 
181
- $(window).resize ( function() {
182
- jpibfiRemoveElements();
183
- jpibfiAddElements();
184
- });
 
 
185
 
186
- //UTILITY FUNCTIONS
187
 
188
- function jpibfiCreateAndShowOverlayDiv( $image, buttonPosition ) {
189
- var position = $image.offset();
 
190
 
191
- var $overlay = jpibfiCreateOverlayDiv( $image, buttonPosition );
192
 
193
- $image.after( $overlay );
194
 
195
- $overlay
196
- .css({
197
- height: $image.get(0).clientHeight + 'px',
198
- width: $image.get(0).clientWidth + 'px'
199
- })
200
- .show()
201
- .offset({ left: position.left, top: position.top });
202
 
203
- return $overlay;
204
- }
205
 
206
- //function creates an overlay div that covers the image
207
- function jpibfiCreateOverlayDiv( $image, buttonPosition ) {
208
 
209
- var indexer = $image.attr("data-jpibfi-indexer");
210
 
211
- return jQuery('<div/>', {
212
- "class": 'pinit-overlay',
213
- "data-jpibfi-indexer": indexer,
214
- title: $image.attr( 'title' ) || '',
215
- html: jpibfiCreatePinitButton( indexer).addClass( jpibfiButtonPositionToClass( buttonPosition ))
216
- })
217
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
218
 
219
  function jpibfiCreatePinitButton( indexer ){
220
 
@@ -227,7 +222,7 @@
227
 
228
  $anchor.click( function(e) {
229
  jpibfiLog( 'Pin In button clicked' );
230
- var index = $(this).attr("data-jpibfi-indexer");
231
  var $image = $('img[data-jpibfi-indexer="' + index+ '"]');
232
 
233
  //Bookmark description is created on click because sometimes it's lazy loaded
@@ -238,8 +233,8 @@
238
  var $inputWithData = $image.closest("div.jpibfi_container").find("input.jpibfi").first();
239
 
240
  if ( $inputWithData.length ) {
241
- descriptionForUrl = $inputWithData.attr("data-jpibfi-description")
242
- bookmarkUrl = $inputWithData.attr("data-jpibfi-url");
243
  }
244
  }
245
  bookmarkUrl = bookmarkUrl || settings.pageUrl;
@@ -251,11 +246,11 @@
251
  else if ( settings.descriptionOption == 4 )
252
  bookmarkDescription = settings.siteTitle;
253
  else if ( settings.descriptionOption == 5 )
254
- bookmarkDescription = $image.attr( 'data-jpibfi-description' );
255
 
256
  bookmarkDescription = bookmarkDescription || ( descriptionForUrl || settings.pageTitle );
257
 
258
- var imageUrl = 'http://pinterest.com/pin/create/bookmarklet/?is_video=' + encodeURIComponent('false') + "&url=" + encodeURIComponent( bookmarkUrl ) + "&media=" + encodeURIComponent( $image.data('media') || $image[0].src )
259
  + '&description=' + encodeURIComponent( bookmarkDescription );
260
 
261
  window.open(imageUrl, 'Pinterest', 'width=632,height=253,status=0,toolbar=0,menubar=0,location=1,scrollbars=1');
@@ -265,52 +260,104 @@
265
  return $anchor;
266
  }
267
 
268
- });
269
 
270
- //UTILITY FUNCTIONS
271
-
272
- //functions logs a message or object data if plugin runs in debug mode
273
- function jpibfiLog( o ) {
274
- if ( jpibfi_debug && console && console.log ) {
275
- if ( 'string' == typeof o || o instanceof String ) {
276
- console.log( 'jpibfi debug: ' + o );
277
- } else if ( 'object' == typeof o && typeof JSON !== 'undefined' && typeof JSON.stringify === 'function' ) {
278
- console.log( 'jpibfi debug: ' + JSON.stringify( o, null, 4 ) );
279
- } else if ( 'object' == typeof o ) {
280
- var out = '';
281
- for (var p in o)
282
- out += p + ': ' + o[p] + '\n';
283
- console.log( 'jpibfi debug: ' + out );
284
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
285
  }
286
- };
287
-
288
- //returns class name based on given button position
289
- function jpibfiButtonPositionToClass( buttonPosition ) {
290
- switch( buttonPosition ){
291
- case '0': return 'pinit-top-left';
292
- case '1': return 'pinit-top-right';
293
- case '2': return 'pinit-bottom-left';
294
- case '3': return 'pinit-bottom-right';
295
- case '4': return 'pinit-middle';
296
- default: return '';
 
 
297
  }
298
- }
299
 
300
- //function creates a selector from a list of semicolon separated classes
301
- function createSelectorFromList(classes) {
302
- var arrayOfClasses = classes.split( ';' );
 
 
 
 
 
 
 
303
 
304
- var selector = "";
 
305
 
306
- for (var i = 0; i < arrayOfClasses.length; i++) {
307
- if ( arrayOfClasses[i] )
308
- selector += '.' + arrayOfClasses[i] + ',';
309
  }
310
 
311
- if (selector)
312
- selector = selector.substr(0, selector.length - 1);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
313
 
314
- return selector;
315
- }
316
  })(jQuery);
1
+ (function($){
2
  "use strict";
3
 
4
+ window.jpibfi = (function(){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
 
6
+ /* PRIVATE VARIABLES */
7
+ var jpibfi_debug = false;
8
 
9
+ /* SETTINGS */
10
+ var settings = {};
11
+ var pinButtonDimensions = {};
12
+ var pinButtonMargins = {};
13
 
14
+ var notSelector = "";
15
+ var filterSelector = "*";
16
 
17
+ //max index of images with the data-jpibfi-indexer attribute
18
+ var imageMaxIndex = 0;
19
 
20
+ var jpibfi = {};
 
 
21
 
22
+ /* FUNCTIONS THAT CAN BE OVERRIDDEN */
23
+ jpibfi.fn = {};
 
24
 
25
+ jpibfi.fn.getImageUrl = function( $elem ) {
26
+ return $elem.data('media') || $elem.attr('src');
27
+ };
 
 
 
28
 
29
+ /* FUNCTIONS THAT SHOULDN'T BE OVERRIDDEN */
30
 
31
+ jpibfi.addImages = function( selector ) {
32
+ jpibfiLog( '>>addImages' );
33
 
34
+ var $elements = $( selector )
35
+ .not( notSelector )
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
 
59
  imageCount++;
60
  });
61
  jpibfiLog( 'Images caught after filtering: ' + imageCount );
62
+ };
63
 
64
+ jpibfi.removeAllImages = function () {
65
  jpibfiLog( 'Remove Elements called' );
66
  $( 'div.pinit-overlay' ).remove();
67
+ };
68
+
69
+ /* INITIALIZE */
70
+
71
+ jpibfi.init = function( jpibfi_options ) {
72
+ settings = {
73
+ pageUrl : document.URL,
74
+ pageTitle : document.title,
75
+ pageDescription : $('meta[name="description"]').attr('content') || "",
76
+ siteTitle : jpibfi_options.site_title,
77
+ disabledClasses : jpibfi_options.disabled_classes,
78
+ enabledClasses : jpibfi_options.enabled_classes,
79
+ descriptionOption : jpibfi_options.description_option,
80
+ usePostUrl : jpibfi_options.use_post_url == "1",
81
+ minImageHeight : jpibfi_options.min_image_height,
82
+ minImageWidth : jpibfi_options.min_image_width,
83
+ mode : jpibfi_options.mode,
84
+ buttonPosition : jpibfi_options.button_position
85
+ }
86
 
87
+ pinButtonDimensions = {
88
+ height: parseInt( jpibfi_options.pin_image_height ),
89
+ width: parseInt( jpibfi_options.pin_image_width )
90
+ }
91
 
92
+ pinButtonMargins = {
93
+ top: parseInt( jpibfi_options.button_margin_top ),
94
+ right: parseInt( jpibfi_options.button_margin_right ),
95
+ bottom: parseInt( jpibfi_options.button_margin_bottom ),
96
+ left: parseInt( jpibfi_options.button_margin_left )
97
+ }
98
 
99
+ jpibfi_debug = '1' == jpibfi_options.debug;
100
 
101
+ jpibfiLog( settings );
102
+ jpibfiLog( pinButtonDimensions );
103
+ jpibfiLog( pinButtonMargins );
104
 
105
+ var $containers = $('.jpibfi').closest('div').addClass('jpibfi_container');
106
 
107
+ jpibfiLog( 'Number of containers added: ' + $containers.length );
108
 
109
+ //we need to prepare selectors
110
+ notSelector = createSelectorFromList( settings.disabledClasses );
111
+ filterSelector = createSelectorFromList( settings.enabledClasses ) || "*";
 
 
 
 
112
 
113
+ jpibfiLog( 'Filter selector: ' + filterSelector );
114
+ jpibfiLog( 'Not selector: ' + notSelector );
115
 
116
+ //EVENT HANDLING - ADDING EVERY NEEDED EVENT
 
117
 
118
+ if ( 'static' == settings.mode) {
119
 
120
+ jpibfiLog( 'Adding static mode delegates');
121
+
122
+ $( document).delegate( 'div.pinit-overlay', 'hover', function( event ) {
123
+ var hover = event.type === 'mouseenter';
124
+ var indexer = $(this).data("jpibfi-indexer");
125
+ $('.pinit-button[data-jpibfi-indexer="' + indexer + '"]').toggle( hover );
126
+ $('img[data-jpibfi-indexer="' + indexer + '"]').toggleClass( 'pinit-hover', hover );
127
+ });
128
+
129
+ } else if ( 'dynamic' == settings.mode ) {
130
+
131
+ jpibfiLog( 'Adding dynamic mode delegates');
132
+
133
+ $( document ).delegate( 'a.pinit-button', 'mouseenter', function() {
134
+ var $button = $( this );
135
+ clearTimeout( $button.data('jpibfi-timeoutId') );
136
+ });
137
+
138
+ $( document ).delegate( 'a.pinit-button', 'mouseleave', function() {
139
+ var $button = $( this );
140
+ var timeoutId = setTimeout( function(){
141
+ $button.remove();
142
+ $('img[data-jpibfi-indexer="' + $button.data( 'jpibfi-indexer' ) + '"]').removeClass( 'pinit-hover' );
143
+ }, 100 );
144
+ $button.data('jpibfi-timeoutId', timeoutId);
145
+ });
146
+
147
+ $( document ).delegate( 'img[data-jpibfi-indexer]', 'mouseenter', function() {
148
+ var $image = $( this );
149
+ var indexer = $image.data( 'jpibfi-indexer' );
150
+
151
+ var $button = $('a.pinit-button[data-jpibfi-indexer="' + indexer + '"]');
152
+
153
+ if ( $button.length == 0 ) {
154
+ //button doesn't exist so we need to create it
155
+ var $button = jpibfiCreatePinitButton( indexer );
156
+ var position = $image.offset();
157
+ var imageDimensions = {
158
+ width: $image.get(0).clientWidth,
159
+ height: $image.get(0).clientHeight
160
+ }
161
+
162
+ switch( settings.buttonPosition ){
163
+ case '0': //top-left
164
+ position.left += pinButtonMargins.left;
165
+ position.top += pinButtonMargins.top;
166
+ break;
167
+ case '1': //top-right
168
+ position.top += pinButtonMargins.top;
169
+ position.left = position.left + imageDimensions.width - pinButtonMargins.right - pinButtonDimensions.width;
170
+ break;
171
+ case '2': //bottom-left;
172
+ position.left += pinButtonMargins.left;
173
+ position.top = position.top + imageDimensions.height - pinButtonMargins.bottom - pinButtonDimensions.height;
174
+ break;
175
+ case '3': //bottom-right
176
+ position.left = position.left + imageDimensions.width - pinButtonMargins.right - pinButtonDimensions.width;
177
+ position.top = position.top + imageDimensions.height - pinButtonMargins.bottom - pinButtonDimensions.height;
178
+ break;
179
+ case '4': //middle
180
+ position.left = Math.round( position.left + imageDimensions.width / 2 - pinButtonDimensions.width / 2 );
181
+ position.top = Math.round( position.top + imageDimensions.height / 2 - pinButtonDimensions.height / 2 );
182
+ break;
183
+ }
184
+
185
+ $image.after( $button );
186
+ $button
187
+ .show()
188
+ .offset({ left: position.left, top: position.top });
189
+ } else {
190
+ //button exists, we need to clear the timeout that has to remove it
191
+ clearTimeout( $button.data('jpibfi-timeoutId') );
192
+ }
193
+ $image.addClass( 'pinit-hover' );
194
+ });
195
+
196
+ $( document).delegate( 'img[data-jpibfi-indexer]', 'mouseleave', function() {
197
+ var indexer = $(this).data("jpibfi-indexer");
198
+ var $button = $('a.pinit-button[data-jpibfi-indexer="' + indexer + '"]');
199
+
200
+ var timeoutId = setTimeout(function(){
201
+ $button.remove();
202
+ $('img[data-jpibfi-indexer="' + $button.data( 'jpibfi-indexer' ) + '"]').removeClass( 'pinit-hover' );
203
+ }, 100 );
204
+ $button.data('jpibfi-timeoutId', timeoutId);
205
+ });
206
+
207
+ }
208
+ };
209
+
210
+ return jpibfi;
211
+
212
+ /* PRIVATE CREATE ELEMENTS FUNCTIONS */
213
 
214
  function jpibfiCreatePinitButton( indexer ){
215
 
222
 
223
  $anchor.click( function(e) {
224
  jpibfiLog( 'Pin In button clicked' );
225
+ var index = $(this).data("jpibfi-indexer");
226
  var $image = $('img[data-jpibfi-indexer="' + index+ '"]');
227
 
228
  //Bookmark description is created on click because sometimes it's lazy loaded
233
  var $inputWithData = $image.closest("div.jpibfi_container").find("input.jpibfi").first();
234
 
235
  if ( $inputWithData.length ) {
236
+ descriptionForUrl = $inputWithData.data("jpibfi-description")
237
+ bookmarkUrl = $inputWithData.data("jpibfi-url");
238
  }
239
  }
240
  bookmarkUrl = bookmarkUrl || settings.pageUrl;
246
  else if ( settings.descriptionOption == 4 )
247
  bookmarkDescription = settings.siteTitle;
248
  else if ( settings.descriptionOption == 5 )
249
+ bookmarkDescription = $image.data( 'jpibfi-description' );
250
 
251
  bookmarkDescription = bookmarkDescription || ( descriptionForUrl || settings.pageTitle );
252
 
253
+ var imageUrl = 'http://pinterest.com/pin/create/bookmarklet/?is_video=' + encodeURIComponent('false') + "&url=" + encodeURIComponent( bookmarkUrl ) + "&media=" + encodeURIComponent( jpibfi.fn.getImageUrl( $image ) )
254
  + '&description=' + encodeURIComponent( bookmarkDescription );
255
 
256
  window.open(imageUrl, 'Pinterest', 'width=632,height=253,status=0,toolbar=0,menubar=0,location=1,scrollbars=1');
260
  return $anchor;
261
  }
262
 
 
263
 
264
+ function jpibfiCreateAndShowOverlayDiv( $image, buttonPosition ) {
265
+ var position = $image.offset();
266
+
267
+ var $overlay = jpibfiCreateOverlayDiv( $image, buttonPosition );
268
+
269
+ $image.after( $overlay );
270
+
271
+ $overlay
272
+ .css({
273
+ height: $image.get(0).clientHeight + 'px',
274
+ width: $image.get(0).clientWidth + 'px'
275
+ })
276
+ .show()
277
+ .offset({ left: position.left, top: position.top });
278
+
279
+ return $overlay;
280
+ }
281
+
282
+ //function creates an overlay div that covers the image
283
+ function jpibfiCreateOverlayDiv( $image, buttonPosition ) {
284
+
285
+ var indexer = $image.data("jpibfi-indexer");
286
+
287
+ return jQuery('<div/>', {
288
+ "class": 'pinit-overlay',
289
+ "data-jpibfi-indexer": indexer,
290
+ title: $image.attr( 'title' ) || '',
291
+ html: jpibfiCreatePinitButton( indexer).addClass( jpibfiButtonPositionToClass( buttonPosition ))
292
+ })
293
  }
294
+
295
+ /* PRIVATE UTILITY FUNCTIONS */
296
+
297
+ //returns class name based on given button position
298
+ function jpibfiButtonPositionToClass( buttonPosition ) {
299
+ switch( buttonPosition ){
300
+ case '0': return 'pinit-top-left';
301
+ case '1': return 'pinit-top-right';
302
+ case '2': return 'pinit-bottom-left';
303
+ case '3': return 'pinit-bottom-right';
304
+ case '4': return 'pinit-middle';
305
+ default: return '';
306
+ }
307
  }
 
308
 
309
+ //function creates a selector from a list of semicolon separated classes
310
+ function createSelectorFromList(classes) {
311
+ var arrayOfClasses = classes.split( ';' );
312
+
313
+ var selector = "";
314
+
315
+ for (var i = 0; i < arrayOfClasses.length; i++) {
316
+ if ( arrayOfClasses[i] )
317
+ selector += '.' + arrayOfClasses[i] + ',';
318
+ }
319
 
320
+ if (selector)
321
+ selector = selector.substr(0, selector.length - 1);
322
 
323
+ return selector;
 
 
324
  }
325
 
326
+ //functions logs a message or object data if plugin runs in debug mode
327
+ function jpibfiLog( o ) {
328
+ if ( jpibfi_debug && console && console.log ) {
329
+ if ( 'string' == typeof o || o instanceof String ) {
330
+ console.log( 'jpibfi debug: ' + o );
331
+ } else if ( 'object' == typeof o && typeof JSON !== 'undefined' && typeof JSON.stringify === 'function' ) {
332
+ console.log( 'jpibfi debug: ' + JSON.stringify( o, null, 4 ) );
333
+ } else if ( 'object' == typeof o ) {
334
+ var out = '';
335
+ for (var p in o)
336
+ out += p + ': ' + o[p] + '\n';
337
+ console.log( 'jpibfi debug: ' + out );
338
+ }
339
+ }
340
+ };
341
+
342
+ })();
343
+
344
+ })(jQuery);
345
+
346
+
347
+ ;(function($){
348
+ "use strict";
349
+
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();
359
+ jpibfi.prepareImages( $('img[data-jpibfi-indexer]') );
360
+ });
361
+ });
362
 
 
 
363
  })(jQuery);
js/script.min.js CHANGED
@@ -1 +1 @@
1
- (function(e){"use strict";function n(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)}}}function r(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 i(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}var t=false;e(document).ready(function(){function h(){n("Add Elements called");var t=0;e("img[data-jpibfi-indexer]").each(function(){var n=e(this);if(this.clientWidth<s.minImageWidth||this.clientHeight<s.minImageHeight){n.removeAttr("data-jpibfi-indexer");return}if(s.mode=="static")d(n,s.buttonPosition);t++});n("Images caught after filtering: "+t)}function p(){n("Remove Elements called");e("div.pinit-overlay").remove()}function d(e,t){var n=e.offset();var r=v(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 v(e,t){var n=e.attr("data-jpibfi-indexer");return jQuery("<div/>",{"class":"pinit-overlay","data-jpibfi-indexer":n,title:e.attr("title")||"",html:m(n).addClass(r(t))})}function m(t){var r=jQuery("<a/>",{href:"#","class":"pinit-button","data-jpibfi-indexer":t,text:"Pin It"});r.click(function(t){n("Pin In button clicked");var r=e(this).attr("data-jpibfi-indexer");var i=e('img[data-jpibfi-indexer="'+r+'"]');var o="",u="",a="";if(s.usePostUrl){var f=i.closest("div.jpibfi_container").find("input.jpibfi").first();if(f.length){u=f.attr("data-jpibfi-description");a=f.attr("data-jpibfi-url")}}a=a||s.pageUrl;if(s.descriptionOption==3)o=i.attr("title")||i.attr("alt");else if(s.descriptionOption==2)o=u||s.pageDescription;else if(s.descriptionOption==4)o=s.siteTitle;else if(s.descriptionOption==5)o=i.attr("data-jpibfi-description");o=o||u||s.pageTitle;var l="http://pinterest.com/pin/create/bookmarklet/?is_video="+encodeURIComponent("false")+"&url="+encodeURIComponent(a)+"&media="+encodeURIComponent(i.data("media")||i[0].src)+"&description="+encodeURIComponent(o);window.open(l,"Pinterest","width=632,height=253,status=0,toolbar=0,menubar=0,location=1,scrollbars=1");return false});return r}var s={pageUrl:document.URL,pageTitle:document.title,pageDescription:e('meta[name="description"]').attr("content")||"",siteTitle:jpibfi_options.site_title,imageSelector:jpibfi_options.image_selector,disabledClasses:jpibfi_options.disabled_classes,enabledClasses:jpibfi_options.enabled_classes,descriptionOption:jpibfi_options.description_option,usePostUrl:jpibfi_options.use_post_url=="1",minImageHeight:jpibfi_options.min_image_height,minImageWidth:jpibfi_options.min_image_width,mode:jpibfi_options.mode,buttonPosition:jpibfi_options.button_position};var o={height:parseInt(jpibfi_options.pin_image_height),width:parseInt(jpibfi_options.pin_image_width)};var u={top:parseInt(jpibfi_options.button_margin_top),right:parseInt(jpibfi_options.button_margin_right),bottom:parseInt(jpibfi_options.button_margin_bottom),left:parseInt(jpibfi_options.button_margin_left)};t="1"==jpibfi_options.debug;n(s);n(o);n(u);var a=e(".jpibfi").closest("div").addClass("jpibfi_container");n("Number of containers added: "+a.length);var f=i(s.disabledClasses);var l=i(s.enabledClasses)||"*";n("Image selector: "+s.imageSelector);n("Filter selector: "+l);n("Not selector: "+f);var c=0;e(s.imageSelector).not(f).filter(l).each(function(t){e(this).attr("data-jpibfi-indexer",t);c++});n("Images caught by selectors: "+c);if("static"==s.mode){n("Adding static mode delegates");e(document).delegate("div.pinit-overlay","hover",function(t){var n=t.type==="mouseenter";var r=e(this).attr("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"==s.mode){n("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.attr("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 n=t.attr("data-jpibfi-indexer");var r=e('a.pinit-button[data-jpibfi-indexer="'+n+'"]');if(r.length==0){var r=m(n);var i=t.offset();var a={width:t.get(0).clientWidth,height:t.get(0).clientHeight};switch(s.buttonPosition){case"0":i.left+=u.left;i.top+=u.top;break;case"1":i.top+=u.top;i.left=i.left+a.width-u.right-o.width;break;case"2":i.left+=u.left;i.top=i.top+a.height-u.bottom-o.height;break;case"3":i.left=i.left+a.width-u.right-o.width;i.top=i.top+a.height-u.bottom-o.height;break;case"4":i.left=Math.round(i.left+a.width/2-o.width/2);i.top=Math.round(i.top+a.height/2-o.height/2);break}t.after(r);r.show().offset({left:i.left,top:i.top})}else{clearTimeout(r.data("jpibfi-timeoutId"))}e('img[data-jpibfi-indexer="'+r.attr("data-jpibfi-indexer")+'"]').addClass("pinit-hover")});e(document).delegate("img[data-jpibfi-indexer]","mouseleave",function(){var t=e(this).attr("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.attr("data-jpibfi-indexer")+'"]').removeClass("pinit-hover")},100);n.data("jpibfi-timeoutId",r)})}e(window).load(h);e(window).resize(function(){p();h()})});})(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");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)
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.17
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.17 =
80
  * Released 2013-12-10
81
  * Minor bug fix
@@ -181,6 +185,9 @@ Please report them in the plugin's support forum on Wordpress.org.
181
 
182
  == Upgrade Notice ==
183
 
 
 
 
184
  = 1.17 =
185
  Minor bug fix and Spanish translation added.
186
 
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
 
77
  == Changelog ==
78
 
79
+ = 1.20 =
80
+ * Released 2014-02-16
81
+ * Major JavaScript code redesign
82
+
83
  = 1.17 =
84
  * Released 2013-12-10
85
  * Minor bug fix
185
 
186
  == Upgrade Notice ==
187
 
188
+ = 1.20 =
189
+ Just code redesign.
190
+
191
  = 1.17 =
192
  Minor bug fix and Spanish translation added.
193