Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Commit

Permalink
Massive performance gains on start up, by loading some libraries asyn…
Browse files Browse the repository at this point in the history
…chronously and reporting to later some other.

Connexion.loadLibrary() can no be used async, ResourcesManager.loadJSResource should be able as well.
Use a contextChange clientListener to avoid auto-loading of AjxpMailer.js class.
We should definitely hunt the autoload JS files and provide alternative strategies whenever possible.
Theme can declare not using the loader Progress Bar if it's not necessary. Modal triggers events instead of calling window implicit objects.
Rework background color and loading overlay on Orbit theme.
  • Loading branch information
cdujeu committed Nov 8, 2014
1 parent c798a27 commit 436fe3d
Show file tree
Hide file tree
Showing 13 changed files with 80 additions and 54 deletions.
6 changes: 5 additions & 1 deletion core/src/plugins/core.mailer/manifest.xml
Expand Up @@ -14,13 +14,17 @@
<client_settings>
<resources>
<i18n namespace="core.mailer" path="plugins/core.mailer/i18n"/>
<js className="AjxpMailer" file="plugins/core.mailer/class.AjxpMailer.js" autoload="true"/>
<js className="AjxpMailer" file="plugins/core.mailer/class.AjxpMailer.js"/>
</resources>
</client_settings>
<registry_contributions>
<actions>
<action name="send_mail">
<rightsContext adminOnly="false" noUser="false" read="false" userLogged="only" write="false"/>
<processing>
<clientListener name="contextChange"><![CDATA[
if(!window.AjxpMailer && ajaxplorer.user) ResourcesManager.prototype.loadJSResource('plugins/core.mailer/class.AjxpMailer.js', 'AjxpMailer');
]]></clientListener>
<serverCallback methodName="sendMailAction"/>
</processing>
</action>
Expand Down
2 changes: 1 addition & 1 deletion core/src/plugins/gui.ajax/res/js/ajaxplorer.js

Large diffs are not rendered by default.

91 changes: 56 additions & 35 deletions core/src/plugins/gui.ajax/res/js/ajaxplorer/class.AjxpBootstrap.js
Expand Up @@ -175,12 +175,9 @@ Class.create("AjxpBootstrap", {
window.ajxpResourcesFolder = this.parameters.get('ajxpResourcesFolder') + "/themes/" + this.parameters.get("theme");
}
if(this.parameters.get('additional_js_resource')){
connexion.loadLibrary(this.parameters.get('additional_js_resource?v='+this.parameters.get("ajxpVersion")));
connexion.loadLibrary(this.parameters.get('additional_js_resource?v='+this.parameters.get("ajxpVersion")), null, true);
}
this.insertLoaderProgress();
if(!this.parameters.get("debugMode")){
connexion.loadLibrary("ajaxplorer.js?v="+this.parameters.get("ajxpVersion"));
}
window.MessageHash = this.parameters.get("i18nMessages");
if(!Object.keys(MessageHash).length){
alert('Ooups, this should not happen, your message file is empty!');
Expand All @@ -190,14 +187,22 @@ Class.create("AjxpBootstrap", {
}
window.zipEnabled = this.parameters.get("zipEnabled");
window.multipleFilesDownloadEnabled = this.parameters.get("multipleFilesDownloadEnabled");
document.fire("ajaxplorer:boot_loaded");
window.ajaxplorer = new Ajaxplorer(this.parameters.get("EXT_REP")||"", this.parameters.get("usersEnabled"), this.parameters.get("loggedUser"));
if(this.parameters.get("currentLanguage")){
window.ajaxplorer.currentLanguage = this.parameters.get("currentLanguage");
}
$('version_span').update(' - Version '+this.parameters.get("ajxpVersion") + ' - '+ this.parameters.get("ajxpVersionDate"));
window.ajaxplorer.init();
},
var masterClassLoaded = function(){
document.fire("ajaxplorer:boot_loaded");
window.ajaxplorer = new Ajaxplorer(this.parameters.get("EXT_REP")||"", this.parameters.get("usersEnabled"), this.parameters.get("loggedUser"));
if(this.parameters.get("currentLanguage")){
window.ajaxplorer.currentLanguage = this.parameters.get("currentLanguage");
}
$('version_span').update(' - Version '+this.parameters.get("ajxpVersion") + ' - '+ this.parameters.get("ajxpVersionDate"));
window.ajaxplorer.init();
}.bind(this);
if(!this.parameters.get("debugMode")){
connexion.loadLibrary("ajaxplorer.js?v="+this.parameters.get("ajxpVersion"), masterClassLoaded, true);
}else{
masterClassLoaded();
}

},

/**
* Detect the base path of the javascripts based on the script tags
Expand Down Expand Up @@ -297,29 +302,45 @@ Class.create("AjxpBootstrap", {
left:parseInt(Math.max((viewPort.width-progressBox.getWidth())/2,0))+"px",
top:parseInt(Math.max((viewPort.height-progressBox.getHeight())/3,0))+"px"
});
var options = {
animate : true, // Animate the progress? - default: true
showText : false, // show text with percentage in next to the progressbar? - default : true
width : 154, // Width of the progressbar - don't forget to adjust your image too!!!
boxImage : window.ajxpResourcesFolder+'/images/progress_box.gif', // boxImage : image around the progress bar
barImage : window.ajxpResourcesFolder+'/images/progress_bar.gif', // Image to use in the progressbar. Can be an array of images too.
height : 11, // Height of the progressbar - don't forget to adjust your image too!!!
onTick : function(pbObj) {
if(pbObj.getPercentage() >= 80){
new Effect.Parallel([
new Effect.Opacity($('loader_round_progress'),{sync:true,from:1,to:0,duration:0.6}),
new Effect.Opacity($('loader_dialog_footer'),{sync:true,from:1,to:0,duration:0.6})
],
{afterFinish : function(){
$('loading_overlay').remove();
$('progressBox').hide();
}});
return false;
}
return true ;
}
};
window.loaderProgress = new JS_BRAMUS.jsProgressBar($('loaderProgress'), 0, options);
var loaderEndCallback = function(){
document.stopObserving('ajaxplorer:loader_state_update');
new Effect.Parallel([
new Effect.Opacity($('loading_overlay'),{sync:true, from:1.0, to:0.0, duration:0.5}),
new Effect.Opacity($('loader_round_progress'),{sync:true,from:1,to:0,duration:0.5}),
new Effect.Opacity($('loader_dialog_footer'),{sync:true,from:1,to:0,duration:0.5})
],
{afterFinish : function(){
if($('loading_overlay')) $('loading_overlay').remove();
if($('progressBox')) $('progressBox').hide();
}});
};
if(!window.ajxpThemeSkipLoaderProgress){
var options = {
animate : false, // Animate the progress? - default: true
showText : false, // show text with percentage in next to the progressbar? - default : true
width : 154, // Width of the progressbar - don't forget to adjust your image too!!!
boxImage : window.ajxpResourcesFolder+'/images/progress_box.gif', // boxImage : image around the progress bar
barImage : window.ajxpResourcesFolder+'/images/progress_bar.gif', // Image to use in the progressbar. Can be an array of images too.
height : 11, // Height of the progressbar - don't forget to adjust your image too!!!
onTick : function(pbObj) {
if(pbObj.getPercentage() >= 80){
loaderEndCallback();
return false;
}
return true ;
}
};
this.loaderProgress = new JS_BRAMUS.jsProgressBar($('loaderProgress'), 0, options);
}
document.observe('ajaxplorer:loader_state_update', function(e){
var p = e.memo.percent;
if(this.loaderProgress){
this.loaderProgress.setPercentage(p*100);
}else if(p >= 0.8){
loaderEndCallback();
}
}.bind(this));

},
/**
* Inserts Google Analytics Code
Expand Down
Expand Up @@ -213,16 +213,17 @@ Class.create("Connexion", {
* Load a javascript library
* @param fileName String
* @param onLoadedCode Function Callback
* @param aSync Boolean load library asynchroneously
*/
loadLibrary : function(fileName, onLoadedCode){
loadLibrary : function(fileName, onLoadedCode, aSync){
if(window.ajxpBootstrap && window.ajxpBootstrap.parameters.get("ajxpVersion") && fileName.indexOf("?")==-1){
fileName += "?v="+window.ajxpBootstrap.parameters.get("ajxpVersion");
}
var path = (this._libUrl?this._libUrl+'/'+fileName:fileName);
new Ajax.Request(path,
{
method:'get',
asynchronous: false,
asynchronous: (aSync?true:false),
onComplete:function(transport){
if(transport.responseText)
{
Expand Down
5 changes: 1 addition & 4 deletions core/src/plugins/gui.ajax/res/js/ajaxplorer/class.Modal.js
Expand Up @@ -738,16 +738,13 @@ Class.create("Modal", {
updateLoadingProgress: function(state){
this.loadingStep --;
var percent = (1 - (this.loadingStep / this.loadingStepsCount));
if(window.loaderProgress){
window.loaderProgress.setPercentage(parseFloat(percent)*100, true);
}
document.fire("ajaxplorer:loader_state_update", {percent:parseFloat(percent)});
if(state && $('progressState')){
$('progressState').update(state);
}
if(this.loadingStep == 0){
this.pageLoading = false;
}
return;
},
/**
* Callback to be called on close
Expand Down
Expand Up @@ -125,7 +125,7 @@ Class.create("ResourcesManager", {
if(ajxpBootstrap.parameters.get('SERVER_PREFIX_URI')){
conn._libUrl = ajxpBootstrap.parameters.get('SERVER_PREFIX_URI');
}
conn.loadLibrary(fileName);
conn.loadLibrary(fileName, null, false);
}
}
},
Expand Down Expand Up @@ -197,17 +197,17 @@ Class.create("ResourcesManager", {
* @param registry DOMDocument XML Registry
*/
loadAutoLoadResources : function(registry){
var jsNodes = XPathSelectNodes(registry, '//client_settings/resources/js[@autoload="true"]');
var jsNodes = XPathSelectNodes(registry, 'plugins/*/client_settings/resources/js[@autoload="true"]');
if(jsNodes.length){
jsNodes.each(function(node){
this.loadJSResource(node.getAttribute('file'), node.getAttribute('className'));
}.bind(this));
}
var imgNodes = XPathSelectNodes(registry, '//client_settings/resources/img_library');
var imgNodes = XPathSelectNodes(registry, 'plugins/*/client_settings/resources/img_library');
imgNodes.each(function(node){
addImageLibrary(node.getAttribute('alias'), node.getAttribute('path'));
}.bind(this));
var cssNodes = XPathSelectNodes(registry, '//client_settings/resources/css[@autoload="true"]');
var cssNodes = XPathSelectNodes(registry, 'plugins/*/client_settings/resources/css[@autoload="true"]');
cssNodes.each(function(node){
this.loadCSSResource(node.getAttribute("file"));
}.bind(this));
Expand Down
2 changes: 1 addition & 1 deletion core/src/plugins/gui.ajax/res/js/ajaxplorer_boot.js

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Expand Up @@ -94,6 +94,7 @@ body, html
{
margin: 0;
padding: 0;
background-color: #333;
}

input, textarea, select
Expand Down
2 changes: 1 addition & 1 deletion core/src/plugins/gui.ajax/res/themes/orbit/css/allz.css

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions core/src/plugins/gui.ajax/res/themes/orbit/css/screen.css
Expand Up @@ -42,11 +42,11 @@
#loading_overlay{
display:block;
z-index:2000;
-moz-opacity:1.0 !important;
opacity:1.0 !important;
-moz-opacity:1.0 ;
opacity:1.0 ;
filter: alpha(opacity=100) !important;
background-color: #fff !important;
background-image: url('../images/grid_t.png');
background-color: rgba(0, 0, 0, 0.83) !important;
/*background-image: url('../images/grid_t.png');*/
}

#element_overlay{
Expand Down
1 change: 1 addition & 0 deletions core/src/plugins/gui.ajax/res/themes/orbit/html/gui.html
Expand Up @@ -13,6 +13,7 @@
<body bgcolor="#FFFFFF" text="#000000" marginheight="0" marginwidth="0" leftmargin="0" topmargin="0" style="overflow:hidden;">
<script type="text/javascript">
window.ajxpNoNotifLoader = true;
window.ajxpThemeSkipLoaderProgress = true;
// Initialize booter. Do not remove the commented line AJXP_JSON_START_PARAMETERS, as it is
// dynamically replaced by the application!
var ajaxplorer, startParameters = {}, MessageHash={};
Expand Down
Expand Up @@ -34,6 +34,7 @@

<script type="text/javascript">
window.ajxpNoNotifLoader = true;
window.ajxpThemeSkipLoaderProgress = true;
var ajaxplorer, startParameters = {};
<?php if($JSON_START_PARAMETERS) print "startParameters = ".$JSON_START_PARAMETERS.";"; ?>
window.ajxpBootstrap = new AjxpBootstrap(startParameters);
Expand Down

0 comments on commit 436fe3d

Please sign in to comment.