| author | Production Moz <dev@sopinspace.com> |
| Mon, 16 Apr 2012 15:57:14 +0200 | |
| changeset 410 | 55ce34b8d146 |
| parent 389 | eecda8559c1d |
| child 504 | b2e0186daa5b |
| permissions | -rw-r--r-- |
| 0 | 1 |
// globals used: gConf, gPrefs, gLayout, gSync |
2 |
||
3 |
||
4 |
// IComment == IHM comment class |
|
5 |
IComment = function() { |
|
| 341 | 6 |
|
7 |
this.commentId = null ; |
|
8 |
|
|
9 |
var iCommentWidth = gLayout.getTopICommentsWidth() ; |
|
10 |
var iCommentLeft = gConf['iCommentLeftPadding'] ; |
|
11 |
|
|
12 |
var changeToPending = gettext("change comment state to pending") ; |
|
13 |
var changeToApprove = gettext("change comment state to approved") ; |
|
14 |
var changeToUnapprove= gettext("change comment state to unapproved") ; |
|
15 |
var cancelChange = gettext("cancel changing the state of this comment") ; |
|
16 |
var pending = gettext("pending") ; |
|
17 |
var approved = gettext("approved") ; |
|
18 |
var unapproved = gettext("unapproved") ; |
|
19 |
var cancel = gettext("cancel") ; |
|
20 |
var showReplies = gettext("show replies") ; |
|
21 |
var changeTo= gettext("change to:") ; |
|
22 |
var reply = ngettext("reply","replies",1) ; // hack to get django to add 'replies' as the plural in f_text_view_frame !! |
|
23 |
var editComment = gettext("edit comment") ; |
|
24 |
var deleteComment = gettext("delete comment") ; |
|
25 |
var edit = gettext("edit") ; |
|
26 |
var del = gettext("delete") ; |
|
27 |
var close = gettext("close") ; |
|
28 |
var showScope = gettext("show scope") ; |
|
29 |
var scopeRemoved = gettext("Comment is detached: it was created on a previous version and text it applied to has been modified or removed.") ; |
|
30 |
|
|
31 |
// no header, no body yet |
|
32 |
this.overlay = new CY.Overlay( { |
|
33 |
zIndex :3, |
|
34 |
shim :false, /* until we really need it, no shim */ |
|
35 |
visible :false, |
|
36 |
width : iCommentWidth, |
|
37 |
xy : [ iCommentLeft, 0 ], |
|
38 |
headerContent : '<div class="icomment-header">' + |
|
39 |
'<div class="c-iactions">' + |
|
40 |
'<a class="c-moderate c-action" title="">'+ "vis" +'</a>' + " " + |
|
41 |
'<a class="c-edit c-action" title="'+ editComment +'" alt="' + editComment + '">' + edit + '</a>' + " " + |
|
42 |
'<a class="c-delete c-action" title="'+ deleteComment +'" alt="' + deleteComment + '">' + del + '</a>' + " " + |
|
43 |
'</div>' + |
|
44 |
'<div class="c-state-actions displaynone">' + |
|
45 |
changeTo + ' ' + |
|
46 |
'<a class="c-state-pending c-action" title="' + changeToPending + '" alt="' + changeToPending + '">'+ pending +'</a>' + " " + |
|
47 |
'<a class="c-state-approved c-action" title="' + changeToApprove + '" alt="' + changeToApprove + '">'+ approved +'</a>' + " " + |
|
48 |
'<a class="c-state-unapproved c-action" title="' + changeToUnapprove + '" alt="' + changeToUnapprove + '">'+ unapproved +'</a>' + " " + |
|
49 |
'<a class="c-state-cancel c-action" title="' + cancelChange + '" alt="' + cancelChange + '">' + cancel +'</a>' + " " + |
|
50 |
'</div>' + |
|
51 |
'<div class="c-no-scope-msg">' + |
|
52 |
scopeRemoved + |
|
53 |
'</div>' + |
|
54 |
'<a class="c-show-scope c-action" title="'+ showScope + '" alt="' + showScope + '"><em>-</em></a>' + |
|
55 |
'<a class="c-close c-action" title="'+ close + '" alt="' + close + '"><em>X</em></a>' + |
|
56 |
'</div>', |
|
57 |
bodyContent : '<div class="icomment-body">' + |
|
58 |
'<span class="c-content"></span>' + |
|
59 |
'<span class="c-ireplyactions">' + |
|
60 |
'<a class="c-readreplies c-action" title="'+ showReplies +'" alt="' + showReplies + '">' + showReplies +'</a>' + " " + |
|
61 |
'<a class="c-reply c-action" title="'+ reply +'" alt="' + reply + '">' + reply +'</a>' + " " + |
|
62 |
'</span>' + |
|
63 |
'</div>' |
|
64 |
}); |
|
65 |
|
|
66 |
this.overlay.get('contentBox').addClass("c-comment") ; |
|
67 |
|
|
68 |
// attach to DOM |
|
69 |
this.overlay.render('#leftcolumn'); |
|
70 |
|
|
71 |
this.animation = new CY.Anim({ |
|
| 0 | 72 |
node: this.overlay.get('boundingBox'), |
73 |
duration: gPrefs.get('general','animduration'), |
|
74 |
easing: CY.Easing.easeOut |
|
| 341 | 75 |
}); |
| 0 | 76 |
|
| 341 | 77 |
// CY.on won't work |
78 |
this.overlay.get('contentBox').query(".c-close").on("click", this.onCloseCommentClick, this); |
|
79 |
this.overlay.get('contentBox').query(".c-moderate").on("click", this.onModerateCommentClick, this); |
|
80 |
this.overlay.get('contentBox').query(".c-state-pending").on("click", this.onPendingCommentClick, this); |
|
81 |
this.overlay.get('contentBox').query(".c-state-approved").on("click", this.onApprovedCommentClick, this); |
|
82 |
this.overlay.get('contentBox').query(".c-state-unapproved").on("click", this.onUnapprovedCommentClick, this); |
|
83 |
this.overlay.get('contentBox').query(".c-state-cancel").on("click", this.onCancelStateChangeClick, this); |
|
84 |
this.overlay.get('contentBox').query(".c-edit").on("click", this.onEditCommentClick, this); |
|
85 |
this.overlay.get('contentBox').query(".c-delete").on("click", this.onDeleteCommentClick, this); |
|
86 |
this.overlay.get('contentBox').query(".c-reply").on("click", this.onReplyCommentClick, this); |
|
87 |
this.overlay.get('contentBox').query(".c-readreplies").on("click", this.onReadRepliesCommentClick, this); |
|
| 0 | 88 |
|
| 341 | 89 |
this.overlay.get('contentBox').query(".icomment-header").on("mouseenter", this.onMouseEnterHeader, this); |
90 |
this.overlay.get('contentBox').query(".icomment-header").on("mouseleave", this.onMouseLeaveHeader, this); |
|
91 |
|
|
92 |
this.overlay.get('contentBox').on("click", this.onCommentClick, this); |
|
| 0 | 93 |
} |
94 |
||
95 |
IComment.prototype = { |
|
| 341 | 96 |
// checking readyForAction is not enough because handler could be called after animation end in the case : |
97 |
// close btn is clicked before animation end (so before overlay gets hidden) but handler is called after so preventClickOn is false and close is called on an invisible overlay. |
|
98 |
// (whan clicking very fast on the close button while close animation is taking place). |
|
99 |
// SO : SHOULD ALWAYS CHECK FOR VISIBLE OVERLAY IN HANDLERS THAT COULD BE CALLED FROM AN ANIMATED OVERLAY |
|
100 |
onCloseCommentClick : function (e) { |
|
101 |
e.halt() ; // prevent click triggered on content box |
|
102 |
if (readyForAction() && this.isVisible()) |
|
103 |
gSync.closeComment(this) ; |
|
104 |
}, |
|
105 |
onModerateCommentClick : function (e) { |
|
106 |
e.halt() ; // prevent click triggered on content box |
|
107 |
if (readyForAction() && this.isVisible()) { |
|
108 |
this.overlay.get('contentBox').query(".c-iactions").addClass("displaynone") ; |
|
109 |
this.overlay.get('contentBox').query(".c-state-actions").removeClass("displaynone") ; |
|
110 |
} |
|
111 |
}, |
|
112 |
onPendingCommentClick : function (e) { |
|
113 |
e.halt() ; // prevent click triggered on content box |
|
114 |
if (readyForAction() && this.isVisible()) { |
|
115 |
gSync.moderateComment(this, 'pending') ; |
|
116 |
} |
|
117 |
}, |
|
118 |
onApprovedCommentClick : function (e) { |
|
119 |
e.halt() ; // prevent click triggered on content box |
|
120 |
if (readyForAction() && this.isVisible()) { |
|
121 |
gSync.moderateComment(this, 'approved') ; |
|
122 |
} |
|
123 |
}, |
|
124 |
onUnapprovedCommentClick : function (e) { |
|
125 |
e.halt() ; // prevent click triggered on content box |
|
126 |
if (readyForAction() && this.isVisible()) { |
|
127 |
gSync.moderateComment(this, 'unapproved') ; |
|
128 |
} |
|
129 |
}, |
|
130 |
onCancelStateChangeClick : function (e) { |
|
131 |
e.halt() ; // prevent click triggered on content box |
|
132 |
if (readyForAction() && this.isVisible()) { |
|
133 |
this.overlay.get('contentBox').query(".c-iactions").removeClass("displaynone") ; |
|
134 |
this.overlay.get('contentBox').query(".c-state-actions").addClass("displaynone") ; |
|
135 |
} |
|
136 |
}, |
|
137 |
onDeleteCommentClick : function (e) { |
|
138 |
e.halt() ; // prevent click triggered on content box |
|
139 |
if (readyForAction() && this.isVisible()) { |
|
140 |
gSync.removeComment(this) ; |
|
141 |
} |
|
142 |
}, |
|
143 |
onEditCommentClick : function (e) { |
|
144 |
e.halt() ; // prevent click triggered on content box |
|
145 |
if (readyForAction() && this.isVisible()) |
|
146 |
gSync.showEditForm(this) ; |
|
147 |
}, |
|
148 |
onReplyCommentClick : function (e) { |
|
149 |
e.halt() ; // prevent click triggered on content box |
|
150 |
if (readyForAction() && this.isVisible()) |
|
151 |
gSync.showReplyForm(this) ; |
|
152 |
}, |
|
153 |
onReadRepliesCommentClick : function (e) { |
|
154 |
e.halt() ; // prevent click triggered on content box |
|
155 |
if (readyForAction() && this.isVisible()) |
|
156 |
gSync.openComment(this) ; |
|
157 |
}, |
|
158 |
onCommentClick : function (e) { |
|
159 |
if (readyForAction() && this.isVisible()) { |
|
160 |
// first condition here is checking it's not clicked via a 'show comments' link |
|
161 |
if (e.target.get("target") == "_blank") { |
|
162 |
var link = e.target ; |
|
163 |
var showCommentUrl = sv_site_url + sv_text_view_show_comment_url ; |
|
164 |
if (link.get('href').indexOf(showCommentUrl) == 0) { |
|
165 |
var res = (new RegExp('comment_id_key=([^&]*)', "g")).exec(link.get('href')) ; |
|
166 |
if (res != null) { |
|
167 |
// open new comment .... we'll suppose it satisfies the filter for now |
|
168 |
// TODO : should we reset the filter in this case ? instead of having the link open in a new window |
|
169 |
var id_key = res[1] ; |
|
170 |
var comment = gDb.getCommentByIdKey(id_key) ; |
|
171 |
if (comment != null) { |
|
172 |
e.halt() ; |
|
173 |
if (!link.hasClass("c-permalink")) {// clicking on the permalink itself should do anything |
|
174 |
checkForOpenedDialog(null, function() { |
|
175 |
gSync.showSingleComment(comment) ; |
|
176 |
}) ; |
|
177 |
} |
|
178 |
} |
|
179 |
} |
|
180 |
} |
|
181 |
} |
|
182 |
else { |
|
183 |
if (gShowingAllComments) { |
|
184 |
// next special dirty case test explained : when editing/replying to a comment with gShowingAllComments a click in the edit/reply form also is a click on the iComment, in this case we don't want to showSingleComment .... |
|
185 |
// should be handled via a preventDefault in some way |
|
186 |
if (!this._isHostingAForm()) { |
|
187 |
var comment = gDb.getComment(this.commentId) ; |
|
188 |
checkForOpenedDialog(null, function() { |
|
189 |
if (comment != null) |
|
190 |
gSync.showSingleComment(comment) ; |
|
191 |
}) |
|
192 |
} |
|
193 |
} |
|
194 |
else |
|
195 |
gSync.activate(this) ; |
|
196 |
} |
|
197 |
} |
|
198 |
}, |
|
199 |
|
|
200 |
onMouseEnterHeader : function () { |
|
|
389
eecda8559c1d
Allow permalink on comments even when embedfing iframe.
gibus
parents:
341
diff
changeset
|
201 |
if (readyForAction() && this.isVisible()) { |
| 341 | 202 |
this.overlay.get('contentBox').query(".c-permalink").removeClass('displaynone'); |
203 |
} |
|
204 |
}, |
|
205 |
|
|
206 |
onMouseLeaveHeader : function () { |
|
|
389
eecda8559c1d
Allow permalink on comments even when embedfing iframe.
gibus
parents:
341
diff
changeset
|
207 |
if (readyForAction() && this.isVisible()) { |
| 341 | 208 |
this.overlay.get('contentBox').query(".c-permalink").addClass('displaynone'); |
209 |
} |
|
210 |
}, |
|
211 |
|
|
212 |
setWidth : function(width) { |
|
213 |
this.overlay.get('boundingBox').setStyle("width", width + 'px'); |
|
214 |
}, |
|
215 |
|
|
216 |
activate:function() { |
|
217 |
// debug !! |
|
218 |
// CY.log('activate' + this.commentId) ; |
|
219 |
this.overlay.get('boundingBox').addClass('c-focus-comment') ; |
|
220 |
|
|
221 |
}, |
|
222 |
|
|
223 |
deactivate:function() { |
|
224 |
// debug !! |
|
225 |
// CY.log('deactivate' + this.commentId) ; |
|
226 |
this.overlay.get('boundingBox').removeClass('c-focus-comment') ; |
|
227 |
|
|
228 |
}, |
|
229 |
hide:function() { |
|
230 |
// is IComment the top active one ? |
|
231 |
if (gIComments.isTopActive(this.commentId)) { // then try to activate next in displayed list |
|
232 |
if (!gIComments.activateVisibleNext()) |
|
233 |
gIComments.deactivate() ; |
|
234 |
} |
|
| 0 | 235 |
|
| 341 | 236 |
if (this.isVisible()) { |
237 |
this.overlay.hide(); |
|
238 |
this.overlay.blur() ; |
|
239 |
} |
|
240 |
}, |
|
241 |
hideContent:function() { |
|
242 |
this.overlay.get('contentBox').query(".icomment-header").addClass('displaynone') ; |
|
243 |
this.overlay.get('contentBox').query(".icomment-body").addClass('displaynone') ; |
|
244 |
}, |
|
245 |
showContent:function() { |
|
246 |
this.overlay.get('contentBox').query(".icomment-header").removeClass('displaynone') ; |
|
247 |
this.overlay.get('contentBox').query(".icomment-body").removeClass('displaynone') ; |
|
248 |
}, |
|
249 |
isVisible:function() { |
|
250 |
return this.overlay.get('visible') ; |
|
251 |
}, |
|
252 |
show:function() { |
|
253 |
this.hideReadRepliesLnk() ; // for now |
|
254 |
return this.overlay.show() ; |
|
255 |
}, |
|
256 |
showReadRepliesLnk:function() { |
|
257 |
this.overlay.get('contentBox').query(".c-readreplies").removeClass('displaynone') ; |
|
258 |
}, |
|
259 |
hideReadRepliesLnk:function() { |
|
260 |
this.overlay.get('contentBox').query(".c-readreplies").addClass('displaynone') ; |
|
261 |
}, |
|
262 |
changeModeration:function(comment) { |
|
263 |
var moderationLnk = this.overlay.get('contentBox').query(".c-moderate") ; |
|
264 |
moderationLnk.set("innerHTML", gettext(comment.state)) ; |
|
265 |
|
|
266 |
moderationLnk.removeClass("c-state-approved") ; |
|
267 |
moderationLnk.removeClass("c-state-pending") ; |
|
268 |
moderationLnk.removeClass("c-state-unapproved") ; |
|
269 |
moderationLnk.addClass("c-state-" + comment.state) ; |
|
| 0 | 270 |
|
| 341 | 271 |
this.overlay.get('contentBox').query(".c-iactions").removeClass("displaynone") ; |
272 |
this.overlay.get('contentBox').query(".c-state-actions").addClass("displaynone") ; |
|
273 |
}, |
|
274 |
isfetched : function() { |
|
275 |
return (this.commentId != null) ; |
|
276 |
}, |
|
277 |
unfetch : function() { |
|
278 |
this.commentId = null ; |
|
279 |
}, |
|
280 |
fetch : function(comment) { |
|
281 |
this.commentId = comment.id ; |
|
282 |
var boundingBoxNode = this.overlay.get('boundingBox') ; |
|
283 |
|
|
284 |
if (comment['start_wrapper'] != -1){ |
|
285 |
boundingBoxNode.addClass('c-has-scope') ; |
|
286 |
boundingBoxNode.removeClass('c-has-no-scope') ; |
|
287 |
} |
|
288 |
else { |
|
289 |
boundingBoxNode.addClass('c-has-no-scope') ; |
|
290 |
boundingBoxNode.removeClass('c-has-scope') ; |
|
291 |
} |
|
292 |
|
|
293 |
if (comment['reply_to_id'] != null){ |
|
294 |
boundingBoxNode.addClass('c-is-reply') ; |
|
295 |
} |
|
296 |
else { |
|
297 |
boundingBoxNode.removeClass('c-is-reply') ; |
|
298 |
} |
|
299 |
|
|
300 |
// TITLE |
|
301 |
var titleInfos = interpolate(gettext('last modified on %(date)s'),{'date':comment.modified_user_str}, true) ; |
|
302 |
|
|
303 |
var modifDateTooltip = (comment.modified == comment.created) ? '' : '<a title="' + titleInfos + '"> * </a>' ; |
|
304 |
var permaTitle = gettext('Permalink to this comment') ; |
|
|
389
eecda8559c1d
Allow permalink on comments even when embedfing iframe.
gibus
parents:
341
diff
changeset
|
305 |
var permalink = '<a class="c-permalink displaynone c-action" target="_blank" title="'+ permaTitle +'" href="" >¶ </a>' ; |
| 341 | 306 |
|
307 |
var infos = interpolate(gettext('by %(name)s, created on %(date)s'),{'name':comment.name, 'date':comment.created_user_str}, true) ; |
|
308 |
|
|
309 |
var newTitleContent = '<span class="c-header"><div class="c-header-title">' + comment.title + permalink + '</div><div class="c-infos">' + infos + '</div></span>' ; |
|
310 |
|
|
311 |
var newTitleNode = CY.Node.create(newTitleContent) ; |
|
312 |
var prevTitleNode = boundingBoxNode.query(".c-header") ; |
|
313 |
if (prevTitleNode == null) // first time, no title yet |
|
314 |
boundingBoxNode.query('.icomment-header').insertBefore(newTitleNode, boundingBoxNode.one('.c-iactions')) ; |
|
315 |
else |
|
316 |
prevTitleNode.get('parentNode').replaceChild(newTitleNode, prevTitleNode) ; |
|
| 0 | 317 |
|
| 341 | 318 |
// TAG |
319 |
var newTagNode = CY.Node.create('<div class="c-tags"><span class="c-tags-infos">' + 'tags:' + '</span>' + comment.tags + '</div>') ; |
|
320 |
var prevTagNode = boundingBoxNode.query(".c-tags") ; |
|
321 |
if (prevTagNode == null) |
|
322 |
boundingBoxNode.query('.icomment-header').appendChild(newTagNode) ; |
|
323 |
else |
|
324 |
prevTagNode.get('parentNode').replaceChild(newTagNode, prevTagNode) ; |
|
325 |
// NO TAG ? |
|
326 |
if (comment.tags == "") |
|
327 |
newTagNode.addClass('displaynone') ; |
|
| 0 | 328 |
|
| 341 | 329 |
// CONTENT |
330 |
var newContentNode = CY.Node.create('<span class="c-content">' + comment.content_html + '</span>') ; |
|
331 |
var prevContentNode = boundingBoxNode.query(".c-content") ; |
|
332 |
if (prevContentNode == null) |
|
333 |
boundingBoxNode.query('.icomment-body').appendChild(newContentNode) ; |
|
334 |
else |
|
335 |
prevContentNode.get('parentNode').replaceChild(newContentNode, prevContentNode) ; |
|
| 0 | 336 |
|
| 341 | 337 |
// PERMALINK |
338 |
if (sv_prefix=="") { |
|
339 |
boundingBoxNode.query(".c-permalink").set("href",sv_site_url + comment.permalink) ; |
|
340 |
} |
|
|
389
eecda8559c1d
Allow permalink on comments even when embedfing iframe.
gibus
parents:
341
diff
changeset
|
341 |
else { |
|
410
55ce34b8d146
Allows multiple co-mentable texts to be isplayed in the same HTML page (with Drupal 7 co_ment module).
Production Moz <dev@sopinspace.com>
parents:
389
diff
changeset
|
342 |
comment_id_delta_prefix = sv_delta != '' ? Array(parseInt(sv_delta)+1).join(',') : ''; |
|
55ce34b8d146
Allows multiple co-mentable texts to be isplayed in the same HTML page (with Drupal 7 co_ment module).
Production Moz <dev@sopinspace.com>
parents:
389
diff
changeset
|
343 |
boundingBoxNode.query(".c-permalink").set("href", top.location.protocol + '//' + top.location.hostname + top.location.pathname + '?comment_id_key=' + comment_id_delta_prefix + comment.id_key) ; |
|
389
eecda8559c1d
Allow permalink on comments even when embedfing iframe.
gibus
parents:
341
diff
changeset
|
344 |
} |
| 0 | 345 |
|
| 341 | 346 |
// MODERATION |
347 |
this.changeModeration(comment) ; |
|
| 103 | 348 |
/* useless : use implemendted permanentlink instead |
349 |
* |
|
| 341 | 350 |
// also change link title to give users the possibility to know comment id (to be able to reference this exact comment in GET arguments) |
351 |
var moderationLnk = this.overlay.get('contentBox').query(".c-moderate") ; |
|
352 |
//var cid = (comment.reply_to_id == null) ? this.commentId : "" ; |
|
353 |
moderationLnk.set("title", "click to change comment ID visibility".replace(/ID/, this.commentId).replace(/ /, " ")) ; |
|
354 |
|
|
355 |
*/ |
|
356 |
// open links in new window : |
|
357 |
var links = boundingBoxNode.queryAll(".c-content a") ; |
|
358 |
if (links != null) |
|
359 |
links.setAttribute( "target" , "_blank" ) ; |
|
360 |
links = boundingBoxNode.queryAll(".c-header-title a") ; |
|
361 |
if (links != null) |
|
362 |
links.setAttribute( "target" , "_blank" ) ; |
|
363 |
|
|
364 |
this.permAdapt(comment) ; |
|
365 |
}, |
|
| 0 | 366 |
|
| 341 | 367 |
permAdapt : function(comment) { |
368 |
// this comment permissions |
|
369 |
var delLnk = this.overlay.get('contentBox').query(".c-delete") ; |
|
370 |
if (delLnk) { // there will be a server side check anyway |
|
371 |
if (!comment.can_delete) |
|
372 |
delLnk.addClass('displaynone') ; |
|
373 |
else |
|
374 |
delLnk.removeClass('displaynone') ; |
|
375 |
} |
|
| 0 | 376 |
|
| 341 | 377 |
var editLnk = this.overlay.get('contentBox').query(".c-edit") ; |
378 |
if (editLnk) { |
|
379 |
if (!comment.can_edit) |
|
380 |
editLnk.addClass('displaynone') ; |
|
381 |
else |
|
382 |
editLnk.removeClass('displaynone') ; |
|
383 |
} |
|
384 |
|
|
385 |
var replyLnk = this.overlay.get('contentBox').query(".c-reply") ; |
|
386 |
if (replyLnk) { |
|
387 |
if (!hasPerm("can_create_comment")) |
|
388 |
replyLnk.addClass('displaynone') ; |
|
389 |
else |
|
390 |
replyLnk.removeClass('displaynone') ; |
|
391 |
} |
|
| 0 | 392 |
|
| 341 | 393 |
var moderateLnk = this.overlay.get('contentBox').query(".c-moderate") ; |
394 |
if (moderateLnk) { |
|
395 |
if (!comment.can_moderate) |
|
396 |
moderateLnk.addClass('displaynone') ; |
|
397 |
else |
|
398 |
moderateLnk.removeClass('displaynone') ; |
|
399 |
} |
|
400 |
}, |
|
401 |
setThreadPad : function(pad) { // TODO review ... |
|
402 |
this.overlay.get('contentBox').query('.yui-widget-hd').setStyle('paddingLeft', pad + 'px') ; |
|
403 |
this.overlay.get('contentBox').query('.yui-widget-bd').setStyle('paddingLeft', pad + 'px') ; |
|
404 |
|
|
405 |
}, |
|
406 |
setPosition : function(xy) { |
|
407 |
var boundingBoxNode = this.overlay.get('boundingBox') ; |
|
| 0 | 408 |
|
| 341 | 409 |
boundingBoxNode.setStyle("opacity", 1); // TODO check this is still usefull |
410 |
boundingBoxNode.setXY(xy) ; |
|
411 |
}, |
|
412 |
getPosition : function(xy) { |
|
413 |
var boundingBoxNode = this.overlay.get('boundingBox') ; |
|
| 0 | 414 |
|
| 341 | 415 |
return boundingBoxNode.getXY() ; |
416 |
}, |
|
417 |
onAnimationEnd : function() { |
|
418 |
if (!CY.Lang.isUndefined(this['animation-handle']) && !CY.Lang.isNull(this['animation-handle'])) { |
|
419 |
this['animation-handle'].detach() ; |
|
420 |
this['animation-handle'] = null ; |
|
421 |
// CY.log('detached...') ; |
|
422 |
} |
|
423 |
gIComments.signalAnimationEnd() ; |
|
424 |
if (gIComments.animationsEnded()) |
|
425 |
gIComments.whenAnimationsEnd() ; |
|
426 |
}, |
|
427 |
onAnimationEndFocus : function() { |
|
428 |
if (!CY.Lang.isUndefined(this['animation-handle']) && !CY.Lang.isNull(this['animation-handle'])) { |
|
429 |
this['animation-handle'].detach() ; |
|
430 |
this['animation-handle'] = null ; |
|
431 |
// CY.log('detached...') ; |
|
432 |
} |
|
433 |
gIComments.signalAnimationEnd() ; |
|
434 |
if (gIComments.animationsEnded()) |
|
435 |
gIComments.whenAnimationsEndFocus() ; |
|
436 |
}, |
|
437 |
onAnimationEndReply : function() { |
|
438 |
if (!CY.Lang.isUndefined(this['animation-handle']) && !CY.Lang.isNull(this['animation-handle'])) { |
|
439 |
this['animation-handle'].detach() ; |
|
440 |
this['animation-handle'] = null ; |
|
441 |
// CY.log('detached...') ; |
|
442 |
} |
|
443 |
gIComments.signalAnimationEnd() ; |
|
444 |
if (gIComments.animationsEnded()) |
|
445 |
gIComments.whenAnimationsEndReply() ; |
|
446 |
}, |
|
| 0 | 447 |
|
| 341 | 448 |
//aa = new CY.Anim({node:gIComments._c[0].overlay.get('boundingBox'), to:{xy : [0,0]}, duration:2.0}) |
449 |
setAnimationToPosition : function(toXY, focus, reply) { |
|
450 |
var boundingBoxNode = this.overlay.get('boundingBox') ; |
|
451 |
|
|
452 |
// ANIMATION |
|
453 |
// 2 lines of optim that could be removed (0.011) |
|
454 |
if (gPrefs.get('general','animduration') < 0.011) |
|
455 |
boundingBoxNode.setXY(toXY) ; |
|
456 |
|
|
457 |
this.animation.set('to', { xy: toXY}); |
|
458 |
this.animation.set('duration', gPrefs.get('general','animduration')) ; // shouldn't be here really ... |
|
|
329
00df963f91fb
When comment_id_key is passed as URL parameter, focus on this comment, instead of the top comment of the related thread.
gibus
parents:
294
diff
changeset
|
459 |
if (focus) |
|
337
614669e0e313
Add url parameter (comment_op=reply) to open automatically reply to comment form
gibus
parents:
330
diff
changeset
|
460 |
if (reply) |
| 341 | 461 |
this['animation-handle'] = this.animation.on('end', this.onAnimationEndReply, this); |
|
337
614669e0e313
Add url parameter (comment_op=reply) to open automatically reply to comment form
gibus
parents:
330
diff
changeset
|
462 |
else |
| 341 | 463 |
this['animation-handle'] = this.animation.on('end', this.onAnimationEndFocus, this); |
| 330 | 464 |
else |
| 341 | 465 |
this['animation-handle'] = this.animation.on('end', this.onAnimationEnd, this); |
466 |
|
|
467 |
return this.animation ; |
|
468 |
}, |
|
469 |
getHeight : function() { |
|
470 |
return this.overlay.get('boundingBox').get('offsetHeight') ; |
|
471 |
}, |
|
472 |
scrollIntoView : function() { |
|
473 |
//this.isVisible() && |
|
474 |
if (!this.overlay.get('contentBox').inViewportRegion()) |
|
475 |
this.overlay.get('contentBox').scrollIntoView(true) ; |
|
476 |
}, |
|
477 |
_isHostingAForm : function() { |
|
478 |
return (this.isVisible() && ((gNewReplyHost != null && gNewReplyHost == this) || (gEditICommentHost != null && gEditICommentHost == this))); |
|
479 |
} |
|
| 0 | 480 |
|
481 |
} |