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 // These share options don't need to have a popup. 78 if ( 'copy' === $( event ).data( 'site' ) || 'email' === $( event ).data( 'site' ) || 'print' === $( event ).data( 'site' ) || 'pinterest' === $( event ).data( 'site' ) ) { 79 if ( 'copy' === $( event ).data( 'site' ) ) { 80 const copybutton = document.querySelector( '[data-site="copy"]' ); 81 82 navigator.clipboard.writeText(copybutton.getAttribute('href')); 83 84 if ( copybutton ) { 85 const copymessage = document.createElement( 'span' ) 86 copymessage.innerText = 'URL Copied!'; 87 copymessage.className = 'copy-notify'; 88 copymessage.style.opacity = '1'; 89 copymessage.style.width = '100px'; 90 copymessage.style.fontSize = '12px'; 91 copymessage.style.transition = 'all .6s'; 92 copymessage.style.position = 'absolute'; 93 copymessage.style.top = '-24px'; 94 copymessage.style.left = '-24px'; 95 copybutton.append( copymessage ); 96 97 setTimeout( () => { 98 copymessage.style.opacity = '0'; 99 copymessage.style.minWidth = '0'; 100 copymessage.style.width = '0'; 101 copymessage.style.padding = '0'; 102 copymessage.style.overflow = 'hidden'; 103 104 setTimeout( () => { 105 copymessage.remove(); 106 }, 1000 ); 107 }, 1500 ); 108 } 109 } else { 110 // Just redirect. 111 window.location.href = $( event ).attr( 'href' ); 112 } 113 } else { 114 115 // Prepare popup window. 116 var width = 575, 117 height = 520, 118 left = ( $( window ).width() - width ) / 2, 119 top = ( $( window ).height() - height ) / 2, 120 opts = 'status=1' + 121 ',width=' + width + 122 ',height=' + height + 123 ',top=' + top + 124 ',left=' + left; 125 126 // Open the share url in a smaller window. 127 window.open( $( event ).attr( 'href' ), 'share', opts ); 128 } 129 } 130 }, 131 132 /** 133 * Remove generated p tag from facebook save button. 134 */ 135 removeP: function() { 136 } 137 }; 138} )( 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.