jQuery Plugin template

by lollero

HTML

<div>asdasd</div> 
<div>asdasd as</div> 
<div>asdasd a </div> 
<div>asdasd</div>

JavaScript

(function($) {

    $.fn.myPlugin = function( options ) {

        return this.each(function() {

            // A basket of blueberriess
            x = {},
            // This element is an image... maybe....
            x.this = $(this),
            // Looks for data in x.image.
            x.thisD = x.this.data(),
            // Overriding options happens in this order:
            // - Default options
            // - Custom options
            // - Data-attribute
            x.o = $.extend( true, {}, $.fn.myPlugin.defaults, options, x.thisD );

            
            // $.fn.myPlugin.destroy( x );

            // Css styling using javascript.....
            // This module is not necessary to use, if you don't want to
    /**/    typeof modules.styling == 'function' && modules.styling( x );


        }); // each();

    }; // sic();

    /*
    ===================
      DEFAULT OPTIONS
    ===================
    */
    $.fn.myPlugin.defaults = {

        showme: {
            text: null,
            posinvert: false,
            background: null, // CSS file. Color: #000.
            color: null, // CSS file. Color: #fff
            opacity: 0.8
        }

    }; // Default options


    // EFFECTS START HERE
    var modules = {
        styling: function( x ) {
            x.this.html( x.this.html() + ' - YATTAAA' );
        }

    };
    
    $.fn.myPlugin.destroy = function(txt) {
        return alert('as');
    };


})(jQuery);



$(function() {
    
    $('div').myPlugin.destroy();

});