=0;i--){
TQE.removeNode(es[i],false);
}
//删除不必要的SPAN
es=TQE._tags(d,'SPAN');
for(i=es.length-1;i>=0;i--){
e=es[i];
fw= e.style.fontWeight,c=e.style.color;
if(''===e.innerHTML.replace(/<[a-z\/][^>]*>/gi,'') || ( fw=='' && c=='')){
TQE.removeNode(e,false);
continue;
}
e.removeAttribute('style');
e.className=''
e.removeAttribute('class');
e.style.fontWeight=fw;
e.style.color=c;
}
//清理分页符
es=TQE._tags(d,'H3');
for(i=es.length-1;i>=0;i--){
if(es[i].className === 'splitPage') es[i].innerHTML=es[i].innerHTML.replace(/<\/?[a-zA-z][^>]*>/g,'');
}
//清理段落
es=TQE._tags(d,'P');
var emtpyReg=/^( | ){3,}/
for(i=es.length-1;i>=0;i--){
e=es[i];
if(''==e.innerHTML.replace(/<[a-z\/][^>]*>/gi,'').replace( /( |\n|\r|\t| )/gi, '')){//删除空白的段落
TQE.removeNode(e,false);
continue;
}
e.removeAttribute('style');
e.className=''
e.removeAttribute('class');
if(emtpyReg.test(e.innerHTML)){
e.align='center';
}else{
e.removeAttribute('align');
e.style.textIndent=$.config.typesetIndentParagraph ? '2em':'';
}
}
//清理链接
es=TQE._tags(d,'A');
for(i=es.length-1;i>=0;i--){
e=es[i];
if(''==e.innerHTML.replace(/<[a-z\/][^>]*>/gi,'').replace( /( |\n|\r|\t| )/gi, '')){//删除空白的链接
TQE.removeNode(e,false);
continue;
}
e.removeAttribute('style');
e.className=''
e.removeAttribute('class');
}
var isEmptyNode=function(node){
var nn=node.nodeName, emptyReg=/^( |\n|\r|\t| )*$/gi;
if(nn==='#text') return emptyReg.test(node.nodeValue)
return 'BR'===nn || 'IMG'!==nn && ''==node.innerHTML.replace(/<[a-z\/][^>]*>/gi,'').replace(/(\s| )/gmi,'');
},
//排版图片下方的文字
centerImageText=function(node){
var ne,s;
while(node && node.tagName!='BODY'){
ne = node;
while(ne = ne.nextSibling){
if(isEmptyNode(ne)) continue;
if(ne.nodeName==='#text'){
div = TQE.CE('CENTER','',ne.nodeValue);
//div.style.textAlign='center';
node.parentNode.insertBefore(div,ne);
TQE.removeNode(ne,true);
return ;
}else{
if(ne.tagName=='CENTER') return;
if(ne.tagName=='P') ne.align='center';
else ne.style.textAlign='center';
return ;
}
}
node=node.parentNode;
}
};
//排版图片
es=TQE._tags(d,'IMG');
for(i=es.length-1;i>=0;i--){
e=es[i];
if(e.getAttribute('emot')) continue;//表情
if($.config.typesetImageTextCenter)centerImageText(e);
e.removeAttribute('style');
e.border= $.config.typesetImageBorder ? '1':'0';
e.style.margin='5px';
//e.style.margin='5px auto';
//e.style.display='block';
ep=e.parentNode;
if(ep.tagName=='A' && ep.firstChild==ep.lastChild){
e=ep;
ep=ep.parentNode;
}
if(ep.tagName=='P' && ep.align=='center' || ep.tagName=='CENTER' || ep.style.textAlign=='center') continue;
div = TQE.CE('CENTER');
ep.insertBefore(div, e);
div.appendChild(e);
}
//排版视频,flash等
es=TQE._tags(d,'OBJECT');
for(i=es.length-1;i>=0;i--){
e=es[i];
if($.config.typesetImageTextCenter)centerImageText(e);
ep=e.parentNode;
if(ep.tagName=='P' && ep.align=='center' || ep.tagName=='CENTER' || ep.style.textAlign=='center') continue;
div = TQE.CE('CENTER');
ep.insertBefore(div, e);
div.appendChild(e);
}
//排版视频,flash等
es=TQE._tags(d,'EMBED');
for(i=es.length-1;i>=0;i--){
e=es[i];
if('OBJECT'===e.parentNode.tagName) continue;
if($.config.typesetImageTextCenter) centerImageText(e);
ep=e.parentNode;
if(ep.tagName=='P' && ep.align=='center' || ep.tagName=='CENTER' || ep.style.textAlign=='center') continue;
div = TQE.CE('CENTER');
ep.insertBefore(div, e);
div.appendChild(e);
}
$.cleanWord(true);
};
//force 布尔值
$.cleanWord=function(force){
if('visual'!=$.currentMode()) return;
var d = $._getDoc(),s;
if(!force){
s= d.body.innerHTML;
if(s.indexOf('mso') <0 && s.search(/[a-z]+:[a-z0-9]+="[^\"]*"/ig)<0) return;
}
var cleanTag=function(tags, removeOnEmptyStyle){
for(var e,es,s,j,i=tags.length-1; i>=0; i--){
es=TQE._tags(d,tags[i]);
for(j=es.length-1;j>=0;j--){
e=es[j];
e.removeAttribute('lang');
s = e.getAttribute('style');
if(null==s && removeOnEmptyStyle){
TQE.removeNode(e,false);
continue;
}
if(typeof s =='string' && s.indexOf('mso-')>=0){
s+=';';
s=s.replace(/mso\-[^;]+?;/gi,'').replace(/FONT\-FAMILY[^;]+?;/gi,'').replace(/\s+/g,' ').replace(/MARGIN\: 0cm 0cm 0pt;/gi,'').replace(/tab\-stops\:[^;]+?;/gi,'');
if(''==s || ' '==s){
if(removeOnEmptyStyle){
TQE.removeNode(e,false);
continue;
}
e.removeAttribute('style');
}else{
e.setAttribute('style',s);
}
}
s = e.getAttribute('class');
if(null!=s){
s=s.replace(/mso[a-z\-]+\s*/gi,'').replace(/^xl[0-9]+$/i,'');
if(''==s){
e.removeAttribute('class');
}else{
e.setAttribute('class',s);
}
}
}
}
},
removeEmtpyTags=function(tags){
for(var e,es,s,j,i=tags.length-1; i>=0; i--){
es=TQE._tags(d,tags[i]);
for(j=es.length-1;j>=0;j--){
e=es[j];
if(e.innerHTML=='')TQE.removeNode(e,false);
}
}
};
cleanTag(['SPAN'],true);
cleanTag(['P','B','I','U','TD','TR','TABLE','DIV','COL','FONT'],false);
//.replace(/<([a-z][a-z0-9]*)[^>]*>\s*<\/\1>/gi,'') ,'FONT'
d.body.innerHTML=d.body.innerHTML.replace(/
]*>/gi,'').replace(/<\/o:[a-z0-9_]+>/gi,'').replace(/<\?xml.+?\/>/gi,'').replace(/(<[a-z]+[^>]+>)/ig,function(m,p1){if(p1.indexOf(':')>0){ p1=p1.replace(/[a-z]+:[a-z0-9]+="[^\"]*"/ig,''); }return p1; });
cleanTag(['SPAN'],true);
removeEmtpyTags(['SPAN','FONT','B','U','I','STRONG','EM']);
$.save();
};
// 设置编辑器宽度,值大于1时,单位像, 小于1时是 百分比, 如 0.5表示50%
// 参数必须是0-1之间的小数或大于1的整数
$.setWidth=function(value){
if(value>1){
$.config.width=value+'px';
}else{
$.config.width=(value*100)+'%';
}
$._containerDiv.style.width= $.config.width;
};
//设置编辑器高度,单位像素
$.setHeight=function(value){
if(value<9) value=9;
$.config.height=value;
$._setHeight(value);
};
$._setHeight=function(value){
if(value<2)value=2;
$._editorObj().style.height= value+'px';
if('visual'==$.currentMode()){
value-=6;
if(value<2) value=2;
$._getDoc().body.style.minHeight=value+'px';
if(isIE6)$._getDoc().body.style.height=value+'px';
}
};
$._fixFull=function(){
var d=TQE._doc(),e=$._containerDiv, h;
e.style.zIndex='10000';
e.style.width=(d.clientWidth-2) + 'px';
e.style.top = TQE._docST()+'px';
e.style.left = TQE._docSL()+'px';
h = d.clientHeight-$._toolbarDiv.offsetHeight
$._setHeight(h- ('visual'==$.currentMode()?2:6));
//e.scrollIntoView();
//return;
//e=$._editorObj();
//if('visual'==$.currentMode()){
// $.setHeight(h-2);
// e.style.height= h-2 + 'px';
// d = $._getDoc();
// if(d.body){
// h-=6;
// if(h<2)h=2;
// d.body.style.minHeight=h+'px';
// if(isIE6)d.body.style.height=h+'px';
// }
// //e.style.width='';
//}else{
// //e.style.width=(d.clientWidth-6)+'px';
// e.style.height= h-7 + 'px';
//}
};
$._button=function(name){
//var btns = TQE._tags($._toolbarDiv,'LI'),i;
var btns = TQE._tags($._toolbarDiv,'A'),i;
for(i=btns.length-1;i>=0;i--){
if(name==btns[i].getAttribute('name') ) {//
return btns[i];
}
}
return null;
};
$.changeToolbarMode=function(advMode,force){
var e=$._toolbarDiv,btns,i,hOld=e.offsetHeight;
if(advMode===undefined || null===advMode){
advMode = (e.className=='eToolBar')?true:false;
}else if(force===undefined || !force){
if(advMode == (e.className!='eToolBar')) return;
}
if(advMode){
e.className='eToolBar eLargeIcons';
document.body.appendChild(e); //专用来修改IE6,7,8里编辑器直接父节点是P的bug。 即
e.innerHTML=$._toobarCode($.config.advToolbar, $.config.advToolbarRight);
}else{ //toolbar common mode
e.className='eToolBar';
document.body.appendChild(e); //专用来修改IE6,7,8里编辑器直接父节点是P的bug。 即
e.innerHTML=$._toobarCode($.config.toolbar, $.config.toolbarRight);
}
$._containerDiv.insertBefore(e,$._containerDiv.firstChild);//专用来修改IE6,7,8里编辑器直接父节点是P的bug。 即
//if(isIE6 || isIE && (document.documentMode==7 || document.compatMode != "CSS1Compat")){//IE6或兼容视图或怪异模式
if( isIE && IEVersion<9){//ie6,7,8
//var groups = TQE._tags(e,'UL'),w;
var groups = TQE._tags(e,'SPAN'),w=0,j=0;
for(i=groups.length-1;i>=0;i--){
groups[i].style.width=groups[i].offsetWidth+2+'px';
//if(isIE6) break;
btns = TQE._tags(groups[i],'A');
w=0;
for(j=btns.length-1;j>=0;j--){
if(btns[j].offsetLeft+btns[j].offsetWidth > w) w= btns[j].offsetLeft+btns[j].offsetWidth;
}
w-=groups[i].offsetLeft-2;
if(w>0)groups[i].style.width=w+'px';
/*continue;
w=3;
btns=groups[i].childNodes;
for(j=btns.length-1;j>=0;j--){w += btns[j].offsetWidth;}
groups[i].style.minWidth=w+'px';
*/
}
}
if(hOld){
$.setHeight($.config.height+hOld-e.offsetHeight);
if($._containerDiv.style.position=='absolute')$._fixFull();
}
TQE._noSel(e);
if($.config.showToolbarGroupHandle){
var w = e.getElementsByTagName('DIV')[0].offsetWidth;
e.style.marginLeft="-"+w+"px";
}
//btns = TQE._tags(e,'LI');
btns = TQE._tags(e,'A');
for(i=btns.length-1;i>=0;i--){
//$._ieMouseStyle(btns[i],'eButton','eButtonUp','eButtonDown'); //ie6
TQE.addListener(btns[i],'click', $._toolbarBottonClick);
TQE.addListener(btns[i],'mouseout', function(){
var o=TQE.activePop;
this.className= (o && o.relateObj==this)? 'eButtonDropDown':'eButton';
});
}
$._updateToolbar('visual'===$.currentMode(),['toolbarmode','mode','fullscreen','help'], true);
};
$.fullScreen=function(b){
var e=$._containerDiv,isVisualMode = 'visual'===$.currentMode(),o,btn;
if(b===undefined || null===b){
b = (e.style.position!='absolute');
}else{
if(b == (e.style.position=='absolute'))return;
}
//移动IFrame会导致内容丢失, 所以要转为代码模式
if(isVisualMode){
$.changeMode('code');
}
if(b){
//$.tl=[TQE._docST(),TQE._docSL()];
document.body.parentNode.style.overflow = 'hidden';
//e.parentNode.removeChild(e);
document.body.appendChild(e);
if(isVisualMode){
if(isGecko){//算是Firefox的bug吗?
window.setTimeout(function(){$.changeMode('visual');},1);
}else{
$.changeMode('visual');
}
}
e.style.position='absolute';
e.style.top = '0px';
$._fixFull();
TQE.addListener(window,'resize',$._fixFull);
}else{
//TQE._docST($.tl[0]);
//TQE._docSL($.tl[1]);
document.body.parentNode.style.overflow = 'auto';
TQE.delListener(window,'resize',$._fixFull);
e.style.position='';
e.style.width=$.config.width;
o=$._editorObj();
o.style.height=$.config.height+'px';
//e.parentNode.removeChild(e);
$.obj.parentNode.insertBefore(e,$.obj);
if(isVisualMode){
$.changeMode('visual');
}
e.scrollIntoView(false);
}
//更新全屏按钮图标
btn=$._button('fullscreen');
if(btn){
btn.id = b ? 'eBTNfullscreen-reset' : 'eBTNfullscreen';
}
};
$.setContent=function(code){
//code = ('code'==$.currentMode())? changeAsUbb(code): changeAsHtml(code);
if('code'===$.currentMode()){
$._editorObj().value=code;
}else{
if('function'===typeof $.config.onsetcontent) code=$.config.onsetcontent.call($,code);
$._getDoc().body.innerHTML=code;
}
$.save();
};
$._initContent=function(code){
if('code'!==$.currentMode()){
if((isGecko || isOpera) && ' '==code.substring(0,4)){
code=code.substr(4); // 怪怪的Firefox
}
if(isGecko) code = code.replace(/
]*)>\s*<\/td/ig, ' ',
d = $._getDoc(),
h;
s+='\n';
if($.config.baseHref!=''){
s +=' ';
}
if ($.config.css) {
s += ' \n';
}
s+='';// '+ code+'
d.open();
d.write(s);
d.close();
h=Math.max(20,$._editorObj().offsetHeight-6);
if(d.body){
d.body.style.minHeight=h+'px';
if(isIE6)d.body.style.height=h+'px';
}
}
$.setContent(code);
$._changed();
};
$.setOpacity=function(e, opacity) {
if (isIE) {// && IEVersion<9
e.style.filter = (opacity == 100) ? '' : 'gray() alpha(opacity=' + opacity + ')';
} else {
e.style.opacity = (opacity == 100) ? '' : opacity/100;
}
};
$.inArray=function(e,arr){
for(var i=arr.length-1;i>=0;i--) if(e==arr[i]) return true;
return false;
};
$.content=function(){
var m=$.currentMode(), cells,i,code;
if('visual'===m){
cells = $.selectedCells();
for(i=cells.length-1;i>=0;i--){
cells[i].className='';
}
code= $._getDoc().body.innerHTML;
for(i=cells.length-1;i>=0;i--){
cells[i].className='selectedTD';
}
if((isGecko || isOpera) && ' '==code.substring(0,4)) code=code.substr(4);//怪怪的Firefox
if(''==code.replace(/<\/?(div|p|font|b|s|u|i|strong|em|strike)(?![a-z0-9])[^>]*>| |\s/ig , '')) code= '';
if('function'===typeof $.config.ongetcontent) code=$.config.ongetcontent.call($,code);
else code=TQE.formatHTML(code);
}else{
code= $._editorObj().value;
}
return code;
};
$._autoSave=function(b){
var e = $._editorObj(), func = b? TQE.addListener : TQE.delListener;
if (isIE ){
func(e,'beforedeactivate',$.save);
}else if('code'==$.currentMode()){
func(e,'blur',$.save);
}else{
func(e.contentWindow,'blur',$.save);
}
};
$.save=function(){
$.obj.value=$.content();
};
$._intEdit=function(obj){
if(obj.isIniEdit)return;
obj.isIniEdit=true;
obj.style.imeMode='disabled';
obj.onkeypress=function(){
if(45==event.keyCode){
this.value = ('-'==this.value.charAt(0))? this.value.substr(1) : '-'+this.value;
return false;
}
return event.keyCode>=48&&event.keyCode<=57;
};
obj.onpaste=function(){return !clipboardData.getData('text').match(/\D/);};
obj.ondragenter=function(){return ! /\D/.test(event.dataTransfer.getData('text'));};
obj.oldBlur=obj.onblur;
obj.onblur=function(){
if(''==this.value) return;
this.value=parseInt(this.value,10);
var max = this.getAttribute('max'),
min = this.getAttribute('min');
if(max!==undefined && parseInt(this.value,10)>parseInt(max,10))this.value=parseInt(max,10);
if(min!=undefined && parseInt(this.value,10) ');
if(isIE && document.compatMode != "CSS1Compat"){
document.write(' ');
}
}
//配置
TQE.config={
"paragraphs" : [
["正文", "p"],
["标题1", "h1"],
["标题2", "h2"],
["标题3", "h3"],
["标题4", "h4"],
["标题5", "h5"],
["标题6", "h6"],
["预定义", "pre"]
],
"fontnames" : [
["宋体", "宋体"],
["新宋体", "新宋体"],
["仿宋_GB2312", "仿宋_GB2312"],
["黑体", "黑体"],
["微软雅黑", "微软雅黑"],
["楷体_GB2312", "楷体_GB2312"],
["Arial", "arial, helvetica, sans-serif"],
["Courier New", "courier new, courier, mono"],
["Georgia", "Georgia, Times New Roman, Times, Serif"],
["Tahoma", "Tahoma, Arial, Helvetica, sans-serif"],
["Times New Roman", "times new roman, times, serif"]
],
"fontsizes": [
//[text,preview, value]
["特小","xx-small", 1],
["较小","x-small", 2],
["小", "small", 3],
["中", "medium", 4],
["大", "large", 5],
["较大","x-large", 6],
["特大","xx-large", 7]
],
"toolbar":'default',
"toolbarRight":[],
"advToolbar":['paragraph','fontname','fontsize','br','bold','italic','underline','strikethrough','forecolor','backcolor','removeformat','typeset',
'||','justifyleft','justifycenter','justifyright','justifynone',['superscript','subscript'],'br','orderedlist','unorderedlist','indent','outdent',
'||','inserthorizontalrule','splitpage','cleanword','br','createlink','unlink','inserttable',
'||','insertface','insertimage','insertmusic','insertflash','insertvideo'],
"advToolbarRight":['toolbarmode','br','fullscreen','mode','help'],
"advToolbarMode":false,
'showToolbarGroupHandle':true, //显示工具组最前的图
//模板
//插入媒体***时的模板代码,
//flash 宏 {$url} {$width} {$height}
'tplFlash':' ',
//flv视频 宏 {$url} {$width} {$height} {$auto_start}
'tplFlv':' ',
//rm视频 宏 {$url} {$width} {$height} {$auto_start}
'tplRm':' ',
//windows的媒体文件 宏 {$url} {$width} {$height} {$auto_start}
'tplVideo':' ',
//音乐播放 宏 {$url} {$auto_start}
'tplMusic':' ',
//分页符代码
'tplSplitPage':' ',
'uploadFieldName':'file',//接收上传时的上传表单名
'faceurl':'',
'imageUploadUrl':'',//接收上传图片网址, 留空表示不允许上传, 以#开头, 表示点击上传按扭后的界面网址
'imageFileTypes':'*.jpg;*.gif;*.png;*.jpeg',//允许上传的图片后缀
'imageFileSize':'2MB',//允许上传文件大小
'directInsertUploadImage':false,//直接将上传的图片插入编辑器中
'linkUploadUrl':'',//接收上传网址, 留空表示不允许上传, 以#开头, 表示点击上传按扭后的界面网址
'linkFileTypes':'*.*',//允许上传的后缀
'linkFileSize':'2MB',//允许上传文件大小
'flashUploadUrl':'',//接收上传Flash网址, 留空表示不允许上传, 以#开头, 表示点击上传按扭后的界面网址
'flashFileTypes':'*.swf',//允许上传的图片后缀
'flashFileSize':'2MB',//允许上传文件大小
'musicUploadUrl':'',//接收上传音频文件网址, 留空表示不允许上传, 以#开头, 表示点击上传按扭后的界面网址
'musicFileTypes':'*.mp3;*.wma',//允许上传音频文件后缀
'musicFileSize':'2MB',//允许上传文件大小
'videoUploadUrl':'',//接收上传视频文件网址, 留空表示不允许上传, 以#开头, 表示点击上传按扭后的界面网址
'videoFileTypes':'*.flv;.mp4;*.mkv;*.wmv;*.asf;*.avi;*.rmvb;*.rm',//允许上传的文件后缀
'videoFileSize':'2MB',//允许上传文件大小
'enter2br':false,
//'formatHTML':true,//对HTML源码进行美化(换行与缩进)
//'height_delta':20,
'width':'auto',
'height':'auto',
'autoClean':true,//在执行粘贴时,自动清理word相关的垃圾代码
'faceCount':55,//表情数量, 在face目录中
'css':'',//设计辅助的相关样式网址
'cssCode':'',//直接指定设计辅助的相关样式代码
'bgColor':'', //可视化编辑时, 编辑器背景色
'textColor':'', //可视化编辑时, 文字色
'autoPopImagePanel':true, //自动弹出图片面板
'autoPopTablePanel':true, //自动弹出表格操作面板(插入行/列,删行/列/表格)
'typesetImageTextCenter':true,//自动排版图片下方的文字居中
'typesetIndentParagraph':false,//自动排版段落首行缩进2字
'typesetImageBorder':true,//自动排版图片添边框
'baseHref':'',//设置相对网址的基网址
'resize':true,//允许修改编辑器尺寸
'onfocus':null,//获取焦点时的回调, function(event){}
'onblur':null,//失去焦点时的回调, function(event){}
'onkeydown':null,//当用户按下键盘按键时触发, function(event){}
'onkeyup':null,//当用户释放键盘按键时触发, function(event){}
'onpaste':null,//当粘贴时触发, function(event){}
'oninit':null,//设置执行初始化时的回调函数, function(){}
'ongetcontent':null,//取代码时的事件回调函数, function(code){}
'onsetcontent':null,//设置代码时的事件回调函数, function(code){}
//'onuploaded':null,//上传成功后的回调函数
'debug':false
};
TQE.find=function(id){return document.getElementById(id);};
TQE.CE=function(tag,id, htm, append){
var o=document.createElement(tag);
if(id)o.id=id;
if(htm)o.innerHTML=htm;
if(append) document.body.appendChild(o);
return o;
};
TQE.loadSkin=function(skin){
var e = TQE.find('TQEditorSkinCSS');
e.href= TQE.url+(skin &&'default'!=skin ? 'skin/'+skin+'/':'')+'TQEditor.css';
};
TQE.checkSkin=function(linkObj){
var i,objs=document.styleSheets,rules;
for(i=objs.length-1;i>=0;i--){
if(objs[i].href==linkObj.href){
rules = objs[i].cssRules || objs[i].rules;
if(rules.length<1) linkObj.href= TQE.url+'TQEditor.css';
break;
}
}
};
TQE._doc=function(){return (document.compatMode != "CSS1Compat") ? document.body : document.documentElement;};
TQE._docST=function(){
return window.scrollY ? window.scrollY : TQE._doc().scrollTop ;
};
TQE._docSL=function(){
return window.scrollX ? window.scrollX : TQE._doc().scrollLeft ;
};
TQE.pos=function(e){
var x = 0, y = 0;
//if (e.getBoundingClientRect) {
var box = e.getBoundingClientRect(),
d=TQE._doc();
x = box.left + TQE._docSL() - d.clientLeft;
y = box.top + TQE._docST() - d.clientTop;
//} else {
// x = e.offsetLeft;
// y = e.offsetTop;
// var parent = e.offsetParent;
// while (parent) {
// x += parent.offsetLeft;
// y += parent.offsetTop;
// parent = parent.offsetParent;
// }
//}
return {'x' : x, 'y' : y, left:x, top:y, width:e.offsetWidth, height:e.offsetHeight};
};
TQE._hideContext=function(){
if(TQE.activeContext){
TQE.activeContext.style.display="none";
TQE.activeContext=null;
}
};
TQE.pop=function(obj,relateObj){
if(TQE.activePop==obj){
TQE.hidePop();
return false;
}
TQE._hideContext();
TQE.hidePop();
TQE.activePop=obj;
obj.relateObj=relateObj;
relateObj.className='eButtonDropDown';
obj.style.display='block';
var p=TQE.pos(relateObj),
l=p.x,
t= 1+relateObj.clientHeight +p.y,
dl = TQE._docSL(),
w = TQE._doc().clientWidth;
if(l+obj.offsetWidth>dl+w)l-=obj.offsetWidth-relateObj.offsetWidth;
obj.style.left= l + 'px';
obj.style.top = t+ 'px';
return true;
};
TQE.hidePop=function(){
if(!TQE.activePop) return;
var o=TQE.activePop;
TQE.activePop=null;
o.style.display='none';
if(o.relateObj && o.relateObj.className=='eButtonDropDown') o.relateObj.className='eButton';
o=TQE.find('ColorPicker');
if(o)o.style.display='none';
};
TQE.delListener=function(e,eventName,func){
if(e.removeEventListener) {
e.removeEventListener(eventName, func, false );
}else{
e.detachEvent('on'+eventName, e['e'+eventName+func]);
}
};
TQE.addListener=function(e,eventName,func){
if(e.addEventListener) {
e.addEventListener( eventName, func, false );
}else{
e['fn'+func]=func;
e['e'+eventName+func]=function(et){e['fn'+func](et)};
e.attachEvent('on'+eventName, e['e'+eventName+func]);//
}
};
TQE._tags=function(domNode, tagName){
return domNode.getElementsByTagName(tagName);
};
TQE.listenTags=function(node,tag,eventname,func){
var ds = TQE._tags(node,tag),i;
for(i=ds.length-1;i>=0;i--){
TQE.addListener(ds[i],eventname,func);
}
};
TQE._noSel=function(o, tagsName){
var noSel=function(){
if(isIE){
var tn=event.srcElement.tagName;
return 'INPUT'==tn || 'TEXTAREA'==tn;
}
return false;
};
if(tagsName){
var a=tagsName.split(','),nodes,i,j;
for(j=a.length-1;j>=0;j--){
nodes = TQE._tags(o,a[j]);
for(i=nodes.length-1; i>=0;i--){
nodes[i].unselectable='on';
nodes[i].onselectstart = noSel
}
}
}else{
o.unselectable='on';
o.onselectstart = noSel;
}
};
TQE._colorPickerUI=function(){
var ColorHex=['00','33','66','99','CC','FF'],
SpColorHex=['FF0000','00FF00','0000FF','FFFF00','00FFFF','FF00FF'],
w=191,//1+19*10
colorTable='';};
colorTable += isIE ? 'cellspacing=1 border=0 bgcolor="#000000;">':'cellspacing=0 border=1 style="border-collapse:collapse;" >';
for (i=0;i<2;i++){
for (j=0;j<6;j++){
colorTable += '';
//colorTable += ' ';
if (i>0) colorTable += colorTD(SpColorHex[j]);
else colorTable += colorTD(ColorHex[j]+ColorHex[j]+ColorHex[j]);
//colorTable += ' ';
for (k=0;k<3;k++){
for (l=0;l<6;l++){
//立方色
colorTable += colorTD(ColorHex[k+i*3]+ColorHex[l]+ColorHex[j]);
//连续色
//var c1 = 4+i-k*2;
//var c2 = i*j + (1-i)*(5-j);// i?j:5-j
//var c3 = k!=1? 5-l:l; //k!=1? 5-l:l;
//colorTable += ' ';
}
}
colorTable += ' ';
}
}
colorTable +='
'+
'';
return colorTable;
};
TQE.pickColor=function(callbackFunc,x,y){
var o=TQE.find('ColorPicker');
if(null==o){
o = TQE.CE('DIV','ColorPicker', TQE._colorPickerUI() ,true);
o.className='ePopPanel';
o.style.zIndex=99999999;
o.onmouseover=function(){this.active=true;};
o.onmouseout=function(){this.active=false;};
TQE._noSel(o);//,'TABLE,TR,TD,DIV');
TQE.listenTags(o,'TD','mouseover',function(){
var self=this,
p=this.parentNode.parentNode.parentNode.parentNode.lastChild,
iid = window.setInterval(function(){self.style.backgroundColor=(self.style.backgroundColor!='')?'':'#FFFFFF'},500);
p.firstChild.style.backgroundColor=this.bgColor;
p.firstChild.nextSibling.innerHTML=this.bgColor;
self.style.backgroundColor='#FFFFFF';
self.onmouseout=function(){window.clearInterval(iid);this.style.backgroundColor='';}
});
o.lastChild.lastChild.onclick=function(){this.parentNode.parentNode.style.display='none';};
TQE.listenTags(o,'TD','mouseup',function(){this.parentNode.parentNode.parentNode.parentNode.style.display='none';});
TQE.addListener(document,'mousedown',function(){var o=TQE.find('ColorPicker');if(!o.active)o.style.display='none';});
}
var ds = TQE._tags(o,'TD');
for(var i=ds.length-1;i>=0;i--){
ds[i].onmousedown=function(e){callbackFunc(this.bgColor); e = e || event; e.cancelBubble=true; }
}
o.lastChild.lastChild.onclick=function(e){callbackFunc(''); e = e || event; e.cancelBubble=true;};
o.style.left=x+'px';
o.style.top=y+'px';
o.style.display='block';
};
TQE.drag=function(o){
o.style.position='absolute';
o.style.userSelect='none';
o.style.mozUserSelect='none';
o.style.webkitUserSelect='none';
o.dragging=false;
o.onmousedown=function(a){
var x,y,obj,n,
p=TQE.pos(this),
scrollLeft = TQE._docSL(),
scrollTop =TQE._docST();
if(isIE){
a=window.event;
//if(a.button!=0) return;
obj=a.srcElement;
x=scrollLeft + a.clientX-p.x;
y=scrollTop + a.clientY-p.y;
}else{
//if(a.button!=0) return;
obj=a.target;
x=a.pageX-p.x;
y=a.pageY-p.y;
}
if(o.dragging)return ;
n=obj.tagName;
if(obj!=this && ( n=='INPUT' || n=='TEXTAREA'|| n=='BUTTON'|| n=='SELECT')) return;
o.dragging=true;
var mousemove=function(a){
if(isIE){
a=window.event;
a.pageX=scrollLeft + a.clientX;
a.pageY=scrollTop + a.clientY;
}
var tx=a.pageX-x, ty=a.pageY-y;
o.style.left=tx +'px';
o.style.top=ty +'px';
o.style.cursor='move';
},
mouseup=function(){
o.style.cursor='';
o.dragging=false;
};
TQE._draging(mousemove,mouseup,o);
};
};
TQE._draging=function(mousemove,mouseup,o){
if(TQE._draging.running) return;
if(o.setCapture)
o.setCapture();
else if(window.captureEvents)
window.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP);
TQE._draging.running=true;
TQE._draging.mm=document.onmousemove;
TQE._draging.mu=document.onmouseup;
var maskDiv=TQE.CE('DIV','','',true);//ie6,webkit
maskDiv.className='eDragMaskDiv';
maskDiv.style.height=Math.max(document.documentElement.clientHeight, document.body.scrollHeight)+'px';
document.onmousemove=mousemove;
document.onmouseup=function(a){
if(maskDiv) document.body.removeChild(maskDiv);
maskDiv=null;
document.onmousemove=TQE._draging.mm;
document.onmouseup=TQE._draging.mu;
if(o.releaseCapture)
o.releaseCapture();
else if(window.releaseEvents)
window.releaseEvents(Event.MOUSEMOVE|Event.MOUSEUP);
TQE._draging.running=false;
mouseup(a);
}
return maskDiv;
};
TQE._draging.running=null;
//TQE._draging.mm=null;
//TQE._draging.mu=null;
TQE.clone=function(srcObj){
if(typeof(srcObj) != 'object') return srcObj;
if(srcObj == null) return srcObj;
var i, newObj = '[object Array]'==Object.prototype.toString.call(srcObj)? [] : {};
for(i in srcObj) newObj[i] = TQE.clone(srcObj[i]);
return newObj;
};
TQE.removeNode=function(node, delChild){
if(node.removeNode) return node.removeNode(delChild); //ie
if(delChild) return node.parentNode.removeChild(node);
while(node.firstChild) node.parentNode.insertBefore(node.firstChild,node);
node.parentNode.removeChild(node);
};
//table functions
TQE.updateCellsStatus=function(table){
var rows=table.rows,cells,cells2,td,td2, i,j,k,l;
for(i=0;i= td.colStart){
td2.colStart += td.colSpan;
td2.colEnd += td.colSpan;
}
}
}
}
}
//fix rowIndex
for(i=rows.length-1;i>=0;i--){
cells= rows[i].cells;
var minrs=cells[0].rowSpan;
for(j=cells.length-1;j>0;j--){
minrs = Math.min(minrs,cells[j].rowSpan);
if(minrs<2)break;
}
if(--minrs > 0){
for(j=cells.length-1;j>=0;j--){
cells[j].rowSpan-=minrs;
cells[j].rowEnd -=minrs;
}
for(k=i-1;k>=0;k--){
for(l=rows[k].cells.length-1;l>=0;l--){
if(rows[k].cells[l].rowEnd>cells[0].rowStart){
rows[k].cells[l].rowSpan-=minrs;
rows[k].cells[l].rowEnd-=minrs;
}
}
}
}
}
};
TQE.insertCol=function(cell, bBegin){
var table=cell.parentNode.parentNode.parentNode,cells,td,td2, i=0,j, colIndex, cc, row, rowCount=table.rows.length;
TQE.updateCellsStatus(table);
colIndex= bBegin?cell.colStart : cell.colEnd+1;
//for(i=table.rows.length-1;i>=0;i--){
while(i=0;j--){
cc=cells[j];
if(cc.colStart<=colIndex){
if(cc.colStart=colIndex){
cc.colSpan++;
cc.colEnd++;
i+=cc.rowSpan-1;
}else{
td=row.insertCell(cc.colStart!=colIndex && (cc.colEnd==colIndex-1 || j==cells.length-1) ? j+1 : j);
}
//if(cc.colStart==colIndex){
// td=row.insertCell(j);
//}else if(cc.colEnd==colIndex-1){
// td=row.insertCell(j+1);
//}else if(cc.colSpan>1 && cc.colEnd>=colIndex){
// cc.colSpan++;
//}else if(j==cells.length-1 && cc.colEnd=0;i--){
cells= table.rows[i].cells;
for(j=cells.length-1;j>=0;j--){
if(cells[j].rowEnd>=rowIndex){
cells[j].rowSpan++;
k+=cells[j].colSpan;
}
}
}
cells= table.rows[0].cells;
for(j=cells.length-1;j>=0;j--){
k -= cells[j].colSpan;
}
row = table.insertRow(rowIndex);
while(k++ <0){
row.insertCell(0).innerHTML=' ';
}
TQE.updateCellsStatus(table);
cells = row.cells;
cells2 = table.rows[ bBegin ? rowIndex+1 : rowIndex-1].cells;
j=cells2.length-1;
for(i=cells.length-1;i>=0;i--){
while(j>=0 && cells2[j].colStart > cells[i].colStart ) j--;
if(j>=0 && cells2[j].colStart == cells[i].colStart && cells2[j].colEnd == cells[i].colEnd ){
cells[i].style.backgroundColor = cells2[j].style.backgroundColor;
}
}
};
TQE.deleteCol=function(cell){
var table=cell.parentNode.parentNode.parentNode,rows=table.rows,td, i,j, start,end;
TQE.updateCellsStatus(table);
start=cell.colStart;
end=cell.colEnd;
for(i=rows.length-1;i>=0;i--){
for(j=Math.min(end,rows[i].cells.length-1);j>=0;j--){
td=rows[i].cells[j];
if(td.colEnd>=start && td.colStart<=end){
if(td.colStart>=start && td.colEnd<=end) rows[i].removeChild(td);
else if(td.colStartend) td.colSpan -= 1+end-start;
else if(td.colStart=start) td.colSpan -= td.colEnd-start+1;
else if(td.colStart<=end && td.colEnd>end){ td.colSpan -= 1+end-td.colStart; td.innerHTML='';}
}
}
if(rows[i].cells.length<1) rows[i].parentNode.removeChild(rows[i]);
}
if(rows.length<1) table.parentNode.removeChild(table);
};
TQE.deleteRow=function(cell){
var table=cell.parentNode.parentNode.parentNode,rows=table.rows,nextRow,td,td2, i,j,k, start,end;
TQE.updateCellsStatus(table);
start=cell.rowStart;
end=cell.rowEnd;
delRowCount=cell.rowSpan;
nextRow=rows[end+1];
for(i=Math.min(end,rows.length-1);i>=0;i--){
for(j=rows[i].cells.length-1;j>=0;j--){
td=rows[i].cells[j];
if(td.rowEnd>=start && td.rowStart<=end) {
if(td.rowStart>=start && td.rowEnd<=end) rows[i].removeChild(td);
else if(td.rowStartend) td.rowSpan -= delRowCount;
else if(td.rowStart=start) td.rowSpan -= td.rowEnd-start+1;
else if(td.rowStart<=end && td.rowEnd>end){
if(nextRow){
for(k=0;ktd.colEnd){
break;
}
}
td2=nextRow.insertCell(k);
td2.rowSpan= td.rowSpan-delRowCount;
td2.colSpan=td.colSpan;
td2.colStart=td.colStart;
td2.colEnd=td.colEnd;
td2.style.backgroundColor=td.style.backgroundColor;
}
rows[i].removeChild(td);
}
}
}
if(rows[i].cells.length<1) rows[i].parentNode.removeChild(rows[i]);
}
if(rows.length<1) table.parentNode.removeChild(table);
};
TQE.formatHTML=function(htmStr){
return htmStr.replace(/\s*<(p|table|tr|hr|div|object|ol|li|ul|h[1-6])(?![a-z])/ig,'\n<$1')
.replace(/<\/(p|table|div|object|ol|ul|h[1-6])>\s*/ig,'$1>\n')
.replace(/(<(?:br|hr)(?![a-z0-9])[^>]*>)\s*/ig,'$1\n')
.replace(/^\s*/,'').replace(/\s*$/,'')
};
//常用工具栏模式
TQE.toolbarMode={
admin:{left:['paragraph','fontsize','|','bold','italic','underline','forecolor','backcolor','removeformat','|','justifyleft','justifycenter','orderedlist','unorderedlist',['justifyright','|','indent','outdent','|','superscript','subscript'],
'||','createlink','insertimage','inserttable',['splitpage','inserthorizontalrule'],'|','insertmusic','insertflash','insertvideo',
'||','cleanword','typeset'],
right:['toolbarmode','fullscreen','|','help']},
bbs:{left:['fontsize','|','bold','italic','underline','forecolor','backcolor','removeformat','|','justifyleft','justifycenter','justifyright',
'||','createlink','insertimage','|','insertface','insertmusic','insertflash','insertvideo','|','typeset'],
right:['toolbarmode','fullscreen','|','help']},
user:{left:['fontsize','|','bold','italic','underline','forecolor','backcolor','removeformat','|','justifyleft','justifycenter','orderedlist',['justifyright','unorderedlist','|','indent','outdent','|','inserthorizontalrule'],
'||','createlink','insertimage','insertvideo','|','typeset'],
right:['toolbarmode','fullscreen','|','help']},
mini:{left:['fontsize','|','bold','italic','underline','forecolor','backcolor','removeformat','|','align','|','createlink','insertimage'],
right:['help']},
message:{left:['insertface','|','bold','italic','underline','forecolor','removeformat'],
right:['help']},
full:{left:['paragraph','fontname','fontsize','|','bold','italic','underline','strikethrough','forecolor','backcolor','removeformat',
'||','align','list','iodent',['superscript','subscript'],
'||','createlink','unlink','insertimage','inserttable','inserthorizontalrule','splitpage','insertface','|','insertmusic','insertflash','insertvideo',
'||','cleanword','typeset'],
right:['toolbarmode','fullscreen','mode','|','help']},
normal:{left:['paragraph','fontsize','|','bold','italic','underline','forecolor','backcolor','removeformat',
'||','justifyleft','justifycenter','orderedlist','unorderedlist',
'||','createlink','insertimage','inserttable','|','insertvideo','|','typeset'],
right:['toolbarmode','fullscreen','|','help']}
};
//可用的按钮
TQE.toolbarBottons={
paragraph:{
text:'段落',
click:function($,sender){
var o=TQE.find($.objId+'Paragraph'),i;
if(null==o){
var s='',fs=$.config.paragraphs;
for(i=0;i < fs.length; i++){
s +='';
}
o = TQE.CE('DIV',$.objId+'Paragraph',s,true);
o.className='ePopPanel';
TQE._noSel(o);//,'DIV'
TQE.listenTags(o,'DIV','click',function(){
TQE.hidePop();
var pv=this.getAttribute('paraValue');
if(isIE)pv ='<'+pv+'>';
$.exeCmd('FormatBlock', pv);
});
if(isIE6){
var es = TQE._tags(o,'DIV');
for(i=es.length-1;i>=0;i--){
$._ieMouseStyle(es[i],'eMenuItem','eMenuItemUp','eMenuItem');
}
}
}
TQE.pop(o,sender);
}
},
fontsize:{
text:'文字大小',
click:function($,sender){
var o=TQE.find($.objId+'FontSize');
if(null==o){
var s='',i,es,
fs=$.config.fontsizes;
for(i=0;i < fs.length; i++){
s +='';
}
o = TQE.CE('DIV',$.objId+'FontSize',s,true);
o.className='ePopPanel';
TQE._noSel(o);//,'DIV'
TQE.listenTags(o,'DIV','click',function(){TQE.hidePop();$.exeCmd('FontSize', this.getAttribute('paraValue'))});
if(isIE6){
es = TQE._tags(o,'DIV');
for(i=es.length-1;i>=0;i--){
$._ieMouseStyle(es[i],'eMenuItem','eMenuItemUp','eMenuItem');
}
}
}
TQE.pop(o,sender);
}
},
fontname:{
text:'字体',
click:function($,sender){
var o=TQE.find($.objId+'FontName');
if(null==o){
var es,i,s='',fs=$.config.fontnames;
for(i=0;i < fs.length; i++){
s +='';
}
o = TQE.CE('DIV',$.objId+'FontName',s,true);
o.className='ePopPanel';
TQE._noSel(o);//,'DIV'
TQE.listenTags(o,'DIV','click',function(){TQE.hidePop();$.exeCmd('FontName', this.getAttribute('paraValue'))});
if(isIE6){
es = TQE._tags(o,'DIV');
for(i=es.length-1;i>=0;i--){
$._ieMouseStyle(es[i],'eMenuItem','eMenuItemUp','eMenuItem');
}
}
}
TQE.pop(o,sender);
}
},
forecolor:{
text:'文本颜色',
click:function($,sender){
$._showColorSelectUI(sender,'forecolor');
}
},
backcolor:{
text:'背景色',
click:function($,sender){
$._showColorSelectUI(sender, isIE ? 'backcolor':'hilitecolor');
}
},
bold:{
text:'粗体',
click:null
},
italic:{
text:'斜体',
click:null
},
underline:{
text:'下划线',
click:null
},
strikethrough:{
text:'删除线',
click:null
},
removeformat:{
text:'消除格式',
click:function($,sender){
TQE.hidePop();
$.exeCmd('removeformat');
if(isGecko || isOpera) return;//ff,opera本身已完美的清理格式, 其他的浏览器还要加代码处理word的代码
var rang=$._getRange(),
clear=function(s){return s.replace(/<\/?span[^>]*>/ig,'').replace(/]*>/ig,'
').replace(/
]*>/ig,'
');},
htm='',
str=rang.htmlText,
nodes,
i;
if(str){//ie6,7,8
$.insertHtml(clear(str));
}else{//ie9,chrome
nodes=rang.cloneContents().childNodes;
for(i=0;i
'+(title?title:href)+'');
return false;
}
var n=$.focusNode();
do{
if(n.tagName=='A'){
if(''==target) n.removeAttribute('target') ;
else n.setAttribute('target',target);
if(''==title) n.removeAttribute('title');
else n.setAttribute('title',title);
break;
}
}while(n = n.parentNode);
return false;
};
o = $._popFormUI($.objId+'CreateLink',resStrCreateLink, resStrInsertLinkUI, okClick,null, $.config.linkUploadUrl,$.config.linkFileTypes,$.config.linkFileSize,'link');
TQE.drag(o);
}
if(!TQE.pop(o,sender)) return;
var f = TQE._tags(o,'FORM')[0],
es = f.elements,
n = $.focusNode();
f.reset();
do{
if(n.tagName=='A'){
es['url'].value=n.getAttribute('href');
es['title'].value=n.getAttribute('title');
$.__selectOption(es['target'],n.getAttribute('target'));
break;
}
}while(n = n.parentNode);
es['url'].focus();
}
},
unlink:{
text:'删除链接',
click:null
},
inserttable:{
text:'插入表格',
click:function($,sender){
var o=TQE.find($.objId+'InsertTable');
if(null==o){
var s=resStrTableContextUI + '',i=0,j=0;
for(i=0;i<5;i++){
s+='';
for(j=0;j<8;j++){
s+=' ';
}
s+=' ';
}
s+='
1 × 1
';
o = TQE.CE('DIV',$.objId+'InsertTable', s ,true);
o.className='ePopPanel';
TQE._noSel(o);//,'TABLE,TR,TD,DIV');
TQE.listenTags(o.lastChild,'TD','click',function(){
TQE.hidePop();
var i,j,s='';
for(i=this.parentNode.rowIndex;i>=0;i--){
s+='';
for(j=this.cellIndex;j>=0;j--){
s+= isIE ? ' ':' ';
}
s+=' ';
}
s+='
';
//s = ''+s+'
';
//$.exeCmd('InsertParagraph');
//$.exeCmd('FormatBlock','p');
$.insertHtml(s);
}
);
TQE.listenTags(o.lastChild,'TD','mouseover',function(){
var i,j,ci=this.cellIndex, row=this.parentNode,ri=row.rowIndex,table=row.parentNode.parentNode, rc=table.rows.length,cc=row.cells.length;
for(i=0;i1 || td.colSpan>1));
showObj(miSplit.nextSibling, miMerge.style.display!='none' || miSplit.style.display!='none');
}else{
showObj(propertyPanel, 0);
}
showObj(insertPanel.previousSibling, propertyPanel.style.display!='none' && insertPanel.style.display!='none');
var objs=o.firstChild.getElementsByTagName('A'),
alignTD=function(align,vAlign){
if(selectedCells.length>0){
for(var i=selectedCells.length-1;i>=0;i--){
selectedCells[i].align=align;
selectedCells[i].vAlign=vAlign;
}
}else if(td){
td.align=align;
td.vAlign=vAlign;
}
};
for(i=objs.length-1;i>=0;i--){
objs[i].href='#';
objs[i].onclick=function(){
switch(this.id){
case 'eTableAlignDefault':table.align=''; break;
case 'eTableAlignLeft':table.align='left'; break;
case 'eTableAlignCenter':table.align='center'; break;
case 'eTableAlignRight':table.align='right'; break;
case 'eCellAlignLT':alignTD('left','top');break;
case 'eCellAlignCT':alignTD('center','top');break;
case 'eCellAlignRT':alignTD('right','top');break;
case 'eCellAlignLC':alignTD('left','middle');break;
case 'eCellAlignCC':alignTD('center','middle');break;
case 'eCellAlignRC':alignTD('right','middle');break;
case 'eCellAlignLB':alignTD('left','bottom');break;
case 'eCellAlignCB':alignTD('center','bottom');break;
case 'eCellAlignRB':alignTD('right','bottom');break;
}
$.focus();
return false;
};
}
objs=o.firstChild.getElementsByTagName('INPUT');
for(i=objs.length-1;i>=0;i--){
if(table) objs[i].value= undefined==table[objs[i].id] ? '' : table[objs[i].id];
objs[i].onblur=function(){
if(''==this.value ) table.removeAttribute(this.id);
else table[this.id]=this.value;
table.style.borderCollapse = table.cellSpacing<1 && table.border==1 ? 'collapse':'';
};
}
miMerge.onclick=function(){TQE.hidePop();$.mergeSelectedCells();$.focus(); return false;}
miSplit.onclick=function(){TQE.hidePop();$.splitCell(td);$.focus();return false;}
//--
if(!TQE.pop(o,sender)) return;
}
},
insertimage:{
text:'插入图片',
click:function($,sender){
$img_modal.modal('show');
/*var o=TQE.find($.objId+'InsertImage');
if(null==o){
//var s='图片网址: 替换文本: 尺寸: × px 对齐:默认 居上 文本上方 居中 绝对居中 基线 底部 绝对底部 左 右 边框: ';
var okClick=function(){
TQE.hidePop();
var es=this.form.elements;
$.insertImage(es['url'].value,es['width'].value,es['height'].value,es['border'].value, es['alt'].value,es['align'].value);
return false;
};
o = $._popFormUI($.objId+'InsertImage',resStrInsertImage, resStrInsertImageUI, okClick ,['width','height','border'], $.config.imageUploadUrl,$.config.imageFileTypes, $.config.imageFileSize, 'image');
TQE.drag(o);
}
if(!TQE.pop(o,sender)) return;
var f = TQE._tags(o,'FORM')[0],
es = f.elements,
r=$._getRange(),
n=r.commonAncestorContainer;
f.reset();
if(n){ //标准dom
if(!r.collapsed && r.startContainer == r.endContainer && r.startOffset - r.endOffset < 2 && r.startContainer.hasChildNodes()){
n=r.startContainer.childNodes[r.startOffset];
}
if(n.tagName!='IMG' && IEVersion>=9 && ''===r.toString()){
if(undefined===r.startContainer.length && r.startContainer.firstChild===r.endContainer.previousSibling)n=r.startContainer.firstChild;
else if(r.endContainer.lastChild===r.startContainer.nextSibling)n=r.endContainer.lastChild;
else if(r.startContainer.length == r.startOffset && r.endOffset==0 && r.startContainer.nextSibling==r.endContainer.previousSibling){
n=r.startContainer.nextSibling;
}
}
if(!n || n.tagName!='IMG') n=null;
}else if(r.length && r.item(0).tagName=='IMG'){ //isIE, ie6,7,8
n=r.item(0);
}
if(n && 'IMG'==n.nodeName){
es['url'].value=n.getAttribute('src');
es['width'].value=n.width;
es['height'].value=n.height;
es['border'].value=n.border;
es['alt'].value=n.alt;
$.__selectOption(es['align'],n.align);
}
es['url'].focus();*/
}
},
insertface:{
text:'表情',
click:function($,sender){
var o=TQE.find($.objId+'InsertFace');
if(null==o){
var i,es,s='';
for( i=1;i<=$.config.faceCount;i++){
s+='
';
}
s+='
';
o = TQE.CE('DIV',$.objId+'InsertFace', s ,true);
o.className='ePopPanel';
TQE._noSel(o);//,'IMG,DIV');
TQE.listenTags(o,'IMG','click',function(){TQE.hidePop();$.insertHtml(' ');});
if(isIE6){
es = TQE._tags(o,'IMG');
for(i=es.length-1;i>=0;i--){
$._ieMouseStyle(es[i],'','imgHover','');
}
}
}
TQE.pop(o,sender);
}
},
insertflash:{
text:'插入Flash',
click:function($,sender){
var o=TQE.find($.objId+'InsertFlash'),form;
if(null==o){
//var s='Flash网址: 尺寸: × px';
var okClick= function(){
TQE.hidePop();
var es=this.form.elements;
$.insertFlash(es['url'].value,es['width'].value,es['height'].value);
return false;
};
o = $._popFormUI($.objId+'InsertFlash',resStrInsertFlash, resStrInsertFlashUI, okClick,['width','height'], $.config.flashUploadUrl,$.config.flashFileTypes,$.config.flashFileSize, 'flash');
TQE.drag(o);
}
if(!TQE.pop(o,sender)) return;
form=TQE._tags(o,'FORM')[0];
form.reset();
form.elements['url'].focus();
}
},
insertmusic:{
text:'插入音频',
click:function($,sender){
var o=TQE.find($.objId+'InsertMusic'),form;
if(null==o){
//var s='音频网址: 自动播放:手动开始 自动开始 ';
var okClick= function(){
TQE.hidePop();
var es=this.form.elements;
$.insertMusic(es['url'].value,es['auto_start'].value);
return false;
};
o = $._popFormUI($.objId+'InsertMusic',resStrInsertMusic, resStrInsertMusicUI, okClick,null, $.config.musicUploadUrl,$.config.musicFileTypes,$.config.musicFileSize, 'music');
TQE.drag(o);
}
if(!TQE.pop(o,sender)) return ;
form=TQE._tags(o,'FORM')[0];
form.reset();
form.elements['url'].focus();
}
},
insertvideo:{
text:'插入视频',
click:function($,sender){
var o=TQE.find($.objId+'InsertVideo'),form;
if(null==o){
//var s='视频网址: 尺寸: × px 自动播放:手动开始 自动开始 视频类型:自动识别 FLV RMVB 其他视频 ';
var okClick= function(){
TQE.hidePop();
var es=this.form.elements;
$.insertVideo(es['url'].value,es['auto_start'].value,es['width'].value,es['height'].value,es['video_type'].value);
return false;
};
o = $._popFormUI($.objId+'InsertVideo',resStrInsertVideo, resStrInsertVideoUI, okClick,['width','height'], $.config.videoUploadUrl,$.config.videoFileTypes,$.config.videoFileSize, 'video');
TQE.drag(o);
}
if(!TQE.pop(o,sender)) return;
form=TQE._tags(o,'FORM')[0];
form.reset();
form.elements['url'].focus();
}
},
cleanword:{
text:'清理Word代码',
click:function($,sender){
TQE.hidePop();
$.cleanWord(true);
}
},
typeset:{
text:'自动排版',
click:function($,sender){
TQE.hidePop();
$.typeset();
/*return;
var o=TQE.find($.objId+'Typeset'),form;
if(null==o){
var resStrTypeset='自动排版', resStrTypesetUI='图片/视频/Flash 左对齐 居中 同时居中下方文本 首行缩进 不修改 使用样式缩进 使用中文空格缩进 清除缩进 ';
var okClick= function(){
TQE.hidePop();
var es=this.form.elements;
$.typeset();
//$.insertVideo(es['url'].value,es['auto_start'].value,es['width'].value,es['height'].value,es['video_type'].value);
return false;
};
o = $._popFormUI($.objId+'Typeset',resStrTypeset, resStrTypesetUI, okClick);
TQE.drag(o);
}
if(!TQE.pop(o,sender)) return;
form=TQE._tags(o,'FORM')[0];
form.reset();
form.elements['url'].focus();
*/
}
},
mode:{
text:'查看源码',
click:function($,sender){
TQE.hidePop();
$.changeMode();
}
},
splitpage:{
text:'插入分页符',
click:function($,sender){
TQE.hidePop();
//$.insertHtml($.config.tplSplitPage,'after');
$.insertHtml($.config.tplSplitPage);
}
},
group:{
text:'',
click:null
},
br:{
text:'',
click:null
},
separator:{
text:'',
click:null
},
fullscreen:{
text:'全屏',
click:function($,sender){
TQE.hidePop();
$.fullScreen();
}
},
toolbarmode:{
text:'工具栏模式',
click:function($,sender){
TQE.hidePop();
$.changeToolbarMode();
}
},
help:{
text:'帮助',
click:function($,sender){
var o=TQE.find($.objId+'TQHelpPanel');
if(null==o){
o = TQE.CE('DIV',$.objId+'TQHelpPanel', '' ,true);
o.className='ePopPanel';
}
TQE.pop(o,sender);
}
}
};
//运行时对象容器
//TQE.rto={};
//explode names;
window.tqEditor=window.tqeditor=window.TQEditor=window.TQE=TQE;
window.isIE=isIE;
window.isIE6=isIE6;
window.IEVersion=IEVersion;
window.isWebkit=isWebkit;
window.isOpera=isOpera;
window.isGecko=isGecko;
})(window);