/*
* redmicro all Copyright (c)
*/
/**
* Created by seeker910 on 2014/8/13.
*/
Rsd.define('Rsd.control.RichTextBox', {
extend: 'Rsd.control.Component',
xtype: 'rich-text-box',
height: 30,
margin: '3 5 10 5',
label:{position:'top',content:null,height:45},
labelTagName:'div',
ctrlTagName: 'textarea',
uploadUrl:'',
readOnly: false,
saveHandler:null,
autoLoad:true,
/**
*
* @param {*} config
*/
constructor: function RichTextBox(config) {
config = config || {};
this.apply(config);
},
/**
*
*/
onAfterRender:function onAfterRender()
{
var me = this;
me.callParent();
setTimeout(function(){
me.editor = new nicEditor({fullPanel : true,iconsPath:Rsd.getRedjsHost() +'/plugin/nicEdit/nicEditorIcons.gif'}).panelInstance(me.ctrl.element.id);
},500);
},
/*
设置为只读
* */
setReadOnly:function setReadOnly(readonly) {
var editor = this.editor;
if(editor)
{
editor.setReadOnly( readonly );
this.readOnly = readonly;
if(readonly)
{
editor.commands.save.disable();
}
else
{
editor.commands.save.enable();
}
}
},
/*
* */
setMenuVisible:function setMenuVisible(visible) {
if(visible)
{
$('#' + this.id).find('.cke_top').show();
}
else
{
$('#' + this.id).find('.cke_top').hide();
}
},
/*
* */
setUIColor:function(c)
{
var editor = this.editor;
if(editor)
{
editor.setUiColor(c);
}
},
/*
*
* */
getValue:function getValue() {
var editor = this.editor;
if(editor)
{
return this.getData();
}
return null;
},
/*
* */
setValue:function setValue(data) {
var editor = this.editor;
if(editor)
{
return editor.setData(data);
}
},
/*
* */
remove:function remove() {
this.callParent();
},
},function(type){
var nicEditURL = Rsd.getRedjsHost() + 'plugin/nicEdit/nicEdit.js';
//Rsd.loadPlugin:向dom中添加<script>标签,来加载插件
//Rsd.loadPlugin(nicEditURL);
//Rsd.loadScriptFile直接加载js文件
Rsd.loadScriptFile(nicEditURL);
var _editorGetter = function () {
return this.__editor;
};
var _editorSetter = function (editor) {
this.__editor = editor;
return ;
};
this.defineProperty(type,"editor", _editorGetter, _editorSetter,true);
});