diff -r 9e2b9e568e42 -r 053551f213fb src/cm/media/js/client/c_interface_forms.js --- a/src/cm/media/js/client/c_interface_forms.js Mon Nov 29 15:05:21 2010 +0100 +++ b/src/cm/media/js/client/c_interface_forms.js Tue Nov 30 09:53:35 2010 +0100 @@ -1,71 +1,71 @@ gNoSelectionYet = gettext("No selection yet") ; gFormHtml = { - 'formStart' :'
', - 'nameInput' :gettext('Username:') + '
', - 'emailInput' :gettext('E-mail address:') + '
', - 'titleInput' :gettext('Title:') + '
', - 'contentInput' :gettext("Content:") + '
', - 'tagsInput' :gettext("Tag:") + '
', - 'hidden' :'', - 'formEnd' :'
', - 'changeScope' :'
' + gettext("Modify comment's scope:") + '
', - 'headerTitle' :'
', - 'currentSel' :'
' + gettext('Comment will apply to this selection:') + '
' + gNoSelectionYet + '
#hiddeninput#
', - 'btns' :'
', - 'closeIcon' :'      ' - } ; + 'formStart' :'
', + 'nameInput' :gettext('Username:') + '
', + 'emailInput' :gettext('E-mail address:') + '
', + 'titleInput' :gettext('Title:') + '
', + 'contentInput' :gettext("Content:") + '
', + 'tagsInput' :gettext("Tag:") + '
', + 'hidden' :'', + 'formEnd' :'
', + 'changeScope' :'
' + gettext("Modify comment's scope:") + '
', + 'headerTitle' :'
', + 'currentSel' :'
' + gettext('Comment will apply to this selection:') + '
' + gNoSelectionYet + '
#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']) ; + 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 ; + 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) ; + 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 formElt = document.getElementById(formId) ; var i, e, s, ilen ; // Iterate over the form elements collection to construct the @@ -73,14 +73,14 @@ 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) ; + 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) ; } } @@ -88,8 +88,8 @@ // 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) ;}) ; + var nodes = CY.all('#'+formId+' .c-error'); + if (nodes != null) + nodes.each(function (node) {node.get('parentNode').removeChild(node) ;}) ; }