Skip to content

Commit

Permalink
修复对话框
Browse files Browse the repository at this point in the history
  • Loading branch information
yiifaa committed Jun 26, 2017
1 parent 2923b4c commit d2013ad
Show file tree
Hide file tree
Showing 12 changed files with 365 additions and 507 deletions.
75 changes: 48 additions & 27 deletions WebContent/birt/ajax/ui/dialog/AbstractBaseDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,34 @@
* Dialog base class
*/
AbstractBaseDialog = function(){};
// 添加Dialog实例监控
var Dialogs = {};

AbstractBaseDialog.prototype =
{
contentHolderWidth: 500, //TODO - move to display constants? Default width in pixels
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)
{
__initBase: function(htmlId, contentWidth) {
this.__instance = $(htmlId);
// 初始化Dialog
this.__view = jQuery(document.getElementById(htmlId));
this.__view.modal({
keyboard: false,
backdrop: 'static',
show: false
})
// 记录所有的对话框
Dialogs[htmlId] = this;
//
this.htmlId = htmlId;
this.visible = false;

Expand All @@ -26,8 +40,10 @@ AbstractBaseDialog.prototype =

//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";
Expand Down Expand Up @@ -64,7 +80,7 @@ AbstractBaseDialog.prototype =
__base_installEventHandlers : function( id )
{
//Initialize iframe
this.__iframe = $(id + "iframe");
// this.__iframe = $(id + "iframe");

// Close button
var closeBtn = $(id + "dialogCloseBtn");
Expand Down Expand Up @@ -151,13 +167,20 @@ AbstractBaseDialog.prototype =
* @event, incoming browser native event
* @return, void
*/
__l_show : function( )
{
__l_show : function() {
// 隐藏其他对话框
for(var prop in Dialogs) {
if(Dialogs[prop] !== this) {
// 隐藏其他对话框
Dialogs[prop].__l_hide();
}
}
// reset cancelled flag
this.__operationCancelled = false;
this.__preShow();

//check if the dialog is already shown
/**
if(!this.visible)
{
var zIndex = Mask.show();
Expand All @@ -167,13 +190,6 @@ AbstractBaseDialog.prototype =
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 );
Expand Down Expand Up @@ -201,17 +217,20 @@ AbstractBaseDialog.prototype =
Event.observe( window, 'resize', this.__neh_resize_closure, false );
Event.observe( document, 'mouseup', this.disposeSelection_closure, false );
}

**/
if(!this.visible) {
this.__view.modal('show');
this.visible = true;
}
this.__postShow();
},


/**
Called right before element is shown
*/
__preShow: function()
{
//implementation is left to extending class
__preShow: function() {

},

/**
Expand All @@ -231,18 +250,22 @@ AbstractBaseDialog.prototype =
__l_hide : function( )
{
this.__preHide();
this.__view.modal('hide');
/**
Event.stopObserving( window, 'resize', this.__neh_resize_closure, false );
Event.stopObserving( document, 'mouseup', this.disposeSelection_closure, false );
[ this.__instance, this.__iframe ].each( Element.hide );
this.visible = false;
[this.__instance].each(Element.hide);
Mask.hide();
**/
// [this.__instance, this.__iframe].each( Element.hide );
this.visible = false;

},

/**
Called before element is hidden
*/
__preHide: function()
{
__preHide: function() {
//implementation is left to extending class
},

Expand Down Expand Up @@ -424,17 +447,15 @@ AbstractBaseDialog.prototype =
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)
{
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';
}
**/
},

/**
Expand Down
9 changes: 4 additions & 5 deletions WebContent/birt/ajax/ui/dialog/BirtParameterDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -325,11 +325,10 @@ BirtParameterDialog.prototype = Object.extend(new AbstractParameterDialog(),

var k = 0;
//oTRC[i] is <tr></tr> section
var oTRC = document.getElementById("parameter_table").getElementsByTagName("TR");
for(var i = 0; i < oTRC.length; i++)
{
if(!this.__parameter[k])
{
//var oTRC = document.getElementById("parameter_table").getElementsByTagName("TR");
var oTRC = document.getElementById("parameter_table").querySelectorAll('div.form-group');
for(var i = 0; i < oTRC.length; i++) {
if(!this.__parameter[k]) {
this.__parameter[k] = { };
}

Expand Down
127 changes: 41 additions & 86 deletions WebContent/birt/pages/dialog/DialogContainerFragment.jsp
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
<%-----------------------------------------------------------------------------
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.
-----------------------------------------------------------------------------%>
<%--
对话框模板
--%>
<%@ page contentType="text/html; charset=utf-8" %>
<%@ page session="false" buffer="none" %>
<%@ page import="org.eclipse.birt.report.presentation.aggregation.IFragment,
Expand All @@ -16,83 +9,45 @@
org.eclipse.birt.report.utility.ParameterAccessor,
org.eclipse.birt.report.resource.BirtResources" %>

<%-----------------------------------------------------------------------------
Expected java beans
-----------------------------------------------------------------------------%>
<jsp:useBean id="fragment" type="org.eclipse.birt.report.presentation.aggregation.IFragment" scope="request" />
<jsp:useBean id="attributeBean" type="org.eclipse.birt.report.context.BaseAttributeBean" scope="request" />

<%-----------------------------------------------------------------------------
Dialog container fragment, shared by all standard dialogs.
-----------------------------------------------------------------------------%>
<div id="<%= fragment.getClientId( ) %>" class="dialogBorder" style="display:none;position:absolute;z-index:220">
<iframe id="<%= fragment.getClientId( ) %>iframe" name="<%= fragment.getClientId( ) %>iframe" style="z-index:-1; display: none; left:0px; top:0px;
background-color: #ff0000; opacity: .0; filter: alpha(opacity = 0); position: absolute;" frameBorder="0" scrolling="no" src="birt/pages/common/blank.html">
</iframe>
<div id="<%= fragment.getClientId( ) %>dialogTitleBar" class="dialogTitleBar dTitleBar">
<div class="dTitleTextContainer">
<table style="width: 100%; height: 100%;">
<tr>
<td class="dialogTitleText dTitleText">
<%= fragment.getTitle( ) %>
</td>
</tr>
</table>
</div>
<div class="dialogCloseBtnContainer dCloseBtnContainer">
<table style="width: 100%; height: 100%; border-collapse: collapse">
<tr>
<td>
<label class="birtviewer_hidden_label" for="<%= fragment.getClientId( ) %>dialogCloseBtn">
<%=
BirtResources.getMessage( "birt.viewer.dialog.close" )
%>
</label>
<div id="<%= fragment.getClientId( ) %>dialogCloseBtn" class="dialogCloseBtn dCloseBtn"/>
</td>
</tr>
</table>
</div>
</div>
<!-- overflow is set as workaround for Mozilla bug https://bugzilla.mozilla.org/show_bug.cgi?id=167801 -->
<div class="dialogBackground" style="overflow: auto;">
<div class="dBackground">
<div class="dialogContentContainer" id="<%= fragment.getClientId( ) %>dialogContentContainer">
<%
if ( fragment != null )
{
fragment.callBack( request, response );
}
%>
</div>
<div class="dialogBtnBarContainer">
<div>
<div class="dBtnBarDividerTop">
<div class="modal fade" tabindex="-1" role="dialog" id="<%= fragment.getClientId()%>">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header" id="<%= fragment.getClientId() %>dialogTitleBar">
<button type="button" class="close" data-dismiss="modal" aria-label="Close" id="<%= fragment.getClientId() %>dialogCloseBtn"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title"><%= fragment.getTitle() %></h4>
</div>
<div class="modal-body" id="<%= fragment.getClientId() %>dialogContentContainer">
<%
if (fragment != null) {
fragment.callBack(request, response);
}
%>
</div>
<div class="modal-footer">
<div id="<%= fragment.getClientId( ) %>dialogCustomButtonContainer" class="dialogBtnBarButtonContainer ">
<div id="<%= fragment.getClientId() %>cancelButton" style="float:right;">
<div class="dialogBtnBarButtonLeftBackgroundEnabled"></div>
<div class="dialogBtnBarButtonRightBackgroundEnabled"></div>
<input class="btn btn-default" type="button" value="<%= BirtResources.getHtmlMessage( "birt.viewer.dialog.cancel" )%>"
title="<%= BirtResources.getHtmlMessage( "birt.viewer.dialog.cancel" )%>"
class="dialogBtnBarButtonText dialogBtnBarButtonEnabled"/>
</div>
<div class="dBtnBarDividerBottom">
</div>
</div>
<div class="dialogBtnBar">
<div id="<%= fragment.getClientId( ) %>dialogCustomButtonContainer" class="dialogBtnBarButtonContainer">
<div id="<%= fragment.getClientId( ) %>okButton">
<div id="<%= fragment.getClientId( ) %>okButtonLeft" class="dialogBtnBarButtonLeftBackgroundEnabled"></div>
<div id="<%= fragment.getClientId( ) %>okButtonRight" class="dialogBtnBarButtonRightBackgroundEnabled"></div>
<input type="button" value="<%= BirtResources.getHtmlMessage( "birt.viewer.dialog.ok" ) %>"
title="<%= BirtResources.getHtmlMessage( "birt.viewer.dialog.ok" ) %>"
class="dialogBtnBarButtonText dialogBtnBarButtonEnabled"/>
</div>
<div class="dialogBtnBarDivider"></div>
<div id="<%= fragment.getClientId( ) %>cancelButton">
<div class="dialogBtnBarButtonLeftBackgroundEnabled"></div>
<div class="dialogBtnBarButtonRightBackgroundEnabled"></div>
<input type="button" value="<%= BirtResources.getHtmlMessage( "birt.viewer.dialog.cancel" )%>"
title="<%= BirtResources.getHtmlMessage( "birt.viewer.dialog.cancel" )%>"
class="dialogBtnBarButtonText dialogBtnBarButtonEnabled"/>
</div>
</div>
</div>
</div>
</div>
</div>
</div>


<div class="dialogBtnBarDivider"></div>

<div id="<%= fragment.getClientId( ) %>okButton" style="float:right;margin-right:15px;">
<div id="<%= fragment.getClientId( ) %>okButtonLeft" class="dialogBtnBarButtonLeftBackgroundEnabled"></div>
<div id="<%= fragment.getClientId( ) %>okButtonRight" class="dialogBtnBarButtonRightBackgroundEnabled"></div>
<input type="button" class="btn btn-primary" value="<%= BirtResources.getHtmlMessage( "birt.viewer.dialog.ok" ) %>"
title="<%= BirtResources.getHtmlMessage("birt.viewer.dialog.ok" ) %>"
class="dialogBtnBarButtonText dialogBtnBarButtonEnabled"/>
</div>

</div>
</div>
</div>
</div>
</div>
Loading

0 comments on commit d2013ad

Please sign in to comment.