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