* Add a loading overlay while an application is loading

This commit is contained in:
Nathan Gray 2015-03-12 16:56:36 +00:00
parent c68aacab0c
commit 7d9f15a5ab
6 changed files with 78 additions and 8 deletions

View File

@ -241,7 +241,13 @@ html, body {
background-position: center; background-position: center;
float: right; float: right;
} }
.egw_fw_ui_tab_content > .loading {
background-image:url(images/ajax-loader.gif);
background-repeat: no-repeat;
background-position: center;
text-align: center;
line-height: 400px;
}
.egw_fw_ui_sidemenu_entry_header h1, .egw_fw_ui_sidemenu_marker h1{ .egw_fw_ui_sidemenu_entry_header h1, .egw_fw_ui_sidemenu_marker h1{
display: inline; display: inline;
font-size: 10pt; font-size: 10pt;

View File

@ -152,6 +152,8 @@ var fw_base = Class.extend({
* @param {bool} _hidden specifies, whether the application should be set active * @param {bool} _hidden specifies, whether the application should be set active
* after opening the tab * after opening the tab
* @param {int} _pos * @param {int} _pos
*
* @return {Deferred|null} Deferred Promise, will be resolved when the tab is loaded
*/ */
applicationTabNavigate: function(_app, _url, _hidden, _pos) applicationTabNavigate: function(_app, _url, _hidden, _pos)
{ {
@ -162,6 +164,9 @@ var fw_base = Class.extend({
//Create the tab for that application //Create the tab for that application
this.createApplicationTab(_app, _pos); this.createApplicationTab(_app, _pos);
// Response
var deferred = new jQuery.Deferred();
if (typeof _url == 'undefined' || _url == null) if (typeof _url == 'undefined' || _url == null)
{ {
_url = _app.indexUrl; _url = _app.indexUrl;
@ -178,7 +183,8 @@ var fw_base = Class.extend({
{ {
this.setActiveApp(_app); this.setActiveApp(_app);
} }
return; deferred.resolve();
return deferred.promise();
} }
if (_app.browser == null) if (_app.browser == null)
@ -191,13 +197,15 @@ var fw_base = Class.extend({
if (typeof _hidden == 'undefined' || !_hidden) if (typeof _hidden == 'undefined' || !_hidden)
{ {
_app.browser.browse(_url); deferred = _app.browser.browse(_url);
this.setActiveApp(_app); this.setActiveApp(_app);
} }
else else
{ {
this.notifyTabChange(); this.notifyTabChange(deferred);
} }
return deferred.promise();
}, },
/** /**
@ -348,9 +356,11 @@ var fw_base = Class.extend({
} }
}, },
/** /**
* Notify a tab that it was changed, update preferences
* *
* @param {Deferred} deferred Someone is listening, and wants to know when done.
*/ */
notifyTabChange: function() notifyTabChange: function(deferred)
{ {
// Call the "resize" function of the currently active app // Call the "resize" function of the currently active app
if (this.activeApp) if (this.activeApp)
@ -373,6 +383,10 @@ var fw_base = Class.extend({
{ {
window.focus(); window.focus();
} }
if(deferred)
{
deferred.resolve();
}
}, 100); }, 100);
} }
} }
@ -722,7 +736,7 @@ var fw_base = Class.extend({
this.tabsUi.showTab(_app.tab); this.tabsUi.showTab(_app.tab);
//Going to a new tab changes the tab state //Going to a new tab changes the tab state
this.notifyTabChange(_app.tab); this.notifyTabChange();
} }
} }
}, },

View File

@ -36,6 +36,8 @@ var fw_browser = Class.extend({
this.heightCallback = _heightCallback; this.heightCallback = _heightCallback;
this.app = _app; this.app = _app;
this.currentLocation = ''; this.currentLocation = '';
this.ajaxLoaderDiv = null;
this.loadingDeferred = null;
}, },
/** /**
@ -88,7 +90,10 @@ var fw_browser = Class.extend({
$j(this.baseDiv).empty(); $j(this.baseDiv).empty();
this.iframe = null; this.iframe = null;
this.contentDiv = null; this.contentDiv = null;
this.ajaxLoaderDiv = null; if(this.loadingDeferred && this.type)
{
this.loadingDeferred.reject();
}
switch (_type) switch (_type)
{ {
@ -121,6 +126,7 @@ var fw_browser = Class.extend({
/** /**
* Sets url to browse and load the content in proper content browser * Sets url to browse and load the content in proper content browser
* @param {string} _url * @param {string} _url
* @return {Deferred} Returns a Deferred promise object
*/ */
browse: function(_url) browse: function(_url)
{ {
@ -139,6 +145,24 @@ var fw_browser = Class.extend({
} }
var useIframe = true; var useIframe = true;
var targetUrl = _url; var targetUrl = _url;
if(_url == this.currentLocation && this.loadingDeferred != null)
{
// Still loading
return this.loadingDeferred.promise();
}
// Show loader div, start blocking
var self = this;
this.ajaxLoaderDiv = jQuery('<div class="loading ui-widget-overlay ui-front">'+egw.lang('please wait...')+'</div>').insertBefore(this.baseDiv);
this.loadingDeferred = new jQuery.Deferred();
this.loadingDeferred.always(function() {
if(self.ajaxLoaderDiv)
{
self.ajaxLoaderDiv.hide().remove();
self.ajaxLoaderDiv = null;
}
self.loadingDeferred = null;
});
// Check whether the given url is a pseudo url which should be executed // Check whether the given url is a pseudo url which should be executed
// by calling the ajax_exec function // by calling the ajax_exec function
@ -204,7 +228,6 @@ var fw_browser = Class.extend({
//Postpone the actual "navigation" - gives some speedup with internet explorer //Postpone the actual "navigation" - gives some speedup with internet explorer
//as it does no longer blocks the complete page until all frames have loaded. //as it does no longer blocks the complete page until all frames have loaded.
var self = this;
window.setTimeout(function() { window.setTimeout(function() {
//Load the iframe content //Load the iframe content
self.iframe.src = _url; self.iframe.src = _url;
@ -225,6 +248,11 @@ var fw_browser = Class.extend({
// ignoer SecurityError: Blocked a frame ..., caused by different origin // ignoer SecurityError: Blocked a frame ..., caused by different origin
} }
} }
if(self.loadingDeferred)
{
self.loadingDeferred.resolve();
}
}, 1); }, 1);
} }
else else
@ -257,6 +285,7 @@ var fw_browser = Class.extend({
req.sendRequest(); req.sendRequest();
} }
} }
return this.loadingDeferred.promise();
}, },
/** /**
@ -299,6 +328,11 @@ var fw_browser = Class.extend({
// Run the javascript code // Run the javascript code
//console.log(content.js); //console.log(content.js);
$j(this.contentDiv).append(content.js); $j(this.contentDiv).append(content.js);
if(this.loadingDeferred)
{
this.loadingDeferred.resolve();
}
}, },
/** /**

View File

@ -2527,6 +2527,11 @@ body {
background-position: center; background-position: center;
float: right; float: right;
} }
.egw_fw_ui_tab_content > .loading {
background-image: url('../images/loading.gif');
text-align: center;
line-height: 400px;
}
/** /**
* EGroupware: Stylite Pixelegg template * EGroupware: Stylite Pixelegg template
* *

View File

@ -2516,6 +2516,11 @@ body {
background-position: center; background-position: center;
float: right; float: right;
} }
.egw_fw_ui_tab_content > .loading {
background-image: url('../images/loading.gif');
text-align: center;
line-height: 400px;
}
/** /**
* EGroupware: Stylite Pixelegg template * EGroupware: Stylite Pixelegg template
* *

View File

@ -24,3 +24,9 @@
background-position: center; background-position: center;
float: right; float: right;
} }
.egw_fw_ui_tab_content > .loading {
background-image:url('../images/loading.gif');
text-align: center;
line-height: 400px;
}