/* plugin.js is part of Aloha Editor project http://aloha-editor.org * * Aloha Editor is a WYSIWYG HTML5 inline editing library and editor. * Copyright (c) 2010-2012 Gentics Software GmbH, Vienna, Austria. * Contributors http://aloha-editor.org/contribution.php * * Aloha Editor is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or any later version. * * Aloha Editor is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * As an additional permission to the GNU GPL version 2, you may distribute * non-source (e.g., minimized or compacted) forms of the Aloha-Editor * source code without the copy of the GNU GPL normally required, * provided you include this license notice and a URL through which * recipients can access the Corresponding Source. */ define([ 'aloha/core', 'jquery', 'util/class', 'aloha/pluginmanager', 'aloha/console' ], function ( Aloha, jQuery, Class, PluginManager, console ) { "use strict"; /** * Abstract Plugin Object * @namespace Aloha * @class Plugin * @constructor * @param {String} pluginPrefix unique plugin prefix */ var Plugin = Class.extend({ name: null, /** * contains the plugin's default settings object * @cfg {Object} default settings for the plugin */ defaults: {}, /** * contains the plugin's settings object * @cfg {Object} settings the plugins settings stored in an object */ settings: {}, /** * Names of other plugins which must be loaded in order for this plugin to * function. * @cfg {Array} */ dependencies: [], _constructor: function (name) { /** * Settings of the plugin */ if (typeof name !== "string") { console.error('Cannot initialise unnamed plugin, skipping'); } else { this.name = name; } }, /** * @return true if dependencies satisfied, false otherwise */ checkDependencies: function () { var plugin = this; var satisfied = true; jQuery.each(plugin.dependencies, function (i, dependency) { if (!Aloha.isPluginLoaded(dependency.toString())) { satisfied = false; console.error('plugin.' + plugin.name, 'Required plugin "' + dependency + '" not found.'); return false; } }); return satisfied; }, /** * Init method of the plugin. Called from Aloha Core to initialize this plugin * @return void * @hide */ init: function () {}, /** * Get the configuration settings for an editable obj. * Handles both conf arrays or conf objects *
* "list": { * config : [ 'b', 'h1' ], * editables : { * '#title' : [ ], * 'div' : [ 'b', 'i' ], * '.article' : [ 'h1' ] * } * } ** * The hash keys of the editables are css selectors. For a * *
** * the selectors 'div' and '.article' match and the returned configuration is * *content*
* [ 'b', 'i', 'h1'] ** * The '#title' object would return an empty configuration. * *
* [ ] ** * All other objects would get the 'config' configuration. If config is not set * the plugin default configuration is returned. * *
* [ 'b', 'h1'] *
* "image": { * config : { 'img': { 'max_width': '50px', * 'max_height': '50px' }}, * editables : { * '#title': {}, * 'div': {'img': {}}, * '.article': {'img': { 'max_width': '150px', * 'max_height': '150px' }} * } * } ** The '#title' object would return an empty configuration.
* {'img': { 'max_width': '150px', * 'max_height': '150px' }} **