Skip to content

Commit

Permalink
fixed #3: using angular's orderBy filter to sort steps
Browse files Browse the repository at this point in the history
  • Loading branch information
benmarch committed Jan 15, 2016
1 parent 1ec92f1 commit 1e745d0
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 26 deletions.
11 changes: 3 additions & 8 deletions app/tour-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
(function (app) {
'use strict';

app.controller('TourController', ['$q', 'TourConfig', 'uiTourBackdrop', function ($q, TourConfig, uiTourBackdrop) {
app.controller('TourController', ['$q', '$filter', 'TourConfig', 'uiTourBackdrop', function ($q, $filter, TourConfig, uiTourBackdrop) {

var self = this,
stepList = [],
Expand Down Expand Up @@ -63,13 +63,8 @@
if (~stepList.indexOf(step)) {
return;
}
var insertBeforeIndex = 0;
stepList.forEach(function (stepElement, index) {
if (step.order >= stepElement.order) {
insertBeforeIndex = index;
}
});
stepList.splice(insertBeforeIndex + 1, 0, step);
stepList.push(step);
stepList = $filter('orderBy')(stepList, 'order');
if (resumeWhenFound) {
resumeWhenFound(step);
}
Expand Down
16 changes: 7 additions & 9 deletions demo/angular-ui-tour.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@
(function (app) {
'use strict';

app.controller('TourController', ['$q', 'TourConfig', 'uiTourBackdrop', function ($q, TourConfig, uiTourBackdrop) {
app.controller('TourController', ['$q', '$filter', 'TourConfig', 'uiTourBackdrop', function ($q, $filter, TourConfig, uiTourBackdrop) {

var self = this,
stepList = [],
Expand Down Expand Up @@ -218,13 +218,8 @@
if (~stepList.indexOf(step)) {
return;
}
var insertBeforeIndex = 0;
stepList.forEach(function (stepElement, index) {
if (step.order >= stepElement.order) {
insertBeforeIndex = index;
}
});
stepList.splice(insertBeforeIndex + 1, 0, step);
stepList.push(step);
stepList = $filter('orderBy')(stepList, 'order');
if (resumeWhenFound) {
resumeWhenFound(step);
}
Expand Down Expand Up @@ -471,7 +466,7 @@

//Pass static options through or use defaults
var tour = {},
events = 'onStart onEnd onShow onShown onHide onHidden onNext onPrev onPause onResume'.split(' '),
events = 'onReady onStart onEnd onShow onShown onHide onHidden onNext onPrev onPause onResume'.split(' '),
properties = 'placement animation popupDelay closePopupDelay trigger enable appendToBody tooltipClass orphan backdrop'.split(' ');

//Pass interpolated values through
Expand All @@ -487,6 +482,9 @@

//Initialize tour
scope.tour = ctrl.init(tour);
if (typeof tour.onReady === 'function') {
tour.onReady();
}
}
};

Expand Down
11 changes: 3 additions & 8 deletions dist/angular-ui-tour.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@
(function (app) {
'use strict';

app.controller('TourController', ['$q', 'TourConfig', 'uiTourBackdrop', function ($q, TourConfig, uiTourBackdrop) {
app.controller('TourController', ['$q', '$filter', 'TourConfig', 'uiTourBackdrop', function ($q, $filter, TourConfig, uiTourBackdrop) {

var self = this,
stepList = [],
Expand Down Expand Up @@ -218,13 +218,8 @@
if (~stepList.indexOf(step)) {
return;
}
var insertBeforeIndex = 0;
stepList.forEach(function (stepElement, index) {
if (step.order >= stepElement.order) {
insertBeforeIndex = index;
}
});
stepList.splice(insertBeforeIndex + 1, 0, step);
stepList.push(step);
stepList = $filter('orderBy')(stepList, 'order');
if (resumeWhenFound) {
resumeWhenFound(step);
}
Expand Down
Loading

0 comments on commit 1e745d0

Please sign in to comment.