diff --git a/roles/apps-fp-o/files/fedmenu-staging/js/fedmenu.js b/roles/apps-fp-o/files/fedmenu-staging/js/fedmenu.js
index d8c0dee16c..cc21f03422 100644
--- a/roles/apps-fp-o/files/fedmenu-staging/js/fedmenu.js
+++ b/roles/apps-fp-o/files/fedmenu-staging/js/fedmenu.js
@@ -32,17 +32,10 @@ var fedmenu = function(options) { $(document).ready(function() {
$('body', c).append('
');
- $('body', c).append('');
- $('#fedmenu-main-content', c).append("");
- $('#fedmenu-main-content', c).append("Fedora Infrastructure Apps
");
-
var imgurl;
if (o.user !== null) {
imgurl = libravatar.url(o.user);
$('#fedmenu-user-button .img', c).css('background-image', 'url("' + imgurl + '")');
- $('body', c).append('');
- $('#fedmenu-user-content', c).append("");
- $('#fedmenu-user-content', c).append("View " + o.user + " in other apps
");
}
if (o.package !== null) {
/* This icon is not always going to exist, so we should put in an
@@ -50,9 +43,6 @@ var fedmenu = function(options) { $(document).ready(function() {
* isn't there. */
imgurl = 'https://apps.fedoraproject.org/packages/images/icons/' + o.package + '.png';
$('#fedmenu-package-button .img', c).css('background-image', 'url("' + imgurl + '")');
- $('body', c).append('');
- $('#fedmenu-package-content', c).append("");
- $('#fedmenu-package-content', c).append("View the " + o.package + " package elsewhere
");
}
// Define three functions used to generate the content of the menu panes
@@ -67,6 +57,12 @@ var fedmenu = function(options) { $(document).ready(function() {
"";
});
html = html + "";
+
+ if ($('#fedmenu-main-content').length == 0) {
+ $('body', c).append('');
+ $('#fedmenu-main-content', c).append("");
+ $('#fedmenu-main-content', c).append("Fedora Infrastructure Apps
");
+ }
$("#fedmenu-main-content", c).append(html);
};
@@ -86,6 +82,11 @@ var fedmenu = function(options) { $(document).ready(function() {
}
});
if (found) {
+ if ($('#fedmenu-user-content').length == 0) {
+ $('body', c).append('');
+ $('#fedmenu-user-content', c).append("");
+ $('#fedmenu-user-content', c).append("View " + o.user + " in other apps
");
+ }
html = html + "";
$("#fedmenu-user-content", c).append(html);
}
@@ -108,10 +109,22 @@ var fedmenu = function(options) { $(document).ready(function() {
});
if (found) {
html = html + "";
+ if ($('#fedmenu-package-content').length == 0) {
+ $('body', c).append('');
+ $('#fedmenu-package-content', c).append("");
+ $('#fedmenu-package-content', c).append("View the " + o.package + " package elsewhere
");
+ }
$("#fedmenu-package-content", c).append(html);
}
};
+ // A handy lookup for those functions we just defined.
+ var content_makers = {
+ 'main': make_main_content_html,
+ 'user': make_user_content_html,
+ 'package': make_package_content_html,
+ };
+
$.ajax({
url: o.url,
mimeType: o.mimeType,
@@ -122,11 +135,8 @@ var fedmenu = function(options) { $(document).ready(function() {
console.log(err);
},
success: function(script) {
- $.each(json.children, make_main_content_html);
- if (o.user !== null)
- $.each(json.children, make_user_content_html);
- if (o.package !== null)
- $.each(json.children, make_package_content_html);
+ // Save this for later...
+ master_data = json.children;
},
});
@@ -135,8 +145,15 @@ var fedmenu = function(options) { $(document).ready(function() {
"#fedmenu-" + t + "-button," +
"#fedmenu-" + t + "-content";
};
- var activate = function(t) { $(selector(t), c).addClass('fedmenu-active'); };
- var deactivate = function(t) { $(selector(t), c).removeClass('fedmenu-active'); };
+
+ var activate = function(t) {
+ $.each(master_data, content_makers[t]);
+ $(selector(t), c).addClass('fedmenu-active');
+ };
+ var deactivate = function(t) {
+ $(selector(t), c).removeClass('fedmenu-active');
+ $('.fedmenu-content', c).remove(); // destroy content.
+ };
var click_factory = function(t) { return function() {
if ($(this).hasClass('fedmenu-active')) {