Skip to content

Commit

Permalink
Nicer initial page load, add support to the plugin loader for a callb…
Browse files Browse the repository at this point in the history
…ack as URLs and scripts are loading
  • Loading branch information
gashcrumb committed Oct 14, 2013
1 parent a1ee23b commit ad906ce
Show file tree
Hide file tree
Showing 4 changed files with 334 additions and 303 deletions.
2 changes: 2 additions & 0 deletions hawtio-web/src/main/d.ts/hawtio-plugin-loader.ts
Expand Up @@ -11,6 +11,8 @@ module Hawtio {

getModules():String[];

setLoaderCallback(callback:any);

loadPlugins(callback: () => void);
debug();

Expand Down
12 changes: 6 additions & 6 deletions hawtio-web/src/main/webapp/app/core/js/corePlugin.ts
Expand Up @@ -364,6 +364,10 @@ angular.module('hawtioCore', ['bootstrap', 'ngResource', 'ui', 'ui.bootstrap.dia
CodeEditor.GlobalCodeMirrorOptions = angular.extend(CodeEditor.GlobalCodeMirrorOptions, opts);
}

setTimeout(() => {
$("#main-body").fadeIn(2000);
}, 500);

}).
directive('compile', ['$compile', function ($compile) {
return function(scope, element, attrs) {
Expand Down Expand Up @@ -406,8 +410,8 @@ $(function () {
});

var adjustHeight = function () {
var windowHeight = $(window).height()
var headerHeight = $("#main-nav").height()
var windowHeight = $(window).height();
var headerHeight = $("#main-nav").height();
var containerHeight = windowHeight - headerHeight;
$("#main").css("min-height", "" + containerHeight + "px");
}
Expand All @@ -420,10 +424,6 @@ $(function () {
$(document.documentElement).attr('ng-app', 'hawtioCore');
adjustHeight();
$(window).resize(adjustHeight);

// var tmp:any = window;
// tmp.less.watch();

});
});

Expand Down
20 changes: 20 additions & 0 deletions hawtio-web/src/main/webapp/app/core/js/hawtio-plugin-loader.js
Expand Up @@ -74,11 +74,23 @@
return [];
};


hawtioPluginLoader.loaderCallback = null;

hawtioPluginLoader.setLoaderCallback = function(cb) {
hawtioPluginLoader.loaderCallback = cb;
console.log("Setting callback to : ", hawtioPluginLoader.loaderCallback);
};


hawtioPluginLoader.loadPlugins = function(callback) {

var lcb = hawtioPluginLoader.loaderCallback;

var plugins = {};

var urlsToLoad = hawtioPluginLoader.urls.length;
var totalUrls = urlsToLoad;

var loadScripts = function() {

Expand All @@ -88,9 +100,14 @@
loaded = loaded + data.Scripts.length;
});

var totalScripts = loaded;

var scriptLoaded = function() {
$.ajaxSetup({async:true});
loaded = loaded - 1;
if (lcb) {
lcb.scriptLoaderCallback(lcb, totalScripts, loaded + 1);
}
if (loaded == 0) {
callback();
}
Expand Down Expand Up @@ -129,6 +146,9 @@

var urlLoaded = function () {
urlsToLoad = urlsToLoad - 1;
if (lcb) {
lcb.urlLoaderCallback(lcb, totalUrls, urlsToLoad + 1);
}
if (urlsToLoad == 0) {
loadScripts();
}
Expand Down

0 comments on commit ad906ce

Please sign in to comment.