/**
* @author Rob Gietema
* @copyright Copyright © 2009, Four Digits, All rights reserved.
*/
(function() {
// Load plugin specific language pack
//tinymce.PluginManager.requireLangPack('flags');
tinymce.create('tinymce.plugins.DefinitionList', {
_previousNode : null,
/**
* Initializes the plugin, this will be executed after the plugin has been created.
* This call is done before the editor instance has finished it's initialization so use the onInit event
* of the editor instance to intercept that event.
*
* @param {tinymce.Editor} ed Editor instance that the plugin is initialized in.
* @param {string} url Absolute URL to where the plugin is located.
*/
init : function(ed, url) {
var t = this;
// Register commands
ed.addCommand('mceInsertDefinitionList', function(ui, v) {
t._execCommand(ed, v);
});
// Register flags button
ed.addButton('definitionlist', {
title : 'Definition list',
cmd : 'mceInsertDefinitionList',
image : url + '/img/definitionlist.gif'
});
ed.onNodeChange.add(this._nodeChange, this);
ed.onKeyUp.add(this._keyUp, this);
},
_execCommand : function(ed, v) {
function ReplaceTag(curelm, remove) {
// changing to a different node type
var newelm;
if (remove) {
b = ed.selection.getBookmark();
var html = "";
newelm = ed.getDoc().createElement('p');
for (var c=0; c';
newelm.innerHTML = html;
curelm.parentNode.replaceChild(newelm, curelm);
ed.selection.moveToBookmark(b);
} else {
var dl = ed.getDoc().createElement('dl');
newelm = ed.getDoc().createElement('dt');
for (var c=0; c