鑒于品牌空間后臺的編輯器功能較差,并且非常不穩(wěn)定,我們決定把這個編輯器升級!本來是打算使用百度的uEditor來的,只是后來發(fā)現(xiàn)品牌空間官方對編輯器做了一些修改,很難融合到其它編輯器中了,所以,只好將該編輯器升級至最新的版本,以提升功能和使用體驗。
品牌空間使用的是xhEditor,版本還是1.0的RC版本。目前最新版本為:xhEditor v1.1.14??梢栽谶@個地址下載:
http://xheditor.com/download
下載以后:
1、將src\xheditor-1.1.14-zh-cn.js文件,重命名到:\static\js\editor\xheditor-zh-cn.js;
2、將xheditor_skin目錄和xheditor_emot,復(fù)制到\static\js\editor\ 目錄下;
3、修改\static\js\editor\xheditor-zh-cn.js 文件:
文件頭部增加函數(shù):
function switchImgbutton(contid) {
$("#e_cont").load(admincpfilename+'?action=ajax_editor&cont='+contid);
$("#e_image_ctrl a").removeClass('current');
$("#e_btn_"+contid).addClass('current');
}
找到var htmlImg變量聲明,修改為:
if(enablealbum == 1) {
var htmlImg = '<div style="width:550px; opacity:1; padding:5px 0;"><ul id="e_image_ctrl" class="imguptype" style="cursor: move;"><li><a id="e_btn_www" class="current" hidefocus="true" href="javascript:;">網(wǎng)絡(luò)圖片</a></li><li><a id="e_btn_albumlist" hidefocus="true" href="javascript:;" class="">相冊圖片</a></li><li><a id="e_btn_imgattachlist" hidefocus="true" href="javascript:;" class="">圖片列表</a></li><li><a id="e_btn_multi" hidefocus="true" href="javascript:;" class="">批量上傳</a></li></ul><div id="e_cont"></div></div>';
} else {
var htmlImg = '<div style="width:550px; opacity:1; padding:5px 0;"><ul id="e_image_ctrl" class="imguptype" style="cursor: move;"><li><a id="e_btn_www" class="current" hidefocus="true" href="javascript:;">網(wǎng)絡(luò)圖片</a></li></ul><div id="e_cont"></div></div>';
}
在this.showImg=function()函數(shù)的末尾增加:
//編輯器上傳,品牌空間功能專用圖片工具;
$(function() { switchImgbutton('www');});
4、修改E:\source\adminfunc\editor_ajax_img.func.php文件
將其中2部分如下代碼:
var msgeditor;
msgeditor=$("#message")[0].editor;
修改為:
var msgeditor;
msgeditor = $("#message").xheditor();
//新版本的xheditor獲取方式與之前不同,必須修改,否則無法獲取editor。
其實,到現(xiàn)在為止,編輯器已經(jīng)可以使用了,只是還是之前的一些功能,要想把所有功能開放出來,需要如下操作:
5、修改\source\adminfunc\brandpost.func.php文件
將如下代碼:
<textarea cols=\"100\" id=\"{$showarr[name]}\" name=\"{$showarr[name]}\" rows=\"20\" style=\"width:600px;\" class=\"xheditor {tools:'Bold,Italic,Underline,Strikethrough,FontSize,FontColor,BackColor,Separator,Align,List,Separator,Link,Img,About',skin:'default'}\">{$showarr[value]}</textarea>
修改為:
<textarea cols=\"100\" id=\"{$showarr[name]}\" name=\"{$showarr[name]}\" rows=\"20\" style=\"width:800px;\" class=\"xheditor-mfull\">{$showarr[value]}</textarea>
為了方便大家修改,我們把需要替換和修改的文件重新打包,下載地址如下:
http://115.com/file/bed43n50#
[wangaiche.com]_xhEditor1.1.14_with_brand_files.zip
文章由玩改車(http://wangaiche.com) 技術(shù)支持團隊原創(chuàng),轉(zhuǎn)載請注明來源。
|