📄 正在查看:twcms/plugin/editor_um/admin_content_add_after.htm
大小:1,923 字节 · 修改:2014-01-08 01:16:48 · 行数:65
1<script type="text/javascript">
2(function(){
3 // 只加载一次
4 if(typeof window.editor_once != 'undefined') return;
5 window.editor_once = 1;
6
7 var getWidth = function() {
8 var w = $(".contadd>table").width() - 506;
9 w = parseInt(w*0.97);
10 $("input[name='title'], textarea[intro='intro'], .addition, #tw_dropbox").width(w);
11 typeof setImgBut == 'function' && setImgBut(); // 定位图集上传按钮 (注意:文章时,没有这函数)
12 return $("input[name='title']").outerWidth();
13 }
14
15 // 获取后台路径
16 window.admurl = (function() {
17 var url = document.URL || location.href;
18 return url.substr(0, url.lastIndexOf("/"));
19 })();
20
21 // 获取首页路径
22 window.weburl = (function() {
23 return admurl.substr(0, admurl.lastIndexOf("/"));
24 })();
25
26 window.UMEDITOR_HOME_URL = weburl+"/twcms/plugin/editor_um/umeditor/";
27
28 twLoadCss(UMEDITOR_HOME_URL+"themes/default/css/umeditor.min.css");
29 twLoadJs(UMEDITOR_HOME_URL+"umeditor.config.js", UMEDITOR_HOME_URL+"umeditor.min.js", UMEDITOR_HOME_URL+"lang/zh-cn/zh-cn.js", function(){
30 $("#content").removeAttr("class");
31
32 var ue = UM.getEditor("content", {initialFrameWidth : getWidth()-3, imageUrl : UMEDITOR_CONFIG.imageUrl + '{$edit_cid_id}'});
33 window.editor_api = {
34 content : {
35 obj : ue,
36 get : function() {
37 return this.obj.getContent();
38 },
39 set : function(s) {
40 return this.obj.setContent(s);
41 },
42 focus : function() {
43 return this.obj.focus();
44 }
45 }
46 }
47
48 // 编辑器内容发生改变时自动保存
49 if(action == "add") {
50 ue.addListener('contentChange', function() {
51 ue.sync();
52 autoSave();
53 });
54 }
55
56 $(window).resize(function(){
57 var w = getWidth()-3;
58 $(".edui-container").width(w);
59 $(".edui-body-container").css({"width" : w-20});
60 $(".edui-editor-body textarea").eq(1).css({"width" : w});
61 });
62 });
63})();
64</script>
65