jquery default style-color-amd Support

by HYEONGJINKIM

HTML

<div id="plugin">sample</div>

JavaScript

;(function(factory) {
    'use strict';
	
    if (typeof define === 'function' && define.amd) {	
        define(['jquery'], factory); // AMD
    } else if (typeof exports === 'object') {	
        factory(require('jquery')); // CommonJS
    } else {	
        factory(jQuery); // Browser globals
    }
})(function ( $ ) {
//;(function($, window, document, undefined) {
  var pluginName = "color",
    defaults = {
      color: "#556b2f",
      backgroundColor: "white"
    };

  function Plugin(element, options) {
    this.element = element;
    this.welement = $(this.element);
    this.options = $.extend({}, defaults, options);

    this._defaults = defaults;
    this._name = pluginName;

    this.init();
  }

  Plugin.prototype = {
    init: function() {
      this.applyColor();
    },
    applyColor: function() {
      this.welement.css(this.options);
    }
  };

  $.fn[pluginName] = function(options) {
    return this.each(function() {
      if (!$.data(this, "plugin_" + pluginName)) {
        $.data(this, "plugin_" + pluginName,
          new Plugin(this, options));
      }
    });
  };
//})(jQuery, window, document);
});

$(function() {
  $("#plugin").color();
  /*$("#plugin").color({
    color: "green",
    backgroundColor: "red"
  });*/
});