This repository was archived by the owner on Mar 30, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
This repository was archived by the owner on Mar 30, 2018. It is now read-only.
Anybody have a clean DSL like this for the ember-medium-insert-plugin to add new addons? #3
Copy link
Copy link
Open
Description
Would be awesome to have like a simple DSL for it...
Something like this structure, but it somehow adds a new ember-medium-insert-plugin addon.
I understand the structure of an insert-plugin addon is something like this since it's basically jQuery I think...
;(function ($, window, document, undefined) {
'use strict';
/** Default values */
var pluginName = 'mediumInsert',
addonName = 'CustomAddon', // first char is uppercase
defaults = {
label: '<span class="fa fa-plus-circle"></span>'
};
/**
* Custom Addon object
*
* Sets options, variables and calls init() function
*
* @constructor
* @param {DOM} el - DOM element to init the plugin on
* @param {object} options - Options to override defaults
* @return {void}
*/
function CustomAddon (el, options) {
this.el = el;
this.$el = $(el);
this.templates = window.MediumInsert.Templates;
this.core = this.$el.data('plugin_'+ pluginName);
this.options = $.extend(true, {}, defaults, options);
this._defaults = defaults;
this._name = pluginName;
this.init();
}
/**
* Initialization
*
* @return {void}
*/
CustomAddon.prototype.init = function () {
this.events();
};
/**
* Event listeners
*
* @return {void}
*/
CustomAddon.prototype.events = function () {
};
/**
* Get the Core object
*
* @return {object} Core object
*/
CustomAddon.prototype.getCore = function () {
return this.core;
};
/**
* Add custom content
*
* This function is called when user click on the addon's icon
*
* @return {void}
*/
CustomAddon.prototype.add = function () {
};
/** Addon initialization */
$.fn[pluginName + addonName] = function (options) {
return this.each(function () {
if (!$.data(this, 'plugin_' + pluginName + addonName)) {
$.data(this, 'plugin_' + pluginName + addonName, new CustomAddon(this, options));
}
});
};
})(jQuery, window, document);Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels