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