/**
 * @license Copyright (c) 2003-2013, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.html or http://ckeditor.com/license
 */


CKEDITOR.editorConfig = function( config ) {
	config.uiColor = '#e6e6e6';
	config.defaultLanguage = "en";
	if(typeof currentLocaleForCKEDITOR != "undefined"){
		config.language = currentLocaleForCKEDITOR;
	}else{
		config.language = '<%= (I18n.locale.to_s == "zh_tw" || I18n.locale.to_s == "zh_cn" ? "zh" : I18n.locale.to_s) %>';
	}
	config.height = 400;
	config.resize_minHeight = 400;
	config.toolbarCanCollapse = true;
	config.allowedContent = true;
	config.pasteFromWordRemoveFontStyles=false;
	config.pasteFromWordRemoveStyles=false;
	config.plugins = 'dialogui,dialog,about,a11yhelp,dialogadvtab,basicstyles,blockquote,clipboard,button,panelbutton,panel,floatpanel,colorbutton,colordialog,templates,menu,contextmenu,resize,toolbar,elementspath,enterkey,entities,popup,filebrowser,find,image,fakeobjects,floatingspace,listblock,richcombo,font,format,horizontalrule,htmlwriter,iframe,wysiwygarea,indent,indentblock,indentlist,justify,menubutton,link,list,liststyle,magicline,maximize,newpage,pastetext,pastefromword,removeformat,selectall,showblocks,showborders,sourcearea,specialchar,scayt,stylescombo,tab,table,tabletools,undo,wsc,youtube,codemirror';

	config.toolbarGroups = [
		{ name: 'document',	   groups: [ 'mode', 'document', 'doctools' ] },
		{ name: 'clipboard',   groups: [ 'clipboard', 'undo' ] },
		{ name: 'editing',     groups: [ 'find', 'selection', 'spellchecker' ] },
		{ name: 'links' },
		{ name: 'insert' },
		{ name: 'forms' },
		{ name: 'tools' },
		{ name: 'others' },
		{ name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ] },
		{ name: 'paragraph',   groups: [ 'list', 'indent', 'blocks', 'align' ] },
		{ name: 'styles' },
		{ name: 'colors' },
		{ name: 'about' }
	];

	config.skin = 'moono';

	config.filebrowserBrowseUrl = "<%= Rails.application.routes.url_helpers.admin_assets_path %>";
	config.filebrowserImageBrowseUrl = "<%= Rails.application.routes.url_helpers.admin_assets_path %>";

	//Font Config
	config.font_names = 'Arial;Calibri;Comic Sans MS;Courier New;Georgia;Helvetica;Lucida Sans Unicode;Tahoma;Times New Roman;Trebuchet MS;Verdana;微軟正黑體;標楷體;新細明體';
	
	config.fontSize_sizes = '0.5em;0.563em;0.625em;0.688em;0.750em;0.813em;0.875em;0.938em;1em;1.063em;1.125em;1.250em;1.313em;1.375em;1.438em;1.5em;1.75em;2.25em;3em;4.5em;';
	
	config.enterMode = CKEDITOR.ENTER_BR;
	config.shiftEnterMode = CKEDITOR.ENTER_BR;
	config.templates_files = [ '/assets/ckeditor/orbit_templates.js' ];
};

CKEDITOR.on('instanceReady',function(){
	$('.cke_button').tooltip({
		position: {
			my: "center bottom-4",
			at: "center top"
		}
	});
});
