|
@@ -2,15 +2,6 @@ |
|
@@ -2,15 +2,6 @@ |
2
|
* 评论及登录插件
|
2
|
* 评论及登录插件
|
3
|
* author:liuyue
|
3
|
* author:liuyue
|
4
|
* date:2015-01-07
|
4
|
* date:2015-01-07
|
5
|
-<<<<<<< HEAD
|
|
|
6
|
-*/
|
|
|
7
|
-var $ = require("jquery"),
|
|
|
8
|
- validate = require("./validate"),
|
|
|
9
|
- box = require("./box"),
|
|
|
10
|
- tools = require("yoho-tools"),
|
|
|
11
|
- tips = require("./tips");
|
|
|
12
|
- mustache = require("mustache");
|
|
|
13
|
-=======
|
|
|
14
|
*/
|
5
|
*/
|
15
|
var $ = require("jquery"),
|
6
|
var $ = require("jquery"),
|
16
|
validate = require("./validate"),
|
7
|
validate = require("./validate"),
|
|
@@ -18,248 +9,244 @@ var $ = require("jquery"), |
|
@@ -18,248 +9,244 @@ var $ = require("jquery"), |
18
|
tools = require("yoho-tools"),
|
9
|
tools = require("yoho-tools"),
|
19
|
tips = require("./tips");
|
10
|
tips = require("./tips");
|
20
|
mustache = require("mustache");
|
11
|
mustache = require("mustache");
|
21
|
->>>>>>> develop
|
12
|
+
|
22
|
require("./login");
|
13
|
require("./login");
|
23
|
|
14
|
|
24
|
(function(global, undefined) {
|
15
|
(function(global, undefined) {
|
|
|
16
|
+ var Comment = function(element, options) {
|
|
|
17
|
+ this.options = options;
|
|
|
18
|
+ this.$element = $(element);
|
|
|
19
|
+ //this.$loginBox = $(this.options.loginbox).appendTo("body");
|
|
|
20
|
+ this.init();
|
|
|
21
|
+ };
|
|
|
22
|
+
|
|
|
23
|
+
|
|
|
24
|
+ Comment.DEFAULTS = {
|
|
|
25
|
+ cid: '',
|
|
|
26
|
+ commentPageUrl: '/writer/default/comment',
|
|
|
27
|
+ publishUrl: '/writer/default/publish',
|
|
|
28
|
+ deleteUrl: '/writer/default/delete',
|
|
|
29
|
+ commentNum: $(".comment-num"),
|
|
|
30
|
+ commentItemTpl: '<li class="clearfix">' +
|
|
|
31
|
+ '<div class="userimg">' +
|
|
|
32
|
+ '<img src="\{{userimg}}" alt="">' +
|
|
|
33
|
+ '<i class="\{{partnerType}}"></i>' +
|
|
|
34
|
+ '</div>' +
|
|
|
35
|
+ '<div class="userinfo">' +
|
|
|
36
|
+ '<h6>\{{username}}</h6> ' +
|
|
|
37
|
+ '<p class="comment-text">\{{content}}</p>' +
|
|
|
38
|
+ '\{{# isSelf}}' +
|
|
|
39
|
+ '<a class="delete-comment" href="javascript:;" pid="{{id}}"></a>' +
|
|
|
40
|
+ '\{{/ isSelf}} ' +
|
|
|
41
|
+ '</div>' +
|
|
|
42
|
+ '</li>',
|
|
|
43
|
+ thirdLogin: false,
|
|
|
44
|
+ isEdit: false,
|
|
|
45
|
+ isMobile: false,
|
|
|
46
|
+ login: ''
|
|
|
47
|
+ };
|
|
|
48
|
+
|
|
|
49
|
+
|
|
|
50
|
+ Comment.prototype = {
|
|
|
51
|
+ constructor: Comment,
|
|
|
52
|
+
|
|
|
53
|
+ init: function() {
|
|
|
54
|
+ // 组件的创建主函数。
|
|
|
55
|
+ this._creat();
|
|
|
56
|
+ },
|
|
|
57
|
+
|
|
|
58
|
+ // 主函数,主要是创建节点,绑定事件。
|
|
|
59
|
+ _creat: function() {
|
|
|
60
|
+ if ($(".comments-list").size() > 0 || $(".comment-textarea").size() > 0) return;
|
|
|
61
|
+ // 创建节点
|
|
|
62
|
+ this._creatCommentDom();
|
|
|
63
|
+
|
|
|
64
|
+ this._creatThirdLogin();
|
|
|
65
|
+
|
|
|
66
|
+ // 绑定事件
|
|
|
67
|
+ this._bindEvent();
|
|
|
68
|
+ },
|
|
|
69
|
+
|
|
|
70
|
+ _creatCommentDom: function() {
|
|
|
71
|
+ var that = this;
|
|
|
72
|
+ //var id = {id:this.options.cid};
|
|
|
73
|
+ $.ajax({
|
|
|
74
|
+ type: 'GET',
|
|
|
75
|
+ url: YohoConfig.mainUrl + this.options.commentPageUrl,
|
|
|
76
|
+ /*data: id,
|
|
|
77
|
+ dataType:'json',*/
|
|
|
78
|
+ success: function(response) {
|
|
|
79
|
+ var data = response.data, //返回数据的data
|
|
|
80
|
+ viewMoreNum = data.total - 5, //评论总数-5,除显示评论剩下的评论数量
|
|
|
81
|
+ moreString = viewMoreNum + '', //剩余评论数量转为字符串
|
|
|
82
|
+ moreFirstnum = moreString.slice(0, 1), //评论数量的首数字
|
|
|
83
|
+ commentTpl = $('#comment-tpl').html(), //引入评论html模板
|
|
|
84
|
+ commentPage, //分页数据
|
|
|
85
|
+ commentHtml, //用数据渲染后的html
|
|
|
86
|
+ commentData; //评论数据
|
|
|
87
|
+
|
|
|
88
|
+
|
|
|
89
|
+ if (data.length === 0) return;
|
|
|
90
|
+
|
|
|
91
|
+ commentData = {
|
|
|
92
|
+ comment: data.comment
|
|
|
93
|
+ };
|
25
|
|
94
|
|
26
|
-<<<<<<< HEAD
|
|
|
27
|
- var Comment = function(element, options) {
|
|
|
28
|
- this.options = options;
|
|
|
29
|
- this.$element = $(element);
|
|
|
30
|
- //this.$loginBox = $(this.options.loginbox).appendTo("body");
|
|
|
31
|
- this.init();
|
|
|
32
|
- };
|
|
|
33
|
-
|
|
|
34
|
-
|
|
|
35
|
- Comment.DEFAULTS = {
|
|
|
36
|
- cid: '',
|
|
|
37
|
- commentPageUrl: '/writer/default/comment',
|
|
|
38
|
- publishUrl: '/writer/default/publish',
|
|
|
39
|
- deleteUrl: '/writer/default/delete',
|
|
|
40
|
- commentNum: $(".comment-num"),
|
|
|
41
|
- commentItemTpl: '<li class="clearfix">'+
|
|
|
42
|
- '<div class="userimg">'+
|
|
|
43
|
- '<img src="\{{userimg}}" alt="">'+
|
|
|
44
|
- '<i class="\{{partnerType}}"></i>'+
|
|
|
45
|
- '</div>'+
|
|
|
46
|
- '<div class="userinfo">'+
|
|
|
47
|
- '<h6>\{{username}}</h6> '+
|
|
|
48
|
- '<p class="comment-text">\{{content}}</p>'+
|
|
|
49
|
- '\{{# isSelf}}'+
|
|
|
50
|
- '<a class="delete-comment" href="javascript:;" pid="{{id}}"></a>'+
|
|
|
51
|
- '\{{/ isSelf}} '+
|
|
|
52
|
- '</div>'+
|
|
|
53
|
- '</li>',
|
|
|
54
|
- thirdLogin: false,
|
|
|
55
|
- isEdit: false,
|
|
|
56
|
- isMobile: false,
|
|
|
57
|
- login: ''
|
|
|
58
|
- };
|
|
|
59
|
-
|
|
|
60
|
-
|
|
|
61
|
- Comment.prototype = {
|
|
|
62
|
- constructor: Comment,
|
|
|
63
|
-
|
|
|
64
|
- init:function() {
|
|
|
65
|
- // 组件的创建主函数。
|
|
|
66
|
- this._creat();
|
|
|
67
|
- },
|
|
|
68
|
-
|
|
|
69
|
- // 主函数,主要是创建节点,绑定事件。
|
|
|
70
|
- _creat: function() {
|
|
|
71
|
- if ($(".comments-list").size() > 0 || $(".comment-textarea").size() > 0) return;
|
|
|
72
|
- // 创建节点
|
|
|
73
|
- this._creatCommentDom();
|
|
|
74
|
-
|
|
|
75
|
- this._creatThirdLogin();
|
|
|
76
|
-
|
|
|
77
|
- // 绑定事件
|
|
|
78
|
- this._bindEvent();
|
|
|
79
|
- },
|
|
|
80
|
-
|
|
|
81
|
- _creatCommentDom:function() {
|
|
|
82
|
- var that = this;
|
|
|
83
|
- //var id = {id:this.options.cid};
|
|
|
84
|
- $.ajax({
|
|
|
85
|
- type:'GET',
|
|
|
86
|
- url:YohoConfig.mainUrl + this.options.commentPageUrl,
|
|
|
87
|
- /*data: id,
|
|
|
88
|
- dataType:'json',*/
|
|
|
89
|
- success:function(response) {
|
|
|
90
|
- var data = response.data, //返回数据的data
|
|
|
91
|
- viewMoreNum = data.total - 5, //评论总数-5,除显示评论剩下的评论数量
|
|
|
92
|
- moreString = viewMoreNum + '', //剩余评论数量转为字符串
|
|
|
93
|
- moreFirstnum = moreString.slice(0,1), //评论数量的首数字
|
|
|
94
|
- commentTpl = $('#comment-tpl').html(), //引入评论html模板
|
|
|
95
|
- commentPage, //分页数据
|
|
|
96
|
- commentHtml, //用数据渲染后的html
|
|
|
97
|
- commentData; //评论数据
|
|
|
98
|
-
|
|
|
99
|
-
|
|
|
100
|
- if(data.length === 0) return;
|
|
|
101
|
-
|
|
|
102
|
- commentData = {
|
|
|
103
|
- comment: data.comment
|
|
|
104
|
- };
|
|
|
105
|
-
|
|
|
106
|
- //评论多于五条,渲染more节点
|
|
|
107
|
- if (viewMoreNum > 0) {
|
|
|
108
|
- commentData = {
|
|
|
109
|
- comment: data.comment,
|
|
|
110
|
- more: {
|
|
|
111
|
- moreNum : viewMoreNum
|
|
|
112
|
- }
|
|
|
113
|
- }
|
|
|
114
|
- }
|
|
|
115
|
-
|
|
|
116
|
- //如果分页数据不为空和undefined,渲染分页
|
|
|
117
|
- if ($.trim(data.page) !== '' || typeof(data.page) === 'undefined' || !!data.page) {
|
|
|
118
|
- commentPage = data.page;
|
|
|
119
|
- commentData = {
|
|
|
120
|
- comment: data.comment,
|
|
|
121
|
- more: {
|
|
|
122
|
- moreNum : viewMoreNum
|
|
|
123
|
- },
|
|
|
124
|
- page: commentPage
|
|
|
125
|
- }
|
|
|
126
|
- }
|
|
|
127
|
- commentHtml = mustache.render(commentTpl, commentData, {
|
|
|
128
|
- html: commentPage
|
|
|
129
|
- });
|
|
|
130
|
- that.$element.prepend($(commentHtml));
|
|
|
131
|
-
|
|
|
132
|
- //5条后的评论隐藏
|
|
|
133
|
- that.$element.find("li").eq(4).nextAll().hide(); //5条后的评论隐藏
|
|
|
134
|
- //评论总数上千显示k+,上万显示w+
|
|
|
135
|
- if (moreString.length === 4) {
|
|
|
136
|
- $(".view-more").find("span").text(moreFirstnum + 'k+');
|
|
|
137
|
- } else if (moreString.length === 5) {
|
|
|
138
|
- $(".view-more").find("span").text(moreFirstnum + 'w+');
|
|
|
139
|
- }
|
|
|
140
|
-=======
|
|
|
141
|
- var Comment = function(element, options) {
|
|
|
142
|
- this.options = options;
|
|
|
143
|
- this.$element = $(element);
|
|
|
144
|
- //this.$loginBox = $(this.options.loginbox).appendTo("body");
|
|
|
145
|
- this.init();
|
|
|
146
|
- };
|
|
|
147
|
-
|
|
|
148
|
-
|
|
|
149
|
- Comment.DEFAULTS = {
|
|
|
150
|
- cid: '',
|
|
|
151
|
- commentPageUrl: '/writer/default/comment',
|
|
|
152
|
- publishUrl: '/writer/default/publish',
|
|
|
153
|
- deleteUrl: '/writer/default/delete',
|
|
|
154
|
- commentNum: $(".comment-num"),
|
|
|
155
|
- commentItemTpl: '<li class="clearfix">' +
|
|
|
156
|
- '<div class="userimg">' +
|
|
|
157
|
- '<img src="\{{userimg}}" alt="">' +
|
|
|
158
|
- '<i class="\{{partnerType}}"></i>' +
|
|
|
159
|
- '</div>' +
|
|
|
160
|
- '<div class="userinfo">' +
|
|
|
161
|
- '<h6>\{{username}}</h6> ' +
|
|
|
162
|
- '<p class="comment-text">\{{content}}</p>' +
|
|
|
163
|
- '\{{# isSelf}}' +
|
|
|
164
|
- '<a class="delete-comment" href="javascript:;" pid="{{id}}"></a>' +
|
|
|
165
|
- '\{{/ isSelf}} ' +
|
|
|
166
|
- '</div>' +
|
|
|
167
|
- '</li>',
|
|
|
168
|
- thirdLogin: false,
|
|
|
169
|
- isEdit: false,
|
|
|
170
|
- isMobile: false,
|
|
|
171
|
- login: ''
|
|
|
172
|
- };
|
|
|
173
|
-
|
|
|
174
|
-
|
|
|
175
|
- Comment.prototype = {
|
|
|
176
|
- constructor: Comment,
|
|
|
177
|
-
|
|
|
178
|
- init: function() {
|
|
|
179
|
- // 组件的创建主函数。
|
|
|
180
|
- this._creat();
|
|
|
181
|
- },
|
|
|
182
|
-
|
|
|
183
|
- // 主函数,主要是创建节点,绑定事件。
|
|
|
184
|
- _creat: function() {
|
|
|
185
|
- if ($(".comments-list").size() > 0 || $(".comment-textarea").size() > 0) return;
|
|
|
186
|
- // 创建节点
|
|
|
187
|
- this._creatCommentDom();
|
95
|
+ //评论多于五条,渲染more节点
|
|
|
96
|
+ if (viewMoreNum > 0) {
|
|
|
97
|
+ commentData = {
|
|
|
98
|
+ comment: data.comment,
|
|
|
99
|
+ more: {
|
|
|
100
|
+ moreNum: viewMoreNum
|
|
|
101
|
+ }
|
|
|
102
|
+ }
|
|
|
103
|
+ }
|
188
|
|
104
|
|
189
|
- this._creatThirdLogin();
|
105
|
+ //如果分页数据不为空和undefined,渲染分页
|
|
|
106
|
+ if ($.trim(data.page) !== '' || typeof(data.page) === 'undefined' || !!data.page) {
|
|
|
107
|
+ commentPage = data.page;
|
|
|
108
|
+ commentData = {
|
|
|
109
|
+ comment: data.comment,
|
|
|
110
|
+ more: {
|
|
|
111
|
+ moreNum: viewMoreNum
|
|
|
112
|
+ },
|
|
|
113
|
+ page: commentPage
|
|
|
114
|
+ }
|
|
|
115
|
+ }
|
|
|
116
|
+ commentHtml = mustache.render(commentTpl, commentData, {
|
|
|
117
|
+ html: commentPage
|
|
|
118
|
+ });
|
|
|
119
|
+ that.$element.prepend($(commentHtml));
|
|
|
120
|
+
|
|
|
121
|
+ //5条后的评论隐藏
|
|
|
122
|
+ that.$element.find("li").eq(4).nextAll().hide(); //5条后的评论隐藏
|
|
|
123
|
+ //评论总数上千显示k+,上万显示w+
|
|
|
124
|
+ if (moreString.length === 4) {
|
|
|
125
|
+ $(".view-more").find("span").text(moreFirstnum + 'k+');
|
|
|
126
|
+ } else if (moreString.length === 5) {
|
|
|
127
|
+ $(".view-more").find("span").text(moreFirstnum + 'w+');
|
|
|
128
|
+ }
|
|
|
129
|
+ var Comment = function(element, options) {
|
|
|
130
|
+ this.options = options;
|
|
|
131
|
+ this.$element = $(element);
|
|
|
132
|
+ //this.$loginBox = $(this.options.loginbox).appendTo("body");
|
|
|
133
|
+ this.init();
|
|
|
134
|
+ };
|
190
|
|
135
|
|
191
|
- // 绑定事件
|
|
|
192
|
- this._bindEvent();
|
|
|
193
|
- },
|
|
|
194
|
|
136
|
|
195
|
- _creatCommentDom: function() {
|
|
|
196
|
- var that = this;
|
|
|
197
|
- //var id = {id:this.options.cid};
|
|
|
198
|
- $.ajax({
|
|
|
199
|
- type: 'GET',
|
|
|
200
|
- url: YohoConfig.mainUrl + this.options.commentPageUrl,
|
|
|
201
|
- /*data: id,
|
|
|
202
|
- dataType:'json',*/
|
|
|
203
|
- success: function(response) {
|
|
|
204
|
- var data = response.data, //返回数据的data
|
|
|
205
|
- viewMoreNum = data.total - 5, //评论总数-5,除显示评论剩下的评论数量
|
|
|
206
|
- moreString = viewMoreNum + '', //剩余评论数量转为字符串
|
|
|
207
|
- moreFirstnum = moreString.slice(0, 1), //评论数量的首数字
|
|
|
208
|
- commentTpl = $('#comment-tpl').html(), //引入评论html模板
|
|
|
209
|
- commentPage, //分页数据
|
|
|
210
|
- commentHtml, //用数据渲染后的html
|
|
|
211
|
- commentData; //评论数据
|
|
|
212
|
-
|
|
|
213
|
-
|
|
|
214
|
- if (data.length === 0) return;
|
|
|
215
|
-
|
|
|
216
|
- commentData = {
|
|
|
217
|
- comment: data.comment
|
|
|
218
|
- };
|
|
|
219
|
-
|
|
|
220
|
- //评论多于五条,渲染more节点
|
|
|
221
|
- if (viewMoreNum > 0) {
|
|
|
222
|
- commentData = {
|
|
|
223
|
- comment: data.comment,
|
|
|
224
|
- more: {
|
|
|
225
|
- moreNum: viewMoreNum
|
|
|
226
|
- }
|
|
|
227
|
- }
|
|
|
228
|
- }
|
|
|
229
|
-
|
|
|
230
|
- //如果分页数据不为空和undefined,渲染分页
|
|
|
231
|
- if ($.trim(data.page) !== '' || typeof(data.page) === 'undefined' || !!data.page) {
|
|
|
232
|
- commentPage = data.page;
|
|
|
233
|
- commentData = {
|
|
|
234
|
- comment: data.comment,
|
|
|
235
|
- more: {
|
|
|
236
|
- moreNum: viewMoreNum
|
|
|
237
|
- },
|
|
|
238
|
- page: commentPage
|
|
|
239
|
- }
|
|
|
240
|
- }
|
|
|
241
|
- commentHtml = mustache.render(commentTpl, commentData, {
|
|
|
242
|
- html: commentPage
|
|
|
243
|
- });
|
|
|
244
|
- that.$element.prepend($(commentHtml));
|
|
|
245
|
-
|
|
|
246
|
- //5条后的评论隐藏
|
|
|
247
|
- that.$element.find("li").eq(4).nextAll().hide(); //5条后的评论隐藏
|
|
|
248
|
- //评论总数上千显示k+,上万显示w+
|
|
|
249
|
- if (moreString.length === 4) {
|
|
|
250
|
- $(".view-more").find("span").text(moreFirstnum + 'k+');
|
|
|
251
|
- } else if (moreString.length === 5) {
|
|
|
252
|
- $(".view-more").find("span").text(moreFirstnum + 'w+');
|
|
|
253
|
- }
|
|
|
254
|
->>>>>>> develop
|
|
|
255
|
- }
|
|
|
256
|
- });
|
|
|
257
|
- },
|
137
|
+ Comment.DEFAULTS = {
|
|
|
138
|
+ cid: '',
|
|
|
139
|
+ commentPageUrl: '/writer/default/comment',
|
|
|
140
|
+ publishUrl: '/writer/default/publish',
|
|
|
141
|
+ deleteUrl: '/writer/default/delete',
|
|
|
142
|
+ commentNum: $(".comment-num"),
|
|
|
143
|
+ commentItemTpl: '<li class="clearfix">' +
|
|
|
144
|
+ '<div class="userimg">' +
|
|
|
145
|
+ '<img src="\{{userimg}}" alt="">' +
|
|
|
146
|
+ '<i class="\{{partnerType}}"></i>' +
|
|
|
147
|
+ '</div>' +
|
|
|
148
|
+ '<div class="userinfo">' +
|
|
|
149
|
+ '<h6>\{{username}}</h6> ' +
|
|
|
150
|
+ '<p class="comment-text">\{{content}}</p>' +
|
|
|
151
|
+ '\{{# isSelf}}' +
|
|
|
152
|
+ '<a class="delete-comment" href="javascript:;" pid="{{id}}"></a>' +
|
|
|
153
|
+ '\{{/ isSelf}} ' +
|
|
|
154
|
+ '</div>' +
|
|
|
155
|
+ '</li>',
|
|
|
156
|
+ thirdLogin: false,
|
|
|
157
|
+ isEdit: false,
|
|
|
158
|
+ isMobile: false,
|
|
|
159
|
+ login: ''
|
|
|
160
|
+ };
|
258
|
|
161
|
|
259
|
|
162
|
|
260
|
-<<<<<<< HEAD
|
|
|
261
|
- //创建评论文本域
|
|
|
262
|
- /*_creatTextareaDom:function(){
|
163
|
+ Comment.prototype = {
|
|
|
164
|
+ constructor: Comment,
|
|
|
165
|
+
|
|
|
166
|
+ init: function() {
|
|
|
167
|
+ // 组件的创建主函数。
|
|
|
168
|
+ this._creat();
|
|
|
169
|
+ },
|
|
|
170
|
+
|
|
|
171
|
+ // 主函数,主要是创建节点,绑定事件。
|
|
|
172
|
+ _creat: function() {
|
|
|
173
|
+ if ($(".comments-list").size() > 0 || $(".comment-textarea").size() > 0) return;
|
|
|
174
|
+ // 创建节点
|
|
|
175
|
+ this._creatCommentDom();
|
|
|
176
|
+
|
|
|
177
|
+ this._creatThirdLogin();
|
|
|
178
|
+
|
|
|
179
|
+ // 绑定事件
|
|
|
180
|
+ this._bindEvent();
|
|
|
181
|
+ },
|
|
|
182
|
+
|
|
|
183
|
+ _creatCommentDom: function() {
|
|
|
184
|
+ var that = this;
|
|
|
185
|
+ //var id = {id:this.options.cid};
|
|
|
186
|
+ $.ajax({
|
|
|
187
|
+ type: 'GET',
|
|
|
188
|
+ url: YohoConfig.mainUrl + this.options.commentPageUrl,
|
|
|
189
|
+ /*data: id,
|
|
|
190
|
+ dataType:'json',*/
|
|
|
191
|
+ success: function(response) {
|
|
|
192
|
+ var data = response.data, //返回数据的data
|
|
|
193
|
+ viewMoreNum = data.total - 5, //评论总数-5,除显示评论剩下的评论数量
|
|
|
194
|
+ moreString = viewMoreNum + '', //剩余评论数量转为字符串
|
|
|
195
|
+ moreFirstnum = moreString.slice(0, 1), //评论数量的首数字
|
|
|
196
|
+ commentTpl = $('#comment-tpl').html(), //引入评论html模板
|
|
|
197
|
+ commentPage, //分页数据
|
|
|
198
|
+ commentHtml, //用数据渲染后的html
|
|
|
199
|
+ commentData; //评论数据
|
|
|
200
|
+
|
|
|
201
|
+
|
|
|
202
|
+ if (data.length === 0) return;
|
|
|
203
|
+
|
|
|
204
|
+ commentData = {
|
|
|
205
|
+ comment: data.comment
|
|
|
206
|
+ };
|
|
|
207
|
+
|
|
|
208
|
+ //评论多于五条,渲染more节点
|
|
|
209
|
+ if (viewMoreNum > 0) {
|
|
|
210
|
+ commentData = {
|
|
|
211
|
+ comment: data.comment,
|
|
|
212
|
+ more: {
|
|
|
213
|
+ moreNum: viewMoreNum
|
|
|
214
|
+ }
|
|
|
215
|
+ }
|
|
|
216
|
+ }
|
|
|
217
|
+
|
|
|
218
|
+ //如果分页数据不为空和undefined,渲染分页
|
|
|
219
|
+ if ($.trim(data.page) !== '' || typeof(data.page) === 'undefined' || !!data.page) {
|
|
|
220
|
+ commentPage = data.page;
|
|
|
221
|
+ commentData = {
|
|
|
222
|
+ comment: data.comment,
|
|
|
223
|
+ more: {
|
|
|
224
|
+ moreNum: viewMoreNum
|
|
|
225
|
+ },
|
|
|
226
|
+ page: commentPage
|
|
|
227
|
+ }
|
|
|
228
|
+ }
|
|
|
229
|
+ commentHtml = mustache.render(commentTpl, commentData, {
|
|
|
230
|
+ html: commentPage
|
|
|
231
|
+ });
|
|
|
232
|
+ that.$element.prepend($(commentHtml));
|
|
|
233
|
+
|
|
|
234
|
+ //5条后的评论隐藏
|
|
|
235
|
+ that.$element.find("li").eq(4).nextAll().hide(); //5条后的评论隐藏
|
|
|
236
|
+ //评论总数上千显示k+,上万显示w+
|
|
|
237
|
+ if (moreString.length === 4) {
|
|
|
238
|
+ $(".view-more").find("span").text(moreFirstnum + 'k+');
|
|
|
239
|
+ } else if (moreString.length === 5) {
|
|
|
240
|
+ $(".view-more").find("span").text(moreFirstnum + 'w+');
|
|
|
241
|
+ } >>> >>> > develop
|
|
|
242
|
+ }
|
|
|
243
|
+ });
|
|
|
244
|
+ },
|
|
|
245
|
+
|
|
|
246
|
+
|
|
|
247
|
+ << << << < HEAD
|
|
|
248
|
+ //创建评论文本域
|
|
|
249
|
+ /*_creatTextareaDom:function(){
|
263
|
=======
|
250
|
=======
|
264
|
//创建评论文本域
|
251
|
//创建评论文本域
|
265
|
/*_creatTextareaDom:function(){
|
252
|
/*_creatTextareaDom:function(){
|
|
@@ -291,29 +278,29 @@ require("./login"); |
|
@@ -291,29 +278,29 @@ require("./login"); |
291
|
|
278
|
|
292
|
},*/
|
279
|
},*/
|
293
|
|
280
|
|
294
|
-<<<<<<< HEAD
|
|
|
295
|
- //创建第三方登录
|
|
|
296
|
- _creatThirdLogin:function(){
|
|
|
297
|
- var thirdLoginTpl = $("#third-login-tpl").html();
|
|
|
298
|
-
|
|
|
299
|
- if (this.options.thirdLogin === true) {
|
|
|
300
|
- $(thirdLoginTpl).appendTo(this.$element);
|
|
|
301
|
- //this.$element.html(thirdLoginTpl);
|
|
|
302
|
- }
|
|
|
303
|
- },
|
|
|
304
|
-
|
|
|
305
|
- //事件绑定
|
|
|
306
|
- _bindEvent: function(){
|
|
|
307
|
- var that = this;
|
|
|
308
|
- //查看更多评论
|
|
|
309
|
- this.$element.on("click.comment",".view-more",function() {
|
|
|
310
|
- that.$element.find("li").show(); //显示第一页后五条
|
|
|
311
|
- that.$element.find(".comment-pager-content").show(); //显示分页按钮
|
|
|
312
|
- that.$element.find(".view-more").remove(); //移除view more
|
|
|
313
|
- });
|
|
|
314
|
-
|
|
|
315
|
- //弹出登录框
|
|
|
316
|
- /*$(this).login();
|
281
|
+ << << << < HEAD
|
|
|
282
|
+ //创建第三方登录
|
|
|
283
|
+ _creatThirdLogin: function() {
|
|
|
284
|
+ var thirdLoginTpl = $("#third-login-tpl").html();
|
|
|
285
|
+
|
|
|
286
|
+ if (this.options.thirdLogin === true) {
|
|
|
287
|
+ $(thirdLoginTpl).appendTo(this.$element);
|
|
|
288
|
+ //this.$element.html(thirdLoginTpl);
|
|
|
289
|
+ }
|
|
|
290
|
+ },
|
|
|
291
|
+
|
|
|
292
|
+ //事件绑定
|
|
|
293
|
+ _bindEvent: function() {
|
|
|
294
|
+ var that = this;
|
|
|
295
|
+ //查看更多评论
|
|
|
296
|
+ this.$element.on("click.comment", ".view-more", function() {
|
|
|
297
|
+ that.$element.find("li").show(); //显示第一页后五条
|
|
|
298
|
+ that.$element.find(".comment-pager-content").show(); //显示分页按钮
|
|
|
299
|
+ that.$element.find(".view-more").remove(); //移除view more
|
|
|
300
|
+ });
|
|
|
301
|
+
|
|
|
302
|
+ //弹出登录框
|
|
|
303
|
+ /*$(this).login();
|
317
|
=======
|
304
|
=======
|
318
|
//创建第三方登录
|
305
|
//创建第三方登录
|
319
|
_creatThirdLogin: function() {
|
306
|
_creatThirdLogin: function() {
|
|
@@ -343,136 +330,134 @@ require("./login"); |
|
@@ -343,136 +330,134 @@ require("./login"); |
343
|
$(this).login("loginBoxAnimate");
|
330
|
$(this).login("loginBoxAnimate");
|
344
|
});*/
|
331
|
});*/
|
345
|
|
332
|
|
346
|
-<<<<<<< HEAD
|
|
|
347
|
- //显示删除按钮
|
|
|
348
|
- if (this.options.isMobile) {
|
|
|
349
|
- this.$element.find(".delete-comment").show();
|
|
|
350
|
- } else {
|
|
|
351
|
- this.$element.on("mouseenter","li",function() {
|
|
|
352
|
- $(this).find(".delete-comment").show();
|
|
|
353
|
- }).on("mouseleave","li",function(){
|
|
|
354
|
- $(this).find(".delete-comment").hide();
|
|
|
355
|
- });
|
|
|
356
|
- }
|
|
|
357
|
-
|
|
|
358
|
-
|
|
|
359
|
- //发表评论
|
|
|
360
|
- this.$element.on("click.publish",".publish-btn",function() {
|
|
|
361
|
- var $textarea = that.$element.find("textarea"),
|
|
|
362
|
- nameInput = that.$element.find(".name-input"),
|
|
|
363
|
- emailInput = that.$element.find(".email-input"),
|
|
|
364
|
- comment = $textarea.val(),
|
|
|
365
|
-=======
|
|
|
366
|
- //显示删除按钮
|
|
|
367
|
- if (this.options.isMobile) {
|
|
|
368
|
- this.$element.find(".delete-comment").show();
|
|
|
369
|
- } else {
|
|
|
370
|
- this.$element.on("mouseenter", "li", function() {
|
|
|
371
|
- $(this).find(".delete-comment").show();
|
|
|
372
|
- }).on("mouseleave", "li", function() {
|
|
|
373
|
- $(this).find(".delete-comment").hide();
|
|
|
374
|
- });
|
|
|
375
|
- }
|
|
|
376
|
-
|
|
|
377
|
-
|
|
|
378
|
- //发表评论
|
|
|
379
|
- this.$element.on("click.publish", ".publish-btn", function() {
|
|
|
380
|
- var $textarea = that.$element.find("textarea"),
|
|
|
381
|
- nameInput = that.$element.find(".name-input"),
|
|
|
382
|
- emailInput = that.$element.find(".email-input"),
|
|
|
383
|
- comment = $textarea.val(),
|
|
|
384
|
->>>>>>> develop
|
|
|
385
|
- cid,
|
|
|
386
|
- data,
|
|
|
387
|
- commentsNum,
|
|
|
388
|
- commentsList,
|
|
|
389
|
- publishHtml;
|
|
|
390
|
-
|
|
|
391
|
-
|
|
|
392
|
- //验证名字
|
|
|
393
|
- if (!tools.IYOHO_isUserName(nameInput.val())) {
|
|
|
394
|
- box.alert(tips.getTips("commentUncompleted"), 5, function() {
|
|
|
395
|
- nameInput.focus();
|
|
|
396
|
-<<<<<<< HEAD
|
|
|
397
|
- });
|
|
|
398
|
-=======
|
|
|
399
|
- });
|
|
|
400
|
->>>>>>> develop
|
|
|
401
|
- return false;
|
|
|
402
|
- };
|
|
|
403
|
-
|
|
|
404
|
- //验证邮箱
|
|
|
405
|
- if (emailInput.val() !== '' && !tools.IYOHO_isEmail(emailInput.val())) {
|
|
|
406
|
- box.alert(tips.getTips("commentUncompleted"), 5, function() {
|
|
|
407
|
- emailInput.focus();
|
|
|
408
|
-<<<<<<< HEAD
|
|
|
409
|
- });
|
|
|
410
|
-=======
|
|
|
411
|
- });
|
|
|
412
|
->>>>>>> develop
|
|
|
413
|
- return false;
|
|
|
414
|
- };
|
|
|
415
|
-
|
|
|
416
|
- //验证评论
|
|
|
417
|
- if (typeof(comment) === 'undefined' || $.trim(comment) === '') {
|
|
|
418
|
- box.alert(tips.getTips("commentUncompleted"), 5, function() {
|
|
|
419
|
- $textarea.focus();
|
|
|
420
|
-<<<<<<< HEAD
|
|
|
421
|
- });
|
|
|
422
|
- return false;
|
|
|
423
|
- };
|
|
|
424
|
-
|
|
|
425
|
- if (comment.length > 100) {
|
|
|
426
|
- box.alert(tips.getTips("commentToMuch"), 5);
|
|
|
427
|
- return false;
|
|
|
428
|
- };
|
|
|
429
|
-
|
|
|
430
|
- cid = that.$element.attr('cid');
|
|
|
431
|
- if (!cid) {
|
|
|
432
|
- return false;
|
|
|
433
|
- };
|
|
|
434
|
-
|
|
|
435
|
- data = {id:cid,comment:comment,sync:'222',title:'111'};
|
|
|
436
|
-
|
|
|
437
|
- $.ajax({
|
|
|
438
|
- type: 'GET',
|
|
|
439
|
- url: YohoConfig.mainUrl + that.options.publishUrl,
|
|
|
440
|
- success: function(response) {
|
|
|
441
|
- if (response.code === '800000') {
|
|
|
442
|
- box.alert(tips.getTips("relogin"), 5);
|
|
|
443
|
- that.$element.login("setLogout");
|
|
|
444
|
- return false;
|
|
|
445
|
- };
|
|
|
446
|
-
|
|
|
447
|
- if (response.status && response.data) {
|
|
|
448
|
- var $commentsList = $(".comments-list");
|
|
|
449
|
- publishHtml = mustache.render(that.options.commentItemTpl, response.data);
|
|
|
450
|
-
|
|
|
451
|
- if ($commentsList .find("li").size() === 0){
|
|
|
452
|
- $commentsList.html(publishHtml);
|
|
|
453
|
- } else {
|
|
|
454
|
- $commentsList.find("li").eq(0).before(publishHtml);
|
|
|
455
|
- }
|
|
|
456
|
-
|
|
|
457
|
- box.alert(tips.getTips("publishSuccess"), 5);
|
|
|
458
|
- $(".comment-textarea textarea").val('');
|
|
|
459
|
-
|
|
|
460
|
- commentsNum = 1;
|
|
|
461
|
- if(!!parseInt(that.options.commentNum.eq(0).text())){
|
|
|
462
|
- commentsNum = parseInt(that.options.commentNum.eq(0).text())+1;
|
|
|
463
|
- };
|
|
|
464
|
- that.options.commentNum.text(commentsNum);
|
|
|
465
|
- } else if (900000 === response.code) {
|
|
|
466
|
- box.alert(tips.getTips("notSameContent"), 5);
|
|
|
467
|
- } else {
|
|
|
468
|
- box.alert(tips.getTips("systemBus"), 5);
|
|
|
469
|
- }
|
|
|
470
|
-
|
|
|
471
|
- publishHtml = mustache.render(that.options.commentItemTpl, response.data);
|
|
|
472
|
- that.$element.find(".comments-list").prepend(publishHtml);
|
|
|
473
|
- }
|
|
|
474
|
- })
|
|
|
475
|
- /*$.ajax({
|
333
|
+ << << << < HEAD
|
|
|
334
|
+ //显示删除按钮
|
|
|
335
|
+ if (this.options.isMobile) {
|
|
|
336
|
+ this.$element.find(".delete-comment").show();
|
|
|
337
|
+ } else {
|
|
|
338
|
+ this.$element.on("mouseenter", "li", function() {
|
|
|
339
|
+ $(this).find(".delete-comment").show();
|
|
|
340
|
+ }).on("mouseleave", "li", function() {
|
|
|
341
|
+ $(this).find(".delete-comment").hide();
|
|
|
342
|
+ });
|
|
|
343
|
+ }
|
|
|
344
|
+
|
|
|
345
|
+
|
|
|
346
|
+ //发表评论
|
|
|
347
|
+ this.$element.on("click.publish", ".publish-btn", function() {
|
|
|
348
|
+ var $textarea = that.$element.find("textarea"),
|
|
|
349
|
+ nameInput = that.$element.find(".name-input"),
|
|
|
350
|
+ emailInput = that.$element.find(".email-input"),
|
|
|
351
|
+ comment = $textarea.val(),
|
|
|
352
|
+ === === =
|
|
|
353
|
+ //显示删除按钮
|
|
|
354
|
+ if (this.options.isMobile) {
|
|
|
355
|
+ this.$element.find(".delete-comment").show();
|
|
|
356
|
+ } else {
|
|
|
357
|
+ this.$element.on("mouseenter", "li", function() {
|
|
|
358
|
+ $(this).find(".delete-comment").show();
|
|
|
359
|
+ }).on("mouseleave", "li", function() {
|
|
|
360
|
+ $(this).find(".delete-comment").hide();
|
|
|
361
|
+ });
|
|
|
362
|
+ }
|
|
|
363
|
+
|
|
|
364
|
+
|
|
|
365
|
+ //发表评论
|
|
|
366
|
+ this.$element.on("click.publish", ".publish-btn", function() {
|
|
|
367
|
+ var $textarea = that.$element.find("textarea"),
|
|
|
368
|
+ nameInput = that.$element.find(".name-input"),
|
|
|
369
|
+ emailInput = that.$element.find(".email-input"),
|
|
|
370
|
+ comment = $textarea.val(),
|
|
|
371
|
+ >>> >>> > develop
|
|
|
372
|
+ cid,
|
|
|
373
|
+ data,
|
|
|
374
|
+ commentsNum,
|
|
|
375
|
+ commentsList,
|
|
|
376
|
+ publishHtml;
|
|
|
377
|
+
|
|
|
378
|
+
|
|
|
379
|
+ //验证名字
|
|
|
380
|
+ if (!tools.IYOHO_isUserName(nameInput.val())) {
|
|
|
381
|
+ box.alert(tips.getTips("commentUncompleted"), 5, function() {
|
|
|
382
|
+ nameInput.focus(); << << << < HEAD
|
|
|
383
|
+ }); === === =
|
|
|
384
|
+ }); >>> >>> > develop
|
|
|
385
|
+ return false;
|
|
|
386
|
+ };
|
|
|
387
|
+
|
|
|
388
|
+ //验证邮箱
|
|
|
389
|
+ if (emailInput.val() !== '' && !tools.IYOHO_isEmail(emailInput.val())) {
|
|
|
390
|
+ box.alert(tips.getTips("commentUncompleted"), 5, function() {
|
|
|
391
|
+ emailInput.focus(); << << << < HEAD
|
|
|
392
|
+ }); === === =
|
|
|
393
|
+ }); >>> >>> > develop
|
|
|
394
|
+ return false;
|
|
|
395
|
+ };
|
|
|
396
|
+
|
|
|
397
|
+ //验证评论
|
|
|
398
|
+ if (typeof(comment) === 'undefined' || $.trim(comment) === '') {
|
|
|
399
|
+ box.alert(tips.getTips("commentUncompleted"), 5, function() {
|
|
|
400
|
+ $textarea.focus(); << << << < HEAD
|
|
|
401
|
+ });
|
|
|
402
|
+ return false;
|
|
|
403
|
+ };
|
|
|
404
|
+
|
|
|
405
|
+ if (comment.length > 100) {
|
|
|
406
|
+ box.alert(tips.getTips("commentToMuch"), 5);
|
|
|
407
|
+ return false;
|
|
|
408
|
+ };
|
|
|
409
|
+
|
|
|
410
|
+ cid = that.$element.attr('cid');
|
|
|
411
|
+ if (!cid) {
|
|
|
412
|
+ return false;
|
|
|
413
|
+ };
|
|
|
414
|
+
|
|
|
415
|
+ data = {
|
|
|
416
|
+ id: cid,
|
|
|
417
|
+ comment: comment,
|
|
|
418
|
+ sync: '222',
|
|
|
419
|
+ title: '111'
|
|
|
420
|
+ };
|
|
|
421
|
+
|
|
|
422
|
+ $.ajax({
|
|
|
423
|
+ type: 'GET',
|
|
|
424
|
+ url: YohoConfig.mainUrl + that.options.publishUrl,
|
|
|
425
|
+ success: function(response) {
|
|
|
426
|
+ if (response.code === '800000') {
|
|
|
427
|
+ box.alert(tips.getTips("relogin"), 5);
|
|
|
428
|
+ that.$element.login("setLogout");
|
|
|
429
|
+ return false;
|
|
|
430
|
+ };
|
|
|
431
|
+
|
|
|
432
|
+ if (response.status && response.data) {
|
|
|
433
|
+ var $commentsList = $(".comments-list");
|
|
|
434
|
+ publishHtml = mustache.render(that.options.commentItemTpl, response.data);
|
|
|
435
|
+
|
|
|
436
|
+ if ($commentsList.find("li").size() === 0) {
|
|
|
437
|
+ $commentsList.html(publishHtml);
|
|
|
438
|
+ } else {
|
|
|
439
|
+ $commentsList.find("li").eq(0).before(publishHtml);
|
|
|
440
|
+ }
|
|
|
441
|
+
|
|
|
442
|
+ box.alert(tips.getTips("publishSuccess"), 5);
|
|
|
443
|
+ $(".comment-textarea textarea").val('');
|
|
|
444
|
+
|
|
|
445
|
+ commentsNum = 1;
|
|
|
446
|
+ if (!!parseInt(that.options.commentNum.eq(0).text())) {
|
|
|
447
|
+ commentsNum = parseInt(that.options.commentNum.eq(0).text()) + 1;
|
|
|
448
|
+ };
|
|
|
449
|
+ that.options.commentNum.text(commentsNum);
|
|
|
450
|
+ } else if (900000 === response.code) {
|
|
|
451
|
+ box.alert(tips.getTips("notSameContent"), 5);
|
|
|
452
|
+ } else {
|
|
|
453
|
+ box.alert(tips.getTips("systemBus"), 5);
|
|
|
454
|
+ }
|
|
|
455
|
+
|
|
|
456
|
+ publishHtml = mustache.render(that.options.commentItemTpl, response.data);
|
|
|
457
|
+ that.$element.find(".comments-list").prepend(publishHtml);
|
|
|
458
|
+ }
|
|
|
459
|
+ })
|
|
|
460
|
+ /*$.ajax({
|
476
|
type:'POST',
|
461
|
type:'POST',
|
477
|
url:YohoConfig.mainUrl + that.options.publishUrl,
|
462
|
url:YohoConfig.mainUrl + that.options.publishUrl,
|
478
|
data: data,
|
463
|
data: data,
|
|
@@ -537,116 +522,113 @@ require("./login"); |
|
@@ -537,116 +522,113 @@ require("./login"); |
537
|
}
|
522
|
}
|
538
|
}
|
523
|
}
|
539
|
}); */
|
524
|
}); */
|
540
|
- });
|
|
|
541
|
-
|
|
|
542
|
- //评论翻页
|
|
|
543
|
- this.$element.on("click.commentPage",".pager-item",function(){
|
|
|
544
|
- var url = $(this).attr("href"),
|
|
|
545
|
- pageHtml,
|
|
|
546
|
- pageIcon,
|
|
|
547
|
- commentListTop;
|
|
|
548
|
- $.ajax({
|
|
|
549
|
- type: 'GET',
|
|
|
550
|
- url: url,
|
|
|
551
|
- success: function(response) {
|
|
|
552
|
-
|
|
|
553
|
- $(".comments-list").empty();
|
|
|
554
|
- pageHtml = mustache.render(that.options.commentItemTpl, response.data.comment);
|
|
|
555
|
- $(".comments-list").html(pageHtml);
|
|
|
556
|
-
|
|
|
557
|
- pageIcon = $('<div class="channel-index-pager">'+response.data.page+'</div>');
|
|
|
558
|
- $(".comment-pager-content").html(pageIcon);
|
|
|
559
|
-
|
|
|
560
|
- commentListTop = $(".comments-list").offset().top - $("#minEnterprise").outerHeight();
|
|
|
561
|
- $(window).scrollTop(commentListTop);
|
|
|
562
|
- }
|
|
|
563
|
- });
|
|
|
564
|
-
|
|
|
565
|
- return false;
|
|
|
566
|
- });
|
|
|
567
|
-
|
|
|
568
|
-
|
|
|
569
|
-
|
|
|
570
|
- //删除评论
|
|
|
571
|
- this.$element.on("click.deleteComment",".delete-comment",function(){
|
|
|
572
|
- var _this = $(this);
|
|
|
573
|
- var id = _this.attr('pid');
|
|
|
574
|
- var deleteTip = tips.getTips("deleteComment");
|
|
|
575
|
- if(that.options.isFeedback){
|
|
|
576
|
- deleteTip = tips.getTips("deleteFeedback");
|
|
|
577
|
- }else if(that.options.isEdit){
|
|
|
578
|
- deleteTip = tips.getTips("deleteEdit");
|
|
|
579
|
- }
|
|
|
580
|
- box.confirm(deleteTip, function()
|
|
|
581
|
- {
|
|
|
582
|
- $.ajax
|
|
|
583
|
- ({
|
|
|
584
|
- type:'POST',
|
|
|
585
|
- url:YohoConfig.mainUrl+that.options.deleteUrl,
|
|
|
586
|
- data:'id='+id,
|
|
|
587
|
- dataType:'json',
|
|
|
588
|
- success:function(response)
|
|
|
589
|
-=======
|
|
|
590
|
- });
|
|
|
591
|
- return false;
|
|
|
592
|
- };
|
|
|
593
|
-
|
|
|
594
|
- if (comment.length > 100) {
|
|
|
595
|
- box.alert(tips.getTips("commentToMuch"), 5);
|
|
|
596
|
- return false;
|
|
|
597
|
- };
|
|
|
598
|
-
|
|
|
599
|
- cid = that.$element.attr('cid');
|
|
|
600
|
- if (!cid) {
|
|
|
601
|
- return false;
|
|
|
602
|
- };
|
|
|
603
|
-
|
|
|
604
|
- data = {
|
|
|
605
|
- id: cid,
|
|
|
606
|
- comment: comment,
|
|
|
607
|
- sync: '222',
|
|
|
608
|
- title: '111'
|
|
|
609
|
- };
|
|
|
610
|
-
|
|
|
611
|
- $.ajax({
|
|
|
612
|
- type: 'GET',
|
|
|
613
|
- url: YohoConfig.mainUrl + that.options.publishUrl,
|
|
|
614
|
- success: function(response) {
|
|
|
615
|
- if (response.code === '800000') {
|
|
|
616
|
- box.alert(tips.getTips("relogin"), 5);
|
|
|
617
|
- that.$element.login("setLogout");
|
|
|
618
|
- return false;
|
|
|
619
|
- };
|
|
|
620
|
-
|
|
|
621
|
- if (response.status && response.data) {
|
|
|
622
|
- var $commentsList = $(".comments-list");
|
|
|
623
|
- publishHtml = mustache.render(that.options.commentItemTpl, response.data);
|
|
|
624
|
-
|
|
|
625
|
- if ($commentsList.find("li").size() === 0) {
|
|
|
626
|
- $commentsList.html(publishHtml);
|
|
|
627
|
- } else {
|
|
|
628
|
- $commentsList.find("li").eq(0).before(publishHtml);
|
|
|
629
|
- }
|
|
|
630
|
-
|
|
|
631
|
- box.alert(tips.getTips("publishSuccess"), 5);
|
|
|
632
|
- $(".comment-textarea textarea").val('');
|
|
|
633
|
-
|
|
|
634
|
- commentsNum = 1;
|
|
|
635
|
- if (!!parseInt(that.options.commentNum.eq(0).text())) {
|
|
|
636
|
- commentsNum = parseInt(that.options.commentNum.eq(0).text()) + 1;
|
|
|
637
|
- };
|
|
|
638
|
- that.options.commentNum.text(commentsNum);
|
|
|
639
|
- } else if (900000 === response.code) {
|
|
|
640
|
- box.alert(tips.getTips("notSameContent"), 5);
|
|
|
641
|
- } else {
|
|
|
642
|
- box.alert(tips.getTips("systemBus"), 5);
|
|
|
643
|
- }
|
|
|
644
|
-
|
|
|
645
|
- publishHtml = mustache.render(that.options.commentItemTpl, response.data);
|
|
|
646
|
- that.$element.find(".comments-list").prepend(publishHtml);
|
|
|
647
|
- }
|
|
|
648
|
- })
|
|
|
649
|
- /*$.ajax({
|
525
|
+ });
|
|
|
526
|
+
|
|
|
527
|
+ //评论翻页
|
|
|
528
|
+ this.$element.on("click.commentPage", ".pager-item", function() {
|
|
|
529
|
+ var url = $(this).attr("href"),
|
|
|
530
|
+ pageHtml,
|
|
|
531
|
+ pageIcon,
|
|
|
532
|
+ commentListTop;
|
|
|
533
|
+ $.ajax({
|
|
|
534
|
+ type: 'GET',
|
|
|
535
|
+ url: url,
|
|
|
536
|
+ success: function(response) {
|
|
|
537
|
+
|
|
|
538
|
+ $(".comments-list").empty();
|
|
|
539
|
+ pageHtml = mustache.render(that.options.commentItemTpl, response.data.comment);
|
|
|
540
|
+ $(".comments-list").html(pageHtml);
|
|
|
541
|
+
|
|
|
542
|
+ pageIcon = $('<div class="channel-index-pager">' + response.data.page + '</div>');
|
|
|
543
|
+ $(".comment-pager-content").html(pageIcon);
|
|
|
544
|
+
|
|
|
545
|
+ commentListTop = $(".comments-list").offset().top - $("#minEnterprise").outerHeight();
|
|
|
546
|
+ $(window).scrollTop(commentListTop);
|
|
|
547
|
+ }
|
|
|
548
|
+ });
|
|
|
549
|
+
|
|
|
550
|
+ return false;
|
|
|
551
|
+ });
|
|
|
552
|
+
|
|
|
553
|
+
|
|
|
554
|
+
|
|
|
555
|
+ //删除评论
|
|
|
556
|
+ this.$element.on("click.deleteComment", ".delete-comment", function() {
|
|
|
557
|
+ var _this = $(this);
|
|
|
558
|
+ var id = _this.attr('pid');
|
|
|
559
|
+ var deleteTip = tips.getTips("deleteComment");
|
|
|
560
|
+ if (that.options.isFeedback) {
|
|
|
561
|
+ deleteTip = tips.getTips("deleteFeedback");
|
|
|
562
|
+ } else if (that.options.isEdit) {
|
|
|
563
|
+ deleteTip = tips.getTips("deleteEdit");
|
|
|
564
|
+ }
|
|
|
565
|
+ box.confirm(deleteTip, function() {
|
|
|
566
|
+ $.ajax({
|
|
|
567
|
+ type: 'POST',
|
|
|
568
|
+ url: YohoConfig.mainUrl + that.options.deleteUrl,
|
|
|
569
|
+ data: 'id=' + id,
|
|
|
570
|
+ dataType: 'json',
|
|
|
571
|
+ success: function(response) === === =
|
|
|
572
|
+ });
|
|
|
573
|
+ return false;
|
|
|
574
|
+ };
|
|
|
575
|
+
|
|
|
576
|
+ if (comment.length > 100) {
|
|
|
577
|
+ box.alert(tips.getTips("commentToMuch"), 5);
|
|
|
578
|
+ return false;
|
|
|
579
|
+ };
|
|
|
580
|
+
|
|
|
581
|
+ cid = that.$element.attr('cid');
|
|
|
582
|
+ if (!cid) {
|
|
|
583
|
+ return false;
|
|
|
584
|
+ };
|
|
|
585
|
+
|
|
|
586
|
+ data = {
|
|
|
587
|
+ id: cid,
|
|
|
588
|
+ comment: comment,
|
|
|
589
|
+ sync: '222',
|
|
|
590
|
+ title: '111'
|
|
|
591
|
+ };
|
|
|
592
|
+
|
|
|
593
|
+ $.ajax({
|
|
|
594
|
+ type: 'GET',
|
|
|
595
|
+ url: YohoConfig.mainUrl + that.options.publishUrl,
|
|
|
596
|
+ success: function(response) {
|
|
|
597
|
+ if (response.code === '800000') {
|
|
|
598
|
+ box.alert(tips.getTips("relogin"), 5);
|
|
|
599
|
+ that.$element.login("setLogout");
|
|
|
600
|
+ return false;
|
|
|
601
|
+ };
|
|
|
602
|
+
|
|
|
603
|
+ if (response.status && response.data) {
|
|
|
604
|
+ var $commentsList = $(".comments-list");
|
|
|
605
|
+ publishHtml = mustache.render(that.options.commentItemTpl, response.data);
|
|
|
606
|
+
|
|
|
607
|
+ if ($commentsList.find("li").size() === 0) {
|
|
|
608
|
+ $commentsList.html(publishHtml);
|
|
|
609
|
+ } else {
|
|
|
610
|
+ $commentsList.find("li").eq(0).before(publishHtml);
|
|
|
611
|
+ }
|
|
|
612
|
+
|
|
|
613
|
+ box.alert(tips.getTips("publishSuccess"), 5);
|
|
|
614
|
+ $(".comment-textarea textarea").val('');
|
|
|
615
|
+
|
|
|
616
|
+ commentsNum = 1;
|
|
|
617
|
+ if (!!parseInt(that.options.commentNum.eq(0).text())) {
|
|
|
618
|
+ commentsNum = parseInt(that.options.commentNum.eq(0).text()) + 1;
|
|
|
619
|
+ };
|
|
|
620
|
+ that.options.commentNum.text(commentsNum);
|
|
|
621
|
+ } else if (900000 === response.code) {
|
|
|
622
|
+ box.alert(tips.getTips("notSameContent"), 5);
|
|
|
623
|
+ } else {
|
|
|
624
|
+ box.alert(tips.getTips("systemBus"), 5);
|
|
|
625
|
+ }
|
|
|
626
|
+
|
|
|
627
|
+ publishHtml = mustache.render(that.options.commentItemTpl, response.data);
|
|
|
628
|
+ that.$element.find(".comments-list").prepend(publishHtml);
|
|
|
629
|
+ }
|
|
|
630
|
+ })
|
|
|
631
|
+ /*$.ajax({
|
650
|
type:'POST',
|
632
|
type:'POST',
|
651
|
url:YohoConfig.mainUrl + that.options.publishUrl,
|
633
|
url:YohoConfig.mainUrl + that.options.publishUrl,
|
652
|
data: data,
|
634
|
data: data,
|
|
@@ -735,106 +717,104 @@ require("./login"); |
|
@@ -735,106 +717,104 @@ require("./login"); |
735
|
=======
|
717
|
=======
|
736
|
}
|
718
|
}
|
737
|
}); */
|
719
|
}); */
|
738
|
- });
|
|
|
739
|
->>>>>>> develop
|
|
|
740
|
-
|
|
|
741
|
- //评论翻页
|
|
|
742
|
- this.$element.on("click.commentPage", ".pager-item", function() {
|
|
|
743
|
- var url = $(this).attr("href"),
|
|
|
744
|
- pageHtml,
|
|
|
745
|
- pageIcon,
|
|
|
746
|
- commentListTop;
|
|
|
747
|
- $.ajax({
|
|
|
748
|
- type: 'GET',
|
|
|
749
|
- url: url,
|
|
|
750
|
- success: function(response) {
|
|
|
751
|
-
|
|
|
752
|
- $(".comments-list").empty();
|
|
|
753
|
- pageHtml = mustache.render(that.options.commentItemTpl, response.data.comment);
|
|
|
754
|
- $(".comments-list").html(pageHtml);
|
|
|
755
|
-
|
|
|
756
|
- pageIcon = $('<div class="channel-index-pager">' + response.data.page + '</div>');
|
|
|
757
|
- $(".comment-pager-content").html(pageIcon);
|
|
|
758
|
-
|
|
|
759
|
- commentListTop = $(".comments-list").offset().top - $("#minEnterprise").outerHeight();
|
|
|
760
|
- $(window).scrollTop(commentListTop);
|
|
|
761
|
- }
|
|
|
762
|
- });
|
|
|
763
|
-
|
|
|
764
|
- return false;
|
|
|
765
|
- });
|
|
|
766
|
-
|
720
|
+ }); >>> >>> > develop
|
|
|
721
|
+
|
|
|
722
|
+ //评论翻页
|
|
|
723
|
+ this.$element.on("click.commentPage", ".pager-item", function() {
|
|
|
724
|
+ var url = $(this).attr("href"),
|
|
|
725
|
+ pageHtml,
|
|
|
726
|
+ pageIcon,
|
|
|
727
|
+ commentListTop;
|
|
|
728
|
+ $.ajax({
|
|
|
729
|
+ type: 'GET',
|
|
|
730
|
+ url: url,
|
|
|
731
|
+ success: function(response) {
|
|
|
732
|
+
|
|
|
733
|
+ $(".comments-list").empty();
|
|
|
734
|
+ pageHtml = mustache.render(that.options.commentItemTpl, response.data.comment);
|
|
|
735
|
+ $(".comments-list").html(pageHtml);
|
|
|
736
|
+
|
|
|
737
|
+ pageIcon = $('<div class="channel-index-pager">' + response.data.page + '</div>');
|
|
|
738
|
+ $(".comment-pager-content").html(pageIcon);
|
|
|
739
|
+
|
|
|
740
|
+ commentListTop = $(".comments-list").offset().top - $("#minEnterprise").outerHeight();
|
|
|
741
|
+ $(window).scrollTop(commentListTop);
|
|
|
742
|
+ }
|
|
|
743
|
+ });
|
|
|
744
|
+
|
|
|
745
|
+ return false;
|
|
|
746
|
+ });
|
|
|
747
|
+
|
|
|
748
|
+
|
|
|
749
|
+
|
|
|
750
|
+ //删除评论
|
|
|
751
|
+ this.$element.on("click.deleteComment", ".delete-comment", function() {
|
|
|
752
|
+ var _this = $(this);
|
|
|
753
|
+ var id = _this.attr('pid');
|
|
|
754
|
+ var deleteTip = tips.getTips("deleteComment");
|
|
|
755
|
+ if (that.options.isFeedback) {
|
|
|
756
|
+ deleteTip = tips.getTips("deleteFeedback");
|
|
|
757
|
+ } else if (that.options.isEdit) {
|
|
|
758
|
+ deleteTip = tips.getTips("deleteEdit");
|
|
|
759
|
+ }
|
|
|
760
|
+ box.confirm(deleteTip, function() {
|
|
|
761
|
+ $.ajax({
|
|
|
762
|
+ type: 'POST',
|
|
|
763
|
+ url: YohoConfig.mainUrl + that.options.deleteUrl,
|
|
|
764
|
+ data: 'id=' + id,
|
|
|
765
|
+ dataType: 'json',
|
|
|
766
|
+ success: function(response) {
|
|
|
767
|
+ if (response.status) {
|
|
|
768
|
+ _this.parents("li").remove();
|
|
|
769
|
+ var comments = parseInt($(".comment-num").eq(0).text()) - 1;
|
|
|
770
|
+ if (comments > 0) {
|
|
|
771
|
+ that.options.commentNum.text(comments);
|
|
|
772
|
+ } else {
|
|
|
773
|
+ that.options.commentNum.html('<img src="' + YohoConfig.resUrl + 'boysweb/assets/images/mobile/comment-mobile.png">');
|
|
|
774
|
+ $(".comment-num.zero").text(0);
|
|
|
775
|
+ $(".comment-num.edit-comment").text('留言');
|
|
|
776
|
+ }
|
|
|
777
|
+ }
|
|
|
778
|
+ }
|
|
|
779
|
+ });
|
|
|
780
|
+ });
|
|
|
781
|
+ });
|
|
|
782
|
+
|
|
|
783
|
+ $(".third-login-box").on("click", "a", function() {
|
|
|
784
|
+ var _this = $(this);
|
|
|
785
|
+ if (!_this.attr('ref')) return;
|
|
|
786
|
+ window.open(_this.attr('ref'), "", "width=760,height=650,top=300,left=300");
|
|
|
787
|
+ return false;
|
|
|
788
|
+ }) $(".third-login-box").on("click", "a.yoho", function() {
|
|
|
789
|
+ $(this).login("loginBoxAnimate");
|
|
|
790
|
+ })
|
|
|
791
|
+ },
|
|
|
792
|
+
|
|
|
793
|
+ publishComment: function() {
|
|
|
794
|
+ var textareaVal = $(".comment-textarea").find("textarea").val();
|
|
|
795
|
+ if (!!!textareaVal || $.trim(textareaVal) === '') return;
|
|
|
796
|
+ if (this.options.isFeedback) return;
|
|
|
797
|
+ $(".publish-btn").trigger("click.publish");
|
|
|
798
|
+ }
|
767
|
|
799
|
|
768
|
-
|
|
|
769
|
- //删除评论
|
|
|
770
|
- this.$element.on("click.deleteComment", ".delete-comment", function() {
|
|
|
771
|
- var _this = $(this);
|
|
|
772
|
- var id = _this.attr('pid');
|
|
|
773
|
- var deleteTip = tips.getTips("deleteComment");
|
|
|
774
|
- if (that.options.isFeedback) {
|
|
|
775
|
- deleteTip = tips.getTips("deleteFeedback");
|
|
|
776
|
- } else if (that.options.isEdit) {
|
|
|
777
|
- deleteTip = tips.getTips("deleteEdit");
|
|
|
778
|
- }
|
|
|
779
|
- box.confirm(deleteTip, function() {
|
|
|
780
|
- $.ajax({
|
|
|
781
|
- type: 'POST',
|
|
|
782
|
- url: YohoConfig.mainUrl + that.options.deleteUrl,
|
|
|
783
|
- data: 'id=' + id,
|
|
|
784
|
- dataType: 'json',
|
|
|
785
|
- success: function(response) {
|
|
|
786
|
- if (response.status) {
|
|
|
787
|
- _this.parents("li").remove();
|
|
|
788
|
- var comments = parseInt($(".comment-num").eq(0).text()) - 1;
|
|
|
789
|
- if (comments > 0) {
|
|
|
790
|
- that.options.commentNum.text(comments);
|
|
|
791
|
- } else {
|
|
|
792
|
- that.options.commentNum.html('<img src="' + YohoConfig.resUrl + 'boysweb/assets/images/mobile/comment-mobile.png">');
|
|
|
793
|
- $(".comment-num.zero").text(0);
|
|
|
794
|
- $(".comment-num.edit-comment").text('留言');
|
|
|
795
|
- }
|
|
|
796
|
- }
|
|
|
797
|
- }
|
|
|
798
|
- });
|
|
|
799
|
- });
|
|
|
800
|
- });
|
|
|
801
|
-
|
|
|
802
|
- $(".third-login-box").on("click", "a", function() {
|
|
|
803
|
- var _this = $(this);
|
|
|
804
|
- if (!_this.attr('ref')) return;
|
|
|
805
|
- window.open(_this.attr('ref'), "", "width=760,height=650,top=300,left=300");
|
|
|
806
|
- return false;
|
|
|
807
|
- })
|
|
|
808
|
- $(".third-login-box").on("click", "a.yoho", function() {
|
|
|
809
|
- $(this).login("loginBoxAnimate");
|
|
|
810
|
- })
|
|
|
811
|
- },
|
|
|
812
|
-
|
|
|
813
|
- publishComment: function() {
|
|
|
814
|
- var textareaVal = $(".comment-textarea").find("textarea").val();
|
|
|
815
|
- if (!!!textareaVal || $.trim(textareaVal) === '') return;
|
|
|
816
|
- if (this.options.isFeedback) return;
|
|
|
817
|
- $(".publish-btn").trigger("click.publish");
|
|
|
818
|
- }
|
|
|
819
|
-
|
|
|
820
|
- };
|
800
|
+ };
|
821
|
|
801
|
|
822
|
|
802
|
|
823
|
- function Plugin(option, _relatedTarget) {
|
|
|
824
|
- return this.each(function() {
|
|
|
825
|
- var $this = $(this);
|
|
|
826
|
- var data = $this.data('yoho.Comment');
|
|
|
827
|
- var options = $.extend({}, Comment.DEFAULTS, $this.data(), typeof option == 'object' && option);
|
|
|
828
|
- // 如果没有初始化,则初始化该对象,并且把该对象绑定到此元素的yoho.PicSilder属性下。
|
|
|
829
|
- if (!data) $this.data('yoho.Comment', (data = new Comment(this, options)));
|
803
|
+ function Plugin(option, _relatedTarget) {
|
|
|
804
|
+ return this.each(function() {
|
|
|
805
|
+ var $this = $(this);
|
|
|
806
|
+ var data = $this.data('yoho.Comment');
|
|
|
807
|
+ var options = $.extend({}, Comment.DEFAULTS, $this.data(), typeof option == 'object' && option);
|
|
|
808
|
+ // 如果没有初始化,则初始化该对象,并且把该对象绑定到此元素的yoho.PicSilder属性下。
|
|
|
809
|
+ if (!data) $this.data('yoho.Comment', (data = new Comment(this, options)));
|
830
|
|
810
|
|
831
|
- // 如果传递的options是一个字符串,则表示调用改对象的原型方法。
|
|
|
832
|
- if (typeof option == 'string') data[option](_relatedTarget);
|
|
|
833
|
- });
|
|
|
834
|
- };
|
811
|
+ // 如果传递的options是一个字符串,则表示调用改对象的原型方法。
|
|
|
812
|
+ if (typeof option == 'string') data[option](_relatedTarget);
|
|
|
813
|
+ });
|
|
|
814
|
+ };
|
835
|
|
815
|
|
836
|
|
816
|
|
837
|
- $.fn.comment = Plugin;
|
|
|
838
|
- $.fn.comment.Constructor = Comment;
|
817
|
+ $.fn.comment = Plugin;
|
|
|
818
|
+ $.fn.comment.Constructor = Comment;
|
839
|
|
819
|
|
840
|
-})(this); |
|
|
|
|
820
|
+ })(this); |