appwfPhraseBtn_wev8.js
10.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
UE.registerUI('wfphrasebutton',function(editor,uiName){
var language = readCookie("languageidweaver");
var msg = SystemEnv.getHtmlNoteName(3449,language);
var labelname = "@";
var initphrase = function () {
//点击其他地方,隐藏常用批示语选择框
jQuery("html").live('mouseup', function (e) {
if (jQuery("#_signinputphraseblock").is(":visible") && !!!jQuery(e.target).closest("#_signinputphraseblock")[0]) {
jQuery("#_signinputphraseblock").hide();
jQuery("#_addPhrasebtn").show()
jQuery("#cg_splitline").show();
jQuery("#addphraseblock").hide();
}
e.stopPropagation();
});
try {
jQuery("html", jQuery("#remark").find("iframe")[0].contentWindow.document).live('mouseup', function (e) {
if (jQuery("#_signinputphraseblock").is(":visible") && !!!jQuery(e.target).closest("#_signinputphraseblock")[0]) {
jQuery("#_signinputphraseblock").hide();
jQuery("#_addPhrasebtn").show()
jQuery("#cg_splitline").show();
jQuery("#addphraseblock").hide();
}
e.stopPropagation();
});
} catch (e) {}
//combox html
var comboxHtml = "" +
"<div id=\"_signinputphraseblock\" class=\"_signinputphraseblockClass\" style='display:none;z-index:999;'>" +
" <div class=\"phrase_arrowsblock\"><img src=\"/images/ecology8/workflow/phrase/addPhrasejt_wev8.png\" width=\"14px\" height=\"14px\"></div>" +
" <div class=\"cg_block\" style='background:#fff;'>" +
" <div id=\"_signinputphrasecontentblock\">" +
" <ul>" +
" <li style=\"padding:2px;\"></li>" +
" </ul>" +
" </div>" +
" <div class=\"cg_splitline\" id=\"cg_splitline\" style='display:none;'></div>";
if(_hasPrivateRight){
comboxHtml+=" <ul>" +
" <li >" +
" <div class=\"cg_optblock\" style=\"text-align:center;margin:2px 0 4px 0px;\">" +
" <span class=\"phrase_btn\" style=\"color:#1ca96f;\" id=\"_addPhrasebtn\">" +
" <img src=\"/images/ecology8/workflow/phrase/addPhrase_wev8.png\" height=\"22px\" width=\"22px\" style=\"vertical-align:middle;\"/>" +
" <span style=\"display:none;\"> " +
SystemEnv.getHtmlNoteName(3450,language) +
" </span>" +
" </span>" +
" </div>" +
" </li>" +
" </ul>" +
" <div id=\"addphraseblock\" class=\"addphraseblockClass\">" +
" <input type=\"text\" name=\"phraseinput\" id=\"phraseinput\" class=\"phraseinputClass\" style=\"\"><span style=\"margin-left:12px;color:#3c82b0;cursor:pointer;\" id=\"phraseqdbtn\">"+SystemEnv.getHtmlNoteName(3451,language)+"</span>" +
" </div>";
}
comboxHtml+=" </div>" +
"</div>";
var comboxobj = jQuery(comboxHtml);
//插入dom对象
jQuery(document.body).append(comboxobj);
//从隐藏的select中获取常用批示语
var phraseselect = jQuery("#phraseselect option");
var _ul = comboxobj.find("#_signinputphrasecontentblock ul");
for (var i=1; i<phraseselect.length; i++) {
var phrasejsondata = jQuery(phraseselect[i]);
var _style = "";
if (_ul.children("li").length > 3) {
_style = " style='display:none;' ";
}
_ul.append("<li " + _style + " class=\"cg_item\"><span class='cg_detail'>" + phrasejsondata.html() + "</span></li>");
}
//删除‘添加常用批示语’ 文字
if (comboxobj.find("#_signinputphrasecontentblock ul li").length > 1) {
jQuery(comboxobj).find("#cg_splitline").show();
} else {
if(_hasPrivateRight){
comboxobj.find("#_signinputphrasecontentblock ul").append("<li style=\"text-align:center;\" id='phrasedesc'><span class='cg_detail'>"+SystemEnv.getHtmlNoteName(3450,language)+"</span></li>");
}else{
comboxobj.find("#_signinputphrasecontentblock ul").append("<li style=\"text-align:center;\" id='phrasedesc'><span class='cg_detail'>"+SystemEnv.getHtmlNoteName(4096,language)+"</span></li>");
}
}
//添加按钮 鼠标交互时事件
jQuery("#_addPhrasebtn").hover(function () {
jQuery(this).children("img").hide();
jQuery(this).children("span").show();
}, function () {
jQuery(this).children("img").show();
jQuery(this).children("span").hide();
});
jQuery("#_addPhrasebtn").bind("click", function () {
jQuery(this).hide();
jQuery("#cg_splitline").hide();
jQuery("#addphraseblock").show();
jQuery("#phraseinput")[0].focus();
});
jQuery("#_signinputphrasecontentblock ul li").live("click", function () {
var liarray = jQuery("#_signinputphrasecontentblock ul li");
var j = 0;
for (j=0; j<liarray.length; j++) {
if (liarray[j] == this) {
break;
}
}
try {
_onAddPhrase(jQuery("#phraseselect option")[j].value);
} catch (e) {
}
jQuery("#_signinputphraseblock").hide();
jQuery("#_addPhrasebtn").show()
jQuery("#cg_splitline").show();
jQuery("#addphraseblock").hide();
});
jQuery("#phraseqdbtn").bind("click", function () {
var phrasetext = jQuery("#phraseinput").val();
if (phrasetext != '') {
phrasetext = jQuery("<div>" + phrasetext + "</div>").text();
jQuery("#_signinputphrasecontentblock ul").append("<li class=\"loaddingli\"><span class='cg_detail' style='color:#7f7f7f;'>"+SystemEnv.getHtmlNoteName(3453,language)+"</span></li>");
jQuery("#_signinputphrasecontentblock").scrollTop(jQuery("#_signinputphrasecontentblock ul").height());
jQuery.ajax({
type: "get",
cache: false,
url: "/workflow/sysPhrase/PhraseOperate.jsp?operation=add&phraseShort=" + encodeURI(phrasetext) + "&phraseDesc=" + encodeURI(phrasetext) + "&iswf=1",
contentType : "application/x-www-form-urlencoded;charset=UTF-8",
complete: function(){
},
error:function (XMLHttpRequest, textStatus, errorThrown) {
} ,
success : function (data, textStatus) {
jQuery("#phraseinput").val("");
jQuery("#phrasedesc").remove();
var lastli = jQuery("#_signinputphrasecontentblock ul .loaddingli");
data = eval("(" + data + ")");
var _success = data.success;
var _msg = data.msg;
if(_success == "0"){
window.top.Dialog.alert(_msg);
lastli.remove();
return;
}
if (jQuery("#_signinputphrasecontentblock ul li").length > 3) {
jQuery("#_signinputphrasecontentblock").css("height", jQuery("#_signinputphrasecontentblock").height() + "px");
jQuery("#_signinputphrasecontentblock").css("overflow", "hidden");
jQuery("#_signinputphrasecontentblock").perfectScrollbar({horizrailenabled:false,zindex:1000});
}
lastli.removeClass("loaddingli");
lastli.addClass("cg_item");
lastli.html("<span class='cg_detail'>" + phrasetext + "</span>");
//jQuery("#_signinputphrasecontentblock ul").append("<li class=\"cg_item\"><span class='cg_detail'>" + phrasetext + "</span></li>");
var phraseselect = jQuery("#phraseselect").append("<option value=\"" + phrasetext + "\">" + phrasetext + "</option>");
//jQuery("#_signinputphrasecontentblock").scrollTop(999);
//jQuery("#_signinputphrasecontentblock").scrollTop(jQuery("#_signinputphrasecontentblock ul").height());
}
});
}
jQuery("#_addPhrasebtn").show()
jQuery("#cg_splitline").show();
jQuery("#addphraseblock").hide();
});
};
//加常用短语
var _onAddPhrase = function (phrase){
if(phrase!=null && phrase!=""){
$GetEle("remarkSpan").innerHTML = "";
try{
var curContent = UE.getEditor("remark").getContent();
var setFlag = true; //true 追加内容,false清空再追加内容
if(!!!curContent)
setFlag = false; //第一次添加批示语时不出现空行
UE.getEditor("remark").setContent(phrase, setFlag);
}catch(e){
}
}
}
var _firstclc = true;
//注册按钮执行时的command命令,使用命令默认就会带有回退操作
editor.registerCommand(uiName,{
execCommand:function() {
}
});
//创建一个button
var btn = new UE.ui.Button({
//按钮的名字
name:uiName,
labelname:SystemEnv.getHtmlNoteName(3452,language),
//提示
title:SystemEnv.getHtmlNoteName(3452,language),
//需要添加的额外样式,指定icon图标,这里默认使用一个重复的icon
/*cssRules :"background-image: url('/ueditor/custbtn/images/phraselist_wev8.png') !important;background-position: -990px 1px!important;",*/
//点击时执行的命令
onclick:function () {
//这里可以不用执行命令,做你自己的操作也可
//editor.execCommand(uiName);
var el = jQuery(".edui-for-wfphrasebutton");
var px=el.offset().left;
var py=el.offset().top + 17;
jQuery("#_signinputphraseblock").css({"z-index":"1200","top":py + "px", "left":px+"px"});
jQuery("#_signinputphraseblock").show();
if (_firstclc) {
_firstclc = false;
var _outdiv = jQuery("#_signinputphrasecontentblock");
var _li = jQuery("#_signinputphrasecontentblock ul li");
if (_li.length > 3) {
jQuery("#_signinputphrasecontentblock").css("height", jQuery("#_signinputphrasecontentblock").height() + "px");
jQuery("#_signinputphrasecontentblock").css("overflow", "hidden");
jQuery("#_signinputphrasecontentblock").perfectScrollbar({horizrailenabled:false,zindex:1201});
_li.show();
}
}
}
});
//当点到编辑内容上时,按钮要做的状态反射
editor.addListener('selectionchange', function () {
var state = editor.queryCommandState(uiName);
if (state == -1) {
btn.setDisabled(true);
btn.setChecked(false);
} else {
btn.setDisabled(false);
btn.setChecked(state);
}
});
jQuery("#mainsupports").hide();
setTimeout(function(){initphrase();},1000);
//因为你是添加button,所以需要返回这个button
return btn;
}, 32, "remark"/*index 指定添加到工具栏上的那个位置,默认时追加到最后,editorId 指定这个UI是那个编辑器实例上的,默认是页面上所有的编辑器都会添加这个按钮*/);