|
0
|
1 |
gNoSelectionYet = gettext("No selection yet") ; |
|
|
2 |
gFormHtml = { |
|
|
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 c-iclose" title="' + gettext('close') + '"><em> </em></a>' |
|
|
16 |
} ; |
|
|
17 |
|
|
|
18 |
// returns {'headerContent':headerHtml, 'bodyContent':bodyHtml} |
|
|
19 |
getHtml = function(ids) { |
|
|
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']) ; |
|
|
27 |
|
|
|
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 |
|
|
|
44 |
html = html + gFormHtml['titleInput'].replace('###', ids['titleInputId']) + gFormHtml['contentInput'].replace('###', ids['contentInputId']) + gFormHtml['tagsInput'].replace('###', ids['tagsInputId']); |
|
|
45 |
html = html + gFormHtml['hidden'].replace('###', ids['formatInputId']).replace('???', 'format') ; |
|
|
46 |
html = html + gFormHtml['hidden'].replace('###', ids['startWrapperInputId']).replace('???', 'start_wrapper') ; |
|
|
47 |
html = html + gFormHtml['hidden'].replace('###', ids['endWrapperInputId']).replace('???', 'end_wrapper') ; |
|
|
48 |
html = html + gFormHtml['hidden'].replace('###', ids['startOffsetInputId']).replace('???', 'start_offset') ; |
|
|
49 |
html = html + gFormHtml['hidden'].replace('###', ids['endOffsetInputId']).replace('???', 'end_offset') ; |
|
|
50 |
html = html + gFormHtml['hidden'].replace('###', ids['keyId']).replace('???', 'comment_key') ; |
|
|
51 |
html = html + gFormHtml['hidden'].replace('###', ids['editCommentId']).replace('???', 'edit_comment_id') ; |
|
|
52 |
html = html + btnsHtml + gFormHtml['formEnd'] ; |
|
|
53 |
ret['bodyContent'] = html ; |
|
|
54 |
return ret ; |
|
|
55 |
} ; |
|
|
56 |
|
|
|
57 |
changeFormFieldsWidth = function(formId, val) { |
|
|
58 |
var fieldWidth = (val - 20) +'px' ; |
|
|
59 |
var elts = CY.all("#" + formId + " input[type='text']") ; |
|
|
60 |
if (elts != null) |
|
|
61 |
elts.setStyle("width", fieldWidth) ; |
|
|
62 |
elts = CY.all("#" + formId + " textarea") ; |
|
|
63 |
if (elts != null) |
|
|
64 |
elts.setStyle("width", fieldWidth) ; |
|
|
65 |
} |
|
|
66 |
|
|
|
67 |
addFormErrMsg = function(formId, eltName, errorString) { |
|
|
68 |
var formElt = document.getElementById(formId) ; |
|
|
69 |
var i, e, s, ilen ; |
|
|
70 |
|
|
|
71 |
// Iterate over the form elements collection to construct the |
|
|
72 |
// label-value pairs. |
|
|
73 |
for (i = 0, ilen = formElt.elements.length; i < ilen; ++i) { |
|
|
74 |
e = formElt.elements[i]; |
|
|
75 |
if (e.name == eltName) { |
|
|
76 |
s = document.createElement('DIV') ; |
|
|
77 |
CY.DOM.addClass(s, 'c-error') ; |
|
|
78 |
s.id = e.id + '-err'; |
|
|
79 |
s.appendChild(document.createTextNode(errorString)) ; |
|
|
80 |
if (e.parentNode.nextSibling) |
|
|
81 |
e.parentNode.parentNode.insertBefore(s, e.parentNode.nextSibling) ; |
|
|
82 |
else |
|
|
83 |
e.parentNode.parentNode.appendChild(s) ; |
|
|
84 |
} |
|
|
85 |
|
|
|
86 |
} |
|
|
87 |
} |
|
|
88 |
|
|
|
89 |
// frames['text_view_frame'].removeFormErrMsg(frames['text_view_frame'].gICommentForm['formId']) |
|
|
90 |
removeFormErrMsg = function(formId) { |
|
|
91 |
var nodes = CY.all('#'+formId+' .c-error'); |
|
|
92 |
if (nodes != null) |
|
|
93 |
nodes.each(function (node) {node.get('parentNode').removeChild(node) ;}) ; |
|
|
94 |
} |
|
|
95 |
|