You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by kn...@apache.org on 2007/03/24 19:24:07 UTC

svn commit: r522085 - in /incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket-extensions/src/main/java/wicket/extensions/ajax/markup/html/modal: ModalWindow.java res/modal.js

Author: knopp
Date: Sat Mar 24 11:24:06 2007
New Revision: 522085

URL: http://svn.apache.org/viewvc?view=rev&rev=522085
Log:
Modal window fixes

Modified:
    incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket-extensions/src/main/java/wicket/extensions/ajax/markup/html/modal/ModalWindow.java
    incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket-extensions/src/main/java/wicket/extensions/ajax/markup/html/modal/res/modal.js

Modified: incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket-extensions/src/main/java/wicket/extensions/ajax/markup/html/modal/ModalWindow.java
URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket-extensions/src/main/java/wicket/extensions/ajax/markup/html/modal/ModalWindow.java?view=diff&rev=522085&r1=522084&r2=522085
==============================================================================
--- incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket-extensions/src/main/java/wicket/extensions/ajax/markup/html/modal/ModalWindow.java (original)
+++ incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket-extensions/src/main/java/wicket/extensions/ajax/markup/html/modal/ModalWindow.java Sat Mar 24 11:24:06 2007
@@ -830,7 +830,7 @@
 			if (closeButtonCallback == null
 					|| closeButtonCallback.onCloseButtonClicked(target) == true)
 			{
-				target.appendJavascript("Wicket.Window.get().close();");
+				close(target);
 			}
 		}
 
@@ -944,13 +944,8 @@
 			buffer.append("settings.mask=\"semi-transparent\";\n");
 		}
 
-		if (closeButtonCallback != null)
-		{
-			CloseButtonBehavior behavior = (CloseButtonBehavior)getBehaviors(
-					CloseButtonBehavior.class).get(0);
-			buffer.append("settings.onCloseButton = function() { " + behavior.getCallbackScript()
-					+ "};\n");
-		}
+		// set true if we set a windowclosedcallback
+		boolean haveCloseCallback = false;
 
 		// in case user is interested in window close callback or we have a pagemap to clean
 		// attach notification request
@@ -959,8 +954,20 @@
 			WindowClosedBehavior behavior = (WindowClosedBehavior)getBehaviors(
 					WindowClosedBehavior.class).get(0);
 			buffer.append("settings.onClose = function() { " + behavior.getCallbackScript() + " };\n");
+			
+			haveCloseCallback = true;
 		}
 
+		// in case we didn't set windowclosecallback, we need at least callback on close button,
+		// to close window property (thus cleaning the shown flag) 
+		if (closeButtonCallback != null || haveCloseCallback == false)
+		{
+			CloseButtonBehavior behavior = (CloseButtonBehavior)getBehaviors(
+					CloseButtonBehavior.class).get(0);
+			buffer.append("settings.onCloseButton = function() { " + behavior.getCallbackScript()
+					+ "};\n");
+		}
+		
 		buffer.append("Wicket.Window.create(settings).show();\n");
 
 		return buffer.toString();

Modified: incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket-extensions/src/main/java/wicket/extensions/ajax/markup/html/modal/res/modal.js
URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket-extensions/src/main/java/wicket/extensions/ajax/markup/html/modal/res/modal.js?view=diff&rev=522085&r1=522084&r2=522085
==============================================================================
--- incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket-extensions/src/main/java/wicket/extensions/ajax/markup/html/modal/res/modal.js (original)
+++ incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket-extensions/src/main/java/wicket/extensions/ajax/markup/html/modal/res/modal.js Sat Mar 24 11:24:06 2007
@@ -595,6 +595,17 @@
 		
 		this.caption.getElementsByTagName("a")[0].onclick = null;
 	},
+	
+	/**
+	 * Returns the content document
+	 */
+	getContentDocument: function() {
+		if (this.isIframe() == true) {
+			return this.content.contentWindow.document;
+		} else {
+			return document;
+		}
+	},
 
 	/**
 	 * Places the window to the center of the viewport.
@@ -705,7 +716,7 @@
 	/**
 	 * Shows the window. 
 	 */
-	show: function() {							
+	show: function() {
 		// create the DOM elements
 		this.createDOM();						
 		
@@ -808,7 +819,6 @@
 			}				
 		}
 
-		
 		// create the mask that covers the background		
 		this.createMask();				
 	},
@@ -1320,7 +1330,15 @@
 			// mask is already shown - don't hide it
 			this.dontHide = true; 			
 		}
-	
+		
+		var doc = document;
+		var old = Wicket.Window.current.oldWindow;
+		if (typeof(old) != "undefined") {
+			doc = old.getContentDocument();
+		}
+		
+		this.document = doc;
+		
 		// disable user interaction
 		this.hideSelectBoxes();						
 		this.disableTabs();
@@ -1355,6 +1373,8 @@
 		
 		// revert onfocus handlers
 		this.enableFocus();
+		
+		this.document = null;
 
 	},
 	
@@ -1406,7 +1426,7 @@
 			var win = Wicket.Window.current;					
 			
 			this.boxes = new Array();
-			var selects = document.getElementsByTagName("select");
+			var selects = this.document.getElementsByTagName("select");
 			for (var i = 0; i < selects.length; i++) {				
 				var element = selects[i];
 				
@@ -1463,7 +1483,7 @@
 		// plus in IE this causes problems because it scrolls document		);
 		if (Wicket.Browser.isIE() == false) {			
 			this.focusRevertList = new Array();			
-			var body = document.getElementsByTagName("body")[0];			
+			var body = this.document.getElementsByTagName("body")[0];			
 			for (var i = 0; i < body.childNodes.length; ++i) {		
 				this.disableFocusElement(body.childNodes[i], this.focusRevertList);
 			}
@@ -1494,7 +1514,7 @@
 			var i = 0;			
 			this.tabIndexes = new Array();
 			for (var j = 0; j < this.tabbableTags.length; j++) {
-				var tagElements = document.getElementsByTagName(this.tabbableTags[j]);
+				var tagElements = this.document.getElementsByTagName(this.tabbableTags[j]);
 				for (var k = 0 ; k < tagElements.length; k++) {
 					
 					// if this is not an iframe window and the element is child of window content,
@@ -1516,7 +1536,7 @@
 		if (typeof(this.tabIndexes) != 'undefined') {
 			var i = 0;
 			for (var j = 0; j < this.tabbableTags.length; j++) {
-				var tagElements = document.getElementsByTagName(this.tabbableTags[j]);
+				var tagElements = this.document.getElementsByTagName(this.tabbableTags[j]);
 				for (var k = 0 ; k < tagElements.length; k++) {
 					tagElements[k].tabIndex = this.tabIndexes[i];
 					tagElements[k].tabEnabled = true;
@@ -1546,7 +1566,7 @@
 }
 
 /**
- * Returns thewidth of visible area.
+ * Returns the width of visible area.
  */
 Wicket.Window.getViewportWidth =  function() {
 	if (window.innerWidth != window.undefined)