import $ from 'jquery' ; import { ExampleService } from './example-service' ; $ . fn . examplePlugin = Object . assign < ExamplePluginFunction , ExamplePluginGlobalOptions > ( function ( this , options ) : JQuery { options = $ . extend ( { } , $ . fn . examplePlugin . options , options ) ; if ( ! options . outputSelector ) { console . error ( 'Example plugin options are missing required parameter "outputSelector": ' , JSON . stringify ( options ) ) ; return this ; } let exampleService = new ExampleService ( ) ; this . click ( function ( event ) { let messageText = exampleService . getExampleMessage ( event . currentTarget . textContent ) ; let messageElement = $ ( '<p>' + messageText + '</p>' ) ; if ( options . outputColor ) { messageElement . css ( 'color' , options . outputColor ) ; } $ ( options . outputSelector ) . append ( messageElement ) ; } ) ; return this ; } , { options : { outputSelector : null } } ) ;