CKEditor.js 2.19 KB

CKEditor = {
 
  'toolbar' : {
      'basic' :[
	              ['Source','Preview','Maximize'],
	              ['Cut','Copy','Paste','PasteWord','Undo','Redo'],
	              ['Image','Link','Unlink'],
	              ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],

	              ['Bold','Italic','Underline','StrikeThrough',],
	              ['OrderedList','UnorderedList','-','Outdent','Indent','Blockquote'],

              ]
  }


}

CKEditor.create = function( name,module ){
  if ( false==module ){
    module = '';
  }
  var hEd = CKEDITOR.instances[name];
  if (hEd) {
    CKEDITOR.remove(hEd);
  }

  hEd = CKEDITOR.replace(name,{
    'AutoDetectLanguage':false,
    'toolbar' : CKEditor.toolbar.basic,
    'DefaultLanguage' : 'ru',
    'theme' : 'default',
    'skin' : 'v2',
    'filebrowserImageUploadUrl' : '/?p_name=admin_images&act=editor_upload&module='+module,
    'removePlugins' : 'elementspath',
    'entities' : false,
    'height':400
  });
  	
	
	 	
    CKEDITOR.on( 'dialogDefinition', function( ev ){
    var dialogName = ev.data.name;
   
   		//CKEDITOR.dialog.dialogDefinitionObject
    var dialogDefinition = ev.data.definition;
    if ( dialogName == 'image' ){
    	dialogDefinition.removeContents( 'advanced' );
    	dialogDefinition.removeContents( 'Link' );
    	var content = dialogDefinition.getContents( 'info' );
    	content.remove( 'txtVSpace' );
    	content.remove( 'txtHSpace' );
    	content.remove( 'txtBorder' );
    	content.remove( 'txtHeight' );
    	content.remove( 'txtWidth' );
    	content.remove( 'txtAlt' );
    	//alert( content.elements[0].type )
    }
    
    if ( dialogName == 'link' ){
    	dialogDefinition.removeContents( 'advanced' );
   		dialogDefinition.removeContents( 'target' );
   	}
   	
    if ( dialogName == 'flash' ){
    	dialogDefinition.removeContents( 'advanced' );
    }
  })
  
  return hEd;
} //  end create

CKEditor.remove = function( element ){
  editor_id = element.attr('link_editor');
  HL.editor.get(editor_id).destroy();
}

CKEditor.getText = function( element  ){
  editor_id = element.attr('link_editor');
  return HL.editor.get(editor_id) .getData()
 
}

  //  регистрируем
HL.editor.register('CKEditor',CKEditor);