You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by sm...@apache.org on 2007/05/16 12:17:25 UTC
svn commit: r538516 - in
/portals/jetspeed-2/trunk/src/webapp/javascript/jetspeed: common.js
desktop/core.js
Author: smilek
Date: Wed May 16 03:17:22 2007
New Revision: 538516
URL: http://svn.apache.org/viewvc?view=rev&rev=538516
Log:
use new getmenus includeMenuDefs query parameter to obtain all menu definitions in single request (rather than one menu definition per request); added support for js-showloading action (show loading indicator)
Modified:
portals/jetspeed-2/trunk/src/webapp/javascript/jetspeed/common.js
portals/jetspeed-2/trunk/src/webapp/javascript/jetspeed/desktop/core.js
Modified: portals/jetspeed-2/trunk/src/webapp/javascript/jetspeed/common.js
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/src/webapp/javascript/jetspeed/common.js?view=diff&rev=538516&r1=538515&r2=538516
==============================================================================
--- portals/jetspeed-2/trunk/src/webapp/javascript/jetspeed/common.js (original)
+++ portals/jetspeed-2/trunk/src/webapp/javascript/jetspeed/common.js Wed May 16 03:17:22 2007
@@ -188,13 +188,13 @@
{
jetspeed.println( 'node: ' );
}
- if ( node.nodeType != ELEMENT_NODE && node.nodeType != TEXT_NODE )
+ if ( node.nodeType != 1 && node.nodeType != 3 )
{
- if ( node.length && node.length > 0 && ( node[0].nodeType == ELEMENT_NODE || node[0].nodeType == TEXT_NODE ) )
+ if ( node.length && node.length > 0 && ( node[0].nodeType == 1 || node[0].nodeType == 3 ) )
{
for ( var i = 0 ; i < node.length ; i++ )
{
- debugNodeTree( node[i], " [" + i + "]" )
+ jetspeed.debugNodeTree( node[i], " [" + i + "]" )
}
}
else
@@ -265,6 +265,7 @@
// ... jetspeed.url
+jetspeed.url.LOADING_INDICATOR_ID = "js-showloading";
jetspeed.url.path =
{
SERVER: null, // http://localhost:8080
@@ -683,6 +684,8 @@
dmId = ( ( this.domainModelObject && dojo.lang.isFunction( this.domainModelObject.getId ) ) ? this.domainModelObject.getId() : "" );
dojo.debug( "retrieveContent [" + ( dmId ? dmId : this.url ) + "] no valid contentListener" );
}
+ if ( this.hideLoadingIndicator )
+ jetspeed.url.loadingIndicatorHide();
},
error: function( type, error )
@@ -696,6 +699,8 @@
{
this.contentListener.notifyFailure( type, error, this.url, this.domainModelObject );
}
+ if ( this.hideLoadingIndicator )
+ jetspeed.url.loadingIndicatorHide();
}
});
@@ -707,7 +712,12 @@
bindArgs.debugContentDumpIds = debugContentDumpIds ;
var jetspeedBindArgs = new jetspeed.url.BindArgs( bindArgs );
-
+
+ if ( bindArgs.showLoadingIndicator || ( contentListener && ! contentListener.suppressLoadingIndicator && bindArgs.showLoadingIndicator != false ) )
+ {
+ if ( jetspeed.url.loadingIndicatorShow() )
+ jetspeedBindArgs.hideLoadingIndicator = true ;
+ }
dojo.io.bind( jetspeedBindArgs.createIORequest() ) ;
};
@@ -756,5 +766,36 @@
msg += " (" + bindError.type + ")";
}
return msg;
+ };
+ jetspeed.url.loadingIndicatorShow = function()
+ {
+ var loading = document.getElementById( jetspeed.url.LOADING_INDICATOR_ID );
+ if ( loading != null && loading.style )
+ {
+ if ( loading.style[ "display" ] == "none" )
+ {
+ loading.style[ "display" ] = "";
+
+ var actionlabel = null;
+ if ( jetspeed.prefs != null && jetspeed.prefs.desktopActionLabels != null )
+ actionlabel = jetspeed.prefs.desktopActionLabels[ "loading" ];
+ if ( actionlabel != null )
+ {
+ var loadingContent = document.getElementById( jetspeed.url.LOADING_INDICATOR_ID + "-content" );
+ if ( loadingContent != null )
+ {
+ loadingContent.innerHTML = actionlabel;
+ }
+ }
+ return true;
+ }
+ }
+ return false;
+ };
+ jetspeed.url.loadingIndicatorHide = function()
+ {
+ var loading = document.getElementById( jetspeed.url.LOADING_INDICATOR_ID );
+ if ( loading != null && loading.style )
+ loading.style[ "display" ] = "none";
};
}
Modified: portals/jetspeed-2/trunk/src/webapp/javascript/jetspeed/desktop/core.js
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/src/webapp/javascript/jetspeed/desktop/core.js?view=diff&rev=538516&r1=538515&r2=538516
==============================================================================
--- portals/jetspeed-2/trunk/src/webapp/javascript/jetspeed/desktop/core.js (original)
+++ portals/jetspeed-2/trunk/src/webapp/javascript/jetspeed/desktop/core.js Wed May 16 03:17:22 2007
@@ -104,6 +104,8 @@
ACTION_NAME_DESKTOP_HEIGHT_EXPAND: "heightexpand",
ACTION_NAME_DESKTOP_HEIGHT_NORMAL: "heightnormal",
+ ACTION_NAME_LOADING: "loading",
+
PORTLET_ACTION_TYPE_MODE: "mode",
PORTLET_ACTION_TYPE_STATE: "state",
@@ -297,7 +299,7 @@
}
}
}
-
+ jetspeed.url.loadingIndicatorShow();
jetspeed.loadPage();
};
jetspeed.loadPage = function()
@@ -736,6 +738,7 @@
}
}
+ jetspeed.url.loadingIndicatorHide();
jetspeed.pageNavigateSuppress = false;
};
@@ -1289,6 +1292,7 @@
if ( this.actions != null && ( this.actions[ jetspeed.id.ACTION_NAME_EDIT ] != null || this.actions[ jetspeed.id.ACTION_NAME_VIEW ] != null ) )
jetspeed.editPageInitiate();
}
+
}
else
{
@@ -2299,8 +2303,8 @@
{
if ( ! menuObj ) return;
var menuName = ( menuObj.getName ? menuObj.getName() : null );
- if ( ! menuName ) dojo.raise( "Page.addMenu argument is invalid - no menu-name can be found" );
- this.menus[ menuName ] = menuObj;
+ if ( menuName != null )
+ this.menus[ menuName ] = menuObj;
},
getMenu: function( /* String */ menuName )
{
@@ -2333,17 +2337,17 @@
},
retrieveAllMenus: function()
{
- var contentListener = new jetspeed.om.MenusAjaxApiCallbackContentListener( true );
- this.retrieveMenuDeclarations( contentListener );
+ this.retrieveMenuDeclarations( true );
},
- retrieveMenuDeclarations: function( contentListener )
+ retrieveMenuDeclarations: function( includeMenuDefs )
{
- if ( contentListener == null )
- contentListener = new jetspeed.om.MenusAjaxApiContentListener( false );
+ contentListener = new jetspeed.om.MenusAjaxApiContentListener( includeMenuDefs );
this.clearMenus();
var queryString = "?action=getmenus";
+ if ( includeMenuDefs )
+ queryString += "&includeMenuDefs=true";
var psmlMenusActionUrl = this.getPsmlUrl() + queryString;
var mimetype = "text/xml";
@@ -3730,91 +3734,16 @@
});
-// ... jetspeed.om.MenusAjaxApiContentListener
-jetspeed.om.MenusAjaxApiContentListener = function( /* boolean */ retrieveEachMenu )
-{
- this.retrieveEachMenu = retrieveEachMenu;
-};
-dojo.lang.extend( jetspeed.om.MenusAjaxApiContentListener,
-{
- notifySuccess: function( /* XMLDocument */ data, /* String */ requestUrl, domainModelObject )
- {
- var menuDefs = this.getMenuDefs( data, requestUrl, domainModelObject );
- var menuContentListener = new jetspeed.om.MenuAjaxApiContentListener( this, menuDefs.length )
- for ( var i = 0 ; i < menuDefs.length; i++ )
- {
- var mObj = menuDefs[i];
- domainModelObject.page.putMenu( mObj );
- if ( this.retrieveEachMenu )
- {
- domainModelObject.page.retrieveMenu( mObj.getName(), mObj.getType(), menuContentListener );
- }
- else if ( i == (menuDefs.length -1) )
- {
- if ( dojo.lang.isFunction( this.notifyFinished ) )
- {
- this.notifyFinished( domainModelObject );
- }
- }
- }
- },
- getMenuDefs: function( /* XMLDocument */ data, /* String */ requestUrl, domainModelObject )
- {
- var menuDefs = [];
- var menuDefElements = data.getElementsByTagName( "menu" );
- for( var i = 0; i < menuDefElements.length; i++ )
- {
- var menuType = menuDefElements[i].getAttribute( "type" );
- var menuName = menuDefElements[i].firstChild.nodeValue;
- menuDefs.push( new jetspeed.om.Menu( menuName, menuType ) );
- }
- return menuDefs;
- },
-
- notifyFailure: function( /* String */ type, /* Object */ error, /* String */ requestUrl, domainModelObject )
- {
- dojo.raise( "MenusAjaxApiContentListener error [" + domainModelObject.toString() + "] url: " + requestUrl + " type: " + type + jetspeed.url.formatBindError( error ) );
- }
-});
-
-// ... jetspeed.om.MenusAjaxApiCallbackContentListener
-jetspeed.om.MenusAjaxApiCallbackContentListener = function( /* boolean */ retrieveEachMenu )
-{
- jetspeed.om.MenusAjaxApiContentListener.call( this, retrieveEachMenu );
-};
-dojo.inherits( jetspeed.om.MenusAjaxApiCallbackContentListener, jetspeed.om.MenusAjaxApiContentListener );
-dojo.lang.extend( jetspeed.om.MenusAjaxApiCallbackContentListener,
-{
- notifyFinished: function( domainModelObject )
- {
- jetspeed.notifyRetrieveAllMenusFinished();
- }
-});
-
// ... jetspeed.om.MenuAjaxApiContentListener
-jetspeed.om.MenuAjaxApiContentListener = function( /* jetspeed.om.MenusAjaxApiContentListener */ parentNotifyFinishedListener, /* int */ parentNotifyFinishedAfterIndex )
+jetspeed.om.MenuAjaxApiContentListener = function()
{
- this.parentNotifyFinishedListener = parentNotifyFinishedListener;
- this.parentNotifyFinishedAfterIndex = parentNotifyFinishedAfterIndex;
- this.parentNotified = false;
- this.notifyCount = 0;
};
dojo.lang.extend( jetspeed.om.MenuAjaxApiContentListener,
{
notifySuccess: function( /* XMLDocument */ data, /* String */ requestUrl, domainModelObject )
{
- this.notifyCount++;
var menuObj = this.parseMenu( data, domainModelObject.menuName, domainModelObject.menuType );
domainModelObject.page.putMenu( menuObj );
- if ( ! this.parentNotified && this.parentNotifyFinishedListener != null && this.notifyCount >= this.parentNotifyFinishedAfterIndex && dojo.lang.isFunction( this.parentNotifyFinishedListener.notifyFinished ) )
- {
- this.parentNotified = true;
- this.parentNotifyFinishedListener.notifyFinished( domainModelObject );
- }
- if ( dojo.lang.isFunction( this.notifyFinished ) )
- {
- this.notifyFinished( domainModelObject, menuObj );
- }
},
notifyFailure: function( /* String */ type, /* Object */ error, /* String */ requestUrl, domainModelObject )
{
@@ -3892,17 +3821,51 @@
}
});
-// ... jetspeed.om.MenusAjaxApiCallbackContentListener
-jetspeed.om.MenuAjaxApiCallbackContentListener = function( /* boolean */ retrieveEachMenu )
+// ... jetspeed.om.MenusAjaxApiContentListener
+jetspeed.om.MenusAjaxApiContentListener = function( /* boolean */ includeMenuDefs )
{
- jetspeed.om.MenusAjaxApiContentListener.call( this, retrieveEachMenu );
+ this.includeMenuDefs = includeMenuDefs;
};
-dojo.inherits( jetspeed.om.MenuAjaxApiCallbackContentListener, jetspeed.om.MenuAjaxApiContentListener );
-dojo.lang.extend( jetspeed.om.MenuAjaxApiCallbackContentListener,
+dojo.inherits( jetspeed.om.MenusAjaxApiContentListener, jetspeed.om.MenuAjaxApiContentListener);
+dojo.lang.extend( jetspeed.om.MenusAjaxApiContentListener,
{
- notifyFinished: function( domainModelObject, menuObj )
+ notifySuccess: function( /* XMLDocument */ data, /* String */ requestUrl, domainModelObject )
+ {
+ var menuDefs = this.getMenuDefs( data, requestUrl, domainModelObject );
+ for ( var i = 0 ; i < menuDefs.length; i++ )
+ {
+ var mObj = menuDefs[i];
+ domainModelObject.page.putMenu( mObj );
+ }
+ this.notifyFinished( domainModelObject );
+ },
+ getMenuDefs: function( /* XMLDocument */ data, /* String */ requestUrl, domainModelObject )
+ {
+ var menuDefs = [];
+ var menuDefElements = data.getElementsByTagName( "menu" );
+ for( var i = 0; i < menuDefElements.length; i++ )
+ {
+ var menuType = menuDefElements[i].getAttribute( "type" );
+ if ( this.includeMenuDefs )
+ menuDefs.push( this.parseMenuObject( menuDefElements[i], new jetspeed.om.Menu( null, menuType ) ) );
+ else
+ {
+ var menuName = menuDefElements[i].firstChild.nodeValue;
+ menuDefs.push( new jetspeed.om.Menu( menuName, menuType ) );
+ }
+ }
+ return menuDefs;
+ },
+
+ notifyFailure: function( /* String */ type, /* Object */ error, /* String */ requestUrl, domainModelObject )
+ {
+ dojo.raise( "MenusAjaxApiContentListener error [" + domainModelObject.toString() + "] url: " + requestUrl + " type: " + type + jetspeed.url.formatBindError( error ) );
+ },
+
+ notifyFinished: function( domainModelObject )
{
- jetspeed.notifyRetrieveMenuFinished( menuObj );
+ if ( this.includeMenuDefs )
+ jetspeed.notifyRetrieveAllMenusFinished();
}
});
---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org