Author: chris.laprun(a)jboss.com
Date: 2009-02-11 16:11:47 -0500 (Wed, 11 Feb 2009)
New Revision: 12810
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/theme/WindowContextFactory.java
branches/JBoss_Portal_Branch_2_7/theme/src/bin/portal-ajax-war/dyna/dyna.js
Log:
- Use namespace instead of base 64 encoding of window id (to avoid an issue with prototype
1.6.0.3 and Safari, see
http://prototype.lighthouseapp.com/projects/8886/tickets/497-prototype-v1...
for more details).
- Minor optimizations in dyna.js.
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/theme/WindowContextFactory.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/theme/WindowContextFactory.java 2009-02-11
18:20:48 UTC (rev 12809)
+++
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/theme/WindowContextFactory.java 2009-02-11
21:11:47 UTC (rev 12810)
@@ -1,6 +1,6 @@
/******************************************************************************
* JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * Copyright 2009, Red Hat Middleware, LLC, and individual *
* contributors as indicated by the @authors tag. See the *
* copyright.txt in the distribution for a full listing of *
* individual contributors. *
@@ -25,11 +25,11 @@
import org.jboss.portal.Mode;
import org.jboss.portal.WindowState;
import org.jboss.portal.core.controller.ControllerContext;
-import org.jboss.portal.core.model.portal.PortalObjectPath;
import org.jboss.portal.core.model.portal.Window;
import
org.jboss.portal.core.model.portal.command.action.InvokePortletWindowRenderCommand;
import org.jboss.portal.core.model.portal.command.response.MarkupResponse;
import org.jboss.portal.core.model.portal.content.WindowRendition;
+import org.jboss.portal.portlet.impl.jsr168.PortletUtils;
import org.jboss.portal.server.ServerInvocationContext;
import org.jboss.portal.server.request.URLContext;
import org.jboss.portal.server.request.URLFormat;
@@ -84,7 +84,7 @@
//
return new WindowContext(
- window.getId().toString(PortalObjectPath.LEGACY_BASE64_FORMAT),
+ PortletUtils.generateNamespaceFrom(window.getId().toString()),
region,
order,
windowResult);
Modified: branches/JBoss_Portal_Branch_2_7/theme/src/bin/portal-ajax-war/dyna/dyna.js
===================================================================
--- branches/JBoss_Portal_Branch_2_7/theme/src/bin/portal-ajax-war/dyna/dyna.js 2009-02-11
18:20:48 UTC (rev 12809)
+++ branches/JBoss_Portal_Branch_2_7/theme/src/bin/portal-ajax-war/dyna/dyna.js 2009-02-11
21:11:47 UTC (rev 12810)
@@ -1,4 +1,28 @@
-function sendData(action, windowId, fromPos, fromRegionId, toPos, toRegionId) {
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2009, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+
+function sendData(action, windowId, fromPos, fromRegionId, toPos, toRegionId)
+{
var options = {
requestHeaders:
["ajax","true","bilto","toto"],
method: "post",
@@ -21,31 +45,35 @@
new Ajax.Request(server_base_url + "/ajax", options);
}
-function snapshot() {
+function snapshot()
+{
// Find draggable regions
- var regions_on_page = $$(".dnd-region");
+ var regions_on_page = $$(".dnd-region");
// Save current state in the DOM itself
- for(var i = 0;i < regions_on_page.length;i++) {
+ for (var i = 0; i < regions_on_page.length; i++)
+ {
var regionDiv = regions_on_page[i]
- for (var j = 0;j < regionDiv.childNodes.length;j++) {
+ for (var j = 0; j < regionDiv.childNodes.length; j++)
+ {
var child = regionDiv.childNodes[j];
child["regionId"] = regionDiv.id;
child["pos"] = j;
- }
+ }
}
}
// Check that the URL starts with the provided prefix
-function isURLAccepted(url) {
+function isURLAccepted(url)
+{
var indexOfSessionId = server_base_url.indexOf(";jsessionid");
if (indexOfSessionId > 0)
{
- server_base_url =
server_base_url.substring(0,indexOfSessionId-";jsessionid".length-1);
+ server_base_url = server_base_url.substring(0, indexOfSessionId -
";jsessionid".length - 1);
}
-
+
if (url.indexOf("http://") == 0)
{
var indexOfSlash = url.indexOf("/", "http://".length);
@@ -79,7 +107,8 @@
var container = Element.up(source, "div.dyna-window");
// We found the window
- if (container != null) {
+ if (container != null)
+ {
//
var options = new Object();
@@ -90,7 +119,8 @@
{
// Check we can handle this URL
- if (isURLAccepted(source.href)) {
+ if (isURLAccepted(source.href))
+ {
// Set URL
url = source.href;
@@ -106,23 +136,28 @@
{
// Find enclosing form
var current = source.parentNode;
- while (current.nodeName != 'FORM' && current.nodeName !=
'BODY') {
+ while (current.nodeName != 'FORM' && current.nodeName !=
'BODY')
+ {
current = current.parentNode;
}
// Check we have a form and use it
- if (current.nodeName == 'FORM') {
+ if (current.nodeName == 'FORM')
+ {
var enctype = current.enctype
// We don't handle file upload for now
- if (enctype != "multipart/form-data") {
+ if (enctype != "multipart/form-data")
+ {
// Check it is a POST
- if (current.method.toLowerCase() == "post") {
+ if (current.method.toLowerCase() == "post")
+ {
// Check we can handle this URL
- if (isURLAccepted(current.action)) {
+ if (isURLAccepted(current.action))
+ {
// Set URL
url = current.action;
@@ -139,7 +174,8 @@
}
// Handle links here
- if (url != null) {
+ if (url != null)
+ {
// Setup headers
var headers = ["ajax","true"];
@@ -170,7 +206,7 @@
// Different than 1 is not good
if (matchingElt != null)
{
- var dstContainer = document.getElementById(id);
+ var dstContainer = matchingElt;
if (dstContainer != null)
{
// Get markup fragment
@@ -225,46 +261,47 @@
*/
function copyInnerHTML(srcContainer, dstContainer, className)
{
- var srcs = srcContainer.select("." + className);
+ var classSelector = "." + className;
+ var srcs = srcContainer.select(classSelector);
if (srcs.length == 1)
{
var src = srcs[0];
//
- var dsts = dstContainer.select("." + className);
+ var dsts = dstContainer.select(classSelector);
if (dsts.length == 1)
{
var dst = dsts[0];
- // Remove existing non attribute children in destination
- var dstChildren = dst.childNodes;
- var copy = new Array();
- for (var i = 0;i < dstChildren.length;i++)
- {
- var dstChild = dstChildren.item(i);
- if (dstChild.nodeType != 2)
- {
- copy[i] = dstChildren.item(i);
- }
- }
- for (var i = 0;i < copy.length;i++)
- {
- Element.remove(copy[i]);
- }
+ // Remove existing non attribute children in destination
+ var dstChildren = dst.childNodes;
+ var copy = new Array();
+ for (var i = 0; i < dstChildren.length; i++)
+ {
+ var dstChild = dstChildren.item(i);
+ if (dstChild.nodeType != 2)
+ {
+ copy[i] = dstChildren.item(i);
+ }
+ }
+ for (var i = 0; i < copy.length; i++)
+ {
+ Element.remove(copy[i]);
+ }
- // Move src non attribute children to the destination
- while (src.hasChildNodes())
- {
- var srcChild = src.firstChild;
- if (srcChild.nodeType != 2)
- {
- dst.appendChild(srcChild);
- }
- else
- {
- src.removeChild(srcChild);
- }
- }
+ // Move src non attribute children to the destination
+ while (src.hasChildNodes())
+ {
+ var srcChild = src.firstChild;
+ if (srcChild.nodeType != 2)
+ {
+ dst.appendChild(srcChild);
+ }
+ else
+ {
+ src.removeChild(srcChild);
+ }
+ }
}
else
{
@@ -318,15 +355,18 @@
//var regions_on_page = document.getElementsByClassName("dnd-region");
// Create draggable regions
- for(var i = 0;i < regions_on_page.length;i++) {
+ for (var i = 0; i < regions_on_page.length; i++)
+ {
var region = regions_on_page[i];
- if(typeof Sortable != 'undefined'){
+ if (typeof Sortable != 'undefined')
+ {
Sortable.create(region,
{dropOnEmpty:true,handle:"dnd-handle",tag:"div",containment:regions_on_page,constraint:false,hoverclass:"dnd-droppable"});
}
}
//
- if(typeof Draggables != 'undefined'){
+ if (typeof Draggables != 'undefined')
+ {
Draggables.addObserver(new WindowMoveObserver());
}
//
@@ -337,7 +377,8 @@
// Add listener for the dyna windows on the dyna-window element
// and not async-window as this one will have its markup replaced
- for(var i = 0;i < portlets_on_page.length;i++) {
+ for (var i = 0; i < portlets_on_page.length; i++)
+ {
var portlet = Element.up(portlets_on_page[i]);
Event.observe(portlet, "click", bilto);
}