Added: ofbiz/branches/addbirt/framework/birt/webapp/birt/webcontent/birt/ajax/ui/app/AbstractBaseToc.js
URL: http://svn.apache.org/viewvc/ofbiz/branches/addbirt/framework/birt/webapp/birt/webcontent/birt/ajax/ui/app/AbstractBaseToc.js?rev=831503&view=auto ============================================================================== --- ofbiz/branches/addbirt/framework/birt/webapp/birt/webcontent/birt/ajax/ui/app/AbstractBaseToc.js (added) +++ ofbiz/branches/addbirt/framework/birt/webapp/birt/webcontent/birt/ajax/ui/app/AbstractBaseToc.js Sat Oct 31 01:22:47 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/birt/webapp/birt/webcontent/birt/ajax/ui/app/AbstractBaseToc.js ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/branches/addbirt/framework/birt/webapp/birt/webcontent/birt/ajax/ui/app/AbstractBaseToc.js ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/branches/addbirt/framework/birt/webapp/birt/webcontent/birt/ajax/ui/app/AbstractBaseToc.js ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/branches/addbirt/framework/birt/webapp/birt/webcontent/birt/ajax/ui/app/AbstractBaseToolbar.js URL: http://svn.apache.org/viewvc/ofbiz/branches/addbirt/framework/birt/webapp/birt/webcontent/birt/ajax/ui/app/AbstractBaseToolbar.js?rev=831503&view=auto ============================================================================== --- ofbiz/branches/addbirt/framework/birt/webapp/birt/webcontent/birt/ajax/ui/app/AbstractBaseToolbar.js (added) +++ ofbiz/branches/addbirt/framework/birt/webapp/birt/webcontent/birt/ajax/ui/app/AbstractBaseToolbar.js Sat Oct 31 01:22:47 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/birt/webapp/birt/webcontent/birt/ajax/ui/app/AbstractBaseToolbar.js ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/branches/addbirt/framework/birt/webapp/birt/webcontent/birt/ajax/ui/app/AbstractBaseToolbar.js ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/branches/addbirt/framework/birt/webapp/birt/webcontent/birt/ajax/ui/app/AbstractBaseToolbar.js ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/branches/addbirt/framework/birt/webapp/birt/webcontent/birt/ajax/ui/app/AbstractUIComponent.js URL: http://svn.apache.org/viewvc/ofbiz/branches/addbirt/framework/birt/webapp/birt/webcontent/birt/ajax/ui/app/AbstractUIComponent.js?rev=831503&view=auto ============================================================================== --- ofbiz/branches/addbirt/framework/birt/webapp/birt/webcontent/birt/ajax/ui/app/AbstractUIComponent.js (added) +++ ofbiz/branches/addbirt/framework/birt/webapp/birt/webcontent/birt/ajax/ui/app/AbstractUIComponent.js Sat Oct 31 01:22:47 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/birt/webapp/birt/webcontent/birt/ajax/ui/app/AbstractUIComponent.js ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/branches/addbirt/framework/birt/webapp/birt/webcontent/birt/ajax/ui/app/AbstractUIComponent.js ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/branches/addbirt/framework/birt/webapp/birt/webcontent/birt/ajax/ui/app/AbstractUIComponent.js ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/branches/addbirt/framework/birt/webapp/birt/webcontent/birt/ajax/ui/app/BirtNavigationBar.js URL: http://svn.apache.org/viewvc/ofbiz/branches/addbirt/framework/birt/webapp/birt/webcontent/birt/ajax/ui/app/BirtNavigationBar.js?rev=831503&view=auto ============================================================================== --- ofbiz/branches/addbirt/framework/birt/webapp/birt/webcontent/birt/ajax/ui/app/BirtNavigationBar.js (added) +++ ofbiz/branches/addbirt/framework/birt/webapp/birt/webcontent/birt/ajax/ui/app/BirtNavigationBar.js Sat Oct 31 01:22:47 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/birt/webapp/birt/webcontent/birt/ajax/ui/app/BirtNavigationBar.js ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/branches/addbirt/framework/birt/webapp/birt/webcontent/birt/ajax/ui/app/BirtNavigationBar.js ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/branches/addbirt/framework/birt/webapp/birt/webcontent/birt/ajax/ui/app/BirtNavigationBar.js ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/branches/addbirt/framework/birt/webapp/birt/webcontent/birt/ajax/ui/app/BirtProgressBar.js URL: http://svn.apache.org/viewvc/ofbiz/branches/addbirt/framework/birt/webapp/birt/webcontent/birt/ajax/ui/app/BirtProgressBar.js?rev=831503&view=auto ============================================================================== --- ofbiz/branches/addbirt/framework/birt/webapp/birt/webcontent/birt/ajax/ui/app/BirtProgressBar.js (added) +++ ofbiz/branches/addbirt/framework/birt/webapp/birt/webcontent/birt/ajax/ui/app/BirtProgressBar.js Sat Oct 31 01:22:47 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/birt/webapp/birt/webcontent/birt/ajax/ui/app/BirtProgressBar.js ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/branches/addbirt/framework/birt/webapp/birt/webcontent/birt/ajax/ui/app/BirtProgressBar.js ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/branches/addbirt/framework/birt/webapp/birt/webcontent/birt/ajax/ui/app/BirtProgressBar.js ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/branches/addbirt/framework/birt/webapp/birt/webcontent/birt/ajax/ui/app/BirtToc.js URL: http://svn.apache.org/viewvc/ofbiz/branches/addbirt/framework/birt/webapp/birt/webcontent/birt/ajax/ui/app/BirtToc.js?rev=831503&view=auto ============================================================================== --- ofbiz/branches/addbirt/framework/birt/webapp/birt/webcontent/birt/ajax/ui/app/BirtToc.js (added) +++ ofbiz/branches/addbirt/framework/birt/webapp/birt/webcontent/birt/ajax/ui/app/BirtToc.js Sat Oct 31 01:22:47 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/birt/webapp/birt/webcontent/birt/ajax/ui/app/BirtToc.js ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/branches/addbirt/framework/birt/webapp/birt/webcontent/birt/ajax/ui/app/BirtToc.js ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/branches/addbirt/framework/birt/webapp/birt/webcontent/birt/ajax/ui/app/BirtToc.js ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/branches/addbirt/framework/birt/webapp/birt/webcontent/birt/ajax/ui/app/BirtToolbar.js URL: http://svn.apache.org/viewvc/ofbiz/branches/addbirt/framework/birt/webapp/birt/webcontent/birt/ajax/ui/app/BirtToolbar.js?rev=831503&view=auto ============================================================================== --- ofbiz/branches/addbirt/framework/birt/webapp/birt/webcontent/birt/ajax/ui/app/BirtToolbar.js (added) +++ ofbiz/branches/addbirt/framework/birt/webapp/birt/webcontent/birt/ajax/ui/app/BirtToolbar.js Sat Oct 31 01:22:47 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/birt/webapp/birt/webcontent/birt/ajax/ui/app/BirtToolbar.js ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/branches/addbirt/framework/birt/webapp/birt/webcontent/birt/ajax/ui/app/BirtToolbar.js ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/branches/addbirt/framework/birt/webapp/birt/webcontent/birt/ajax/ui/app/BirtToolbar.js ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/branches/addbirt/framework/birt/webapp/birt/webcontent/birt/ajax/ui/dialog/AbstractBaseDialog.js URL: http://svn.apache.org/viewvc/ofbiz/branches/addbirt/framework/birt/webapp/birt/webcontent/birt/ajax/ui/dialog/AbstractBaseDialog.js?rev=831503&view=auto ============================================================================== --- ofbiz/branches/addbirt/framework/birt/webapp/birt/webcontent/birt/ajax/ui/dialog/AbstractBaseDialog.js (added) +++ ofbiz/branches/addbirt/framework/birt/webapp/birt/webcontent/birt/ajax/ui/dialog/AbstractBaseDialog.js Sat Oct 31 01:22:47 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/birt/webapp/birt/webcontent/birt/ajax/ui/dialog/AbstractBaseDialog.js ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/branches/addbirt/framework/birt/webapp/birt/webcontent/birt/ajax/ui/dialog/AbstractBaseDialog.js ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/branches/addbirt/framework/birt/webapp/birt/webcontent/birt/ajax/ui/dialog/AbstractBaseDialog.js ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/branches/addbirt/framework/birt/webapp/birt/webcontent/birt/ajax/ui/dialog/AbstractExceptionDialog.js URL: http://svn.apache.org/viewvc/ofbiz/branches/addbirt/framework/birt/webapp/birt/webcontent/birt/ajax/ui/dialog/AbstractExceptionDialog.js?rev=831503&view=auto ============================================================================== --- ofbiz/branches/addbirt/framework/birt/webapp/birt/webcontent/birt/ajax/ui/dialog/AbstractExceptionDialog.js (added) +++ ofbiz/branches/addbirt/framework/birt/webapp/birt/webcontent/birt/ajax/ui/dialog/AbstractExceptionDialog.js Sat Oct 31 01:22:47 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/birt/webapp/birt/webcontent/birt/ajax/ui/dialog/AbstractExceptionDialog.js ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/branches/addbirt/framework/birt/webapp/birt/webcontent/birt/ajax/ui/dialog/AbstractExceptionDialog.js ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/branches/addbirt/framework/birt/webapp/birt/webcontent/birt/ajax/ui/dialog/AbstractExceptionDialog.js ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/branches/addbirt/framework/birt/webapp/birt/webcontent/birt/ajax/ui/dialog/AbstractParameterDialog.js URL: http://svn.apache.org/viewvc/ofbiz/branches/addbirt/framework/birt/webapp/birt/webcontent/birt/ajax/ui/dialog/AbstractParameterDialog.js?rev=831503&view=auto ============================================================================== --- ofbiz/branches/addbirt/framework/birt/webapp/birt/webcontent/birt/ajax/ui/dialog/AbstractParameterDialog.js (added) +++ ofbiz/branches/addbirt/framework/birt/webapp/birt/webcontent/birt/ajax/ui/dialog/AbstractParameterDialog.js Sat Oct 31 01:22:47 2009 @@ -0,0 +1,278 @@ +/****************************************************************************** + * 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. + *****************************************************************************/ + +/** + * BirtParameterDialog + * ... + */ +AbstractParameterDialog = function( ) { }; + +AbstractParameterDialog.prototype = Object.extend( new AbstractBaseDialog( ), +{ + /** + *__parameter to store "name" and "value" pairs + */ + __parameter : [], + + /** + *__cascadingParameter to store "name" and "value" pairs + */ + __cascadingParameter : [], + + /** + * Event handler closures. + */ + __neh_click_radio_closure : null, + __neh_change_select_closure : null, + + /** + * Initialize dialog base. + * @return, void + */ + initializeBase : function( id ) + { + this.__initBase( id, '500px' ); + this.__z_index = 200; + + this.__neh_click_radio_closure = this.__neh_click_radio.bindAsEventListener( this ); + this.__neh_change_select_closure = this.__neh_change_select.bindAsEventListener( this ); + + this.__local_installEventHandlers(id); + }, + + /** + * Binding data to the dialog UI. Data includes zoom scaling factor. + * @data, data DOM tree (schema TBD) + * @return, void + */ + __bind : function( data ) + { + this.__propogateCascadeParameter( data ); + }, + + /** + * Binding data to the dialog UI. Data includes zoom scaling factor. + * @data, data DOM tree (schema TBD) + * @return, void + */ + __propogateCascadeParameter : function( data ) + { + if ( this.__operationCancelled ) + { + return; + } + + if( 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 param_name = selectionLists[k].getElementsByTagName( 'Name' )[0].firstChild.data; + var selections = selectionLists[k].getElementsByTagName( 'Selections' ); + + var append_selection = document.getElementById( param_name + "_selection" ); + append_selection.title = ""; + var len = append_selection.options.length; + + // Clear our selection list. + for( var i = 0, index = 0; i < len; i++ ) + { + /* + if ( append_selection.options[index].value == "" ) + { + index++; + continue; + } + */ + 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' ) + if ( oLabel && oLabel.length > 0 ) + { + oLabel = oLabel[0].firstChild; + } + if( oLabel ) + oOption.text = oLabel.data; + else + oOption.text = ""; + + var oValue = selections[i].getElementsByTagName( 'Value' ); + if ( oValue && oValue.length > 0 ) + { + oValue = oValue[0].firstChild; + } + if( oValue ) + oOption.value = oValue.data; + else + oOption.value = ""; + append_selection.options[append_selection.options.length] = oOption; + } + } + } + }, + + /** + * Install native/birt event handlers. + * + * @id, toolbar id (optional since there is only one toolbar) + * @return, void + */ + __local_installEventHandlers : function( id ) + { + //install UIComponent native handler + var oTBC = document.getElementById("parameter_table").getElementsByTagName( 'TABLE' ); + for( var k = 0, counter = 0; k < oTBC.length; k++ ) + { + var temp = oTBC[k].getElementsByTagName( 'TABLE' ); + if( !temp.length ) + { + //install select event handler in cascade parameters + this.__install_cascade_parameter_event_handler( oTBC[k], counter++ ); + } + } + + var oTRC = document.getElementById( "parameter_table" ).getElementsByTagName( "TR" ); + for( var i = 0; i < oTRC.length; i++ ) + { + var oInput = oTRC[i].getElementsByTagName( "input" ); + var oTable = oTRC[i].getElementsByTagName( "table" ); + if( oTable.length > 0 ) + { + continue; + } + //find radio with textbox or select items to install event listener. + var flag = false; + for( var j = 0; j < oInput.length; j++ ) + { + if( oInput[j].type == "radio" && !flag ) + { + var tempRadio = oInput[j]; + flag = true; + continue; + } + + if( oInput[j].type == "radio" && tempRadio != {} && oInput[j].id != tempRadio.id ) + { + Event.observe( tempRadio, 'click', this.__neh_click_radio_closure, false ); + Event.observe( oInput[j], 'click', this.__neh_click_radio_closure, false ); + } + } + } + }, + + /** + * Handle clicking on ok. + * + * @event, incoming browser native event + * @return, void + */ + __okPress : function( ) + { + if( birtParameterDialog.collect_parameter( ) ) + { + birtEventDispatcher.broadcastEvent( birtEvent.__E_CHANGE_PARAMETER ); + this.__l_hide( ); + } + }, + + /** + * Handle clicking on radio. + * + * @event, incoming browser native event + * @return, void + */ + __neh_click_radio : function( event ) + { + var temp = Event.element( event ); + var oInput = temp.parentNode.getElementsByTagName( "input" ); + var oSelect = temp.parentNode.getElementsByTagName( "select" ); + + for( var i = 0; i < oInput.length; i++ ) + { + if( oInput[i].id == temp.id ) + { + //enable the next component + oInput[i].checked = true; + if( oInput[i+1] && ( oInput[i+1].type == "text" || oInput[i+1].type == "password" ) ) + { + oInput[i+1].disabled = false; + oInput[i+1].focus( ); + } + else if( oSelect[0] ) + { + oSelect[0].disabled = false; + oSelect[0].focus( ); + } + } + else if( oInput[i].type == "radio" && oInput[i].id != temp.id ) + { + //disable the next component and clear the radio + oInput[i].checked = false; + if( oInput[i+1] && ( oInput[i+1].type == "text" || oInput[i+1].type == "password" ) ) + { + oInput[i+1].disabled = true; + } + else if( oSelect[0] ) + { + oSelect[0].disabled = true; + } + } + } + }, + + /** + * Handle change event when clicking on select. + * + * @event, incoming browser native event + * @return, void + */ + __neh_change_select : function( event ) + { + var matrix = new Array( ); + var m = 0; + for( var i = 0; i < this.__cascadingParameter.length; i++ ) + { + for( var j = 0; j < this.__cascadingParameter[i].length; j++ ) + { + if( this.__cascadingParameter[i][j].name == Event.element( event ).id.substr( 0, Event.element( event ).id.length - 10 ) ) + { + this.__cascadingParameter[i][j].value = Event.element( event ).options[Event.element( event ).selectedIndex].value; + for( var m = 0; m <= j; m++ ) + { + if( !matrix[m] ) + { + matrix[m] = {}; + } + matrix[m].name = this.__cascadingParameter[i][m].name; + matrix[m].value = this.__cascadingParameter[i][m].value; + } + birtEventDispatcher.broadcastEvent( birtEvent.__E_CASCADING_PARAMETER, matrix ); + } + } + } + } +} ); \ No newline at end of file Propchange: ofbiz/branches/addbirt/framework/birt/webapp/birt/webcontent/birt/ajax/ui/dialog/AbstractParameterDialog.js ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/branches/addbirt/framework/birt/webapp/birt/webcontent/birt/ajax/ui/dialog/AbstractParameterDialog.js ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/branches/addbirt/framework/birt/webapp/birt/webcontent/birt/ajax/ui/dialog/AbstractParameterDialog.js ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/branches/addbirt/framework/birt/webapp/birt/webcontent/birt/ajax/ui/dialog/BirtConfirmationDialog.js URL: http://svn.apache.org/viewvc/ofbiz/branches/addbirt/framework/birt/webapp/birt/webcontent/birt/ajax/ui/dialog/BirtConfirmationDialog.js?rev=831503&view=auto ============================================================================== --- ofbiz/branches/addbirt/framework/birt/webapp/birt/webcontent/birt/ajax/ui/dialog/BirtConfirmationDialog.js (added) +++ ofbiz/branches/addbirt/framework/birt/webapp/birt/webcontent/birt/ajax/ui/dialog/BirtConfirmationDialog.js Sat Oct 31 01:22:47 2009 @@ -0,0 +1,63 @@ +/****************************************************************************** + * 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 confirmation dialog. + */ +BirtConfirmationDialog = Class.create( ); + +BirtConfirmationDialog.prototype = Object.extend( new AbstractBaseDialog( ), +{ + + /** + * Initialization routine required by "ProtoType" lib. + * @return, void + */ + initialize : function( id ) + { + this.__initBase( id ); + this.__z_index = 200; + }, + + /** + * Handle clicking on ok. + * + * @return, void + */ + __okPress : function( ) + { + this.__l_hide( ); + }, + + /** + 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/birt/webapp/birt/webcontent/birt/ajax/ui/dialog/BirtConfirmationDialog.js ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/branches/addbirt/framework/birt/webapp/birt/webcontent/birt/ajax/ui/dialog/BirtConfirmationDialog.js ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/branches/addbirt/framework/birt/webapp/birt/webcontent/birt/ajax/ui/dialog/BirtConfirmationDialog.js ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/branches/addbirt/framework/birt/webapp/birt/webcontent/birt/ajax/ui/dialog/BirtExceptionDialog.js URL: http://svn.apache.org/viewvc/ofbiz/branches/addbirt/framework/birt/webapp/birt/webcontent/birt/ajax/ui/dialog/BirtExceptionDialog.js?rev=831503&view=auto ============================================================================== --- ofbiz/branches/addbirt/framework/birt/webapp/birt/webcontent/birt/ajax/ui/dialog/BirtExceptionDialog.js (added) +++ ofbiz/branches/addbirt/framework/birt/webapp/birt/webcontent/birt/ajax/ui/dialog/BirtExceptionDialog.js Sat Oct 31 01:22:47 2009 @@ -0,0 +1,202 @@ +/****************************************************************************** + * 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. + */ +BirtExceptionDialog = Class.create( ); + +BirtExceptionDialog.prototype = Object.extend( new AbstractExceptionDialog( ), +{ + /** + * indicate whether exception detail is show or not. + */ + __isShow: false, + + /** + * control id definitions + */ + __TRACE_CONTAINER: 'exceptionTraceContainer', + __LABEL_SHOW_TRACE: 'showTraceLabel', + __LABEL_HIDE_TRACE: 'hideTraceLabel', + + _showTraceLabel : null, + _hideTraceLabel : null, + + /** + * Event handler closures. + */ + __neh_click_input_closurre : null, + + /** + * Initialization routine required by "ProtoType" lib. + * + * @return, void + */ + initialize : function( id ) + { + var dialogWidth = (Constants.request.servletPath == Constants.SERVLET_PARAMETER)?500:600; + if ( BrowserUtility.isIE && !BrowserUtility.isIE7 ) + { + dialogWidth -= 55; + } + + this.__initBase( id, dialogWidth + "px" ); + this.__allowSelection = true; // allow selecting text with the mouse + + // it looks like IE 6 handles the width differently + var faultDetailContainer = $( "faultdetail" ); + var faultStringContainer = $("faultStringContainer"); + if ( BrowserUtility.isIE && !BrowserUtility.isIE7 ) + { + this.__setFaultContainersWidth( ( dialogWidth - 20 ) + "px" ); + faultStringContainer.style.overflowX = "auto"; + faultStringContainer.style.paddingBottom = "20px"; + faultDetailContainer.parentNode.style.width = ( dialogWidth - 30 ) + "px"; + faultDetailContainer.style.width = "100%"; + } + else + { + this.__setFaultContainersWidth( ( dialogWidth - 80 ) + "px" ); + faultStringContainer.style.overflow = "auto"; + } + + // Bugzilla 225924: Fix overflow issue in the stack trace container + if ( BrowserUtility.isSafari || BrowserUtility.isIE7 || ( BrowserUtility.isGecko && !BrowserUtility.isFirefox2 ) ) + { + faultDetailContainer.parentNode.style.width = (dialogWidth - 90 ) + "px"; + } + + if ( Constants.request.servletPath == Constants.SERVLET_PARAMETER ) + { + // Hide dialog title bar if embedded in designer. + this.__setTitleBarVisibile(false); + // expand the dialog's height + var contentContainer = $( id + "dialogContentContainer"); + contentContainer.style.height = "355px"; + } + + this.__z_index = 300; + + // click event on input control + this._showTraceLabel = $( this.__LABEL_SHOW_TRACE ); + this._showTraceLabel.tabIndex = 0; + this._hideTraceLabel = $( this.__LABEL_HIDE_TRACE ); + this._hideTraceLabel.tabIndex = 0; + + this.__neh_click_input_closure = this.__neh_click_input.bindAsEventListener( this ); + this.__neh_key_input_closure = this.__neh_key_input.bindAsEventListener( this ); + Event.observe( this._showTraceLabel, 'click', this.__neh_click_input_closure, false ); + Event.observe( this._showTraceLabel, 'keyup', this.__neh_key_input_closure, false ); + Event.observe( $( this._hideTraceLabel ), 'click', this.__neh_click_input_closure, false ); + Event.observe( this._hideTraceLabel, 'keyup', this.__neh_key_input_closure, false ); + }, + + __neh_key_input: function( event ) + { + if ( event.keyCode == 13 || event.keyCode == 32 ) + { + this.__neh_click_input(); + } + }, + + /** + * Handle clicking on input control. + * + * @return, void + */ + __neh_click_input: function( event ) + { + if( !this.__isShow ) + { + $( this.__TRACE_CONTAINER ).style.display = "block"; + $( this.__LABEL_SHOW_TRACE ).style.display = "none"; + $( this.__LABEL_HIDE_TRACE ).style.display = "block"; + var that = this; + window.setTimeout( function() { that._hideTraceLabel.focus(); }, 0 ); + } + else + { + $( this.__TRACE_CONTAINER ).style.display = "none"; + $( this.__LABEL_SHOW_TRACE ).style.display = "block"; + $( this.__LABEL_HIDE_TRACE ).style.display = "none"; + var that = this; + window.setTimeout( function() { that._showTraceLabel.focus(); }, 0 ); + } + + this.__isShow = !this.__isShow; + + // refresh the dialog size (Mozilla/Firefox element resize bug) + birtUtility.refreshElement(this.__instance); + + if ( Constants.request.servletPath == Constants.SERVLET_PARAMETER ) + { + // in designer mode, recenter the dialog + BirtPosition.center( this.__instance ); + } + }, + + __bind : function( data ) + { + // call to super + AbstractExceptionDialog.prototype.__bind.apply( this, arguments ); + + var label = this._showTraceLabel; + // defer + setTimeout(function(){ + // cause any focussed element to lose focus + // (ex: opened drop-down lists) + label.focus(); + label.blur(); + },50); + }, + + /** + * Handle clicking on ok. + * + * @return, void + */ + __okPress: function( ) + { + this.__l_hide( ); + }, + + /** + 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 ); + + // close the exception stack trace + $( this.__TRACE_CONTAINER ).style.display = 'none'; + $( this.__LABEL_SHOW_TRACE ).style.display = "block"; + $( this.__LABEL_HIDE_TRACE ).style.display = "none"; + + this.__isShow = false; + }, + + /** + 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/birt/webapp/birt/webcontent/birt/ajax/ui/dialog/BirtExceptionDialog.js ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/branches/addbirt/framework/birt/webapp/birt/webcontent/birt/ajax/ui/dialog/BirtExceptionDialog.js ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/branches/addbirt/framework/birt/webapp/birt/webcontent/birt/ajax/ui/dialog/BirtExceptionDialog.js ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/branches/addbirt/framework/birt/webapp/birt/webcontent/birt/ajax/ui/dialog/BirtExportReportDialog.js URL: http://svn.apache.org/viewvc/ofbiz/branches/addbirt/framework/birt/webapp/birt/webcontent/birt/ajax/ui/dialog/BirtExportReportDialog.js?rev=831503&view=auto ============================================================================== --- ofbiz/branches/addbirt/framework/birt/webapp/birt/webcontent/birt/ajax/ui/dialog/BirtExportReportDialog.js (added) +++ ofbiz/branches/addbirt/framework/birt/webapp/birt/webcontent/birt/ajax/ui/dialog/BirtExportReportDialog.js Sat Oct 31 01:22:47 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. + *****************************************************************************/ + +/** + * Birt export report dialog. + */ +BirtExportReportDialog = Class.create( ); + +BirtExportReportDialog.prototype = Object.extend( new AbstractBaseDialog( ), +{ + __neh_select_change_closure : null, + __neh_radio_click_closure : null, + + /** + * Initialization routine required by "ProtoType" lib. + * @return, void + */ + initialize : function( id ) + { + this.__initBase( id ); + this.__z_index = 200; + + this.__enableExtSection( ); + + // Binding + this.__neh_select_change_closure = this.__neh_select_change.bindAsEventListener( this ); + this.__neh_radio_click_closure = this.__neh_radio_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 = $( 'exportPageSetting' ).getElementsByTagName( 'input' ); + for( var i=0; i<oInputs.length; i++ ) + { + if( oInputs[i].type == 'radio' ) + Event.observe( oInputs[i], 'click', this.__neh_radio_click_closure,false ); + } + }, + + /** + * Handle clicking on ok. + * + * @return, void + */ + __okPress : function( ) + { + var oSelect = $( 'exportFormat' ); + if( oSelect.value == '' ) + return; + + if ( this.__exportAction( ) ) + { + this.__l_hide( ); + } + }, + + /** + * Handle export report action + * + * @return, void + */ + __exportAction : function( ) + { + var format = $( 'exportFormat' ).value.toLowerCase( ); + + 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 ); + + // Set 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 + "=" + format; + } + else + { + action = action.replace( reg, "$1=" + format ); + } + + // 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( $( 'exportPageCurrent' ).checked ) + { + // Set page setting + var currentPage = birtUtility.trim( $( 'pageNumber' ).innerHTML ); + action = action + "&" + Constants.PARAM_PAGE + "=" + currentPage; + } + else if( $( 'exportPageRange' ).checked ) + { + // Set page range setting + var pageRange = birtUtility.trim( $( 'exportPageRange_input' ).value ); + if ( !birtUtility.checkPageRange( pageRange ) ) + { + alert( Constants.error.invalidPageRange ); + return false; + } + action = action + "&" + Constants.PARAM_PAGERANGE + "=" + pageRange; + } + + // If output format is pdf/ppt/postscript, set some options + if( this.__isPDFLayout( format ) ) + { + // auto fit + var pageOverflow = 0; + //var pagebreakonly = "true"; + + // actual size + if( $( 'exportFitToActual' ).checked ) + { + pageOverflow = 1; + } + else if( $( 'exportFitToWhole' ).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 "__asattachment" as true + reg = new RegExp( "([&|?]{1}" + Constants.PARAM_ASATTACHMENT + "\s*)=([^&|^#]*)", "gi" ); + if( action.search( reg ) < 0 ) + { + action = action + "&" + Constants.PARAM_ASATTACHMENT + "=true"; + } + else + { + action = action.replace( reg, "$1=true" ); + } + + // 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" ); + } + + formObj.action = action; + formObj.method = "post"; + formObj.submit( ); + + return true; + } + }, + + /** + * Native event handler for radio control. + */ + __neh_radio_click : function( event ) + { + var oSC = Event.element( event ); + if( oSC.type == 'radio' ) + { + var oInput = $( 'exportPageRange_input' ); + if( oSC.id == 'exportPageRange' ) + { + oInput.disabled = false; + oInput.focus( ); + } + else + { + oInput.disabled = true; + oInput.value = ""; + } + } + }, + + /** + * Native event handler for select control. + */ + __neh_select_change : function( event ) + { + this.__enableExtSection( ); + }, + + /** + * Enable the extended setting controls according to current selected output format. + */ + __enableExtSection : function( ) + { + var format = $( 'exportFormat' ).value.toLowerCase( ); + if( this.__isPDFLayout( format ) ) + { + this.__setDisabled( 'exportFitSetting', false ); + } + else + { + this.__setDisabled( 'exportFitSetting', true ); + } + }, + + /** + * Set disabled flag for all the controls in the container + * + * @param id, html container id. ( DIV/TABLE....) + * @param flag, true or false + * @return, void + */ + __setDisabled: function( id, flag ) + { + var container = $( id ); + if( container ) + { + var oInputs = container.getElementsByTagName( 'input' ); + for( var i=0; i<oInputs.length; i++ ) + oInputs[i].disabled = flag; + } + }, + + /** + * Check whether this format uses the PDF layout + * + * @param format, the output format + * @return true or false + */ + __isPDFLayout : function( format ) + { + if( !format ) + return false; + + if( format == Constants.FORMAT_PDF + || format == Constants.FORMAT_POSTSCRIPT + || format == Constants.FORMAT_PPT ) + { + return true; + } + + return false; + }, + + /** + 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 |
Free forum by Nabble | Edit this page |