Author: tyrell
Date: Mon Jan 14 20:47:10 2008
New Revision: 12232
Log:
Migrating the mashup sharing dialog from YUI to our own.
Modified:
trunk/mashup/java/modules/www/js/mashup-utils.js
Modified: trunk/mashup/java/modules/www/js/mashup-utils.js
==============================================================================
--- trunk/mashup/java/modules/www/js/mashup-utils.js (original)
+++ trunk/mashup/java/modules/www/js/mashup-utils.js Mon Jan 14 20:47:10 2008
@@ -146,196 +146,83 @@
WSO2.MashupUtils.showMashupSharingDialog = function (serviceName) {
//Creating the content div
- var parent = document.createElement("div");
- parent.setAttribute("id", "MashupSharingDialog");
-
var strFrmService = '<br><table align="center" border="0">' +
'<tr><td width="170">Destination Server
Address</td><td><input name="txtDestAddress" type="text" id="txtDestAddress"
value="http://mashups.wso2.org" size="50"/></td></tr>' +
'<tr><td>Destination Server Username</td><td><input
name="txtDestUsername" type="text" id="txtDestUsername" size="50"/></td></tr>' +
'<tr><td>Destination Server Password</td><td><input
name="txtDestPassword" type="password" id="txtDestPassword"
size="50"/></td></tr>' +
- '<tr><td><label id="lblStatus"></label></td></tr>' +
- '</table>';
-
- /*
- var lblDestAddress = document.createElement("label");
- lblDestAddress.appendChild(document.createTextNode("Destination Server
Address "));
- parent.appendChild(lblDestAddress);
-
- var txtDestServerAddress = document.createElement("input");
- txtDestServerAddress.setAttribute("type", "text");
- txtDestServerAddress.setAttribute("id", "txtDestAddress");
- txtDestServerAddress.setAttribute("value", "http://mashups.wso2.org");
- txtDestServerAddress.setAttribute("size", "50");
- parent.appendChild(txtDestServerAddress);
-
- parent.appendChild(document.createElement("br"));
- parent.appendChild(document.createElement("br"));
-
- var lblUsername = document.createElement("label");
- lblUsername.appendChild(document.createTextNode("Destination Server
Username "));
- parent.appendChild(lblUsername);
-
- var txtDestServerUsername = document.createElement("input");
- txtDestServerUsername.setAttribute("type", "text");
- txtDestServerUsername.setAttribute("id", "txtDestUsername");
- txtDestServerUsername.setAttribute("size", "50");
- parent.appendChild(txtDestServerUsername);
-
- parent.appendChild(document.createElement("br"));
- parent.appendChild(document.createElement("br"));
-
- var lblPassword = document.createElement("label");
- lblPassword.appendChild(document.createTextNode("Destination Server
Password "));
- parent.appendChild(lblPassword);
-
-
- var txtDestServerPassword = document.createElement("input");
- txtDestServerPassword.setAttribute("type", "password");
- txtDestServerPassword.setAttribute("id", "txtDestPassword");
- txtDestServerPassword.setAttribute("size", "50");
- parent.appendChild(txtDestServerPassword);
-
- parent.appendChild(document.createElement("br"));
- parent.appendChild(document.createElement("br"));
-
- var lblStatusMessages = document.createElement("label");
- lblStatusMessages.setAttribute("id", "lblStatus");
- parent.appendChild(lblStatusMessages);
- */
+ '<tr><td><input type="button" id="cmdShare"
value="Share" onclick="WSO2.MashupUtils.shareService(\'' +
+ serviceName + '\');"/></td></tr>' +
+ '</table>' +
+ '<label id="lblStatus" style="width: auto;"></label>';
YAHOO.util.Event.onContentReady('doc3', function() {
// Instantiate the Dialog
- var browser = WSRequest.util._getBrowser();
- var serviceSharingDialog = "";
+ WSO2.MashupUtils.dialog("Share " + serviceName +
+ " with others", strFrmService, 100, 100);
+ });
+};
+
+
+WSO2.MashupUtils.shareService = function (serviceName) {
+ function submitServiceCallback() {
+
+ var response ;
+ var browser = WSRequest.util._getBrowser();
if (browser == "ie" || browser == "ie7") {
- serviceSharingDialog = new
YAHOO.widget.Dialog("MashupSharingDialog",
- {
- width : "600px",
- x:YAHOO.util.Dom.getViewportWidth() /
- 8, //Manual fix for getting rubbish viewport dimensions in IE
- y:100,
- draggable:true,
- visible : false,
- modal:true,
- close:false,
- buttons : [ { text:"Submit", handler:handleSubmit,
isDefault:true },
- { text:"Close", handler:handleCancel } ]
- });
+ response =
+
this.req.responseXML.getElementsByTagName("ns:return")[0].firstChild.nodeValue;
} else {
- serviceSharingDialog = new
YAHOO.widget.Dialog("MashupSharingDialog",
- { width : "600px",
- fixedcenter : true,
- draggable:true,
- visible : false,
- constraintoviewport : true,
- modal:true,
- close:false,
- buttons : [ { text:"Submit", handler:handleSubmit,
isDefault:true },
- { text:"Close", handler:handleCancel } ]
- });
+ response =
+
this.req.responseXML.getElementsByTagName("return")[0].firstChild.nodeValue;
}
- var strSharingDialogHeader = '<table border="0" width="100%"
cellpadding="0" cellspacing="0">' +
- '<tr>' +
- '<td><img
src="images/w_small_top_left_edit.gif"/></td>' +
- '<td class="mashup-editer-hd" >Share "' +
serviceName +
- '" with others</td>' +
- '<td><img
src="images/w_top_right_edit.gif"/></td>' +
- '</tr>' +
- '</table>';
-
-
- serviceSharingDialog.setHeader(strSharingDialogHeader);
- serviceSharingDialog.setBody(strFrmService);
- serviceSharingDialog.render("content");
- serviceSharingDialog.show();
- document.getElementById("txtDestAddress").focus();
-
- WSO2.MashupUtils.currentActiveModelDialog = serviceSharingDialog;
-
- // Event handlers for the Dialog
- function handleSubmit() {
- var labelElement = document.getElementById("lblStatus");
- var destAddress = document.getElementById("txtDestAddress").value;
- var destUsername =
document.getElementById("txtDestUsername").value;
- var destPassword =
document.getElementById("txtDestPassword").value;
-
- if (WSO2.MashupUtils.isUrl(destAddress)) {
- labelElement.innerHTML = "";
- labelElement.appendChild(document.createTextNode("Contacting
backend services. Please wait..."));
- wso2.mashup.services.shareService(serviceName, destAddress,
destUsername, destPassword, submitServiceCallback, labelElement,
submitServiceError);
- }
- else {
- labelElement.innerHTML = "";
- labelElement.appendChild(document.createTextNode("Please enter
a valid server address here ..."));
- }
+ if (response == "true") {
+ this.params.innerHTML =
+ "The service was successfully shared. You can safely close this
window.";
+ } else {
+ this.params.innerHTML =
+ "Failed to share the service. Please verify the destination
address.";
}
+ }
- function submitServiceCallback() {
-
- var response ;
-
- var browser = WSRequest.util._getBrowser();
- if (browser == "ie" || browser == "ie7") {
- response =
-
this.req.responseXML.getElementsByTagName("ns:return")[0].firstChild.nodeValue;
- } else {
- response =
-
this.req.responseXML.getElementsByTagName("return")[0].firstChild.nodeValue;
- }
-
- if (response == "true") {
- this.params.innerHTML = "";
- this.params.appendChild(document.createTextNode("The service
was successfully shared. You can safely close this window."));
+ function submitServiceError() {
- } else {
- this.params.innerHTML = "";
- this.params.appendChild(document.createTextNode("Failed to
share the service. Please verify the destination address."));
- }
+ var error = this.req.error;
+ if (!error) {
+ this.params.innerHTML =
+ "Failed to share the service. Please refer to system admin for
more details.";
}
- function submitServiceError() {
-
- var error = this.req.error;
- if (!error) {
- this.params.innerHTML = "";
- this.params.appendChild(document.createTextNode("Failed to
share the service. Please refer to system admin for more details."));
- }
-
- else if (error.reason.indexOf("Access Denied. Please login first")
> -1) {
- wso2.wsf.Util.alertMessage("Your session has expired.");
+ else if (error.reason.indexOf("Access Denied. Please login first") >
-1) {
+ wso2.wsf.Util.alertMessage("Your session has expired.");
//Envoking force logout
- wso2.mashup.services.logout(wso2.mashup.handleLogout);
- }
-
- else if (error.reason.indexOf("UnknownHostException") > -1) {
- this.params.innerHTML = "";
- this.params.appendChild(document.createTextNode("Failed to
share the service. Unknown Host : '" +
- error.reason +
"'"));
- } else {
- this.params.innerHTML = "";
- this.params.appendChild(document.createTextNode("Failed to
share the service. " +
- error.reason));
- }
+ wso2.mashup.services.logout(wso2.mashup.handleLogout);
}
- function handleCancel() {
- this.cancel();
- clearDom();
- WSO2.MashupUtils.currentActiveModelDialog = null;
- }
+ else if (error.reason.indexOf("UnknownHostException") > -1) {
+ this.params.innerHTML = "Failed to share the service. Unknown Host
: '" +
+ error.reason + "'";
+ } else {
+ this.params.innerHTML = "Failed to share the service. " +
error.reason;
- function clearDom() {
- var dialogMask =
document.getElementById("MashupSharingDialog_mask");
- dialogMask.parentNode.removeChild(dialogMask);
- var dialogResedue =
document.getElementById("MashupSharingDialog_c");
- dialogResedue.parentNode.removeChild(dialogResedue);
}
- });
-};
+ }
+ var labelElement = document.getElementById("lblStatus");
+ var destAddress = document.getElementById("txtDestAddress").value;
+ var destUsername = document.getElementById("txtDestUsername").value;
+ var destPassword = document.getElementById("txtDestPassword").value;
+
+ if (WSO2.MashupUtils.isUrl(destAddress)) {
+ labelElement.innerHTML = "Contacting backend services. Please wait...";
+ wso2.mashup.services.shareService(serviceName, destAddress,
destUsername, destPassword, submitServiceCallback, labelElement,
submitServiceError);
+ }
+ else {
+ labelElement.innerHTML = "Please enter a valid server address here
...";
+ }
+};
/**
* @description Displays the dialog to create a new mashup.
_______________________________________________
Mashup-dev mailing list
[email protected]
http://www.wso2.org/cgi-bin/mailman/listinfo/mashup-dev