diff --git a/.gitignore b/.gitignore index 8cfd857..0ffeec4 100755 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ config.js +/Concepts/ /temp -app/services/mopidy/mopidy.pid @eaDir Thumbs.db diff --git a/app/app.js b/app/app.js index 2221559..2683eea 100755 --- a/app/app.js +++ b/app/app.js @@ -69,7 +69,11 @@ angular.module('spotmop', [ // fetch this instance's best thumbnail $scope.image = getThumbnailImage( $scope.images ); - // get the best thumbnail image, please and thankyou + /** + * Get the most appropriate thumbnail image + * @param images = array of image urls + * @return string (image url) + **/ function getThumbnailImage( images ){ // what if there are no images? then nada @@ -138,12 +142,12 @@ angular.module('spotmop', [ $scope.text = $scope.defaultText; // bind to document-wide click events - $(document).on('click', function(evt){ + $(document).on('click', function(event){ - // if we've clicked on THIS confirmation button - if( evt.target == $element[0] ){ + // if we've left-clicked on THIS confirmation button + if( event.target == $element[0] && event.which == 1 ){ if( $scope.confirming ){ - + // if the function exists, perform the on-confirmation function from the directive's template if( typeof( $scope.$parent[ $scope.onConfirmation ]() ) === 'function' ) $scope.$parent[ $scope.onConfirmation ](); @@ -172,7 +176,7 @@ angular.module('spotmop', [ }, replace: true, // Replace with the template below transclude: true, // we want to insert custom content inside the directive - template: '' + template: '' }; }) @@ -234,7 +238,11 @@ angular.module('spotmop', [ **/ .controller('ApplicationController', function ApplicationController( $scope, $rootScope, $state, $localStorage, $timeout, $location, SpotifyService, MopidyService, EchonestService, SettingsService ){ - $scope.isTouchDevice = function(){ return !!('ontouchstart' in window); } + $scope.isTouchDevice = function(){ + if( SettingsService.getSetting('emulateTouchDevice',false) ) + return true; + return !!('ontouchstart' in window); + } $scope.isSameDomainAsMopidy = function(){ var mopidyhost = SettingsService.getSetting('mopidyhost','localhost'); @@ -255,13 +263,16 @@ angular.module('spotmop', [ window.location.reload(); } $scope.playlistsMenu = []; + $scope.myPlaylists = {}; // update the playlists menu $scope.updatePlaylists = function(){ SpotifyService.getPlaylists( $scope.spotifyUser.id, 50 ) .success(function( response ) { - + + $scope.myPlaylists = response.items; + var newPlaylistsMenu = []; // loop all of our playlists, and set up a menu item for each @@ -302,7 +313,6 @@ angular.module('spotmop', [ } angular.element(window).resize(function () { - $scope.resquarePanels(); $scope.windowWidth = $(document).width(); // if we're a small or medium screen, re-hide the sidebar and reset the body sliding @@ -317,14 +327,6 @@ angular.module('spotmop', [ } }); - // make all the square panels really square - $scope.resquarePanels = function(){ - $(document).find('.square-panel').each( function(index, value){ - var realWidth = value.getBoundingClientRect().width; - $(value).find('.image-container').css('height', realWidth +'px'); - }); - } - $rootScope.$on('$stateChangeStart', function(event, toState, toParams, fromState, fromParams){ $scope.hideMenu(); }); @@ -419,16 +421,6 @@ angular.module('spotmop', [ var notificationItem = $(document).find('#notifications .notification-item[data-id="'+data.id+'"]'); notificationItem.fadeOut(200, function(){ notificationItem.remove() }); }); - - // the page content has been updated - $scope.$on('spotmop:pageUpdated', function(){ - - // wait for $digest - $timeout( function(){ - $scope.resquarePanels(); - }, - 0); - }); diff --git a/app/browse/album/controller.js b/app/browse/album/controller.js index 8bddbd6..e0c8a2d 100755 --- a/app/browse/album/controller.js +++ b/app/browse/album/controller.js @@ -17,10 +17,10 @@ angular.module('spotmop.browse.album', []) /** * Main controller **/ -.controller('AlbumController', function AlbumController( $scope, $rootScope, SpotifyService, $stateParams, $filter ){ +.controller('AlbumController', function AlbumController( $scope, $rootScope, $stateParams, $filter, MopidyService, SpotifyService ){ $scope.album = {}; - $scope.tracklist = {}; + $scope.tracklist = {type: 'track'}; $scope.convertedDate = function(){ if( $scope.album.release_date_precision == 'day' ) return $filter('date')($scope.album.release_date, "MMMM d, yyyy"); @@ -41,6 +41,26 @@ angular.module('spotmop.browse.album', []) } return Math.round(totalTime / 100000); } + + // play the whole album + $scope.playAlbum = function(){ + MopidyService.playStream( $scope.album.uri ); + } + + // add album to library + $scope.addToLibrary = function(){ + $rootScope.$broadcast('spotmop:notifyUser', {type: 'loading', id: 'adding-to-library', message: 'Adding to library'}); + + var trackids = []; + angular.forEach( $scope.tracklist.tracks, function( track ){ + trackids.push( SpotifyService.getFromUri( 'trackid', track.uri ) ); + }); + + SpotifyService.addTracksToLibrary( trackids ) + .success( function(response){ + $rootScope.$broadcast('spotmop:notifyUserRemoval', {id: 'adding-to-library'}); + }); + } $rootScope.$broadcast('spotmop:notifyUser', {type: 'loading', id: 'loading-album', message: 'Loading'}); @@ -50,9 +70,9 @@ angular.module('spotmop.browse.album', []) $scope.album = response; $scope.tracklist = response.tracks; + $scope.tracklist.type = 'track'; $scope.tracklist.tracks = response.tracks.items; - $rootScope.$broadcast('spotmop:pageUpdated'); $rootScope.$broadcast('spotmop:notifyUserRemoval', {id: 'loading-album'}); }) .error(function( error ){ diff --git a/app/browse/album/template.html b/app/browse/album/template.html index aa1aeca..2e4290f 100755 --- a/app/browse/album/template.html +++ b/app/browse/album/template.html @@ -1,7 +1,5 @@