From cvs-return-24642-apmail-cocoon-cvs-archive=cocoon.apache.org@cocoon.apache.org Thu Oct 06 16:20:07 2005 Return-Path: Delivered-To: apmail-cocoon-cvs-archive@www.apache.org Received: (qmail 53576 invoked from network); 6 Oct 2005 16:20:06 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 6 Oct 2005 16:20:06 -0000 Received: (qmail 39076 invoked by uid 500); 6 Oct 2005 16:20:06 -0000 Delivered-To: apmail-cocoon-cvs-archive@cocoon.apache.org Received: (qmail 39028 invoked by uid 500); 6 Oct 2005 16:20:05 -0000 Mailing-List: contact cvs-help@cocoon.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@cocoon.apache.org list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list cvs@cocoon.apache.org Received: (qmail 39017 invoked by uid 99); 6 Oct 2005 16:20:05 -0000 X-ASF-Spam-Status: No, hits=-9.8 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.29) with SMTP; Thu, 06 Oct 2005 09:20:04 -0700 Received: (qmail 53474 invoked by uid 65534); 6 Oct 2005 16:19:44 -0000 Message-ID: <20051006161944.53472.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r306800 - in /cocoon/blocks/ajax/trunk: java/org/apache/cocoon/ajax/resources/js/ java/org/apache/cocoon/ajax/resources/xslt/ samples/ Date: Thu, 06 Oct 2005 16:19:41 -0000 To: cvs@cocoon.apache.org From: jeremy@apache.org X-Mailer: svnmailer-1.0.5 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: jeremy Date: Thu Oct 6 09:19:27 2005 New Revision: 306800 URL: http://svn.apache.org/viewcvs?rev=306800&view=rev Log: adding linked updating via ajax Added: cocoon/blocks/ajax/trunk/java/org/apache/cocoon/ajax/resources/xslt/ cocoon/blocks/ajax/trunk/java/org/apache/cocoon/ajax/resources/xslt/ajax-styling.xsl cocoon/blocks/ajax/trunk/samples/linked-updater-content-1.xml cocoon/blocks/ajax/trunk/samples/linked-updater-content-2.xml cocoon/blocks/ajax/trunk/samples/linked-updater-content-3.xml cocoon/blocks/ajax/trunk/samples/linked-updater.xml Modified: cocoon/blocks/ajax/trunk/java/org/apache/cocoon/ajax/resources/js/browserupdater.js cocoon/blocks/ajax/trunk/java/org/apache/cocoon/ajax/resources/js/timedbrowserupdater.js cocoon/blocks/ajax/trunk/samples/sitemap.xmap cocoon/blocks/ajax/trunk/samples/welcome.xml Modified: cocoon/blocks/ajax/trunk/java/org/apache/cocoon/ajax/resources/js/browserupdater.js URL: http://svn.apache.org/viewcvs/cocoon/blocks/ajax/trunk/java/org/apache/cocoon/ajax/resources/js/browserupdater.js?rev=306800&r1=306799&r2=306800&view=diff ============================================================================== --- cocoon/blocks/ajax/trunk/java/org/apache/cocoon/ajax/resources/js/browserupdater.js (original) +++ cocoon/blocks/ajax/trunk/java/org/apache/cocoon/ajax/resources/js/browserupdater.js Thu Oct 6 09:19:27 2005 @@ -111,34 +111,59 @@ Cocoon.Ajax.BrowserUpdater.Handlers = { replace : function(element) { - var id = element.getAttribute("id"); + var id = element.getAttribute("id"); // the id from the incoming element if (!id) { alert("no id found on update element"); return; } - // Get the first child element (the first child may be some text!) - var firstChild = DOMUtils.firstChildElement(element); - - var oldElement = document.getElementById(id); - + var oldElement = $(id); // the element that is being replaced if (!oldElement) { alert("no element '" + id + "' in source document"); return; } - - var newElement = DOMUtils.importNode(firstChild, document); + // Get the first child element (the first child may be some text!) + var content = DOMUtils.firstChildElement(element); // the element to replace with + var insertion = new Cocoon.Ajax.Insertion.Replace(oldElement, content); - // Warn: it's replace(new, old)!! - oldElement.parentNode.replaceChild(newElement, oldElement); - // Ensure the new node has the correct id + var newElement = $(id); + // Ensure the new node has the correct id newElement.setAttribute("id", id); - + if (Cocoon.Ajax.BrowserUpdater.highlight) { Cocoon.Ajax.BrowserUpdater.highlight(newElement); } } } + +Cocoon.Ajax.Insertion = new Object(); +Cocoon.Ajax.Insertion.Replace = Class.create(); +Cocoon.Ajax.Insertion.Replace.prototype = Object.extend(new Abstract.Insertion(''), { + + initialize: function(element, content) { + this.element = $(element); + this.content = content; + this.insertContent(); + }, + + insertContent: function() { + if (typeof this.content == "string") { + var newDiv = document.createElement('div'); + newDiv.innerHTML = this.content; + var newElement = newDiv.firstChild; + this.element.parentNode.insertBefore(newElement, this.element); + this.element.parentNode.removeChild(this.element); + } else { // hopefully 'content' is a DOM Fragment + var newElement = DOMUtils.importNode(this.content, document); + this.element.parentNode.replaceChild(newElement, this.element); + } + } + +}); + + + + // NB. This will probably be replaced with scriptaculous Effects Modified: cocoon/blocks/ajax/trunk/java/org/apache/cocoon/ajax/resources/js/timedbrowserupdater.js URL: http://svn.apache.org/viewcvs/cocoon/blocks/ajax/trunk/java/org/apache/cocoon/ajax/resources/js/timedbrowserupdater.js?rev=306800&r1=306799&r2=306800&view=diff ============================================================================== --- cocoon/blocks/ajax/trunk/java/org/apache/cocoon/ajax/resources/js/timedbrowserupdater.js (original) +++ cocoon/blocks/ajax/trunk/java/org/apache/cocoon/ajax/resources/js/timedbrowserupdater.js Thu Oct 6 09:19:27 2005 @@ -23,7 +23,7 @@ this.setOptions(options); this.onComplete = this.options.onComplete; this.autostart = (this.options.autostart || true); // default autostart: true - this.frequency = (this.options.frequency || 30); // default frequency: 5 minutes + this.frequency = (this.options.frequency || 30); // default frequency: 5 minutes this.decay = 1; // default decay: none this.populated = false; this.updater = {}; @@ -44,7 +44,6 @@ this.updater.onComplete = undefined; clearTimeout(this.timer); this.timerIsRunning = false; - //(this.onComplete || Ajax.emptyFunction).apply(this, arguments); self.status = "Timer Stoping"; }, @@ -213,6 +212,7 @@ document.location, { method: 'post', - onFailure: Cocoon.Ajax.BrowserUpdater.handleError + onFailure: Cocoon.Ajax.BrowserUpdater.handleError, + insertion: Cocoon.Ajax.Insertion.Replace } ); Added: cocoon/blocks/ajax/trunk/java/org/apache/cocoon/ajax/resources/xslt/ajax-styling.xsl URL: http://svn.apache.org/viewcvs/cocoon/blocks/ajax/trunk/java/org/apache/cocoon/ajax/resources/xslt/ajax-styling.xsl?rev=306800&view=auto ============================================================================== --- cocoon/blocks/ajax/trunk/java/org/apache/cocoon/ajax/resources/xslt/ajax-styling.xsl (added) +++ cocoon/blocks/ajax/trunk/java/org/apache/cocoon/ajax/resources/xslt/ajax-styling.xsl Thu Oct 6 09:19:27 2005 @@ -0,0 +1,80 @@ + + + + + + + + + + + + + + + + + + + + + + + Insertion.Before + Insertion.After + Insertion.Top + Insertion.Bottom + Cocoon.Ajax.Insertion.Replace + + + + + + + + + + + + + + + + + + + + + + + Added: cocoon/blocks/ajax/trunk/samples/linked-updater-content-1.xml URL: http://svn.apache.org/viewcvs/cocoon/blocks/ajax/trunk/samples/linked-updater-content-1.xml?rev=306800&view=auto ============================================================================== --- cocoon/blocks/ajax/trunk/samples/linked-updater-content-1.xml (added) +++ cocoon/blocks/ajax/trunk/samples/linked-updater-content-1.xml Thu Oct 6 09:19:27 2005 @@ -0,0 +1,4 @@ +
+

This is some fresh content.

+

This has been added to your page dynamically.

+
\ No newline at end of file Added: cocoon/blocks/ajax/trunk/samples/linked-updater-content-2.xml URL: http://svn.apache.org/viewcvs/cocoon/blocks/ajax/trunk/samples/linked-updater-content-2.xml?rev=306800&view=auto ============================================================================== --- cocoon/blocks/ajax/trunk/samples/linked-updater-content-2.xml (added) +++ cocoon/blocks/ajax/trunk/samples/linked-updater-content-2.xml Thu Oct 6 09:19:27 2005 @@ -0,0 +1,4 @@ +
+

This content has been added to your page dynamically.

+

Replacing existing content.

+
\ No newline at end of file Added: cocoon/blocks/ajax/trunk/samples/linked-updater-content-3.xml URL: http://svn.apache.org/viewcvs/cocoon/blocks/ajax/trunk/samples/linked-updater-content-3.xml?rev=306800&view=auto ============================================================================== --- cocoon/blocks/ajax/trunk/samples/linked-updater-content-3.xml (added) +++ cocoon/blocks/ajax/trunk/samples/linked-updater-content-3.xml Thu Oct 6 09:19:27 2005 @@ -0,0 +1,3 @@ +
+

This was inserted.

+
\ No newline at end of file Added: cocoon/blocks/ajax/trunk/samples/linked-updater.xml URL: http://svn.apache.org/viewcvs/cocoon/blocks/ajax/trunk/samples/linked-updater.xml?rev=306800&view=auto ============================================================================== --- cocoon/blocks/ajax/trunk/samples/linked-updater.xml (added) +++ cocoon/blocks/ajax/trunk/samples/linked-updater.xml Thu Oct 6 09:19:27 2005 @@ -0,0 +1,56 @@ + + + + Linked Updating + +