| author | Production Moz <dev@sopinspace.com> |
| Wed, 04 Sep 2013 22:11:01 +0200 | |
| changeset 529 | 5eeed336b992 |
| parent 504 | b2e0186daa5b |
| permissions | -rw-r--r-- |
| 0 | 1 |
gNoSelectionYet = gettext("No selection yet") ; |
2 |
gFormHtml = { |
|
| 341 | 3 |
'formStart' :'<form id="###" onsubmit="return false;">', |
4 |
'nameInput' :gettext('Username:') + '<center><input id="###" name="name" class="n_name user_input" style="padding:1px;" type="text"></input></center>', |
|
5 |
'emailInput' :gettext('E-mail address:') + '<center><input id="###" name="email" class="n_email user_input" style="padding:1px;" type="text"></input></center>', |
|
6 |
'titleInput' :gettext('Title:') + '<center><input id="###" name="title" class="n_title comment_input" style="padding:1px;" type="text"></input></center>', |
|
7 |
'contentInput' :gettext("Content:") + '<center><textarea id="###" name="content" class="n_content comment_input" rows="10" style="padding:1px;"></textarea></center>', |
|
8 |
'tagsInput' :gettext("Tag:") + '<center><input id="###" name="tags" class="n_tags comment_input" style="padding:1px;" type="text"></input></center>', |
|
9 |
'hidden' :'<input id="###" class="comment_input" name="???" type="hidden" value=""></input>', |
|
10 |
'formEnd' :'</form>', |
|
11 |
'changeScope' :'<div id="###">' + gettext("Modify comment's scope:") + '<input type="checkbox" name="change_scope"></input></div>', |
|
12 |
'headerTitle' :'<center><div id="###" class="c-header-title"></div></center>', |
|
13 |
'currentSel' :'<div id="###">' + gettext('Comment will apply to this selection:') + '<br/><div class="current_sel"><div id="???" class="current_sel_ins">' + gNoSelectionYet + '</div></div>#hiddeninput#</div>', |
|
14 |
'btns' :'<center><input id="###" type="button" value="' + gettext('Save') + '" /><input id="???" type="button" value="' + gettext('Cancel') + '" /></center>', |
|
15 |
'closeIcon' :'<a id="###" class="c-close" title="' + gettext('close') + '"><em> </em></a>' |
|
16 |
} ; |
|
| 0 | 17 |
|
18 |
// returns {'headerContent':headerHtml, 'bodyContent':bodyHtml} |
|
19 |
getHtml = function(ids) { |
|
| 341 | 20 |
ret = {} ; |
21 |
ret['headerContent'] = '' ; |
|
22 |
|
|
23 |
if ('closeBtnId' in ids) |
|
24 |
ret['headerContent'] += gFormHtml['closeIcon'].replace('###', ids['closeBtnId']) ; |
|
25 |
|
|
26 |
ret['headerContent'] += gFormHtml['headerTitle'].replace('###', ids['formTitleId']) ; |
|
| 0 | 27 |
|
| 341 | 28 |
var selEditChkBoxHtml = "" ; |
29 |
if ('changeScopeInputId' in ids) |
|
30 |
selEditChkBoxHtml = gFormHtml['changeScope'].replace('###', ids['changeScopeInputId']) ; |
|
31 |
|
|
32 |
var hiddenInput = '<center>'+gFormHtml['hidden'].replace('###', ids['selectionPlaceId']).replace('???', 'selection_place')+'</center>' ; |
|
33 |
var selectionTitleHtml = gFormHtml['currentSel'].replace('###', ids['currentSelId']).replace('???', ids['currentSelIdI']).replace('#hiddeninput#', hiddenInput) ; |
|
34 |
|
|
35 |
var btnsHtml = gFormHtml['btns'].replace('###', ids['addBtnId']).replace('???', ids['cancelBtnId']) ; |
|
36 |
|
|
37 |
var html = gFormHtml['formStart'].replace('###', ids['formId']) + selEditChkBoxHtml + selectionTitleHtml ; |
|
38 |
|
|
39 |
if ('nameInputId' in ids) |
|
40 |
html = html + gFormHtml['nameInput'].replace('###', ids['nameInputId']) ; |
|
41 |
if ('emailInputId' in ids) |
|
42 |
html = html + gFormHtml['emailInput'].replace('###', ids['emailInputId']) ; |
|
43 |
|
|
|
504
b2e0186daa5b
Adds a category to comments, painted with colored vertical bar.
gibus
parents:
341
diff
changeset
|
44 |
html = html + gFormHtml['titleInput'].replace('###', ids['titleInputId']) + gFormHtml['contentInput'].replace('###', ids['contentInputId']); |
|
b2e0186daa5b
Adds a category to comments, painted with colored vertical bar.
gibus
parents:
341
diff
changeset
|
45 |
|
|
b2e0186daa5b
Adds a category to comments, painted with colored vertical bar.
gibus
parents:
341
diff
changeset
|
46 |
categories = CY.JSON.parse(sv_categories); |
|
b2e0186daa5b
Adds a category to comments, painted with colored vertical bar.
gibus
parents:
341
diff
changeset
|
47 |
if (categories.hasOwnProperty('0')) { |
|
b2e0186daa5b
Adds a category to comments, painted with colored vertical bar.
gibus
parents:
341
diff
changeset
|
48 |
category_options = ''; |
|
b2e0186daa5b
Adds a category to comments, painted with colored vertical bar.
gibus
parents:
341
diff
changeset
|
49 |
for (c in categories) { |
|
b2e0186daa5b
Adds a category to comments, painted with colored vertical bar.
gibus
parents:
341
diff
changeset
|
50 |
category_options += '<option value="' + c + '">' + categories[c] + '</option>'; |
|
b2e0186daa5b
Adds a category to comments, painted with colored vertical bar.
gibus
parents:
341
diff
changeset
|
51 |
} |
|
b2e0186daa5b
Adds a category to comments, painted with colored vertical bar.
gibus
parents:
341
diff
changeset
|
52 |
gFormHtml['categoryInput'] = gettext("Category:") + ' <select id="###" name="category" class="n_category comment_input" style="padding:1px;" type="text">' + category_options + '</select>'; |
|
b2e0186daa5b
Adds a category to comments, painted with colored vertical bar.
gibus
parents:
341
diff
changeset
|
53 |
html = html + '<span class="n_category_input">' + gFormHtml['categoryInput'].replace('###', ids['categoryInputId']) + '<br /></span>'; |
|
b2e0186daa5b
Adds a category to comments, painted with colored vertical bar.
gibus
parents:
341
diff
changeset
|
54 |
} |
|
b2e0186daa5b
Adds a category to comments, painted with colored vertical bar.
gibus
parents:
341
diff
changeset
|
55 |
|
|
b2e0186daa5b
Adds a category to comments, painted with colored vertical bar.
gibus
parents:
341
diff
changeset
|
56 |
html = html + gFormHtml['tagsInput'].replace('###', ids['tagsInputId']); |
|
b2e0186daa5b
Adds a category to comments, painted with colored vertical bar.
gibus
parents:
341
diff
changeset
|
57 |
|
| 341 | 58 |
html = html + gFormHtml['hidden'].replace('###', ids['formatInputId']).replace('???', 'format') ; |
59 |
html = html + gFormHtml['hidden'].replace('###', ids['startWrapperInputId']).replace('???', 'start_wrapper') ; |
|
60 |
html = html + gFormHtml['hidden'].replace('###', ids['endWrapperInputId']).replace('???', 'end_wrapper') ; |
|
61 |
html = html + gFormHtml['hidden'].replace('###', ids['startOffsetInputId']).replace('???', 'start_offset') ; |
|
62 |
html = html + gFormHtml['hidden'].replace('###', ids['endOffsetInputId']).replace('???', 'end_offset') ; |
|
63 |
html = html + gFormHtml['hidden'].replace('###', ids['keyId']).replace('???', 'comment_key') ; |
|
64 |
html = html + gFormHtml['hidden'].replace('###', ids['editCommentId']).replace('???', 'edit_comment_id') ; |
|
65 |
html = html + btnsHtml + gFormHtml['formEnd'] ; |
|
66 |
ret['bodyContent'] = html ; |
|
67 |
return ret ; |
|
| 0 | 68 |
} ; |
69 |
||
70 |
changeFormFieldsWidth = function(formId, val) { |
|
| 341 | 71 |
var fieldWidth = (val - 20) +'px' ; |
72 |
var elts = CY.all("#" + formId + " input[type='text']") ; |
|
73 |
if (elts != null) |
|
74 |
elts.setStyle("width", fieldWidth) ; |
|
75 |
elts = CY.all("#" + formId + " textarea") ; |
|
76 |
if (elts != null) |
|
77 |
elts.setStyle("width", fieldWidth) ; |
|
| 0 | 78 |
} |
79 |
||
80 |
addFormErrMsg = function(formId, eltName, errorString) { |
|
| 341 | 81 |
var formElt = document.getElementById(formId) ; |
| 0 | 82 |
var i, e, s, ilen ; |
83 |
||
84 |
// Iterate over the form elements collection to construct the |
|
85 |
// label-value pairs. |
|
86 |
for (i = 0, ilen = formElt.elements.length; i < ilen; ++i) { |
|
87 |
e = formElt.elements[i]; |
|
88 |
if (e.name == eltName) { |
|
| 341 | 89 |
s = document.createElement('DIV') ; |
90 |
CY.DOM.addClass(s, 'c-error') ; |
|
91 |
s.id = e.id + '-err'; |
|
92 |
s.appendChild(document.createTextNode(errorString)) ; |
|
93 |
if (e.parentNode.nextSibling) |
|
94 |
e.parentNode.parentNode.insertBefore(s, e.parentNode.nextSibling) ; |
|
95 |
else |
|
96 |
e.parentNode.parentNode.appendChild(s) ; |
|
| 0 | 97 |
} |
98 |
||
99 |
} |
|
100 |
} |
|
101 |
||
102 |
// frames['text_view_frame'].removeFormErrMsg(frames['text_view_frame'].gICommentForm['formId']) |
|
103 |
removeFormErrMsg = function(formId) { |
|
| 341 | 104 |
var nodes = CY.all('#'+formId+' .c-error'); |
105 |
if (nodes != null) |
|
106 |
nodes.each(function (node) {node.get('parentNode').removeChild(node) ;}) ; |
|
| 0 | 107 |
} |
108 |