dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #35469
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18155: Fix regression bug in menu manager and code style
------------------------------------------------------------
revno: 18155
committer: Mark Polak <markpo@xxxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2015-02-02 18:28:12 +0100
message:
Fix regression bug in menu manager and code style
modified:
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.menu.js
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.menu.manager.js
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.menu.ui.js
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.menu.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.menu.js 2014-10-16 19:00:41 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.menu.js 2015-02-02 17:28:12 +0000
@@ -255,14 +255,14 @@
that.getMenuItems = function () {
return menuItems;
- }
+ };
/**
* Get the max number of favorites
*/
that.getMaxFavorites = function () {
return MAX_FAVORITES;
- }
+ };
/**
* Order the menuItems by a given list
@@ -307,7 +307,7 @@
executeCallBacks();
return that;
- }
+ };
/**
* Adds the menu items given to the menu
@@ -363,7 +363,7 @@
that.notify = function () {
executeCallBacks();
- }
+ };
/**
* Get the favorite apps
@@ -390,7 +390,7 @@
that.sortNonFavAppsByName = function (inverse) {
return sortAppsByName(that.getNonFavoriteApps(), inverse);
- }
+ };
/**
* Gets the applist based on the current display order
@@ -409,7 +409,7 @@
break;
}
return favApps.concat(nonFavApps);;
- }
+ };
that.updateOrder = function (reorderedApps) {
switch (that.displayOrder) {
@@ -423,7 +423,7 @@
that.orderMenuItemsByList(reorderedApps);
break;
}
- }
+ };
that.save = function (saveMethod) {
if ( ! du.isFunction(saveMethod)) {
@@ -431,7 +431,7 @@
}
return saveMethod(that.getMenuItems().getOrder());
- }
+ };
that.search = function (searchFor) {
//Get all the apps
@@ -459,7 +459,7 @@
});
return searchMatches;
- }
+ };
if (typeof preLoadedData === 'object') {
that.addMenuItems(preLoadedData);
@@ -490,7 +490,7 @@
return true;
}
return false;
- }
+ };
/**
* Returns the name keys for the current menus.
@@ -508,7 +508,7 @@
}
}
return nameKeys;
- }
+ };
//Expose the fixUrl method so we can use externally
dhis2.menu.fixUrlIfNeeded = fixUrlIfNeeded;
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.menu.manager.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.menu.manager.js 2014-06-11 20:02:19 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.menu.manager.js 2015-02-02 17:28:12 +0000
@@ -37,7 +37,8 @@
* @see jQuery (http://jquery.com)
* @see jQuery Template Plugin (http://github.com/jquery/jquery-tmpl)
*/
-(function ($, menu, undefined) {
+(function ($, undefined) {
+ var menu;
var markup = '',
selector = 'appsMenu';
@@ -137,7 +138,11 @@
$('.app-menu ul').sortable(options).disableSelection();
}
- menu.subscribe(renderMenu);
+ $.when(dhis2.menu.ui.loadingStatus)
+ .then(function () {
+ menu = dhis2.menu.mainAppMenu.menuItems;
+ menu.subscribe(renderMenu);
+ });
/**
* jQuery events that communicate with the web api
@@ -188,4 +193,4 @@
});
});
-})(jQuery, dhis2.menu.mainAppMenu.menuItems);
+})(jQuery);
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.menu.ui.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.menu.ui.js 2015-02-02 16:30:47 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.menu.ui.js 2015-02-02 17:28:12 +0000
@@ -140,7 +140,7 @@
keyCode === keys.arrowDown ||
keyCode === keys.arrowUp);
}
- }
+ };
/*
* Check for what type of jquery/jqLite we are using and assign it to jqLite.
@@ -202,7 +202,7 @@
$('#appsDropDown .menuDropDownBox').html(error_template);
*/
}
- }
+ };
http.send();
}
@@ -244,7 +244,7 @@
}
return template;
- }
+ };
/**
* Gets a "raw" template. This returns the template as it was saved, without parsing it.
@@ -256,7 +256,7 @@
console.error("Template " + name + " does not exist");
}
return templates[name];
- }
+ };
/**
* Adds a template to the template cache
@@ -276,7 +276,7 @@
console.error("Template not allowed to be overridden using the add method, use the replace method instead");
}
templates[name] = template;
- }
+ };
/**
* Replace an already existing template with a different one
@@ -289,10 +289,10 @@
console.error("No template to be replaced, use the add method to add templates")
}
templates[name] = template;
- }
+ };
return template;
- }
+ };
/**
* Creates an error object with that has the passed in message
@@ -313,7 +313,7 @@
error.toString = function () {
return "MenuError: " + this.message + " \n";
- }
+ };
return error;
}
@@ -415,11 +415,11 @@
return false;
}
return true;
- }
+ };
defaultMenu.isClosed = function () {
return ! defaultMenu.isOpen();
- }
+ };
defaultMenu.open = function (hover) {
var dropdownElement = jqLite(document.querySelector(defaultMenu.getDropdownSelector()));
@@ -432,7 +432,7 @@
dropdownElement.attr("data-display-clicked", "true");
}
defaultMenu.hooks.call('open');
- }
+ };
defaultMenu.close = function (hover) {
var dropdownElement = jqLite(document.querySelector(defaultMenu.getDropdownSelector()));
@@ -442,21 +442,21 @@
dropdownElement.attr("data-display-clicked", "false");
}
defaultMenu.hooks.call('close');
- }
+ };
defaultMenu.closeAll = function () {
var menuDropDowns = document.querySelectorAll("#" + defaultMenu.container + " div.app-menu-dropdown-wrap");
jqLite(menuDropDowns).css('display', 'none');
jqLite(menuDropDowns).attr("data-display-clicked", "false");
- }
+ };
defaultMenu.setCurrentId = function (id) {
currentSelectedId = id;
- }
+ };
defaultMenu.getCurrentId = function () {
return currentSelectedId;
- }
+ };
defaultMenu.goToMenuItem = function (menuElement) {
var link, url;
@@ -471,7 +471,7 @@
if (url) {
window.location = url;
}
- }
+ };
defaultMenu.renderMenuItems = function (menuItems) {
var result = '';
@@ -485,15 +485,15 @@
});
});
return result;
- }
+ };
defaultMenu.getButtonId = function () {
return "#" + defaultMenu.name + "Button";
- }
+ };
defaultMenu.getDropdownSelector = function () {
return defaultMenu.getButtonId() + " div.app-menu-dropdown-wrap";
- }
+ };
defaultMenu.getDropDownPosition = function () {
var menuElement = document.querySelector(defaultMenu.getButtonId()),
@@ -513,7 +513,7 @@
dropdownElement.css('display', 'none');
return dropdownPosition;
- }
+ };
defaultMenu.renderers.push(function (menuData) {
var linkItem, menuItems;
@@ -590,7 +590,7 @@
});
return createMenu(defaultMenu);
- }
+ };
scrollUi = function (menu) {
var scrollMenu = menu;
@@ -632,7 +632,7 @@
});
return createMenu(scrollMenu);
- }
+ };
/**
* Adds search functionality to the passed menu
@@ -709,7 +709,7 @@
});
return createMenu(searchMenu);
- }
+ };
linkButtonUi = function (menu) {
var linkButtonMenu = menu,
@@ -734,7 +734,7 @@
});
return createMenu(linkButtonMenu);
- }
+ };
shortCutUi = function (menu) {
var shortCutMenu = menu;
@@ -884,7 +884,7 @@
});
return createMenu(shortCutMenu);
- }
+ };
/*******************************************************************************************************************
* Dhis2 menu ui functions
@@ -949,7 +949,7 @@
dhis2.menu.ui.initMenu = function () {
try {
- jQuery.ajax({
+ dhis2.menu.ui.loadingStatus = jQuery.ajax({
type : "GET",
url : dhis2.settings.getBaseUrl() + "/dhis-web-commons/menu/getHelpPageLinkModule.action",
dataType : "json",
@@ -1175,5 +1175,4 @@
//If there is no angular we just run our normal init function to find tags ourselves
dhis2.menu.ui.initMenu();
}
-
})();
\ No newline at end of file