1jQuery( document ).ready( function( $ ) { 2 var has_remove = function() { 3 $( '.highlight-and-share-wrapper:visible' ).remove(); 4 $('.has_sharing_email').css( 'display', 'none' ); 5 }; 6 7 var title = ''; 8 var link = ''; 9 var href = ''; 10 11 var has_selected_text = ''; 12 13 var has_load_html = function() { 14 if ( highlight_and_share.icons == false ) { 15 var html = '<div class="highlight-and-share-wrapper" style="display: none">'; 16 } else { 17 var html = '<div class="highlight-and-share-wrapper has-icons" style="display: none">'; 18 } 19 var html = '<div class="highlight-and-share-wrapper">'; 20 if ( highlight_and_share.show_twitter && '' != highlight_and_share.twitter_username ) { 21 if ( highlight_and_share.icons == false ) { 22 html += '<div class="has_twitter" style="display: none;" data-type="twitter"><a href="https://twitter.com/intent/tweet?via=%username%&url=%url%&text=%text%" target="_blank"><i class="' + highlight_and_share.twitter_fa_class + '"></i> ' + highlight_and_share.tweet_text + '</a></div>'; 23 } else { 24 html += '<div class="has_twitter" style="display: none;" data-type="twitter"><a href="https://twitter.com/intent/tweet?via=%username%&url=%url%&text=%text%" target="_blank"><i class="' + highlight_and_share.twitter_fa_class + '"></i></a></div>'; 25 26 } 27 28 } else if( highlight_and_share.show_twitter && '' == highlight_and_share.twitter_username ) { 29 if ( highlight_and_share.icons == false ) { 30 html += '<div class="has_twitter" style="display: none;" data-type="twitter"><a href="https://twitter.com/intent/tweet?url=%url%&text=%text%" target="_blank"><i class="' + highlight_and_share.twitter_fa_class + '"></i> ' + highlight_and_share.tweet_text + '</a></div>'; 31 } else { 32 html += '<div class="has_twitter" style="display: none;" data-type="twitter"><a href="https://twitter.com/intent/tweet?url=%url%&text=%text%" target="_blank"><i class="' + highlight_and_share.twitter_fa_class + '"></i></a></div>'; 33 } 34 } 35 if ( highlight_and_share.show_facebook ) { 36 if ( highlight_and_share.icons == false ) { 37 //Note, you must be on a publicly accesible URL to use this button 38 if ( '0' === highlight_and_share.facebook_app_id ) { 39 html += '<div class="has_facebook" style="display: none;" data-type="facebook"><a href="https://www.facebook.com/sharer/sharer.php?u=%url%&t=%title%" target="_blank"><i class="' + highlight_and_share.facebook_fa_class + '"></i> ' + highlight_and_share.facebook_text + '</a></div>'; 40 } else { 41 html += '<div class="has_facebook" style="display: none;" data-type="facebook"><a href="https://www.facebook.com/dialog/share?app_id=' + highlight_and_share.facebook_app_id + '&display=popup&quote=%text%&href=%url%" target="_blank"><i class="' + highlight_and_share.facebook_fa_class + '"></i> ' + highlight_and_share.facebook_text + '</a></div>'; 42 } 43 44 } else { 45 if ( '0' === highlight_and_share.facebook_app_id ) { 46 html += '<div class="has_facebook" style="display: none;" data-type="facebook"><a href="https://www.facebook.com/sharer/sharer.php?u=%url%&t=%title%" target="_blank"><i class="' + highlight_and_share.facebook_fa_class + '"></i></a></div>'; 47 } else { 48 html += '<div class="has_facebook" style="display: none;" data-type="facebook"><a href="https://www.facebook.com/dialog/share?app_id=' + highlight_and_share.facebook_app_id + '&display=popup&quote=%text%&href=%url%" target="_blank"><i class="' + highlight_and_share.facebook_fa_class + '"></i></a></div>'; 49 } 50 51 } 52 } 53 if ( highlight_and_share.show_linkedin ) { 54 if ( highlight_and_share.icons == false ) { 55 //Note, you must be on a publicly accesible URL to use this button 56 html += '<div class="has_linkedin" style="display: none;" data-type="linkedin"><a href="https://www.linkedin.com/shareArticle?mini=true&url=%url%&title=%title%" target="_blank"><i class="' + highlight_and_share.linkedin_fa_class + '"></i> ' + highlight_and_share.linkedin_text + '</a></div>'; 57 } else { 58 html += '<div class="has_linkedin" style="display: none;" data-type="linkedin"><a href="https://www.linkedin.com/shareArticle?mini=true&url=%url%&title=%title%" target="_blank"><i class="' + highlight_and_share.linkedin_fa_class + '"></i></a></div>'; 59 } 60 } 61 62 //={URI-encoded URL of the page to pin}&media={URI-encoded URL of the image to pin}&description={optional URI-encoded description}" 63 if ( highlight_and_share.show_pinterest ) { 64 if ( highlight_and_share.icons == false ) { 65 //Note, you must be on a publicly accesible URL to use this button 66 html += '<div class="has_pinterest" style="display: none;" data-type="pinterest"><a href="http://pinterest.com/pin/create/button/?url=%url%&description=%title%" target="_blank"><i class="' + highlight_and_share.pinterest_fa_class + '"></i> ' + highlight_and_share.pinterest_text + '</a></div>'; 67 } else { 68 html += '<div class="has_pinterest" style="display: none;" data-type="pinterest"><a href="http://pinterest.com/pin/create/button/?url=%url%&description=%title%" target="_blank"><i class="' + highlight_and_share.pinterest_fa_class + '"></i></a></div>'; 69 } 70 } 71 72 if ( highlight_and_share.show_xing ) { 73 if ( highlight_and_share.icons == false ) { 74 html += '<div class="has_xing" style="display: none;" data-type="xing"><a href="https://www.xing.com/spi/shares/new?url=%url%" target="_blank"><i class="' + highlight_and_share.xing_fa_class + '"></i> ' + highlight_and_share.xing_text + '</a></div>'; 75 } else { 76 html += '<div class="has_xing" style="display: none;" data-type="xing"><a href="https://www.xing.com/spi/shares/new?url=%url%" target="_blank"><i class="' + highlight_and_share.xing_fa_class + '"></i></a></div>'; 77 } 78 } 79 80 if ( highlight_and_share.show_whatsapp ) { 81 if ( highlight_and_share.icons == false ) { 82 html += '<div class="has_whatsapp" style="display: none;" data-type="whatsapp"><a href="https://wa.me/?text=%text%' + ' - ' + highlight_and_share.from + ': ' + '%url%" target="_blank"><i class="' + highlight_and_share.whatsapp_fa_class + '"></i> ' + highlight_and_share.whatsapp_text + '</a></div>'; 83 } else { 84 html += '<div class="has_whatsapp" style="display: none;" data-type="whatsapp"><a href="https://wa.me/?text=%text%' + ' - ' + highlight_and_share.from + ': ' + '%url%" target="_blank"><i class="' + highlight_and_share.whatsapp_fa_class + '"></i></a></div>'; 85 } 86 } 87 88 if ( highlight_and_share.show_email ) { 89 if ( highlight_and_share.icons == false ) { 90 //Note, you must be on a publicly accesible URL to use this button 91 html += '<div class="has_email" style="display: none;" data-type="email" data-title="%title%" data-url="%url%"><a href="' + highlight_and_share.ajax_url + '" target="_blank"><i class="' + highlight_and_share.email_fa_class + '"></i> ' + highlight_and_share.email_text + '</a></div>'; 92 } else { 93 html += '<div class="has_email" style="display: none;" data-type="email" data-title="%title%" data-url="%url%"><a href="' + highlight_and_share.ajax_url + '" target="_blank"><i class="' + highlight_and_share.email_fa_class + '"></i></a></div>'; 94 } 95 } 96 html += '</div><!-- #highlight-and-share-wrapper -->'; 97 $( 'body' ).append( html ); 98 }; 99 100 //Initialize events 101 var js_content = highlight_and_share.content; 102 if ( '' == js_content ) return; 103 $( 'body' ).on( 'mouseup vmouseup', js_content, function( e ) { 104 e.stopPropagation(); 105 has_remove(); 106 var selection = window.getSelection(); 107 var text = selection.toString(); 108 this.title = ''; 109 110 if ( '' == text ) { 111 return; 112 } 113 114 //Get URL 115 this.href = $( this ).attr( 'data-url' ); 116 if (typeof href == typeof undefined || href == false) { 117 this.href = $( location ).attr( 'href' ); 118 } 119 120 //Get Title 121 this.title = $( this ).attr( 'data-title' ); 122 if (typeof this.title == typeof undefined || this.title == false) { 123 this.title = $( document ).attr( 'title' ); 124 } 125 126 has_display( text, this.title, this.href, e ); 127 } ); 128 129 $( 'body' ).on( 'mousedown vmousedown', function( e ) { 130 has_get_selection(); 131 } ); 132 document.addEventListener("selectionchange", function() { 133 has_get_selection(); 134 }, false); 135 136 $( 'body' ).on( 'click', '.has_twitter a', function( e ) { 137 e.preventDefault(); 138 if( highlight_and_share.customizer_preview ) { 139 return; 140 } 141 this.href = this.href.replace( '%text%', encodeURIComponent( has_selected_text ) ); 142 window.open( this.href,"tweethighlight","width=575,height=430,toolbar=false,menubar=false,location=false,status=false"); 143 has_remove(); 144 return false;
145 } ); 146 $( 'body' ).on( 'click', '.has_facebook a', function( e ) { 147 e.preventDefault(); 148 if( highlight_and_share.customizer_preview ) { 149 return; 150 } 151 this.href = this.href.replace( '%text%', encodeURIComponent( has_selected_text ) ); 152 window.open( this.href,"sharer","width=575,height=430,toolbar=false,menubar=false,location=false,status=false"); 153 has_remove(); 154 } ); 155 $( 'body' ).on( 'click', '.has_linkedin a', function( e ) { 156 e.preventDefault(); 157 if( highlight_and_share.customizer_preview ) { 158 return; 159 } 160 window.open( this.href,"linkedin","width=575,height=430,toolbar=false,menubar=false,location=false,status=false"); 161 has_remove(); 162 } ); 163 $( 'body' ).on( 'click', '.has_pinterest a', function( e ) { 164 e.preventDefault(); 165 if( highlight_and_share.customizer_preview ) { 166 return; 167 } 168 window.open( this.href,"pinterest","width=575,height=430,toolbar=false,menubar=false,location=false,status=false"); 169 has_remove(); 170 } ); 171 $( 'body' ).on( 'click', '.has_xing a', function( e ) { 172 e.preventDefault(); 173 if( highlight_and_share.customizer_preview ) { 174 return; 175 } 176 window.open( this.href,"xing","width=575,height=430,toolbar=false,menubar=false,location=false,status=false"); 177 has_remove(); 178 } ); 179 $( 'body' ).on( 'click', '.has_whatsapp a', function( e ) { 180 e.preventDefault(); 181 if( highlight_and_share.customizer_preview ) { 182 return; 183 } 184 this.href = this.href.replace( '%text%', encodeURIComponent( has_selected_text ) ); 185 window.open( this.href,"whatsapp","width=575,height=430,toolbar=false,menubar=false,location=false,status=false"); 186 has_remove(); 187 } ); 188 $( 'body' ).on( 'click', '.has_email a', function( e ) { 189 e.preventDefault(); 190 if( highlight_and_share.customizer_preview ) { 191 return; 192 } 193 //Get URL 194 var data_href = decodeURIComponent( $( this ).parent().attr( 'data-url' ) ); 195 196 //Get Title 197 var data_title = decodeURIComponent( $( this ).parent().attr( 'data-title' ) ); 198 var subject = highlight_and_share.email_subject_text; 199 subject = subject.replace( '%title%', data_title ); 200 var html = ''; 201 html += '<div class="has_sharing_email">'; 202 html += '<div class="has_sharing_email_form_wrapper">'; 203 html += '<form action="" method="post" id="has_email_form" class="has_email_form">'; 204 html += '<input type="hidden" name="has_email_nonce" value="' + highlight_and_share.nonce + '" />'; 205 html += '<label for="has_target_email">' + highlight_and_share.email_send_email + '</label>'; 206 html += '<input type="email" name="has_target_email" id="has_target_email" />'; 207 html += '<label for="has_source_name">' + highlight_and_share.email_your_name + '</label>'; 208 html += '<input type="text" name="has_source_name" id="has_source_name" value="' + highlight_and_share.email_your_name_value + '" />'; 209 html += '<label for="has_email_subject">' + highlight_and_share.email_subject + '</label>'; 210 html += '<input type="text" class="has_email_subject" name="has_email_subject" id="has_email_subject" value="' + subject + '" />'; 211 html += '<label for="has_source_email">' + highlight_and_share.email_from + '</label>'; 212 html += '<input type="email" name="has_source_email" id="has_source_email" value="' + highlight_and_share.email_from_value + '" />'; 213 html += '<input type="hidden" name="has_source_title" class="has_source_title" value="' + data_title + '" />'; 214 html += '<input type="hidden" name="has_source_url" class="has_source_url" value="' + data_href + '" />'; 215 html += '<input type="hidden" name="has_ajax_action" value="has_form_submission" />'; 216 html += '<input type="submit" value="' + highlight_and_share.email_send + '" class="has_sharing_send" id="has_sharing_send" />'; 217 html += '<a rel="nofollow" href="#cancel" class="has_sharing_cancel" id="has_sharing_cancel" style="display: inline;">' + highlight_and_share.email_cancel + '</a>'; 218 html += '<img style="float:right; display: none;" class="has_sharing_loading" src="' + highlight_and_share.email_loading + '" />'; 219 html += '<div class="has_errors" style="display: none"></div>'; 220 html += '</form>'; 221 html += '</div><!-- .has_sharing_email_form_wrapper -->'; 222 html += '<div class="has_success_response" style="display: none;">'; 223 html += '<div class="has_response_title">'; 224 html += '</div><!-- .has_response_title -->'; 225 html += '<div class="has_success_response_body">'; 226 html += '</div><!-- .has_success_response_body -->'; 227 html += '<div class="has_success_response_close">' 228 html += '<a rel="nofollow" href="#cancel" class="has_sharing_cancel" id="has_sharing_cancel" style="display: inline;">' + highlight_and_share.email_close + '</a>'; 229 html += '</div><!-- .has_success_response_close -->'; 230 html += '</div><!-- .has_success_response -->'
231 232 html += '</div><!-- #has_sharing_email -->'; 233 234 var html_jquery = jQuery(html); 235 swal( 236 { 237 title: highlight_and_share.email_share, 238 html: html_jquery.html(), 239 customClass: 'has-email-mobie', 240 showCloseButton: false, 241 showCancelButton: false, 242 showConfirmButton: false, 243 width: '320px', 244 } 245 ); 246 jQuery('#has_target_email').focus(); 247 } ); 248 249 // Email Cancel 250 $( 'body' ).on( 'click', 'a.has_sharing_cancel', function( e ) { 251 swal.close(); 252 } ); 253 254 // Email Send 255 $( 'body' ).on( 'click', 'input.has_sharing_send', function( e ) { 256 257 e.preventDefault(); 258 259 var $emails = $('.has_sharing_email_form_wrapper:first'); 260 var $errors = $emails.find('.has_errors:first'); 261 $emails.find('.has_sharing_loading').css( 'display', 'none' ); 262 $errors.css( 'display', 'none' ); 263 264 // Check subject 265 var subject = $emails.find('#has_email_subject').val().trim(); 266 if ( '' == subject ) { 267 $errors.html( highlight_and_share.email_subject_error ); 268 $errors.slideDown(); 269 return; 270 } 271 272 // Check Send to Email Address 273 var emails_to = $emails.find('#has_target_email').val().trim(); 274 if( '' == emails_to ) { 275 $errors.html( highlight_and_share.email_email_to ); 276 $errors.slideDown(); 277 return; 278 } 279 280 // Check From Email Address 281 var emails_from = $emails.find('#has_source_email').val().trim(); 282 if( '' == emails_from ) { 283 $errors.html( highlight_and_share.email_email_from ); 284 $errors.slideDown(); 285 return; 286 } 287 288 // Check Name 289 var emails_name = $emails.find('#has_source_name').val().trim(); 290 if( '' == emails_name ) { 291 $errors.html( highlight_and_share.email_email_name ); 292 $errors.slideDown(); 293 return; 294 } 295 296 // Everything is fine, show loading icon 297 $emails.find('.has_sharing_loading').css( 'display', 'block' ); 298 299 // Show sending icon and disable it 300 $sending_button = $emails.find('.has_sharing_send'); 301 $sending_button.val( highlight_and_share.email_sending ); 302 $sending_button.prop( 'disabled', true ); 303 304 // Serialize data 305 var form_data = $emails.find('#has_email_form').serialize(); 306 307 // Send Ajax data 308 $.post( highlight_and_share.ajax_url, { data: form_data, action: 'has_form_submission' }, function( response ) { 309 if( response.errors ) { 310 $errors.html( response.message ); 311 $errors.slideDown(); 312 $sending_button.val( highlight_and_share.email_send ); 313 $sending_button.prop( 'disabled', false ); 314 $emails.find('.has_sharing_loading').css( 'display', 'none' ); 315 } else { 316 $emails.css( 'display', 'none' ); 317 $emails.find( '#has_target_email' ).val(''); 318 $emails.find( '#has_source_name' ).val( response.message_source_name ); 319 $emails.find( '#has_email_subject' ).val( response.message_subject ); 320 $emails.find( '#has_source_email' ).val( response.message_source_email ); 321 $emails.parent().find( '.has_response_title' ).html( response.message_title ); 322 $emails.parent().find( '.has_success_response_body' ).html( response.message_body ); 323 $emails.parent().find( '.has_success_response' ).css( 'display', 'block' ); 324 } 325 }, 'json' ); 326 327 } ); 328 329 var has_get_selection = function() { 330 var selection = window.getSelection(); 331 var text = selection.toString(); 332 if ( '' == text ) { 333 return; 334 } else { 335 has_selected_text = text; 336 } 337 }; 338 339 var has_display = function( text, title, link, e ) { 340 if ( false == highlight_and_share.show_twitter && false == highlight_and_share.show_facebook && false == highlight_and_share.show_linkedin && false == highlight_and_share.show_pinterest && false == highlight_and_share.show_email ) { 341 return; 342 } 343 344 wrapper_clone = $( '.highlight-and-share-wrapper:last' ).clone(); 345 var wrapper_x = e.pageX - 30; 346 var wrapper_y = e.pageY - 70; 347 if ( highlight_and_share.mobile ) { 348 wrapper_x = e.pageX; 349 wrapper_y = e.pageY + 20; 350 } 351 352 wrapper_clone.css( { position: 'absolute', display: 'block', left: wrapper_x, top: wrapper_y, width: 'auto', height: 'auto', 'z-index': 10000 } ); 353 354 $children = wrapper_clone.find( '.has_whatsapp, .has_xing, .has_pinterest, .has_linkedin, .has_facebook, .has_twitter, .has_email' ); 355 $.each( $children, function( index, item ) { 356 var div = $( this ); 357 var url = div.find( 'a' ).attr( 'href' ); 358 url = url.replace( '%url%', encodeURIComponent( link ) ); 359 url = url.replace( '%username%', encodeURIComponent( highlight_and_share.twitter_username ) ); 360 url = url.replace( '%title%', encodeURIComponent( title ) ); 361 var title_attr = div.attr('data-title'); 362 if (typeof title_attr !== typeof undefined && title_attr !== false) { 363 title_attr = title_attr.replace( '%title%', encodeURIComponent( title ) ); 364 div.attr('data-title', title_attr); 365 } 366 var url_attr = div.attr('data-url'); 367 if (typeof url_attr !== typeof undefined && url_attr !== false) { 368 url_attr = url_attr.replace( '%url%', encodeURIComponent( link ) ); 369 div.attr('data-url', url_attr); 370 } 371 div.find( 'a' ).attr( 'href', url ); 372 var css_class = div.attr( 'class' ); 373 wrapper_clone.find( '.' + css_class ).attr( 'style', 'display: inline-block' ).html( div.html() ); 374 } ); 375 376 //Add to document 377 $( 'body' ).append( wrapper_clone ); 378 }; 379 if ( highlight_and_share.show_twitter == true || highlight_and_share.show_facebook == true || highlight_and_share.show_linkedin == true || highlight_and_share.show_pinterest == true || highlight_and_share.show_email == true) { 380 has_load_html(); 381 } 382} );
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.