/**
 * editor_plugin_src.js
 *
 * Copyright 2012, Grégory Soutadé
 * Released under LGPL License.
 *
 */

(function() {
    tinymce.create('tinymce.plugins.DynastieColor', {
	init : function(ed, url) {
	    var t = this, css = tinymce.explode(ed.settings.content_css);

	    t.editor = ed;

	    // Force absolute CSS urls	
	    tinymce.each(css, function(u, k) {
		css[k] = ed.documentBaseURI.toAbsolute(u);
	    });

	    ed.addCommand('mceDynastieColor', function() {
		ed.windowManager.open({
		    file : ed.getParam("plugin_dynastiecolor_pageurl", url + "/dynastiecolor.html"),
		    width : parseInt(ed.getParam("plugin_dynastiecolor_width", "700")),
		    height : parseInt(ed.getParam("plugin_dynastiecolor_height", "800")),
		    resizable : "yes",
		    scrollbars : "yes",
		    popup_css : css ? css.join(',') : ed.baseURI.toAbsolute("themes/" + ed.settings.theme + "/skins/" + ed.settings.skin + "/content.css"),
		}, {
		    base : ed.documentBaseURI.getURI()
		});
	    });

	    ed.addButton('dynastiecolor', {title : 'Insert code', cmd : 'mceDynastieColor', image : url + "/img/dynastiecolor.png"});
	},

	getInfo : function() {
	    return {
		longname : 'DynastieColor',
		author : 'Grégory Soutadé',
		authorurl : 'http://soutade.fr',
		infourl : 'http://indefero.soutade.fr/p/dynastie',
		version : tinymce.majorVersion + "." + tinymce.minorVersion
	    };
	}
    });

    // Register plugin
    tinymce.PluginManager.add('dynastiecolor', tinymce.plugins.DynastieColor);
})();