Author: smilek
Date: Mon Sep 24 12:11:09 2007
New Revision: 578913

URL: http://svn.apache.org/viewvc?rev=578913&view=rev
Log:
moved portlet selector code out of core.js

Added:
    
portals/jetspeed-2/branches/JETSPEED-2.1.3/src/webapp/javascript/jetspeed/selector.js
    
portals/jetspeed-2/branches/JETSPEED-2.1.3/src/webapp/javascript/jetspeed/selector.src.js

Added: 
portals/jetspeed-2/branches/JETSPEED-2.1.3/src/webapp/javascript/jetspeed/selector.js
URL: 
http://svn.apache.org/viewvc/portals/jetspeed-2/branches/JETSPEED-2.1.3/src/webapp/javascript/jetspeed/selector.js?rev=578913&view=auto
==============================================================================
--- 
portals/jetspeed-2/branches/JETSPEED-2.1.3/src/webapp/javascript/jetspeed/selector.js
 (added)
+++ 
portals/jetspeed-2/branches/JETSPEED-2.1.3/src/webapp/javascript/jetspeed/selector.js
 Mon Sep 24 12:11:09 2007
@@ -0,0 +1,67 @@
+if(window.dojo){
+dojo.provide("jetspeed.selector");
+dojo.require("jetspeed.common");
+}
+if(!window.jetspeed){
+jetspeed={};
+}
+if(!jetspeed.selector){
+jetspeed.selector={};
+}
+jetspeed.selector.PortletDef=function(_1,_2,_3,_4,_5){
+this.portletName=_1;
+this.portletDisplayName=_2;
+this.portletDescription=_3;
+this.image=_4;
+this.count=_5;
+};
+jetspeed.selector.PortletDef.prototype={portletName:null,portletDisplayName:null,portletDescription:null,portletImage:null,portletCount:null,getId:function(){
+return this.portletName;
+},getPortletName:function(){
+return this.portletName;
+},getPortletDisplayName:function(){
+return this.portletDisplayName;
+},getPortletCount:function(){
+return this.portletCount;
+},getPortletDescription:function(){
+return this.portletDescription;
+}};
+jetspeed.selector.addNewPortletDefinition=function(_6,_7,_8){
+var _9=new jetspeed.selector.PortletAddAjaxApiCallbackCL(_6);
+var _a="?action=add&id="+escape(_6.getPortletName());
+if(_8!=null&&_8.length>0){
+_a+="&layoutid="+escape(_8);
+}
+var _b=_7+_a;
+var _c="text/xml";
+var _d=new jetspeed.om.Id("addportlet",{});
+jetspeed.url.retrieveContent({url:_b,mimetype:_c},_9,_d,jetspeed.debugContentDumpIds);
+};
+jetspeed.selector.PortletAddAjaxApiCallbackCL=function(_e){
+this.portletDef=_e;
+};
+jetspeed.selector.PortletAddAjaxApiCallbackCL.prototype={notifySuccess:function(_f,_10,_11){
+jetspeed.url.checkAjaxApiResponse(_10,_f,true,"add-portlet");
+},parseAddPortletResponse:function(_12){
+var _13=null;
+var _14=_12.getElementsByTagName("js");
+if(!_14||_14.length>1){
+dojo.raise("unexpected zero or multiple <js> elements in portlet selector 
xml");
+}
+var _15=_14[0].childNodes;
+for(var i=0;i<_15.length;i++){
+var _17=_15[i];
+if(_17.nodeType!=1){
+continue;
+}
+var _18=_17.nodeName;
+if(_18=="entity"){
+_13=((_17&&_17.firstChild)?_17.firstChild.nodeValue:null);
+break;
+}
+}
+return _13;
+},notifyFailure:function(_19,_1a,_1b,_1c){
+dojo.raise("PortletAddAjaxApiCallbackCL error ["+_1c.toString()+"] url: 
"+_1b+" type: "+_19+jetspeed.url.formatBindError(_1a));
+}};
+

Added: 
portals/jetspeed-2/branches/JETSPEED-2.1.3/src/webapp/javascript/jetspeed/selector.src.js
URL: 
http://svn.apache.org/viewvc/portals/jetspeed-2/branches/JETSPEED-2.1.3/src/webapp/javascript/jetspeed/selector.src.js?rev=578913&view=auto
==============================================================================
--- 
portals/jetspeed-2/branches/JETSPEED-2.1.3/src/webapp/javascript/jetspeed/selector.src.js
 (added)
+++ 
portals/jetspeed-2/branches/JETSPEED-2.1.3/src/webapp/javascript/jetspeed/selector.src.js
 Mon Sep 24 12:11:09 2007
@@ -0,0 +1,123 @@
+/*
+ * 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.
+ *
+ * author: Steve Milek
+ */
+
+// jetspeed javascript to help support portlet-selector in both /portal and 
/desktop
+
+if ( window.dojo )
+{
+    dojo.provide( "jetspeed.selector" );
+    dojo.require( "jetspeed.common" );
+}
+
+// ... jetspeed base objects
+if ( ! window.jetspeed )
+    jetspeed = {};
+if ( ! jetspeed.selector )
+    jetspeed.selector = {} ;
+
+// ... jetspeed.selector.PortletDef
+jetspeed.selector.PortletDef = function( /* String */ portletName, /* String 
*/ portletDisplayName, /* String */ portletDescription, /* String */ 
portletImage,portletCount)
+{
+    this.portletName = portletName;
+    this.portletDisplayName = portletDisplayName;
+    this.portletDescription = portletDescription;
+    this.image = portletImage;
+       this.count = portletCount;
+};
+jetspeed.selector.PortletDef.prototype =
+{
+    portletName: null,
+    portletDisplayName: null,
+    portletDescription: null,
+    portletImage: null,
+       portletCount: null,
+    getId: function()
+    {
+        return this.portletName;
+    },
+    getPortletName: function()
+    {
+        return this.portletName;
+    },
+    getPortletDisplayName: function()
+    {
+        return this.portletDisplayName;
+    },
+       getPortletCount: function()
+    {
+        return this.portletCount;
+    },
+    getPortletDescription: function()
+    {
+        return this.portletDescription;
+    }
+};
+
+jetspeed.selector.addNewPortletDefinition = function( /* 
jetspeed.selector.PortletDef */ portletDef, /* String */ psmlUrl, /* String */ 
layoutId )
+{
+    var contentListener = new jetspeed.selector.PortletAddAjaxApiCallbackCL( 
portletDef );
+    var queryString = "?action=add&id=" + escape( portletDef.getPortletName() 
);
+    if ( layoutId != null && layoutId.length > 0 )
+    {
+        queryString += "&layoutid=" + escape( layoutId );
+    }
+    var addPortletUrl = psmlUrl + queryString;   //  psmlUrl example: 
http://localhost:8080/jetspeed/ajaxapi/google-maps.psml
+    var mimetype = "text/xml";
+    var ajaxApiContext = new jetspeed.om.Id( "addportlet", { } );
+    jetspeed.url.retrieveContent( { url: addPortletUrl, mimetype: mimetype }, 
contentListener, ajaxApiContext, jetspeed.debugContentDumpIds );
+};
+
+// ... jetspeed.selector.PortletAddAjaxApiCallbackCL
+jetspeed.selector.PortletAddAjaxApiCallbackCL = function( /* 
jetspeed.selector.PortletDef */ portletDef )
+{
+    this.portletDef = portletDef;
+};
+jetspeed.selector.PortletAddAjaxApiCallbackCL.prototype =
+{
+    notifySuccess: function( /* XMLDocument */ data, /* String */ requestUrl, 
domainModelObject )
+    {
+        jetspeed.url.checkAjaxApiResponse( requestUrl, data, true, 
"add-portlet" );
+    },
+    parseAddPortletResponse: function( /* XMLNode */ node )
+    {
+        var entityId = null;
+        var jsElements = node.getElementsByTagName( "js" );
+        if ( ! jsElements || jsElements.length > 1 )
+            dojo.raise( "unexpected zero or multiple <js> elements in portlet 
selector xml" );
+        var children = jsElements[0].childNodes;
+        
+        for ( var i = 0 ; i < children.length ; i++ )
+        {
+            var child = children[i];
+            if ( child.nodeType != 1 ) // 1 == ELEMENT_NODE
+                continue;
+            var childLName = child.nodeName;
+            if ( childLName == "entity" )
+            {
+                entityId = ( ( child && child.firstChild ) ? 
child.firstChild.nodeValue : null );
+                break;
+            }
+        }
+        return entityId;
+    },
+    notifyFailure: function( /* String */ type, /* Object */ error, /* String 
*/ requestUrl, domainModelObject )
+    {
+        dojo.raise( "PortletAddAjaxApiCallbackCL error [" + 
domainModelObject.toString() + "] url: " + requestUrl + " type: " + type + 
jetspeed.url.formatBindError( error ) );
+    }
+};



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to