| author | gibus |
| Wed, 11 Sep 2013 23:13:01 +0200 | |
| changeset 532 | 0bad3613f59d |
| parent 525 | 89ef5ed3c48b |
| child 600 | fda73ac53450 |
| permissions | -rw-r--r-- |
| 0 | 1 |
gNewReplyHost = null ; |
2 |
gNewReply = null |
|
3 |
||
4 |
instanciateNewReplyForm = function(iCommentToAppendTo) { |
|
| 341 | 5 |
|
6 |
if (gNewReply == null) { |
|
7 |
gNewReply = { |
|
8 |
'val': { |
|
9 |
'name':gPrefs.get('user','name'), |
|
10 |
'email':gPrefs.get('user','email'), |
|
11 |
'title':'', |
|
12 |
'content':'', |
|
13 |
'tags':''}, |
|
14 |
'ids': { |
|
15 |
'name':gPrefs.get('user','name'), |
|
16 |
'email':gPrefs.get('user','email'), |
|
17 |
'title':'', |
|
18 |
'content':'', |
|
19 |
'tags':'', |
|
20 |
'formId':CY.guid(), |
|
21 |
'nameInputId':CY.guid(), |
|
22 |
'emailInputId':CY.guid(), |
|
23 |
'titleInputId':CY.guid(), |
|
24 |
'contentInputId':CY.guid(), |
|
25 |
'keyInputId':CY.guid(), |
|
26 |
'formatInputId':CY.guid(), |
|
27 |
'tagsInputId':CY.guid(), |
|
28 |
'parentCommentId':CY.guid(), |
|
29 |
'addBtnId':CY.guid(), |
|
30 |
'cancelBtnId':CY.guid()}, |
|
31 |
'handlers':{} |
|
32 |
} ; |
|
33 |
} |
|
| 0 | 34 |
|
| 341 | 35 |
gNewReplyHost = iCommentToAppendTo ; |
| 0 | 36 |
|
| 341 | 37 |
var headerHtml = '<hr/><center><div class="c-header-title">' + gettext('New reply') + '</div></center>' ; |
38 |
var html = gFormHtml['formStart'].replace('###', gNewReply['ids']['formId']) ; |
|
39 |
if (!sv_loggedIn) { |
|
40 |
html = html + gFormHtml['nameInput'].replace('###', gNewReply['ids']['nameInputId']) + gFormHtml['emailInput'].replace('###', gNewReply['ids']['emailInputId']) ; |
|
41 |
} |
|
42 |
html = html + gFormHtml['titleInput'].replace('###', gNewReply['ids']['titleInputId']) + gFormHtml['contentInput'].replace('###', gNewReply['ids']['contentInputId']) + gFormHtml['tagsInput'].replace('###', gNewReply['ids']['tagsInputId']); |
|
43 |
html = html + gFormHtml['hidden'].replace('###', gNewReply['ids']['keyInputId']).replace('???', 'comment_key') ; |
|
44 |
html = html + gFormHtml['hidden'].replace('###', gNewReply['ids']['formatInputId']).replace('???', 'format') ; |
|
45 |
html = html + gFormHtml['hidden'].replace('###', gNewReply['ids']['parentCommentId']).replace('???', 'reply_to_id') ; |
|
46 |
var btnsHtml = gFormHtml['btns'].replace('###', gNewReply['ids']['addBtnId']).replace('???', gNewReply['ids']['cancelBtnId']) ; |
|
47 |
|
|
48 |
gNewReplyHost['overlay'].setStdModContent(CY.WidgetStdMod.FOOTER, headerHtml + html + btnsHtml) ; |
|
49 |
var replyNode = gNewReplyHost['overlay'].getStdModNode(CY.WidgetStdMod.FOOTER) ; |
|
| 0 | 50 |
|
| 341 | 51 |
var comment = gDb.getComment(iCommentToAppendTo.commentId) ; |
52 |
var REPLYPREF = "Re: " ; |
|
53 |
var newReplyTitle = (gNewReply['val']['title'] == "" || gNewReply['val']['title'].substring(0, REPLYPREF.length) == REPLYPREF) ? REPLYPREF + comment['title'] : gNewReply['val']['title'] ; |
|
| 0 | 54 |
|
| 341 | 55 |
if (!sv_loggedIn) { |
|
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
|
56 |
replyNode.query('.n_name').set('value', gNewReply['val']['name']) ; |
|
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
|
57 |
replyNode.query('.n_email').set('value', gNewReply['val']['email']) ; |
| 341 | 58 |
} |
|
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
|
59 |
replyNode.query('.n_title').set('value', newReplyTitle) ; |
|
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
|
60 |
replyNode.query('.n_content').set('value', gNewReply['val']['content']) ; |
|
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
|
61 |
replyNode.query('.n_tags').set('value', gNewReply['val']['tags']) ; |
| 341 | 62 |
|
|
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
|
63 |
replyNode.query('#'+gNewReply['ids']['parentCommentId']).set('value', iCommentToAppendTo['commentId']) ; |
|
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
|
64 |
replyNode.query('#'+gNewReply['ids']['formatInputId']).set('value', gConf['defaultCommentFormat']) ; |
| 341 | 65 |
|
|
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
|
66 |
gNewReplyHost['overlay'].get('contentBox').query(".c-reply").addClass('displaynone') ; |
| 0 | 67 |
|
| 341 | 68 |
gNewReply['handlers']['addBtnId'] = CY.on("click", onAddNewReplyClick, "#"+gNewReply['ids']['addBtnId']); |
69 |
gNewReply['handlers']['cancelBtnId'] = CY.on("click", onCancelNewReplyClick, "#"+gNewReply['ids']['cancelBtnId']); |
|
70 |
|
|
71 |
var width = gLayout.getTopICommentsWidth() ; |
|
72 |
changeFormFieldsWidth(gNewReply['ids']['formId'], width) ; |
|
|
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
|
73 |
CY.get("#"+gNewReply['ids']['contentInputId']).focus(); |
| 0 | 74 |
} |
75 |
cleanNewReplyForm = function() { |
|
| 341 | 76 |
if (gNewReplyHost != null) { |
77 |
var replyNode = gNewReplyHost['overlay'].getStdModNode(CY.WidgetStdMod.FOOTER) ; |
|
|
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
|
78 |
replyNode.queryAll('.comment_input').set('value','') ; |
| 341 | 79 |
} |
| 0 | 80 |
} |
81 |
cancelNewReplyForm = function() { |
|
| 341 | 82 |
if (gNewReplyHost != null) { |
83 |
|
|
84 |
// DETACH EVENT HANDLERS |
|
85 |
for (var id in gNewReply['handlers']) { |
|
86 |
if (gNewReply['handlers'][id] != null) { |
|
87 |
gNewReply['handlers'][id].detach() ; |
|
88 |
gNewReply['handlers'][id] = null ; |
|
89 |
} |
|
90 |
} |
|
| 0 | 91 |
|
|
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
|
92 |
gNewReplyHost['overlay'].get('contentBox').query(".c-reply").removeClass('displaynone') ; |
| 341 | 93 |
|
94 |
var footer = gNewReplyHost['overlay'].getStdModNode(CY.WidgetStdMod.FOOTER) ; |
|
95 |
if (!sv_loggedIn) { |
|
|
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
|
96 |
gNewReply['val']['name'] = footer.query('.n_name').get('value') ; |
|
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
|
97 |
gNewReply['val']['email'] = footer.query('.n_email').get('value') ; |
| 341 | 98 |
} |
|
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
|
99 |
gNewReply['val']['title'] = footer.query('.n_title').get('value') ; |
|
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
|
100 |
gNewReply['val']['content'] = footer.query('.n_content').get('value') ; |
|
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
|
101 |
gNewReply['val']['tags'] = footer.query('.n_tags').get('value') ; |
| 341 | 102 |
|
103 |
footer.set('innerHTML', '') ; |
|
104 |
|
|
105 |
gNewReplyHost = null ; |
|
106 |
} |
|
| 0 | 107 |
} |
108 |
// event triggered |
|
109 |
onAddNewReplyClick = function() { |
|
| 341 | 110 |
if (!sv_loggedIn) { |
|
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
|
111 |
var name = CY.get("#"+gNewReply['ids']['nameInputId']).get('value') ; |
| 341 | 112 |
gPrefs.persist("user", "name", name) ; |
113 |
|
|
|
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
|
114 |
var email = CY.get("#"+gNewReply['ids']['emailInputId']).get('value') ; |
| 341 | 115 |
gPrefs.persist("user", "email", email) ; |
116 |
} |
|
117 |
|
|
118 |
gSync.saveComment(gNewReply['ids']['formId']) ; |
|
| 0 | 119 |
} |
120 |
onCancelNewReplyClick = function() { |
|
| 341 | 121 |
gSync.cancelReply() ; |
| 0 | 122 |
} |