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

CKEDITOR.on('dialogDefinition', function(ev) {
    var dialogName = ev.data.name;
    var dialogDefinition = ev.data.definition;
    var dialog = dialogDefinition.dialog;
    var editor = ev.editor;

    if (dialogName=='image') {
        dialogDefinition.onLoad = function(){ 
            dialog.getContentElement('info', 'htmlPreview').getElement().hide();     
            dialog.getContentElement('info', 'cmbAlign').getElement().hide();     
            this.hidePage('Link');
            this.hidePage('advanced');
            this.selectPage('Upload'); 
        }; 

    } else if (dialogName=='link') {
        dialogDefinition.removeContents('advanced');

        dialogDefinition.onShow = function(){ 
            dialog.getContentElement('info','anchorOptions').getElement().hide(); 
            dialog.getContentElement('info','emailOptions').getElement().hide();
            dialog.getContentElement('info','linkType').getElement().hide(); 
            dialog.getContentElement('info','protocol').disable();
        }; 
    }

    var infoTab = dialogDefinition.getContents('info');
    if (infoTab) {
        infoTab.remove('txtHSpace');
        infoTab.remove('txtVSpace');
        infoTab.remove('txtBorder');
        infoTab.remove('txtWidth');
        infoTab.remove('txtHeight');
        infoTab.remove('ratioLock');
    }
});

CKEDITOR.editorConfig = function( config )
{
	// Define changes to default configuration here.
	// For complete reference see:
	// http://docs.ckeditor.com/#!/api/CKEDITOR.config

	// The toolbar groups arrangement, optimized for two toolbar rows.
    config.toolbar = [
        [ 'Source', '-', 'NewPage', 'Preview', '-', 'Templates' ],
        [ 'Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'Undo', 'Redo' ],
        [ 'Bold', 'Italic', 'Underline' ],
        [ 'Font', 'FontSize', 'TextColor', 'BGColor' ],
        [ 'Maximize', 'About' ]
    ];
	// Remove some buttons provided by the standard plugins, which are
	// not needed in the Standard(s) toolbar.
	// config.removeButtons = 'Underline,Subscript,Superscript';

	// Set the most common block elements.
	// config.format_tags = 'p;h1;h2;h3;pre';

	// Simplify the dialog windows.
	// config.removeDialogTabs = 'image:advanced;link:advanced';

    // 폰트추가
    config.font_names = "굴림; 돋음; 궁서; Nanum Gothic Coding; 맑은 고딕; 바탕; 궁서;" + CKEDITOR.config.font_names;

    // 기본값 소스 모드로 오픈
    config.language = 'ko';
    config.startupMode = 'source';
    config.height = '400px';
    config.enterMode = CKEDITOR.ENTER_BR;
    // config.skin = 'grappelli';
    config.AutoParagraph = false;
    config.allowedContent = true;
};