﻿/*---------------------------------------------------------------+
 | Change names of formatting options for smaller blocks of text |
 +---------------------------------------------------------------*/

tinyMCE.addI18n('', {
	theme_p : 'Normal',
	theme_h3 : 'Subhead'
});

/*-----------------------------+
 | Configuration: static pages |
 +-----------------------------*/

var defaultTinyMCE = $H({
    apply_source_formatting: true,
    content_css: "/styles/master.css,/styles/tinymce.css",
	editor_selector : "", //needs to be defined in clones
	fix_list_elements : true,
	fix_nesting : true,
	fix_table_elements : true,
	height : "600",
	mode : "textareas",
	plugins : "advanchor,preview,spellchecker,imagemanager,documentmanager,advlink,media,table,paste",
	spellchecker_rpc_url:'TinyMCE.ashx?module=SpellChecker',
	tab_focus : ":prev,:next",
	theme : "advanced",
	theme_advanced_blockformats : "p,h2,h3,h4,h5,h6,blockquote",
	theme_advanced_buttons1: "formatselect,separator,"
    + "undo,redo,separator,"
    + "bold,italic,separator,"
    + "bullist,numlist,separator,"
    + "sub,sup,separator,"
    + "indent,outdent,separator,"
    + "justifyleft,justifycenter,justifyright,separator,"
    + "link,unlink,anchor,separator,"
    + "imagemanager,documentmanager,media,charmap",
	theme_advanced_buttons2: "tablecontrols,separator,"
	+ "hr,separator,"
    + "cleanup,code,spellchecker",
	theme_advanced_buttons3 : "",
	theme_advanced_styles : "Reset=;Left pullquote=pull-l;Right pullquote=pull-r;Small grey text=mute",
	theme_advanced_toolbar_location : "top",
	theme_advanced_resizing : true,
	theme_advanced_path : false,
	theme_advanced_toolbar_align : "left",
	theme_advanced_resize_horizontal : false,
	theme_advanced_statusbar_location : "bottom",
	remove_script_host : true,
	relative_urls: false,
	// http://wiki.moxiecode.com/index.php/TinyMCE:Configuration/valid_child_elements
	valid_child_elements: "a[%istrict_na|#text],"
    + "abbr/acronym/caption/cite/code/del/dfn/em/h2/h3/h4/h5/h6/ins/kbd/pre/strong/sub/sup/th[%btrans|%istrict|#text],"
    + "blockquote[%bstrict],"
    + "dl[dd|dt],dd/div/dt/li/td[%btrans|%istrict|#text],"
    + "object[embed|param],ol/ul[li],"
    + "li/p[br|ol|ul|%btrans|%istrict|#text],"
    + "table[caption|tbody|td|tfoot|thead|tr],tbody/tfoot/thead[tr],tr[td|th]",
    // http://wiki.moxiecode.com/index.php/TinyMCE:Configuration/valid_elements
    valid_elements : "-a[class|href|id|title|alt|target],-abbr[title],-acronym[title],"
    + "-blockquote[style],br,"
    + "-caption,-cite,-code,"
    + "-del,-dfn[title],div[class|id],dl,dd[class],dt,"
    + "-em/i,embed[*],"
    + "-h1[id|style],-h2[id|style],-h3[id|style],-h4[id|style],-h5[id|style],-h6[id|style],hr,"
    + "img[*],-ins," //img requires * to enable media plugin
    + "iframe[align|allowtransparency|frameborder|scrolling|src|width|height|style],"
    + "-kbd,-li,object[*],-ol,"
    + "-p[class|id|style],param[*],-pre,"
    + "-span[!class],-strong/b,-sub,-sup,"
    + "-table[*],-tbody,#td[*],-tfoot,#th[*],-thead,-tr[*],"
    + "-ul",
	visual_table_class : "mceTable",
	width : "98%",

	plugin_imagemanager_opts: {
		folder: "/uploads/cms/images/",
		bg:false,
		markup: {tag:"div",align_left_class:"call-l",align_right_class:"call-r"}
	},

	plugin_documentmanager_opts: {
		bg:false,
		folder:"/uploads/cms/documents/"
	}
});

var frontEnd = defaultTinyMCE.clone();
frontEnd.update({
"editor_selector": "mceEditorFrontEnd"
});
tinyMCE.init(frontEnd.toObject());

/*---------------------------------------+
| Configuration: home page introduction |
+---------------------------------------*/
var frontEndIntro = defaultTinyMCE.clone();
frontEndIntro.update({
"editor_selector": "mceEditorFrontEndIntro",
    "height": "500",
    "theme_advanced_buttons1": frontEndIntro.get("theme_advanced_buttons1").replace(",styleselect", ""),
    "theme_advanced_blockformats": "p,h1,h2,h3",
    "theme_advanced_buttons2": frontEndIntro.get("theme_advanced_buttons2").replace("tablecontrols,separator,", ""),
    "theme_advanced_styles": ""
});
tinyMCE.init(frontEndIntro.toObject());

/*------------------------------------------------------------------+
 | Configuration: secondary text (bottom columns on tab home pages) |
 +------------------------------------------------------------------*/
var frontEndSecondary = defaultTinyMCE.clone();
frontEndSecondary.update({
    "content_css": frontEndSecondary.get("content_css") + ",/styles/tinymce-secondary.css",
    "editor_selector": "mceEditorFrontEndSecondary",
    "height": "400",
    "theme_advanced_blockformats": "p,h3,h4,h5,h6,blockquote",
    "theme_advanced_buttons1": frontEndSecondary.get("theme_advanced_buttons1").replace("", ""),
    "theme_advanced_buttons2": frontEndIntro.get("theme_advanced_buttons2").replace("tablecontrols,separator,", ""),
    "theme_advanced_styles": ""
});
tinyMCE.init(frontEndSecondary.toObject());

/*------------------------+
 | Configuration: sidebar |
 +------------------------*/
var frontEndSidebar = frontEndSecondary.clone();
frontEndSidebar.update({
    "content_css": frontEndSidebar.get("content_css") + ",/styles/tinymce-secondary.css,/styles/tinymce-sidebar.css",
    "editor_selector": "mceEditorFrontEndSidebar"
});
tinyMCE.init(frontEndSidebar.toObject());

/*-------------------------------------+
 | Configuration: small blocks of text |
 +-------------------------------------*/
var frontEndSummary = defaultTinyMCE.clone();
frontEndSummary.update({
    "editor_selector": "mceEditorFrontEndSummary",
    "height": "200",
    "theme_advanced_blockformats": "p,h3",
    "theme_advanced_buttons1": frontEndSummary.get("theme_advanced_buttons1").replace(",styleselect", ""),
    "theme_advanced_buttons2": frontEndIntro.get("theme_advanced_buttons2").replace("tablecontrols,separator,", ""),
    "theme_advanced_styles": ""
});
tinyMCE.init(frontEndSummary.toObject());

/*-------------------------------------+
 | Configuration: title                |
 +-------------------------------------*/
var frontEndTitle = defaultTinyMCE.clone();
frontEndTitle.update({
    "editor_selector": "mceEditorFrontEndTitle",
    "forced_root_block": false,
    "height": "25",
    "theme_advanced_blockformats": "",
    "theme_advanced_buttons1": "italic,separator,cleanup,code,spellchecker",
    "theme_advanced_buttons2": "",
    "theme_advanced_styles": "",
    "valid_elements" : "-em/i"
});
tinyMCE.init(frontEndTitle.toObject());

/*------------------------------------------------------------------+
 | Configuration: description boxes on publications, directory entries, calendar events etc |
 +------------------------------------------------------------------*/
var descriptionEditor = defaultTinyMCE.clone();
descriptionEditor.update({
    "content_css": "/styles/master.css",
    "editor_selector": "mceEditorDescription",
    "height": "300",
    "theme_advanced_blockformats": "p,h3,h4,h5,h6,blockquote",
    "theme_advanced_buttons1": descriptionEditor.get("theme_advanced_buttons1").replace("", ""),
    "theme_advanced_buttons2": descriptionEditor.get("theme_advanced_buttons2").replace("tablecontrols,separator,", "")
});
tinyMCE.init(descriptionEditor.toObject());
