1/** 2 * Main. 3 * 4 * @package SimpleShareButtonsAdder 5 */ 6 7/* exported Main */ 8var Main = ( function( $, FB ) { 9 'use strict'; 10 11 return { 12 /** 13 * Holds data. 14 */ 15 data: {}, 16 17 /** 18 * Boot plugin. 19 * 20 * @param data 21 */ 22 boot: function( data ) { 23 this.data = data; 24 25 $( document ).ready( function() { 26 this.init(); 27 }.bind( this ) ); 28 }, 29 30 /** 31 * Initialize plugin. 32 */ 33 init: function() { 34 this.listen(); 35 this.removeP(); 36 }, 37 38 /** 39 * Listener event. 40 */ 41 listen: function() { 42 var self = this; 43 44 // Upon clicking a share button. 45 $( 'body' ).on( 'click', '.ssbp-wrap a', function( event ) { 46 47 // Don't go the the href yet. 48 event.preventDefault(); 49 self.engageShareButton( this ); 50 } ); 51 }, 52 53 /** 54 * Share button popup 55 * 56 * @param event 57 */ 58 engageShareButton: function( event ) { 59 60 // If it's facebook mobile. 61 if ( 'mobile' === $( event ).data( 'facebook' ) ) { 62 FB.ui( { 63 method: 'share', 64 mobile_iframe: true, 65 href: $( event ).data( 'href' ) 66 }, function( response ) {} ); 67 } else { 68 69 // These share options don't need to have a popup. 70 if ( 'email' === $( event ).data( 'site' ) || 'print' === $( event ).data( 'site' ) || 'pinterest' === $( event ).data( 'site' ) ) { 71 72 // Just redirect. 73 window.location.href = $( event ).attr( 'href' ); 74 } else { 75 76 // Prepare popup window. 77 var width = 575, 78 height = 520, 79 left = ( $( window ).width() - width ) / 2, 80 top = ( $( window ).height() - height ) / 2, 81 opts = 'status=1' + 82 ',width=' + width + 83 ',height=' + height + 84 ',top=' + top + 85 ',left=' + left; 86 87 // Open the share url in a smaller window. 88 window.open( $( event ).attr( 'href' ), 'share', opts ); 89 } 90 } 91 }, 92 93 /** 94 * Remove generated p tag from facebook save button. 95 */ 96 removeP: function() { 97 } 98 }; 99} )( window.jQuery, window.FB );
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.