Added: ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/taglib/CascadingParameter.js
URL: http://svn.apache.org/viewvc/ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/taglib/CascadingParameter.js?rev=825391&view=auto ============================================================================== --- ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/taglib/CascadingParameter.js (added) +++ ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/taglib/CascadingParameter.js Thu Oct 15 04:48:28 2009 @@ -0,0 +1,193 @@ +/****************************************************************************** + * 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. + *****************************************************************************/ + +/** + * Utility functions for BIRT JSP Cascading parameter tag. + */ + +CascadingParameter = Class.create( ); + +CascadingParameter.prototype = +{ + __active : false, + __requesterId : '', + __parameter : null, + __paramNames : null, + __group : null, + __data : null, + __targetId : '', + __action : null, + + /** + * Initialization routine required by "ProtoType" lib. + * @return, void + */ + initialize : function( id, parameter, names, group ) + { + this.__requesterId = id; + this.__parameter = parameter; + this.__paramNames = names; + this.__group = group; + this.__data = new Array( ); + + this.__initialize( ); + }, + + /** + * Initialize cascading parameter + * + * @return, void + */ + __initialize : function( ) + { + var oDiv = $( this.__requesterId ); + if( !oDiv ) return; + + var forms = oDiv.getElementsByTagName( "FORM" ); + if( !forms || forms.length <= 0 ) return; + this.__action = forms[0].action; + }, + + /** + * Insert a option into select + * + * @param, list + * @param, index + * @param, text + * @param, value + * @return, void + */ + __insertOption : function( list, index, text, value ) + { + var i = 0; + for ( i = list.options.length; i > index; i-- ) + { + list.options[i] = new Option( list.options[i-1].text, list.options[i-1].value ); + } + + list.options[index] = new Option( text, value ); + }, + + /** + * return action string + * + * @return, action + */ + getAction : function( ) + { + return this.__action; + }, + + /** + * process to get cascading parameter + * @return, void + */ + process : function( ) + { + if( !this.__group || !this.__paramNames ) return; + + // If target select doesn't exist, return + var targetName = this.__paramNames[ this.__paramNames.length -1 ]; + this.__targetId = this.__group.getParameterIdByName( targetName ); + var target = $( this.__targetId ); + if( !target ) return; + + for( var i=0; i<this.__paramNames.length - 1; i++ ) + { + this.__data[i] = {}; + + var id = this.__group.getParameterIdByName( this.__paramNames[i] ); + var radioSelectId = id + "_radio_select"; + if( !$( radioSelectId ) || $( radioSelectId ).checked ) + { + var label = $( id ).text; + if( label == Constants.nullValue ) + { + this.__data[i].name = Constants.PARAM_ISNULL; + this.__data[i].value = this.__paramNames[i]; + } + else + { + this.__data[i].name = this.__paramNames[i]; + this.__data[i].value = $( id ).value; + } + } + else + { + var inputTextId = id + "_input"; + if( $( inputTextId ) ) + { + this.__data[i].name = this.__paramNames[i]; + this.__data[i].value = $( inputTextId ).value; + } + } + } + + // Set task id + var taskid = birtUtility.setTaskId( ); + birtSoapRequest.addOperation( Constants.documentId, Constants.Document,'GetCascadingParameter',null, + this.__data,{ name : Constants.PARAM_TASKID, value : taskid } ); + birtSoapRequest.setURL( this.__action ); + + if ( !birtSoapRequest.getURL( ) ) return; + + this.__active = true; + progressBar.__start( ); + + // Set cascading parameter group + soapResponseHelper.setParameterGroup( this.__group ); + + //workaround for Bugzilla Bug 144598. Add request header "Connection" as "keep-alive" + var myAjax = new Ajax.Request( birtSoapRequest.getURL( ), { method: 'post', postBody: birtSoapRequest.__xml_document, + onSuccess: this.responseHandler, onFailure: this.invalidResponseHandler, + requestHeaders: ['Content-type', 'text/xml; charset=utf-8', 'SOAPAction', '""', 'request-type', 'SOAP', 'Connection', 'keep-alive' ] } ); + + birtSoapRequest.reset( ); + }, + + /** + * Callback function triggered when reponse is ready, status is 200. + * + * @request, httpXmlRequest instance + * @return, void + */ + responseHandler: function( request ) + { + if ( request.responseXML && request.responseXML.documentElement ) + { + soapResponseHelper.processCascadingParameter( request.responseXML.documentElement ); + } + + progressBar.__stop( ); + this.__active = false; + }, + + /** + * Callback function triggered when reponse is ready status is not 200. + * Process any http (non-200) errors. Note this is not exception from + * server side. + * + * @request, httpXmlRequest instance + * @return, void + */ + invalidResponseHandler: function( request ) + { + if ( request.responseXML && request.responseXML.documentElement ) + { + soapResponseHelper.processCascadingParameter( request.responseXML.documentElement ); + } + + progressBar.__stop( ); + this.__active = false; + }, + + noComma : "" //just to avoid javascript syntax errors +} \ No newline at end of file Propchange: ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/taglib/CascadingParameter.js ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/taglib/CascadingParameter.js ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/taglib/CascadingParameter.js ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/taglib/ParameterDefinition.js URL: http://svn.apache.org/viewvc/ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/taglib/ParameterDefinition.js?rev=825391&view=auto ============================================================================== --- ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/taglib/ParameterDefinition.js (added) +++ ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/taglib/ParameterDefinition.js Thu Oct 15 04:48:28 2009 @@ -0,0 +1,120 @@ +/****************************************************************************** + * 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. + *****************************************************************************/ + +/** + * Parameter definition. + */ + +ParameterDefinition = Class.create( ); + +ParameterDefinition.prototype = +{ + __id : null, + __name : null, + __isRequired : null, + __value : null, + __displayText : null, + + /** + * Initialization routine required by "ProtoType" lib. + * @return, void + */ + initialize : function( id, name ) + { + this.__id = id; + this.__name = name; + }, + + /** + * get parameter id + * + * @return, id + */ + getId : function( ) + { + return this.__id; + }, + + /** + * get parameter name + * + * @return, name + */ + getName : function( ) + { + return this.__name; + }, + + /** + * get parameter value + * + * @return, value + */ + getValue : function( ) + { + return this.__value; + }, + + /** + * get parameter display text + * + * @return, displayText + */ + getDisplayText : function( ) + { + return this.__displayText; + }, + + /** + * set value + * + * @param, value + * @return, void + */ + setValue : function( value ) + { + this.__value = value; + }, + + /** + * set display Text + * + * @param, displayText + * @return, void + */ + setValue : function( displayText ) + { + this.__displayText = displayText; + }, + + /** + * set isRequired + * + * @param, isRequired + * @return, void + */ + setRequired : function( isRequired ) + { + this.__isRequired = isRequired; + }, + + /** + * get isRequired + * + * @return, isRequired + */ + isRequired : function( ) + { + return this.__isRequired; + }, + + noComma : "" //just to avoid javascript syntax errors +} \ No newline at end of file Propchange: ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/taglib/ParameterDefinition.js ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/taglib/ParameterDefinition.js ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/taglib/ParameterDefinition.js ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/taglib/ParameterGroup.js URL: http://svn.apache.org/viewvc/ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/taglib/ParameterGroup.js?rev=825391&view=auto ============================================================================== --- ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/taglib/ParameterGroup.js (added) +++ ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/taglib/ParameterGroup.js Thu Oct 15 04:48:28 2009 @@ -0,0 +1,75 @@ +/****************************************************************************** + * 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. + *****************************************************************************/ + +/** + * Utility functions for Parameter Group. + */ +ParameterGroup = Class.create( ); + +ParameterGroup.prototype = +{ + __group : null, + + /** + * Initialization routine required by "ProtoType" lib. + * @return, void + */ + initialize : function( ) + { + this.__group = new Array( ); + }, + + /** + * Add parameter into group + * + * @param, parameter + * @return, void + */ + addParameter : function( parameter ) + { + var len = this.__group.length; + this.__group[len] = {}; + this.__group[len].name = parameter.getName( ); + this.__group[len].value = parameter; + }, + + /** + * Get paramter id by name + * + * @param, parameter + * @return, void + */ + getParameterIdByName : function( name ) + { + for( var i = 0; i < this.__group.length; i++ ) + { + if( this.__group[i].name == name ) + { + if( this.__group[i].value ) + return this.__group[i].value.getId( ); + } + } + + return null; + }, + + /** + * empty parameter group + * + * @return, void + */ + empty : function( ) + { + this.__group = new Array( ); + }, + + noComma : "" //just to avoid javascript syntax errors +} \ No newline at end of file Propchange: ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/taglib/ParameterGroup.js ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/taglib/ParameterGroup.js ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/taglib/ParameterGroup.js ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/taglib/ProgressBar.js URL: http://svn.apache.org/viewvc/ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/taglib/ProgressBar.js?rev=825391&view=auto ============================================================================== --- ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/taglib/ProgressBar.js (added) +++ ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/taglib/ProgressBar.js Thu Oct 15 04:48:28 2009 @@ -0,0 +1,307 @@ +/****************************************************************************** + * 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. + *****************************************************************************/ + +/** + * Progress bar for JSP tag + */ +ProgressBar = Class.create( ); +ProgressBar.prototype = +{ + /** + * UI component html instance. + */ + __instance : null, + + /** + * SOAP action handler + */ + __handler : null, + + /** + * Latency that will trigger the progress bar. + */ + __interval : 300, + + /** + * Timer instance. + */ + __timer : null, + + /** + * mask instance. + */ + __mask : null, + + /** + * Closures + */ + __cb_bind_closure : null, + + /** + * Event handler for click 'cancel' button + */ + __neh_click_closure : null, + + /** + * 'Cancel' button container + */ + __cancel_button : 'cancelTaskButton', + + /** + * The input control to save 'taskid' + */ + __task_id : 'taskid', + + /** + * Initialization routine required by "ProtoType" lib. + * @return, void + */ + initialize : function( id, maskId ) + { + this.__instance = $( id ); + this.__mask = this.__create_mask( maskId ); + this.__cb_bind_closure = this.__cb_bind.bindAsEventListener( this ); + this.__neh_click_closure = this.__neh_click.bindAsEventListener( this ); + + this.__installEventHandlers( id ); + }, + + /** + * Set action handler + * + * @return, void + */ + setHandler : function( handler ) + { + this.__handler = handler; + }, + + /** + * Binding data to the dialog UI. Data includes zoom scaling factor. + * + * @return, void + */ + __cb_bind : function( ) + { + if( !this.__handler ) return; + + if( this.__handler.__active ) + { + this.__timer = window.setTimeout( this.__cb_bind_closure, this.__interval ); + this.__l_show( ); + } + else + { + window.clearTimeout( this.__timer ); + this.__l_hide( ); + } + }, + + /** + * Install native/birt event handlers. + * + * @id, response id + * @return, void + */ + __installEventHandlers : function( id ) + { + var oCancel = this.__loc_cancel_button( ); + if( oCancel ) + Event.observe( oCancel, 'click', this.__neh_click_closure, false ); + }, + + /** + * Install native/birt event handlers. + * + * @id, response id + * @return, void + */ + __start : function( ) + { + // check taskid + var taskid = birtUtility.getTaskId( ); + if( taskid.length > 0 ) + { + // if taskid existed, show 'Cancel' button + this.__l_show_cancel_button( ); + + // enable 'cancel' button + var oCancel = this.__loc_cancel_button( ); + if( oCancel ) + oCancel.disabled = false; + } + else + { + // hide 'Cancel' button + this.__l_hide_cancel_button( ); + } + + this.__timer = window.setTimeout( this.__cb_bind_closure, this.__interval ); + }, + + /** + * Install native/birt event handlers. + * + * @id, response id + * @return, void + */ + __stop : function( ) + { + window.clearTimeout( this.__timer ); + this.__l_hide( ); + + // clear taskid + birtUtility.clearTaskId( ); + }, + + /** + * Create progress bar mask. + * + * @return, __mask + */ + __create_mask : function( maskId ) + { + var oMask = $( maskId ); + if( !oMask ) return null; + + oMask.style.position = 'absolute'; + oMask.style.top = '0px'; + oMask.style.left = '0px'; + oMask.style.width = '50%'; + var height = BirtPosition.viewportHeight( ); + oMask.style.height = height + 'px'; + oMask.style.backgroundColor = '#dbe4ee'; + oMask.style.filter = 'alpha( opacity = 0.0 )'; + oMask.style.opacity = '.0'; + oMask.scrolling = 'no'; + oMask.marginHeight = '0px'; + oMask.marginWidth = '0px'; + oMask.style.display = 'none'; + oMask.style.MozOpacity = 0; + + return oMask; + }, + + /** + * Show progress bar. + */ + __l_show : function( ) + { + Element.show( this.__mask, this.__instance ); + BirtPosition.center( this.__instance ); + }, + + /** + * Hide progress bar. + */ + __l_hide : function( ) + { + Element.hide( this.__instance, this.__mask ); + }, + + /** + * Returns 'cancel' button + * @return, INPUT + */ + __loc_cancel_button: function( ) + { + var oIEC = this.__instance.getElementsByTagName( "input" ); + var oCancel; + if( oIEC && oIEC.length > 0 ) + { + for( var i = 0 ; i < oIEC.length; i++ ) + { + if( oIEC[i].type == 'button' ) + { + oCancel = oIEC[i]; + break; + } + } + } + + return oCancel; + }, + + /** + * Handle click "Cancel" button. + * + * @event, incoming browser native event + * @return, void + */ + __neh_click: function( event ) + { + var oTaskId = document.getElementById( this.__task_id ); + if( oTaskId && window.confirm( "Do you want to cancel current task?" ) ) + { + Event.element( event ).disabled = true; + + // cancel task + birtSoapRequest.addOperation( Constants.documentId, Constants.Document, "CancelTask", null, { name : Constants.PARAM_TASKID, value : oTaskId.value } ); + birtSoapRequest.setURL( this.__handler.getAction( ) ); + + if ( !birtSoapRequest.getURL( ) ) return; + + var myAjax = new Ajax.Request( birtSoapRequest.getURL( ), { method: 'post', postBody: birtSoapRequest.__xml_document, + onSuccess: this.responseHandler, onFailure: this.invalidResponseHandler, + requestHeaders: ['Content-type', 'text/xml; charset=utf-8', 'SOAPAction', '""', 'request-type', 'SOAP', 'Connection', 'keep-alive' ] } ); + + birtSoapRequest.reset( ); + } + }, + + /** + * Callback function triggered when reponse is ready, status is 200. + * + * @request, httpXmlRequest instance + * @return, void + */ + responseHandler: function( request ) + { + progressBar.__stop( ); + }, + + /** + * Callback function triggered when reponse is ready status is not 200. + * Process any http (non-200) errors. Note this is not exception from + * server side. + * + * @request, httpXmlRequest instance + * @return, void + */ + invalidResponseHandler: function( request ) + { + progressBar.__stop( ); + }, + + /** + * Show "Cancel" button. + * + * @return, void + */ + __l_show_cancel_button: function( ) + { + var container = document.getElementById( this.__cancel_button ); + if( container ) + container.style.display = 'block'; + }, + + /** + * Hide "Cancel" button. + * + * @return, void + */ + __l_hide_cancel_button: function( ) + { + var container = document.getElementById( this.__cancel_button ); + if( container ) + container.style.display = 'none'; + } +} \ No newline at end of file Propchange: ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/taglib/ProgressBar.js ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/taglib/ProgressBar.js ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/taglib/ProgressBar.js ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/taglib/SoapResponseHelper.js URL: http://svn.apache.org/viewvc/ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/taglib/SoapResponseHelper.js?rev=825391&view=auto ============================================================================== --- ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/taglib/SoapResponseHelper.js (added) +++ ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/taglib/SoapResponseHelper.js Thu Oct 15 04:48:28 2009 @@ -0,0 +1,155 @@ +/****************************************************************************** + * 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. + *****************************************************************************/ + +/** + * Helper to handle soap response + */ +SoapResponseHelper = Class.create( ); + +SoapResponseHelper.prototype = +{ + __parameterGroup : null, + + /** + * Initialization routine required by "ProtoType" lib. + * + * @return, void + */ + initialize: function( ) + { + }, + + /** + * Set current parameter group object + * + * @param, group cascading parameter group + * @return, void + */ + setParameterGroup : function( group ) + { + this.__parameterGroup = group; + }, + + /** + * Process the soap response, dispatcher message content to designated + * message handlers. + * + * @message, incoming soap message DOM + * @return, void + */ + processCascadingParameter : function( message ) + { + if( !message || !this.__parameterGroup ) return; + + //alert( birtSoapRequest.prettyPrintXML( message ) ); + var soapBody = message.getElementsByTagName( 'soapenv:Body' )[ 0 ]; + if ( !soapBody ) + { + soapBody = message.getElementsByTagName( 'Body' )[ 0 ]; + } + + if ( soapBody ) + { + for ( var i = 0; i < soapBody.childNodes.length; i++ ) + { + if ( soapBody.childNodes[i].nodeType == 1 ) // Need to use NodeType definition. + { + if ( soapBody.childNodes[i].tagName == 'soapenv:Fault' ) + { + // error message + this.__handleErrorMessage( soapBody.childNodes[i] ); + } + else + { + var datas = soapBody.childNodes[i].getElementsByTagName( 'Data' ); + if( !datas || datas.length<=0 ) return; + + var data = datas[0];//assume there is only one data + var cascade_param = data.getElementsByTagName( 'CascadeParameter' )[0];//assume there is only one cascadeparameter + var selectionLists = data.getElementsByTagName( 'SelectionList' ); + if ( !selectionLists ) + { + return; + } + + for ( var k = 0; k < selectionLists.length; k++ ) + { + var paramName = selectionLists[k].getElementsByTagName( 'Name' )[0].firstChild.data; + var selections = selectionLists[k].getElementsByTagName( 'Selections' ); + + var paramId = this.__parameterGroup.getParameterIdByName( paramName ); + var append_selection = document.getElementById( paramId ); + var len = append_selection.options.length; + + // Clear our selection list. + for( var i = 0, index = 0; i < len; i++ ) + { + append_selection.remove( index ); + } + + // Add new options based on server response. + for( var i = 0; i < selections.length; i++ ) + { + if ( !selections[i].firstChild ) + { + continue; + } + + var oOption = document.createElement( "OPTION" ); + var oLabel = selections[i].getElementsByTagName( 'Label' )[0].firstChild; + if( oLabel ) + oOption.text = oLabel.data; + else + oOption.text = ""; + + var oValue = selections[i].getElementsByTagName( 'Value' )[0].firstChild; + if( oValue ) + oOption.value = oValue.data; + else + oOption.value = ""; + append_selection.options[append_selection.options.length] = oOption; + } + } + } + } + } + } + + // reset parameter group + this.__parameterGroup = null; + }, + + /** + * handle error message + * + * @param, data incoming soap error message DOM + * @return, void + */ + __handleErrorMessage : function( data ) + { + if( !data ) return; + + // Prepare fault string (reason) + var faultStrings = data.getElementsByTagName( 'faultstring' ); + if ( faultStrings[0] && faultStrings[0].firstChild ) + { + alert( faultStrings[0].firstChild.data ); + } + else + { + alert( Constants.error.unknownError ); + } + }, + + noComma : "" //just to avoid javascript syntax errors +} + +var soapResponseHelper = new SoapResponseHelper( ); \ No newline at end of file Propchange: ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/taglib/SoapResponseHelper.js ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/taglib/SoapResponseHelper.js ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/taglib/SoapResponseHelper.js ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/app/AbstractBaseToc.js URL: http://svn.apache.org/viewvc/ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/app/AbstractBaseToc.js?rev=825391&view=auto ============================================================================== --- ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/app/AbstractBaseToc.js (added) +++ ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/app/AbstractBaseToc.js Thu Oct 15 04:48:28 2009 @@ -0,0 +1,471 @@ +/****************************************************************************** + * 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. + *****************************************************************************/ + +/** + * AbstractBaseToc + * ... + */ +AbstractBaseToc = function( ) { }; + +AbstractBaseToc.prototype = Object.extend( new AbstractUIComponent( ), +{ + __neh_click_closure : null, + __neh_resize_closure : null, + __beh_toc_closure : null, + __beh_toc_image_closure : null, + __neh_img_click_closure : null, + + __nodeid : '0', + __neh_item_mouse_over : null, + __neh_item_mouse_out : null, + __neh_item_click : null, + + __clickcount : 0, + + /** + * Install native/birt event handlers. + * + * @id, TOC id (optional since there is only one nav bar) + * @return, void + */ + __cb_installEventHandlers : function( ) + { + var oImgs = this.__instance.getElementsByTagName( "img" ); + if ( oImgs ) + { + for ( var i = 0; i < oImgs.length; i++ ) + { + Event.observe( oImgs[i], 'click', this.__neh_click_closure, false ); + } + } + // Birt event handler + Event.observe( window, 'resize', this.__neh_resize_closure, false ); + birtEventDispatcher.registerEventHandler( birtEvent.__E_TOC, this.__instance.id, this.__beh_toc_closure ); + birtEventDispatcher.registerEventHandler( birtEvent.__E_TOC_IMAGE_CLICK, this.__instance.id, this.__beh_toc_image_closure ); + }, + + /** + * Handle mouse over. + */ + __neh_mousemove : function ( event ) + { + var obj = Event.element( event ); + obj.style.filter = 'alpha( opacity=80)'; + obj.style.opacity = 0.8; + obj.style.MozOpacity = 0.8; + }, + + /** + * Handle mouse out. + */ + __neh_mouseout : function ( event ) + { + var obj = Event.element( event ); + obj.style.filter = 'alpha( opacity=100)'; + obj.style.opacity = 1; + obj.style.MozOpacity = 1; + }, + + /** + * Binding data to the TOC UI. Data includes a TOC tree. + * + * @data, data DOM tree (Schema TBD) + * @return, void + */ + __cb_bind : function( data ) + { + var datas = data.getElementsByTagName( 'Child' ); + var len = datas.length; + if( len == 0 ) + { + return ; + } + + var tableEle = document.createElement( "table" ); + tableEle.border = '0'; + tableEle.cellspacing = '0'; + tableEle.cellpadding = '0'; + var tbody = document.createElement( "tbody" ); + for( i = 0; i < len; i++ ) + { + var imgid = this.__nodeid + '_' + i ; + var tr1 = document.createElement( "tr" ); + var td11 = document.createElement( "td" ); + td11.valign = "top"; + td11.id = "td" + imgid; + + var tmp = datas[i]; + + var displaynames = tmp.getElementsByTagName( 'DisplayName' ); + var displayname = displaynames[0].firstChild; + var s_displayname = ""; + if( displayname ) + s_displayname = displayname.data; + + var isLeafs = tmp.getElementsByTagName( 'IsLeaf' ); + var img = document.createElement( "input" ); + img.type = "image"; + img.style.backgroundRepeat = 'no-repeat'; + img.style.paddingLeft = '0px'; + img.style.width = '8px'; + img.style.height = '8px'; + img.plusMinus = '+'; //default it is collapsed + img.id = imgid; + img.query = '0'; //default it needs to communicate with the server. + img.title = birtUtility.htmlDecode( s_displayname ); + + if ( isLeafs[0].firstChild.data == "false" ) + { + img.src = "birt/images/Expand.gif" ; + img.style.cursor = 'pointer'; + Event.observe( img, 'click', this.__neh_img_click_closure, false ); + } + else + { + img.src = "birt/images/Leaf.gif" ; + img.style.cursor = 'default'; + Event.observe( img, 'click', this.__neh_item_click, false ); + } + + Event.observe( img, 'keydown', this.__neh_item_click, false ); + + td11.width = "10px"; + td11.appendChild( img ); + + var td12 = document.createElement( "td" ); + td12.valign = "top"; + + var nodeIds = tmp.getElementsByTagName( 'Id' ); + img.nodeId = nodeIds[0].firstChild.data; + + var bookmarks = tmp.getElementsByTagName( 'Bookmark' ); + img.bookmark = bookmarks[0].firstChild.data; + + var tocitem = document.createElement( "div" ); + tocitem.title = birtUtility.htmlDecode( s_displayname ); + tocitem.id = 'span_' + imgid; + tocitem.innerHTML = s_displayname ? s_displayname : " "; + + var cssText = "cursor:pointer;border:0px;font-family:Verdana;font-size:9pt;background-color:#FFFFFF;overflow:visible;"; + var styles = tmp.getElementsByTagName( 'Style' ); + if( styles && styles.length > 0 ) + { + if( styles[0].firstChild ) + tocitem.style.cssText = cssText + styles[0].firstChild.data; + else + tocitem.style.cssText = cssText; + } + + td12.appendChild( tocitem ); + td12.noWrap = true; + + tr1.appendChild( td11 ); + tr1.appendChild( td12 ); + + var tr2 = document.createElement( "tr" ); + var td2 = document.createElement( "td" ); + td2.id = 'display' + imgid; + td2.style.paddingLeft = '16px'; + td2.style.display = 'none'; + td2.colSpan = 2; + tr2.appendChild( td2 ); + + tbody.appendChild( tr1 ); + tbody.appendChild( tr2 ); + + //observe the text so that when click the text ,we can expand or collapse the toc + Event.observe( tocitem, 'mouseover', this.__neh_item_mouse_over, false ); + Event.observe( tocitem, 'mouseout', this.__neh_item_mouse_out, false ); + Event.observe( tocitem, 'click', this.__neh_item_click, false ); + Event.observe( tocitem, 'keydown', this.__neh_item_click, false ); + } + tableEle.appendChild( tbody ); + var displayid = 'display' + this.__nodeid; + var ele= $( displayid ); + var childLength = ele.childNodes.length; + if ( childLength == 0 ) + { + ele.appendChild( tableEle ); + } + else + { + ele.replaceChild( tableEle, ele.childNodes[0] ); + } + + this.__neh_resize( ); // hack + }, + + /** + * when click the text ,also need to collapse or expand the toc + */ + __neh_text_click : function ( event ) + { + var clickElement = Event.element( event ); + var clickId = clickElement.id; + var imgid; + + if( clickElement.type == "image" ) + { + //get the img id + imgid = clickId; + + if( clickElement.src.indexOf( "Expand" ) > -1 ) + { + // keydown on Expand img + if( event.type == 'keydown' ) + { + if( event.keyCode == 39 ) + this.__neh_img_click( event ); + } + } + else if( clickElement.src.indexOf( "Collapse" ) > -1 ) + { + // keydown on Collapse img + if( event.type == 'keydown' ) + { + if( event.keyCode == 37 ) + this.__neh_img_click( event ); + } + } + } + else + { + //as the clicktextid is 'span_' + id, so we need to substr to get the imgid + var len = "span_".length; + imgid = clickId.substr( len ); + } + + if( event.type == 'keydown' ) + { + // Press "Enter" and "Space" + if( event.keyCode != 13 && event.keyCode != 32) + return; + } + + var clickImg = $( imgid ); + var query = clickImg.query; + var plusMinus = clickImg.plusMinus; + var bookmark = clickImg.bookmark; + + var params = new Array( ); + params[0] = { }; + params[0].name = Constants.PARAM_BOOKMARK; + params[0].value = bookmark; + + // passed bookmark name is not a TOC name. + params[1] = { }; + params[1].name = Constants.PARAM_ISTOC; + params[1].value = "false"; + + birtEventDispatcher.broadcastEvent( birtEvent.__E_GETPAGE, params ); + Event.stop(event); + }, + + /** + * when click the img , collpase or expand the toc + */ + __neh_img_click : function( event ) + { + var clickImg = Event.element( event ); + var query = clickImg.query; + var nodeId = clickImg.nodeId; + var clickId = this.__neh_click_process( clickImg, 0 ); + this.__neh_click_broadcast( query, nodeId ); + }, + + /** + * Process click. + */ + __neh_click_process : function ( clickImg, textClick ) + { + var clickId = clickImg.id; + this.__nodeid = clickId; + var plusMinus = clickImg.plusMinus; + var query = clickImg.query; + if( textClick == 1 && plusMinus != '+' ) + { + } + else + { + clickImg.src = this.__icon_change( plusMinus ); + } + + clickImg.plusMinus = this.__state_change( plusMinus ); + var displayid = 'display' + clickId; + var elem = $( displayid ); + if( ( textClick == 1 && plusMinus == '+' ) || textClick == 0 ) + { + if( clickImg.plusMinus == '+' ) + { + //collapse + elem.style.display = 'none'; + } + else + { + //expand + elem.style.display = ''; + } + } + + if( query == '0' ) + { + clickImg.query = '1'; + } + + return clickId; + }, + + /** + * Broadcast event. + */ + __neh_click_broadcast : function( query, realId ) + { + birtSoapRequest.setURL( soapURL ); + if( query == '0' ) + { + birtSoapRequest.addOperation( Constants.documentId, Constants.Document, + "GetToc", null, + { name : "realId", value : realId } ); + birtEventDispatcher.broadcastEvent( birtEvent.__E_TOC_IMAGE_CLICK ); + } + }, + + /* + * change the img plusMinus + * + to - + * - to + + * 0 to 0 + */ + __state_change : function ( plusMinus ) + { + var stat = '+'; + if( plusMinus == '+' ) + { + stat = '-'; + } + else if( plusMinus == '-' ) + { + stat = '+'; + } + else if( plusMinus == '0' ) + { + stat = '0'; + } + return stat; + }, + + /** + * change the img icon + */ + __icon_change : function ( plusMinus ) + { + var srcLoc = "birt/images/Expand.gif"; + if( plusMinus == '+' ) + { + srcLoc = "birt/images/Collapse.gif"; + } + else if( plusMinus == '-' ) + { + srcLoc = "birt/images/Expand.gif"; + } + + return srcLoc; + }, + + /** + * Handle native event 'click'. + * + * @event, incoming browser native event + * @return, void + */ + __neh_resize : function( event ) + { + //var width = BirtPosition.viewportWidth( ) - ( this.__instance.offsetLeft >= 250 ? 250 : 0 ) - 3; + //this.__instance.style.width = width + "px"; + var height = BirtPosition.viewportHeight( ) - this.__instance.offsetTop - 2; + this.__instance.style.height = height + "px"; + if ( rtl && + ( BrowserUtility.isIE6 || BrowserUtility.isIE7 || + BrowserUtility.isOpera || BrowserUtility.isKHTML || + BrowserUtility.isSafari + ) ) + { + this.__instance.style.position = "absolute"; + if ( birtReportDocument && birtReportDocument.__rtl ) + { + this.__instance.style.left = BirtPosition.viewportWidth( ) - this.getWidth(); + } + else + { + this.__instance.style.left = "0px"; + } + } + }, + + /** + * what is this? + */ + __beh_toc_image : function ( ) + { + return true; + }, + + /** + * Handle native event 'click'. + * + * @event, incoming browser native event + * @return, void + */ + __neh_click: function( event ) + { + var clickId = Event.element( event ).id; + var clickName = Event.element( event ).name; + + if ( Event.element( event ).name == 'close' ) + { + birtEventDispatcher.broadcastEvent( birtEvent.__E_TOC ); + } + + }, + + /** + * Handle native event 'click'. + * + * @event, incoming browser native event + * @return, void + */ + __beh_toc: function( id ) + { + Element.toggle( this.__instance ); + + this.__nodeid = '0'; + this.__clickcount = 0; + var displayid = 'display' + this.__nodeid; + + var root = $( displayid ); + if( root.query != 1 ) + { + root.query = '1'; + birtSoapRequest.setURL( soapURL ); + birtSoapRequest.addOperation( Constants.documentId, Constants.Document, "GetToc", null ); + return true; + } + else + { + root.query = '0'; + } + }, + + getWidth : function() + { + return this.__instance.offsetWidth; + } +} ); Propchange: ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/app/AbstractBaseToc.js ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/app/AbstractBaseToc.js ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/app/AbstractBaseToc.js ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/app/AbstractBaseToolbar.js URL: http://svn.apache.org/viewvc/ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/app/AbstractBaseToolbar.js?rev=825391&view=auto ============================================================================== --- ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/app/AbstractBaseToolbar.js (added) +++ ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/app/AbstractBaseToolbar.js Thu Oct 15 04:48:28 2009 @@ -0,0 +1,93 @@ +/****************************************************************************** + * 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. + *****************************************************************************/ + +/** + * AbstractBaseToolbar. + * ... + */ +AbstractBaseToolbar = function( ) { }; + +AbstractBaseToolbar.prototype = Object.extend( new AbstractUIComponent( ), +{ + /** + * Closure for native click event. + */ + __neh_click_closure : null, + + /** + * instance variable for preloading images + */ + toolbarImagesOff : null, + + /** + * instance variable for preloading images + */ + toolbarImagesOn : null, + + /** + * + */ + toolbarImageState : null, + + /** + * Loads image in off state and stores on and off src strings + * @param source + */ + preloadImages : function( source ) + { + var image; + var strFront; + var strExtension; + + image = new Image( ); + strFront = source.substring( 0, source.lastIndexOf( '.' ) ); + strExtension = source.substring( source.lastIndexOf( '.' ), source.length ); + image.src = strFront + "Off" + strExtension; + this.toolbarImagesOff.push( image.src ); + this.toolbarImagesOn.push( source ); + }, + + /** + * Determines if an image is in disabled state by examining name for "Off." + * @param name + */ + isEnabled : function( name ) + { + var i = name.indexOf( 'Off.' ); + if( i > -1 ) + { + return false; + } + return true; + }, + + /** + * Changes state from enabled to disabled + * @param button IMG + * @param enable true to enable, false to disable + */ + toggleButton : function( button, enable ) + { + if( enable ) + { + this.toolbarImageState[button.name] = true; + button.parentNode.className = "toolbarButton"; + Event.observe( button, 'click', this.__neh_click_closure, false ); + } + else + { + this.toolbarImageState[button.name] = false; + button.parentNode.className = "toolbarButtonOff"; + Event.stopObserving( button, 'click', this.__neh_click_closure, false ); + } + } +} +); \ No newline at end of file Propchange: ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/app/AbstractBaseToolbar.js ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/app/AbstractBaseToolbar.js ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/app/AbstractBaseToolbar.js ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/app/AbstractUIComponent.js URL: http://svn.apache.org/viewvc/ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/app/AbstractUIComponent.js?rev=825391&view=auto ============================================================================== --- ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/app/AbstractUIComponent.js (added) +++ ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/app/AbstractUIComponent.js Thu Oct 15 04:48:28 2009 @@ -0,0 +1,34 @@ +/****************************************************************************** + * 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. + *****************************************************************************/ + +/** + * AbstractUIComponentBase. + * Base class for all UI components. + */ +AbstractUIComponent = function( ) { }; + +AbstractUIComponent.prototype = +{ + /** + * UI component html instance. + */ + __instance : null, + + /** + * Initialization routine required by "ProtoType" lib. + * + * @return, void + */ + __initBase : function( id ) + { + this.__instance = $( id ); + } +} \ No newline at end of file Propchange: ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/app/AbstractUIComponent.js ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/app/AbstractUIComponent.js ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/app/AbstractUIComponent.js ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/app/BirtNavigationBar.js URL: http://svn.apache.org/viewvc/ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/app/BirtNavigationBar.js?rev=825391&view=auto ============================================================================== --- ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/app/BirtNavigationBar.js (added) +++ ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/app/BirtNavigationBar.js Thu Oct 15 04:48:28 2009 @@ -0,0 +1,252 @@ +/****************************************************************************** + * 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. + *****************************************************************************/ + +/** + * BirtNavigationBar + * ... + */ +BirtNavigationBar = Class.create( ); +BirtNavigationBar.prototype = Object.extend( new AbstractUIComponent( ), +{ + _IMAGE_PATH : "birt/images/", + _IMAGE_EXTENSION : ".gif", + _IMAGE_FIRST_PAGE : !rtl?"FirstPage":"LastPage", + _IMAGE_LAST_PAGE : !rtl?"LastPage":"FirstPage", + _IMAGE_PREVIOUS_PAGE : !rtl?"PreviousPage":"NextPage", + _IMAGE_NEXT_PAGE : !rtl?"NextPage":"PreviousPage", + _IMAGE_DISABLED_SUFFIX : "_disabled", + + /** + * Total number of pages. + */ + __oTotalPage : null, + + /** + * Current page number. + */ + __oPageNumber : null, + + /** + * Initialization routine required by "ProtoType" lib. + * @return, void + */ + initialize : function( id ) + { + this.__initBase( id ); + this.__oPageNumber = $( 'pageNumber' ); + this.__oTotalPage = $( 'totalPage' ); + this.__cb_installEventHandlers( ); + }, + + /** + * Binding data to the navigation bar UI. Data includes page number, total + * page number (optional). + * + * @data, data DOM tree (Schema TBD) + * @return, void + */ + __cb_bind : function( data ) + { + if ( !data ) + { + return; + } + + var oPageNumbers = data.getElementsByTagName( 'PageNumber' ); + if ( !oPageNumbers && !oPageNumbers[0] ) + { + return; + } + + this.__oPageNumber.innerHTML = oPageNumbers[0].firstChild.data; + + var oTotalPages = data.getElementsByTagName( 'TotalPage' ); + this.__oTotalPage.innerHTML = ( oTotalPages && oTotalPages[0] )? oTotalPages[0].firstChild.data : '+'; + + var pageNumber = parseInt( this.__oPageNumber.firstChild.data ); + var totalPage = ( this.__oTotalPage.firstChild.data == '+' )? '+' : parseInt( this.__oTotalPage.firstChild.data ); + + var oImgs = this.__instance.getElementsByTagName( "INPUT" ); + + var isFirstPage = !( pageNumber > 1 ); + var isLastPage = !( totalPage == '+' || pageNumber < totalPage ); + + oImgs[0].style.cursor = (!isFirstPage)? "pointer" : "default"; + oImgs[1].style.cursor = (!isFirstPage)? "pointer" : "default"; + oImgs[2].style.cursor = (!isLastPage)? "pointer" : "default"; + oImgs[3].style.cursor = (!isLastPage)? "pointer" : "default"; + + oImgs[0].src = this._getImageFileName( this._IMAGE_FIRST_PAGE, isFirstPage ); + oImgs[1].src = this._getImageFileName( this._IMAGE_PREVIOUS_PAGE, isFirstPage ); + oImgs[2].src = this._getImageFileName( this._IMAGE_NEXT_PAGE, isLastPage ); + oImgs[3].src = this._getImageFileName( this._IMAGE_LAST_PAGE, isLastPage ); + }, + + _getImageFileName : function( base, disabled ) + { + return this._IMAGE_PATH + base + ( disabled?this._IMAGE_DISABLED_SUFFIX:"" ) + this._IMAGE_EXTENSION; + }, + + /** + * Install native/birt event handlers. + * + * @id, navigation bar id (optional since there is only one nav bar) + * @return, void + */ + __cb_installEventHandlers : function( ) + { + var oImgs = this.__instance.getElementsByTagName( 'INPUT' ); + + if ( oImgs ) + { + for ( var i = 0; i < oImgs.length; i++ ) + { + if ( oImgs[i].type == 'image' ) + { + Event.observe( oImgs[i], 'click', this.__neh_click.bindAsEventListener( this ), false ); + } + } + } + + // Observe "keydown" event + this.keydown_closure = this.__neh_keydown.bindAsEventListener(this); + Event.observe($('gotoPage'), 'keydown', this.keydown_closure, false); + }, + + /** + * Handle press "Enter" key. + * + * @event, incoming browser native event + * @return, void + */ + __neh_keydown: function( event ) + { + // If press 'Enter' key + if( event.keyCode == 13 ) + { + this.__gotoGage( ); + Event.stop( event ); + } + }, + + /** + * Handle clicking 'Goto' event. + * + * @return, void + */ + __gotoGage : function( ) + { + var iPageNo = -1; + var totalPage = ( this.__oTotalPage.firstChild.data == '+' )? '+' : parseInt( this.__oTotalPage.firstChild.data ); + + var oGotoPage = $( 'gotoPage' ); + var pageNo = oGotoPage.value; + if ( pageNo != null && birtUtility.trim( pageNo ).length > 0 ) + { + iPageNo = parseInt( pageNo ); + } + if ( iPageNo > 0 && iPageNo <= totalPage ) + { + birtEventDispatcher.broadcastEvent( birtEvent.__E_GETPAGE, { name : Constants.PARAM_PAGE, value : oGotoPage.value } ); + } + else + { + alert( Constants.error.invalidPageNumber ); + oGotoPage.focus( ); + } + }, + + /** + * Handle native event 'click'. + * + * @event, incoming browser native event + * @return, void + */ + __neh_click : function( event ) + { + var pageNumber = parseInt( this.__oPageNumber.firstChild.data ); + var totalPage = ( this.__oTotalPage.firstChild.data == '+' )? '+' : parseInt( this.__oTotalPage.firstChild.data ); + + var oBtn = Event.element( event ); + if ( oBtn ) + { + switch ( oBtn.name ) + { + case 'first': + { + if ( pageNumber > 1 ) + { + birtEventDispatcher.broadcastEvent( birtEvent.__E_GETPAGE, { name : Constants.PARAM_PAGE, value : 1 } ); + } + break; + } + case 'previous': + { + if ( pageNumber > 1 ) + { + birtEventDispatcher.broadcastEvent( birtEvent.__E_GETPAGE, { name : Constants.PARAM_PAGE, value : pageNumber - 1 } ); + } + break; + } + case 'next': + { + if ( totalPage == '+' || pageNumber < totalPage ) + { + birtEventDispatcher.broadcastEvent( birtEvent.__E_GETPAGE, { name : Constants.PARAM_PAGE, value : pageNumber + 1 } ); + } + break; + } + case 'last': + { + if ( totalPage == '+' || pageNumber < totalPage ) + { + birtEventDispatcher.broadcastEvent( birtEvent.__E_GETPAGE, { name : Constants.PARAM_PAGE, value : totalPage } ); + } + break; + } + case 'goto': + { + this.__gotoGage( ); + break; + } + default: + { + break; + } + } + } + }, + + __get_current_page : function( ) + { + return this.__oPageNumber.innerHTML; + }, + + /** + * Load current page. Triggered by init. + */ + __init_page : function( ) + { + if( birtParameterDialog.collect_parameter( ) ) + { + if ( this.__oPageNumber.firstChild ) + { + var pageNumber = parseInt( this.__oPageNumber.firstChild.data ); + birtEventDispatcher.broadcastEvent( birtEvent.__E_GETPAGE_INIT, { name : Constants.PARAM_PAGE, value : pageNumber } ); + } + else + { + birtEventDispatcher.broadcastEvent( birtEvent.__E_GETPAGE_INIT ); + } + } + } +} +); \ No newline at end of file Propchange: ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/app/BirtNavigationBar.js ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/app/BirtNavigationBar.js ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/app/BirtNavigationBar.js ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/app/BirtProgressBar.js URL: http://svn.apache.org/viewvc/ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/app/BirtProgressBar.js?rev=825391&view=auto ============================================================================== --- ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/app/BirtProgressBar.js (added) +++ ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/app/BirtProgressBar.js Thu Oct 15 04:48:28 2009 @@ -0,0 +1,314 @@ +/****************************************************************************** + * 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. + *****************************************************************************/ + +/** + * BirtProgressBar + * ... + */ +BirtProgressBar = Class.create( ); +BirtProgressBar.prototype = Object.extend( new AbstractUIComponent( ), +{ + /** + * Latency that will trigger the progress bar. + */ + __interval : 300, + + /** + * Timer instance. + */ + __timer : null, + + /** + * mask instance. + */ + __mask : null, + + /** + * Closures + */ + __cb_bind_closure : null, + + /** + * Event handler for click 'cancel' button + */ + __neh_click_closure : null, + + /** + * 'Cancel' button container + */ + __cancel_button : 'cancelTaskButton', + + /** + * The input control to save 'taskid' + */ + __task_id : 'taskid', + + /** + * When click cancel button, indicate whether redirect a cancel page + */ + __redirect : false, + + /** + * Initialization routine required by "ProtoType" lib. + * @return, void + */ + initialize : function( id ) + { + this.__initBase( id ); + this.__mask = this.__create_mask( ); + this.__cb_bind_closure = this.__cb_bind.bindAsEventListener( this ); + this.__neh_click_closure = this.__neh_click.bindAsEventListener( this ); + + this.__installEventHandlers( id ); + }, + + /** + * Binding data to the dialog UI. Data includes zoom scaling factor. + * + * @return, void + */ + __cb_bind : function( ) + { + if( birtCommunicationManager.__active ) + { + this.__timer = window.setTimeout( this.__cb_bind_closure, this.__interval ); + this.__l_show( ); + } + else + { + window.clearTimeout( this.__timer ); + this.__l_hide( ); + } + }, + + /** + * Install native/birt event handlers. + * + * @id, response id + * @return, void + */ + __installEventHandlers : function( id ) + { + var oCancel = this.__loc_cancel_button( ); + if( oCancel ) + Event.observe( oCancel, 'click', this.__neh_click_closure, false ); + }, + + /** + * Install native/birt event handlers. + * + * @id, response id + * @return, void + */ + __start : function( ) + { + // check taskid + var taskid = birtUtility.getTaskId( ); + if( taskid.length > 0 ) + { + // if taskid existed, show 'Cancel' button + this.__l_show_cancel_button( ); + + // enable 'cancel' button + var oCancel = this.__loc_cancel_button( ); + if( oCancel ) + oCancel.disabled = false; + } + else + { + // hide 'Cancel' button + this.__l_hide_cancel_button( ); + } + + this.__timer = window.setTimeout( this.__cb_bind_closure, this.__interval ); + }, + + /** + * Install native/birt event handlers. + * + * @id, response id + * @return, void + */ + __stop : function( ) + { + window.clearTimeout( this.__timer ); + this.__l_hide( ); + + // clear taskid + birtUtility.clearTaskId( ); + }, + + /** + * Install native/birt event handlers. + * + * @id, response id + * @return, void + */ + __create_mask : function( ) + { + var oMask = document.createElement( 'iframe' ); + // Workaround for IE https secure warning + oMask.src = "birt/pages/common/blank.html"; + oMask.style.position = 'absolute'; + oMask.style.top = '0px'; + oMask.style.left = '0px'; + oMask.style.width = '100%'; + var height = BirtPosition.viewportHeight( ); + oMask.style.height = height + 'px'; + oMask.style.zIndex = '300'; + oMask.style.backgroundColor = '#dbe4ee'; + oMask.style.filter = 'alpha( opacity = 0.0 )'; + oMask.style.opacity = '.0'; + oMask.scrolling = 'no'; + oMask.marginHeight = '0px'; + oMask.marginWidth = '0px'; + oMask.style.display = 'none'; + document.body.appendChild( oMask ); + + return oMask; + }, + + /** + * Show progress bar. + */ + __l_show : function( ) + { + Element.show( this.__mask, this.__instance ); + BirtPosition.center( this.__instance ); + }, + + /** + * Hide progress bar. + */ + __l_hide : function( ) + { + Element.hide( this.__instance, this.__mask ); + }, + + /** + * Returns 'cancel' button + * @return, INPUT + */ + __loc_cancel_button: function( ) + { + var oIEC = this.__instance.getElementsByTagName( "input" ); + var oCancel; + if( oIEC && oIEC.length > 0 ) + { + for( var i = 0 ; i < oIEC.length; i++ ) + { + if( oIEC[i].type == 'button' ) + { + oCancel = oIEC[i]; + break; + } + } + } + + return oCancel; + }, + + /** + * Handle click "Cancel" button. + * + * @event, incoming browser native event + * @return, void + */ + __neh_click: function( event ) + { + var oTaskId = document.getElementById( this.__task_id ); + if( oTaskId && window.confirm( Constants.error.confirmCancelTask ) ) + { + if( this.__redirect ) + { + this.cancel( oTaskId.value ); + } + else + { + birtEventDispatcher.broadcastEvent( birtEvent.__E_CANCEL_TASK, { name : Constants.PARAM_TASKID, value : oTaskId.value } ); + Event.element( event ).disabled = true; + } + } + }, + + /** + * Try to cancel the process. + * + * @return, void + */ + cancel: function( taskid ) + { + if( !taskid ) + { + var oTaskId = document.getElementById( this.__task_id ); + if( oTaskId ) + taskid = oTaskId.value; + } + + if( !taskid || taskid.length <= 0 ) + return; + + var hiddenForm = document.createElement( 'form' ); + hiddenForm.method = 'post'; + hiddenForm.target = '_self'; + var url = soapURL; + url = url.replace( /[\/][a-zA-Z]+[?]/, '/CancelTask.jsp?' ); + hiddenForm.action = url; + + var taskidInput = document.createElement( 'input' ); + taskidInput.type = 'hidden'; + taskidInput.name = Constants.PARAM_TASKID; + taskidInput.value = taskid; + hiddenForm.appendChild( taskidInput ); + + var divObj = document.createElement( "DIV" ); + document.body.appendChild( divObj ); + divObj.style.display = "none"; + divObj.appendChild( hiddenForm ); + + hiddenForm.submit( ); + }, + + /** + * Show "Cancel" button. + * + * @return, void + */ + __l_show_cancel_button: function( ) + { + var container = document.getElementById( this.__cancel_button ); + if( container ) + container.style.display = 'block'; + }, + + /** + * Hide "Cancel" button. + * + * @return, void + */ + __l_hide_cancel_button: function( ) + { + var container = document.getElementById( this.__cancel_button ); + if( container ) + container.style.display = 'none'; + }, + + /** + * Set redirect flag + * + * @param, flag + * @return, void + */ + setRedirect : function( flag ) + { + this.__redirect = flag; + } +} ); \ No newline at end of file Propchange: ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/app/BirtProgressBar.js ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/app/BirtProgressBar.js ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/app/BirtProgressBar.js ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/app/BirtToc.js URL: http://svn.apache.org/viewvc/ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/app/BirtToc.js?rev=825391&view=auto ============================================================================== --- ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/app/BirtToc.js (added) +++ ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/app/BirtToc.js Thu Oct 15 04:48:28 2009 @@ -0,0 +1,41 @@ +/****************************************************************************** + * 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. + *****************************************************************************/ + +/** + * BirtToc + * ... + */ +BirtToc = Class.create( ); + +BirtToc.prototype = Object.extend( new AbstractBaseToc( ), +{ + /** + * Initialization routine required by "ProtoType" lib. + * @return, void + */ + initialize : function( id ) + { + this.__initBase( id ); + + this.__neh_click_closure = this.__neh_click.bindAsEventListener( this ); + this.__beh_toc_closure = this.__beh_toc.bindAsEventListener( this ); + + this.__beh_toc_image_closure = this.__beh_toc_image.bindAsEventListener( this ); + this.__neh_img_click_closure = this.__neh_img_click.bindAsEventListener( this ); + this.__neh_resize_closure = this.__neh_resize.bindAsEventListener( this ); + + this.__neh_item_mouse_over = this.__neh_mousemove.bindAsEventListener( this ); + this.__neh_item_mouse_out = this.__neh_mouseout.bindAsEventListener( this ); + this.__neh_item_click = this.__neh_text_click.bindAsEventListener( this ); + + this.__cb_installEventHandlers( ); + } +} ); \ No newline at end of file Propchange: ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/app/BirtToc.js ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/app/BirtToc.js ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/app/BirtToc.js ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/app/BirtToolbar.js URL: http://svn.apache.org/viewvc/ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/app/BirtToolbar.js?rev=825391&view=auto ============================================================================== --- ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/app/BirtToolbar.js (added) +++ ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/app/BirtToolbar.js Thu Oct 15 04:48:28 2009 @@ -0,0 +1,115 @@ +/****************************************************************************** + * 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. + *****************************************************************************/ + +/** + * BirtToolbar + * ... + */ +BirtToolbar = Class.create( ); + +BirtToolbar.prototype = Object.extend( new AbstractBaseToolbar( ), +{ + /** + * Initialization routine required by "ProtoType" lib. + * @return, void + */ + initialize : function( id ) + { + this.__initBase( id ); + this.__neh_click_closure = this.__neh_click.bindAsEventListener( this ); + this.__cb_installEventHandlers( ); + }, + + /** + * Binding data to the toolbar UI. Data includes zoom scaling factor. + * + * @data, data DOM tree (schema TBD) + * @return, void + */ + __cb_bind : function( data ) + { + }, + + /** + * Install native/birt event handlers. + * + * @id, toolbar id (optional since there is only one toolbar) + * @return, void + */ + __cb_installEventHandlers : function( ) + { + var oImgs = this.__instance.getElementsByTagName( 'INPUT' ); + if ( oImgs ) + { + for ( var i = 0; i < oImgs.length; i++ ) + { + if ( oImgs[i].type == 'image' ) + { + Event.observe( oImgs[i], 'click', this.__neh_click_closure, false ); + } + } + } + }, + + /** + * Handle native event 'click'. + * + * @event, incoming browser native event + * @return, void + */ + __neh_click : function( event ) + { + var oBtn = Event.element( event ); + + if ( oBtn ) + { + switch ( oBtn.name ) + { + case 'print': + { + birtEventDispatcher.broadcastEvent( birtEvent.__E_PRINT ); + break; + } + case 'printServer': + { + birtEventDispatcher.broadcastEvent( birtEvent.__E_PRINT_SERVER ); + break; + } + case 'exportReport': + { + birtEventDispatcher.broadcastEvent( birtEvent.__E_EXPORT_REPORT ); + break; + } + case 'export': + { + birtEventDispatcher.fireEvent( birtEvent.__E_QUERY_EXPORT ); + break; + } + case 'toc': + { + birtEventDispatcher.broadcastEvent( birtEvent.__E_TOC ); + break; + } + case 'parameter': + { + birtEventDispatcher.broadcastEvent( birtEvent.__E_PARAMETER ); + break; + } + default: + { + alert( oBtn.name ); + break; + } + } + } + } +} +); \ No newline at end of file Propchange: ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/app/BirtToolbar.js ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/app/BirtToolbar.js ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/app/BirtToolbar.js ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/dialog/AbstractBaseDialog.js URL: http://svn.apache.org/viewvc/ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/dialog/AbstractBaseDialog.js?rev=825391&view=auto ============================================================================== --- ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/dialog/AbstractBaseDialog.js (added) +++ ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/dialog/AbstractBaseDialog.js Thu Oct 15 04:48:28 2009 @@ -0,0 +1,482 @@ +/****************************************************************************** + * 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. + *****************************************************************************/ + +/** + * Dialog base class + */ +AbstractBaseDialog = function(){}; + +AbstractBaseDialog.prototype = +{ + contentHolderWidth: 500, //TODO - move to display constants? Default width in pixels + visible: null, //Is the dialog currently visible + __operationCancelled: false, + __allowSelection: false, + + /** + Initialize dialog base + */ + __initBase: function(htmlId, contentWidth) + { + this.__instance = $(htmlId); + this.htmlId = htmlId; + this.visible = false; + + //references will be set for okay button so it can be enabled/disabled + this.okButton = null; + this.okButtonLeft = null; + this.okButtonRight = null; + + //Instance is given a location within screen to avoid + //extra scroll bar creation + this.__instance.style.top = '0px'; + this.__instance.style.left = '0px'; + + //Sizing + this.contentHolderName = htmlId + "dialogContentContainer"; + if(contentWidth) + { + this.contentHolderWidth = parseInt(contentWidth); + } + + this.__neh_resize_closure = this.__neh_resize.bindAsEventListener( this ); + + // Initialize event handler closures + this.__neh_okay_closure = this.__neh_okay.bind(this); + this.__neh_cancel_closure = this.__neh_cancel.bind(this); + this.mousedown_closure = this.__neh_mousedown.bindAsEventListener(this); + this.mouseup_closure = this.__neh_mouseup.bindAsEventListener(this); + this.drag_closure = this.__neh_drag.bindAsEventListener(this); + this.disposeSelection_closure = this.__neh_disposeSelection.bindAsEventListener(this); + this.enableSelection_closure = this.__neh_enableSelection.bindAsEventListener(this); + + this.__beh_cancelOperation_closure = this.__beh_cancelOperation.bindAsEventListener( this ); + + birtEventDispatcher.registerEventHandler( birtEvent.__E_CANCEL_TASK, this.htmlId, this.__beh_cancelOperation_closure ); + + this.__operationCancelled = false; + + // Initialize shared events + this.__base_installEventHandlers(htmlId); + }, + + /** + Install event handlers shared across all dialogs. + Buttons (close, cancel, ok), move dialog (drag and drop), screen resize. + */ + __base_installEventHandlers : function( id ) + { + //Initialize iframe + this.__iframe = $(id + "iframe"); + + // Close button + var closeBtn = $(id + "dialogCloseBtn"); + Event.observe( closeBtn, 'click', this.__neh_cancel_closure, false ); + Event.observe( closeBtn, 'mousedown', this.__neh_stopEvent.bindAsEventListener(this), false ); + + // OK and Cancel buttons + this.okBtn = $(id + "okButton"); + var cancelBtn = $(id + "cancelButton"); + + this.okBtnLeft = $(id + "okButtonLeft"); //left part of background image + this.okBtnRight = $(id + "okButtonRight"); //right part of background image + + //set OK button to enabled as default + this.okBtn.className = "dialogBtnBarButtonEnabled"; + if ( this.okBtnLeft ) + { + this.okBtnLeft.className = "dialogBtnBarButtonLeftBackgroundEnabled"; + } + if ( this.okBtnRight ) + { + this.okBtnRight.className = "dialogBtnBarButtonRightBackgroundEnabled"; + } + + Event.observe( this.okBtn, 'click', this.__neh_okay_closure , false ); + //Cancel + Event.observe( cancelBtn, 'click', this.__neh_cancel_closure , false ); + + //Drag and Drop + this.dragBarName = id + "dialogTitleBar"; + var dragArea = $(this.dragBarName); + Event.observe(dragArea, 'mousedown', this.mousedown_closure, false); + + //work around for IE, enable selection for dialog text controls + var oInputs = this.__instance.getElementsByTagName( 'INPUT' ); + for ( var i = 0; i < oInputs.length ; i++ ) + { + if(oInputs[i].type != 'button') + { + this.__enableSelection( oInputs[i] ); + } + } + + var oTextAreas = this.__instance.getElementsByTagName( 'TEXTAREA' ); + for ( var i = 0; i < oTextAreas.length ; i++ ) + { + this.__enableSelection( oTextAreas[i] ); + } + }, + + /** + * Binding data to the dialog UI. + * + * @data, data DOM tree (schema TBD) + * @return, void + */ + __cb_bind : function( data ) + { + this.__bind( data ); + + this.__l_show( ); + }, + + /** + ABSTRACT - must be implemented by extending class + Gets xml data before dialog is shown + */ + __bind: function(data) + { + + }, + + /** + Trigger dialog from client (bypasses bind step) + */ + showDialog: function() + { + this.__l_show( ); + }, + + /** + * + * + * @event, incoming browser native event + * @return, void + */ + __l_show : function( ) + { + // reset cancelled flag + this.__operationCancelled = false; + this.__preShow(); + + //check if the dialog is already shown + if(!this.visible) + { + var zIndex = Mask.show(); + debug("showing at zIndex " + zIndex); + this.__instance.style.zIndex = zIndex; + + Element.show( this.__instance ); + this.visible = true; + + //workaround for Mozilla bug https://bugzilla.mozilla.org/show_bug.cgi?id=167801 + if(BrowserUtility.useIFrame()) + { + //show iframe under dialog + Element.show( this.__iframe ); + } + + this.__setWidth(); + + BirtPosition.center( this.__instance ); + + // workaround for IE7 in rtl mode + if ( BrowserUtility.isIE7 && rtl ) + { + // force refreshing the DIV elements, + // else their positioning might become brokem after opening + // the same dialog box twice... + var titleContainer = $(this.htmlId + "dialogTitleBar"); + if ( titleContainer ) + { + titleContainer.style.direction = "rtl"; + var elements = titleContainer.getElementsByTagName("div"); + for ( var i = 0; i < elements.length; i++ ) + { + var el = elements[i]; + el.style.display = "none"; + el.style.display = "block"; + } + } + } + + Event.observe( window, 'resize', this.__neh_resize_closure, false ); + Event.observe( document, 'mouseup', this.disposeSelection_closure, false ); + } + + this.__postShow(); + }, + + + /** + Called right before element is shown + */ + __preShow: function() + { + //implementation is left to extending class + }, + + /** + Called after element is shown + */ + __postShow: function() + { + //implementation is left to extending class + }, + + /** + * Handle native event 'click'. + * + * @event, incoming browser native event + * @return, void + */ + __l_hide : function( ) + { + this.__preHide(); + Event.stopObserving( window, 'resize', this.__neh_resize_closure, false ); + Event.stopObserving( document, 'mouseup', this.disposeSelection_closure, false ); + Element.hide( this.__instance, this.__iframe ); + this.visible = false; + Mask.hide(); + }, + + /** + Called before element is hidden + */ + __preHide: function() + { + //implementation is left to extending class + }, + + /** + Enables/disabled OK button + @param boolean enabled + */ + __setOKButtonState: function(enabled) + { + if(enabled) + { + if(this.okBtn.className == "dialogBtnBarButtonDisabled") + { + this.okBtn.className = "dialogBtnBarButtonEnabled"; + if ( this.okBtnLeft ) + { + this.okBtnLeft.className = "dialogBtnBarButtonLeftBackgroundEnabled"; + } + if ( this.okBtnRight ) + { + this.okBtnRight.className = "dialogBtnBarButtonRightBackgroundEnabled"; + } + Event.observe( this.okBtn, 'click', this.__neh_okay_closure , false ); + } + } + else + { + this.okBtn.className = "dialogBtnBarButtonDisabled"; + if ( this.okBtnLeft ) + { + this.okBtnLeft.className = "dialogBtnBarButtonLeftBackgroundDisabled"; + } + if ( this.okBtnRight ) + { + this.okBtnRight.className = "dialogBtnBarButtonRightBackgroundDisabled"; + } + Event.stopObserving( this.okBtn, 'click', this.__neh_okay_closure , false ); + } + }, + + /** + Stop event + */ + __neh_stopEvent: function(event) + { + Event.stop(event); + }, + + /** + Handle mouse down + */ + __neh_mousedown: function(event) + { + debug("AbstractBaseDialog __neh_mousedown"); + + //Event.stop(event); + var target = Event.element( event ); + + Event.observe( target, 'mouseup', this.mouseup_closure , false ); + Event.observe( target, 'mousemove', this.drag_closure , false ); + }, + + /** + Handle mouse up + */ + __neh_mouseup: function(event) + { + var target = Event.element( event ); + + Event.stopObserving( target, 'mouseup', this.mouseup_closure , false ); + Event.stopObserving( target, 'mousemove', this.drag_closure , false ); + }, + + /** + Handle mousemove + */ + __neh_drag: function(event) + { + debug("Mouse move"); + Event.stop( event ); + + var target = Event.element( event ); + Event.stopObserving( target, 'mouseup', this.mouseup_closure , false ); + Event.stopObserving( target, 'mousemove', this.drag_closure , false ); + + DragDrop.startDrag(this.__instance, event, null); + }, + + /** + * Handle cancel selection + */ + __neh_disposeSelection: function(event) + { + if ( !this.__allowSelection ) + { + if(document.selection) + { + document.selection.empty(); + } + else if(window.getSelection) + { + var selection = window.getSelection(); + if(selection) + { + selection.removeAllRanges(); + } + } + } + }, + + /** + * Handle enable selection for dialog controls. + * + * @obj, incoming target object + * @return, void + */ + __enableSelection: function( obj ) + { + Event.observe( obj, 'select', this.enableSelection_closure , false ); + Event.observe( obj, 'selectstart', this.enableSelection_closure , false ); + Event.observe( obj, 'mouseup', this.enableSelection_closure , false ); + }, + + /** + * Handle enable selection event. + * + * @event, incoming browser native event + * @return, void + */ + __neh_enableSelection: function( event ) + { + event.cancelBubble = true; + }, + + /** + * Handle native event 'resize'. + * + * @event, incoming browser native event + * @return, void + */ + __neh_resize : function( event ) + { + BirtPosition.center( this.__instance ); + }, + + __neh_cancel: function() + { + this.__l_hide( ); + }, + + __neh_okay: function() + { + this.__okPress( ); + }, + + /** + ABSTRACT - Handle clicking on ok. + */ + __okPress: function( ) + { + //ABSTRACT - needs to be implemented by extending class + }, + + //TODO change so called once + __setWidth: function() + { + // In Mozilla 1.4 or lower version, if don't set overflow as "auto",then + // clientWidth/clientHeight always return zero. The display is incorrect. + // So add the following section. + if ( this.__instance.clientWidth <= 0) + { + this.__instance.style.overflow = "auto"; + } + + var contentHolder = $(this.contentHolderName); + var innerWidth = contentHolder.offsetWidth; + var outerWidth = this.__instance.clientWidth; + var difference = outerWidth - innerWidth; + contentHolder.style.width = this.contentHolderWidth + 'px'; + var newOuterWidth = contentHolder.offsetWidth + difference; + this.__instance.style.width = newOuterWidth + 'px'; + + this.__iframe.style.width = this.__instance.offsetWidth + 'px'; + this.__iframe.style.height = this.__instance.offsetHeight + 'px'; + + //move iframe to true top, left + //assumes that top/bottom left/right borders are same width + if(this.__iframe.clientWidth > 0) + { + this.__iframe.style.top = (this.__instance.clientHeight - this.__instance.offsetHeight)/2 + 'px'; + this.__iframe.style.left = (this.__instance.clientWidth - this.__instance.offsetWidth)/2 + 'px'; + } + }, + + /** + * Shows or hide the title bar. + * @param visible visibility flag + */ + __setTitleBarVisibile : function(visible) + { + // Hide dialog title bar if embedded in designer. + var titleBar = $( this.htmlId + 'dialogTitleBar' ); + titleBar.style.display = visible?'inline':'none'; + }, + + /** + @returns html id attribute of associated html element for this dialog + */ + getHtmlId: function() + { + return this.htmlId; + }, + + /** + * This event handler is called whenever an operation has been cancelled. + * If the dialog box is visible, sets the cancelled flag to true. + */ + __beh_cancelOperation : function() + { + if ( this.visible ) + { + this.__operationCancelled = true; + } + } + +} \ No newline at end of file Propchange: ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/dialog/AbstractBaseDialog.js ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/dialog/AbstractBaseDialog.js ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/dialog/AbstractBaseDialog.js ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/dialog/AbstractExceptionDialog.js URL: http://svn.apache.org/viewvc/ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/dialog/AbstractExceptionDialog.js?rev=825391&view=auto ============================================================================== --- ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/dialog/AbstractExceptionDialog.js (added) +++ ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/dialog/AbstractExceptionDialog.js Thu Oct 15 04:48:28 2009 @@ -0,0 +1,126 @@ +/****************************************************************************** + * 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 error dialog. + */ +AbstractExceptionDialog = function( ) { }; + +AbstractExceptionDialog.prototype = Object.extend( new AbstractBaseDialog( ), +{ + __faultCode : "", + + __setFaultContainersWidth: function( width ) + { + document.getElementById("faultStringContainer").style.width = width; + document.getElementById("exceptionTraceContainer").style.width = width; + }, + + + /** + * Formats the given stack trace for HTML output. + * @param data stack trace + * @return formatted HTML data + */ + __formatStackTrace : function( data ) + { + if ( !data ) + { + return ""; + } + return data.replace(/\r?\n/g,"<br/>").replace(/[\s]{1}at/g," at"); + }, + + /** + * 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 oSpans = this.__instance.getElementsByTagName( 'SPAN' ); + + // Prepare fault string (reason) + var faultStrings = data.getElementsByTagName( 'faultstring' ); + if ( faultStrings[0] && faultStrings[0].firstChild ) + { + oSpans[0].innerHTML = faultStrings[0].firstChild.data; + } + else + { + oSpans[0].innerHTML = ""; + } + + // Prepare fault detail (Stack traces) + var faultDetail = data.getElementsByTagName( 'string' ); + if ( faultDetail && faultDetail.length > 0 ) + { + var detailSpan = oSpans[1]; + for ( var detailIndex = 0; detailIndex < faultDetail.length; detailIndex++ ) + { + if ( faultDetail[detailIndex].hasChildNodes() ) + { + var detailNodes = faultDetail[detailIndex].childNodes; + if ( detailIndex > 0 ) + { + detailSpan.appendChild( document.createElement("hr") ); + } + var detailElement = document.createElement("div"); + detailElement.style.whiteSpace = "nowrap"; + if ( detailIndex > 0 ) + { + detailElement.style.borderTopStyle = "solid"; + detailElement.style.borderTopWidth = "1px"; + } + + for ( var textIndex = 0; textIndex < detailNodes.length; textIndex++ ) + { + var stackTrace = detailNodes[textIndex].data; + stackTrace = this.__formatStackTrace( stackTrace ) + var stackTraceElement = document.createElement("span"); + stackTraceElement.innerHTML = stackTrace; + detailElement.appendChild( stackTraceElement ); + detailSpan.appendChild(detailElement); + } + } + } + } + else + { + oSpans[1].innerHTML = ""; + } + + var faultCodeElement = data.getElementsByTagName( 'faultcode' ); + if ( faultCodeElement[0] && faultCodeElement[0].firstChild ) + { + this.__faultCode = faultCodeElement[0].firstChild.data; + } + else + { + this.__faultCode = ""; + } + + if ( this.__faultCode == "DocumentProcessor.getPageNumber( )" ) + { + birtEventDispatcher.broadcastEvent( + birtEvent.__E_GETPAGE_INIT, + { name : Constants.PARAM_PAGE, value : 1 } + ); + } + + } +} ); \ No newline at end of file Propchange: ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/dialog/AbstractExceptionDialog.js ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/dialog/AbstractExceptionDialog.js ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/branches/addBirt/framework/webtools/webapp/birt/webcontent/birt/ajax/ui/dialog/AbstractExceptionDialog.js ------------------------------------------------------------------------------ svn:mime-type = text/plain |
Free forum by Nabble | Edit this page |