Link to home
Start Free TrialLog in
Avatar of Bruce Gust
Bruce GustFlag for United States of America

asked on

What is this Boilerplate doing?

I'm trying to track down where the database logic is coming from on a page I've been tasked with troubleshooting.

This particular app makes use of some Boilerplates and some other JQuery logic which I'm trying to get my brain around.

Here's what I understand about Boilerplates and IIFE: http://brucegust.com/adm/terms.php

Where I'm a little puzzled with this particular page is I'm trying to figure out what it does. However obvious that might be to the trained eye, I'm looking for something that references or even implies a SELECT somewhere and I don't see how that would happen with this page.

Here's the code:

/**
 * Created by nhill on 9/12/2016.
 */
;( function( $, window, document, undefined ) {

    "use strict";
    // Create the defaults once
    var pluginName = "widgetIncentives";
    var defaults = {
    };

    // The actual plugin constructor
    function Plugin ( element, options ) {
        var plugin = this;
        plugin.element = element;
        plugin.$element = $(element);
        plugin.settings = $.extend( {}, defaults, options );
        plugin._defaults = defaults;
        plugin._name = pluginName;
        plugin.init();
    }
    // Avoid Plugin.prototype conflicts
    $.extend( Plugin.prototype, {

        init: function(){
            var plugin = this;
            plugin.$element.find('a.popup-trigger').magnificPopup({'type': 'ajax'});
        }

    });


    // A really lightweight plugin wrapper around the constructor,
    // preventing against multiple instantiations
    $.fn[pluginName] = function(options,additionaloptions) {
        return this.each(function() {
            if (!$.data(this, 'plugin_' + pluginName)) {
                $.data(this, 'plugin_' + pluginName, new Plugin(this, options));
            }
            else if (Plugin.prototype[options]) {
                $.data(this, 'plugin_' + pluginName)[options](additionaloptions);
            }
        });
    }

} )( jQuery, window, document );

$(function(){
    $('.w-Incentives').widgetIncentives();
});

Open in new window


For lack of a better way of putting it, what's this page doing?
ASKER CERTIFIED SOLUTION
Avatar of ste5an
ste5an
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Bruce Gust

ASKER

Thanks, friend! That helped!