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/08/26 18:12:06 UTC
svn commit: r569830 - in
/wicket/trunk/jdk-1.4/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal:
ModalWindow.java res/modal.js
Author: knopp
Date: Sun Aug 26 09:12:06 2007
New Revision: 569830
URL: http://svn.apache.org/viewvc?rev=569830&view=rev
Log:
WICKET-890
Modified:
wicket/trunk/jdk-1.4/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/ModalWindow.java
wicket/trunk/jdk-1.4/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/res/modal.js
Modified: wicket/trunk/jdk-1.4/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/ModalWindow.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/ModalWindow.java?rev=569830&r1=569829&r2=569830&view=diff
==============================================================================
--- wicket/trunk/jdk-1.4/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/ModalWindow.java (original)
+++ wicket/trunk/jdk-1.4/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/ModalWindow.java Sun Aug 26 09:12:06 2007
@@ -129,8 +129,8 @@
private static ResourceReference JAVASCRIPT = new JavascriptResourceReference(
ModalWindow.class, "res/modal.js");
- private static ResourceReference CSS = new CompressedResourceReference(
- ModalWindow.class, "res/modal.css");
+ private static ResourceReference CSS = new CompressedResourceReference(ModalWindow.class,
+ "res/modal.css");
/**
* Creates a new modal window component.
@@ -215,7 +215,7 @@
public void onClose(AjaxRequestTarget target);
}
-
+
/**
* Is this window currently showing.
*
@@ -225,6 +225,7 @@
{
return shown;
}
+
/**
* Sets the name of the page ma for the content page. This makes only sense
* when the content is a page, not a component and if wicket multiwindow
@@ -290,7 +291,8 @@
*/
public void show(AjaxRequestTarget target)
{
- if (shown == false) {
+ if (shown == false)
+ {
target.addComponent(this);
target.appendJavascript(getWindowOpenJavascript());
shown = true;
@@ -298,10 +300,9 @@
}
/**
- * Hides the modal window.
- * This can be called from within the modal window, however, the
- * modal window must have configured WindowClosedCallback. Otherwise
- * use the {@link #close(AjaxRequestTarget)} method.
+ * Hides the modal window. This can be called from within the modal window,
+ * however, the modal window must have configured WindowClosedCallback.
+ * Otherwise use the {@link #close(AjaxRequestTarget)} method.
*
* @param target
* Request target associated with current ajax request.
@@ -310,14 +311,15 @@
{
target.appendJavascript(getCloseJavacript());
}
-
+
/**
* Closes the modal window.
*
* @param target
* Request target associated with current ajax request.
*/
- public void close(AjaxRequestTarget target) {
+ public void close(AjaxRequestTarget target)
+ {
target.appendJavascript(getCloseJavacript());
shown = false;
}
@@ -591,6 +593,10 @@
*/
public void setCookieName(String cookieName)
{
+ if (cookieName != null && cookieName.indexOf(",") != -1 && cookieName.indexOf("|") != -1)
+ {
+ throw new IllegalArgumentException("Cookie name may not contain ',' or '|' characters.");
+ }
this.cookieName = cookieName;
}
@@ -732,12 +738,13 @@
protected void onBeforeRender()
{
super.onBeforeRender();
-
- // if user is refreshing whole page, the window will not be shown
- if (((WebRequest)getRequest()).isAjax() == false) {
+
+ // if user is refreshing whole page, the window will not be shown
+ if (((WebRequest)getRequest()).isAjax() == false)
+ {
shown = false;
}
-
+
getContent().setOutputMarkupId(true);
getContent().setVisible(shown);
}
@@ -968,19 +975,22 @@
// 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
+ // in case user is interested in window close callback or we have a
+ // pagemap to clean
// attach notification request
- if ((isCustomComponent() == false && deletePageMap) || windowClosedCallback != null)
+ if ((isCustomComponent() == false && deletePageMap) || windowClosedCallback != null)
{
WindowClosedBehavior behavior = (WindowClosedBehavior)getBehaviors(
WindowClosedBehavior.class).get(0);
- buffer.append("settings.onClose = function() { " + behavior.getCallbackScript() + " };\n");
-
+ 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)
+ // 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(
@@ -988,9 +998,9 @@
buffer.append("settings.onCloseButton = function() { " + behavior.getCallbackScript()
+ "};\n");
}
-
+
postProcessSettings(buffer);
-
+
buffer.append("Wicket.Window.create(settings).show();\n");
return buffer.toString();
@@ -998,6 +1008,7 @@
/**
* Method that allows tweaking the settings
+ *
* @param settings
* @return settings javascript
*/
Modified: wicket/trunk/jdk-1.4/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/res/modal.js
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/res/modal.js?rev=569830&r1=569829&r2=569830&view=diff
==============================================================================
--- wicket/trunk/jdk-1.4/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/res/modal.js (original)
+++ wicket/trunk/jdk-1.4/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/res/modal.js Sun Aug 26 09:12:06 2007
@@ -493,22 +493,56 @@
this.window.style.top = top + "px";
},
+ cookieKey: "wicket-modal-window-positions",
+ cookieExp: 31,
+
+ findPositionString: function(remove) {
+ var cookie = Wicket.Cookie.get(this.cookieKey);
+
+ var entries = cookie != null ? cookie.split("|") : new Array();
+
+ for (var i = 0; i < entries.length; ++i) {
+ if (entries[i].indexOf(this.settings.cookieId + "::") == 0) {
+ var string = entries[i];
+ if (remove) {
+ entries.splice(i, 1);
+ Wicket.Cookie.set(this.cookieKey, entries.join("|"), this.cookieExp);
+
+ }
+ return string;
+ }
+ }
+ return null;
+ },
+
/**
* Saves the position (and size if resizable) as a cookie.
*/
savePosition: function() {
- if (typeof(this.settings.cookieId) != "undefined" &&
- this.settings.cookieId != null) {
- var key = "wicket-modal-" + this.settings.cookieId + "-";
- var exp = 31;
-
- var s = Wicket.Cookie.set;
- s(key + "left", this.window.style.left, exp);
- s(key + "top", this.window.style.top, exp);
- if (this.settings.resizable) {
- s(key + "width", this.window.style.width, exp);
- s(key + "height", this.content.style.height, exp);
+
+ if (typeof(this.settings.cookieId) != "undefined" && this.settings.cookieId != null) {
+
+ this.findPositionString(true);
+
+ if (cookie == null || cookie.length == 0)
+ cookie = "";
+ else
+ cookie = cookie + "|";
+
+ var cookie = this.settings.cookieId;
+ cookie += "::";
+
+ cookie += this.window.style.left + ",";
+ cookie += this.window.style.top + ",";
+ cookie += this.window.style.width + ",";
+ cookie += this.content.style.height;
+
+ var rest = Wicket.Cookie.get(this.cookieKey);
+ if (rest != null) {
+ cookie += "|" + rest;
}
+ Wicket.Cookie.set(this.cookieKey, cookie, this.cookieExp);
+
};
},
@@ -516,26 +550,20 @@
* Restores the position (and size if resizable) from the cookie.
*/
loadPosition: function() {
- if (typeof(this.settings.cookieId) != "undefined" &&
- this.settings.cookieId != null) {
- var key = "wicket-modal-" + this.settings.cookieId + "-";
-
- var g = Wicket.Cookie.get;
- var left = g(key + "left");
- var top = g(key + "top");
- if (this.settings.resizable) {
- var width = g(key + "width");
- var height = g(key + "height");
- }
+ if (typeof(this.settings.cookieId) != "undefined" && this.settings.cookieId != null) {
- if (left != null)
- this.window.style.left = left;
- if (top != null)
- this.window.style.top = top;
- if (width != null)
- this.window.style.width = width;
- if (height != null)
- this.content.style.height = height;
+ var string = this.findPositionString(false);
+
+ if (string != null) {
+ var array = string.split("::");
+ var positions = array[1].split(",");
+ if (positions.length == 4) {
+ this.window.style.left = positions[0];
+ this.window.style.top = positions[1];
+ this.window.style.width = positions[2];
+ this.content.style.height = positions[3];
+ }
+ }
}
},
@@ -572,7 +600,7 @@
this.content.src = this.settings.src;
// opera seems to have problem accessing contentWindow here
- if (Wicket.Browser.isOpera()) {
+ if (Wicket.Browser.isOpera() || Wicket.Browser.isSafari()) {
this.content.onload = function() {
this.content.contentWindow.name = this.settings.iframeName;
}