Propchange: ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/dialog/BirtPrintReportDialog.js
------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/dialog/BirtPrintReportDialog.js ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/dialog/BirtPrintReportDialog.js ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/dialog/BirtPrintReportServerDialog.js URL: http://svn.apache.org/viewvc/ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/dialog/BirtPrintReportServerDialog.js?rev=825391&view=auto ============================================================================== --- ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/dialog/BirtPrintReportServerDialog.js (added) +++ ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/dialog/BirtPrintReportServerDialog.js Thu Oct 15 04:48:28 2009 @@ -0,0 +1,662 @@ +/****************************************************************************** + * Copyright (c) 2004 Actuate Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Actuate Corporation - Initial implementation. + *****************************************************************************/ + +/** + * Birt print report on the server dialog. + */ +BirtPrintReportServerDialog = Class.create( ); + +BirtPrintReportServerDialog.prototype = Object.extend( new AbstractBaseDialog( ), +{ + __neh_select_change_closure : null, + __neh_printserver_click_closure : null, + __neh_pageradio_click_closure : null, + + __enable : false, + __printer : null, + + /** + * Initialization routine required by "ProtoType" lib. + * @return, void + */ + initialize : function( id ) + { + this.__initBase( id ); + this.__z_index = 200; + + this.__initLayout( ); + + // Binding + this.__neh_select_change_closure = this.__neh_select_change.bindAsEventListener( this ); + this.__neh_printserver_click_closure = this.__neh_printserver_click.bindAsEventListener( this ); + this.__neh_pageradio_click_closure = this.__neh_pageradio_click.bindAsEventListener( this ); + + this.__installEventHandlers( id ); + }, + + /** + * Install native/birt event handlers. + * + * @id, toolbar id (optional since there is only one toolbar) + * @return, void + */ + __installEventHandlers : function( id ) + { + var oSelects = this.__instance.getElementsByTagName( 'select' ); + Event.observe( oSelects[0], 'change', this.__neh_select_change_closure, false ); + + var oInputs = this.__instance.getElementsByTagName( 'input' ); + Event.observe( oInputs[0], 'click', this.__neh_printserver_click_closure, false ); + + var oInputs = $( 'printServerPageSetting' ).getElementsByTagName( 'input' ); + for( var i=0; i<oInputs.length; i++ ) + { + if( oInputs[i].type == 'radio' ) + Event.observe( oInputs[i], 'click', this.__neh_pageradio_click_closure,false ); + } + }, + + /** + * Handle clicking on ok. + * + * @return, void + */ + __okPress : function( ) + { + var flag = false; + if( this.__enable ) + { + this.__collectPrinter( ); + flag = this.__printAction( ); + + if ( flag ) + { + birtConfirmationDialog.__cb_bind( ); + } + } + + // don't hide if there was an error + if ( !( this.__enable && !flag ) ) + { + this.__l_hide( ); + } + + }, + + /** + * Collect printer information + * + * @return, void + * + */ + __collectPrinter : function( ) + { + if( !this.__printer ) + return; + + var oCopies = $( 'printer_copies' ); + if( !oCopies.disabled ) + this.__printer.setCopies( oCopies.value ); + + var oCollate = $( 'printer_collate' ); + if( !oCollate.disabled ) + { + if( oCollate.checked ) + this.__printer.setCollate( true ); + else + this.__printer.setCollate( false ); + } + + var oDuplex = $( 'printer_duplexSimplex' ); + if( !oDuplex.disabled && oDuplex.checked ) + { + this.__printer.setDuplex( this.__printer.DUPLEX_SIMPLEX ); + } + oDuplex = $( 'printer_duplexHorz' ); + if( !oDuplex.disabled && oDuplex.checked ) + { + this.__printer.setDuplex( this.__printer.DUPLEX_HORIZONTAL ); + } + oDuplex = $( 'printer_duplexVert' ); + if( !oDuplex.disabled && oDuplex.checked ) + { + this.__printer.setDuplex( this.__printer.DUPLEX_VERTICAL ); + } + + var oMode = $( 'printer_modeBW' ); + if( !oMode.disabled && oMode.checked ) + { + this.__printer.setMode( this.__printer.MODE_MONOCHROME ); + } + oMode = $( 'printer_modeColor' ); + if( !oMode.disabled && oMode.checked ) + { + this.__printer.setMode( this.__printer.MODE_COLOR ); + } + + var oMediaSize = $( 'printer_mediasize' ); + if( !oMediaSize.disabled ) + this.__printer.setMediaSize( oMediaSize.value ); + + }, + + /** + * Handle print report action + * + * @return, true or false + */ + __printAction : function( ) + { + if( !this.__printer ) + return false; + + var docObj = document.getElementById( "Document" ); + if ( !docObj || birtUtility.trim( docObj.innerHTML ).length <= 0) + { + alert ( Constants.error.generateReportFirst ); + return false; + } + else + { + var divObj = document.createElement( "DIV" ); + document.body.appendChild( divObj ); + divObj.style.display = "none"; + + var formObj = document.createElement( "FORM" ); + divObj.appendChild( formObj ); + + // Replace "html" to selected output format + var action = soapURL; + var reg = new RegExp( "([&|?]{1}" + Constants.PARAM_FORMAT + "\s*)=([^&|^#]*)", "gi" ); + if( action.search( reg ) < 0 ) + { + action = action + "&" + Constants.PARAM_FORMAT + "=" + Constants.FORMAT_POSTSCRIPT; + } + else + { + action = action.replace( reg, "$1=" + Constants.FORMAT_POSTSCRIPT ); + } + + // Delete page, pagerange and parameterpage settings in url if existed + action = birtUtility.deleteURLParameter( action, Constants.PARAM_PAGE ); + action = birtUtility.deleteURLParameter( action, Constants.PARAM_PAGERANGE ); + action = birtUtility.deleteURLParameter( action, Constants.PARAM_PARAMETERPAGE ); + action = birtUtility.deleteURLParameter( action, Constants.PARAM_EMITTER_ID ); + + if( $( 'printServerPageCurrent' ).checked ) + { + // Set page setting + var currentPage = birtUtility.trim( $( 'pageNumber' ).innerHTML ); + action = action + "&" + Constants.PARAM_PAGE + "=" + currentPage; + } + else if( $( 'printServerPageRange' ).checked ) + { + // Set page range setting + var pageRange = birtUtility.trim( $( 'printServerPageRange_input' ).value ); + if ( !birtUtility.checkPageRange( pageRange ) ) + { + alert( Constants.error.invalidPageRange ); + return false; + } + action = action + "&" + Constants.PARAM_PAGERANGE + "=" + pageRange; + } + + // auto + var pageOverflow = 0; + //var pagebreakonly = "true"; + + // fit to actual size + if( $( 'printServerFitToActual' ).checked ) + { + pageOverflow = 1; + } + //fit to whole page + else if( $( 'printServerFitToWhole' ).checked ) + { + pageOverflow = 2; + } + + reg = new RegExp( "([&|?]{1}" + Constants.PARAM_PAGE_OVERFLOW + "\s*)=([^&|^#]*)", "gi" ); + if( action.search( reg ) < 0 ) + { + action = action + "&" + Constants.PARAM_PAGE_OVERFLOW + "=" + pageOverflow; + } + else + { + action = action.replace( reg, "$1=" + pageOverflow ); + } + + /* + reg = new RegExp( "([&|?]{1}" + Constants.PARAM_PAGEBREAKONLY + "\s*)=([^&|^#]*)", "gi" ); + if( action.search( reg ) < 0 ) + { + action = action + "&" + Constants.PARAM_PAGEBREAKONLY + "=" + pagebreakonly; + } + else + { + action = action.replace( reg, "$1=" + pagebreakonly ); + } + */ + + // Force "__overwrite" as false + reg = new RegExp( "([&|?]{1}" + Constants.PARAM_OVERWRITE + "\s*)=([^&|^#]*)", "gi" ); + if( action.search( reg ) < 0 ) + { + action = action + "&" + Constants.PARAM_OVERWRITE + "=false"; + } + else + { + action = action.replace( reg, "$1=false" ); + } + + // Set action as print + reg = new RegExp( "([&|?]{1}" + Constants.PARAM_ACTION + "\s*)=([^&|^#]*)", "gi" ); + if( action.search( reg ) < 0 ) + { + action = action + "&" + Constants.PARAM_ACTION + "=" + Constants.ACTION_PRINT; + } + else + { + action = action.replace( reg, "$1=" + Constants.ACTION_PRINT ); + } + + // Post printer settings + var curPrinter = this.__findPrinter( this.__printer.getName( ) ); + if( curPrinter ) + { + var param = document.createElement( "INPUT" ); + formObj.appendChild( param ); + param.TYPE = "HIDDEN"; + param.name = Constants.PARAM_PRINTER_NAME; + param.value = this.__printer.getName( ); + + if( curPrinter.isCopiesSupported( ) ) + { + param = document.createElement( "INPUT" ); + formObj.appendChild( param ); + param.TYPE = "HIDDEN"; + param.name = Constants.PARAM_PRINTER_COPIES; + param.value = this.__printer.getCopies( ); + } + + if( curPrinter.isCollateSupported( ) ) + { + param = document.createElement( "INPUT" ); + formObj.appendChild( param ); + param.TYPE = "HIDDEN"; + param.name = Constants.PARAM_PRINTER_COLLATE; + param.value = new String( this.__printer.isCollate( ) ); + } + + if( curPrinter.isDuplexSupported( ) ) + { + param = document.createElement( "INPUT" ); + formObj.appendChild( param ); + param.TYPE = "HIDDEN"; + param.name = Constants.PARAM_PRINTER_DUPLEX; + param.value = this.__printer.getDuplex( ); + } + + if( curPrinter.isModeSupported( ) ) + { + param = document.createElement( "INPUT" ); + formObj.appendChild( param ); + param.TYPE = "HIDDEN"; + param.name = Constants.PARAM_PRINTER_MODE; + param.value = this.__printer.getMode( ); + } + + if( curPrinter.isMediaSupported( ) ) + { + param = document.createElement( "INPUT" ); + formObj.appendChild( param ); + param.TYPE = "HIDDEN"; + param.name = Constants.PARAM_PRINTER_MEDIASIZE; + param.value = this.__printer.getMediaSize( ); + } + } + + formObj.action = action; + formObj.method = "post"; + formObj.target = "birt_confirmation_iframe"; + formObj.submit( ); + } + + return true; + }, + + /** + * Native event handler for select control. + * + * @param event + * @return, void + */ + __neh_select_change : function( event ) + { + this.__updateInfo( ); + }, + + /** + * Native event handler for click 'Print On Server' control. + * + * @param event + * @return, void + */ + __neh_printserver_click : function( event ) + { + var oCtl = Event.element( event ); + + if( oCtl.checked ) + { + this.__enable = true; + $( 'printer' ).disabled = false; + } + else + { + this.__enable = false; + $( 'printer' ).disabled = true; + } + + // Update info + this.__updateInfo( ); + }, + + /** + * Check whether focus on input control + * + * @param oSC + * @return, void + */ + __checkPageRadio : function( oSC ) + { + if( !oSC || oSC.type != 'radio' ) + return; + + var oInput = $( 'printServerPageRange_input' ); + if( oSC.checked && oSC.id == 'printServerPageRange' ) + { + oInput.disabled = false; + oInput.focus( ); + } + else + { + oInput.disabled = true; + oInput.value = ""; + } + }, + + /** + * Native event handler for page radio control. + */ + __neh_pageradio_click : function( event ) + { + var oSC = Event.element( event ); + this.__checkPageRadio( oSC ); + }, + + /** + * Initilize dialog layout + * + * @return, void + */ + __initLayout : function( ) + { + var oSelect = $( 'printer' ); + if( !oSelect ) + return; + + oSelect.disabled = true; + for( var i=0; i<printers.length; i++ ) + { + var oOption = document.createElement( "OPTION" ); + oOption.text = printers[i].name; + oOption.value = printers[i].value.getName( ); + oSelect.options[oSelect.options.length] = oOption; + } + + // Update info + this.__updateInfo( ); + }, + + /** + * Insert HTML in a control + * + * @param id + * @param text + * @return, void + */ + __insertHTML : function( id,text ) + { + var oControl = $( id ); + if( oControl ) + { + oControl.innerHTML = text; + } + }, + + /** + * Set disabled status for all controls in container + * + * @param id + * @param flag + * @return, void + */ + __setDisabled : function( id, flag ) + { + var oContainer = $( id ); + if( !oContainer ) + return; + + var oSelects = oContainer.getElementsByTagName( "select" ); + if( oSelects ) + { + for( var i=0; i<oSelects.length; i++ ) + oSelects[i].disabled = flag; + } + + var oInputs = oContainer.getElementsByTagName( "input" ); + if( oInputs ) + { + for( var i=0; i<oInputs.length; i++ ) + oInputs[i].disabled = flag; + } + }, + + /** + * Find certain printer object by name + * + * @param name + * @return, void + */ + __findPrinter : function( name ) + { + var curPrinter; + for( var i=0; i<printers.length; i++ ) + { + if( name == printers[i].name ) + { + curPrinter = printers[i].value; + break; + } + } + + return curPrinter; + }, + + /** + * Update generate information + * + * @return, void + */ + __updateInfo : function( ) + { + var printerName = $( 'printer' ).value; + var curPrinter = this.__findPrinter( printerName ); + if( !curPrinter ) + { + this.__enable = false; + this.__setDisabled( 'printer_config',true ); + this.__setDisabled( 'printServerPageSetting',true ); + this.__setDisabled( 'printServerFitSetting',true ); + return; + } + + this.__printer = curPrinter; + + // Generate info + this.__insertHTML( 'printer_status', curPrinter.getStatus( ) ); + this.__insertHTML( 'printer_model', curPrinter.getModel( ) ); + this.__insertHTML( 'printer_info', curPrinter.getInfo( ) ); + + // Print settings + if( this.__enable ) + { + this.__setDisabled( 'printer_config',false ); + this.__setDisabled( 'printServerPageSetting',false ); + this.__setDisabled( 'printServerFitSetting',false ); + var oInputs = $( 'printServerPageSetting' ).getElementsByTagName( 'input' ); + for( var i=0; i<oInputs.length; i++ ) + this.__checkPageRadio( oInputs[i] ); + } + else + { + this.__setDisabled( 'printer_config',true ); + this.__setDisabled( 'printServerPageSetting',true ); + this.__setDisabled( 'printServerFitSetting',true ); + } + + if( curPrinter.isCopiesSupported( ) ) + { + $( 'printer_copies' ).value = curPrinter.getCopies( ); + } + else + { + $( 'printer_copies' ).disabled = true; + } + + if( curPrinter.isCollateSupported( ) ) + { + if( curPrinter.isCollate( ) ) + $( 'printer_collate' ).checked = true; + else + $( 'printer_collate' ).checked = false; + } + else + { + $( 'printer_collate' ).disabled = true; + $( 'printer_collate' ).checked = false; + } + + if( curPrinter.isDuplexSupported( ) ) + { + var duplex = curPrinter.getDuplex( ); + switch( duplex ) + { + case curPrinter.DUPLEX_SIMPLEX: + $( 'printer_duplexSimplex' ).checked = true; + break; + case curPrinter.DUPLEX_HORIZONTAL: + $( 'printer_duplexHorz' ).checked = true; + break; + case curPrinter.DUPLEX_VERTICAL: + $( 'printer_duplexVert' ).checked = true; + break; + default: + $( 'printer_duplexSimplex' ).checked = true; + } + } + else + { + $( 'printer_duplexSimplex' ).disabled = true; + $( 'printer_duplexSimplex' ).checked = false; + + $( 'printer_duplexHorz' ).disabled = true; + $( 'printer_duplexHorz' ).checked = false; + + $( 'printer_duplexVert' ).disabled = true; + $( 'printer_duplexVert' ).checked = false; + } + + if( curPrinter.isModeSupported( ) ) + { + var mode = curPrinter.getMode( ); + switch( mode ) + { + case curPrinter.MODE_MONOCHROME: + $( 'printer_modeBW' ).checked = true; + break; + case curPrinter.MODE_COLOR: + $( 'printer_modeColor' ).checked = true; + break; + default: + $( 'printer_modeBW' ).checked = true; + } + } + else + { + $( 'printer_modeBW' ).disabled = true; + $( 'printer_modeBW' ).checked = false; + + $( 'printer_modeColor' ).disabled = true; + $( 'printer_modeColor' ).checked = false; + } + + if( curPrinter.isMediaSupported( ) ) + { + var mediaSize = curPrinter.getMediaSize( ); + var mediaSizeNames = curPrinter.getMediaSizeNames( ); + var oSize = $( 'printer_mediasize' ); + oSize.length = 0; + for( var i=0; i<mediaSizeNames.length; i++ ) + { + var oOption = document.createElement( "OPTION" ); + var oLabel = document.createElement( "LABEL" ); + oLabel.innerHTML = mediaSizeNames[i].name; + oOption.text = oLabel.innerHTML; + oOption.value = mediaSizeNames[i].value; + + if( mediaSizeNames[i].value == mediaSize ) + oOption.selected = true; + + oSize.options[oSize.options.length] = oOption; + } + } + else + { + $( 'printer_mediasize' ).length = 0; + $( 'printer_mediasize' ).disabled = true; + } + }, + + /** + Called right before element is shown + */ + __preShow: function() + { + // disable the toolbar buttons + birtUtility.setButtonsDisabled ( "toolbar", true ); + + // disable the Navigation Bar buttons + birtUtility.setButtonsDisabled ( "navigationBar", true ); + }, + + /** + Called before element is hidden + */ + __preHide: function() + { + // enable the toolbar buttons + birtUtility.setButtonsDisabled ( "toolbar", false ); + + // enable the Navigation Bar buttons + birtUtility.setButtonsDisabled ( "navigationBar", false ); + } +} ); \ No newline at end of file Propchange: ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/dialog/BirtPrintReportServerDialog.js ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/dialog/BirtPrintReportServerDialog.js ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/dialog/BirtPrintReportServerDialog.js ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/dialog/BirtSimpleExportDataDialog.js URL: http://svn.apache.org/viewvc/ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/dialog/BirtSimpleExportDataDialog.js?rev=825391&view=auto ============================================================================== --- ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/dialog/BirtSimpleExportDataDialog.js (added) +++ ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/dialog/BirtSimpleExportDataDialog.js Thu Oct 15 04:48:28 2009 @@ -0,0 +1,573 @@ +/****************************************************************************** + * Copyright (c) 2004 Actuate Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Actuate Corporation - Initial implementation. + *****************************************************************************/ + +/** + * Birt export data dialog. + */ +BirtSimpleExportDataDialog = Class.create( ); + +BirtSimpleExportDataDialog.prototype = Object.extend( new AbstractBaseDialog( ), +{ + __neh_select_change_closure : null, + __neh_switchResultSet_closure : null, + + availableResultSets : [], + selectedColumns : [], + + /** + * Initialization routine required by "ProtoType" lib. + * @return, void + */ + initialize : function( id ) + { + this.__initBase( id ); + this.__z_index = 200; + + // Closures + this.__neh_switchResultSet_closure = this.__neh_switchResultSet.bindAsEventListener( this ); + this.__neh_click_exchange_closure = this.__neh_click_exchange.bindAsEventListener( this ); + this.__neh_dblclick_src_closure = this.__neh_dblclick_src.bindAsEventListener( this ); + this.__neh_dblclick_dest_closure = this.__neh_dblclick_dest.bindAsEventListener( this ); + this.__neh_click_src_closure = this.__neh_click_src.bindAsEventListener( this ); + this.__neh_click_dest_closure = this.__neh_click_dest.bindAsEventListener( this ); + + this.__installEventHandlers( id ); + }, + + /** + * Install native/birt event handlers. + * + * @id, toolbar id (optional since there is only one toolbar) + * @return, void + */ + __installEventHandlers : function( id ) + { + var oSelects = this.__instance.getElementsByTagName( 'select' ); + Event.observe( oSelects[0], 'change', this.__neh_switchResultSet_closure, false ); + + // Initialize exchange buttons + var oInputs = this.__instance.getElementsByTagName( 'input' ); + for ( var i = 0; i < oInputs.length ; i++ ) + { + Event.observe( oInputs[i], 'click', this.__neh_click_exchange_closure, false ); + } + + // Initialize exchange selects + var oSelects = this.__instance.getElementsByTagName( 'select' ); + if( oSelects.length > 2 ) + { + Event.observe( oSelects[1], 'dblclick', this.__neh_dblclick_src_closure, false ); + Event.observe( oSelects[2], 'dblclick', this.__neh_dblclick_dest_closure, false ); + Event.observe( oSelects[1], 'change', this.__neh_click_src_closure, false ); + Event.observe( oSelects[2], 'change', this.__neh_click_dest_closure, false ); + } + }, + + /** + * Native event handler for selection item movement. + */ + __neh_click_exchange : function( event ) + { + var oSC = Event.element( event ); + if( oSC.id == 'exportDataEncoding_other' ) + { + this.__updateButtons( ); + $( 'exportDataOtherEncoding_input' ).focus( ); + } + else + { + var oInputs = this.__instance.getElementsByTagName( 'input' ); + var oSelects = this.__instance.getElementsByTagName( 'select' ); + + switch ( Event.element( event ).name ) + { + case 'Addall': + { + if ( oSelects[1].options.length > 0 ) + { + this.moveAllItems( oSelects[1], oSelects[2] ); + } + break; + } + case 'Add': + { + if ( oSelects[1].options.length > 0 ) + { + this.moveSingleItem( oSelects[1], oSelects[2] ); + } + break; + } + case 'Remove': + { + if ( oSelects[2].options.length > 0 ) + { + this.moveSingleItem( oSelects[2], oSelects[1] ); + } + break; + } + case 'Removeall': + { + if ( oSelects[2].options.length > 0 ) + { + this.moveAllItems( oSelects[2], oSelects[1] ); + } + break; + } + case 'Up': + { + birtUtility.moveSelectedItemsUp( oSelects[2] ); + break; + } + case 'Down': + { + birtUtility.moveSelectedItemsDown( oSelects[2] ); + break; + } + } + + this.__updateButtons( ); + } + }, + + /** + * Native event handler for double click source select element. + */ + __neh_dblclick_src : function( event ) + { + var oSelects = this.__instance.getElementsByTagName( 'select' ); + + if ( oSelects[1].options.length > 0 ) + { + this.moveSingleItem( oSelects[1], oSelects[2] ); + } + + this.__updateButtons( ); + }, + + /** + * Native event handler for double click dest select element. + */ + __neh_dblclick_dest : function( event ) + { + var oSelects = this.__instance.getElementsByTagName( 'select' ); + + if ( oSelects[2].options.length > 0 ) + { + this.moveSingleItem( oSelects[2], oSelects[1] ); + } + + this.__updateButtons( ); + }, + + /** + * Native event handler for click source select element. + */ + __neh_click_src : function( event ) + { + this.__updateButtons( ); + }, + + /** + * Native event handler for click dest select element. + */ + __neh_click_dest : function( event ) + { + this.__updateButtons( ); + }, + + /** + * Update button status. + */ + __updateButtons : function( ) + { + var oSelects = this.__instance.getElementsByTagName( 'select' ); + var canExport = oSelects[0].options.length > 0; + var canAdd = oSelects[1].options.length > 0; + var canRemove = oSelects[2].options.length > 0; + var srcSelectedIndex = oSelects[1].selectedIndex; + var destSelectedIndex = oSelects[2].selectedIndex; + + var oInputs = this.__instance.getElementsByTagName( 'input' ); + + if( !rtl ) + { + oInputs[0].src = canAdd ? "birt/images/AddAll.gif" : "birt/images/AddAll_disabled.gif"; + } + else + { + oInputs[0].src = canAdd ? "birt/images/AddAll_rtl.gif" : "birt/images/AddAll_disabled_rtl.gif"; + } + oInputs[0].style.cursor = canAdd ? "pointer" : "default"; + + if( !rtl ) + { + oInputs[1].src = canAdd && srcSelectedIndex >= 0 ? "birt/images/Add.gif" : "birt/images/Add_disabled.gif"; + } + else + { + oInputs[1].src = canAdd && srcSelectedIndex >= 0 ? "birt/images/Add_rtl.gif" : "birt/images/Add_disabled_rtl.gif"; + } + oInputs[1].style.cursor = canAdd ? "pointer" : "default"; + + if( !rtl ) + { + oInputs[2].src = canRemove && destSelectedIndex >= 0 ? "birt/images/Remove.gif" : "birt/images/Remove_disabled.gif"; + } + else + { + oInputs[2].src = canRemove && destSelectedIndex >= 0 ? "birt/images/Remove_rtl.gif" : "birt/images/Remove_disabled_rtl.gif"; + } + oInputs[2].style.cursor = canRemove ? "pointer" : "default"; + + if( !rtl ) + { + oInputs[3].src = canRemove ? "birt/images/RemoveAll.gif" : "birt/images/RemoveAll_disabled.gif"; + } + else + { + oInputs[3].src = canRemove ? "birt/images/RemoveAll_rtl.gif" : "birt/images/RemoveAll_disabled_rtl.gif"; + } + oInputs[3].style.cursor = canRemove ? "pointer" : "default"; + + oInputs[4].src = canRemove && destSelectedIndex >= 0 ? "birt/images/Up.gif" : "birt/images/Up_disabled.gif"; + oInputs[4].style.cursor = canRemove ? "pointer" : "default"; + + oInputs[5].src = canRemove && destSelectedIndex >= 0 ? "birt/images/Down.gif" : "birt/images/Down_disabled.gif"; + oInputs[5].style.cursor = canRemove ? "pointer" : "default"; + + if( canExport ) + { + this.__setDisabled( 'exportDataEncodingSetting', false ); + $( 'exportDataCSVSeparator' ).disabled = false; + + var oEnc = $( 'exportDataEncoding_other' ); + var oEncInput = $( 'exportDataOtherEncoding_input' ); + if( oEnc && oEnc.checked ) + { + oEncInput.disabled = false; + } + else + { + oEncInput.disabled = true; + } + } + else + { + this.__setDisabled( 'exportDataEncodingSetting', true ); + $( 'exportDataCSVSeparator' ).disabled = true; + } + }, + + /** + * Set disabled status for all controls in container + * + * @param id + * @param flag + * @return, void + */ + __setDisabled : function( id, flag ) + { + var oContainer = $( id ); + if( !oContainer ) + return; + + var oSelects = oContainer.getElementsByTagName( "select" ); + if( oSelects ) + { + for( var i=0; i<oSelects.length; i++ ) + oSelects[i].disabled = flag; + } + + var oInputs = oContainer.getElementsByTagName( "input" ); + if( oInputs ) + { + for( var i=0; i<oInputs.length; i++ ) + oInputs[i].disabled = flag; + } + }, + + /** + * Move single selection item. + */ + moveSingleItem : function( sel_source, sel_dest ) + { + if ( sel_source.selectedIndex == -1 ) + { + return; + } + + for ( var i=0; i<sel_source.options.length; i++ ) + { + if ( sel_source.options[i].selected ) + { + var selectedItem = sel_source.options[i]; + sel_dest.options[sel_dest.options.length] = new Option( selectedItem.text, selectedItem.value ); + sel_source.remove( i ); + i = i - 1; + } + } + + sel_source.selectedIndex = 0; + }, + + /** + * Move all selection items. + */ + moveAllItems : function( sel_source, sel_dest ) + { + for ( var i = 0; i < sel_source.length; i++ ) + { + var SelectedText = sel_source.options[i].text; + var SelectedValue = sel_source.options[i].value; + var newOption = new Option( SelectedText ); + newOption.value = SelectedValue; + sel_dest.options[sel_dest.options.length] = newOption; + } + + sel_dest.selectedIndex = 0; + sel_source.length = 0; + }, + + /** + * Binding data to the dialog UI. Data includes zoom scaling factor. + * + * @data, data DOM tree (schema TBD) + * @return, void + */ + __bind : function( data ) + { + if ( !data ) + { + return; + } + + var oSelects = this.__instance.getElementsByTagName( 'select' ); + oSelects[0].options.length = 0; + oSelects[1].options.length = 0; + oSelects[2].options.length = 0; + + this.availableResultSets = []; + + var resultSets = data.getElementsByTagName( 'ResultSet' ); + for ( var k = 0; k < resultSets.length; k++ ) + { + var resultSet = resultSets[k]; + + var queryNames = resultSet.getElementsByTagName( 'QueryName' ); + oSelects[0].options[oSelects[0].options.length] = new Option(queryNames[0].firstChild.data); + + this.availableResultSets[k] = {}; + + var columns = resultSet.getElementsByTagName( 'Column' ); + for( var i = 0; i < columns.length; i++ ) + { + var column = columns[i]; + + var columnName = column.getElementsByTagName( 'Name' ); + var label = column.getElementsByTagName( 'Label' ); + this.availableResultSets[k][label[0].firstChild.data] = columnName[0].firstChild.data; + } + } + + this.__neh_switchResultSet( ); + }, + + /** + * switch result set. + */ + __neh_switchResultSet : function( ) + { + var oSelects = this.__instance.getElementsByTagName( 'select' ); + oSelects[1].options.length = 0; + oSelects[2].options.length = 0; + + var columns = this.availableResultSets[oSelects[0].selectedIndex]; + for( var label in columns ) + { + var colName = columns[label]; + var option = new Option( label ); + option.value = colName; + oSelects[1].options[oSelects[1].options.length] = option; + } + + this.__updateButtons( ); + }, + + /** + * Handle clicking on ok. + * + * @return, void + */ + __okPress : function( ) + { + var oSelects = this.__instance.getElementsByTagName( 'select' ); + this.__l_hide( ); + if ( oSelects[2].options.length > 0 ) + { + for( var i = 0; i < oSelects[2].options.length; i++ ) + { + this.selectedColumns[i] = oSelects[2].options[i].value; + } + + this.__constructForm( ); + } + }, + + /** + * Construct extract data form. Post it to server. + */ + __constructForm : function( ) + { + var dialogContent = $( 'simpleExportDialogBody' ); + var hiddenDiv = document.createElement( 'div' ); + hiddenDiv.style.display = 'none'; + + var hiddenForm = document.createElement( 'form' ); + hiddenForm.method = 'post'; + hiddenForm.target = '_self'; + var url = soapURL; + url = url.replace( /[\/][a-zA-Z]+[?]/, '/' + Constants.SERVLET_EXTRACT + '?' ); + + // delete some URL parameters + url = birtUtility.deleteURLParameter( url, Constants.PARAM_BOOKMARK ); + url = birtUtility.deleteURLParameter( url, Constants.PARAM_INSTANCE_ID ); + hiddenForm.action = url; + + // Pass over current element's iid. + var queryNameInput = document.createElement( 'input' ); + queryNameInput.type = 'hidden'; + queryNameInput.name = Constants.PARAM_RESULTSETNAME; + var oSelects = this.__instance.getElementsByTagName( 'select' ); + queryNameInput.value = oSelects[0].options[oSelects[0].selectedIndex].text; + hiddenForm.appendChild( queryNameInput ); + + // Total # of selected columns. + if ( this.selectedColumns.length > 0 ) + { + var hiddenSelectedColumnNumber = document.createElement( 'input' ); + hiddenSelectedColumnNumber.type = 'hidden'; + hiddenSelectedColumnNumber.name = Constants.PARAM_SELECTEDCOLUMNNUMBER; + hiddenSelectedColumnNumber.value = this.selectedColumns.length; + hiddenForm.appendChild( hiddenSelectedColumnNumber ); + + // data of selected columns. + for( var i = 0; i < this.selectedColumns.length; i++ ) + { + var hiddenSelectedColumns = document.createElement( 'input' ); + hiddenSelectedColumns.type = 'hidden'; + hiddenSelectedColumns.name = Constants.PARAM_SELECTEDCOLUMN + i; + hiddenSelectedColumns.value = this.selectedColumns[i]; + hiddenForm.appendChild( hiddenSelectedColumns ); + } + } + + this.selectedColumns = []; + + // CSV separator + var oExtension = $( 'exportDataExtension' ); + if( oExtension && oExtension.value != '' ) + { + var hiddenExtension = document.createElement( 'input' ); + hiddenExtension.type = 'hidden'; + hiddenExtension.name = Constants.PARAM_DATA_EXTRACT_EXTENSION; + hiddenExtension.value = oExtension.value; + hiddenForm.appendChild( hiddenExtension ); + } + + // Pass the export data encoding + var oUTF8 = $( 'exportDataEncoding_UTF8' ); + var hiddenEnc = document.createElement( 'input' ); + hiddenEnc.type = 'hidden'; + hiddenEnc.name = Constants.PARAM_EXPORT_ENCODING; + if( oUTF8 && oUTF8.checked ) + { + hiddenEnc.value = oUTF8.value; + } + else + { + hiddenEnc.value = $('exportDataOtherEncoding_input').value; + } + hiddenForm.appendChild( hiddenEnc ); + + // CSV separator + var oSep = $( 'exportDataCSVSeparator' ); + if( oSep && oSep.value != '' ) + { + var hiddenSep = document.createElement( 'input' ); + hiddenSep.type = 'hidden'; + hiddenSep.name = Constants.PARAM_SEP; + hiddenSep.value = oSep.value; + hiddenForm.appendChild( hiddenSep ); + } + + var hiddenAsAttachment = document.createElement( 'input' ); + hiddenAsAttachment.type = 'hidden'; + hiddenAsAttachment.name = Constants.PARAM_ASATTACHMENT; + hiddenAsAttachment.value = "true"; + hiddenForm.appendChild( hiddenAsAttachment ); + + // Whether exports column's data type + var oType = $( 'exportColumnDataType' ); + var hiddenType = document.createElement( 'input' ); + hiddenType.type = 'hidden'; + hiddenType.name = Constants.PARAM_EXPORT_DATATYPE; + if( oType && oType.checked ) + hiddenType.value = "true"; + else + hiddenType.value = "false"; + hiddenForm.appendChild( hiddenType ); + + // Whether exports column as locale neutral + var oLocaleNeutral = $( 'exportColumnLocaleNeutral' ); + var hiddenLocaleNeutral = document.createElement( 'input' ); + hiddenLocaleNeutral.type = 'hidden'; + hiddenLocaleNeutral.name = Constants.PARAM_LOCALENEUTRAL; + if( oLocaleNeutral && oLocaleNeutral.checked ) + hiddenLocaleNeutral.value = "true"; + else + hiddenLocaleNeutral.value = "false"; + hiddenForm.appendChild( hiddenLocaleNeutral ); + + var tmpSubmit = document.createElement( 'input' ); + tmpSubmit.type = 'submit'; + tmpSubmit.value = 'TmpSubmit'; + hiddenForm.appendChild( tmpSubmit ); + + hiddenDiv.appendChild( hiddenForm ); + dialogContent.appendChild( hiddenDiv ); + tmpSubmit.click( ); + dialogContent.removeChild( hiddenDiv ); + }, + + /** + Called right before element is shown + */ + __preShow: function() + { + // disable the toolbar buttons + birtUtility.setButtonsDisabled ( "toolbar", true ); + + // disable the Navigation Bar buttons + birtUtility.setButtonsDisabled ( "navigationBar", true ); + }, + + /** + Called before element is hidden + */ + __preHide: function() + { + // enable the toolbar buttons + birtUtility.setButtonsDisabled ( "toolbar", false ); + + // enable the Navigation Bar buttons + birtUtility.setButtonsDisabled ( "navigationBar", false ); + } +} ); \ No newline at end of file Propchange: ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/dialog/BirtSimpleExportDataDialog.js ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/dialog/BirtSimpleExportDataDialog.js ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/dialog/BirtSimpleExportDataDialog.js ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/dialog/BirtTabedDialogBase.js URL: http://svn.apache.org/viewvc/ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/dialog/BirtTabedDialogBase.js?rev=825391&view=auto ============================================================================== --- ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/dialog/BirtTabedDialogBase.js (added) +++ ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/dialog/BirtTabedDialogBase.js Thu Oct 15 04:48:28 2009 @@ -0,0 +1,135 @@ +/****************************************************************************** + * Copyright (c) 2004 Actuate Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Actuate Corporation - Initial implementation. + *****************************************************************************/ + +/** + * BirtTabedDialogBase + * ... + */ +BirtTabedDialogBase = Class.create( ); + +BirtTabedDialogBase.prototype = Object.extend( new AbstractBaseDialog( ), +{ + /** + * Current tabs + */ + __tabs_caption : { }, + + /** + * Current sections + */ + __tabs_content : { }, + + /** + * Current tabs + */ + __current_tab : null, + + __neh_switchTab_closure : null, + __neh_hoverTab_closure : null, + + /** + * Initialization routine required by "ProtoType" lib. + * + * @return, void + */ + initialize : function( id ) + { + this.__initBase(id); + this.__z_index = 300; + + // TODO: need a better way to identify the dialog layout. + var oTabs = $( 'tabs' ); + var oDivs = $( 'aaacontent' ); + if ( oTabs && oDivs ) + { + var oCells = oTabs.getElementsByTagName( 'td' ); + var oTables = oDivs.getElementsByTagName( 'div' ); + + for ( var i = 0; i < oCells.length; i++ ) + { + this.__tabs_caption[ oCells[i].firstChild.data ] = oCells[i]; + this.__tabs_content[ oCells[i].firstChild.data ] = oTables[i]; + } + + this.__current_tab = oCells[0].firstChild.data; + } + + // Closures + this.__neh_switchTab_closure = this.__neh_switchTab.bindAsEventListener( this ); + this.__neh_hoverTab_closure = this.__neh_hoverTab.bindAsEventListener( this ); + + this.__initialize( id ); + }, + + /** + * Install native/birt event handlers. + * + * @id, toolbar id (optional since there is only one toolbar) + * @return, void + */ + __tabBase_installEventHandlers : function( id ) + { + // Tabs + if ( this.__tabs_caption ) + { + for ( var i in this.__tabs_caption ) + { + Event.observe( this.__tabs_caption[ i ], 'click', this.__neh_switchTab_closure, false ); + Event.observe( this.__tabs_caption[ i ], 'mouseover', this.__neh_hoverTab_closure, false ); + Event.observe( this.__tabs_caption[ i ], 'mouseout', this.__neh_hoverTab_closure, false ); + } + } + + this.__installEventHandlers( id ); + }, + + /** + * Handle native event 'click'. + * + * @event, incoming browser native event + * @return, void + */ + __neh_hoverTab : function( event ) + { + var oCell = Event.element( event ); + if ( this.__current_tab != oCell.firstChild.data ) + { + this.__tabs_caption[oCell.firstChild.data].style.backgroundColor = ( event.type == 'mouseover' )? "#4682b4" : "#dbe4ee"; + this.__tabs_caption[oCell.firstChild.data].style.color = ( event.type == 'mouseover' )? "white" : "black"; + } + }, + + /** + * Handle native event 'click'. + * + * @event, incoming browser native event + * @return, void + */ + __neh_switchTab : function( event ) + { + var oCell = Event.element( event ); + if ( this.__current_tab != oCell.firstChild.data ) + { + this.__tabs_caption[this.__current_tab].style.borderStyle = "outset"; + this.__tabs_caption[this.__current_tab].style.cursor = "hand"; + + this.__tabs_caption[oCell.firstChild.data].style.borderStyle = "inset"; + this.__tabs_caption[oCell.firstChild.data].style.cursor = "default"; + this.__tabs_caption[oCell.firstChild.data].style.backgroundColor = "#dbe4ee"; + this.__tabs_caption[oCell.firstChild.data].style.color = "black"; + + this.__tabs_content[this.__current_tab].style.display = "none"; + this.__tabs_content[oCell.firstChild.data].style.display = "block"; + + this.__current_tab = oCell.firstChild.data; + } + } +}); \ No newline at end of file Propchange: ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/dialog/BirtTabedDialogBase.js ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/dialog/BirtTabedDialogBase.js ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/dialog/BirtTabedDialogBase.js ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/report/AbstractBaseReportDocument.js URL: http://svn.apache.org/viewvc/ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/report/AbstractBaseReportDocument.js?rev=825391&view=auto ============================================================================== --- ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/report/AbstractBaseReportDocument.js (added) +++ ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/report/AbstractBaseReportDocument.js Thu Oct 15 04:48:28 2009 @@ -0,0 +1,372 @@ +/****************************************************************************** + * Copyright (c) 2004-2008 Actuate Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Actuate Corporation - Initial implementation. + *****************************************************************************/ + +/** + * AbstractBaseDocument + * ... + */ +AbstractBaseReportDocument = function( ) { }; + +AbstractBaseReportDocument.prototype = Object.extend( new AbstractReportComponent( ), +{ + __instance : null, + __has_svg_support : false, + __tocElement : null, + + /** + * Event handler closures. + */ + __neh_resize_closure : null, + __neh_select_closure : null, + __beh_toc_closure : null, + __beh_getPage_closure : null, + __beh_changeParameter_closure : null, + __rtl : null, + + __cb_bind : function( data ) + { + // set rtl only the first time + if ( this.__rtl == null ) + { + this.__rtl = false; + var oRtlElement = data.getElementsByTagName( 'rtl' ); + if ( oRtlElement && oRtlElement[0] && oRtlElement[0].firstChild ) + { + this.__rtl = ( "true" == oRtlElement[0].firstChild.data ); + } + } + + var documentViewElement = $("documentView"); + documentViewElement.style.direction = this.__rtl?"rtl":"ltr"; + var docObj = document.getElementById( "Document" ); + if ( docObj && BrowserUtility.isMozilla && !BrowserUtility.isFirefox3 ) + { + docObj.scrollLeft = this.__rtl?(docObj.offsetWidth + "px"):"0px"; + } + }, + + /** + * Local version of __cb_installEventHandlers. + */ + __local_installEventHandlers : function( id, children, bookmark ) + { + // jump to bookmark. + if ( bookmark ) + { + var obj = $( bookmark ); + if ( obj && obj.scrollIntoView ) + { + obj.scrollIntoView( true ); + } + } + }, + + /** + * Unregister any birt event handlers. + * + * @id, object id + * @return, void + */ + __local_disposeEventHandlers : function( id ) + { + }, + + /** + * Handle native event 'click'. + * + * @event, incoming browser native event + * @return, void + */ + __neh_resize : function( event ) + { + if ( !this.__updateContainerSize_closure ) + { + this.__updateContainerSize_closure = this.__updateContainerSize.bind( this ); + } + + if ( BrowserUtility.isIE6 || BrowserUtility.isIE7 ) + { + // delay resizing operation to the event queue + // else IE might override our changes with its calculated ones + setTimeout( this.__updateContainerSize_closure, 0); + } + else + { + this.__updateContainerSize(); + } + }, + + /** + * Updates the container size according to the window size. + */ + __updateContainerSize : function() + { + var tocWidth = 0; + if ( this.__tocElement && this.__tocElement.__instance ) + { + tocWidth = this.__tocElement.getWidth(); + } + + var width = BirtPosition.viewportWidth( ) - tocWidth - (BrowserUtility.isFirefox?6:4); + + // in IE, the width contains the border, unlike in other browsers + if ( BrowserUtility.isIE6 || BrowserUtility.isIE7 || + BrowserUtility.isOpera || BrowserUtility.isKHTML || BrowserUtility.isSafari ) + { + var containerLeft = 0; + // if viewer in rtl mode + if ( Constants.request.rtl ) + { + // if report in rtl mode + if ( birtReportDocument && birtReportDocument.__rtl ) + { + if ( BrowserUtility.isKHTML || BrowserUtility.isSafari ) + { + containerLeft = 0; + } + else + { + containerLeft = -tocWidth; + } + } + else + { + containerLeft = tocWidth; + } + + this.__instance.style.left = containerLeft + "px"; + } + else + { + this.__instance.style.left = "0px"; + } + } + if( width > 0 ) + this.__instance.style.width = width + "px"; + + var height = BirtPosition.viewportHeight( ) - this.__instance.offsetTop - 2; + if( height > 0 ) + this.__instance.style.height = height + "px"; + + this.__instance.style.left = containerLeft + "px"; + + if (BrowserUtility.isIE) { + var reportContainer = this.__instance.firstChild; + + if (reportContainer != null) { + var scrollBarWidth = BrowserUtility._getScrollBarWidth(reportContainer, width, height); + var containerWidth = "100%"; + + if (height < reportContainer.offsetHeight && width > scrollBarWidth) { + containerWidth = (width - scrollBarWidth) + "px"; + } + reportContainer.style.overflowX = "visible"; + reportContainer.style.overflowY = "visible"; + reportContainer.style.position = "relative"; + reportContainer.style.width = containerWidth; + } + } + }, + + /** + * Birt event handler for "getpage" event. + * + * @id, document id (optional since there's only one document instance) + * @return, true indicating server call + */ + __beh_parameter : function( id ) + { + birtParameterDialog.__cb_bind( ); + }, + + /** + * Birt event handler for "change parameter" event. + * + * @id, document id (optional since there's only one document instance) + * @return, true indicating server call + */ + __beh_changeParameter : function( id ) + { + // set task id + var taskid = birtUtility.setTaskId( ); + + if ( birtParameterDialog.__parameter > 0 ) + { + birtParameterDialog.__parameter.length = birtParameterDialog.__parameter.length - 1; + } + + // Get current page number + var pageNum = birtUtility.getPageNumber( ); + + if( pageNum > 0 ) + { + birtSoapRequest.addOperation( Constants.documentId, Constants.Document, + "ChangeParameter", null, birtParameterDialog.__parameter, + { name : Constants.PARAM_SVG, value : this.__has_svg_support? "true" : "false" }, + { name : Constants.PARAM_PAGE, value : pageNum }, + { name : Constants.PARAM_TASKID, value : taskid } ); + } + else + { + birtSoapRequest.addOperation( Constants.documentId, Constants.Document, + "ChangeParameter", null, birtParameterDialog.__parameter, + { name : Constants.PARAM_SVG, value : this.__has_svg_support? "true" : "false" }, + { name : Constants.PARAM_TASKID, value : taskid } ); + } + birtSoapRequest.setURL( soapURL ); + birtProgressBar.setRedirect( true ); + birtEventDispatcher.setFocusId( null ); // Clear out current focusid. + return true; + }, + + /** + * Handle change cascade parameter. + */ + __beh_cascadingParameter : function( id, object ) + { + // set task id + var taskid = birtUtility.setTaskId( ); + + birtSoapRequest.addOperation( Constants.documentId, Constants.Document, + "GetCascadingParameter", null, object, + { name : Constants.PARAM_TASKID, value : taskid } ); + birtSoapRequest.setURL( soapURL ); + birtEventDispatcher.setFocusId( null ); // Clear out current focusid. + return true; + }, + + /** + * Handle native event 'click'. + * + * @event, incoming browser native event + * @return, void + */ + __beh_toc : function( id ) + { + // resize document window + this.__neh_resize(); + }, + + /** + * Birt event handler for "getpage" event. + * + * @param id, document id (optional since there's only one document instance) + * @param object, pass some settings, for example: page,bookmark... + * @return, true indicating server call + */ + __beh_getPage : function( id, object ) + { + // set task id + var taskid = birtUtility.setTaskId( ); + + var url = soapURL; + // if set bookmark, delete the bookmark parameter in URL + if( object && object.name && object.name == Constants.PARAM_BOOKMARK ) + { + url = birtUtility.deleteURLParameter( url, Constants.PARAM_BOOKMARK ); + url = birtUtility.deleteURLParameter( url, Constants.PARAM_ISTOC ); + } + + birtSoapRequest.setURL( url ); + if ( object ) + { + birtSoapRequest.addOperation( Constants.documentId, Constants.Document, + "GetPage", null, + object, + { name : Constants.PARAM_SVG, value : this.__has_svg_support? "true" : "false" }, + { name : Constants.PARAM_TASKID, value : taskid } ); + } + else + { + birtSoapRequest.addOperation( Constants.documentId, Constants.Document, + "GetPage", null, + { name : Constants.PARAM_SVG, value : this.__has_svg_support? "true" : "false" }, + { name : Constants.PARAM_TASKID, value : taskid } ); + } + + birtEventDispatcher.setFocusId( null ); // Clear out current focusid. + birtProgressBar.setRedirect( true ); + return true; + }, + + /** + * Birt event handler for "getpage" event with collected parameters. + * + * @param id, document id (optional since there's only one document instance) + * @param object, pass some settings, for example: page... + * @return, true indicating server call + */ + __beh_getPageInit : function( id, object ) + { + // set task id + var taskid = birtUtility.setTaskId( ); + + // Get current page number + var pageNum = birtUtility.getPageNumber( ); + + birtSoapRequest.setURL( soapURL ); + if ( object ) + { + if( pageNum > 0 ) + { + birtSoapRequest.addOperation( Constants.documentId, Constants.Document, + "GetPage", null, birtParameterDialog.__parameter, + object, + { name : Constants.PARAM_SVG, value : this.__has_svg_support? "true" : "false" }, + { name : Constants.PARAM_PAGE, value : pageNum }, + { name : Constants.PARAM_TASKID, value : taskid } ); + } + else + { + birtSoapRequest.addOperation( Constants.documentId, Constants.Document, + "GetPage", null, birtParameterDialog.__parameter, + object, + { name : Constants.PARAM_SVG, value : this.__has_svg_support? "true" : "false" }, + { name : Constants.PARAM_TASKID, value : taskid } ); + } + } + else + { + if( pageNum > 0 ) + { + birtSoapRequest.addOperation( Constants.documentId, Constants.Document, + "GetPage", null, birtParameterDialog.__parameter, + { name : Constants.PARAM_SVG, value : this.__has_svg_support? "true" : "false" }, + { name : Constants.PARAM_PAGE, value : pageNum }, + { name : Constants.PARAM_TASKID, value : taskid } ); + } + else + { + birtSoapRequest.addOperation( Constants.documentId, Constants.Document, + "GetPage", null, birtParameterDialog.__parameter, + { name : Constants.PARAM_SVG, value : this.__has_svg_support? "true" : "false" }, + { name : Constants.PARAM_TASKID, value : taskid } ); + } + } + + birtEventDispatcher.setFocusId( null ); // Clear out current focusid. + birtProgressBar.setRedirect( true ); + return true; + }, + + /** + * Birt event handler for "print" event. + * + * @id, document id (optional since there's only one document instance) + * @return, true indicating server call + */ + __beh_export : function( id ) + { + birtSoapRequest.setURL( soapURL); + birtSoapRequest.addOperation( "Document", Constants.Document, "QueryExport", null ); + return true; + } +}); Propchange: ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/report/AbstractBaseReportDocument.js ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/report/AbstractBaseReportDocument.js ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/report/AbstractBaseReportDocument.js ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/report/AbstractReportComponent.js URL: http://svn.apache.org/viewvc/ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/report/AbstractReportComponent.js?rev=825391&view=auto ============================================================================== --- ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/report/AbstractReportComponent.js (added) +++ ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/report/AbstractReportComponent.js Thu Oct 15 04:48:28 2009 @@ -0,0 +1,200 @@ +/****************************************************************************** + * Copyright (c) 2004 Actuate Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Actuate Corporation - Initial implementation. + *****************************************************************************/ + +/** + * AbstractReportComponent. + * Base class for all UI components. + */ +AbstractReportComponent = function( ) { }; + +AbstractReportComponent.prototype = +{ + /** + * UI component html instance. + */ + __instance : null, + + /** + * Re-render ui object with new content. + * + * @id, ui object id + * @content, new html UI content + * @return, void + */ + __cb_render : function( id, content ) + { + var oDiv = $( id ); + + while( oDiv.childNodes.length > 0) + { + oDiv.removeChild(oDiv.firstChild); + } + + // workaround for IE. If content starts with script, + // append a hidden line to avoid ignore these scripts. + // Delete script attribute "defer" to avoid exec javascript twice + if( BrowserUtility.__isIE( ) ) + { + content = '<span style="display: none"> </span>' + content; + content = content.replace(/<script(.*)defer([^\s|^>]*)([^>]*)>/gi,'<script$1$3>'); + } + + var container = document.createElement( "div" ); + + container.innerHTML = content; + + // FIXME: Mozilla 1.7.12 produces an exception on the following line + // because the "content" variable contains some unrecognized parts + // see Bugzilla Bug 199998 + try + { + oDiv.appendChild( container ); + } + catch ( error ) + { + // ignore exception + } + + var scripts = container.getElementsByTagName( "script" ); + for( var i = 0; i < scripts.length; i++ ) + { + if( scripts[i].src ) + { + // workaround for IE, need append these scripts in head + if( BrowserUtility.__isIE( ) ) + { + var scriptObj = document.createElement( "script" ); + scriptObj.setAttribute( "type", "text/javascript" ); + scriptObj.setAttribute( "src", scripts[i].src ); + + var head = document.getElementsByTagName( "head" )[0]; + if( head ) + head.appendChild( scriptObj ); + } + } + else if ( scripts[i].innerHTML ) + { + // Internet Explorer has a funky execScript method that makes this easy + if ( window.execScript ) + window.execScript( scripts[i].innerHTML ); + } + } + + if ( BrowserUtility.__isSafari() || BrowserUtility.__isKHTML() ) + { + // add the styles explicitly into the head + var styles = container.getElementsByTagName("style"); + for ( var i = 0; i < styles.length; i++ ) + { + var style = styles[i]; + var styleContent = style.innerHTML; + if ( styleContent ) + { + birtUtility.addStyleSheet( styleContent ); + } + } + } + + // workaround for bug 165750, overflow-x and overflow-y only used in IE + if( BrowserUtility.__isIE( ) ) + { + container.style.overflowX = "visible"; + container.style.overflowY = "visible"; + } + + this.__postRender(id); + }, + + /** + * Called after the component content is rendered. + * + * @id, ui object id + * @return, void + */ + __postRender : function( id ) + { + //implementation is left to extending class + }, + + /** + * Install native/birt event handlers. + * + * @id, table object id + * @return, void + */ + __cb_installEventHandlers : function( id, children, bookmark, type ) + { + if ( this.__local_installEventHandlers ) + { + this.__local_installEventHandlers( id, children, bookmark, type ); + } + + var container = $( id ); + + container[ Constants.reportBase ] = ( type != 'Group' && type != 'ColumnInfo'); + container[ Constants.activeIds ] = [ ]; // Need to remember active children + container[ Constants.activeIdTypes ] = [ ]; // Need to remember active children types + + if ( !children ) + { + return; + } + + // Also need to take care the active children. + for( var i = 0; i < children.length; i++ ) + { + var oElementIds = children[i].getElementsByTagName( 'Id' ); + var oElementTypes = children[i].getElementsByTagName( 'Type' ); + + var birtObj = ReportComponentIdRegistry.getObjectForType( oElementTypes[0].firstChild.data ); + + if ( !birtObj || !birtObj.__cb_installEventHandlers ) + { + continue; + } + + container[ Constants.activeIds ].push( oElementIds[0].firstChild.data ); + container[ Constants.activeIdTypes ].push( oElementTypes[0].firstChild.data ); + + birtObj.__cb_installEventHandlers( oElementIds[0].firstChild.data, null, null, oElementTypes[0].firstChild.data ); + } + }, + + /** + * Unregister any birt event handlers. + * Remove local event listeners + * + * @id, object id + * @return, void + */ + __cb_disposeEventHandlers : function( id, type ) + { + if ( this.__local_disposeEventHandlers ) + { + this.__local_disposeEventHandlers( id, type ); + } + + var container = $( id ); + + var id = null; + while( container[ Constants.activeIds ].length > 0 ) + { + var id = container[ Constants.activeIds ].shift( ) + var type = container[ Constants.activeIdTypes ].shift( ); + var birtObj = ReportComponentIdRegistry.getObjectForType( type ); + if ( !birtObj || !birtObj.__cb_disposeEventHandlers ) + { + continue; + } + birtObj.__cb_disposeEventHandlers( id, type ); + } + } +} \ No newline at end of file Propchange: ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/report/AbstractReportComponent.js ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/report/AbstractReportComponent.js ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/report/AbstractReportComponent.js ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/report/BirtReportDocument.js URL: http://svn.apache.org/viewvc/ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/report/BirtReportDocument.js?rev=825391&view=auto ============================================================================== --- ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/report/BirtReportDocument.js (added) +++ ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/report/BirtReportDocument.js Thu Oct 15 04:48:28 2009 @@ -0,0 +1,239 @@ +/****************************************************************************** + * Copyright (c) 2004 Actuate Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Actuate Corporation - Initial implementation. + *****************************************************************************/ + +/** + * BirtReportDocument + * ... + */ +BirtReportDocument = Class.create( ); + +BirtReportDocument.prototype = Object.extend( new AbstractBaseReportDocument( ), +{ + /** + * Initialization routine required by "ProtoType" lib. + * + * @return, void + */ + initialize : function( id, tocElement ) + { + this.__instance = $( id ); + this.__tocElement = tocElement; + this.__neh_resize( ); + this.__has_svg_support = hasSVGSupport; + + // Prepare closures. + this.__neh_resize_closure = this.__neh_resize.bindAsEventListener( this ); + this.__beh_getPage_closure = this.__beh_getPage.bind( this ); + this.__beh_getPageInit_closure = this.__beh_getPageInit.bind( this ); + this.__beh_changeParameter_closure = this.__beh_changeParameter.bind( this ); + this.__beh_toc_closure = this.__beh_toc.bindAsEventListener( this ); + this.__beh_cacheParameter_closure = this.__beh_cacheParameter.bind( this ); + this.__beh_printServer_closure = this.__beh_printServer.bind( this ); + this.__beh_print_closure = this.__beh_print.bind( this ); + this.__beh_pdf_closure = this.__beh_pdf.bind( this ); + this.__beh_cancelTask_closure = this.__beh_cancelTask.bind( this ); + this.__beh_getPageAll_closure = this.__beh_getPageAll.bind( this ); + this.__beh_exportReport_closure = this.__beh_exportReport.bind( this ); + + Event.observe( window, 'resize', this.__neh_resize_closure, false ); + + birtEventDispatcher.registerEventHandler( birtEvent.__E_GETPAGE, this.__instance.id, this.__beh_getPage_closure ); + birtEventDispatcher.registerEventHandler( birtEvent.__E_GETPAGE_INIT, this.__instance.id, this.__beh_getPageInit_closure ); + birtEventDispatcher.registerEventHandler( birtEvent.__E_PARAMETER, this.__instance.id, this.__beh_parameter ); + birtEventDispatcher.registerEventHandler( birtEvent.__E_CHANGE_PARAMETER, this.__instance.id, this.__beh_changeParameter_closure ); + birtEventDispatcher.registerEventHandler( birtEvent.__E_CASCADING_PARAMETER, this.__instance.id, this.__beh_cascadingParameter ); + birtEventDispatcher.registerEventHandler( birtEvent.__E_TOC, this.__instance.id, this.__beh_toc_closure ); + birtEventDispatcher.registerEventHandler( birtEvent.__E_QUERY_EXPORT, this.__instance.id, this.__beh_export ); + birtEventDispatcher.registerEventHandler( birtEvent.__E_CACHE_PARAMETER, this.__instance.id, this.__beh_cacheParameter_closure ); + birtEventDispatcher.registerEventHandler( birtEvent.__E_PRINT, this.__instance.id, this.__beh_print_closure ); + birtEventDispatcher.registerEventHandler( birtEvent.__E_PRINT_SERVER, this.__instance.id, this.__beh_printServer_closure ); + birtEventDispatcher.registerEventHandler( birtEvent.__E_PDF, this.__instance.id, this.__beh_pdf_closure ); + birtEventDispatcher.registerEventHandler( birtEvent.__E_CANCEL_TASK, this.__instance.id, this.__beh_cancelTask_closure ); + birtEventDispatcher.registerEventHandler( birtEvent.__E_GETPAGE_ALL, this.__instance.id, this.__beh_getPageAll_closure ); + birtEventDispatcher.registerEventHandler( birtEvent.__E_EXPORT_REPORT, this.__instance.id, this.__beh_exportReport_closure ); + + birtGetUpdatedObjectsResponseHandler.addAssociation( "Docum", this ); + + // TODO: rename it to birt event + this.__cb_installEventHandlers( id ); + }, + + /** + * Birt event handler for "cache parameter" event. + * + * @id, document id (optional since there's only one document instance) + * @return, true indicating server call + */ + __beh_cacheParameter : function( id ) + { + if ( birtParameterDialog.__parameter > 0 ) + { + birtParameterDialog.__parameter.length = birtParameterDialog.__parameter.length - 1; + } + birtSoapRequest.addOperation( Constants.documentId, Constants.Document, + "CacheParameter", null, birtParameterDialog.__parameter ); + birtSoapRequest.setURL( soapURL ); + birtEventDispatcher.setFocusId( null ); // Clear out current focusid. + return true; + }, + + /** + * Birt event handler for "PrintServer" event. + * + * @id, document id (optional since there's only one document instance) + * @return, true indicating server call + */ + __beh_printServer : function( id ) + { + birtPrintReportServerDialog.__cb_bind( ); + }, + + /** + * Birt event handler for "print" event. + * + * @id, document id (optional since there's only one document instance) + * @return, true indicating server call + */ + __beh_print : function( id ) + { + birtPrintReportDialog.__cb_bind( ); + }, + + /** + * Birt event handler for "pdf" event. + * + * @id, document id (optional since there's only one document instance) + * @return, true indicating server call + */ + __beh_pdf : function( id ) + { + var docObj = document.getElementById( "Document" ); + if ( !docObj || birtUtility.trim( docObj.innerHTML ).length <= 0) + { + alert ( Constants.error.generateReportFirst ); + return; + } + else + { + var divObj = document.createElement( "DIV" ); + document.body.appendChild( divObj ); + divObj.style.display = "none"; + + var formObj = document.createElement( "FORM" ); + divObj.appendChild( formObj ); + + // Replace "html" to "pdf" + var action = soapURL; + var reg = new RegExp( "([&|?]{1}__format\s*)=([^&|^#]*)", "gi" ); + if( action.search( reg ) < 0 ) + { + action = action + "&__format=pdf"; + } + else + { + action = action.replace( reg, "$1=pdf" ); + } + + // Force "__overwrite" as false + reg = new RegExp( "([&|?]{1}__overwrite\s*)=([^&|^#]*)", "gi" ); + if( action.search( reg ) < 0 ) + { + action = action + "&__overwrite=false"; + } + else + { + action = action.replace( reg, "$1=false" ); + } + + formObj.action = action; + formObj.method = "post"; + formObj.submit( ); + } + }, + + /** + * Birt event handler for "CancelTask" event. + * + * @id, document id (optional since there's only one document instance) + * @return, true indicating server call + */ + __beh_cancelTask : function( id, object ) + { + birtSoapRequest.addOperation( Constants.documentId, Constants.Document, "CancelTask", null, object ); + birtSoapRequest.setURL( soapURL ); + birtEventDispatcher.setFocusId( null ); // Clear out current focusid. + return true; + }, + + /** + * Birt event handler for "GetPageAll" event. + * + * @id, document id (optional since there's only one document instance) + * @return, true indicating server call + */ + __beh_getPageAll : function( id, object ) + { + // set task id + var taskid = birtUtility.setTaskId( ); + + if( object ) + { + birtSoapRequest.addOperation( Constants.documentId, Constants.Document, "GetPageAll", + null, birtParameterDialog.__parameter, object, + { name : Constants.PARAM_SVG, value : this.__has_svg_support? "true" : "false" }, + { name : Constants.PARAM_TASKID, value : taskid } ); + } + else + { + birtSoapRequest.addOperation( Constants.documentId, Constants.Document, "GetPageAll", + null, birtParameterDialog.__parameter, + { name : Constants.PARAM_SVG, value : this.__has_svg_support? "true" : "false" }, + { name : Constants.PARAM_TASKID, value : taskid } ); + } + birtSoapRequest.setURL( soapURL ); + birtEventDispatcher.setFocusId( null ); // Clear out current focusid. + birtProgressBar.setRedirect( true ); + return true; + }, + + /** + * Birt event handler for "ExportReport" event. + * + * @id, document id (optional since there's only one document instance) + * @return, true indicating server call + */ + __beh_exportReport : function( id ) + { + birtExportReportDialog.__cb_bind( ); + }, + + /** + * Called after the component content is rendered. + * + * @id, ui object id + * @return, void + */ + __postRender : function( id ) + { + // ensures that the rendered component is the report document + if ( id == "Document" ) + { + var docObj = document.getElementById( id ); + if ( docObj ) + { + // set document scrollbar position to the top + docObj.scrollTop = "0px"; + this.__neh_resize(); + } + } + } + +}); \ No newline at end of file Propchange: ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/report/BirtReportDocument.js ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/report/BirtReportDocument.js ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/report/BirtReportDocument.js ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/report/ReportComponentIdRegistry.js URL: http://svn.apache.org/viewvc/ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/report/ReportComponentIdRegistry.js?rev=825391&view=auto ============================================================================== --- ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/report/ReportComponentIdRegistry.js (added) +++ ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/report/ReportComponentIdRegistry.js Thu Oct 15 04:48:28 2009 @@ -0,0 +1,128 @@ +/****************************************************************************** + * Copyright (c) 2004 Actuate Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Actuate Corporation - Initial implementation. + *****************************************************************************/ + +/** + * Class ReportComponentIdRegistry + */ +ReportComponentIdRegistry = +{ + types: + { + DOCUMENT : null, + TABLE : null, + LABEL : null, + CHART : null, + TABLE_T : null, + LABEL_T : null, + CHART_T : null + }, + + ids: {}, + + getDocumentType : function( ) + { + return 'DOCUMENT'; + }, + + getTableType : function( ) + { + return 'TABLE'; + }, + + getLabelType : function( ) + { + return 'LABEL'; + }, + + getChartType : function( ) + { + return 'CHART'; + }, + + getTemplateTableType : function( ) + { + return 'TABLE_T'; + }, + + getTemplateLabelType : function( ) + { + return 'LABEL_T'; + }, + + getTemplateChartType : function( ) + { + return 'CHART_T'; + }, + + getTypeForId : function( id ) + { + if ( this.ids[id] ) + { + return this.ids[id]; + } + return null; + }, + + setHandlerObjectForType : function( object, type ) + { + for ( var i in this.types ) + { + if ( i == type ) + { + this.types[i] = object; + return; + } + } + }, + + getObjectForId : function( id ) + { + var type = this.getTypeForId( id ); + if ( type ) + { + return this.types[type]; + } + return null; + }, + + getObjectForType : function( type ) + { + if ( type ) + { + if ( type.toUpperCase( ) == 'Group'.toUpperCase( ) + || type.toUpperCase( ) == 'ColumnInfo'.toUpperCase( ) ) + { + return this.types['TABLE']; + } + else + { + return this.types[type.toUpperCase( )]; + } + } + + return null; + + }, + + addId : function( id, type ) + { + this.ids[id] = type; + }, + + removeId : function( id ) + { + if ( this.ids[id] ) + { + this.ids[id] = null; + delete this.ids[id]; + } + } +}; Propchange: ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/report/ReportComponentIdRegistry.js ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/report/ReportComponentIdRegistry.js ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/report/ReportComponentIdRegistry.js ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/utility/BirtPosition.js URL: http://svn.apache.org/viewvc/ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/utility/BirtPosition.js?rev=825391&view=auto ============================================================================== --- ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/utility/BirtPosition.js (added) +++ ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/utility/BirtPosition.js Thu Oct 15 04:48:28 2009 @@ -0,0 +1,56 @@ +/****************************************************************************** + * Copyright (c) 2004 Actuate Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Actuate Corporation - Initial implementation. + *****************************************************************************/ + +/** + * BirtPosition. + * We could extend Position from Ruby. + */ +var BirtPosition = +{ + viewportHeight: function( ) + { + if (window.innerHeight!=window.undefined) return window.innerHeight; + if (document.compatMode=='CSS1Compat') return document.documentElement.clientHeight; + if (document.body) return document.body.clientHeight; + return window.undefined; + }, + + viewportWidth: function( ) + { + if (window.innerWidth!=window.undefined) return window.innerWidth; + if (document.compatMode=='CSS1Compat') return document.documentElement.clientWidth; + if (document.body) return document.body.clientWidth; + return window.undefined; + }, + + center: function( ) + { + var element = $( arguments[0] ); + if ( !element ) return; + + var scTop = parseInt( document.documentElement.scrollTop, 10 ); + var scLeft = parseInt( document.documentElement.scrollLeft, 10 ); + + element.style.top = ( scTop + ( ( this.viewportHeight( ) - element.offsetHeight ) / 2 ) ) + "px"; + element.style.left = ( scLeft + ( ( this.viewportWidth( ) - element.offsetWidth ) / 2 ) ) + "px"; + }, + + move: function( element, x, y ) + { + if ( !element ) return; + + var scTop = parseInt( document.documentElement.scrollTop, 10 ); + var scLeft = parseInt( document.documentElement.scrollLeft, 10 ); + + element.style.top = scTop + y + "px"; + element.style.left = scLeft + x + "px"; + } +} \ No newline at end of file Propchange: ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/utility/BirtPosition.js ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/utility/BirtPosition.js ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/utility/BirtPosition.js ------------------------------------------------------------------------------ svn:mime-type = text/plain |
Free forum by Nabble | Edit this page |