Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
<!-- build:js showcase/scripts/vendor/modernizr.js -->
<script src="bower_components/modernizr/modernizr.js"></script>
<!-- endbuild -->
<!-- build:js showcase/scripts/vendor/ember-i18n.js -->
<script src="bower_components/ember-i18n/lib/i18n.js"></script>
<!-- endbuild -->
</head>
<body>
<!-- build:js showcase/scripts/showcase-components.js -->
Expand Down
3 changes: 3 additions & 0 deletions app/scripts/components/BsBreadcrumbs.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Bootstrap.BsBreadcrumbs = Bootstrap.ItemsView.extend(Bootstrap.WithRouter,
@get('content').clear()

routes = @get('container').lookup 'router:main'
translation = /(.*)Translation$/;
routes.get('router.currentHandlerInfos').forEach (route, i, arr) =>
name = route.name
return if name.indexOf('.index') isnt -1 || name is 'application'
Expand All @@ -40,6 +41,8 @@ Bootstrap.BsBreadcrumbs = Bootstrap.ItemsView.extend(Bootstrap.WithRouter,
routeName = route.handler.routeName
if route.handler.breadcrumbs?.name
displayName = route.handler.breadcrumbs.name
if translation.test(displayName)
displayName = route.handler[displayName.match(translation)[1]]
else if @get('nameDictionary')?["#{@dictionaryNamePrefix}.#{routeName}"]
displayName = @get('nameDictionary')["#{@dictionaryNamePrefix}.#{routeName}"]
else
Expand Down
14 changes: 13 additions & 1 deletion app/templates/showcase/show_components/breadcrumbs.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,17 @@ SomeRoute = Ember.Route.extend({
breadcrumbs: {name: 'Primary'}

...
})
});
```


If you're using [ember-i18n](https://github.com/jamesarosen/ember-i18n) translation library, you can also translate your breadcrumbs with relative ease. You'll have to enable [ember-i18n's properties translation](https://github.com/jamesarosen/ember-i18n#translate-properties-on-any-object) feature for the routes you'd like their names translated and setup breadcrumbs to refernce the translated property's name, like so:

```javascript
SomeRoute = Ember.Route.extend(Ember.I18n.TranslateableProperties, {
primaryTranslation: "generic.primary",
breadcrumbs: {name: 'primaryTranslation'}

...
});
```
2 changes: 1 addition & 1 deletion dist/js/bs-badge.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/js/bs-basic.max.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
}
},
click: function(event) {
return this.sendAction('clicked');
return this.sendAction('clicked', event);
},
collapsibleBodyId: (function() {
return "" + (this.get('elementId')) + "_body";
Expand Down
2 changes: 1 addition & 1 deletion dist/js/bs-basic.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions dist/js/bs-breadcrumbs.max.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Breadcrumbs compponent.
Breadcrumbs component.
*/


Expand Down Expand Up @@ -29,10 +29,11 @@ Breadcrumbs compponent.
return this.send('updateCrumbsByRoute');
},
updateCrumbsByRoute: function() {
var routes,
var routes, translation,
_this = this;
this.get('content').clear();
routes = this.get('container').lookup('router:main');
translation = /(.*)Translation$/;
routes.get('router.currentHandlerInfos').forEach(function(route, i, arr) {
var crumb, displayName, name, routeName, _ref, _ref1, _ref2;
name = route.name;
Expand All @@ -45,6 +46,9 @@ Breadcrumbs compponent.
routeName = route.handler.routeName;
if ((_ref1 = route.handler.breadcrumbs) != null ? _ref1.name : void 0) {
displayName = route.handler.breadcrumbs.name;
if (translation.test(displayName)) {
displayName = route.handler[displayName.match(translation)[1]];
}
} else if ((_ref2 = _this.get('nameDictionary')) != null ? _ref2["" + _this.dictionaryNamePrefix + "." + routeName] : void 0) {
displayName = _this.get('nameDictionary')["" + _this.dictionaryNamePrefix + "." + routeName];
} else {
Expand Down
Loading