/** * A jQuery plugin to do nascar buttons. */ jQuery( document ).ready( function() { // This is the wrapper class for each group of share buttons. var el = jQuery( '.lxb_nascar_js' ); jQuery( el ).lxbNascar(); }); ( function ( $ ) { $.fn.lxbNascar = function( options ) { // For each group of share buttons... return this.each( function() { // Store that for later. var that = this; // Grab the share links in this group. var links = jQuery( this ).find( '.lxb_nascar_share' ); // We're going to assume that the popup windows should always have the same specs. var specs = 'scrollbars=yes,width=800,height=400'; // We're going to assume that the popup windows should always have the same target. var target = '_blank'; // This will hold a string of data attributes that we'll grab from the link and pass to the service we are sharing to. var dataStr = ''; // When a link is clicked... jQuery( links ).on( 'click', function( event ) { // Grab the data for this link. var data = $( this ).data(); // The email link does not share to anything, so bail. if( ! data.hasOwnProperty( 'share_to' ) ) { return; } // Don't navigate the page. event.preventDefault(); // To what url do we share? var shareTo = data.share_to; // Grab the data as params. var dataStr = $.param( data ); var fullUrl = shareTo + '?' + dataStr; // Do a popup window. var popUp = window.open( fullUrl, target, specs ); popUp.focus(); }); }); } }( jQuery ) );