portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From woon...@apache.org
Subject svn commit: r882621 - /portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/toolbox/toolbox.jsp
Date Fri, 20 Nov 2009 15:56:52 GMT
Author: woonsan
Date: Fri Nov 20 15:56:52 2009
New Revision: 882621

URL: http://svn.apache.org/viewvc?rev=882621&view=rev
Log:
JS2-1057: Moving event handlers for toolbox portlet from portal.js

Modified:
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/toolbox/toolbox.jsp

Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/toolbox/toolbox.jsp
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/toolbox/toolbox.jsp?rev=882621&r1=882620&r2=882621&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/toolbox/toolbox.jsp
(original)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/toolbox/toolbox.jsp
Fri Nov 20 15:56:52 2009
@@ -67,7 +67,6 @@
 
 </script>
 
-<form id='jsPortletSearch' method="POST" action='<portlet:actionURL/>'>
 <table style="border-collapse: collapse;  width: 100%; margin-top: 0px; margin-bottom:
0px; float: left;">
     <tr>
     <td class="portlet-section-subheader" colspan='10'>
@@ -83,13 +82,14 @@
 </table>
 
 <table id="<portlet:namespace/>portletsTab" style="border-collapse: collapse;  width:
100%; margin-top: 0px; margin-bottom: 0px; float: left;">
+    <form onsubmit="return false;">
     <tr>
         <th class="portlet-section-header" colspan="10">Portlets</th>
     </tr>
     <tr>
         <td class="portlet-section-subheader" colspan='10'>
-            <input type="text" name="filter" size="15" value="" >
-            <input type="submit" value="search" onClick="loadPortlets(null); alert('test');"/>
+            <input id="<portlet:namespace/>query" type="text" name="filter" size="15"
value="" >
+            <input id="<portlet:namespace/>search" type="button" value="Search"
/>
         </td>
     </tr>
     
@@ -107,16 +107,7 @@
     <tr>
         <td>
             <div style="height: 400px; overflow: auto;">
-                <table class="portlet-panel-portlets" style="border-collapse: collapse;
width: 100%; margin-top: 0px; margin-bottom: 0px; float: left;">
-					<!--
-                    <c:forEach var="portletInfo" items="${portlets}">
-                        <tr>
-                            <td class="portlet-section-body" style='background: #fff'>
-                                
-                            </td>
-                        </tr>
-                    </c:forEach>
-					-->
+                <table id="<portlet:namespace/>portletsTable" class="portlet-panel-portlets"
style="border-collapse: collapse; width: 100%; margin-top: 0px; margin-bottom: 0px; float:
left;">
                 </table>
             </div>
         </td>
@@ -125,14 +116,17 @@
     <tr>
         <th class="portlet-section-header" colspan="2"></th>
     </tr>
+    </form>
 </table>
 
-<table id="portlet-body-html" style="display: none; border-collapse: collapse; width:
100%; margin-top: 0px; margin-bottom: 0px; float: left;">
+<table id="<portlet:namespace/>portletItemTemplate" style="display: none; border-collapse:
collapse; width: 100%; margin-top: 0px; margin-bottom: 0px; float: left;">
     <tr>
-       <td rowspan="2" width="20%" class="portlet-section-body">
-           <img src='${portalContextPath}' />
-       </td>
-       <td id="name" width="80%" class="portlet-section-body">#</td>
+        <td rowspan="2" width="20%" class="portlet-section-body">
+            <img src='${portalContextPath}' />
+        </td>
+        <td width="80%" class="portlet-section-body">
+            <div>#</span>
+        </td>
     </tr>       
     <tr>
        <td class="portlet-section-body">
@@ -146,18 +140,28 @@
     <tr>
         <th class="portlet-section-header" colspan="2">Layouts</th>
     </tr>
-    <c:forEach var="layout" items="${layouts}">	
-	<tr>		
-		<c:choose><c:when test="${editAccess}">
-         <td><a href='<portlet:actionURL><portlet:param name='layout' value="${layout.layoutPortlet}"/></portlet:actionURL>'><img
<c:if test="${!layout.selected}"> style='border-style: none' </c:if> src='<c:url
context="${portalContextPath}" value="/layouts/${layout.image}"/>'></a></td>
-		</c:when>
-		<c:otherwise>
-         <td><img <c:if test="${layout.selected}"> style='border-style: solid'
</c:if> src='<c:url context="${portalContextPath}" value="/layouts/${layout.image}"/>'></td>
-		</c:otherwise>
-		</c:choose>
-		 <td style="vertical-align: middle">${layout.title}</td>
-	</tr>
-	</c:forEach>
+    <c:forEach var="layout" items="${layouts}"> 
+    <tr>        
+        <c:choose>
+            <c:when test="${editAccess}">
+                <td><a href='<portlet:actionURL><portlet:param name='layout'
value="${layout.layoutPortlet}"/></portlet:actionURL>'><img <c:if test="${!layout.selected}">
style='border-style: none' </c:if> src='<c:url context="${portalContextPath}" value="/layouts/${layout.image}"/>'></a></td>
+            </c:when>
+            <c:otherwise>
+                <td>
+                    <c:choose>
+                        <c:when test="${layout.selected}">
+                            <img style='border-style: solid' src='<c:url context="${portalContextPath}"
value="/layouts/${layout.image}"/>'>
+                        </c:when>
+                        <c:otherwise>
+                            <img src='<c:url context="${portalContextPath}" value="/layouts/${layout.image}"/>'>
+                        </c:otherwise>
+                    </c:choose>
+                </td>
+            </c:otherwise>
+        </c:choose>
+        <td style="vertical-align: middle">${layout.title}</td>
+    </tr>
+    </c:forEach>
     <tr>
         <th class="portlet-section-header" colspan="2"></th>
     </tr>
@@ -168,18 +172,19 @@
     <tr>
         <th class="portlet-section-header" colspan="2">Themes</th>
     </tr>
-    <c:forEach var="theme" items="${themes}">	
-	<tr>		
-		<c:choose><c:when test="${editAccess}">
-         <td><a href='<portlet:actionURL><portlet:param name='theme' value="${theme.name}"/></portlet:actionURL>'><img
<c:if test="${!theme.selected}"> style='border-style: none' </c:if> src='<c:url
context="${portalContextPath}" value="/decorations/layout/${theme.name}/${theme.image}"/>'></a></td>
-		</c:when>
-		<c:otherwise>
-         <td><img <c:if test="${theme.selected}"> style='border-style: solid'
</c:if> src='<c:url context="${portalContextPath}" value="/decorations/layout/${theme.name}/${theme.image}"/>'></td>
-		</c:otherwise>
-		</c:choose>
-		 <td style="vertical-align: middle">${theme.title}</td>
-	</tr>
-	</c:forEach>
+    <c:forEach var="theme" items="${themes}">   
+    <tr>        
+        <c:choose>
+            <c:when test="${editAccess}">
+                <td><a href='<portlet:actionURL><portlet:param name='theme'
value="${theme.name}"/></portlet:actionURL>'><img <c:if test="${!theme.selected}">
style='border-style: none' </c:if> src='<c:url context="${portalContextPath}" value="/decorations/layout/${theme.name}/${theme.image}"/>'></a></td>
+            </c:when>
+            <c:otherwise>
+                <td><img <c:if test="${theme.selected}"> style='border-style:
solid' </c:if> src='<c:url context="${portalContextPath}" value="/decorations/layout/${theme.name}/${theme.image}"/>'></td>
+            </c:otherwise>
+        </c:choose>
+        <td style="vertical-align: middle">${theme.title}</td>
+    </tr>
+    </c:forEach>
     <tr>
         <th class="portlet-section-header" colspan="2"></th>
     </tr>
@@ -194,4 +199,77 @@
     </tr>
 </table>
 
-</form>
\ No newline at end of file
+<script language="javascript">
+YUI(yuiConfig).use('io', 'dataschema-json', 'node-base', function(Y) {
+    var onLoadPortletComplete = function(id, o, args) { 
+        var id = id; // Transaction ID. 
+        var data = o.responseText; // Response data.
+        var portletsTable = Y.Node.one("#<portlet:namespace/>portletsTable");
+        var schemaPortletList = {
+            metaFields: {status:"status", action:"action"},
+            resultListLocator: "portlets", 
+            resultFields: [{key:"name"}, {key:"displayName"}, {key:"description"}, {key:"image"}]
+        };
+
+        var dataOut = null;
+
+        try {
+            dataOut = Y.DataSchema.JSON.apply(schemaPortletList, data);
+            // TODO: error handling
+            if (!dataOut) {
+                Y.log("Error: no data found.");
+                return;
+            } else if (dataOut.error) {
+                Y.log("Error: " + dataOut.error);
+                return;
+            }
+        } catch (e) {
+            Y.log("Error: " + e.message);
+            return;
+        }
+        
+        var templatePanel = Y.Node.one("#<portlet:namespace/>portletItemTemplate");
+        var results = dataOut.results;
+        for (var i = 0; i < results.length; i++) {
+            var item = results[i];
+            var clone = templatePanel.cloneNode(true);
+            clone.setStyle('display', '');
+            var imgNode = clone.one('img');
+            var url = imgNode.get('src');
+            var imgURL = url + "/" + item.image;
+            imgNode.set('src', imgURL);
+            var nameNode = clone.one('div');
+            nameNode.setContent(item.displayName);
+            
+            <c:if test="${editAccess}">
+                var actionURL = "<portlet:actionURL/>";
+                var addActionURL = actionURL + (actionURL.indexOf('?') == -1 ? "?portletAdd="
: "&portletAdd=") + item.name;
+                clone.all("a").item(1).set("href", addActionURL);
+            </c:if>
+            
+            // TODO: add handlers for add and preview
+            // TODO: limit # of portlets to n...
+            // TODO: support paging...
+            clone.set("id", "<portlet:namespace/>portletItem-" + item.name);
+            
+            portletsTable.appendChild(clone);
+        }
+    };
+    
+    var loadPortlets = function() {
+        var uri = document.location.href;
+        uri = uri.replace("/ui/", "/ajaxapi/").replace(/#$/, "");
+        uri += "?action=getportlets&format=json";
+        var filter = Y.Node.one("#<portlet:namespace/>query").get("value");
+        if (filter) {
+            uri += "&filter=" + filter;
+        }
+        Y.on('io:complete', onLoadPortletComplete, this, []); 
+        var request = Y.io(uri);
+    };
+    
+    Y.on("click", loadPortlets, "#<portlet:namespace/>search");
+    
+    loadPortlets();
+});
+</script>



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Mime
View raw message