diff -r 000000000000 -r 40c8f766c9b8 src/cm/media/js/client/c_interface_forms.js
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/cm/media/js/client/c_interface_forms.js Mon Nov 23 15:14:29 2009 +0100
@@ -0,0 +1,95 @@
+gNoSelectionYet = gettext("No selection yet") ;
+gFormHtml = {
+ 'formStart' :'
',
+ 'changeScope' :'' + gettext("Modify comment's scope:") + '
',
+ 'headerTitle' :'',
+ 'currentSel' :'' + gettext('Comment will apply to this selection:') + '
#hiddeninput#
',
+ 'btns' :'',
+ 'closeIcon' :' '
+ } ;
+
+// returns {'headerContent':headerHtml, 'bodyContent':bodyHtml}
+getHtml = function(ids) {
+ ret = {} ;
+ ret['headerContent'] = '' ;
+
+ if ('closeBtnId' in ids)
+ ret['headerContent'] += gFormHtml['closeIcon'].replace('###', ids['closeBtnId']) ;
+
+ ret['headerContent'] += gFormHtml['headerTitle'].replace('###', ids['formTitleId']) ;
+
+ var selEditChkBoxHtml = "" ;
+ if ('changeScopeInputId' in ids)
+ selEditChkBoxHtml = gFormHtml['changeScope'].replace('###', ids['changeScopeInputId']) ;
+
+ var hiddenInput = ''+gFormHtml['hidden'].replace('###', ids['selectionPlaceId']).replace('???', 'selection_place')+'' ;
+ var selectionTitleHtml = gFormHtml['currentSel'].replace('###', ids['currentSelId']).replace('???', ids['currentSelIdI']).replace('#hiddeninput#', hiddenInput) ;
+
+ var btnsHtml = gFormHtml['btns'].replace('###', ids['addBtnId']).replace('???', ids['cancelBtnId']) ;
+
+ var html = gFormHtml['formStart'].replace('###', ids['formId']) + selEditChkBoxHtml + selectionTitleHtml ;
+
+ if ('nameInputId' in ids)
+ html = html + gFormHtml['nameInput'].replace('###', ids['nameInputId']) ;
+ if ('emailInputId' in ids)
+ html = html + gFormHtml['emailInput'].replace('###', ids['emailInputId']) ;
+
+ html = html + gFormHtml['titleInput'].replace('###', ids['titleInputId']) + gFormHtml['contentInput'].replace('###', ids['contentInputId']) + gFormHtml['tagsInput'].replace('###', ids['tagsInputId']);
+ html = html + gFormHtml['hidden'].replace('###', ids['formatInputId']).replace('???', 'format') ;
+ html = html + gFormHtml['hidden'].replace('###', ids['startWrapperInputId']).replace('???', 'start_wrapper') ;
+ html = html + gFormHtml['hidden'].replace('###', ids['endWrapperInputId']).replace('???', 'end_wrapper') ;
+ html = html + gFormHtml['hidden'].replace('###', ids['startOffsetInputId']).replace('???', 'start_offset') ;
+ html = html + gFormHtml['hidden'].replace('###', ids['endOffsetInputId']).replace('???', 'end_offset') ;
+ html = html + gFormHtml['hidden'].replace('###', ids['keyId']).replace('???', 'comment_key') ;
+ html = html + gFormHtml['hidden'].replace('###', ids['editCommentId']).replace('???', 'edit_comment_id') ;
+ html = html + btnsHtml + gFormHtml['formEnd'] ;
+ ret['bodyContent'] = html ;
+ return ret ;
+} ;
+
+changeFormFieldsWidth = function(formId, val) {
+ var fieldWidth = (val - 20) +'px' ;
+ var elts = CY.all("#" + formId + " input[type='text']") ;
+ if (elts != null)
+ elts.setStyle("width", fieldWidth) ;
+ elts = CY.all("#" + formId + " textarea") ;
+ if (elts != null)
+ elts.setStyle("width", fieldWidth) ;
+}
+
+addFormErrMsg = function(formId, eltName, errorString) {
+ var formElt = document.getElementById(formId) ;
+ var i, e, s, ilen ;
+
+ // Iterate over the form elements collection to construct the
+ // label-value pairs.
+ for (i = 0, ilen = formElt.elements.length; i < ilen; ++i) {
+ e = formElt.elements[i];
+ if (e.name == eltName) {
+ s = document.createElement('DIV') ;
+ CY.DOM.addClass(s, 'c-error') ;
+ s.id = e.id + '-err';
+ s.appendChild(document.createTextNode(errorString)) ;
+ if (e.parentNode.nextSibling)
+ e.parentNode.parentNode.insertBefore(s, e.parentNode.nextSibling) ;
+ else
+ e.parentNode.parentNode.appendChild(s) ;
+ }
+
+ }
+}
+
+// frames['text_view_frame'].removeFormErrMsg(frames['text_view_frame'].gICommentForm['formId'])
+removeFormErrMsg = function(formId) {
+ var nodes = CY.all('#'+formId+' .c-error');
+ if (nodes != null)
+ nodes.each(function (node) {node.get('parentNode').removeChild(node) ;}) ;
+}
+