| author | rbernard |
| Mon, 22 Feb 2010 22:30:38 +0100 | |
| changeset 190 | faf3a87a7d73 |
| parent 106 | 36165e7cd1f0 |
| child 329 | 00df963f91fb |
| permissions | -rw-r--r-- |
| 0 | 1 |
gShowingAllComments = false ; |
2 |
// YUI : queue, overlay |
|
3 |
Sync = function() { |
|
4 |
// this queue handles both animations and io requests |
|
5 |
this._q = null ; |
|
6 |
|
|
7 |
this._iPreventClick = false ; // oh really ? |
|
8 |
} |
|
9 |
||
10 |
Sync.prototype = { |
|
11 |
init : function (iComment) { |
|
12 |
this._q = new CY.AsyncQueue() ; |
|
13 |
// pr2 this._q = new CY.Queue() ; |
|
14 |
}, |
|
15 |
|
|
16 |
setPreventClickOn : function () { |
|
17 |
CY.log("setPreventClickOn !") ; |
|
18 |
if (gLayout.isInFrame()) |
|
19 |
parent.f_interfaceFreeze() |
|
20 |
this._iPreventClick = true ; |
|
21 |
}, |
|
22 |
||
23 |
setPreventClickOff : function () { |
|
24 |
CY.log("setPreventClickOff !") ; |
|
25 |
if (gLayout.isInFrame()) |
|
26 |
parent.f_interfaceUnfreeze() |
|
27 |
this._iPreventClick = false ; |
|
28 |
}, |
|
29 |
||
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'] ; |
|
77 |
||
78 |
var iComment = (successfull) ? args['failure']['iComment'] : args['success']['iComment'] ; |
|
79 |
||
80 |
if (successfull) { |
|
81 |
var ret = args['returned'] ; |
|
82 |
var comment = ret['comment'] ; |
|
83 |
||
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 |
} |
|
94 |
||
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 |
|
|
| 12 | 127 |
if ("ask_for_notification" in ret) { |
128 |
if (ret['ask_for_notification']) { |
|
129 |
// TODO ask for notification ...or use AUTO_CONTRIB ? |
|
| 106 | 130 |
parent.f_yesNoDialog(gettext("Do you want to be notified of all replies in all discussions you participated in?"), gettext("Reply notification"), |
| 12 | 131 |
function() { // special case : no waiting for the return, no error check, nothing ! |
132 |
var cfg = { |
|
133 |
method: "POST", |
|
| 24 | 134 |
data: urlEncode({'fun':'ownNotify', 'key':sv_key, 'version_key':sv_version_key, 'email':ret['email'], 'active':false}) |
|
17
a4be0b8a905d
bug fix : can view own comment on comment add on mod priori
reno
parents:
15
diff
changeset
|
135 |
} ; |
|
a4be0b8a905d
bug fix : can view own comment on comment add on mod priori
reno
parents:
15
diff
changeset
|
136 |
CY.io(sv_client_url, cfg); |
|
a4be0b8a905d
bug fix : can view own comment on comment add on mod priori
reno
parents:
15
diff
changeset
|
137 |
}, this, null, |
|
a4be0b8a905d
bug fix : can view own comment on comment add on mod priori
reno
parents:
15
diff
changeset
|
138 |
function() { // special case : no waiting for the return, no error check, nothing ! |
|
a4be0b8a905d
bug fix : can view own comment on comment add on mod priori
reno
parents:
15
diff
changeset
|
139 |
var cfg = { |
|
a4be0b8a905d
bug fix : can view own comment on comment add on mod priori
reno
parents:
15
diff
changeset
|
140 |
method: "POST", |
| 24 | 141 |
data: urlEncode({'fun':'ownNotify', 'key':sv_key, 'version_key':sv_version_key, 'email':ret['email'], 'active':true}) |
| 12 | 142 |
} ; |
143 |
CY.io(sv_client_url, cfg); |
|
144 |
}, this, null) ; |
|
145 |
} |
|
146 |
} |
|
147 |
|
|
148 |
|
|
| 0 | 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 |
} |
|
171 |
||
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 |
} |
|
184 |
||
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 |
} |
|
190 |
||
191 |
this._q.add({fn:CY.bind(this.setPreventClickOff, this)}) ; |
|
192 |
this.resume() ; |
|
193 |
}, |
|
194 |
|
|
195 |
example : function () { |
|
196 |
CY.log('in example .........') ; |
|
197 |
}, |
|
198 |
||
199 |
moderateComment : function(iComment, state) { |
|
200 |
var comment = gDb.getComment(iComment['commentId']) ; |
|
201 |
this._q.add( |
|
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) { |
|
208 |
this._q.add( |
|
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)}); |
|
278 |
||
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)}); |
|
292 |
||
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() { |
|
304 |
this._q.add({fn:CY.bind(this.setPreventClickOn, this)}); |
|
305 |
|
|
306 |
// this._q.add({fn:function() {cleanICommentForm();}}) ; |
|
307 |
this.hideICommentForm() ; |
|
308 |
|
|
309 |
this._q.add({fn:CY.bind(this.setPreventClickOff, this)}); |
|
310 |
this._q.run() ; |
|
311 |
}, |
|
312 |
cancelEdit : function() { |
|
313 |
this._q.add({fn:CY.bind(this.setPreventClickOn, this)}); |
|
314 |
|
|
315 |
this._q.add({fn:function() {cancelEditForm();}}) ; |
|
316 |
this._animateToTop() ; |
|
317 |
|
|
318 |
this._q.add({fn:CY.bind(this.setPreventClickOff, this)}); |
|
319 |
this._q.run() ; |
|
320 |
}, |
|
321 |
cancelReply : function() { |
|
322 |
this._q.add({fn:CY.bind(this.setPreventClickOn, this)}); |
|
323 |
|
|
324 |
this._q.add({fn:function() {cancelNewReplyForm();}}) ; |
|
325 |
this._animateToTop() ; |
|
326 |
|
|
327 |
this._q.add({fn:CY.bind(this.setPreventClickOff, this)}); |
|
328 |
this._q.run() ; |
|
329 |
}, |
|
330 |
changeScopeFormClick : function() { |
|
331 |
this._q.add({fn:CY.bind(this.setPreventClickOn, this)}); |
|
332 |
|
|
333 |
this._q.add({fn:function() {changeScopeFormClick();}}) ; |
|
334 |
this._animateToTop() ; |
|
335 |
|
|
336 |
this._q.add({fn:CY.bind(this.setPreventClickOff, this)}); |
|
337 |
this._q.run() ; |
|
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] |
|
356 |
||
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() ; |
|
370 |
||
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] ; |
|
| 103 | 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 |
|
|
| 0 | 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 |
||
391 |
showSingleComment : function(comment) { |
|
392 |
this._q.add({fn:CY.bind(this.setPreventClickOn, this)}) ; |
|
393 |
this._showSingleComment(comment) ; |
|
394 |
this._q.add({fn:CY.bind(this.setPreventClickOff, this)}) ; |
|
395 |
this._q.run(); |
|
396 |
}, |
|
397 |
|
|
398 |
browse : function(order, whereto) { |
|
399 |
var comment = gIComments.browse(order, whereto) ; |
|
400 |
if (comment != null) |
|
401 |
this.showSingleComment(comment) ; |
|
402 |
}, |
|
403 |
|
|
| 103 | 404 |
_showComments : function(commentDbIds, topY, atDocumentTop) { |
| 0 | 405 |
this._q.add( |
406 |
{fn:function() { |
|
| 103 | 407 |
gShowingAllComments = atDocumentTop ; |
| 0 | 408 |
gIComments.hide() ; |
409 |
var cs = CY.Array.map(commentDbIds, function(id) { return gDb.getComment(id) ; }) ; |
|
410 |
var comments = gDb.getThreads(cs) ; |
|
411 |
gIComments.fetch(comments) ; |
|
412 |
|
|
413 |
if (commentDbIds.length > 0) { |
|
| 103 | 414 |
if (atDocumentTop) { |
415 |
CY.get('document').set('scrollTop', 0) ; |
|
416 |
} |
|
417 |
else { |
|
| 0 | 418 |
gIComments.activate(commentDbIds[0]) ; |
419 |
var scopeStart = CY.get(".c-id-"+commentDbIds[0]) ; |
|
| 103 | 420 |
if (scopeStart && !scopeStart.inViewportRegion()) // scopeStart could be null when comment has no scope |
| 0 | 421 |
scopeStart.scrollIntoView(true) ; |
422 |
} |
|
423 |
} |
|
424 |
|
|
425 |
gIComments.setPosition([gConf['iCommentLeftPadding'], topY]) ; |
|
426 |
|
|
427 |
gIComments.show() ; |
|
428 |
}}) ; |
|
429 |
}, |
|
430 |
|
|
431 |
_animateTo : function(topY) { |
|
432 |
this._q.add({fn:function() { |
|
433 |
gIComments.setAnimationToPositions(topY) ; |
|
434 |
}}, |
|
435 |
{id:"animationRun", autoContinue:false, fn:CY.bind(gIComments.runAnimations, gIComments)} |
|
436 |
) ; |
|
437 |
}, |
|
438 |
|
|
439 |
_animateToTop : function() { |
|
440 |
var topPos = gIComments.getTopPosition() ; |
|
441 |
if (topPos != null) |
|
442 |
this._animateTo(topPos[1]) ; |
|
443 |
}, |
|
444 |
|
|
445 |
animateToTop : function() { |
|
446 |
this._q.add({fn:CY.bind(this.setPreventClickOn, this)}) ; |
|
447 |
this._animateToTop() ; |
|
448 |
this._q.add({fn:CY.bind(this.setPreventClickOff, this)}) ; |
|
449 |
this._q.run(); |
|
450 |
}, |
|
451 |
|
|
452 |
showAllComments : function() { |
|
453 |
checkForOpenedDialog(null, function() { |
|
454 |
gShowingAllComments = true ; |
|
455 |
var allTopComments = CY.Array.map(gDb.comments, function(c){return c.id;}) ; |
|
456 |
this.showComments(allTopComments, [0,0], true) ; |
|
457 |
}, this, null) ; |
|
458 |
}, |
|
459 |
||
| 103 | 460 |
showScopeRemovedComments : function() { |
461 |
checkForOpenedDialog(null, function() { |
|
462 |
gShowingAllComments = true ; |
|
463 |
var scopeRemovedComments = CY.Array.filter(gDb.comments, function(comment) { return (comment.start_wrapper == -1) ; }) ; |
|
464 |
var scopeRemovedCommentIds = CY.Array.map(scopeRemovedComments, function(c){return c.id;}) ; |
|
465 |
this.showComments(scopeRemovedCommentIds, [0,0], true) ; |
|
466 |
|
|
467 |
}, this, null) ; |
|
468 |
}, |
|
469 |
||
470 |
showComments : function(commentDbIds, mouseXY, atDocumentTop) { |
|
| 0 | 471 |
checkForOpenedDialog(null, function() { |
472 |
this._q.add({fn:CY.bind(this.setPreventClickOn, this)}) ; |
|
| 103 | 473 |
this._showComments(commentDbIds, mouseXY[1], atDocumentTop) ; |
| 0 | 474 |
this._animateTo(mouseXY[1]) ; |
475 |
this._q.add({fn:CY.bind(this.setPreventClickOff, this)}) ; |
|
476 |
this._q.run(); |
|
477 |
}, this, null) ; |
|
478 |
}, |
|
479 |
||
480 |
openComment : function(iComment) { |
|
481 |
this._q.add({fn:CY.bind(this.setPreventClickOn, this)}) ; |
|
482 |
||
483 |
var y = gIComments.getTopPosition()[1] ; |
|
484 |
this._q.add({fn:function() { |
|
485 |
gIComments.open(iComment.commentId) ; |
|
486 |
gIComments.refresh(iComment.commentId) ; |
|
487 |
}}) ; |
|
488 |
this._animateTo(y) ; |
|
489 |
|
|
490 |
this._q.add({fn:CY.bind(this.setPreventClickOff, this)}) ; |
|
491 |
this._q.run(); |
|
492 |
}, |
|
493 |
|
|
494 |
closeComment : function(iComment) { |
|
495 |
checkForOpenedDialog(iComment, function() { |
|
496 |
this._q.add({fn:CY.bind(this.setPreventClickOn, this)}) ; |
|
497 |
|
|
498 |
var y = gIComments.getTopPosition()[1] ; |
|
499 |
this._q.add({fn:function() { |
|
500 |
var comment = gDb.getComment(iComment.commentId) ; |
|
501 |
gIComments.close(iComment.commentId) ; |
|
502 |
if (comment.reply_to_id != null) |
|
503 |
gIComments.refresh(comment.reply_to_id) ; |
|
504 |
}}) ; |
|
505 |
this._animateTo(y) ; |
|
506 |
|
|
507 |
this._q.add({fn:CY.bind(this.setPreventClickOff, this)}) ; |
|
508 |
this._q.run() ; |
|
509 |
}, this, null) ; |
|
510 |
}, |
|
511 |
|
|
512 |
activate : function(iComment) { |
|
513 |
gIComments.activate(iComment.commentId) ; |
|
514 |
} |
|
515 |
} |
|
516 |
|
|
517 |
readyForAction = function () { |
|
518 |
return !gSync._iPreventClick ; |
|
519 |
}; |