Skip to content

Commit

Permalink
Add buildLink
Browse files Browse the repository at this point in the history
  • Loading branch information
adrienlauer committed Oct 6, 2016
1 parent 064259c commit 8cccdc0
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Version 2.3.2 (2016-10-06)

* [chg] Add method `buildLink` to build links in `NavigationService`.

# Version 2.3.1 (2016-05-25)

* [fix] Add missing entries in the angular locale object generated from globalize culture definition.
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "w20",
"version": "2.3.1",
"version": "2.3.2",
"ignore": [
".*",
"*.iml",
Expand Down
29 changes: 28 additions & 1 deletion modules/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ define([
* to build the tree menu for instance.
*
*/
w20CoreUI.factory('NavigationService', ['$route', 'SecurityExpressionService', 'EventService', function ($route, securityExpressionService, eventService) {
w20CoreUI.factory('NavigationService', ['$route', '$location', 'SecurityExpressionService', 'EventService', function ($route, $location, securityExpressionService, eventService) {
var routeTree,
expandedRouteCategories,
topLevelCategories,
Expand Down Expand Up @@ -563,6 +563,33 @@ define([
*/
refreshNavigation: function () {
refreshNavigation();
},

/**
* @ngdoc function
* @name w20CoreUI.service:NavigationService#buildLink
* @methodOf w20CoreUI.service:NavigationService
*
* @param {String} path Route path to build link from.
*
* @description
*
* This method take a route path and build a suitable link depending on pretty URLs mode. Path is prefixed by
* the hashbang if application is in legacy mode. Path is stripped of starting slash if application is in
* HTML5 mode.
*/
buildLink: function (path) {
if ($location.$$html5) {
if (path === '/') {
return "./";
} else if (path.indexOf('/') === 0) {
return path.substring(1);
} else {
return path;
}
} else {
return '#!' + path;
}
}
};
}]);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "w20",
"version": "2.3.1",
"version": "2.3.2",
"description": "SeedStack Web framework",
"license": "MPL 2.0",
"contributors": [
Expand Down

0 comments on commit 8cccdc0

Please sign in to comment.