UNPKG

jquery-my-plugin

Version:

Made with create-jquery-plugin

10 lines 2.17 kB
"use strict";function _classCallCheck(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function _defineProperties(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,_toPropertyKey(i.key),i)}}function _createClass(t,e,n){return e&&_defineProperties(t.prototype,e),n&&_defineProperties(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function _toPropertyKey(t){t=_toPrimitive(t,"string");return"symbol"===_typeof(t)?t:String(t)}function _toPrimitive(t,e){if("object"!==_typeof(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0===n)return("string"===e?String:Number)(t);n=n.call(t,e||"default");if("object"!==_typeof(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}function _typeof(t){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)} /*! * jquery-my-plugin 1.0.0 * Made with create-jquery-plugin * * Created by ashraf <ashraf.alqadi@atlascrisis.ae> * * @license MIT */ !function(n){"function"==typeof define&&define.amd?define(["jquery"],n):"object"===("undefined"==typeof module?"undefined":_typeof(module))&&module.exports?module.exports=function(t,e){return void 0===e&&(e="undefined"!=typeof window?require("jquery"):require("jquery")(t)),n(e),e}:n(jQuery)}(function(i){var o={myStyle:"my-style1"},r=function(){function n(t,e){_classCallCheck(this,n),this.options=i.extend(!0,{},o,e),this.main=i(t),this._init()}return _createClass(n,[{key:"_init",value:function(){this.main.addClass(this.options.myStyle).html(this.options.myStyle)}}]),n}();i.fn.myPlugin=function(t){var e,n="myPlugin";return void 0===t||"object"===_typeof(t)?this.each(function(){i.data(this,n)||i.data(this,n,new r(this,t))}):"string"==typeof t&&"_"!==t[0]&&"init"!==t?(e=i.data(this[0],n),"destroy"===t&&i.data(this,n,null),e instanceof r&&"function"==typeof e[t]?e[t].apply(e,Array.prototype.slice.call(arguments,1)):this):void 0}});