Author: tyrell Date: Sat Jul 12 18:49:36 2008 New Revision: 19184 URL: http://wso2.org/svn/browse/wso2?view=rev&revision=19184
Log: Handling recursive dialog display. If a dialog is already displayed, closing it and re-building. Modified: trunk/mashup/java/modules/www/js/mashup-utils.js Modified: trunk/mashup/java/modules/www/js/mashup-utils.js URL: http://wso2.org/svn/browse/wso2/trunk/mashup/java/modules/www/js/mashup-utils.js?rev=19184&r1=19183&r2=19184&view=diff ============================================================================== --- trunk/mashup/java/modules/www/js/mashup-utils.js (original) +++ trunk/mashup/java/modules/www/js/mashup-utils.js Sat Jul 12 18:49:36 2008 @@ -75,7 +75,8 @@ mashupEprs = xmlDataContent.getElementsByTagName("ns:eprs"); mashupOperartions = xmlDataContent.getElementsByTagName("ns:operations"); mashupStatus = xmlDataContent.getElementsByTagName("ns:active")[0].firstChild.nodeValue; - mashupServiceType = xmlDataContent.getElementsByTagName("ns:serviceType")[0].firstChild.nodeValue; + mashupServiceType = + xmlDataContent.getElementsByTagName("ns:serviceType")[0].firstChild.nodeValue; } else { mashupId = xmlDataContent.getElementsByTagName("serviceId")[0].firstChild.nodeValue; mashupTitle = xmlDataContent.getElementsByTagName("name")[0].firstChild.nodeValue; @@ -83,7 +84,8 @@ mashupEprs = xmlDataContent.getElementsByTagName("eprs"); mashupOperartions = xmlDataContent.getElementsByTagName("operations"); mashupStatus = xmlDataContent.getElementsByTagName("active")[0].firstChild.nodeValue; - mashupServiceType = xmlDataContent.getElementsByTagName("serviceType")[0].firstChild.nodeValue; + mashupServiceType = + xmlDataContent.getElementsByTagName("serviceType")[0].firstChild.nodeValue; } return new wso2.mashup.Mashup(mashupId, mashupTitle, mashupDesc, mashupEprs, mashupOperartions, mashupStatus, mashupServiceType); @@ -166,13 +168,17 @@ '<tr><td nowrap height="25"><b>Destination Server Username: </b></td><td><input name="txtDestUsername" type="text" id="txtDestUsername" size="50"/></td></tr>' + '<tr><td nowrap height="25"><b>Destination Server Password: </b></td><td><input name="txtDestPassword" type="password" id="txtDestPassword" size="50"/></td></tr>' + '<tr><td></td><td nowrap height="30" valign="bottom"><input type="button" id="cmdShare" value="Share" onclick="WSO2.MashupUtils.shareService(\'' + - serviceName + '\', \'userpass\',\'' + localUserName + '\', \'noBasicAuth\',\'' + null + '\',\'' + null + '\',\'' + null + '\',\'' + null + '\',\'' + null + '\');"/></td></tr>'; + serviceName + '\', \'userpass\',\'' + localUserName + + '\', \'noBasicAuth\',\'' + null + '\',\'' + null + '\',\'' + null + + '\',\'' + null + '\',\'' + null + '\');"/></td></tr>'; if (InformationCard.AreCardsSupported()) { strFrmService += '<tr><td height="25"><hr>If you have an associated InfoCard to login to the destination server, use the option below</td><td><img src="images/infocard_92x64.png" border="0"</td></tr>' + '<tr><td height="25"><input type="button" onclick="WSO2.MashupUtils.shareService(\'' + - serviceName + '\', \'infocard\',\'' + localUserName + '\', \'noBasicAuth\',\'' + null + '\',\'' + null + '\',\'' + null + '\',\'' + null + '\',\'' + null + '\');" value="Share with infocard"/></td></tr>'; + serviceName + '\', \'infocard\',\'' + localUserName + '\', \'noBasicAuth\',\'' + null + + '\',\'' + null + '\',\'' + null + '\',\'' + null + '\',\'' + null + + '\');" value="Share with infocard"/></td></tr>'; } strFrmService += '</table>' + @@ -185,7 +191,9 @@ }); }; -WSO2.MashupUtils.showMashupSharingWithHTTPBasicAuthDialog = function (serviceName, localUserName, mode, destAddress, destUsername, destPassword, overwriteExisting, migrateTags) { +WSO2.MashupUtils.showMashupSharingWithHTTPBasicAuthDialog = +function (serviceName, localUserName, mode, destAddress, destUsername, destPassword, + overwriteExisting, migrateTags) { //Creating the content div var strFrmService = '<table align="center" border="0">' + @@ -196,11 +204,15 @@ if (mode == "infocard") { strFrmService += '<input type="button" onclick="WSO2.MashupUtils.shareService(\'' + - serviceName + '\', \'infocard\',\'' + localUserName + '\' , \'withBasicAuth\',\'' + destAddress + '\',\'' + destUsername + '\',\'' + destPassword + '\',\'' + overwriteExisting + '\',\'' + migrateTags + '\');" value="Share Service"/></td></tr>'; + serviceName + '\', \'infocard\',\'' + localUserName + '\' , \'withBasicAuth\',\'' + + destAddress + '\',\'' + destUsername + '\',\'' + destPassword + '\',\'' + + overwriteExisting + '\',\'' + migrateTags + '\');" value="Share Service"/></td></tr>'; } else { strFrmService += '<input type="button" id="cmdShare" value="Share" onclick="WSO2.MashupUtils.shareService(\'' + - serviceName + '\', \'userpass\',\'' + localUserName + '\' , \'withBasicAuth\',\'' + destAddress + '\',\'' + destUsername + '\',\'' + destPassword + '\',\'' + overwriteExisting + '\',\'' + migrateTags + '\');"/></td></tr>'; + serviceName + '\', \'userpass\',\'' + localUserName + '\' , \'withBasicAuth\',\'' + + destAddress + '\',\'' + destUsername + '\',\'' + destPassword + '\',\'' + + overwriteExisting + '\',\'' + migrateTags + '\');"/></td></tr>'; } strFrmService += '</table>' + @@ -214,7 +226,8 @@ WSO2.MashupUtils.shareService = function (serviceName, mode, localUserName, basicAuth, destAddress, - destUsername, destPassword, overwriteExisting, migrateTags) { + destUsername, destPassword, overwriteExisting, + migrateTags) { function submitServiceCallback() { var returnElementList = this.req.responseXML.getElementsByTagName("ns:return"); @@ -238,12 +251,15 @@ if (lastChar == "/") { mashupUrl = destAddress + SERVICE_PATH + '/' + destUsername + '/' + mashupName; } else { - mashupUrl = destAddress + '/' + SERVICE_PATH + '/' + destUsername + '/' + mashupName; + mashupUrl = + destAddress + '/' + SERVICE_PATH + '/' + destUsername + '/' + mashupName; } - + var strShareSuccess = '<table align="center" border="0">' + - '<tr><td nowrap height="25">The Mashup ' + mashupName + ' has been successfully shared!</td></tr>' + - '<tr><td nowrap height="25">Click <a href="' + mashupUrl + '">here</a> to view the mashup on ' + destAddress + '<tr><td nowrap height="25">The Mashup ' + mashupName + + ' has been successfully shared!</td></tr>' + + '<tr><td nowrap height="25">Click <a href="' + mashupUrl + + '">here</a> to view the mashup on ' + destAddress + ', or <a href="javascript:WSO2.MashupUtils.dialog.close()">close</a> this window.</td></tr>' + '</table>'; @@ -263,14 +279,16 @@ if (!error) { this.params.innerHTML = "Failed to share the service. Please refer to system admin for more details."; - } else if (error.reason.indexOf("Transport error: 401 Error: Authorization Required") > -1) { + } else if (error.reason.indexOf("Transport error: 401 Error: Authorization Required") > + -1) { if (document.getElementById("txtBasicAuthUsername") != null) { var labelElement = document.getElementById("lblStatus"); - labelElement.innerHTML = "Credentials provided for HTTP Basic Authentication are incorrect. PLease reenter your username and password." + labelElement.innerHTML = + "Credentials provided for HTTP Basic Authentication are incorrect. PLease reenter your username and password." } else { WSO2.MashupUtils.dialog.close(); WSO2.MashupUtils.showMashupSharingWithHTTPBasicAuthDialog(serviceName, localUserName, - mode, destAddress, destUsername, destPassword, overwriteExisting, migrateTags); + mode, destAddress, destUsername, destPassword, overwriteExisting, migrateTags); } } else if (error.reason.indexOf("Access Denied. Please login first") > -1) { wso2.wsf.Util.alertMessage("Your session has expired."); @@ -280,7 +298,8 @@ this.params.innerHTML = "Failed to share the service. Unknown Host : '" + error.reason + "'"; } else if (error.reason.indexOf("No trusted certificate found") > -1) { - this.params.innerHTML = "Failed to share the service since a trusted certificate was not found for the destination site.<br/> You can manage your trusted certificates <a target='_blank' href='cert_manager.jsp'>here</a>. (Link opens a new window)"; + this.params.innerHTML = + "Failed to share the service since a trusted certificate was not found for the destination site.<br/> You can manage your trusted certificates <a target='_blank' href='cert_manager.jsp'>here</a>. (Link opens a new window)"; } else { this.params.innerHTML = "Failed to share the service. " + error.reason; @@ -308,7 +327,8 @@ var basicAuthUsername = ""; var basicAuthPassword = ""; if (basicAuth == "withBasicAuth") { - labelElement.innerHTML = "Contacting backend services. Please wait... Authenticating to remote site via HTTP Basic Authentication"; + labelElement.innerHTML = + "Contacting backend services. Please wait... Authenticating to remote site via HTTP Basic Authentication"; basicAuthUsername = document.getElementById("txtBasicAuthUsername").value; basicAuthPassword = document.getElementById("txtBasicAuthPassword").value; labelElement.innerHTML = "Contacting backend services. Please wait..."; @@ -395,7 +415,8 @@ var lblWarnMessage = document.createElement("label"); var txtStrong = document.createElement("strong"); txtStrong.appendChild(document.createTextNode("Please confirm that you wish to delete the '" + - tag + "' tag added by any and all users to this Mashup!")); + tag + + "' tag added by any and all users to this Mashup!")); lblWarnMessage.appendChild(txtStrong); parent.appendChild(lblWarnMessage); @@ -666,7 +687,8 @@ WSO2.MashupUtils.showMashupDownloadingDialog = function (serviceName) { //Creating the form content - var downloadForm = '<form method="post" style="display:inline;" id="downloadForm" name="downloadForm" action="' + SERVICE_PATH + '/ServiceSharingHelper/downloadService">' + + var downloadForm = '<form method="post" style="display:inline;" id="downloadForm" name="downloadForm" action="' + + SERVICE_PATH + '/ServiceSharingHelper/downloadService">' + '<input size="10" id="txtServiceName" name="serviceName" type="hidden" value="' + serviceName + '">' + '<table width="100%" border="0" cellspacing="0" cellpadding="0">' + @@ -700,7 +722,8 @@ }; YAHOO.util.Connect.setForm("downloadForm"); - YAHOO.util.Connect.asyncRequest('POST', SERVICE_PATH + '/ServiceSharingHelper/downloadService', callback, null); + YAHOO.util.Connect.asyncRequest('POST', SERVICE_PATH + + '/ServiceSharingHelper/downloadService', callback, null); WSO2.MashupUtils.dialog.close(); } @@ -847,7 +870,9 @@ }); } else { - document.getElementById('lyrDialog').style.display = "block"; + // Closing the existing dialog and re-buildinga a new one + WSO2.MashupUtils.dialog.close(); + WSO2.MashupUtils.dialog(strTitle, strBody, width, height, elementToFocusAfterLoading); } }; _______________________________________________ Mashup-dev mailing list [email protected] http://wso2.org/cgi-bin/mailman/listinfo/mashup-dev
