/* eslint-env jquery */ export default class SharePopup { constructor( selector, intWidth, intHeight, blnResize ) { this.selector = selector; this.intWidth = intWidth || '500'; this.intHeight = intHeight || '400'; this.blnResize = ( blnResize ? 'yes' : 'no' ); this.sharePopup = this.sharePopup.bind( this ); this.init = this.init.bind( this ); this.init(); } init() { const that = this; $( this.selector ).each( function() { $( this ).find( 'a' ).each( function() { const item = $( this ); item.on( 'click', ( e ) => { that.sharePopup( item, e ); } ); } ); } ); } sharePopup( item, e ) { e.preventDefault(); const strTitle = ( ( typeof item.attr( 'title' ) !== 'undefined' ) ? item.attr( 'title' ) : 'Social Share' ), strParam = 'width=' + this.intWidth + ',height=' + this.intHeight + ',resizable=' + this.blnResize; return window.open( item.attr( 'href' ), strTitle, strParam ).focus(); } }