summaryrefslogtreecommitdiffstats
path: root/base/server/share/webapps
diff options
context:
space:
mode:
authorEndi S. Dewata <edewata@redhat.com>2014-02-07 19:48:09 -0500
committerEndi S. Dewata <edewata@redhat.com>2014-02-11 14:22:30 -0500
commit310e410dfc1916e19b3aca655bbfedc62db35216 (patch)
tree295a6e52ac21a71f279430b8b45b996e4aedee75 /base/server/share/webapps
parent1401227e6a24366210d89349b07dcc871e1e8347 (diff)
downloadpki-310e410dfc1916e19b3aca655bbfedc62db35216.tar.gz
pki-310e410dfc1916e19b3aca655bbfedc62db35216.tar.xz
pki-310e410dfc1916e19b3aca655bbfedc62db35216.zip
Improved TPS UI page loading.
Previously the TPS UI would reload the JS libraries and CSS files every time a page is opened. The pages have been simplified such that it will only contain the necessary elements of the page. A new Page class has been added to the framework to define page initialization. Ticket #654
Diffstat (limited to 'base/server/share/webapps')
-rw-r--r--base/server/share/webapps/pki/js/pki-ui.js33
1 files changed, 29 insertions, 4 deletions
diff --git a/base/server/share/webapps/pki/js/pki-ui.js b/base/server/share/webapps/pki/js/pki-ui.js
index c16af03ba..d35de5893 100644
--- a/base/server/share/webapps/pki/js/pki-ui.js
+++ b/base/server/share/webapps/pki/js/pki-ui.js
@@ -107,27 +107,52 @@ var Collection = Backbone.Collection.extend({
}
});
+var Page = Backbone.View.extend({
+ initialize: function(options) {
+ var self = this;
+ Page.__super__.initialize.call(self, options);
+
+ self.url = options.url;
+ },
+ load: function() {
+ }
+});
+
var Navigation = Backbone.View.extend({
initialize: function(options) {
var self = this;
Navigation.__super__.initialize.call(self, options);
self.content = options.content;
- self.homeURL = options.homeURL;
+ self.pages = options.pages;
+ self.homePage = options.homePage;
$("li", self.$el).each(function(index) {
var li = $(this);
var link = $("a", li);
var url = link.attr("href");
link.click(function(e) {
- if (url != "#") {
- self.content.load(url);
+ // get page name
+ if (url.charAt(0) == "#" && url.length > 1) {
+ var name = url.substring(1);
+ self.load(name);
}
e.preventDefault();
});
});
- if (self.homeURL) self.content.load(self.homeURL);
+ if (self.homePage) self.load(self.homePage);
+ },
+ load: function(name) {
+ var self = this;
+ var page = self.pages[name];
+ if (!page) {
+ alert("Invalid page: " + name);
+ return;
+ }
+ self.content.load(page.url, function(response, status, xhr) {
+ page.load();
+ });
}
});