Skip to content

Commit

Permalink
chore(sample): unused controller
Browse files Browse the repository at this point in the history
  • Loading branch information
ncuillery committed Jun 13, 2014
1 parent e49eeac commit a474fe2
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 28 deletions.
54 changes: 37 additions & 17 deletions dist/angular-breadcrumb.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! angular-breadcrumb - v0.2.1 - 2014-05-16
/*! angular-breadcrumb - v0.2.1-dev-2014-06-13
* https://github.com/ncuillery/angular-breadcrumb
* Copyright (c) 2014 Nicolas Cuillery; Licensed MIT */

Expand All @@ -23,7 +23,18 @@ function $Breadcrumb() {
angular.extend($$options, options);
};

this.$get = ['$state', function($state) {
this.$get = ['$state', '$rootScope', function($state, $rootScope) {

var $lastViewScope = $rootScope;

// Early catch of $viewContentLoaded event
$rootScope.$on('$viewContentLoaded', function (event) {
console.log('listener service');
// With nested views, the event occur several times, in "wrong" order
if(isAOlderThanB(event.targetScope.$id, $lastViewScope.$id)) {
$lastViewScope = event.targetScope;
}
});

// Check if a property in state's data is inherited from the parent state
var $$isInherited = function(state, dataProperty) {
Expand Down Expand Up @@ -128,6 +139,10 @@ function $Breadcrumb() {
while(state && state.name !== '');

return chain;
},

$getLastViewScope: function() {
return $lastViewScope;
}
};
}];
Expand Down Expand Up @@ -162,22 +177,27 @@ function BreadcrumbDirective($interpolate, $breadcrumb, $rootScope) {
templateUrl: $breadcrumb.getTemplateUrl(),
link: {
post: function postLink(scope) {
var lastScopeId;
$rootScope.$on('$viewContentLoaded', function (event) {
// With nested views, the event occur several times, in "wrong" order
if(!lastScopeId || isAOlderThanB(event.targetScope.$id, lastScopeId)) {
lastScopeId = event.targetScope.$id;
scope.steps = $breadcrumb.getStatesChain();
angular.forEach(scope.steps, function (value) {
if (value.data && value.data.ncyBreadcrumbLabel) {
var parseLabel = $interpolate(value.data.ncyBreadcrumbLabel);
value.ncyBreadcrumbLabel = parseLabel(event.targetScope);
} else {
value.ncyBreadcrumbLabel = value.name;
}
});
}

var renderBreadcrumb = function() {
var viewScope = $breadcrumb.$getLastViewScope();
scope.steps = $breadcrumb.getStatesChain();
angular.forEach(scope.steps, function (value) {
if (value.data && value.data.ncyBreadcrumbLabel) {
var parseLabel = $interpolate(value.data.ncyBreadcrumbLabel);
value.ncyBreadcrumbLabel = parseLabel(viewScope);
} else {
value.ncyBreadcrumbLabel = value.name;
}
});
};

$rootScope.$on('$viewContentLoaded', function () {
console.log('listener directive');
renderBreadcrumb();
});

// View(s) may be already loaded while the directive's linking
renderBreadcrumb();
}
}
};
Expand Down
4 changes: 2 additions & 2 deletions dist/angular-breadcrumb.min.js

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

8 changes: 0 additions & 8 deletions sample/controllers/home.js

This file was deleted.

1 change: 0 additions & 1 deletion sample/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@

<script src="app.js"></script>

<script src="controllers/home.js"></script>
<script src="controllers/room_list.js"></script>
<script src="controllers/room_detail.js"></script>
<script src="controllers/booking_list.js"></script>
Expand Down

0 comments on commit a474fe2

Please sign in to comment.