|
0
|
1 |
gShowingAllComments = false ; |
|
|
2 |
// YUI : queue, overlay |
|
|
3 |
Sync = function() { |
|
341
|
4 |
// this queue handles both animations and io requests |
|
|
5 |
this._q = null ; |
|
|
6 |
|
|
|
7 |
this._iPreventClick = false ; // oh really ? |
|
0
|
8 |
} |
|
|
9 |
|
|
|
10 |
Sync.prototype = { |
|
341
|
11 |
init : function (iComment) { |
|
|
12 |
this._q = new CY.AsyncQueue() ; |
|
0
|
13 |
// pr2 this._q = new CY.Queue() ; |
|
341
|
14 |
}, |
|
|
15 |
|
|
|
16 |
setPreventClickOn : function () { |
|
|
17 |
CY.log("setPreventClickOn !") ; |
|
|
18 |
if (gLayout.isInFrame()) |
|
|
19 |
parent.f_interfaceFreeze() |
|
|
20 |
this._iPreventClick = true ; |
|
|
21 |
}, |
|
0
|
22 |
|
|
341
|
23 |
setPreventClickOff : function () { |
|
|
24 |
CY.log("setPreventClickOff !") ; |
|
|
25 |
if (gLayout.isInFrame()) |
|
|
26 |
parent.f_interfaceUnfreeze() |
|
|
27 |
this._iPreventClick = false ; |
|
|
28 |
}, |
|
0
|
29 |
|
|
341
|
30 |
removeCommentRet : function(args) { |
|
|
31 |
var successfull = args['successfull'] ; |
|
|
32 |
|
|
|
33 |
var iComment = (successfull) ? args['failure']['iComment'] : args['success']['iComment'] ; |
|
|
34 |
|
|
|
35 |
if (successfull) { |
|
|
36 |
var filterData = args['returned']['filterData'] ; |
|
|
37 |
if (gLayout.isInFrame()) { |
|
|
38 |
parent.f_updateFilterData(filterData) ; |
|
|
39 |
} |
|
|
40 |
|
|
|
41 |
var y = gIComments.getTopPosition()[1] ; |
|
|
42 |
|
|
|
43 |
var comment = gDb.getComment(iComment.commentId) ; |
|
|
44 |
this._q.add( |
|
|
45 |
function(){ |
|
|
46 |
|
|
|
47 |
unpaintCommentScope(comment) ; |
|
|
48 |
gIComments.close(comment.id) ; |
|
|
49 |
gIComments.remove(comment.id) ; |
|
|
50 |
if (comment.reply_to_id != null) |
|
|
51 |
gIComments.refresh(comment.reply_to_id) ; |
|
|
52 |
|
|
|
53 |
gDb.del(comment) ; |
|
|
54 |
|
|
|
55 |
if (gLayout.isInFrame()) { |
|
|
56 |
if (gDb.comments.length == 0 && gDb.allComments.length != 0) { |
|
|
57 |
parent.f_enqueueMsg(gettext("no filtered comments left")) ; |
|
|
58 |
parent.resetFilter() ; |
|
|
59 |
} |
|
|
60 |
else { |
|
|
61 |
// just counting here ... |
|
|
62 |
var filterRes = gDb.computeFilterResults() ; |
|
|
63 |
updateFilterResultsCount(filterRes['nbDiscussions'], filterRes['nbComments'], filterRes['nbReplies']) ; |
|
|
64 |
} |
|
|
65 |
} |
|
|
66 |
} |
|
|
67 |
); |
|
|
68 |
|
|
|
69 |
this._animateTo(y) ; |
|
|
70 |
} |
|
|
71 |
this._q.add({fn:CY.bind(this.setPreventClickOff, this)}) ; |
|
|
72 |
this.resume() ; |
|
|
73 |
}, |
|
|
74 |
|
|
|
75 |
moderateCommentRet : function(args) { |
|
|
76 |
var successfull = args['successfull'] ; |
|
0
|
77 |
|
|
341
|
78 |
var iComment = (successfull) ? args['failure']['iComment'] : args['success']['iComment'] ; |
|
0
|
79 |
|
|
341
|
80 |
if (successfull) { |
|
|
81 |
var ret = args['returned'] ; |
|
|
82 |
var comment = ret['comment'] ; |
|
0
|
83 |
|
|
341
|
84 |
gDb.upd(comment) ; |
|
|
85 |
|
|
|
86 |
var shouldReset = gLayout.isInFrame() && !parent.f_isFrameFilterFieldsInit() ; |
|
|
87 |
if (shouldReset){ |
|
|
88 |
parent.resetFilter() ; |
|
|
89 |
this._showSingleComment(comment) ; |
|
|
90 |
} |
|
|
91 |
else |
|
|
92 |
iComment.changeModeration(comment) ; |
|
|
93 |
} |
|
0
|
94 |
|
|
341
|
95 |
this._q.add({fn:CY.bind(this.setPreventClickOff, this)}) ; |
|
|
96 |
this.resume() ; |
|
|
97 |
}, |
|
|
98 |
|
|
|
99 |
saveCommentRet : function(args) { |
|
|
100 |
var successfull = args['successfull'] ; |
|
|
101 |
if (successfull) { |
|
|
102 |
var formId = args['success']['formId'] ; |
|
|
103 |
var ret = args['returned'] ; |
|
|
104 |
|
|
|
105 |
removeFormErrMsg(formId) ; |
|
|
106 |
|
|
|
107 |
if ('errors' in ret) { // validation error |
|
|
108 |
var errors = ret['errors'] ; |
|
|
109 |
for (var eltName in errors) { |
|
|
110 |
addFormErrMsg(formId, eltName, errors[eltName]) ; |
|
|
111 |
} |
|
|
112 |
this._animateToTop() ; |
|
|
113 |
} |
|
|
114 |
else { |
|
|
115 |
var isReply = function() {return (gNewReply != null) && (formId == gNewReply['ids']['formId']) ;} ; |
|
|
116 |
var isNewComment = function() {return (gICommentForm != null) && (formId == gICommentForm['formId']) ;} ; |
|
|
117 |
var isEdit = function() {return (gEdit != null) && (formId == gEdit['ids']['formId']) ;} ; |
|
|
118 |
|
|
|
119 |
// doing this here for the a priori moderation case |
|
|
120 |
if (isNewComment()) |
|
|
121 |
this.hideICommentForm(cleanICommentForm()) ; |
|
|
122 |
else if (isEdit()) |
|
|
123 |
this._hideEditForm() ; |
|
|
124 |
else if (isReply()) |
|
|
125 |
this._hideNewReplyForm() ; |
|
|
126 |
|
|
|
127 |
if ("ask_for_notification" in ret) { |
|
|
128 |
if (ret['ask_for_notification']) { |
|
|
129 |
// TODO ask for notification ...or use AUTO_CONTRIB ? |
|
|
130 |
parent.f_yesNoDialog(gettext("Do you want to be notified of all replies in all discussions you participated in?"), gettext("Reply notification"), |
|
|
131 |
function() { // special case : no waiting for the return, no error check, nothing ! |
|
|
132 |
var cfg = { |
|
|
133 |
method: "POST", |
|
|
134 |
data: urlEncode({'fun':'ownNotify', 'key':sv_key, 'version_key':sv_version_key, 'email':ret['email'], 'active':false}) |
|
|
135 |
} ; |
|
|
136 |
CY.io(sv_client_url, cfg); |
|
|
137 |
}, this, null, |
|
|
138 |
function() { // special case : no waiting for the return, no error check, nothing ! |
|
|
139 |
var cfg = { |
|
|
140 |
method: "POST", |
|
|
141 |
data: urlEncode({'fun':'ownNotify', 'key':sv_key, 'version_key':sv_version_key, 'email':ret['email'], 'active':true}) |
|
|
142 |
} ; |
|
|
143 |
CY.io(sv_client_url, cfg); |
|
|
144 |
}, this, null) ; |
|
|
145 |
} |
|
|
146 |
} |
|
|
147 |
|
|
|
148 |
|
|
|
149 |
if ("comment" in ret) { // won't be when add with a priori moderation |
|
|
150 |
var comment = ret['comment'] ; |
|
|
151 |
|
|
|
152 |
gDb.upd(comment) ; |
|
|
153 |
|
|
|
154 |
var shouldReset = gLayout.isInFrame() && !parent.f_isFrameFilterFieldsInit() ; |
|
|
155 |
if (shouldReset) |
|
|
156 |
parent.resetFilter() ; |
|
|
157 |
else { // ASSUMING filter is in init state ! (because when not // TODO $$$$$$$$$$$ this isn't true anymore .... when passing filter arguments in url !! |
|
|
158 |
// in frame for now data can't be filtered) |
|
|
159 |
if (comment.reply_to_id == null) { // not a reply |
|
|
160 |
unpaintCommentScope(comment) ; // for the edit case |
|
|
161 |
paintCommentScope(comment) ; |
|
|
162 |
} |
|
|
163 |
} |
|
|
164 |
|
|
|
165 |
// UPDATE FILTER DATA // TODO move ???? |
|
|
166 |
var filterData = ret['filterData'] ; |
|
|
167 |
if (gLayout.isInFrame()) { |
|
|
168 |
parent.f_updateFilterData(filterData) ; |
|
|
169 |
updateResetFilterResultsCount() ; |
|
|
170 |
} |
|
0
|
171 |
|
|
341
|
172 |
if (isReply()) { // add reply case |
|
|
173 |
if (!shouldReset) { |
|
|
174 |
this._insertReply(comment) ; |
|
|
175 |
} |
|
|
176 |
} |
|
|
177 |
else { // edit (reply or comment) or add (comment) case |
|
|
178 |
this._showSingleComment(comment) ; |
|
|
179 |
} |
|
|
180 |
} |
|
|
181 |
else |
|
|
182 |
this._animateToTop() ; |
|
|
183 |
} |
|
0
|
184 |
|
|
341
|
185 |
} |
|
|
186 |
else { // TODO ? ALL ret-FUNCTIONS ? |
|
|
187 |
this._q.add({id:"expl", fn:function () {CY.log('in example .........') ;}}) ; |
|
|
188 |
this._q.promote("expl") ; |
|
|
189 |
} |
|
0
|
190 |
|
|
341
|
191 |
this._q.add({fn:CY.bind(this.setPreventClickOff, this)}) ; |
|
|
192 |
this.resume() ; |
|
|
193 |
}, |
|
|
194 |
|
|
|
195 |
example : function () { |
|
|
196 |
CY.log('in example .........') ; |
|
|
197 |
}, |
|
0
|
198 |
|
|
341
|
199 |
moderateComment : function(iComment, state) { |
|
|
200 |
var comment = gDb.getComment(iComment['commentId']) ; |
|
0
|
201 |
this._q.add( |
|
341
|
202 |
{fn:CY.bind(this.setPreventClickOn, this)}, |
|
|
203 |
{autoContinue:false, fn:CY.bind(doExchange, null, "editComment", {'comment_key':comment.key, 'state':state}, null, this.moderateCommentRet, this, {'iComment':iComment}, gettext("could not save comment"))} |
|
|
204 |
).run(); |
|
|
205 |
}, |
|
|
206 |
|
|
|
207 |
_saveComment : function(serverFun, formId) { |
|
0
|
208 |
this._q.add( |
|
341
|
209 |
{fn:CY.bind(this.setPreventClickOn, this)}, |
|
|
210 |
{autoContinue:false, fn:CY.bind(doExchange, null, serverFun, {}, formId, this.saveCommentRet, this, {'formId':formId}, gettext("could not save comment"))} |
|
|
211 |
).run(); |
|
|
212 |
}, |
|
|
213 |
|
|
|
214 |
editComment : function() { |
|
|
215 |
this._saveComment("editComment", gEdit['ids']['formId']) ; |
|
|
216 |
}, |
|
|
217 |
|
|
|
218 |
saveComment : function(formId) { |
|
|
219 |
this._saveComment("addComment", formId) ; |
|
|
220 |
}, |
|
|
221 |
|
|
|
222 |
removeComment : function(iComment) { |
|
|
223 |
checkForOpenedDialog(iComment, function() { |
|
|
224 |
if (gLayout.isInFrame()) { |
|
|
225 |
parent.f_yesNoDialog(gettext("Are you sure you want to delete this comment?"), gettext("Warning"), function() { this.animateToTop() ;}, this, null, function() { |
|
|
226 |
var comment = gDb.getComment(iComment.commentId) ; |
|
|
227 |
this._q.add( |
|
|
228 |
{fn:CY.bind(this.setPreventClickOn, this)}, |
|
|
229 |
{autoContinue:false, fn:CY.bind(doExchange, null, "removeComment", {'comment_key':comment.key}, null, this.removeCommentRet, this, {'iComment':iComment}, gettext("could not remove comment"))} |
|
|
230 |
).run(); |
|
|
231 |
}, this, null) ; |
|
|
232 |
|
|
|
233 |
} |
|
|
234 |
// else { |
|
|
235 |
// alert("TODO : can't yet delete comments when not embed in text_view_frame because can't 'dialog' confirmation") ; |
|
|
236 |
// } |
|
|
237 |
|
|
|
238 |
}, this, null) ; |
|
|
239 |
}, |
|
|
240 |
|
|
|
241 |
resume : function(commentDbIds, mouseXY) { |
|
|
242 |
this._q.run() ; |
|
|
243 |
}, |
|
|
244 |
|
|
|
245 |
resetAutoContinue : function(callbackId) { |
|
|
246 |
this._q.getCallback(callbackId).autoContinue = true; |
|
|
247 |
}, |
|
|
248 |
|
|
|
249 |
hideICommentForm : function(funObj) { |
|
|
250 |
// this._q.add({fn:function() {persistICommentFormValues();}}) ; |
|
|
251 |
this._q.add({autoContinue:false, fn:CY.bind(gICommentForm['animationHide'].run, gICommentForm['animationHide'])}) ; |
|
|
252 |
// this._q.add({fn:function() {cleanICommentForm();}}) ; |
|
|
253 |
if (funObj) |
|
|
254 |
this._q.add(funObj) ; |
|
|
255 |
}, |
|
|
256 |
|
|
|
257 |
/* ANIMATION DRIVEN INTERFACE CHANGES */ |
|
|
258 |
|
|
|
259 |
showCommentForm : function(iComment) { |
|
|
260 |
checkForOpenedDialog(null, function() { |
|
|
261 |
this._q.add({fn:CY.bind(this.setPreventClickOn, this)}); |
|
|
262 |
this._q.add({fn:function() { |
|
|
263 |
if (iComment == null) { |
|
|
264 |
var selection = getSelectionInfo() ; |
|
|
265 |
updateICommentFormSelection(selection) ; |
|
|
266 |
} |
|
|
267 |
showICommentForm(iComment); |
|
|
268 |
}}) ; |
|
|
269 |
this._q.add({autoContinue:false, fn:CY.bind(gICommentForm['animationShow'].run, gICommentForm['animationShow'])}, |
|
|
270 |
{fn:CY.bind(this.setPreventClickOff, this)} |
|
|
271 |
).run(); |
|
|
272 |
}, this, null) ; |
|
|
273 |
}, |
|
|
274 |
|
|
|
275 |
showEditForm : function(iComment) { |
|
|
276 |
checkForOpenedDialog(null, function() { |
|
|
277 |
this._q.add({fn:CY.bind(this.setPreventClickOn, this)}); |
|
0
|
278 |
|
|
341
|
279 |
this._q.add({fn:function() { |
|
|
280 |
showEditForm(iComment) ; |
|
|
281 |
}}); |
|
|
282 |
this._animateToTop() ; |
|
|
283 |
|
|
|
284 |
this._q.add({fn:CY.bind(this.setPreventClickOff, this)}); |
|
|
285 |
this._q.run() ; |
|
|
286 |
}, this, null) ; |
|
|
287 |
}, |
|
|
288 |
|
|
|
289 |
showReplyForm : function(iComment) { |
|
|
290 |
checkForOpenedDialog(null, function() { |
|
|
291 |
this._q.add({fn:CY.bind(this.setPreventClickOn, this)}); |
|
0
|
292 |
|
|
341
|
293 |
this._q.add({fn:function() { |
|
|
294 |
instanciateNewReplyForm(iComment) ; |
|
|
295 |
}}); |
|
|
296 |
this._animateToTop() ; |
|
|
297 |
|
|
|
298 |
this._q.add({fn:CY.bind(this.setPreventClickOff, this)}); |
|
|
299 |
this._q.run() ; |
|
|
300 |
}, this, null) ; |
|
|
301 |
}, |
|
|
302 |
|
|
|
303 |
cancelICommentForm : function() { |
|
0
|
304 |
this._q.add({fn:CY.bind(this.setPreventClickOn, this)}); |
|
|
305 |
|
|
341
|
306 |
// this._q.add({fn:function() {cleanICommentForm();}}) ; |
|
|
307 |
this.hideICommentForm() ; |
|
|
308 |
|
|
0
|
309 |
this._q.add({fn:CY.bind(this.setPreventClickOff, this)}); |
|
|
310 |
this._q.run() ; |
|
341
|
311 |
}, |
|
|
312 |
cancelEdit : function() { |
|
0
|
313 |
this._q.add({fn:CY.bind(this.setPreventClickOn, this)}); |
|
|
314 |
|
|
341
|
315 |
this._q.add({fn:function() {cancelEditForm();}}) ; |
|
|
316 |
this._animateToTop() ; |
|
|
317 |
|
|
0
|
318 |
this._q.add({fn:CY.bind(this.setPreventClickOff, this)}); |
|
|
319 |
this._q.run() ; |
|
341
|
320 |
}, |
|
|
321 |
cancelReply : function() { |
|
0
|
322 |
this._q.add({fn:CY.bind(this.setPreventClickOn, this)}); |
|
|
323 |
|
|
341
|
324 |
this._q.add({fn:function() {cancelNewReplyForm();}}) ; |
|
|
325 |
this._animateToTop() ; |
|
|
326 |
|
|
0
|
327 |
this._q.add({fn:CY.bind(this.setPreventClickOff, this)}); |
|
|
328 |
this._q.run() ; |
|
341
|
329 |
}, |
|
|
330 |
changeScopeFormClick : function() { |
|
0
|
331 |
this._q.add({fn:CY.bind(this.setPreventClickOn, this)}); |
|
|
332 |
|
|
341
|
333 |
this._q.add({fn:function() {changeScopeFormClick();}}) ; |
|
|
334 |
this._animateToTop() ; |
|
|
335 |
|
|
0
|
336 |
this._q.add({fn:CY.bind(this.setPreventClickOff, this)}); |
|
|
337 |
this._q.run() ; |
|
341
|
338 |
}, |
|
|
339 |
// this is invoked during queue execution |
|
|
340 |
_hideNewReplyForm : function() { |
|
|
341 |
this._q.add({fn:function() { |
|
|
342 |
cleanNewReplyForm() ; |
|
|
343 |
cancelNewReplyForm() ;}}) ; |
|
|
344 |
}, |
|
|
345 |
// this is invoked during queue execution |
|
|
346 |
_hideEditForm : function() { |
|
|
347 |
this._q.add({fn:function() { |
|
|
348 |
cancelEditForm() ;}}) ; |
|
|
349 |
}, |
|
|
350 |
// this is invoked during queue execution |
|
|
351 |
_insertReply : function(comment) { |
|
|
352 |
this._q.add({fn:function() { |
|
|
353 |
var parentComment = gDb.getComment(comment.reply_to_id) ; |
|
|
354 |
var parentThread = gDb.getThreads([parentComment]) ; |
|
|
355 |
var previousComment = parentThread[parentThread.length - 2] ; // - 2 because now that comment has been added comment is parentThread[parentThread.length - 1] |
|
0
|
356 |
|
|
341
|
357 |
var iComment = gIComments.insertAfter(previousComment, comment) ; |
|
|
358 |
// iComment CAN'T BE NULL ! (TODO check that there is a |
|
|
359 |
// check server side that parent exists when adding a reply |
|
|
360 |
// !) |
|
|
361 |
|
|
|
362 |
var parentPosition = gIComments.getPosition(comment.reply_to_id) ; |
|
|
363 |
iComment.setPosition(parentPosition) ; |
|
|
364 |
|
|
|
365 |
// check if activation is necessary (will always be ?) |
|
|
366 |
var comment_path = gDb.getPath(comment) ; |
|
|
367 |
var topComment = comment_path[comment_path.length - 1] ; |
|
|
368 |
if (gIComments.isTopActive(topComment.id)) |
|
|
369 |
iComment.activate() ; |
|
0
|
370 |
|
|
341
|
371 |
iComment.show() ;}}) ; |
|
|
372 |
this._animateToTop() ; |
|
|
373 |
}, |
|
|
374 |
_showSingleComment : function(comment) { |
|
|
375 |
if (comment != null) { |
|
|
376 |
var path = gDb.getPath(comment) ; |
|
|
377 |
var topAncestorComment = path[path.length - 1] ; |
|
|
378 |
var topY = 0 ; |
|
|
379 |
if (comment['start_wrapper'] != -1) |
|
|
380 |
topY = CY.get(".c-id-"+topAncestorComment.id).getY() ; |
|
|
381 |
else |
|
|
382 |
topY = CY.get('document').get('scrollTop') ; |
|
|
383 |
|
|
|
384 |
this._showComments([topAncestorComment.id], topY, false) ; |
|
|
385 |
// optim when browsing comments with no reply |
|
|
386 |
if (topAncestorComment.replies.length > 0) |
|
|
387 |
this._animateTo(topY) ; |
|
|
388 |
} |
|
|
389 |
}, |
|
|
390 |
_showFocusSingleComment : function(topComment, focusComment, reply) { |
|
|
391 |
if (topComment != null) { |
|
|
392 |
var topY = 0 ; |
|
|
393 |
if (topComment['start_wrapper'] != -1) |
|
|
394 |
topY = CY.get(".c-id-"+topComment.id).getY() ; |
|
|
395 |
else |
|
|
396 |
topY = CY.get('document').get('scrollTop') ; |
|
|
397 |
|
|
|
398 |
this._showComments([topComment.id], topY, false) ; |
|
|
399 |
// optim when browsing comments with no reply |
|
|
400 |
if (topComment.replies.length > 0 || reply) |
|
|
401 |
this._animateToAndFocus(topY, focusComment.id, reply) ; |
|
|
402 |
} |
|
|
403 |
}, |
|
0
|
404 |
|
|
341
|
405 |
showSingleComment : function(comment) { |
|
|
406 |
this._q.add({fn:CY.bind(this.setPreventClickOn, this)}) ; |
|
|
407 |
this._showSingleComment(comment) ; |
|
|
408 |
this._q.add({fn:CY.bind(this.setPreventClickOff, this)}) ; |
|
|
409 |
this._q.run(); |
|
|
410 |
}, |
|
|
411 |
|
|
|
412 |
showFocusSingleComment : function(topComment, focusComment, reply) { |
|
|
413 |
this._q.add({fn:CY.bind(this.setPreventClickOn, this)}) ; |
|
|
414 |
this._showFocusSingleComment(topComment, focusComment, reply) ; |
|
|
415 |
this._q.add({fn:CY.bind(this.setPreventClickOff, this)}) ; |
|
|
416 |
this._q.run(); |
|
|
417 |
}, |
|
|
418 |
|
|
|
419 |
browse : function(order, whereto) { |
|
|
420 |
var comment = gIComments.browse(order, whereto) ; |
|
|
421 |
if (comment != null) |
|
|
422 |
this.showSingleComment(comment) ; |
|
|
423 |
}, |
|
|
424 |
|
|
|
425 |
_showComments : function(commentDbIds, topY, atDocumentTop) { |
|
|
426 |
this._q.add( |
|
|
427 |
{fn:function() { |
|
|
428 |
gShowingAllComments = atDocumentTop ; |
|
|
429 |
gIComments.hide() ; |
|
421
|
430 |
hideToc(); |
|
341
|
431 |
var cs = CY.Array.map(commentDbIds, function(id) { return gDb.getComment(id) ; }) ; |
|
|
432 |
var comments = gDb.getThreads(cs) ; |
|
|
433 |
gIComments.fetch(comments) ; |
|
|
434 |
|
|
|
435 |
if (commentDbIds.length > 0) { |
|
|
436 |
if (atDocumentTop) { |
|
|
437 |
CY.get('document').set('scrollTop', 0) ; |
|
|
438 |
} |
|
|
439 |
else { |
|
|
440 |
gIComments.activate(commentDbIds[0]) ; |
|
|
441 |
var scopeStart = CY.get(".c-id-"+commentDbIds[0]) ; |
|
|
442 |
if (scopeStart && !scopeStart.inViewportRegion()) // scopeStart could be null when comment has no scope |
|
|
443 |
scopeStart.scrollIntoView(true) ; |
|
|
444 |
} |
|
|
445 |
} |
|
|
446 |
|
|
|
447 |
gIComments.setPosition([gConf['iCommentLeftPadding'], topY]) ; |
|
|
448 |
|
|
|
449 |
gIComments.show() ; |
|
|
450 |
}}) ; |
|
|
451 |
}, |
|
|
452 |
|
|
|
453 |
_animateTo : function(topY) { |
|
|
454 |
this._q.add({fn:function() { |
|
|
455 |
gIComments.setAnimationToPositions(topY) ; |
|
|
456 |
}}, |
|
|
457 |
{id:"animationRun", autoContinue:false, fn:CY.bind(gIComments.runAnimations, gIComments)} |
|
|
458 |
) ; |
|
|
459 |
}, |
|
|
460 |
|
|
|
461 |
_animateToAndFocus : function(topY, focusCommentId, reply) { |
|
|
462 |
this._q.add({fn:function() { |
|
|
463 |
gIComments.setAnimationToPositionsAndFocus(topY, focusCommentId, reply) ; |
|
|
464 |
}}, |
|
|
465 |
{id:"animationRun", autoContinue:false, fn:CY.bind(gIComments.runAnimations, gIComments)} |
|
|
466 |
) ; |
|
|
467 |
}, |
|
|
468 |
|
|
|
469 |
_animateToTop : function() { |
|
|
470 |
var topPos = gIComments.getTopPosition() ; |
|
|
471 |
if (topPos != null) |
|
|
472 |
this._animateTo(topPos[1]) ; |
|
|
473 |
}, |
|
|
474 |
|
|
|
475 |
animateToTop : function() { |
|
|
476 |
this._q.add({fn:CY.bind(this.setPreventClickOn, this)}) ; |
|
|
477 |
this._animateToTop() ; |
|
|
478 |
this._q.add({fn:CY.bind(this.setPreventClickOff, this)}) ; |
|
|
479 |
this._q.run(); |
|
|
480 |
}, |
|
|
481 |
|
|
|
482 |
showAllComments : function() { |
|
|
483 |
checkForOpenedDialog(null, function() { |
|
|
484 |
gShowingAllComments = true ; |
|
|
485 |
var allTopComments = CY.Array.map(gDb.comments, function(c){return c.id;}) ; |
|
375
|
486 |
// GIB: go down the 'add comment' icon |
|
|
487 |
this.showComments(allTopComments, [0,30], true) ; |
|
341
|
488 |
}, this, null) ; |
|
|
489 |
}, |
|
0
|
490 |
|
|
341
|
491 |
showScopeRemovedComments : function() { |
|
|
492 |
checkForOpenedDialog(null, function() { |
|
|
493 |
gShowingAllComments = true ; |
|
|
494 |
var scopeRemovedComments = CY.Array.filter(gDb.comments, function(comment) { return (comment.start_wrapper == -1) ; }) ; |
|
|
495 |
var scopeRemovedCommentIds = CY.Array.map(scopeRemovedComments, function(c){return c.id;}) ; |
|
375
|
496 |
// GIB: go down the 'add comment' icon |
|
|
497 |
this.showComments(scopeRemovedCommentIds, [0,30], true) ; |
|
341
|
498 |
|
|
|
499 |
}, this, null) ; |
|
|
500 |
}, |
|
103
|
501 |
|
|
341
|
502 |
showComments : function(commentDbIds, mouseXY, atDocumentTop) { |
|
|
503 |
checkForOpenedDialog(null, function() { |
|
|
504 |
this._q.add({fn:CY.bind(this.setPreventClickOn, this)}) ; |
|
|
505 |
this._showComments(commentDbIds, mouseXY[1], atDocumentTop) ; |
|
|
506 |
this._animateTo(mouseXY[1]) ; |
|
|
507 |
this._q.add({fn:CY.bind(this.setPreventClickOff, this)}) ; |
|
|
508 |
this._q.run(); |
|
|
509 |
}, this, null) ; |
|
|
510 |
}, |
|
0
|
511 |
|
|
341
|
512 |
openComment : function(iComment) { |
|
|
513 |
this._q.add({fn:CY.bind(this.setPreventClickOn, this)}) ; |
|
0
|
514 |
|
|
341
|
515 |
var y = gIComments.getTopPosition()[1] ; |
|
|
516 |
this._q.add({fn:function() { |
|
|
517 |
gIComments.open(iComment.commentId) ; |
|
|
518 |
gIComments.refresh(iComment.commentId) ; |
|
|
519 |
}}) ; |
|
|
520 |
this._animateTo(y) ; |
|
|
521 |
|
|
|
522 |
this._q.add({fn:CY.bind(this.setPreventClickOff, this)}) ; |
|
|
523 |
this._q.run(); |
|
|
524 |
}, |
|
|
525 |
|
|
|
526 |
closeComment : function(iComment) { |
|
|
527 |
checkForOpenedDialog(iComment, function() { |
|
|
528 |
this._q.add({fn:CY.bind(this.setPreventClickOn, this)}) ; |
|
|
529 |
|
|
|
530 |
var y = gIComments.getTopPosition()[1] ; |
|
|
531 |
this._q.add({fn:function() { |
|
|
532 |
var comment = gDb.getComment(iComment.commentId) ; |
|
|
533 |
gIComments.close(iComment.commentId) ; |
|
|
534 |
if (comment.reply_to_id != null) |
|
|
535 |
gIComments.refresh(comment.reply_to_id) ; |
|
|
536 |
}}) ; |
|
|
537 |
this._animateTo(y) ; |
|
|
538 |
|
|
|
539 |
this._q.add({fn:CY.bind(this.setPreventClickOff, this)}) ; |
|
|
540 |
this._q.run() ; |
|
|
541 |
}, this, null) ; |
|
|
542 |
}, |
|
|
543 |
|
|
|
544 |
activate : function(iComment) { |
|
|
545 |
gIComments.activate(iComment.commentId) ; |
|
|
546 |
} |
|
0
|
547 |
} |
|
341
|
548 |
|
|
0
|
549 |
readyForAction = function () { |
|
341
|
550 |
return !gSync._iPreventClick ; |
|
0
|
551 |
}; |