@@ -17,6 +17,7 @@ angular.module('spotmop', [
1717 'spotmop.common.contextmenu' ,
1818 'spotmop.common.tracklist' ,
1919
20+ 'spotmop.services.notify' ,
2021 'spotmop.services.settings' ,
2122 'spotmop.services.player' ,
2223 'spotmop.services.spotify' ,
@@ -27,7 +28,6 @@ angular.module('spotmop', [
2728 'spotmop.player' ,
2829 'spotmop.queue' ,
2930 'spotmop.library' ,
30- 'spotmop.playlists' ,
3131 'spotmop.search' ,
3232 'spotmop.settings' ,
3333
@@ -60,7 +60,7 @@ angular.module('spotmop', [
6060/**
6161 * Global controller
6262 **/
63- . controller ( 'ApplicationController' , function ApplicationController ( $scope , $rootScope , $state , $localStorage , $timeout , $location , SpotifyService , MopidyService , EchonestService , PlayerService , SettingsService ) {
63+ . controller ( 'ApplicationController' , function ApplicationController ( $scope , $rootScope , $state , $localStorage , $timeout , $location , SpotifyService , MopidyService , EchonestService , PlayerService , SettingsService , NotifyService ) {
6464
6565 $scope . isTouchDevice = function ( ) {
6666 if ( SettingsService . getSetting ( 'emulateTouchDevice' , false ) )
@@ -130,8 +130,8 @@ angular.module('spotmop', [
130130 SettingsService . getVersion ( )
131131 . success ( function ( response ) {
132132 if ( ! currentVersion || currentVersion != response . versionCode ) {
133- SettingsService . setSetting ( 'version' , response . versionCode )
134- $scope . $broadcast ( 'spotmop:notifyUser' , { id : 'updated' , message : ' Spotmop has been updated - please clear your browser cache', autoremove : 5000 } ) ;
133+ SettingsService . setSetting ( 'version' , response . versionCode ) ;
134+ NotifyService . notify ( ' Spotmop has been updated - please clear your browser cache' ) ;
135135 }
136136 } ) ;
137137
@@ -241,44 +241,6 @@ angular.module('spotmop', [
241241 if ( SettingsService . getSetting ( 'echonestenabled' , false ) )
242242 EchonestService . addToTasteProfile ( 'play' , tlTrack . tl_track . track . uri ) ;
243243 } ) ;
244-
245-
246- /**
247- * User notifications
248- * Displays a user-friendly notification. Can be error, loader or tip
249- **/
250- $scope . $on ( 'spotmop:notifyUser' , function ( event , data ) {
251-
252- // handle undefined errors
253- if ( typeof ( data . type ) === 'undefined' )
254- data . type = '' ;
255-
256- // if we're a keyboard shortcut notification, this requires icon injection
257- if ( data . type == 'keyboard-shortcut' ) {
258- data . message = '<i class="fa fa-' + data . icon + '"></i>' ;
259- }
260-
261- // default to autoremove
262- if ( typeof ( data . autoremove ) === 'undefined' )
263- data . autoremove = true ;
264-
265- // remove any existing notifications of this type (using notification id)
266- $ ( document ) . find ( '#notifications .notification-item[data-id="' + data . id + '"]' ) . remove ( ) ; ;
267-
268- var container = $ ( document ) . find ( '#notifications' ) ;
269- var notification = '<div class="notification-item ' + data . type + '" data-id="' + data . id + '">' + data . message + '</div>' ;
270- container . append ( notification ) ;
271- notification = $ ( document ) . find ( '#notifications .notification-item[data-id="' + data . id + '"]' ) ;
272-
273- if ( data . autoremove ) {
274- $timeout (
275- function ( ) {
276- notification . fadeOut ( 200 , function ( ) { notification . remove ( ) } ) ;
277- } ,
278- 2500
279- ) ;
280- }
281- } ) ;
282244
283245
284246
@@ -318,7 +280,7 @@ angular.module('spotmop', [
318280 $scope . spotifyUser = response ;
319281
320282 if ( typeof ( response . error ) !== 'undefined' ) {
321- $scope . $broadcast ( 'spotmop:notifyUser' , { type : 'error' , message : response . error . message } ) ;
283+ NotifyService . error ( response . error . message ) ;
322284 } else {
323285 $rootScope . spotifyOnline = true ;
324286
@@ -408,12 +370,12 @@ angular.module('spotmop', [
408370 * When we click anywhere
409371 * This allows us to kill context menus, unselect tracks, etc
410372 **/
411- $ ( document ) . on ( 'mouseup' , 'body' , function ( evt ) {
373+ $ ( document ) . on ( 'mouseup' , 'body' , function ( event ) {
412374
413375 // if we've clicked OUTSIDE of a tracklist, let's kill the context menu
414376 // clicking INSIDE the tracklist is handled by the track/tltrack directives
415- if ( $ ( evt . target ) . closest ( '.tracklist' ) . length <= 0 ) {
416- $rootScope . $broadcast ( 'spotmop:hideContextMenu ' ) ;
377+ if ( $ ( event . target ) . closest ( '.tracklist' ) . length <= 0 ) {
378+ $rootScope . $broadcast ( 'spotmop:contextMenu:hide ' ) ;
417379 }
418380 } ) ;
419381
@@ -504,21 +466,16 @@ angular.module('spotmop', [
504466
505467 // dropping on queue
506468 if ( isMenuItem && target . attr ( 'data-type' ) === 'queue' ) {
507-
508- $rootScope . requestsLoading ++ ;
509469
510470 if ( uris . length > 10 ) {
511- $scope . $broadcast ( 'spotmop:notifyUser' , { type : 'loading' , id : 'adding-to-queue' , message : ' Adding '+ uris . length + ' track(s) to queue... this could take some time' } ) ;
471+ NotifyService . notify ( ' Adding '+ uris . length + ' track(s) to queue... this could take some time' ) ;
512472 }
513473
514- MopidyService . addToTrackList ( uris ) . then ( function ( response ) {
515- $rootScope . requestsLoading -- ;
516- $scope . $broadcast ( 'spotmop:notifyUserRemoval' , { id : 'adding-to-queue' } ) ;
517- } ) ;
474+ MopidyService . addToTrackList ( uris ) ;
518475
519476 // dropping on library
520477 } else if ( isMenuItem && target . attr ( 'data-type' ) === 'library' ) {
521-
478+
522479 // convert all our URIs to IDs
523480 var trackids = new Array ( ) ;
524481 $ . each ( uris , function ( key , value ) {
@@ -548,6 +505,10 @@ angular.module('spotmop', [
548505 // sorting queue tracklist
549506 if ( track . closest ( '.tracklist' ) . hasClass ( 'queue-items' ) ) {
550507
508+ // destination position needs to account for length of selection offset, if we're dragging DOWN the list
509+ if ( to_position >= end )
510+ to_position = to_position - uris . length ;
511+
551512 // note: mopidy want's the first track AFTER our range, so we need to +1
552513 MopidyService . moveTlTracks ( start , end + 1 , to_position ) ;
553514
0 commit comments