JSFiddle - React, Tailwind, and code Playground

by pavel_krupala

HTML

<p>Hello</p>
<p>World</p>

JavaScript

/**
	jQuery FaceTuner Layer Plugin
*/

(function($) {
    var PLUGIN_NAME = "ftlayer";
    /** DEFAULT PLUGIN SETTINGS *******************************************************/
    var settings = {
        foo: 'bar'
    };
    
    /** ALL PUBLIC PLUGIN METHODS *****************************************************/
    var methods = {
        init: function(options) {
            return this.each(function() {
                var $this = $(this);                
                console.log('init called');
                var data = $this.data(PLUGIN_NAME+"_plugin")                
                var opts = $.extend({}, settings, options);
                
                // If the plugin has not been initialized yet...
                if (! data) {		// do the setup                    
                    $this.data(PLUGIN_NAME+"_plugin", { options: opts });
                    data = $this.data(PLUGIN_NAME+"_plugin");
                    try {
                        var img = $.extend({}, {
                            source: options.source,
                            width: options.width,
                            height: options.height                        
                        });
                        setData('image', img);
                        // call some method here...
                        methods.run.call(this);
                    } catch (e) {
                        alert('data source, width, height not defined correctly');
                    }
                    
                }
                
               
            });
        },
        run: function(options) {
            var $this = $(this);
            console.log('run called');
            var data = getData($this, 'image');
            //$this.append(" - " + data.options.foo);
            console.log(data);
            console.log('data: ', data.source, data.width, data.height);
            
            // check if draggable and resizable are present
            if...