/*! * Aloha Editor * Author & Copyright (c) 2010 Gentics Software GmbH * aloha-sales@gentics.com * Licensed unter the terms of http://www.aloha-editor.com/license.html */ define( ['aloha','aloha/plugin', 'aloha/floatingmenu', 'i18n!attributes/nls/i18n', 'i18n!aloha/nls/i18n', 'css!attributes/css/attributes.css'], function(Aloha, Plugin, FloatingMenu, i18n, i18nCore) { var jQuery = Aloha.jQuery, $ = jQuery, GENTICS = window.GENTICS, Aloha = window.Aloha; return Plugin.create('attributes', { _constructor: function(){ this._super('attributes'); }, // namespace prefix for this plugin // Pseudo-namespace prefix ns : 'aloha-attributes', uid : 'attributes', // namespaced classnames nsClasses : {}, supplant : function(str, obj) { return str.replace(/\{([a-z0-9\-\_]+)\}/ig, function (str, p1, offset, s) { var replacement = obj[p1] || str; return (typeof replacement == 'function') ? replacement() : replacement; }); }, /** * Wrapper to all the supplant method on a given string, taking the * nsClasses object as the associative array containing the replacement * pairs * * @param {String} str * @return {String} */ renderTemplate : function(str) { return (typeof str === 'string') ? this.supplant(str, this.nsClasses) : str; }, /** * Generates a selector string with this component's namepsace prefixed the * each classname * * Usage: * nsSel('header,', 'main,', 'foooter ul') * will return * ".aloha-myplugin-header, .aloha-myplugin-main, .aloha-mypluzgin-footer ul" * * @return {String} */ nsSel : function() { var strBldr = [], prx = this.ns; $.each(arguments, function () { strBldr.push('.' + (this == '' ? prx : prx + '-' + this)); }); return strBldr.join(' ').trim(); }, /** * Generates s string with this component's namepsace prefixed the each * classname * * Usage: * nsClass('header', 'innerheaderdiv') * will return * "aloha-myplugin-header aloha-myplugin-innerheaderdiv" * * @return {String} */ nsClass : function (){ var strBldr = [], prx = this.ns; $.each(arguments, function () { strBldr.push(this == '' ? prx : prx + '-' + this); }); return strBldr.join(' ').trim(); }, config: ['true'], //activeOn: 'a,span,div,p,q,blockquote,h1,h2,h3,h4,h5,h6,em,i,b', activeOn : function(effective) { if (typeof this.settings.disabled === 'boolean' && this.settings.disabled) { return false; } if (typeof effective != 'undefined' && effective != null) { return true; } return false; }, /** * Initialize the plugin */ init: function () { var that = this; this.nsClasses = { newattributename : this.nsClass('newattributename'), newattributebutton : this.nsClass('newattributebutton'), newattributewert : this.nsClass('newattributewert'), container : this.nsClass('container'), attribcontainer : this.nsClass('attribcontainer'), newattribute : this.nsClass('newattribute'), item : this.nsClass('item'), element : this.nsClass('element'), iteminput : this.nsClass('iteminput') }; if ( typeof this.settings.activeOn !== 'undefined') { this.activeOn = this.settings.activeOn; } Aloha.ready( function (ev, sidebars) { that.initSidebar(Aloha.Sidebar.right); }); }, getSidebarContent: function() { return this.renderTemplate( '