| author | Yves-Marie Haussonne <ymh.work+github@gmail.com> |
| Fri, 09 May 2014 18:35:26 +0200 | |
| changeset 656 | a84519031134 |
| parent 600 | fda73ac53450 |
| 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 |
|
600
fda73ac53450
Use YUI 3.10 (now that conflict with ASCIIMathML is solved).
gibus
parents:
532
diff
changeset
|
78 |
this.overlay.get('contentBox').one(".c-close").on("click", this.onCloseCommentClick, this); |
|
fda73ac53450
Use YUI 3.10 (now that conflict with ASCIIMathML is solved).
gibus
parents:
532
diff
changeset
|
79 |
this.overlay.get('contentBox').one(".c-moderate").on("click", this.onModerateCommentClick, this); |
|
fda73ac53450
Use YUI 3.10 (now that conflict with ASCIIMathML is solved).
gibus
parents:
532
diff
changeset
|
80 |
this.overlay.get('contentBox').one(".c-state-pending").on("click", this.onPendingCommentClick, this); |
|
fda73ac53450
Use YUI 3.10 (now that conflict with ASCIIMathML is solved).
gibus
parents:
532
diff
changeset
|
81 |
this.overlay.get('contentBox').one(".c-state-approved").on("click", this.onApprovedCommentClick, this); |
|
fda73ac53450
Use YUI 3.10 (now that conflict with ASCIIMathML is solved).
gibus
parents:
532
diff
changeset
|
82 |
this.overlay.get('contentBox').one(".c-state-unapproved").on("click", this.onUnapprovedCommentClick, this); |
|
fda73ac53450
Use YUI 3.10 (now that conflict with ASCIIMathML is solved).
gibus
parents:
532
diff
changeset
|
83 |
this.overlay.get('contentBox').one(".c-state-cancel").on("click", this.onCancelStateChangeClick, this); |
|
fda73ac53450
Use YUI 3.10 (now that conflict with ASCIIMathML is solved).
gibus
parents:
532
diff
changeset
|
84 |
this.overlay.get('contentBox').one(".c-edit").on("click", this.onEditCommentClick, this); |
|
fda73ac53450
Use YUI 3.10 (now that conflict with ASCIIMathML is solved).
gibus
parents:
532
diff
changeset
|
85 |
this.overlay.get('contentBox').one(".c-delete").on("click", this.onDeleteCommentClick, this); |
|
fda73ac53450
Use YUI 3.10 (now that conflict with ASCIIMathML is solved).
gibus
parents:
532
diff
changeset
|
86 |
this.overlay.get('contentBox').one(".c-reply").on("click", this.onReplyCommentClick, this); |
|
fda73ac53450
Use YUI 3.10 (now that conflict with ASCIIMathML is solved).
gibus
parents:
532
diff
changeset
|
87 |
this.overlay.get('contentBox').one(".c-readreplies").on("click", this.onReadRepliesCommentClick, this); |
| 0 | 88 |
|
|
600
fda73ac53450
Use YUI 3.10 (now that conflict with ASCIIMathML is solved).
gibus
parents:
532
diff
changeset
|
89 |
this.overlay.get('contentBox').one(".icomment-header").on("mouseenter", this.onMouseEnterHeader, this); |
|
fda73ac53450
Use YUI 3.10 (now that conflict with ASCIIMathML is solved).
gibus
parents:
532
diff
changeset
|
90 |
this.overlay.get('contentBox').one(".icomment-header").on("mouseleave", this.onMouseLeaveHeader, this); |
| 341 | 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()) { |
|
|
600
fda73ac53450
Use YUI 3.10 (now that conflict with ASCIIMathML is solved).
gibus
parents:
532
diff
changeset
|
108 |
this.overlay.get('contentBox').one(".c-iactions").addClass("displaynone") ; |
|
fda73ac53450
Use YUI 3.10 (now that conflict with ASCIIMathML is solved).
gibus
parents:
532
diff
changeset
|
109 |
this.overlay.get('contentBox').one(".c-state-actions").removeClass("displaynone") ; |
| 341 | 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()) { |
|
|
600
fda73ac53450
Use YUI 3.10 (now that conflict with ASCIIMathML is solved).
gibus
parents:
532
diff
changeset
|
133 |
this.overlay.get('contentBox').one(".c-iactions").removeClass("displaynone") ; |
|
fda73ac53450
Use YUI 3.10 (now that conflict with ASCIIMathML is solved).
gibus
parents:
532
diff
changeset
|
134 |
this.overlay.get('contentBox').one(".c-state-actions").addClass("displaynone") ; |
| 341 | 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()) { |
|
600
fda73ac53450
Use YUI 3.10 (now that conflict with ASCIIMathML is solved).
gibus
parents:
532
diff
changeset
|
202 |
this.overlay.get('contentBox').one(".c-permalink").removeClass('displaynone'); |
| 341 | 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()) { |
|
600
fda73ac53450
Use YUI 3.10 (now that conflict with ASCIIMathML is solved).
gibus
parents:
532
diff
changeset
|
208 |
this.overlay.get('contentBox').one(".c-permalink").addClass('displaynone'); |
| 341 | 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() { |
|
|
600
fda73ac53450
Use YUI 3.10 (now that conflict with ASCIIMathML is solved).
gibus
parents:
532
diff
changeset
|
242 |
this.overlay.get('contentBox').one(".icomment-header").addClass('displaynone') ; |
|
fda73ac53450
Use YUI 3.10 (now that conflict with ASCIIMathML is solved).
gibus
parents:
532
diff
changeset
|
243 |
this.overlay.get('contentBox').one(".icomment-body").addClass('displaynone') ; |
| 341 | 244 |
}, |
245 |
showContent:function() { |
|
|
600
fda73ac53450
Use YUI 3.10 (now that conflict with ASCIIMathML is solved).
gibus
parents:
532
diff
changeset
|
246 |
this.overlay.get('contentBox').one(".icomment-header").removeClass('displaynone') ; |
|
fda73ac53450
Use YUI 3.10 (now that conflict with ASCIIMathML is solved).
gibus
parents:
532
diff
changeset
|
247 |
this.overlay.get('contentBox').one(".icomment-body").removeClass('displaynone') ; |
| 341 | 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() { |
|
|
600
fda73ac53450
Use YUI 3.10 (now that conflict with ASCIIMathML is solved).
gibus
parents:
532
diff
changeset
|
257 |
this.overlay.get('contentBox').one(".c-readreplies").removeClass('displaynone') ; |
| 341 | 258 |
}, |
259 |
hideReadRepliesLnk:function() { |
|
|
600
fda73ac53450
Use YUI 3.10 (now that conflict with ASCIIMathML is solved).
gibus
parents:
532
diff
changeset
|
260 |
this.overlay.get('contentBox').one(".c-readreplies").addClass('displaynone') ; |
| 341 | 261 |
}, |
262 |
changeModeration:function(comment) { |
|
|
600
fda73ac53450
Use YUI 3.10 (now that conflict with ASCIIMathML is solved).
gibus
parents:
532
diff
changeset
|
263 |
var moderationLnk = this.overlay.get('contentBox').one(".c-moderate") ; |
| 341 | 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 |
|
|
600
fda73ac53450
Use YUI 3.10 (now that conflict with ASCIIMathML is solved).
gibus
parents:
532
diff
changeset
|
271 |
this.overlay.get('contentBox').one(".c-iactions").removeClass("displaynone") ; |
|
fda73ac53450
Use YUI 3.10 (now that conflict with ASCIIMathML is solved).
gibus
parents:
532
diff
changeset
|
272 |
this.overlay.get('contentBox').one(".c-state-actions").addClass("displaynone") ; |
| 341 | 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) ; |
|
|
600
fda73ac53450
Use YUI 3.10 (now that conflict with ASCIIMathML is solved).
gibus
parents:
532
diff
changeset
|
312 |
var prevTitleNode = boundingBoxNode.one(".c-header") ; |
| 341 | 313 |
if (prevTitleNode == null) // first time, no title yet |
|
600
fda73ac53450
Use YUI 3.10 (now that conflict with ASCIIMathML is solved).
gibus
parents:
532
diff
changeset
|
314 |
boundingBoxNode.one('.icomment-header').insertBefore(newTitleNode, boundingBoxNode.one('.c-iactions')) ; |
| 341 | 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>') ; |
|
|
600
fda73ac53450
Use YUI 3.10 (now that conflict with ASCIIMathML is solved).
gibus
parents:
532
diff
changeset
|
320 |
var prevTagNode = boundingBoxNode.one(".c-tags") ; |
| 341 | 321 |
if (prevTagNode == null) |
|
600
fda73ac53450
Use YUI 3.10 (now that conflict with ASCIIMathML is solved).
gibus
parents:
532
diff
changeset
|
322 |
boundingBoxNode.one('.icomment-header').appendChild(newTagNode) ; |
| 341 | 323 |
else |
324 |
prevTagNode.get('parentNode').replaceChild(newTagNode, prevTagNode) ; |
|
325 |
// NO TAG ? |
|
326 |
if (comment.tags == "") |
|
327 |
newTagNode.addClass('displaynone') ; |
|
| 0 | 328 |
|
|
504
b2e0186daa5b
Adds a category to comments, painted with colored vertical bar.
gibus
parents:
410
diff
changeset
|
329 |
// CATEGORY |
|
b2e0186daa5b
Adds a category to comments, painted with colored vertical bar.
gibus
parents:
410
diff
changeset
|
330 |
var newCatNode = CY.Node.create('<div class="c-cat">' + gettext("category") + ': <span class="c-cat-val c-cat-' + comment.category + '">' + categories[comment.category] + '</span></div>') ; |
|
600
fda73ac53450
Use YUI 3.10 (now that conflict with ASCIIMathML is solved).
gibus
parents:
532
diff
changeset
|
331 |
var prevCatNode = boundingBoxNode.one(".c-cat") ; |
|
504
b2e0186daa5b
Adds a category to comments, painted with colored vertical bar.
gibus
parents:
410
diff
changeset
|
332 |
if (prevCatNode == null) |
|
600
fda73ac53450
Use YUI 3.10 (now that conflict with ASCIIMathML is solved).
gibus
parents:
532
diff
changeset
|
333 |
boundingBoxNode.one('.icomment-header').appendChild(newCatNode) ; |
|
504
b2e0186daa5b
Adds a category to comments, painted with colored vertical bar.
gibus
parents:
410
diff
changeset
|
334 |
else |
|
b2e0186daa5b
Adds a category to comments, painted with colored vertical bar.
gibus
parents:
410
diff
changeset
|
335 |
prevCatNode.get('parentNode').replaceChild(newCatNode, prevCatNode) ; |
|
b2e0186daa5b
Adds a category to comments, painted with colored vertical bar.
gibus
parents:
410
diff
changeset
|
336 |
// NO CATEGORY ? |
|
b2e0186daa5b
Adds a category to comments, painted with colored vertical bar.
gibus
parents:
410
diff
changeset
|
337 |
if (comment.category == 0) |
|
b2e0186daa5b
Adds a category to comments, painted with colored vertical bar.
gibus
parents:
410
diff
changeset
|
338 |
newCatNode.addClass('displaynone') ; |
|
b2e0186daa5b
Adds a category to comments, painted with colored vertical bar.
gibus
parents:
410
diff
changeset
|
339 |
|
| 341 | 340 |
// CONTENT |
341 |
var newContentNode = CY.Node.create('<span class="c-content">' + comment.content_html + '</span>') ; |
|
|
600
fda73ac53450
Use YUI 3.10 (now that conflict with ASCIIMathML is solved).
gibus
parents:
532
diff
changeset
|
342 |
var prevContentNode = boundingBoxNode.one(".c-content") ; |
| 341 | 343 |
if (prevContentNode == null) |
|
600
fda73ac53450
Use YUI 3.10 (now that conflict with ASCIIMathML is solved).
gibus
parents:
532
diff
changeset
|
344 |
boundingBoxNode.one('.icomment-body').appendChild(newContentNode) ; |
| 341 | 345 |
else |
346 |
prevContentNode.get('parentNode').replaceChild(newContentNode, prevContentNode) ; |
|
| 0 | 347 |
|
| 341 | 348 |
// PERMALINK |
349 |
if (sv_prefix=="") { |
|
|
600
fda73ac53450
Use YUI 3.10 (now that conflict with ASCIIMathML is solved).
gibus
parents:
532
diff
changeset
|
350 |
boundingBoxNode.one(".c-permalink").set("href",sv_site_url + comment.permalink) ; |
| 341 | 351 |
} |
|
389
eecda8559c1d
Allow permalink on comments even when embedfing iframe.
gibus
parents:
341
diff
changeset
|
352 |
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
|
353 |
comment_id_delta_prefix = sv_delta != '' ? Array(parseInt(sv_delta)+1).join(',') : ''; |
|
600
fda73ac53450
Use YUI 3.10 (now that conflict with ASCIIMathML is solved).
gibus
parents:
532
diff
changeset
|
354 |
boundingBoxNode.one(".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
|
355 |
} |
| 0 | 356 |
|
| 341 | 357 |
// MODERATION |
358 |
this.changeModeration(comment) ; |
|
| 103 | 359 |
/* useless : use implemendted permanentlink instead |
360 |
* |
|
| 341 | 361 |
// also change link title to give users the possibility to know comment id (to be able to reference this exact comment in GET arguments) |
|
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
|
362 |
var moderationLnk = this.overlay.get('contentBox').query(".c-moderate") ; |
| 341 | 363 |
//var cid = (comment.reply_to_id == null) ? this.commentId : "" ; |
364 |
moderationLnk.set("title", "click to change comment ID visibility".replace(/ID/, this.commentId).replace(/ /, " ")) ; |
|
365 |
|
|
366 |
*/ |
|
367 |
// open links in new window : |
|
|
600
fda73ac53450
Use YUI 3.10 (now that conflict with ASCIIMathML is solved).
gibus
parents:
532
diff
changeset
|
368 |
var links = boundingBoxNode.all(".c-content a") ; |
| 341 | 369 |
if (links != null) |
370 |
links.setAttribute( "target" , "_blank" ) ; |
|
|
600
fda73ac53450
Use YUI 3.10 (now that conflict with ASCIIMathML is solved).
gibus
parents:
532
diff
changeset
|
371 |
links = boundingBoxNode.all(".c-header-title a") ; |
| 341 | 372 |
if (links != null) |
373 |
links.setAttribute( "target" , "_blank" ) ; |
|
374 |
|
|
375 |
this.permAdapt(comment) ; |
|
376 |
}, |
|
| 0 | 377 |
|
| 341 | 378 |
permAdapt : function(comment) { |
379 |
// this comment permissions |
|
|
600
fda73ac53450
Use YUI 3.10 (now that conflict with ASCIIMathML is solved).
gibus
parents:
532
diff
changeset
|
380 |
var delLnk = this.overlay.get('contentBox').one(".c-delete") ; |
| 341 | 381 |
if (delLnk) { // there will be a server side check anyway |
382 |
if (!comment.can_delete) |
|
383 |
delLnk.addClass('displaynone') ; |
|
384 |
else |
|
385 |
delLnk.removeClass('displaynone') ; |
|
386 |
} |
|
| 0 | 387 |
|
|
600
fda73ac53450
Use YUI 3.10 (now that conflict with ASCIIMathML is solved).
gibus
parents:
532
diff
changeset
|
388 |
var editLnk = this.overlay.get('contentBox').one(".c-edit") ; |
| 341 | 389 |
if (editLnk) { |
390 |
if (!comment.can_edit) |
|
391 |
editLnk.addClass('displaynone') ; |
|
392 |
else |
|
393 |
editLnk.removeClass('displaynone') ; |
|
394 |
} |
|
395 |
|
|
|
600
fda73ac53450
Use YUI 3.10 (now that conflict with ASCIIMathML is solved).
gibus
parents:
532
diff
changeset
|
396 |
var replyLnk = this.overlay.get('contentBox').one(".c-reply") ; |
| 341 | 397 |
if (replyLnk) { |
398 |
if (!hasPerm("can_create_comment")) |
|
399 |
replyLnk.addClass('displaynone') ; |
|
400 |
else |
|
401 |
replyLnk.removeClass('displaynone') ; |
|
402 |
} |
|
| 0 | 403 |
|
|
600
fda73ac53450
Use YUI 3.10 (now that conflict with ASCIIMathML is solved).
gibus
parents:
532
diff
changeset
|
404 |
var moderateLnk = this.overlay.get('contentBox').one(".c-moderate") ; |
| 341 | 405 |
if (moderateLnk) { |
406 |
if (!comment.can_moderate) |
|
407 |
moderateLnk.addClass('displaynone') ; |
|
408 |
else |
|
409 |
moderateLnk.removeClass('displaynone') ; |
|
410 |
} |
|
411 |
}, |
|
412 |
setThreadPad : function(pad) { // TODO review ... |
|
|
600
fda73ac53450
Use YUI 3.10 (now that conflict with ASCIIMathML is solved).
gibus
parents:
532
diff
changeset
|
413 |
this.overlay.get('contentBox').one('.yui-widget-hd').setStyle('paddingLeft', pad + 'px') ; |
|
fda73ac53450
Use YUI 3.10 (now that conflict with ASCIIMathML is solved).
gibus
parents:
532
diff
changeset
|
414 |
this.overlay.get('contentBox').one('.yui-widget-bd').setStyle('paddingLeft', pad + 'px') ; |
| 341 | 415 |
|
416 |
}, |
|
417 |
setPosition : function(xy) { |
|
418 |
var boundingBoxNode = this.overlay.get('boundingBox') ; |
|
| 0 | 419 |
|
| 341 | 420 |
boundingBoxNode.setStyle("opacity", 1); // TODO check this is still usefull |
421 |
boundingBoxNode.setXY(xy) ; |
|
422 |
}, |
|
423 |
getPosition : function(xy) { |
|
424 |
var boundingBoxNode = this.overlay.get('boundingBox') ; |
|
| 0 | 425 |
|
| 341 | 426 |
return boundingBoxNode.getXY() ; |
427 |
}, |
|
428 |
onAnimationEnd : function() { |
|
429 |
if (!CY.Lang.isUndefined(this['animation-handle']) && !CY.Lang.isNull(this['animation-handle'])) { |
|
430 |
this['animation-handle'].detach() ; |
|
431 |
this['animation-handle'] = null ; |
|
432 |
// CY.log('detached...') ; |
|
433 |
} |
|
434 |
gIComments.signalAnimationEnd() ; |
|
435 |
if (gIComments.animationsEnded()) |
|
436 |
gIComments.whenAnimationsEnd() ; |
|
437 |
}, |
|
438 |
onAnimationEndFocus : function() { |
|
439 |
if (!CY.Lang.isUndefined(this['animation-handle']) && !CY.Lang.isNull(this['animation-handle'])) { |
|
440 |
this['animation-handle'].detach() ; |
|
441 |
this['animation-handle'] = null ; |
|
442 |
// CY.log('detached...') ; |
|
443 |
} |
|
444 |
gIComments.signalAnimationEnd() ; |
|
445 |
if (gIComments.animationsEnded()) |
|
446 |
gIComments.whenAnimationsEndFocus() ; |
|
447 |
}, |
|
448 |
onAnimationEndReply : function() { |
|
449 |
if (!CY.Lang.isUndefined(this['animation-handle']) && !CY.Lang.isNull(this['animation-handle'])) { |
|
450 |
this['animation-handle'].detach() ; |
|
451 |
this['animation-handle'] = null ; |
|
452 |
// CY.log('detached...') ; |
|
453 |
} |
|
454 |
gIComments.signalAnimationEnd() ; |
|
455 |
if (gIComments.animationsEnded()) |
|
456 |
gIComments.whenAnimationsEndReply() ; |
|
457 |
}, |
|
| 0 | 458 |
|
| 341 | 459 |
//aa = new CY.Anim({node:gIComments._c[0].overlay.get('boundingBox'), to:{xy : [0,0]}, duration:2.0}) |
460 |
setAnimationToPosition : function(toXY, focus, reply) { |
|
461 |
var boundingBoxNode = this.overlay.get('boundingBox') ; |
|
462 |
|
|
463 |
// ANIMATION |
|
464 |
// 2 lines of optim that could be removed (0.011) |
|
465 |
if (gPrefs.get('general','animduration') < 0.011) |
|
466 |
boundingBoxNode.setXY(toXY) ; |
|
467 |
|
|
468 |
this.animation.set('to', { xy: toXY}); |
|
469 |
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
|
470 |
if (focus) |
|
337
614669e0e313
Add url parameter (comment_op=reply) to open automatically reply to comment form
gibus
parents:
330
diff
changeset
|
471 |
if (reply) |
| 341 | 472 |
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
|
473 |
else |
| 341 | 474 |
this['animation-handle'] = this.animation.on('end', this.onAnimationEndFocus, this); |
| 330 | 475 |
else |
| 341 | 476 |
this['animation-handle'] = this.animation.on('end', this.onAnimationEnd, this); |
477 |
|
|
478 |
return this.animation ; |
|
479 |
}, |
|
480 |
getHeight : function() { |
|
481 |
return this.overlay.get('boundingBox').get('offsetHeight') ; |
|
482 |
}, |
|
483 |
scrollIntoView : function() { |
|
484 |
//this.isVisible() && |
|
485 |
if (!this.overlay.get('contentBox').inViewportRegion()) |
|
486 |
this.overlay.get('contentBox').scrollIntoView(true) ; |
|
487 |
}, |
|
488 |
_isHostingAForm : function() { |
|
489 |
return (this.isVisible() && ((gNewReplyHost != null && gNewReplyHost == this) || (gEditICommentHost != null && gEditICommentHost == this))); |
|
490 |
} |
|
| 0 | 491 |
|
492 |
} |