#4: Keep the dropdown menu open after selecting a track or album download in a cacheable format.

This commit is contained in:
Peter Deltchev 2015-11-02 20:15:26 -08:00
parent b2408e3d84
commit b441a58819
5 changed files with 32 additions and 13 deletions

View file

@ -1,7 +1,7 @@
<div class="resource-details album-details" bindonce="album">
<ul class="dropdowns">
<li class="dropdown">
<a href="#" class="btn btn-small btn-info dropdown-toggle" ng-disabled="album.is_downloadable == 0">
<a href="#" class="btn btn-small btn-info dropdown-toggle" ng-disabled="album.is_downloadable == 0" auto-close="outsideClick">
Downloads
</a>
<ul class="dropdown-menu" ng-show="album.is_downloadable == 1">

View file

@ -1,7 +1,7 @@
<div class="resource-details track-details" bindonce="track">
<ul class="dropdowns">
<li class="dropdown">
<a href="#" class="btn btn-small btn-info dropdown-toggle" ng-disabled="track.is_downloadable == 0">
<a href="#" class="btn btn-small btn-info dropdown-toggle" ng-disabled="track.is_downloadable == 0" auto-close="outsideClick">
Downloads
</a>
<ul class="dropdown-menu" ng-show="track.is_downloadable == 1">

View file

@ -52,5 +52,5 @@ angular.module('ponyfm').controller "album", [
$timeout $scope.getCachedAlbum(id, format), 5000
else
$scope.isInProgress = false
$window.open $scope.albumUrl, '_blank'
$window.open $scope.albumUrl
]

View file

@ -84,5 +84,5 @@ angular.module('ponyfm').controller "track", [
$timeout $scope.getCachedTrack(id, format), 5000
else
$scope.isInProgress = false
$window.open $scope.trackUrl, '_blank'
$window.location = $scope.trackUrl#, '_blank'
]

View file

@ -1269,10 +1269,29 @@ angular.module('ui.bootstrap.dropdownToggle', []).directive('dropdownToggle', ['
element.parent().addClass('open');
openElement = element;
closeMenu = function (event) {
// Dropdowns with with the `auto-close="outsideClick"` attribute are handled differently.
// They will only close if the user clicks somewhere outside of the dropdown menu.
//
// => Partially backported from: https://github.com/angular-ui/bootstrap/pull/3045/files
if ('autoClose' in attrs && attrs.autoClose === 'outsideClick') {
if (typeof event !== 'undefined' && !element.parent()[0].contains(event.target)) {
// Only close the menu if we detect a click outside the element.
$document.unbind('click', closeMenu);
element.parent().removeClass('open');
closeMenu = angular.noop;
openElement = null;
}
return;
}
// If this isn't an "outside click", handle it as usual.
if (event) {
event.preventDefault();
event.stopPropagation();
}
$document.unbind('click', closeMenu);
element.parent().removeClass('open');
closeMenu = angular.noop;