|
|
1
|
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
|
|
2
|
+ "http://www.w3.org/TR/html4/loose.dtd">
|
|
|
3
|
+<html>
|
|
|
4
|
+<head>
|
|
|
5
|
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
|
|
6
|
+ <title></title>
|
|
|
7
|
+ <style type="text/css">
|
|
|
8
|
+ *{margin:0;padding:0;color: #838383;}
|
|
|
9
|
+ table{font-size: 12px;margin: 10px;line-height: 30px; width: 80%; margin: 50px auto;}
|
|
|
10
|
+ .txt{width:300px;height:21px;line-height:21px;border:1px solid #d7d7d7;}
|
|
|
11
|
+ </style>
|
|
|
12
|
+</head>
|
|
|
13
|
+<body>
|
|
|
14
|
+<table style="width: 420px; margin: 30px auto;">
|
|
|
15
|
+ <tr>
|
|
|
16
|
+ <td><label for="text"> 文本内容</label></td>
|
|
|
17
|
+ <td><input class="txt" id="text" type="text" disabled="true"/></td>
|
|
|
18
|
+ </tr>
|
|
|
19
|
+ <tr>
|
|
|
20
|
+ <td><label for="href"> 链接类型</var></label></td>
|
|
|
21
|
+ <td>
|
|
|
22
|
+ <select class="form-control observe" id="action" name="action" value="">
|
|
|
23
|
+
|
|
|
24
|
+ <option value="">请选择跳转列表</option>
|
|
|
25
|
+
|
|
|
26
|
+ <option value="go.brand">品牌列表页</option>
|
|
|
27
|
+
|
|
|
28
|
+ <option value="go.productDetail">商品详情页</option>
|
|
|
29
|
+
|
|
|
30
|
+ <option value="go.coupon">优惠券页</option>
|
|
|
31
|
+
|
|
|
32
|
+ <option value="go.fav">收藏列表页</option>
|
|
|
33
|
+
|
|
|
34
|
+ <option value="go.mine">我的页面</option>
|
|
|
35
|
+
|
|
|
36
|
+ <option value="go.list">列表或搜索页</option>
|
|
|
37
|
+
|
|
|
38
|
+ <option value="go.attention">关注页</option>
|
|
|
39
|
+
|
|
|
40
|
+ <option value="go.plus">plus页</option>
|
|
|
41
|
+
|
|
|
42
|
+ <option value="go.star">star页</option>
|
|
|
43
|
+
|
|
|
44
|
+ <option value="go.new">新品到着页</option>
|
|
|
45
|
+
|
|
|
46
|
+ <option value="go.sale">折扣页</option>
|
|
|
47
|
+
|
|
|
48
|
+ <option value="go.share">分享</option>
|
|
|
49
|
+
|
|
|
50
|
+ <option value="go.h5">h5网页</option>
|
|
|
51
|
+
|
|
|
52
|
+ <option value="go.weblogin">h5网页调用本地登录</option>
|
|
|
53
|
+
|
|
|
54
|
+ <option value="go.gender">男女首页</option>
|
|
|
55
|
+
|
|
|
56
|
+ <option value="go.activity">app活动页</option>
|
|
|
57
|
+
|
|
|
58
|
+ <option value="go.home">频道首页</option>
|
|
|
59
|
+
|
|
|
60
|
+ <option value="go.yohood">YOHOOD</option>
|
|
|
61
|
+
|
|
|
62
|
+ <option value="go.top100">热销排行</option>
|
|
|
63
|
+
|
|
|
64
|
+ <option value="go.activitytemplate">活动模板</option>
|
|
|
65
|
+
|
|
|
66
|
+ <option value="go.globalpurchase">全球购</option>
|
|
|
67
|
+
|
|
|
68
|
+ <option value="go.subchannel">二级频道</option>
|
|
|
69
|
+
|
|
|
70
|
+ <option value="go.showgoods">去晒单</option>
|
|
|
71
|
+
|
|
|
72
|
+ <option value="go.limitpurchase">尖货频道</option>
|
|
|
73
|
+
|
|
|
74
|
+ <option value="go.vippro">会员商品</option>
|
|
|
75
|
+
|
|
|
76
|
+ <option value="go.shortsize">断码页</option>
|
|
|
77
|
+
|
|
|
78
|
+ <option value="go.discountmarket">折扣专区</option>
|
|
|
79
|
+
|
|
|
80
|
+ <option value="go.discountmarketpro">折扣专区详情页</option>
|
|
|
81
|
+
|
|
|
82
|
+ <option value="go.signin">签到页</option>
|
|
|
83
|
+
|
|
|
84
|
+ <option value="go.playvideo">视频播放</option>
|
|
|
85
|
+
|
|
|
86
|
+ <option value="go.shop">店铺</option>
|
|
|
87
|
+
|
|
|
88
|
+ <option value="go.outletactivity">奥莱活动详情页</option>
|
|
|
89
|
+
|
|
|
90
|
+ <option value="go.newoutlet">奥莱频道页</option>
|
|
|
91
|
+
|
|
|
92
|
+ <option value="go.category">选择一级品类</option>
|
|
|
93
|
+
|
|
|
94
|
+ <option value="go.comm.postdetail">社区帖子详情页</option>
|
|
|
95
|
+
|
|
|
96
|
+ <option value="go.comm.forum">社区版块首页</option>
|
|
|
97
|
+
|
|
|
98
|
+ <option value="go.comm.h5">社区H5</option>
|
|
|
99
|
+
|
|
|
100
|
+ <option value="go.comm.productDetail">社区商品详情页</option>
|
|
|
101
|
+
|
|
|
102
|
+ <option value="go.videolive">直播详情页</option>
|
|
|
103
|
+
|
|
|
104
|
+ <option value="go.videoreplay">重播详情页</option>
|
|
|
105
|
+
|
|
|
106
|
+ <option value="go.newyohood">new YOHOOD</option>
|
|
|
107
|
+
|
|
|
108
|
+ <option value="go.myInstalment">分期</option>
|
|
|
109
|
+
|
|
|
110
|
+ <option value="go.blkbrandcategory">BLK品牌品类页</option>
|
|
|
111
|
+
|
|
|
112
|
+ <option value="go.findgoodgoods">发现好货</option>
|
|
|
113
|
+
|
|
|
114
|
+ <option value="go.poollist">商品列表页</option>
|
|
|
115
|
+
|
|
|
116
|
+ <option value="go.gallay">xx馆落地页</option>
|
|
|
117
|
+
|
|
|
118
|
+ <option value="go.shopactivity">店铺活动页</option>
|
|
|
119
|
+
|
|
|
120
|
+ <option value="go.newarrivalsingleshop">新品到着单品</option>
|
|
|
121
|
+
|
|
|
122
|
+ <option value="go.blkhome">有货BLK首页</option>
|
|
|
123
|
+
|
|
|
124
|
+ <option value="go.family">有货 !family</option>
|
|
|
125
|
+
|
|
|
126
|
+ <option value="go.vipInfo">会员中心页</option>
|
|
|
127
|
+
|
|
|
128
|
+ <option value="go.vipexclusivepro">会员专享列表</option>
|
|
|
129
|
+
|
|
|
130
|
+ <option value="go.minealliance">联盟</option>
|
|
|
131
|
+
|
|
|
132
|
+ <option value="go.miniapp">跳转到小程序</option>
|
|
|
133
|
+
|
|
|
134
|
+ <option value="go.collagehome">拼团首页</option>
|
|
|
135
|
+
|
|
|
136
|
+ <option value="go.switchchannel">频道切换</option>
|
|
|
137
|
+
|
|
|
138
|
+ <option value="go.mineredpackage">我的红包</option>
|
|
|
139
|
+
|
|
|
140
|
+ <option value="go.ufo">UFO落地页</option>
|
|
|
141
|
+
|
|
|
142
|
+ <option value="go.bargainlist">砍价商品列表</option>
|
|
|
143
|
+
|
|
|
144
|
+ <option value="go.searchlist">搜索结果页</option>
|
|
|
145
|
+
|
|
|
146
|
+ <option value="go.guangchannel">社区</option>
|
|
|
147
|
+
|
|
|
148
|
+ </select>
|
|
|
149
|
+ </td>
|
|
|
150
|
+ </tr>
|
|
|
151
|
+ <tr>
|
|
|
152
|
+ <td><label for="href"> 链接地址</var></label></td>
|
|
|
153
|
+ <td><input class="txt" id="href" type="text" /></td>
|
|
|
154
|
+ </tr>
|
|
|
155
|
+ <tr>
|
|
|
156
|
+ <td><label for="title"> 标题</label></td>
|
|
|
157
|
+ <td><input class="txt" id="title" type="text"/></td>
|
|
|
158
|
+ </tr>
|
|
|
159
|
+ <tr>
|
|
|
160
|
+ <td colspan="2" id="msg"></td>
|
|
|
161
|
+ </tr>
|
|
|
162
|
+</table>
|
|
|
163
|
+<!--页面中一定要引入internal.js为了能直接使用当前打开dialog的实例变量-->
|
|
|
164
|
+<!--internal.js默认是放到dialogs目录下的-->
|
|
|
165
|
+<script type="text/javascript" src="../../third-party/jquery-1.10.2.min.js"></script>
|
|
|
166
|
+<script type="text/javascript" src="../internal.js"></script>
|
|
|
167
|
+<script>
|
|
|
168
|
+ $(function () {
|
|
|
169
|
+ var lang = editor.getLang('link');
|
|
|
170
|
+ var action = $("#action");
|
|
|
171
|
+ var range = editor.selection.getRange(),
|
|
|
172
|
+ link = range.collapsed ? editor.queryCommandValue( "link" ) : editor.selection.getStart(),
|
|
|
173
|
+ url,
|
|
|
174
|
+ trueUrl,
|
|
|
175
|
+ text = $G('text'),
|
|
|
176
|
+ rangeLink = domUtils.findParentByTagName(range.getCommonAncestor(),'a',true),
|
|
|
177
|
+ orgText;
|
|
|
178
|
+ link = domUtils.findParentByTagName( link, "a", true );
|
|
|
179
|
+ if(link){
|
|
|
180
|
+ url = utils.html(link.getAttribute( '_href' ) || link.getAttribute( 'href', 2 ));
|
|
|
181
|
+
|
|
|
182
|
+ if(rangeLink === link && !link.getElementsByTagName('img').length){
|
|
|
183
|
+ text.removeAttribute('disabled');
|
|
|
184
|
+ orgText = text.value = link[browser.ie ? 'innerText':'textContent'];
|
|
|
185
|
+ }else{
|
|
|
186
|
+ text.setAttribute('disabled','true');
|
|
|
187
|
+ text.value = lang.validLink;
|
|
|
188
|
+ }
|
|
|
189
|
+
|
|
|
190
|
+ }else{
|
|
|
191
|
+ if(range.collapsed){
|
|
|
192
|
+ text.removeAttribute('disabled');
|
|
|
193
|
+ text.value = '';
|
|
|
194
|
+ }else{
|
|
|
195
|
+ text.setAttribute('disabled','true');
|
|
|
196
|
+ text.value = lang.validLink;
|
|
|
197
|
+ }
|
|
|
198
|
+
|
|
|
199
|
+ }
|
|
|
200
|
+
|
|
|
201
|
+ // url = url+'?openby:yohobuy=' + JSON.stringify({action: action, params: {url: url}});
|
|
|
202
|
+
|
|
|
203
|
+ // yoholink
|
|
|
204
|
+ if (url) {
|
|
|
205
|
+ var urlPart = url.split('?openby:yohobuy=');
|
|
|
206
|
+ if (urlPart.length == 2) {
|
|
|
207
|
+ try {
|
|
|
208
|
+ action.val(JSON.parse(urlPart[1]).action);
|
|
|
209
|
+ trueUrl = urlPart[0];
|
|
|
210
|
+ } catch (err) {
|
|
|
211
|
+ console.log("yoho link err", err);
|
|
|
212
|
+ }
|
|
|
213
|
+
|
|
|
214
|
+ }
|
|
|
215
|
+ }
|
|
|
216
|
+ $G("title").value = url ? link.title : "";
|
|
|
217
|
+ $G("href").value = url && trueUrl ? trueUrl : '';
|
|
|
218
|
+ $focus($G("href"));
|
|
|
219
|
+
|
|
|
220
|
+ function handleDialogOk(){
|
|
|
221
|
+ var href =$G('href').value.replace(/^\s+|\s+$/g, '');
|
|
|
222
|
+ if (!domainValidate(href)) {
|
|
|
223
|
+ return;
|
|
|
224
|
+ }
|
|
|
225
|
+ if(href){
|
|
|
226
|
+ if(!hrefStartWith(href,["http","/","ftp://",'#'])) {
|
|
|
227
|
+ href = "http://" + href;
|
|
|
228
|
+ }
|
|
|
229
|
+
|
|
|
230
|
+ var obj = {
|
|
|
231
|
+ 'href' : href,
|
|
|
232
|
+ 'title' : $G("title").value.replace(/^\s+|\s+$/g, ''),
|
|
|
233
|
+ '_href':href
|
|
|
234
|
+ };
|
|
|
235
|
+ //修改链接内容的情况太特殊了,所以先做到这里了
|
|
|
236
|
+ //todo:情况多的时候,做到command里
|
|
|
237
|
+ if(orgText && text.value != orgText){
|
|
|
238
|
+ link[browser.ie ? 'innerText' : 'textContent'] = obj.textValue = text.value;
|
|
|
239
|
+ range.selectNode(link).select()
|
|
|
240
|
+ }
|
|
|
241
|
+ if(range.collapsed){
|
|
|
242
|
+ obj.textValue = text.value;
|
|
|
243
|
+ }
|
|
|
244
|
+ var conItem = href.indexOf("?") > -1 ? "&" : "?";
|
|
|
245
|
+ obj._href = obj.href = href + conItem + 'openby:yohobuy=' + JSON.stringify({action: action.val(), params: {url: encodeURI(href)}});
|
|
|
246
|
+
|
|
|
247
|
+ editor.execCommand('link',utils.clearEmptyAttrs(obj) );
|
|
|
248
|
+ dialog.close();
|
|
|
249
|
+ }
|
|
|
250
|
+
|
|
|
251
|
+ }
|
|
|
252
|
+
|
|
|
253
|
+ dialog.onok = handleDialogOk;
|
|
|
254
|
+
|
|
|
255
|
+
|
|
|
256
|
+ function hrefStartWith(href,arr){
|
|
|
257
|
+ href = href.replace(/^\s+|\s+$/g, '');
|
|
|
258
|
+ for(var i=0,ai;ai=arr[i++];){
|
|
|
259
|
+ if(href.indexOf(ai)==0){
|
|
|
260
|
+ return true;
|
|
|
261
|
+ }
|
|
|
262
|
+ }
|
|
|
263
|
+ return false;
|
|
|
264
|
+ }
|
|
|
265
|
+ var hrefDomain = ["yohobuy.com", "yhbimg.com", "yohomars.com", "yoho.cn", "yohoboys.com"];
|
|
|
266
|
+ function domainValidate(href) {
|
|
|
267
|
+ var result = false;
|
|
|
268
|
+
|
|
|
269
|
+ for(var i=0; i< hrefDomain.length; i++) {
|
|
|
270
|
+ if (href.indexOf(hrefDomain[i]) > -1) {
|
|
|
271
|
+ result = true;
|
|
|
272
|
+ break;
|
|
|
273
|
+ }
|
|
|
274
|
+ }
|
|
|
275
|
+ return result;
|
|
|
276
|
+ }
|
|
|
277
|
+
|
|
|
278
|
+ $G('href').onblur = function(){
|
|
|
279
|
+ if(!hrefStartWith(this.value,["http","/","ftp://",'#'])){
|
|
|
280
|
+ $G("msg").innerHTML = "<span style='color: red'>"+lang.httpPrompt+"</span>";
|
|
|
281
|
+ }else{
|
|
|
282
|
+ $G("msg").innerHTML = "";
|
|
|
283
|
+ }
|
|
|
284
|
+
|
|
|
285
|
+ if(!domainValidate(this.value)) {
|
|
|
286
|
+ $G("msg").innerHTML = "<span style='color: red'>合法域名"+hrefDomain.join('、') +"</span>";
|
|
|
287
|
+ }
|
|
|
288
|
+ };
|
|
|
289
|
+ })
|
|
|
290
|
+
|
|
|
291
|
+</script>
|
|
|
292
|
+</body>
|
|
|
293
|
+</html> |