| author | gibus |
| Wed, 11 Sep 2013 23:13:01 +0200 | |
| changeset 532 | 0bad3613f59d |
| parent 525 | 89ef5ed3c48b |
| child 552 | ee0c833d1969 |
| permissions | -rw-r--r-- |
| 0 | 1 |
gEditICommentHost = null ; |
2 |
gEdit = null ; |
|
3 |
||
4 |
dbgc = null ; |
|
5 |
showEditForm = function(iCommentHost) { |
|
| 341 | 6 |
|
7 |
if (gEdit == null) { |
|
8 |
gEdit = { |
|
9 |
'ids':{ |
|
10 |
'formId':CY.guid(), |
|
11 |
'formTitleId':CY.guid(), |
|
12 |
'nameInputId':CY.guid(), |
|
13 |
'emailInputId':CY.guid(), |
|
14 |
'titleInputId':CY.guid(), |
|
15 |
'contentInputId':CY.guid(), |
|
16 |
'tagsInputId':CY.guid(), |
|
|
504
b2e0186daa5b
Adds a category to comments, painted with colored vertical bar.
gibus
parents:
341
diff
changeset
|
17 |
'categoryInputId':CY.guid(), |
| 341 | 18 |
'formatInputId':CY.guid(), |
19 |
'startWrapperInputId':CY.guid(), |
|
20 |
'endWrapperInputId':CY.guid(), |
|
21 |
'startOffsetInputId':CY.guid(), |
|
22 |
'endOffsetInputId':CY.guid(), |
|
23 |
'changeScopeInputId':CY.guid(), |
|
24 |
'changeScopeInputWrapper':CY.guid(), |
|
25 |
'selectionPlaceId':CY.guid(), |
|
26 |
'keyId':CY.guid(), |
|
27 |
'editCommentId':CY.guid(), |
|
28 |
'currentSelId':CY.guid(), |
|
29 |
'currentSelIdI':CY.guid(), |
|
30 |
'addBtnId':CY.guid(), |
|
31 |
'cancelBtnId':CY.guid() |
|
32 |
}, |
|
33 |
'handlers':{} |
|
34 |
} ; |
|
35 |
} |
|
36 |
|
|
37 |
gEditICommentHost = iCommentHost ; |
|
| 0 | 38 |
|
| 341 | 39 |
gEditICommentHost.hideContent() ; |
| 0 | 40 |
|
| 341 | 41 |
// FORM HTML |
42 |
var overlayHtml = getHtml(gEdit['ids']) ; |
|
43 |
var editHeader = '<div class="icomment-edit-header">' + overlayHtml['headerContent'] + '</div>' ; |
|
44 |
var editBody = '<div class="icomment-edit-body">' + overlayHtml['bodyContent'] + '</div>' ; |
|
45 |
|
|
46 |
// cf. http://yuilibrary.com/projects/yui3/ticket/2528319 |
|
47 |
gEditICommentHost['overlay'].setStdModContent(CY.WidgetStdMod.HEADER,CY.Node.create(editHeader),CY.WidgetStdMod.AFTER); |
|
48 |
gEditICommentHost['overlay'].setStdModContent(CY.WidgetStdMod.BODY,CY.Node.create(editBody),CY.WidgetStdMod.AFTER); |
|
49 |
|
|
50 |
// FORM TITLE |
|
|
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
|
51 |
CY.get("#"+gEdit['ids']['formTitleId']).set('innerHTML', gettext("Edit comment")) ; |
| 0 | 52 |
|
53 |
// FETCH FORM VALUES FROM COMMENT |
|
| 341 | 54 |
|
55 |
var comment = gDb.getComment(gEditICommentHost.commentId) ; |
|
|
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 |
CY.get("#"+gEdit['ids']['editCommentId']).set('value', comment.id) ; |
|
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 |
CY.get("#"+gEdit['ids']['keyId']).set('value', comment.key) ; |
| 0 | 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 |
CY.get("#"+gEdit['ids']['changeScopeInputId']+" input").set('checked', false) ; |
|
504
b2e0186daa5b
Adds a category to comments, painted with colored vertical bar.
gibus
parents:
341
diff
changeset
|
60 |
// Edit scope and category just for the first comment in a thread |
|
b2e0186daa5b
Adds a category to comments, painted with colored vertical bar.
gibus
parents:
341
diff
changeset
|
61 |
// => hides these inputs for a reply. |
|
b2e0186daa5b
Adds a category to comments, painted with colored vertical bar.
gibus
parents:
341
diff
changeset
|
62 |
if (comment.reply_to_id != null) { |
|
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 |
CY.get("#"+gEdit['ids']['changeScopeInputId']).addClass('displaynone') |
|
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 |
CY.get("#"+gEdit['ids']['categoryInputId']).addClass('displaynone') |
|
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
|
65 |
CY.get("#"+gEdit['ids']['categoryInputId']).ancestor().addClass('displaynone') |
|
504
b2e0186daa5b
Adds a category to comments, painted with colored vertical bar.
gibus
parents:
341
diff
changeset
|
66 |
} |
| 341 | 67 |
changeScopeFormClick() ; // to adapt |
| 0 | 68 |
|
|
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
|
69 |
CY.get("#"+gEdit['ids']['nameInputId']).set('value', comment.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
|
70 |
CY.get("#"+gEdit['ids']['emailInputId']).set('value', comment.email) ; |
| 0 | 71 |
|
| 341 | 72 |
if (comment.logged_author) { |
|
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("#"+gEdit['ids']['nameInputId']).setAttribute("disabled", true); |
|
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
|
74 |
CY.get("#"+gEdit['ids']['emailInputId']).setAttribute("disabled", true); |
| 341 | 75 |
} |
76 |
|
|
| 0 | 77 |
// FORM VALUES |
|
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 |
CY.get("#"+gEdit['ids']['titleInputId']).set('value', comment['title']) ; |
|
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
|
79 |
CY.get("#"+gEdit['ids']['contentInputId']).set('value', comment['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
|
80 |
CY.get("#"+gEdit['ids']['tagsInputId']).set('value', comment['tags']) ; |
|
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
|
81 |
if ( CY.get("#"+gEdit['ids']['categoryInputId'])) |
|
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
|
82 |
CY.get("#"+gEdit['ids']['categoryInputId']).set('value', comment['category']) ; |
| 341 | 83 |
|
|
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
|
84 |
CY.get("#"+gEdit['ids']['formatInputId']).set('value',gConf['defaultCommentFormat']) ;// for now ... |
| 341 | 85 |
|
86 |
// WIDTH |
|
87 |
var width = gLayout.getTopICommentsWidth() ; |
|
88 |
changeFormFieldsWidth(gEdit['ids']['formId'], width) ; |
|
89 |
|
|
| 0 | 90 |
// ATTACH EVENT HANDLERS |
| 341 | 91 |
gEdit['handlers']['addBtnId'] = CY.on("click", onEditSaveClick, "#"+gEdit['ids']['addBtnId']); |
92 |
gEdit['handlers']['cancelBtnId'] = CY.on("click", onEditCancelClick, "#"+gEdit['ids']['cancelBtnId']); |
|
93 |
gEdit['handlers']['changeScope'] = CY.on("click", onChangeScopeClick, "#"+gEdit['ids']['changeScopeInputId']); |
|
94 |
|
|
| 0 | 95 |
} |
96 |
onEditSaveClick = function(iCommentHost) { |
|
| 341 | 97 |
if (readyForAction()) |
98 |
gSync.editComment() ; |
|
| 0 | 99 |
} |
100 |
onEditCancelClick = function(iCommentHost) { |
|
| 341 | 101 |
if (readyForAction()) |
102 |
gSync.cancelEdit() ; |
|
| 0 | 103 |
} |
104 |
onChangeScopeClick = function() { |
|
| 341 | 105 |
if (readyForAction()) |
106 |
gSync.changeScopeFormClick() ; |
|
107 |
else {// (onChangeScopeClick triggers an animation : checking for readyForAction does not prevent the checkbox change ...) |
|
|
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
|
108 |
var chckCtrl = CY.get("#"+gEdit['ids']['changeScopeInputId']+" input") ; |
| 341 | 109 |
var chck = chckCtrl.get('checked') ; |
110 |
chckCtrl.set('checked', !chck) ; // set it back |
|
111 |
} |
|
| 0 | 112 |
} |
113 |
changeScopeFormClick = function() { |
|
|
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 node = CY.get("#"+gEdit['ids']['currentSelId']) ; |
|
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
|
115 |
if (CY.get("#"+gEdit['ids']['changeScopeInputId']+" input").get('checked')) |
| 341 | 116 |
node.removeClass('displaynone') ; |
117 |
else |
|
118 |
node.addClass('displaynone') ; |
|
| 0 | 119 |
} |
120 |
cancelEditForm = function() { |
|
| 341 | 121 |
if (gEditICommentHost != null) { |
| 0 | 122 |
// DETACH EVENT HANDLERS |
| 341 | 123 |
for (var id in gEdit['handlers']) { |
124 |
if (gEdit['handlers'][id] != null) { |
|
125 |
gEdit['handlers'][id].detach() ; |
|
126 |
gEdit['handlers'][id] = null ; |
|
127 |
} |
|
128 |
} |
|
| 0 | 129 |
|
130 |
// REMOVE EDIT FORM NODES FROM ICOMMENT OVERLAY |
|
|
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
|
131 |
var node = gEditICommentHost['overlay'].get('contentBox').query(".icomment-edit-body") ; |
| 341 | 132 |
node.get('parentNode').removeChild(node) ; |
|
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
|
133 |
node = gEditICommentHost['overlay'].get('contentBox').query(".icomment-edit-header") ; |
| 341 | 134 |
node.get('parentNode').removeChild(node) ; |
| 0 | 135 |
|
136 |
// SHOW ICOMMENT OVERLAY |
|
| 341 | 137 |
gEditICommentHost.showContent() ; |
138 |
|
|
139 |
gEditICommentHost = null ; |
|
140 |
} |
|
| 0 | 141 |
} |