JSFiddle - React, Tailwind, and code Playground

by Eric Howe

HTML

<div id="pancakes"></div>

CoffeeScript

(($, window) ->
    'use strict'
    pluginName = 'fullscreen'
    dataKey    = "plugin_#{pluginName}"
    
    class Plugin
        constructor: (@element, @options) -> console.log('attaching...', @element)
        destroy: -> console.log('destroying...', @element)

    $.fn[pluginName] = (args...) ->
        @each ->
            plugin = $.data(@, dataKey)
            if typeof args[0] == 'string'
                plugin?[args[0]]?()
            else if !plugin
                $.data(@, dataKey, new Plugin(@, args[0]))
) jQuery, window

$('#pancakes').fullscreen('not_attached_yet')
$('#pancakes').fullscreen()
$('#pancakes').fullscreen('no_such_method')
$('#pancakes').fullscreen('destroy')