/************************************************* * TQEditor * Author : TengQiu Li * E-Mail : litqqs@163.com * Copyright : TengQiu Li * Version : 2.3.6 * Site : http://www.e512.net *************************************************/ (function(window,undefined){ if(window.TQE) return; var version='2.3.6',//编辑器版本 ua = navigator.userAgent.toLowerCase(), document=window.document, isIE =!!window.ActiveXObject, //ie // ua.indexOf('trident')>=0 || ua.indexOf('msie 6')>=0 ; isIE6 = isIE && !window.XMLHttpRequest,//ie6 ieTest = /msie ([0-9]+)/.exec(ua), IEVersion = ieTest!=null ? parseInt(ieTest[1]):0, //IE版本号 isWebkit = ua.indexOf('webkit')>=0,//chrome,safari isOpera = ua.indexOf('presto')>=0, //opera isGecko = !isWebkit && !isOpera && ua.indexOf('gecko')>=0, //firefox //相关资源 resStrCreateLink='添加链接', resStrTargetOptions='', resStrInsertLinkUI='网址:
标题:
打开:', resStrInsertImage='插入图片', resStrInsertImageUI='图片网址:
替换文本:
尺寸: × px  
对齐:     边框:', resStrImageContextUI='
网址:
尺寸: × px 重设大小
替换文本: 边框:
排版: 默认 | 左浮动 | 居中 | 右浮动 | 上对齐 | 中对齐 | 下对齐

链接:
', resStrInsertFlash='插入动画', resStrInsertFlashUI='Flash网址:
尺寸:× px', resStrInsertMusic='插入音频', resStrInsertMusicUI='音频网址:
自动播放:', resStrInsertVideo='插入视频', resStrInsertVideoUI='视频网址:
尺寸:× px
自动播放:
视频类型:', resStrInsertRow='插入行', resStrInsertCol='插入列', resStrDeleteRow='删除行', resStrDeleteCol='删除列', resStrDeleteTable='删除表格', resStrTableContextUI='
合并单元格拆分单元格
表格排版: 居左 | 居中 | 居右
内容对齐


宽度
边框
间距
填充

插入表格
', resStrNoColor='无色', resStrOK='确定', resStrCenal='取消', resStrUpload='上传', resStrClose='关闭', resStrVersion='版本', resStrAuthor='作者', resStrSite='官网', resStrMail='邮箱', resStrPageTitlePre='分页标题: ', TQE=function(objId,userConfig) { var $=this,config=TQE.clone(TQE.config); $.objId = objId; if(userConfig){ if(userConfig.height && userConfig.height != "auto" ){ userConfig.height= parseInt(userConfig.height); if( isNaN(userConfig.height) )userConfig.height='auto'; } for(var k in userConfig){ config[k] = userConfig[k]; } } if(typeof config.toolbar =='string'){ var tm=TQE.toolbarMode[config.toolbar]; if(!tm) tm=TQE.toolbarMode.normal; config.toolbar=tm.left; if(!userConfig || undefined===userConfig.toolbarRight)config.toolbarRight=tm.right; } $.config = config; $.hasFocus=false; $._containerDiv=null; $._toolbarDiv=null; $._clientDiv=null; $._statusDiv=null; //Methods $.init=function(){ $.obj = TQE.find($.objId); if(!$.obj){ if($.config.debug) throw('缺少ID为 '+$.objId+' 表单元素'); return; } if($.obj.editor) return;//对象不存在或已执行过 $.obj.editor = $; if (!$.config.width || $.config.width == "auto") { if($.obj.style.width){$.config.width = $.obj.style.width; } else if($.obj.cols){ $.config.width = ($.obj.cols * 8)+'px'; } else{ $.config.width = '100%'; } } if (!$.config.height || $.config.height == "auto") { if($.obj.style.height){ $.config.height = parseInt($.obj.style.height,10); } else if($.obj.offsetHeight){ $.config.height = $.obj.offsetHeight } else if($.obj.rows){ $.config.height = $.obj.rows * 17 } else{ $.config.height = 200; } } //toolbar var i,j, btn,code ='
'; //code +=$._toobarCode($.config.toolbar, $.config.toolbarRight) code += '
'+ //编辑区 '
'+ ''+ '
'+ //''+ '
'; if (!$.config.debug) { $.obj.style.display = "none"; } var e =TQE.CE('DIV','TQEditorContainer_'+$.objId, code ); e.className='eEditor'; e.style.width=$.config.width; $.obj.parentNode.insertBefore(e, $.obj); $._containerDiv = e; $._toolbarDiv = TQE.find($.objId+'_EditorToolBar'); $._clientDiv = TQE.find($.objId+'_EditorClient'); //-- if('function'===typeof $.config.oninit) $.config.oninit.call($); $._initContent($.obj.value); $.changeToolbarMode($.config.advToolbarMode,true); $.obj.focus = function(){this.editor.focus();} //-- $._statusDiv = e.lastChild; if(false==$.config.resize)$._statusDiv.style.display='none'; $._statusDiv.onmousedown=function(a){ if($._containerDiv.style.position=='absolute') return; var x,y,obj,maskDiv, o=this, //$=this.context, p=TQE.pos(this), scrollTop = TQE._docST(), scrollLeft = TQE._docSL(), h = $.config.height, w=$._containerDiv.offsetWidth-2, bChangeWidth = this.style.cursor == 'se-resize', oldTop = TQE.pos($._clientDiv).y; $._showTableContext(0); if(isIE){ a=window.event; obj=a.srcElement; x=scrollLeft + a.clientX-p.x; y=scrollTop + a.clientY-p.y; }else{ obj=a.target; x=a.pageX-p.x; y=a.pageY-p.y; } bChangeWidth = bChangeWidth || obj===o.firstChild && 'h'!=$.config.resize ; o.mouseout=o.onmouseleave=null; //$.setOpacity(o,80); //if(isWebkit || isIE6){ //maskDiv=TQE.CE('DIV','','',true); //maskDiv.className='eDragMaskDiv'; //maskDiv.style.cursor= bChangeWidth ? 'se-resize':'s-resize'; //maskDiv.style.height=Math.max(document.documentElement.clientHeight, document.body.scrollHeight)+'px'; //} var mousemove=function(a){ if(isIE){ a=window.event; a.pageX=scrollLeft + a.clientX; a.pageY=scrollTop + a.clientY; } var deltaH=oldTop - TQE.pos($._clientDiv).y, ty=Math.max(50-h+p.y-deltaH, a.pageY-y),tx=Math.max(100-w+p.x, a.pageX-x); if(bChangeWidth){ //o.style.width= tx-p.x + w +'px'; $.setWidth(tx-p.x + w); } //o.style.top=ty +'px'; $.setHeight(ty-p.y + h + deltaH ); }, mouseup=function(a){ $.focus(); $._popTableContext(); //$.setOpacity(o,100); }; maskDiv = TQE._draging(mousemove,mouseup,o); maskDiv.style.cursor= bChangeWidth ? 'se-resize':'s-resize'; }; }; $._toobarCode=function(leftButtons,rightButtons){ var i,btn,code =''; // if(rightButtons.length){ //code +=''; code +=''; } //工具组 //code +=''+ //工具组完 code += ''+ //工具组完 '
'; return code; }; $._btnCode=function(tn, groupFlag){ var submenu='',btn,code,styleCode; if('||'===tn) tn='group'; else if('|'===tn) tn='separator'; else if('string'!==typeof tn){//子菜单 submenu= 'submenu="'+tn.join(',')+'" '; tn='submenu'; } btn = TQE.toolbarBottons[tn]; if(!btn) return ''; styleCode=function(btn){return 'id="eBTN'+tn+'" class="eButton"' + (btn.css ? ' style="'+btn.css+'"':'' ); }; switch(tn){ case 'group': if(!groupFlag) return ''; //code='