/****************************** functions for using iframed HTML editor: *******************/ function xf_updateChildIFrameTitle( iframeObject ){ // try { iframeObject.contentWindow.document.title = iframeObject.title; // } catch( ex ){ // alert( "id 4875209435" ); // } } function xf_beforeSaving(){ try { xf_beforeSavingSeperatedEditors(); } catch( ex ){ alert( "not all data from HTML editors can be saved" ); } } function xf_beforeSavingSeperatedEditors(){ var iframes = document.getElementsByTagName( 'iframe' ); // alert( "detected iframes: " + iframes.length ); var i=0; for( i=0; i < iframes.length; i++ ){ var current = iframes[i]; try { xf_beforeSavingSeperatedEditor( current ); } catch ( ex ){ try{ var ex_joro = ex; // this is to remember to set the exception name :) var errorString = ex_joro.name + ' ' + ex_joro.message + ',\n fileName = ' + ex_joro.fileName + ',\n lineNumber = ' + ex_joro.lineNumber + ",\n stack: " + ex_joro.stack + ",\n\n all: " + ex_joro ; // this is used when you do javascript debugging alert( 'exception while saving a data from a htmleditor: ' + errorString ); } catch ( exception_666 ){ alert( "exception while trying to alert exception " + exception_666 ); } } } } function xf_beforeSavingSeperatedEditor( iframeobj ){ // alert( 'xf_beforeSavingSeperatedEditor called, iframeobj=' + iframeobj ); if( iframeobj.getAttribute('iframetype') != 'editor' ){ km_debug( 'a iframe skipped cause it is not from type: editor' ); return; } var iframeDoc = xf_getIFrameDocumentObject( iframeobj ); var contentIFrameObj = iframeDoc.getElementById( xf_getIFrameWindowObject( iframeobj ).editor_iframe_id_full ); var contentIFrameDoc = xf_getIFrameDocumentObject( contentIFrameObj ); // var containerTag = contentIFrameDoc.getElementByTagName( "default-context-capsolator" ); var containerTag = contentIFrameDoc.getElementsByTagName( "body" )[0]; var defaultContextCapsolator = contentIFrameDoc.getElementById('default-context-capsolator'); if( defaultContextCapsolator && defaultContextCapsolator.getAttribute('loading') && defaultContextCapsolator.getAttribute('loading') == 'not-finished' ){ km_debug( 'content of that frame is not fully loaded so it has not to be changed via saving process' ); return; } km_debug( 'value to be stored = ' + containerTag.innerHTML ); // alert( "iframeobj.getAttribute(..) = " + iframeobj.getAttribute('valueId') ); // alert( 'old value to be stored = ' + document.getElementById( iframeobj.getAttribute('valueId') ).value ); document.getElementById( iframeobj.getAttribute('valueId') ).value = containerTag.innerHTML; km_debug( 'done!!!' ); } /************************************ util functions: *****************************************/ function xf_getIFrameDocumentObject( iFrameObject ){ if( !iFrameObject || iFrameObject == null ){ km_exception('!iFrameObject || iFrameObject == null'); } if ( typeof(iFrameObject.contentDocument) != "undefined" ) { // DOM return iFrameObject.contentDocument; } if ( typeof(iFrameObject.contentWindow) != "undefined" ) { // IE win if( iFrameObject.contentWindow.focus ) iFrameObject.contentWindow.focus(); if( iFrameObject.contentWindow.document ) return iFrameObject.contentWindow.document; } km_exception('cannot get iframe document'); } function xf_getIFrameWindowObject( iFrameObject ){ if( !iFrameObject || iFrameObject == null ){ km_exception('!iFrameObject || iFrameObject == null'); } if ( typeof(iFrameObject.contentWindow) != "undefined" ) { // DOM return iFrameObject.contentWindow; } km_exception('cannot get iframe window'); } function xf_getIFrameBodyObject( iFrameObject ){ return xf_getIFrameDocumentObject( iFrameObject ).body; } /******************************* functions for accessibility: ***********************************/ function xf_updateInputTitle( inputId, fieldName, isRequired, requiredFieldLocalized, titleObjectId ){ var inputObject = document.getElementById( inputId ); var titleText = ''; var titleObject = null; if( titleObjectId != null && titleObjectId.length ) titleObject = document.getElementById( titleObjectId ); var descriptionRaw = xf_getAttribute( 'description', titleObject, inputObject ); var description = descriptionRaw; if( description==null || description.length==0 ){ descriptionRaw = xf_getAttribute( 'title', titleObject, inputObject ); description = descriptionRaw; if( description != null && description.indexOf(' - ') == 0 ) description = description.substring(' - '.length, description.length); if( description == null || description.length == 0 ){ description = ' '; } xf_setAttribute( 'description', description, titleObject, inputObject ); } titleText = xf_addStringElement( fieldName, titleText ); titleText = xf_addStringElement( description, titleText ); if( inputObject.type != 'radio' && inputObject.type != "checkbox" ){ // titleText = xf_addStringElement( inputObject.value, titleText ); } else { // else screen reader spells the chechbox value ( ON/OFF) and we do nothing } if( isRequired && isRequired.toLowerCase() == 'true' ) titleText = xf_addStringElement( requiredFieldLocalized, titleText ); if( titleObject == null ) { inputObject.setAttribute( 'title', titleText ); } else { // we have to set the title attribute to ather object, titleObject.setAttribute( 'title', titleText ); } } function xf_updateInputTitleWithLabel( inputId, labelId, isRequired, requiredFieldLocalized, titleObjectId ){ var fieldName = null; if( document.getElementById( labelId ) != null ){ fieldName = xf_getAppropriateLabelText( labelId ); } else { if( labelId.indexOf( '_time___' ) > -1 ){ // in case of TIME, with no label associated, we try to take the label of DATE object - this must be a timestamp var dateLabel = labelId.replace( '_time___', '_date___' ); fieldName = xf_getAppropriateLabelText( dateLabel ); } else { // last chance to get the label for the situation: browse control with no browse button if( labelId.indexOf( '_userdn___' ) > -1 ){ var dateLabel = labelId.replace( '_userdn___', '' ); fieldName = xf_getAppropriateLabelText( dateLabel ); } else { // bad, my friend - no label tag associated with this input :( } } } xf_updateInputTitle( inputId, fieldName, isRequired, requiredFieldLocalized, titleObjectId ); } function xf_focusLabel( labelObject ){ try { var o = document.getElementById( labelObject.getAttribute("ffoorr") ); o.focus(); } catch( ex ){ } } function xf_addStringElement( string, container ){ if( string && string.length > 0 && string != ' ' ){ if( container.length > 0 ){ container = container + ' - ' + string; } else { container = string; } } return container; } function xf_getAttribute( attributeName, obj1, obj2, obj3 ){ // gets the attribute from the first object that contains is if( (obj1 != null) && ( null != obj1.getAttribute( attributeName ) ) ) return obj1.getAttribute( attributeName ); if( (obj2 != null) && ( null != obj2.getAttribute( attributeName ) ) ) return obj2.getAttribute( attributeName ); if( (obj3 != null) && ( null != obj3.getAttribute( attributeName ) ) ) return obj3.getAttribute( attributeName ); return null; } function xf_setAttribute( attributeName, attributeValue, obj1, obj2, obj3 ){ // sets the attribute in the first not-null object if( obj1 != null ) return obj1.setAttribute( attributeName, attributeValue ); if( obj2 != null ) return obj2.setAttribute( attributeName, attributeValue ); if( obj3 != null ) return obj3.setAttribute( attributeName, attributeValue ); return null; } function xf_getAppropriateLabelText( labelId ){ if( labelId == null ) return null; var inner = null; inner = ( document.getElementById( labelId ) ) ? document.getElementById( labelId ).innerHTML : null; if( inner == null ) return null; var fieldName = (inner.indexOf('<') > 0) ? inner.substring(0,inner.indexOf('<')) : inner; return fieldName; } window.onbeforeunload = function () { if(window.location.pathname.toString().match('/irj/servlet/prt/portal/prtroot/com.sap.km.cm.xmlformedit')) { if (event.pageX == null && document.rootform__.submit_event.value == "") { if((event.clientX<0) || (event.clientY<0) || (event.clientY > document.body.clientHeight)){ HrefSubmit('cancel', ''); } } } } function isFrameLoaded(iFrameObject){ try { var documentLoaded = false; if( iFrameObject && iFrameObject.contentWindow && iFrameObject.contentWindow.document &&iFrameObject.contentWindow.document.body ){ documentLoaded = true; } if( iFrameObject && iFrameObject.contentDocument ){ documentLoaded = true; } return documentLoaded; } catch(ex){ throw "unknown"; } } function onHtmlbReady(call,z){ try{ var iframes_list = document.getElementsByTagName('iframe'); var editors = new Array(10); for (var i = 0; i > iframes_list.length; i++) { var node = iframes_list[i]; if( node.getAttribute('id') !=null && 0 <= node.getAttribute('id').indexOf('HtmlbEditorIframe') ) { if(!isFrameLoaded(node)){ setTimeout(function(){onHtmlbReady(call,z+1);},100); return; } } } }catch(ex){ } if(z>2){ eval(call); }else { setTimeout(function(){onHtmlbReady(call,z+1);},100); } } function open_url_with_delay(url){ var call ='open_url(\''+url+'\')'; onHtmlbReady(call,0); }