You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@clerezza.apache.org by it...@apache.org on 2009/12/15 12:13:05 UTC

svn commit: r890758 - in /incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.webapp.parent/org.apache.clerezza.web.resources.scripts/src/main/resources/org/apache/clerezza/web/resources/scripts/staticweb: ajax-options.js overlay.js

Author: ito
Date: Tue Dec 15 11:13:05 2009
New Revision: 890758

URL: http://svn.apache.org/viewvc?rev=890758&view=rev
Log:
added overlay js to web.resources.scripts and jquery  ajax options

Added:
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.webapp.parent/org.apache.clerezza.web.resources.scripts/src/main/resources/org/apache/clerezza/web/resources/scripts/staticweb/ajax-options.js
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.webapp.parent/org.apache.clerezza.web.resources.scripts/src/main/resources/org/apache/clerezza/web/resources/scripts/staticweb/overlay.js

Added: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.webapp.parent/org.apache.clerezza.web.resources.scripts/src/main/resources/org/apache/clerezza/web/resources/scripts/staticweb/ajax-options.js
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.webapp.parent/org.apache.clerezza.web.resources.scripts/src/main/resources/org/apache/clerezza/web/resources/scripts/staticweb/ajax-options.js?rev=890758&view=auto
==============================================================================
--- incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.webapp.parent/org.apache.clerezza.web.resources.scripts/src/main/resources/org/apache/clerezza/web/resources/scripts/staticweb/ajax-options.js (added)
+++ incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.webapp.parent/org.apache.clerezza.web.resources.scripts/src/main/resources/org/apache/clerezza/web/resources/scripts/staticweb/ajax-options.js Tue Dec 15 11:13:05 2009
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * The AjaxOptions is a object defining the options of an jquery ajax object.
+ * @see <a href="http://docs.jquery.com/Ajax/jQuery.ajax#options">
+ * http://docs.jquery.com/Ajax/jQuery.ajax#options</a>. AjaxOptions has the
+ * following fields: type (type of the url request), actionName (name/id of the request),
+ * actionText (text which will be displayed for the user),
+ * beforeSendAction (function called before the ajax request),
+ * beforeSend (function, which calls beforeSendAction), successAction
+ * function called if requested was successfully), success (function, which calls
+ * successAction), errorAction (analogous to successAction), error (analogous to success)
+ * 
+ */
+
+AjaxOptions = function(actionName, actionText, successAction) {
+    if (actionName) {
+        this.actionName = actionName
+    }
+	if (actionText) {
+        this.actionText = actionText
+    }
+    if (successAction) {
+        this.successAction = successAction
+    }
+}
+AjaxOptions.prototype.type = "GET";
+AjaxOptions.prototype.actionName = "Unnamed";
+AjaxOptions.prototype.actionText = "retrieving data";
+AjaxOptions.prototype.beforeSendAction = function() {};
+AjaxOptions.prototype.beforeSend = function() {
+	this.beforeSendAction();
+	statusMessage.add(this.actionName, this.actionText);
+}
+AjaxOptions.prototype.successAction = function(obj) {};
+AjaxOptions.prototype.success = function(obj) {
+	this.successAction(obj);
+	statusMessage.remove(this.actionName);
+}
+AjaxOptions.prototype.errorAction = function() {};
+AjaxOptions.prototype.error = function(XMLHttpRequest, textStatus, errorThrown) {
+    this.errorAction();
+	AlertMessage.show(function(){}, "The following error occured: " + textStatus, "Error", "Ok");
+	statusMessage.remove(this.actionName);
+};

Added: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.webapp.parent/org.apache.clerezza.web.resources.scripts/src/main/resources/org/apache/clerezza/web/resources/scripts/staticweb/overlay.js
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.webapp.parent/org.apache.clerezza.web.resources.scripts/src/main/resources/org/apache/clerezza/web/resources/scripts/staticweb/overlay.js?rev=890758&view=auto
==============================================================================
--- incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.webapp.parent/org.apache.clerezza.web.resources.scripts/src/main/resources/org/apache/clerezza/web/resources/scripts/staticweb/overlay.js (added)
+++ incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.webapp.parent/org.apache.clerezza.web.resources.scripts/src/main/resources/org/apache/clerezza/web/resources/scripts/staticweb/overlay.js Tue Dec 15 11:13:05 2009
@@ -0,0 +1,137 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * <code>Overlay</code> generates an overlay window on the page.
+ * <code>Overlay</code> has a method show, which creates and renders an
+ * overlay. The following css and javascript are required (provided by clerezza):
+ * /yui/container/assets/container-core.css
+ * /yui/yahoo-dom-event/yahoo-dom-event.js
+ * /yui/build/dragdrop/dragdrop-min.js
+ * /yui/container/container-min.js
+ * /yui/resize/resize-min.js
+ *
+ */
+function Overlay(){};
+
+/**
+ * Creates and renders an overlay.
+ *
+ * @param bodyText
+ * @param headerText
+ * @param widthOverlay an optional parameter which specifies the width of the overlay
+ * (default is 560px)
+ * @param heightOverlay an optional parameter which specifies the height of the overlay
+ * (default is 450px)
+ * 
+ *
+ */
+Overlay.show = function(bodyText, headerText, widthOverlay, heightOverlay) {
+
+	if(widthOverlay == undefined || widthOverlay == "") {
+		widthOverlay = "560px";
+	}
+	if(heightOverlay == undefined || heightOverlay == "") {
+		heightOverlay = "450px";
+	}
+
+	this.overlay = new YAHOO.widget.Panel("tx-assetsdetail", {
+		draggable: true,
+		width: "560px",
+		height: "450px",
+		constraintoviewport: true,
+		modal: true,
+		zIndex: 100,
+		close: true,
+		fixedcenter: true,
+		autofillheight: "body",
+		context: ["content"]
+	});
+	
+	if (bodyText.length) {
+		this.overlay.setBody(bodyText);
+	}
+	
+	if (headerText.length) {
+		this.overlay.setHeader(headerText);
+	}	
+	
+	this.overlay.render("tx-body");
+	$("#tx-assetsdetail").addClass("tx-window");
+	
+	// if overlay is closed the overlay is removed from dom (default is visibility: hidden)
+	this.overlay.hideEvent.subscribe(function() {
+		this.overlay.destroy();
+		this.resize.destroy();
+	});
+	
+	// Creates resize object, binding it to the 'tx-assetsdetail' <div>
+	
+	this.resize = new YAHOO.util.Resize("tx-assetsdetail", {
+		handles: ["br"],
+		autoRatio: false,
+		minWidth: 560,
+		minHeight: 300,
+		status: false 
+	});
+
+	// Setup startResize handler, to limit the resize width/height
+	// if the constraintoviewport configuration property is enabled.
+	this.resize.on("startResize", function(args) {
+
+		if (this.cfg.getProperty("constraintoviewport")) {
+			var D = YAHOO.util.Dom;
+
+			var clientRegion = D.getClientRegion();
+			var elRegion = D.getRegion(this.element);
+
+			this.resize.set("maxWidth", clientRegion.right - elRegion.left - YAHOO.widget.Overlay.VIEWPORT_OFFSET);
+			this.resize.set("maxHeight", clientRegion.bottom - elRegion.top - YAHOO.widget.Overlay.VIEWPORT_OFFSET);
+		} else {
+			this.resize.set("maxWidth", null);
+			this.resize.set("maxHeight", null);
+		}
+
+	}, this.overlay, true);
+
+	// Setup resize handler to update the panel's 'height' configuration property
+	// whenever the size of the 'resizablepanel' div changes.
+
+	// Setting the height configuration property will result in the 
+	// body of the Panel being resized to fill the new height (based on the
+	// autofillheight property introduced in 2.6.0) and the iframe shim and 
+	// shadow being resized if required (for IE6 and IE7 quirks mode).
+	this.resize.on("resize", function(args) {
+		var panelHeight = args.height;
+		this.cfg.setProperty("height", panelHeight + "px");
+	}, this.overlay, true);
+
+};
+
+Overlay.close = function() {
+	this.overlay.destroy();	
+	this.resize.destroy();	
+}
+
+
+
+
+
+
+