Skip to content

Commit ba90207

Browse files
authored
Merge pull request #31 from vineetasharma/master
Fixed back button clicking taking user to more than one back and merged breadcrumbs changes #119443087
2 parents 67f5d8b + 7571358 commit ba90207

File tree

4 files changed

+94
-24
lines changed

4 files changed

+94
-24
lines changed

test/widget/widget.home.controller.spec.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ describe("WidgetHomeCtrl", function () {
4848
datastore: {
4949
onUpdate: function () {
5050

51+
}
52+
},
53+
history: {
54+
get: function () {
55+
5156
}
5257
}
5358
};
@@ -72,7 +77,8 @@ describe("WidgetHomeCtrl", function () {
7277
$timeout: $timeout,
7378
DEFAULT_DATA: DEFAULT_DATA,
7479
soundCloudAPI: soundCloudAPI,
75-
Buildfire: BF
80+
Buildfire: BF,
81+
$rootScope: $rootScope
7682
});
7783
q = $q;
7884
});
@@ -287,7 +293,7 @@ describe("WidgetHomeCtrl", function () {
287293

288294
it('should make openMoreInfo true', function () {
289295
controller.openMoreInfoOverlay();
290-
expect(controller.openMoreInfo).toBeTruthy();
296+
expect($rootScope.openMoreInfo).toBeTruthy();
291297
});
292298
});
293299

@@ -385,7 +391,7 @@ describe("WidgetHomeCtrl", function () {
385391
});
386392
});
387393

388-
xdescribe('Initial Data fetch', function () {
394+
describe('Initial Data fetch', function () {
389395
it('should set the info to default data in case fetch fails', function () {
390396
controller.SoundCloudInfoContent = {
391397
get: function () {

widget/app.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -128,25 +128,25 @@
128128
});
129129
};
130130
}])
131-
.run(['$location', '$rootScope','$timeout', function ($location, $rootScope,$timeout) {
132-
buildfire.navigation.onBackButtonClick = function () {
131+
.run(['$location', '$rootScope','$timeout', function ($location, $rootScope,$timeout) {
132+
buildfire.history.onPop(function(data, err){
133+
console.log('buildfire.history.onPop----------------------------',data,'Error------------------',err);
133134
if($rootScope.playTrack){
134135
$timeout(function () {
135136
if($rootScope.openPlaylist){
136137
$rootScope.openPlaylist=false;
137-
}
138-
else{
138+
} else if($rootScope.openSettings) {
139+
$rootScope.openSettings = false;
140+
} else if($rootScope.openMoreInfo) {
141+
$rootScope.openMoreInfo = false;
142+
} else {
139143
$rootScope.playTrack=false;
140144
$rootScope.$broadcast("destroy currentTrack");
141145
}
142146
}, 100);
143147
if($rootScope.$$phase){$rootScope.$digest();}
144148
}
145-
else{
146-
buildfire.navigation._goBackOne();
147-
}
148-
};
149-
149+
});
150150
}]);
151151
})
152152
(window.angular, window.buildfire);

widget/controllers/widget.home.controller.js

Lines changed: 71 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,21 @@
8080
);
8181

8282
WidgetHome.goToTrack = function (track) {
83+
var breadCrumbFlag = true;
84+
85+
Buildfire.history.get('pluginBreadcrumbsOnly', function (err, result) {
86+
if(result && result.length) {
87+
result.forEach(function(breadCrumb) {
88+
if(breadCrumb.label == track.title) {
89+
breadCrumbFlag = false;
90+
}
91+
});
92+
}
93+
if(breadCrumbFlag) {
94+
Buildfire.history.push(track.title, { elementToShow: 'Media' });
95+
}
96+
});
97+
// Buildfire.history.push(track.title, { elementToShow:'Media'});
8398
WidgetHome.showTrackSlider = false;
8499
console.log('Goto Track called---------------------------------------', track);
85100
audioPlayer.pause();
@@ -362,16 +377,46 @@
362377
}
363378
});
364379
// }
365-
WidgetHome.openMoreInfo = false;
380+
var breadCrumbFlag = true;
381+
382+
Buildfire.history.get('pluginBreadcrumbsOnly', function (err, result) {
383+
if(result && result.length) {
384+
result.forEach(function(breadCrumb) {
385+
if(breadCrumb.label == 'Playlist') {
386+
breadCrumbFlag = false;
387+
}
388+
});
389+
}
390+
if(breadCrumbFlag) {
391+
Buildfire.history.push('Playlist', { elementToShow: 'Playlist' });
392+
}
393+
});
394+
$rootScope.openMoreInfo = false;
366395
$rootScope.openPlaylist = true;
367396
};
368397
WidgetHome.changeTime = function (time) {
369398
console.log('Change time method called---------------------------------', time);
370399
audioPlayer.setTime(time);
371400
};
372401
WidgetHome.getSettings = function (dontOpen) {
373-
if (!dontOpen)
374-
WidgetHome.openSettings = true;
402+
if (!dontOpen) {
403+
$rootScope.openSettings = true;
404+
var breadCrumbFlag = true;
405+
406+
Buildfire.history.get('pluginBreadcrumbsOnly', function (err, result) {
407+
if(result && result.length) {
408+
result.forEach(function(breadCrumb) {
409+
if(breadCrumb.label == 'Settings') {
410+
breadCrumbFlag = false;
411+
}
412+
});
413+
}
414+
if(breadCrumbFlag) {
415+
Buildfire.history.push('Settings', { elementToShow: 'Settings' });
416+
}
417+
});
418+
}
419+
375420
audioPlayer.settings.get(function (err, data) {
376421
console.log('Got player settings-----------------------', err, data);
377422
if (data) {
@@ -393,17 +438,36 @@
393438
toggle ? track.swiped = true : track.swiped = false;
394439
};
395440
WidgetHome.openMoreInfoOverlay = function () {
396-
WidgetHome.openMoreInfo = true;
441+
$rootScope.openMoreInfo = true;
442+
var breadCrumbFlag = true;
443+
444+
Buildfire.history.get('pluginBreadcrumbsOnly', function (err, result) {
445+
if(result && result.length) {
446+
result.forEach(function(breadCrumb) {
447+
if(breadCrumb.label == 'MoreMenu') {
448+
breadCrumbFlag = false;
449+
}
450+
});
451+
}
452+
if(breadCrumbFlag) {
453+
Buildfire.history.push('MoreMenu', { elementToShow: 'MoreMenu' });
454+
}
455+
});
397456
};
398457
WidgetHome.closeSettingsOverlay = function () {
399-
WidgetHome.openSettings = false;
458+
//$rootScope.openSettings = false;
459+
Buildfire.history.pop();
460+
WidgetHome.closeSwipeRemove();
400461
};
401462
WidgetHome.closePlayListOverlay = function () {
402-
$rootScope.openPlaylist = false;
463+
Buildfire.history.pop();
464+
//$rootScope.openPlaylist = false;
403465
WidgetHome.closeSwipeRemove();
404466
};
405467
WidgetHome.closeMoreInfoOverlay = function () {
406-
WidgetHome.openMoreInfo = false;
468+
//$rootScope.openMoreInfo = false;
469+
Buildfire.history.pop();
470+
WidgetHome.closeSwipeRemove();
407471
};
408472
WidgetHome.closeSwipeRemove = function () {
409473
for (var _i = 0; _i < WidgetHome.swiped.length; _i++) {

widget/templates/nowPlaying.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,9 @@ <h3 class="titleBarTheme">Playlist is empty.</h3>
136136
</div>
137137

138138
<!-- More Info Overlay -->
139-
<div ng-if="WidgetHome.openMoreInfo" class="overlay"
140-
style="position:fixed; top:0; left:0; width:100%; height:100%;">
141-
<div class="overlay-content" style="position:absolute; top:0; left:0; height:100%; width: 100%; overflow:auto;">
139+
<div ng-if="openMoreInfo" class="overlay"
140+
style="position:fixed; top:0; left:0; width:100%; height:100%; background:rgba(0,0,0,0.8);">
141+
<div class="overlay-content" style="postiion:absolute; top:0; left:0; height:100%; width: 100%; overflow:auto;">
142142
<div class="media-player-more-info">
143143
<div class="media-holder margin-top-thirty">
144144
<div class="media-inner text-center">
@@ -184,8 +184,8 @@ <h4 class="margin-zero ellipsis whiteTheme">{{WidgetHome.currentTrack.title}}</h
184184
</div>
185185

186186
<!-- Settings Overlay -->
187-
<div ng-if="WidgetHome.openSettings" class="overlay"
188-
style="position:fixed; top:0; left:0; width:100%; height:100%;">
187+
<div ng-if="openSettings" class="overlay"
188+
style="position:fixed; top:0; left:0; width:100%; height:100%; background:rgba(0,0,0,0.8);">
189189
<div class="overlay-content" style="position:absolute; top:0; left:0; height:100%; width: 100%; overflow:auto;">
190190
<div class="media-player-settings">
191191
<div class="settings-list padded padding-top-zero">

0 commit comments

Comments
 (0)