kanbanworkflowstimelinescrumrubyroadmapproject-planningproject-managementopenprojectangularissue-trackerifcgantt-chartganttbug-trackerboardsbcf
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.2 KiB
51 lines
1.2 KiB
11 years ago
|
angular.module('openproject.layout')
|
||
|
|
||
|
.factory('menuItemFactory', [
|
||
|
'$rootScope',
|
||
|
'$compile',
|
||
|
'$http',
|
||
|
'$templateCache',
|
||
|
'$animate',
|
||
|
function($rootScope, $compile, $http, $templateCache, $animate) {
|
||
|
|
||
|
return function(options) {
|
||
|
if (!options.container) {
|
||
|
throw new Error('Container must be specified menu item to have exacly one of either `template` or `templateUrl`');
|
||
|
}
|
||
|
|
||
|
var templateUrl = '/templates/layout/menu_item.html',
|
||
|
type = options.type,
|
||
|
container = angular.element(options.container),
|
||
|
linkFn = options.linkFn,
|
||
|
scope;
|
||
|
|
||
|
function generateMenuItem(title, path, objectId) {
|
||
|
var menuItem;
|
||
|
|
||
|
scope = $rootScope.$new(true);
|
||
|
|
||
|
scope.type = type;
|
||
|
scope.title = title;
|
||
|
scope.path = path;
|
||
|
scope.objectId = objectId;
|
||
|
|
||
|
$http.get(templateUrl, {
|
||
|
cache: $templateCache
|
||
|
}).then(function (response) {
|
||
|
menuItem = angular.element(response.data);
|
||
|
|
||
|
if (linkFn) linkFn(scope, menuItem.children('a'), {});
|
||
|
|
||
|
$compile(menuItem)(scope);
|
||
|
$animate.enter(menuItem, container);
|
||
|
});
|
||
|
|
||
|
}
|
||
|
|
||
|
return {
|
||
|
generateMenuItem: generateMenuItem,
|
||
|
link: linkFn
|
||
|
};
|
||
|
};
|
||
|
}]);
|