mirror of
https://github.com/Poniverse/Pony.fm.git
synced 2024-11-22 13:07:59 +01:00
Add assets (scripts + styles)
This commit is contained in:
parent
b233738eb5
commit
6875637fe4
184 changed files with 56637 additions and 2 deletions
|
@ -1,2 +0,0 @@
|
|||
// @import "node_modules/bootstrap-sass/assets/stylesheets/bootstrap";
|
||||
|
248
resources/assets/scripts/app/app.coffee
Normal file
248
resources/assets/scripts/app/app.coffee
Normal file
|
@ -0,0 +1,248 @@
|
|||
window.pfm.preloaders = {}
|
||||
|
||||
module = angular.module 'ponyfm', ['ui.bootstrap', 'ui.state', 'ui.date', 'ui.sortable', 'pasvaz.bindonce', 'angularytics']
|
||||
|
||||
module.run [
|
||||
'Angularytics',
|
||||
(analyitcs) ->
|
||||
analyitcs.init()
|
||||
]
|
||||
|
||||
module.config [
|
||||
'$locationProvider', '$stateProvider', '$dialogProvider', 'AngularyticsProvider', '$httpProvider', '$sceDelegateProvider'
|
||||
(location, state, $dialogProvider, analytics, $httpProvider, $sceDelegateProvider) ->
|
||||
|
||||
$httpProvider.interceptors.push [
|
||||
->
|
||||
request: (config) ->
|
||||
return config if !(/^\/?templates\//.test config.url)
|
||||
config.url += '?' + Math.ceil(Math.random() * 1000000)
|
||||
return config
|
||||
]
|
||||
|
||||
# This fixes resource loading on IE
|
||||
$sceDelegateProvider.resourceUrlWhitelist [
|
||||
'self',
|
||||
'/templates/directives/*'
|
||||
]
|
||||
|
||||
analytics.setEventHandlers ['Google']
|
||||
|
||||
# Errors
|
||||
state.state 'errors-404',
|
||||
url: '/errors/not-found'
|
||||
templateUrl: '/templates/errors/404.html'
|
||||
|
||||
state.state 'errors-500',
|
||||
url: '/errors/server'
|
||||
templateUrl: '/templates/errors/500.html'
|
||||
|
||||
state.state 'errors-403',
|
||||
url: '/errors/not-authorized'
|
||||
templateUrl: '/templates/errors/403.html'
|
||||
|
||||
state.state 'errors-400',
|
||||
url: '/errors/invalid'
|
||||
templateUrl: '/templates/errors/400.html'
|
||||
|
||||
# Upload
|
||||
|
||||
state.state 'uploader',
|
||||
url: '/account/uploader'
|
||||
templateUrl: '/templates/uploader/index.html'
|
||||
controller: 'uploader'
|
||||
|
||||
# Account
|
||||
|
||||
state.state 'account',
|
||||
url: '/account'
|
||||
abstract: true
|
||||
templateUrl: '/templates/account/_layout.html'
|
||||
|
||||
state.state 'account.settings',
|
||||
url: ''
|
||||
templateUrl: '/templates/account/settings.html'
|
||||
controller: 'account-settings'
|
||||
|
||||
state.state 'account.tracks',
|
||||
url: '/tracks'
|
||||
templateUrl: '/templates/account/tracks.html'
|
||||
controller: 'account-tracks'
|
||||
|
||||
state.state 'account.tracks.edit',
|
||||
url: '/edit/:track_id'
|
||||
templateUrl: '/templates/account/track.html'
|
||||
controller: 'account-track'
|
||||
|
||||
state.state 'account.albums',
|
||||
url: '/albums'
|
||||
templateUrl: '/templates/account/albums.html'
|
||||
controller: 'account-albums'
|
||||
|
||||
state.state 'account.albums.create',
|
||||
url: '/create'
|
||||
templateUrl: '/templates/account/album.html'
|
||||
controller: 'account-albums-edit'
|
||||
|
||||
state.state 'account.albums.edit',
|
||||
url: '/edit/:album_id'
|
||||
templateUrl: '/templates/account/album.html'
|
||||
controller: 'account-albums-edit'
|
||||
|
||||
state.state 'account.playlists',
|
||||
url: '/playlists'
|
||||
templateUrl: '/templates/account/playlists.html'
|
||||
controller: 'account-playlists'
|
||||
|
||||
state.state 'favourites',
|
||||
url: '/account/favourites'
|
||||
abstract: true
|
||||
templateUrl: '/templates/favourites/_layout.html'
|
||||
|
||||
state.state 'favourites.tracks',
|
||||
url: '/tracks'
|
||||
templateUrl: '/templates/favourites/tracks.html'
|
||||
controller: 'favourites-tracks'
|
||||
|
||||
state.state 'favourites.playlists',
|
||||
url: '/playlists'
|
||||
templateUrl: '/templates/favourites/playlists.html'
|
||||
controller: 'favourites-playlists'
|
||||
|
||||
state.state 'favourites.albums',
|
||||
url: '/albums'
|
||||
templateUrl: '/templates/favourites/albums.html'
|
||||
controller: 'favourites-albums'
|
||||
|
||||
# Tracks
|
||||
|
||||
state.state 'content',
|
||||
abstract: true
|
||||
templateUrl: '/templates/content/_layout.html'
|
||||
|
||||
state.state 'content.tracks',
|
||||
templateUrl: '/templates/tracks/index.html'
|
||||
controller: 'tracks'
|
||||
url: '/tracks'
|
||||
abstract: true
|
||||
|
||||
state.state 'content.tracks.list',
|
||||
url: '^/tracks?filter&page'
|
||||
templateUrl: '/templates/tracks/list.html'
|
||||
controller: 'tracks-list'
|
||||
|
||||
state.state 'content.track',
|
||||
url: '/tracks/{id:[^\-]+}-{slug}'
|
||||
templateUrl: '/templates/tracks/show.html'
|
||||
controller: 'track'
|
||||
|
||||
# Albums
|
||||
|
||||
state.state 'content.albums',
|
||||
url: '/albums'
|
||||
templateUrl: '/templates/albums/index.html'
|
||||
controller: 'albums'
|
||||
abstract: true
|
||||
|
||||
state.state 'content.albums.list',
|
||||
url: '?page'
|
||||
templateUrl: '/templates/albums/list.html'
|
||||
controller: 'albums-list'
|
||||
|
||||
state.state 'content.album',
|
||||
url: '/albums/{id:[^\-]+}-{slug}'
|
||||
templateUrl: '/templates/albums/show.html'
|
||||
controller: 'album'
|
||||
|
||||
# Playlists
|
||||
|
||||
state.state 'content.playlists',
|
||||
url: '/playlists'
|
||||
templateUrl: '/templates/playlists/index.html'
|
||||
controller: 'playlists'
|
||||
abstract: true
|
||||
|
||||
state.state 'content.playlists.list',
|
||||
url: '?page'
|
||||
controller: 'playlists-list'
|
||||
templateUrl: '/templates/playlists/list.html'
|
||||
|
||||
state.state 'content.playlist',
|
||||
url: '/playlist/{id:[^\-]+}-{slug}'
|
||||
templateUrl: '/templates/playlists/show.html'
|
||||
controller: 'playlist'
|
||||
|
||||
# Artists
|
||||
|
||||
state.state 'content.artists',
|
||||
url: '/artists'
|
||||
templateUrl: '/templates/artists/index.html'
|
||||
controller: 'artists'
|
||||
abstract: true
|
||||
|
||||
state.state 'content.artists.list',
|
||||
url: '?page'
|
||||
templateUrl: '/templates/artists/list.html'
|
||||
controller: 'artists-list'
|
||||
|
||||
# Pages
|
||||
|
||||
state.state 'faq',
|
||||
url: '/faq'
|
||||
templateUrl: '/templates/pages/faq.html'
|
||||
|
||||
state.state 'about',
|
||||
url: '/about'
|
||||
templateUrl: '/templates/pages/about.html'
|
||||
|
||||
# Auth
|
||||
|
||||
state.state 'login',
|
||||
url: '/login'
|
||||
templateUrl: '/templates/auth/login.html'
|
||||
controller: 'login'
|
||||
|
||||
state.state 'register',
|
||||
url: '/register'
|
||||
templateUrl: '/templates/auth/register.html'
|
||||
|
||||
# Hompage
|
||||
|
||||
if window.pfm.auth.isLogged
|
||||
state.state 'home',
|
||||
url: '/'
|
||||
templateUrl: '/templates/dashboard/index.html'
|
||||
controller: 'dashboard'
|
||||
else
|
||||
state.state 'home',
|
||||
url: '/'
|
||||
templateUrl: '/templates/home/index.html'
|
||||
controller: 'home'
|
||||
|
||||
# Final catch-all for aritsts
|
||||
state.state 'content.artist',
|
||||
url: '^/{slug}'
|
||||
templateUrl: '/templates/artists/_show_layout.html'
|
||||
abstract: true
|
||||
controller: 'artist'
|
||||
|
||||
state.state 'content.artist.profile',
|
||||
url: ''
|
||||
templateUrl: '/templates/artists/profile.html'
|
||||
controller: 'artist-profile'
|
||||
|
||||
state.state 'content.artist.content',
|
||||
url: '/content'
|
||||
templateUrl: '/templates/artists/content.html'
|
||||
controller: 'artist-content'
|
||||
|
||||
state.state 'content.artist.favourites',
|
||||
url: '/favourites'
|
||||
templateUrl: '/templates/artists/favourites.html'
|
||||
controller: 'artist-favourites'
|
||||
|
||||
location.html5Mode(true);
|
||||
$dialogProvider.options
|
||||
dialogFade: true
|
||||
backdropClick: false
|
||||
]
|
|
@ -0,0 +1,143 @@
|
|||
window.pfm.preloaders['account-albums-edit'] = [
|
||||
'account-tracks', 'account-albums', '$state'
|
||||
(tracks, albums, $state) ->
|
||||
defs = [tracks.refresh()]
|
||||
if $state.params.album_id
|
||||
defs.push albums.getEdit($state.params.album_id, true)
|
||||
|
||||
$.when.all defs
|
||||
]
|
||||
|
||||
angular.module('ponyfm').controller "account-albums-edit", [
|
||||
'$scope', '$state', '$dialog', 'account-albums'
|
||||
($scope, $state, $dialog, albums) ->
|
||||
$scope.isNew = $state.params.album_id == undefined
|
||||
$scope.data.isEditorOpen = true
|
||||
$scope.errors = {}
|
||||
$scope.isDirty = false
|
||||
$scope.album = {}
|
||||
$scope.isSaving = false
|
||||
$scope.tracks = []
|
||||
$scope.trackIds = {}
|
||||
|
||||
$scope.toggleTrack = (track) ->
|
||||
if $scope.trackIds[track.id]
|
||||
delete $scope.trackIds[track.id]
|
||||
$scope.tracks.splice ($scope.tracks.indexOf track), 1
|
||||
else
|
||||
$scope.trackIds[track.id] = track
|
||||
$scope.tracks.push track
|
||||
|
||||
$scope.isDirty = true
|
||||
|
||||
$scope.sortTracks = () ->
|
||||
$scope.isDirty = true
|
||||
|
||||
$scope.touchModel = -> $scope.isDirty = true
|
||||
|
||||
$scope.setCover = (image, type) ->
|
||||
delete $scope.album.cover_id
|
||||
delete $scope.album.cover
|
||||
|
||||
if image == null
|
||||
$scope.album.remove_cover = true
|
||||
else if type == 'file'
|
||||
$scope.album.cover = image
|
||||
else if type == 'gallery'
|
||||
$scope.album.cover_id = image.id
|
||||
|
||||
$scope.isDirty = true
|
||||
|
||||
$scope.$on '$destroy', -> $scope.data.isEditorOpen = false
|
||||
|
||||
$scope.saveAlbum = ->
|
||||
return if !$scope.isNew && !$scope.isDirty
|
||||
|
||||
url =
|
||||
if $scope.isNew
|
||||
'/api/web/albums/create'
|
||||
else
|
||||
'/api/web/albums/edit/' + $state.params.album_id
|
||||
|
||||
xhr = new XMLHttpRequest()
|
||||
xhr.onload = -> $scope.$apply ->
|
||||
$scope.isSaving = false
|
||||
response = $.parseJSON(xhr.responseText)
|
||||
if xhr.status != 200
|
||||
$scope.errors = {}
|
||||
_.each response.errors, (value, key) -> $scope.errors[key] = value.join ', '
|
||||
return
|
||||
|
||||
$scope.$emit 'album-updated'
|
||||
|
||||
if $scope.isNew
|
||||
$scope.isDirty = false
|
||||
$scope.$emit 'album-created'
|
||||
$state.transitionTo 'account.albums.edit', {album_id: response.id}
|
||||
else
|
||||
$scope.isDirty = false
|
||||
$scope.data.selectedAlbum.title = $scope.album.title
|
||||
$scope.data.selectedAlbum.covers.normal = response.real_cover_url
|
||||
|
||||
formData = new FormData()
|
||||
|
||||
_.each $scope.album, (value, name) ->
|
||||
if name == 'cover'
|
||||
return if value == null
|
||||
if typeof(value) == 'object'
|
||||
formData.append name, value, value.name
|
||||
else
|
||||
formData.append name, value
|
||||
|
||||
formData.append 'track_ids', _.map($scope.tracks, (t) -> t.id).join()
|
||||
|
||||
xhr.open 'POST', url, true
|
||||
xhr.setRequestHeader 'X-Token', pfm.token
|
||||
$scope.isSaving = true
|
||||
xhr.send formData
|
||||
|
||||
$scope.deleteAlbum = () ->
|
||||
$dialog.messageBox('Delete ' + $scope.album.title, 'Are you sure you want to delete "' + $scope.album.title + '"? This cannot be undone.', [
|
||||
{result: 'ok', label: 'Yes', cssClass: 'btn-danger'}, {result: 'cancel', label: 'No', cssClass: 'btn-primary'}
|
||||
]).open().then (res) ->
|
||||
return if res == 'cancel'
|
||||
$.post('/api/web/albums/delete/' + $scope.album.id, {_token: window.pfm.token})
|
||||
.then -> $scope.$apply ->
|
||||
$scope.$emit 'album-deleted'
|
||||
$state.transitionTo 'account.albums'
|
||||
|
||||
$scope.setCover = (image, type) ->
|
||||
delete $scope.album.cover_id
|
||||
delete $scope.album.cover
|
||||
|
||||
if image == null
|
||||
$scope.album.remove_cover = true
|
||||
else if type == 'file'
|
||||
$scope.album.cover = image
|
||||
else if type == 'gallery'
|
||||
$scope.album.cover_id = image.id
|
||||
|
||||
$scope.isDirty = true
|
||||
|
||||
if !$scope.isNew
|
||||
albums.getEdit($state.params.album_id).done (album) ->
|
||||
$scope.album =
|
||||
id: album.id
|
||||
title: album.title
|
||||
description: album.description
|
||||
remove_cover: false
|
||||
cover: album.cover_url
|
||||
|
||||
$scope.tracks = []
|
||||
$scope.tracks.push track for track in album.tracks
|
||||
$scope.trackIds[track.id] = track for track in album.tracks
|
||||
|
||||
else
|
||||
$scope.album =
|
||||
title: ''
|
||||
description: ''
|
||||
|
||||
$scope.$on '$locationChangeStart', (e) ->
|
||||
return if !$scope.isDirty
|
||||
e.preventDefault() if !confirm('Are you sure you want to leave this page without saving your changes?')
|
||||
]
|
|
@ -0,0 +1,47 @@
|
|||
window.pfm.preloaders['account-albums'] = [
|
||||
'account-tracks', 'account-albums'
|
||||
(tracks, albums) ->
|
||||
$.when.all [tracks.refresh('published=true&in_album=false', true), albums.refresh(true)]
|
||||
]
|
||||
|
||||
angular.module('ponyfm').controller "account-albums", [
|
||||
'$scope', '$state', 'account-albums', 'account-tracks'
|
||||
($scope, $state, albums, tracks) ->
|
||||
|
||||
$scope.albums = []
|
||||
$scope.data =
|
||||
isEditorOpen: false
|
||||
selectedAlbum: null
|
||||
tracksDb: []
|
||||
|
||||
selectAlbum = (album) -> $scope.data.selectedAlbum = album
|
||||
|
||||
updateTracks = (tracks) ->
|
||||
$scope.data.tracksDb.push track for track in tracks
|
||||
|
||||
tracks.refresh('published=true&in_album=false').done updateTracks
|
||||
|
||||
albumsDb = {}
|
||||
|
||||
updateAlbums = (albums) ->
|
||||
$scope.albums.length = 0
|
||||
|
||||
for album in albums
|
||||
$scope.albums.push album
|
||||
albumsDb[album.id] = album
|
||||
|
||||
if $state.params.album_id
|
||||
selectAlbum albumsDb[$state.params.album_id]
|
||||
|
||||
albums.refresh().done updateAlbums
|
||||
|
||||
$scope.$on '$stateChangeSuccess', () ->
|
||||
if $state.params.album_id
|
||||
selectAlbum albumsDb[$state.params.album_id]
|
||||
else
|
||||
selectAlbum null
|
||||
|
||||
$scope.$on 'album-created', () -> albums.refresh(true).done(updateAlbums)
|
||||
$scope.$on 'album-deleted', () -> albums.refresh(true).done(updateAlbums)
|
||||
$scope.$on 'album-updated', () -> tracks.refresh('published=true&in_album=false', true).done updateTracks
|
||||
]
|
|
@ -0,0 +1,10 @@
|
|||
angular.module('ponyfm').controller "account-image-select", [
|
||||
'$scope'
|
||||
($scope) ->
|
||||
$scope.images = []
|
||||
$scope.isLoading = true
|
||||
|
||||
$.getJSON('/api/web/images/owned').done (images) -> $scope.$apply ->
|
||||
$scope.images = images
|
||||
$scope.isLoading = false
|
||||
]
|
|
@ -0,0 +1,44 @@
|
|||
window.pfm.preloaders['account-playlists'] = [
|
||||
'playlists'
|
||||
(playlists) -> playlists.refreshOwned true
|
||||
]
|
||||
|
||||
angular.module('ponyfm').controller "account-playlists", [
|
||||
'$scope', 'auth', '$dialog', 'playlists'
|
||||
($scope, auth, $dialog, playlists) ->
|
||||
$scope.playlists = []
|
||||
|
||||
loadPlaylists = (playlists) ->
|
||||
$scope.playlists.push playlist for playlist in playlists
|
||||
|
||||
playlists.refreshOwned().done loadPlaylists
|
||||
|
||||
$scope.editPlaylist = (playlist) ->
|
||||
dialog = $dialog.dialog
|
||||
templateUrl: '/templates/partials/playlist-dialog.html'
|
||||
controller: 'playlist-form'
|
||||
resolve: {
|
||||
playlist: () -> angular.copy playlist
|
||||
}
|
||||
|
||||
dialog.open()
|
||||
|
||||
$scope.togglePlaylistPin = (playlist) ->
|
||||
playlist.is_pinned = !playlist.is_pinned;
|
||||
playlists.editPlaylist playlist
|
||||
|
||||
$scope.deletePlaylist = (playlist) ->
|
||||
$dialog.messageBox('Delete ' + playlist.title, 'Are you sure you want to delete "' + playlist.title + '"? This cannot be undone.', [
|
||||
{result: 'ok', label: 'Yes', cssClass: 'btn-danger'},
|
||||
{result: 'cancel', label: 'No', cssClass: 'btn-primary'}
|
||||
]).open().then (res) ->
|
||||
return if res == 'cancel'
|
||||
playlists.deletePlaylist(playlist).done ->
|
||||
$scope.playlists.splice _.indexOf($scope.playlists, (p) -> p.id == playlist.id), 1
|
||||
|
||||
$scope.$on 'playlist-updated', (e, playlist) ->
|
||||
index = _.indexOf($scope.playlists, (p) -> p.id == playlist.id)
|
||||
content = $scope.playlists[index]
|
||||
_.each playlist, (value, name) -> content[name] = value
|
||||
$scope.playlists.sort (left, right) -> left.title.localeCompare right.title
|
||||
]
|
|
@ -0,0 +1,63 @@
|
|||
angular.module('ponyfm').controller "account-settings", [
|
||||
'$scope', 'auth'
|
||||
($scope, auth) ->
|
||||
$scope.settings = {}
|
||||
$scope.errors = {}
|
||||
$scope.isDirty = false
|
||||
|
||||
$scope.touchModel = () ->
|
||||
$scope.isDirty = true
|
||||
|
||||
$scope.refresh = () ->
|
||||
$.getJSON('/api/web/account/settings')
|
||||
.done (res) -> $scope.$apply ->
|
||||
$scope.settings = res
|
||||
|
||||
$scope.setAvatar = (image, type) ->
|
||||
delete $scope.settings.avatar_id
|
||||
delete $scope.settings.avatar
|
||||
|
||||
if type == 'file'
|
||||
$scope.settings.avatar = image
|
||||
else if type == 'gallery'
|
||||
$scope.settings.avatar_id = image.id
|
||||
|
||||
$scope.isDirty = true
|
||||
|
||||
$scope.updateAccount = () ->
|
||||
return if !$scope.isDirty
|
||||
|
||||
xhr = new XMLHttpRequest()
|
||||
xhr.onload = -> $scope.$apply ->
|
||||
$scope.isSaving = false
|
||||
response = $.parseJSON(xhr.responseText)
|
||||
if xhr.status != 200
|
||||
$scope.errors = {}
|
||||
_.each response.errors, (value, key) -> $scope.errors[key] = value.join ', '
|
||||
return
|
||||
|
||||
$scope.isDirty = false
|
||||
$scope.errors = {}
|
||||
$scope.refresh()
|
||||
|
||||
formData = new FormData()
|
||||
|
||||
_.each $scope.settings, (value, name) ->
|
||||
if name == 'avatar'
|
||||
return if value == null
|
||||
if typeof(value) == 'object'
|
||||
formData.append name, value, value.name
|
||||
else
|
||||
formData.append name, value
|
||||
|
||||
xhr.open 'POST', '/api/web/account/settings/save', true
|
||||
xhr.setRequestHeader 'X-Token', pfm.token
|
||||
$scope.isSaving = true
|
||||
xhr.send formData
|
||||
|
||||
$scope.refresh()
|
||||
|
||||
$scope.$on '$stateChangeStart', (e) ->
|
||||
return if $scope.selectedTrack == null || !$scope.isDirty
|
||||
e.preventDefault() if !confirm('Are you sure you want to leave this page without saving your changes?')
|
||||
]
|
147
resources/assets/scripts/app/controllers/account-track.coffee
Normal file
147
resources/assets/scripts/app/controllers/account-track.coffee
Normal file
|
@ -0,0 +1,147 @@
|
|||
window.pfm.preloaders['account-track'] = [
|
||||
'account-tracks', 'account-albums', 'taxonomies', '$state'
|
||||
(tracks, albums, taxonomies, state) ->
|
||||
$.when.all [albums.refresh(), taxonomies.refresh(), tracks.getEdit(state.params.track_id, true)]
|
||||
]
|
||||
|
||||
angular.module('ponyfm').controller "account-track", [
|
||||
'$scope', '$state', 'taxonomies', '$dialog', 'account-albums', 'account-tracks', 'images'
|
||||
($scope, $state, taxonomies, $dialog, albums, tracks, images) ->
|
||||
$scope.isDirty = false
|
||||
$scope.isSaving = false
|
||||
$scope.taxonomies = taxonomies
|
||||
$scope.selectedSongsTitle = 'None'
|
||||
$scope.selectedSongs = {}
|
||||
$scope.albums = []
|
||||
$scope.selectedAlbum = null
|
||||
|
||||
albumsDb = {}
|
||||
albums.refresh().done (albums) ->
|
||||
$scope.albums.legnth = 0
|
||||
albumsDb = {}
|
||||
for album in albums
|
||||
albumsDb[album.id] = album
|
||||
$scope.albums.push album
|
||||
|
||||
$scope.selectAlbum = (album) ->
|
||||
$scope.selectedAlbum = album
|
||||
$scope.edit.album_id = if album then album.id else null
|
||||
$scope.isDirty = true
|
||||
|
||||
$scope.setCover = (image, type) ->
|
||||
delete $scope.edit.cover_id
|
||||
delete $scope.edit.cover
|
||||
|
||||
if image == null
|
||||
$scope.edit.remove_cover = true
|
||||
else if type == 'file'
|
||||
$scope.edit.cover = image
|
||||
else if type == 'gallery'
|
||||
$scope.edit.cover_id = image.id
|
||||
|
||||
$scope.isDirty = true
|
||||
|
||||
updateSongDisplay = () ->
|
||||
if _.size $scope.selectedSongs
|
||||
$scope.selectedSongsTitle = (_.map _.values($scope.selectedSongs), (s) -> s.title).join(', ')
|
||||
else
|
||||
$scope.selectedSongsTitle = 'None'
|
||||
|
||||
$scope.toggleSong = (song) ->
|
||||
$scope.isDirty = true
|
||||
if $scope.selectedSongs[song.id]
|
||||
delete $scope.selectedSongs[song.id]
|
||||
else
|
||||
$scope.selectedSongs[song.id] = song
|
||||
|
||||
updateSongDisplay()
|
||||
|
||||
$scope.updateIsVocal = () ->
|
||||
delete $scope.errors.lyrics if !$scope.edit.is_vocal
|
||||
|
||||
$scope.updateTrack = () ->
|
||||
xhr = new XMLHttpRequest()
|
||||
xhr.onload = -> $scope.$apply ->
|
||||
$scope.isSaving = false
|
||||
if xhr.status != 200
|
||||
errors =
|
||||
if xhr.getResponseHeader('content-type') == 'application/json'
|
||||
$.parseJSON(xhr.responseText).errors
|
||||
else
|
||||
['There was an unknown error!']
|
||||
|
||||
$scope.errors = {}
|
||||
_.each errors, (value, key) -> $scope.errors[key] = value.join ', '
|
||||
return
|
||||
|
||||
track = $.parseJSON(xhr.responseText)
|
||||
|
||||
trackDbItem = $scope.data.selectedTrack
|
||||
trackDbItem.title = $scope.edit.title
|
||||
trackDbItem.is_explicit = $scope.edit.is_explicit
|
||||
trackDbItem.is_vocal = $scope.edit.is_vocal
|
||||
trackDbItem.genre_id = $scope.edit.genre_id
|
||||
trackDbItem.is_published = true
|
||||
trackDbItem.cover_url = track.real_cover_url
|
||||
$scope.isDirty = false
|
||||
$scope.errors = {}
|
||||
images.refresh true
|
||||
|
||||
formData = new FormData();
|
||||
_.each $scope.edit, (value, name) ->
|
||||
if name == 'cover'
|
||||
return if value == null
|
||||
if typeof(value) == 'object'
|
||||
formData.append name, value, value.name
|
||||
else if value != null
|
||||
formData.append name, value
|
||||
|
||||
if parseInt($scope.edit.track_type_id) == 2
|
||||
formData.append 'show_song_ids', _.map(_.values($scope.selectedSongs), (s) -> s.id).join()
|
||||
|
||||
xhr.open 'POST', '/api/web/tracks/edit/' + $scope.edit.id, true
|
||||
xhr.setRequestHeader 'X-Token', pfm.token
|
||||
$scope.isSaving = true
|
||||
xhr.send formData
|
||||
|
||||
tracks.getEdit($state.params.track_id).done (track) ->
|
||||
console.log (track.album_id);
|
||||
$scope.edit =
|
||||
id: track.id
|
||||
title: track.title
|
||||
description: track.description
|
||||
lyrics: track.lyrics
|
||||
is_explicit: track.is_explicit
|
||||
is_downloadable: track.is_downloadable
|
||||
is_vocal: track.is_vocal
|
||||
license_id: track.license_id
|
||||
genre_id: track.genre_id
|
||||
track_type_id: track.track_type_id
|
||||
released_at: if track.released_at then track.released_at.date else ''
|
||||
remove_cover: false
|
||||
cover: track.cover_url
|
||||
album_id: track.album_id
|
||||
is_published: track.is_published
|
||||
is_listed: track.is_listed
|
||||
|
||||
$scope.selectedAlbum = if track.album_id then albumsDb[track.album_id] else null
|
||||
$scope.selectedSongs = {}
|
||||
$scope.selectedSongs[song.id] = song for song in track.show_songs
|
||||
updateSongDisplay()
|
||||
|
||||
$scope.touchModel = -> $scope.isDirty = true
|
||||
|
||||
$scope.deleteTrack = (track) ->
|
||||
$dialog.messageBox('Delete ' + track.title, 'Are you sure you want to delete "' + track.title + '"? This cannot be undone.', [
|
||||
{result: 'ok', label: 'Yes', cssClass: 'btn-danger'}, {result: 'cancel', label: 'No', cssClass: 'btn-primary'}
|
||||
]).open().then (res) ->
|
||||
return if res == 'cancel'
|
||||
$.post('/api/web/tracks/delete/' + track.id, {_token: window.pfm.token})
|
||||
.then -> $scope.$apply ->
|
||||
$scope.$emit 'track-deleted'
|
||||
$state.transitionTo 'account.tracks'
|
||||
|
||||
$scope.$on '$locationChangeStart', (e) ->
|
||||
return if !$scope.isDirty
|
||||
e.preventDefault() if !confirm('Are you sure you want to leave this page without saving your changes?')
|
||||
]
|
|
@ -0,0 +1,44 @@
|
|||
window.pfm.preloaders['account-tracks'] = [
|
||||
'account-tracks', 'account-albums', 'taxonomies'
|
||||
(tracks, albums, taxonomies) ->
|
||||
$.when.all [tracks.refresh(null, true), albums.refresh(true), taxonomies.refresh()]
|
||||
]
|
||||
|
||||
angular.module('ponyfm').controller "account-tracks", [
|
||||
'$scope', '$state', 'taxonomies', '$dialog', 'lightbox', 'account-albums', 'account-tracks'
|
||||
($scope, $state, taxonomies, $dialog, lightbox, albums, tracks) ->
|
||||
$scope.data =
|
||||
selectedTrack: null
|
||||
|
||||
$scope.tracks = []
|
||||
|
||||
tracksDb = {}
|
||||
|
||||
setTracks = (tracks) ->
|
||||
$scope.tracks.length = 0
|
||||
tracksDb = {}
|
||||
for track in tracks
|
||||
tracksDb[track.id] = track
|
||||
$scope.tracks.push track
|
||||
|
||||
if $state.params.track_id
|
||||
$scope.data.selectedTrack = tracksDb[$state.params.track_id]
|
||||
|
||||
tracks.refresh().done setTracks
|
||||
|
||||
$scope.refreshList = () ->
|
||||
tracks.refresh().done setTracks
|
||||
|
||||
$scope.selectTrack = (track) ->
|
||||
$scope.data.selectedTrack = track
|
||||
|
||||
$scope.$on '$stateChangeSuccess', () ->
|
||||
if $state.params.track_id
|
||||
$scope.selectTrack tracksDb[$state.params.track_id]
|
||||
else
|
||||
$scope.selectTrack null
|
||||
|
||||
$scope.$on 'track-deleted', () ->
|
||||
tracks.clearCache()
|
||||
$scope.refreshList()
|
||||
]
|
27
resources/assets/scripts/app/controllers/album.coffee
Normal file
27
resources/assets/scripts/app/controllers/album.coffee
Normal file
|
@ -0,0 +1,27 @@
|
|||
window.pfm.preloaders['album'] = [
|
||||
'albums', '$state', 'playlists'
|
||||
(albums, $state, playlists) ->
|
||||
$.when.all [albums.fetch $state.params.id, playlists.refreshOwned(true)]
|
||||
]
|
||||
|
||||
angular.module('ponyfm').controller "album", [
|
||||
'$scope', 'albums', '$state', 'playlists', 'auth', '$dialog'
|
||||
($scope, albums, $state, playlists, auth, $dialog) ->
|
||||
album = null
|
||||
|
||||
albums.fetch($state.params.id).done (albumResponse) ->
|
||||
$scope.album = albumResponse.album
|
||||
album = albumResponse.album
|
||||
|
||||
$scope.playlists = []
|
||||
|
||||
$scope.share = () ->
|
||||
dialog = $dialog.dialog
|
||||
templateUrl: '/templates/partials/album-share-dialog.html',
|
||||
controller: ['$scope', ($scope) -> $scope.album = album; $scope.close = () -> dialog.close()]
|
||||
dialog.open()
|
||||
|
||||
if auth.data.isLogged
|
||||
playlists.refreshOwned().done (lists) ->
|
||||
$scope.playlists.push list for list in lists
|
||||
]
|
12
resources/assets/scripts/app/controllers/albums-list.coffee
Normal file
12
resources/assets/scripts/app/controllers/albums-list.coffee
Normal file
|
@ -0,0 +1,12 @@
|
|||
window.pfm.preloaders['albums-list'] = [
|
||||
'albums', '$state'
|
||||
(albums, $state) ->
|
||||
albums.fetchList($state.params.page, true)
|
||||
]
|
||||
|
||||
angular.module('ponyfm').controller "albums-list", [
|
||||
'$scope', 'albums', '$state'
|
||||
($scope, albums, $state) ->
|
||||
albums.fetchList($state.params.page).done (list) ->
|
||||
$scope.albums = list.albums
|
||||
]
|
22
resources/assets/scripts/app/controllers/albums.coffee
Normal file
22
resources/assets/scripts/app/controllers/albums.coffee
Normal file
|
@ -0,0 +1,22 @@
|
|||
angular.module('ponyfm').controller "albums", [
|
||||
'$scope', 'albums', '$state'
|
||||
($scope, albums, $state) ->
|
||||
|
||||
refreshPages = (list) ->
|
||||
$scope.albums = list.albums
|
||||
$scope.currentPage = parseInt(list.current_page)
|
||||
$scope.totalPages = parseInt(list.total_pages)
|
||||
|
||||
delete $scope.nextPage
|
||||
delete $scope.prevPage
|
||||
$scope.nextPage = $scope.currentPage + 1 if $scope.currentPage < $scope.totalPages
|
||||
$scope.prevPage = $scope.currentPage - 1 if $scope.currentPage > 1
|
||||
$scope.pages = [1..$scope.totalPages]
|
||||
|
||||
albums.fetchList($state.params.page).done refreshPages
|
||||
$scope.$on 'albums-feteched', (e, list) -> refreshPages(list)
|
||||
|
||||
$scope.gotoPage = (page) ->
|
||||
return if !page
|
||||
$state.transitionTo 'content.albums.list', {page: page}
|
||||
]
|
85
resources/assets/scripts/app/controllers/application.coffee
Normal file
85
resources/assets/scripts/app/controllers/application.coffee
Normal file
|
@ -0,0 +1,85 @@
|
|||
angular.module('ponyfm').controller "application", [
|
||||
'$scope', 'auth', '$location', 'upload', '$state', '$stateParams', '$injector', '$rootScope', 'playlists'
|
||||
($scope, auth, $location, upload, $state, $stateParams, $injector, $rootScope, playlists) ->
|
||||
$scope.auth = auth.data
|
||||
$scope.$state = $state
|
||||
$scope.$stateParams = $stateParams
|
||||
$scope.isPinnedPlaylistSelected = false
|
||||
$loadingElement = null
|
||||
loadingStateName = null
|
||||
|
||||
if window.pfm.error
|
||||
$state.transitionTo 'errors-' + window.pfm.error
|
||||
|
||||
$rootScope.safeApply = (fn) ->
|
||||
phase = $rootScope.$$phase
|
||||
if (phase == '$apply' || phase == 'digest')
|
||||
fn()
|
||||
return
|
||||
|
||||
$rootScope.$apply fn
|
||||
|
||||
$scope.logout = () ->
|
||||
auth.logout().done -> location.reload()
|
||||
|
||||
$scope.isActive = (loc) -> $location.path() == loc
|
||||
$scope.$on '$viewContentLoaded', () ->
|
||||
window.setTimeout (-> window.handleResize()), 0
|
||||
|
||||
if $loadingElement
|
||||
$loadingElement.removeClass 'loading'
|
||||
$loadingElement = null
|
||||
|
||||
$scope.stateIncludes = (state) ->
|
||||
if $loadingElement
|
||||
newParts = state.split '.'
|
||||
oldParts = loadingStateName.split '.'
|
||||
for i in [0..newParts.length]
|
||||
continue if !newParts[i]
|
||||
return false if newParts[i] != oldParts[i]
|
||||
|
||||
return true
|
||||
else
|
||||
$state.includes(state)
|
||||
|
||||
statesPreloaded = {}
|
||||
$scope.$on '$stateChangeStart', (e, newState, newParams, oldState, oldParams) ->
|
||||
$scope.isPinnedPlaylistSelected = false
|
||||
|
||||
if newState.name == 'content.playlist'
|
||||
$scope.isPinnedPlaylistSelected = playlists.isPlaylistPinned newParams.id
|
||||
|
||||
return if !oldState || !newState.controller
|
||||
|
||||
preloader = window.pfm.preloaders[newState.controller]
|
||||
return if !preloader
|
||||
|
||||
if statesPreloaded[newState]
|
||||
delete statesPreloaded[newState]
|
||||
return
|
||||
|
||||
e.preventDefault()
|
||||
loadingStateName = newState.name
|
||||
|
||||
selector = ''
|
||||
newParts = newState.name.split '.'
|
||||
oldParts = oldState.name.split '.'
|
||||
zipped = _.zip(newParts, oldParts)
|
||||
for i in [0..zipped.length]
|
||||
break if !zipped[i] || zipped[i][0] != zipped[i][1]
|
||||
selector += ' ui-view '
|
||||
|
||||
selector += ' ui-view ' if newState.name != oldState.name
|
||||
|
||||
$loadingElement = $ selector
|
||||
$loadingElement.addClass 'loading'
|
||||
|
||||
stateToInject = angular.copy newState
|
||||
stateToInject.params = newParams
|
||||
try
|
||||
$injector.invoke(preloader, null, {$state: stateToInject}).then ->
|
||||
statesPreloaded[newState] = true
|
||||
$state.transitionTo newState, newParams
|
||||
catch error
|
||||
$state.transitionTo newState, newParams
|
||||
]
|
|
@ -0,0 +1,13 @@
|
|||
window.pfm.preloaders['artist-content'] = [
|
||||
'artists', '$state'
|
||||
(artists, $state) ->
|
||||
$.when.all [artists.fetch($state.params.slug), artists.fetchContent($state.params.slug, true)]
|
||||
]
|
||||
|
||||
angular.module('ponyfm').controller "artist-content", [
|
||||
'$scope', 'artists', '$state'
|
||||
($scope, artists, $state) ->
|
||||
artists.fetchContent($state.params.slug)
|
||||
.done (artistResponse) ->
|
||||
$scope.content = artistResponse
|
||||
]
|
|
@ -0,0 +1,12 @@
|
|||
window.pfm.preloaders['artist-favourites'] = [
|
||||
'artists', '$state'
|
||||
(artists, $state) ->
|
||||
$.when.all [artists.fetch($state.params.slug), artists.fetchFavourites($state.params.slug, true)]
|
||||
]
|
||||
|
||||
angular.module('ponyfm').controller "artist-favourites", [
|
||||
'$scope', 'artists', '$state'
|
||||
($scope, artists, $state) ->
|
||||
artists.fetchFavourites($state.params.slug).done (artistResponse) ->
|
||||
$scope.favourites = artistResponse
|
||||
]
|
|
@ -0,0 +1,10 @@
|
|||
window.pfm.preloaders['artist-profile'] = [
|
||||
'artists', '$state'
|
||||
(artists, $state) ->
|
||||
artists.fetch $state.params.slug, true
|
||||
]
|
||||
|
||||
angular.module('ponyfm').controller "artist-profile", [
|
||||
'$scope', 'artists', '$state'
|
||||
($scope, artists, $state) ->
|
||||
]
|
17
resources/assets/scripts/app/controllers/artist.coffee
Normal file
17
resources/assets/scripts/app/controllers/artist.coffee
Normal file
|
@ -0,0 +1,17 @@
|
|||
window.pfm.preloaders['artist'] = [
|
||||
'artists', '$state'
|
||||
(artists, $state) ->
|
||||
artists.fetch $state.params.slug, true
|
||||
]
|
||||
|
||||
angular.module('ponyfm').controller "artist", [
|
||||
'$scope', 'artists', '$state', 'follow'
|
||||
($scope, artists, $state, follow) ->
|
||||
artists.fetch($state.params.slug)
|
||||
.done (artistResponse) ->
|
||||
$scope.artist = artistResponse.artist
|
||||
|
||||
$scope.toggleFollow = () ->
|
||||
follow.toggle('artist', $scope.artist.id).then (res) ->
|
||||
$scope.artist.user_data.is_following = res.is_followed
|
||||
]
|
12
resources/assets/scripts/app/controllers/artists-list.coffee
Normal file
12
resources/assets/scripts/app/controllers/artists-list.coffee
Normal file
|
@ -0,0 +1,12 @@
|
|||
window.pfm.preloaders['artists-list'] = [
|
||||
'artists', '$state'
|
||||
(artists, $state) ->
|
||||
artists.fetchList($state.params.page, true)
|
||||
]
|
||||
|
||||
angular.module('ponyfm').controller "artists-list", [
|
||||
'$scope', 'artists', '$state'
|
||||
($scope, artists, $state) ->
|
||||
artists.fetchList($state.params.page).done (list) ->
|
||||
$scope.artists = list.artists
|
||||
]
|
22
resources/assets/scripts/app/controllers/artists.coffee
Normal file
22
resources/assets/scripts/app/controllers/artists.coffee
Normal file
|
@ -0,0 +1,22 @@
|
|||
angular.module('ponyfm').controller "artists", [
|
||||
'$scope', 'artists', '$state'
|
||||
($scope, artists, $state) ->
|
||||
|
||||
refreshPages = (list) ->
|
||||
$scope.artists = list.artists
|
||||
$scope.currentPage = parseInt(list.current_page)
|
||||
$scope.totalPages = parseInt(list.total_pages)
|
||||
|
||||
delete $scope.nextPage
|
||||
delete $scope.prevPage
|
||||
$scope.nextPage = $scope.currentPage + 1 if $scope.currentPage < $scope.totalPages
|
||||
$scope.prevPage = $scope.currentPage - 1 if $scope.currentPage > 1
|
||||
$scope.pages = [1..$scope.totalPages]
|
||||
|
||||
artists.fetchList($state.params.page).done refreshPages
|
||||
$scope.$on 'artists-feteched', (e, list) -> refreshPages(list)
|
||||
|
||||
$scope.gotoPage = (page) ->
|
||||
return if !page
|
||||
$state.transitionTo 'content.artists.list', {page: page}
|
||||
]
|
22
resources/assets/scripts/app/controllers/dashboard.coffee
Normal file
22
resources/assets/scripts/app/controllers/dashboard.coffee
Normal file
|
@ -0,0 +1,22 @@
|
|||
window.pfm.preloaders['dashboard'] = [
|
||||
'dashboard'
|
||||
(dashboard) -> dashboard.refresh(true)
|
||||
]
|
||||
|
||||
angular.module('ponyfm').controller "dashboard", [
|
||||
'$scope', 'dashboard', 'auth', '$http'
|
||||
($scope, dashboard, auth, $http) ->
|
||||
$scope.recentTracks = null
|
||||
$scope.popularTracks = null
|
||||
$scope.news = null
|
||||
|
||||
dashboard.refresh().done (res) ->
|
||||
$scope.recentTracks = res.recent_tracks
|
||||
$scope.popularTracks = res.popular_tracks
|
||||
$scope.news = res.news
|
||||
|
||||
$scope.markAsRead = (post) ->
|
||||
if auth.data.isLogged
|
||||
$http.post('/api/web/dashboard/read-news', {url: post.url, _token: window.pfm.token}).success ->
|
||||
post.read = true
|
||||
]
|
|
@ -0,0 +1,12 @@
|
|||
window.pfm.preloaders['favourites-albums'] = [
|
||||
'favourites'
|
||||
(favourites) ->
|
||||
favourites.fetchAlbums(true)
|
||||
]
|
||||
|
||||
angular.module('ponyfm').controller "favourites-albums", [
|
||||
'$scope', 'favourites'
|
||||
($scope, favourites) ->
|
||||
favourites.fetchAlbums().done (res) ->
|
||||
$scope.albums = res.albums
|
||||
]
|
|
@ -0,0 +1,12 @@
|
|||
window.pfm.preloaders['favourites-playlists'] = [
|
||||
'favourites'
|
||||
(favourites) ->
|
||||
favourites.fetchPlaylists(true)
|
||||
]
|
||||
|
||||
angular.module('ponyfm').controller "favourites-playlists", [
|
||||
'$scope', 'favourites'
|
||||
($scope, favourites) ->
|
||||
favourites.fetchPlaylists().done (res) ->
|
||||
$scope.playlists = res.playlists
|
||||
]
|
|
@ -0,0 +1,12 @@
|
|||
window.pfm.preloaders['favourites-tracks'] = [
|
||||
'favourites'
|
||||
(favourites) ->
|
||||
favourites.fetchTracks(true)
|
||||
]
|
||||
|
||||
angular.module('ponyfm').controller "favourites-tracks", [
|
||||
'$scope', 'favourites'
|
||||
($scope, favourites) ->
|
||||
favourites.fetchTracks().done (res) ->
|
||||
$scope.tracks = res.tracks
|
||||
]
|
17
resources/assets/scripts/app/controllers/home.coffee
Normal file
17
resources/assets/scripts/app/controllers/home.coffee
Normal file
|
@ -0,0 +1,17 @@
|
|||
window.pfm.preloaders['home'] = [
|
||||
'dashboard'
|
||||
(dashboard) -> dashboard.refresh(true)
|
||||
]
|
||||
|
||||
angular.module('ponyfm').controller "home", [
|
||||
'$scope', 'dashboard'
|
||||
($scope, dashboard) ->
|
||||
$scope.recentTracks = null
|
||||
$scope.popularTracks = null
|
||||
$scope.news = null
|
||||
|
||||
dashboard.refresh().done (res) ->
|
||||
$scope.recentTracks = res.recent_tracks
|
||||
$scope.popularTracks = res.popular_tracks
|
||||
$scope.news = res.news
|
||||
]
|
18
resources/assets/scripts/app/controllers/login.coffee
Normal file
18
resources/assets/scripts/app/controllers/login.coffee
Normal file
|
@ -0,0 +1,18 @@
|
|||
angular.module('ponyfm').controller "login", [
|
||||
'$scope', 'auth'
|
||||
($scope, auth) ->
|
||||
|
||||
$scope.messages = []
|
||||
|
||||
$scope.login =
|
||||
remember: true
|
||||
|
||||
submit: () ->
|
||||
$scope.messages = []
|
||||
|
||||
auth.login(this.email, this.password, this.remember)
|
||||
.done ->
|
||||
location.reload()
|
||||
.fail (messages) ->
|
||||
$scope.messages = _.values messages
|
||||
]
|
|
@ -0,0 +1,27 @@
|
|||
angular.module('ponyfm').controller "playlist-form", [
|
||||
'$scope', 'dialog', 'playlists', 'playlist'
|
||||
($scope, dialog, playlists, playlist) ->
|
||||
$scope.isLoading = false
|
||||
$scope.form = playlist
|
||||
$scope.isNew = playlist.id == undefined
|
||||
|
||||
$scope.errors = {}
|
||||
|
||||
$scope.createPlaylist = () ->
|
||||
$scope.isLoading = true
|
||||
def =
|
||||
if $scope.isNew
|
||||
playlists.createPlaylist($scope.form)
|
||||
else
|
||||
playlists.editPlaylist($scope.form)
|
||||
|
||||
def
|
||||
.done (res) ->
|
||||
dialog.close(res)
|
||||
|
||||
.fail (errors)->
|
||||
$scope.errors = errors
|
||||
$scope.isLoading = false
|
||||
|
||||
$scope.close = () -> dialog.close(null)
|
||||
]
|
21
resources/assets/scripts/app/controllers/playlist.coffee
Normal file
21
resources/assets/scripts/app/controllers/playlist.coffee
Normal file
|
@ -0,0 +1,21 @@
|
|||
window.pfm.preloaders['playlist'] = [
|
||||
'$state', 'playlists'
|
||||
($state, playlists) ->
|
||||
playlists.fetch $state.params.id, true
|
||||
]
|
||||
|
||||
angular.module('ponyfm').controller 'playlist', [
|
||||
'$scope', '$state', 'playlists', '$dialog'
|
||||
($scope, $state, playlists, $dialog) ->
|
||||
playlist = null
|
||||
|
||||
playlists.fetch($state.params.id).done (playlistResponse) ->
|
||||
$scope.playlist = playlistResponse
|
||||
playlist = playlistResponse
|
||||
|
||||
$scope.share = () ->
|
||||
dialog = $dialog.dialog
|
||||
templateUrl: '/templates/partials/playlist-share-dialog.html',
|
||||
controller: ['$scope', ($scope) -> $scope.playlist = playlist; $scope.close = () -> dialog.close()]
|
||||
dialog.open()
|
||||
]
|
|
@ -0,0 +1,12 @@
|
|||
window.pfm.preloaders['playlists-list'] = [
|
||||
'playlists', '$state'
|
||||
(playlists, $state) ->
|
||||
playlists.fetchList($state.params.page, true)
|
||||
]
|
||||
|
||||
angular.module('ponyfm').controller "playlists-list", [
|
||||
'$scope', 'playlists', '$state',
|
||||
($scope, playlists, $state) ->
|
||||
playlists.fetchList($state.params.page).done (searchResults) ->
|
||||
$scope.playlists = searchResults.playlists
|
||||
]
|
22
resources/assets/scripts/app/controllers/playlists.coffee
Normal file
22
resources/assets/scripts/app/controllers/playlists.coffee
Normal file
|
@ -0,0 +1,22 @@
|
|||
angular.module('ponyfm').controller "playlists", [
|
||||
'$scope', 'playlists', '$state'
|
||||
($scope, playlists, $state) ->
|
||||
|
||||
refreshPages = (list) ->
|
||||
$scope.playlists = list.playlists
|
||||
$scope.currentPage = parseInt(list.current_page)
|
||||
$scope.totalPages = parseInt(list.total_pages)
|
||||
|
||||
delete $scope.nextPage
|
||||
delete $scope.prevPage
|
||||
$scope.nextPage = $scope.currentPage + 1 if $scope.currentPage < $scope.totalPages
|
||||
$scope.prevPage = $scope.currentPage - 1 if $scope.currentPage > 1
|
||||
$scope.pages = [1..$scope.totalPages]
|
||||
|
||||
playlists.fetchList($state.params.page).done refreshPages
|
||||
$scope.$on 'playlists-feteched', (e, list) -> refreshPages(list)
|
||||
|
||||
$scope.gotoPage = (page) ->
|
||||
return if !page
|
||||
$state.transitionTo 'content.playlists.list', {page: page}
|
||||
]
|
41
resources/assets/scripts/app/controllers/sidebar.coffee
Normal file
41
resources/assets/scripts/app/controllers/sidebar.coffee
Normal file
|
@ -0,0 +1,41 @@
|
|||
angular.module('ponyfm').controller "sidebar", [
|
||||
'$scope', '$dialog', 'playlists'
|
||||
($scope, $dialog, playlists) ->
|
||||
$scope.playlists = playlists.pinnedPlaylists
|
||||
|
||||
$scope.createPlaylist = () ->
|
||||
dialog = $dialog.dialog
|
||||
templateUrl: '/templates/partials/playlist-dialog.html'
|
||||
controller: 'playlist-form'
|
||||
resolve: {
|
||||
playlist: () ->
|
||||
is_public: true
|
||||
is_pinned: true
|
||||
name: ''
|
||||
description: ''
|
||||
}
|
||||
|
||||
dialog.open()
|
||||
|
||||
$scope.editPlaylist = (playlist) ->
|
||||
dialog = $dialog.dialog
|
||||
templateUrl: '/templates/partials/playlist-dialog.html'
|
||||
controller: 'playlist-form'
|
||||
resolve: {
|
||||
playlist: () -> angular.copy playlist
|
||||
}
|
||||
|
||||
dialog.open()
|
||||
|
||||
$scope.unpinPlaylist = (playlist) ->
|
||||
playlist.is_pinned = false;
|
||||
playlists.editPlaylist playlist
|
||||
|
||||
$scope.deletePlaylist = (playlist) ->
|
||||
$dialog.messageBox('Delete ' + playlist.title, 'Are you sure you want to delete "' + playlist.title + '"? This cannot be undone.', [
|
||||
{result: 'ok', label: 'Yes', cssClass: 'btn-danger'},
|
||||
{result: 'cancel', label: 'No', cssClass: 'btn-primary'}
|
||||
]).open().then (res) ->
|
||||
return if res == 'cancel'
|
||||
playlists.deletePlaylist playlist
|
||||
]
|
59
resources/assets/scripts/app/controllers/track.coffee
Normal file
59
resources/assets/scripts/app/controllers/track.coffee
Normal file
|
@ -0,0 +1,59 @@
|
|||
window.pfm.preloaders['track'] = [
|
||||
'tracks', '$state', 'playlists'
|
||||
(tracks, $state, playlists) ->
|
||||
$.when.all [tracks.fetch $state.params.id, playlists.refreshOwned(true)]
|
||||
]
|
||||
|
||||
angular.module('ponyfm').controller "track", [
|
||||
'$scope', 'tracks', '$state', 'playlists', 'auth', 'favourites', '$dialog'
|
||||
($scope, tracks, $state, playlists, auth, favourites, $dialog) ->
|
||||
track = null
|
||||
|
||||
tracks.fetch($state.params.id).done (trackResponse) ->
|
||||
$scope.track = trackResponse.track
|
||||
track = trackResponse.track
|
||||
|
||||
$scope.playlists = []
|
||||
|
||||
if auth.data.isLogged
|
||||
playlists.refreshOwned().done (lists) ->
|
||||
$scope.playlists.push list for list in lists
|
||||
|
||||
$scope.favouriteWorking = false
|
||||
|
||||
$scope.toggleFavourite = (track) ->
|
||||
$scope.favouriteWorking = true
|
||||
favourites.toggle('track', track.id).done (res) ->
|
||||
track.is_favourited = res.is_favourited
|
||||
$scope.favouriteWorking = false
|
||||
|
||||
$scope.share = () ->
|
||||
dialog = $dialog.dialog
|
||||
templateUrl: '/templates/partials/track-share-dialog.html',
|
||||
controller: ['$scope', ($scope) -> $scope.track = track; $scope.close = () -> dialog.close()]
|
||||
dialog.open()
|
||||
|
||||
$scope.addToNewPlaylist = () ->
|
||||
dialog = $dialog.dialog
|
||||
templateUrl: '/templates/partials/playlist-dialog.html'
|
||||
controller: 'playlist-form'
|
||||
resolve: {
|
||||
playlist: () ->
|
||||
is_public: true
|
||||
is_pinned: true
|
||||
name: ''
|
||||
description: ''
|
||||
}
|
||||
|
||||
dialog.open().then (playlist) ->
|
||||
return if !playlist
|
||||
|
||||
playlists.addTrackToPlaylist playlist.id, $scope.track.id
|
||||
$state.transitionTo 'playlist', {id: playlist.id}
|
||||
|
||||
$scope.addToPlaylist = (playlist) ->
|
||||
return if playlist.message
|
||||
|
||||
playlists.addTrackToPlaylist(playlist.id, $scope.track.id).done (res) ->
|
||||
playlist.message = res.message
|
||||
]
|
17
resources/assets/scripts/app/controllers/tracks-list.coffee
Normal file
17
resources/assets/scripts/app/controllers/tracks-list.coffee
Normal file
|
@ -0,0 +1,17 @@
|
|||
window.pfm.preloaders['tracks-list'] = [
|
||||
'tracks', '$state'
|
||||
(tracks, $state) ->
|
||||
tracks.loadFilters().then(->
|
||||
tracks.mainQuery.fromFilterString($state.params.filter)
|
||||
tracks.mainQuery.setPage $state.params.page || 1
|
||||
|
||||
tracks.mainQuery.fetch()
|
||||
)
|
||||
]
|
||||
|
||||
angular.module('ponyfm').controller "tracks-list", [
|
||||
'$scope', 'tracks', '$state',
|
||||
($scope, tracks, $state) ->
|
||||
tracks.mainQuery.fetch().done (searchResults) ->
|
||||
$scope.tracks = searchResults.tracks
|
||||
]
|
45
resources/assets/scripts/app/controllers/tracks.coffee
Normal file
45
resources/assets/scripts/app/controllers/tracks.coffee
Normal file
|
@ -0,0 +1,45 @@
|
|||
window.pfm.preloaders['tracks'] = [
|
||||
'tracks', '$state'
|
||||
(tracks) ->
|
||||
tracks.loadFilters()
|
||||
]
|
||||
|
||||
angular.module('ponyfm').controller "tracks", [
|
||||
'$scope', 'tracks', '$state'
|
||||
($scope, tracks, $state) ->
|
||||
$scope.recentTracks = null
|
||||
$scope.query = tracks.mainQuery
|
||||
$scope.filters = tracks.filters
|
||||
|
||||
$scope.toggleListFilter = (filter, id) ->
|
||||
$scope.query.toggleListFilter filter, id
|
||||
$state.transitionTo 'content.tracks.list', {filter: $scope.query.toFilterString()}
|
||||
|
||||
$scope.setFilter = (filter, value) ->
|
||||
$scope.query.setFilter filter, value
|
||||
$state.transitionTo 'content.tracks.list', {filter: $scope.query.toFilterString()}
|
||||
|
||||
$scope.setListFilter = (filter, id) ->
|
||||
$scope.query.setListFilter filter, id
|
||||
$state.transitionTo 'content.tracks.list', {filter: $scope.query.toFilterString()}
|
||||
|
||||
$scope.clearFilter = (filter) ->
|
||||
$scope.query.clearFilter filter
|
||||
$state.transitionTo 'content.tracks.list', {filter: $scope.query.toFilterString()}
|
||||
|
||||
tracks.mainQuery.listen (searchResults) ->
|
||||
$scope.tracks = searchResults.tracks
|
||||
$scope.currentPage = parseInt(searchResults.current_page)
|
||||
$scope.totalPages = parseInt(searchResults.total_pages)
|
||||
delete $scope.nextPage
|
||||
delete $scope.prevPage
|
||||
|
||||
$scope.nextPage = $scope.currentPage + 1 if $scope.currentPage < $scope.totalPages
|
||||
$scope.prevPage = $scope.currentPage - 1 if $scope.currentPage > 1
|
||||
$scope.pages = [1..$scope.totalPages]
|
||||
|
||||
$scope.gotoPage = (page) ->
|
||||
$state.transitionTo 'content.tracks.list', {filter: $state.params.filter, page: page}
|
||||
|
||||
$scope.$on '$destroy', -> tracks.mainQuery = tracks.createQuery()
|
||||
]
|
5
resources/assets/scripts/app/controllers/uploader.coffee
Normal file
5
resources/assets/scripts/app/controllers/uploader.coffee
Normal file
|
@ -0,0 +1,5 @@
|
|||
angular.module('ponyfm').controller "uploader", [
|
||||
'$scope', 'auth', 'upload', '$state'
|
||||
($scope, auth, upload, $state) ->
|
||||
$scope.data = upload
|
||||
]
|
13
resources/assets/scripts/app/directives/albums-list.coffee
Normal file
13
resources/assets/scripts/app/directives/albums-list.coffee
Normal file
|
@ -0,0 +1,13 @@
|
|||
angular.module('ponyfm').directive 'pfmAlbumsList', () ->
|
||||
restrict: 'E'
|
||||
replace: true
|
||||
templateUrl: '/templates/directives/albums-list.html'
|
||||
scope:
|
||||
albums: '=albums',
|
||||
class: '@class'
|
||||
|
||||
controller: [
|
||||
'$scope', 'auth'
|
||||
($scope, auth) ->
|
||||
$scope.auth = auth.data
|
||||
]
|
28
resources/assets/scripts/app/directives/comments.coffee
Normal file
28
resources/assets/scripts/app/directives/comments.coffee
Normal file
|
@ -0,0 +1,28 @@
|
|||
angular.module('ponyfm').directive 'pfmComments', () ->
|
||||
restrict: 'E'
|
||||
templateUrl: '/templates/directives/comments.html'
|
||||
scope:
|
||||
resource: '=resource',
|
||||
type: '@type'
|
||||
|
||||
controller: [
|
||||
'$scope', 'comments', 'auth'
|
||||
($scope, comments, auth) ->
|
||||
|
||||
$scope.isWorking = false
|
||||
$scope.content = ''
|
||||
$scope.auth = auth.data
|
||||
|
||||
refresh = () ->
|
||||
comments.fetchList($scope.type, $scope.resource.id, true).done (comments) ->
|
||||
$scope.resource.comments.length = 0
|
||||
$scope.resource.comments.push comment for comment in comments.list
|
||||
$scope.isWorking = false
|
||||
|
||||
$scope.addComment = () ->
|
||||
content = $scope.content
|
||||
$scope.content = ''
|
||||
$scope.isWorking = true
|
||||
comments.addComment($scope.type, $scope.resource.id, content).done () ->
|
||||
refresh()
|
||||
]
|
4
resources/assets/scripts/app/directives/eat-click.coffee
Normal file
4
resources/assets/scripts/app/directives/eat-click.coffee
Normal file
|
@ -0,0 +1,4 @@
|
|||
angular.module('ponyfm').directive 'pfmEatClick', () ->
|
||||
(scope, element) ->
|
||||
$(element).click (e) ->
|
||||
e.preventDefault()
|
|
@ -0,0 +1,21 @@
|
|||
angular.module('ponyfm').directive 'pfmFavouriteButton', () ->
|
||||
restrict: 'E'
|
||||
templateUrl: '/templates/directives/favourite-button.html'
|
||||
scope:
|
||||
resource: '=resource',
|
||||
class: '@class',
|
||||
type: '@type'
|
||||
replace: true
|
||||
|
||||
controller: [
|
||||
'$scope', 'favourites', 'auth'
|
||||
($scope, favourites, auth) ->
|
||||
$scope.auth = auth.data
|
||||
|
||||
$scope.isWorking = false
|
||||
$scope.toggleFavourite = () ->
|
||||
$scope.isWorking = true
|
||||
favourites.toggle($scope.type, $scope.resource.id).done (res) ->
|
||||
$scope.isWorking = false
|
||||
$scope.resource.user_data.is_favourited = res.is_favourited
|
||||
]
|
86
resources/assets/scripts/app/directives/image-upload.coffee
Normal file
86
resources/assets/scripts/app/directives/image-upload.coffee
Normal file
|
@ -0,0 +1,86 @@
|
|||
angular.module('ponyfm').directive 'pfmImageUpload', () ->
|
||||
$image = null
|
||||
$uploader = null
|
||||
|
||||
restrict: 'E'
|
||||
templateUrl: '/templates/directives/image-upload.html'
|
||||
scope:
|
||||
setImage: '=setImage'
|
||||
image: '=image'
|
||||
|
||||
compile: (element) ->
|
||||
$image = element.find 'img'
|
||||
$uploader = element.find 'input'
|
||||
|
||||
controller: [
|
||||
'images', '$scope', 'lightbox'
|
||||
(images, $scope, lightbox) ->
|
||||
$scope.imageObject = null
|
||||
$scope.imageFile = null
|
||||
$scope.imageUrl = null
|
||||
$scope.isImageLoaded = false
|
||||
$scope.error = null
|
||||
|
||||
$scope.$watch 'image', (val) ->
|
||||
$scope.imageObject = $scope.imageFile = $scope.imageUrl = null
|
||||
$scope.isImageLoaded = false
|
||||
return if !val
|
||||
|
||||
$scope.imageUrl = val
|
||||
$image.attr 'src', val
|
||||
$scope.isImageLoaded = true
|
||||
|
||||
$image.load () -> $scope.$apply ->
|
||||
$scope.isImageLoaded = true
|
||||
window.setTimeout (() -> window.alignVertically($image)), 0
|
||||
|
||||
images.refresh().done (images) -> $scope.images = images
|
||||
|
||||
$scope.previewImage = () ->
|
||||
return if !$scope.isImageLoaded
|
||||
|
||||
if $scope.imageObject
|
||||
lightbox.openImageUrl $scope.imageObject.urls.normal
|
||||
else if $scope.imageFile
|
||||
lightbox.openDataUrl $image.attr 'src'
|
||||
else if $scope.imageUrl
|
||||
lightbox.openImageUrl $scope.imageUrl
|
||||
|
||||
$scope.uploadImage = () ->
|
||||
$uploader.trigger 'click'
|
||||
|
||||
$scope.clearImage = () ->
|
||||
$scope.imageObject = $scope.imageFile = $scope.imageUrl = null
|
||||
$scope.isImageLoaded = false
|
||||
$scope.setImage null
|
||||
|
||||
$scope.selectGalleryImage = (image) ->
|
||||
$scope.imageObject = image
|
||||
$scope.imageFile = null
|
||||
$scope.imageUrl = image.urls.small
|
||||
$image.attr 'src', image.urls.small
|
||||
$scope.isImageLoaded = true
|
||||
$scope.setImage image, 'gallery'
|
||||
|
||||
$scope.setImageFile = (input) ->
|
||||
$scope.$apply ->
|
||||
file = input.files[0]
|
||||
$scope.imageObject = null
|
||||
$scope.imageFile = file
|
||||
|
||||
if file.type != 'image/png'
|
||||
$scope.error = 'Image must be a png!'
|
||||
$scope.isImageLoaded = false
|
||||
$scope.imageObject = $scope.imageFile = $scope.imageUrl = null
|
||||
return
|
||||
|
||||
$scope.error = null
|
||||
$scope.setImage file, 'file'
|
||||
|
||||
reader = new FileReader()
|
||||
reader.onload = (e) -> $scope.$apply ->
|
||||
$image[0].src = e.target.result
|
||||
$scope.isImageLoaded = true
|
||||
|
||||
reader.readAsDataURL file
|
||||
]
|
74
resources/assets/scripts/app/directives/player.coffee
Normal file
74
resources/assets/scripts/app/directives/player.coffee
Normal file
|
@ -0,0 +1,74 @@
|
|||
angular.module('ponyfm').directive 'pfmPlayer', () ->
|
||||
$element = null
|
||||
|
||||
restrict: 'E'
|
||||
templateUrl: '/templates/directives/player.html'
|
||||
scope: {}
|
||||
replace: true
|
||||
|
||||
compile: (element) ->
|
||||
$element = element
|
||||
|
||||
controller: [
|
||||
'$scope', 'player', 'auth'
|
||||
($scope, player, auth) ->
|
||||
$scope.player = player
|
||||
$scope.auth = auth.data
|
||||
$scope.playPause = () ->
|
||||
$scope.player.playPause()
|
||||
|
||||
$scope.playNext = () ->
|
||||
$scope.player.playNext()
|
||||
|
||||
$scope.playPrev = () ->
|
||||
$scope.player.playPrev()
|
||||
|
||||
$scope.seek = (e) ->
|
||||
$transport = $ '.transport'
|
||||
percent = ((e.pageX - $transport.offset().left) / $transport.width())
|
||||
duration = parseFloat($scope.player.currentTrack.duration)
|
||||
|
||||
$scope.player.seek percent * duration * 1000
|
||||
|
||||
isSliding = false
|
||||
$slider = $element.find('.volume-slider')
|
||||
$knob = $element.find('.volume-slider .knob')
|
||||
$bar = $element.find('.volume-slider .bar')
|
||||
|
||||
player.readyDef.done ->
|
||||
initialY = (180 - (180 * (player.volume / 100))) - 7.5
|
||||
$knob.css {top: initialY}
|
||||
|
||||
moveVolumeSlider = (absoluteY) ->
|
||||
newY = absoluteY - $bar.offset().top;
|
||||
maxY = $bar.height() - ($knob.height() / 2) - 8
|
||||
|
||||
newY = 0 if newY < 0
|
||||
newY = maxY if newY > maxY
|
||||
|
||||
percent = 100 - ((newY / maxY) * 100)
|
||||
$scope.player.setVolume percent
|
||||
$knob.css {top: newY}
|
||||
|
||||
$knob.click (e) ->
|
||||
e.preventDefault()
|
||||
e.stopPropagation()
|
||||
|
||||
$slider.click (e) -> $scope.$apply -> moveVolumeSlider(e.pageY - 8)
|
||||
|
||||
$(document).mousemove (e) ->
|
||||
return if !isSliding
|
||||
moveVolumeSlider(e.pageY - 8)
|
||||
|
||||
$knob.mousedown (e) ->
|
||||
e.preventDefault()
|
||||
e.stopPropagation()
|
||||
isSliding = true
|
||||
$slider.parent().addClass('keep-open')
|
||||
|
||||
$(document).mouseup (e) ->
|
||||
e.preventDefault()
|
||||
e.stopPropagation()
|
||||
isSliding = false
|
||||
$slider.parent().removeClass('keep-open')
|
||||
]
|
|
@ -0,0 +1,13 @@
|
|||
angular.module('ponyfm').directive 'pfmPlaylistsList', () ->
|
||||
restrict: 'E'
|
||||
replace: true
|
||||
templateUrl: '/templates/directives/playlists-list.html'
|
||||
scope:
|
||||
playlists: '=playlists',
|
||||
class: '@class'
|
||||
|
||||
controller: [
|
||||
'$scope', 'auth'
|
||||
($scope, auth) ->
|
||||
$scope.auth = auth.data
|
||||
]
|
86
resources/assets/scripts/app/directives/popup.coffee
Normal file
86
resources/assets/scripts/app/directives/popup.coffee
Normal file
|
@ -0,0 +1,86 @@
|
|||
angular.module('ponyfm').directive 'pfmPopup', () ->
|
||||
(scope, element, attrs) ->
|
||||
align = 'left'
|
||||
elementId = attrs.pfmPopup
|
||||
if elementId.indexOf ',' != -1
|
||||
parts = elementId.split ','
|
||||
elementId = parts[0]
|
||||
align = parts[1]
|
||||
|
||||
$popup = $ '#' + attrs.pfmPopup
|
||||
$element = $ element
|
||||
$positionParent = null
|
||||
open = false
|
||||
|
||||
|
||||
documentClickHandler = () ->
|
||||
return if !open
|
||||
$popup.removeClass 'open'
|
||||
open = false
|
||||
|
||||
calculatePosition = ->
|
||||
$popup.parents().each () ->
|
||||
$this = $ this
|
||||
$positionParent = $this if $positionParent == null && ($this.css('position') == 'relative' || $this.is 'body')
|
||||
|
||||
position = $element.offset()
|
||||
parentPosition = $positionParent.offset()
|
||||
|
||||
windowWidth = $(window).width() - 15
|
||||
left = position.left
|
||||
right = left + $popup.width()
|
||||
|
||||
if align == 'left' && right > windowWidth
|
||||
left -= right - windowWidth
|
||||
else if align == 'right'
|
||||
left -= $popup.outerWidth() - $element.outerWidth()
|
||||
|
||||
height = 'auto'
|
||||
top = position.top + $element.height() + 10
|
||||
bottom = top + $popup.height()
|
||||
windowHeight = $(window).height()
|
||||
if bottom > windowHeight
|
||||
height = windowHeight - top;
|
||||
|
||||
return {
|
||||
left: left - parentPosition.left
|
||||
top: top - parentPosition.top,
|
||||
height: height - 15}
|
||||
|
||||
windowResizeHandler = () ->
|
||||
return if !open
|
||||
$popup.css 'height', 'auto'
|
||||
position = calculatePosition()
|
||||
$popup.css
|
||||
left: position.left
|
||||
top: position.top
|
||||
height: position.height
|
||||
|
||||
$(document.body).bind 'click', documentClickHandler
|
||||
$(window).bind 'resize', windowResizeHandler
|
||||
|
||||
$(element).click (e) ->
|
||||
e.preventDefault()
|
||||
e.stopPropagation()
|
||||
|
||||
if open
|
||||
open = false
|
||||
$popup.removeClass 'open'
|
||||
return
|
||||
|
||||
$popup.addClass 'open'
|
||||
|
||||
$popup.css 'height', 'auto'
|
||||
window.setTimeout (->
|
||||
position = calculatePosition()
|
||||
$popup.css
|
||||
left: position.left
|
||||
top: position.top
|
||||
height: position.height
|
||||
|
||||
open = true
|
||||
), 0
|
||||
|
||||
scope.$on '$destroy', () ->
|
||||
$(document.body).unbind 'click', documentClickHandler
|
||||
$(window).unbind 'click', windowResizeHandler
|
|
@ -0,0 +1,5 @@
|
|||
angular.module('ponyfm').directive 'pfmProgressBar', () ->
|
||||
(scope, element, attrs) ->
|
||||
scope.$watch attrs.pfmProgressBar, (val) ->
|
||||
return if !val?
|
||||
$(element).css 'width', val + '%'
|
|
@ -0,0 +1,28 @@
|
|||
angular.module('ponyfm').directive 'pfmScrollRecorder', () ->
|
||||
(scope, element, attrs) ->
|
||||
timeout = null
|
||||
onScroll = null
|
||||
lastInView = null
|
||||
|
||||
element.scroll (e) ->
|
||||
(window.clearTimeout timeout) if timeout
|
||||
timeout = window.setTimeout (-> onScroll e), 500
|
||||
|
||||
onScroll = (e) -> scope.safeApply ->
|
||||
items = element.find 'li:not(.empty)'
|
||||
itemHeight = (items.eq 0).height()
|
||||
itemsArray = items.get()
|
||||
|
||||
elementViewTop = element.offset().top
|
||||
elementViewBottom = elementViewTop + element.height()
|
||||
|
||||
for i in [itemsArray.length - 1..0]
|
||||
listItem = $ itemsArray[i]
|
||||
|
||||
listItemTop = listItem.offset().top + itemHeight
|
||||
isInView = listItemTop > elementViewTop && listItemTop < elementViewBottom
|
||||
if isInView
|
||||
lastInView = listItem
|
||||
break
|
||||
|
||||
scope.$emit 'element-in-view', angular.element(lastInView).scope()
|
|
@ -0,0 +1,6 @@
|
|||
angular.module('ponyfm').directive 'pfmShareButtons', () ->
|
||||
(scope, element) ->
|
||||
window.setTimeout((->
|
||||
Tumblr.activate_share_on_tumblr_buttons()
|
||||
FB.XFBML.parse(null, -> element.addClass('loaded'))
|
||||
), 0)
|
22
resources/assets/scripts/app/directives/src-loader.coffee
Normal file
22
resources/assets/scripts/app/directives/src-loader.coffee
Normal file
|
@ -0,0 +1,22 @@
|
|||
angular.module('ponyfm').directive 'pfmSrcLoader', () ->
|
||||
(scope, element, attrs) ->
|
||||
size = attrs.pfmSrcSize || 'normal'
|
||||
element.css {opacity: .5}
|
||||
|
||||
update = (val) ->
|
||||
element.attr 'src', '/images/icons/loading_' + size + '.png'
|
||||
|
||||
image = element.clone()
|
||||
image.removeAttr 'pfm-src-loader'
|
||||
image.removeAttr 'pfm-src-size'
|
||||
|
||||
image[0].onload = ->
|
||||
element.attr 'src', val
|
||||
element.css {opacity: 0}
|
||||
element.animate {opacity: 1}, 250
|
||||
|
||||
image[0].src = val
|
||||
|
||||
update scope.$eval attrs.pfmSrcLoader
|
||||
|
||||
scope.$watch attrs.pfmSrcLoader, update
|
14
resources/assets/scripts/app/directives/track-player.coffee
Normal file
14
resources/assets/scripts/app/directives/track-player.coffee
Normal file
|
@ -0,0 +1,14 @@
|
|||
angular.module('ponyfm').directive 'pfmTrackPlayer', () ->
|
||||
restrict: 'E'
|
||||
templateUrl: '/templates/directives/track-player.html'
|
||||
scope:
|
||||
track: '=track',
|
||||
class: '@class'
|
||||
replace: true
|
||||
|
||||
controller: [
|
||||
'$scope', 'player'
|
||||
($scope, player) ->
|
||||
$scope.play = () ->
|
||||
player.playTracks [$scope.track], 0
|
||||
]
|
21
resources/assets/scripts/app/directives/tracks-list.coffee
Normal file
21
resources/assets/scripts/app/directives/tracks-list.coffee
Normal file
|
@ -0,0 +1,21 @@
|
|||
angular.module('ponyfm').directive 'pfmTracksList', () ->
|
||||
restrict: 'E'
|
||||
templateUrl: '/templates/directives/tracks-list.html'
|
||||
replace: true
|
||||
scope:
|
||||
tracks: '=tracks',
|
||||
class: '@class'
|
||||
|
||||
controller: [
|
||||
'$scope', 'favourites', 'player', 'auth'
|
||||
($scope, favourites, player, auth) ->
|
||||
$scope.auth = auth.data
|
||||
|
||||
$scope.toggleFavourite = (track) ->
|
||||
favourites.toggle('track', track.id).done (res) ->
|
||||
track.user_data.is_favourited = res.is_favourited
|
||||
|
||||
$scope.play = (track) ->
|
||||
index = _.indexOf $scope.tracks, (t) -> t.id == track.id
|
||||
player.playTracks $scope.tracks, index
|
||||
]
|
20
resources/assets/scripts/app/directives/uploader.coffee
Normal file
20
resources/assets/scripts/app/directives/uploader.coffee
Normal file
|
@ -0,0 +1,20 @@
|
|||
angular.module('ponyfm').directive 'uploader', [
|
||||
'upload'
|
||||
(upload) -> (scope, element) ->
|
||||
$dropzone = $(element)
|
||||
|
||||
$dropzone[0].addEventListener 'dragover', (e) ->
|
||||
e.preventDefault()
|
||||
$dropzone.addClass 'file-over'
|
||||
|
||||
$dropzone[0].addEventListener 'dragleave', (e) ->
|
||||
e.preventDefault()
|
||||
$dropzone.removeClass 'file-over'
|
||||
|
||||
$dropzone[0].addEventListener 'drop', (e) ->
|
||||
e.preventDefault()
|
||||
$dropzone.removeClass 'file-over'
|
||||
|
||||
files = e.target.files || e.dataTransfer.files
|
||||
scope.$apply -> upload.upload files
|
||||
]
|
3
resources/assets/scripts/app/filters/length.coffee
Normal file
3
resources/assets/scripts/app/filters/length.coffee
Normal file
|
@ -0,0 +1,3 @@
|
|||
angular.module('ponyfm').filter 'pfmLength', () ->
|
||||
(input) ->
|
||||
input.length
|
|
@ -0,0 +1,3 @@
|
|||
angular.module('ponyfm').filter 'momentFromNow', () ->
|
||||
(input) ->
|
||||
moment(input).fromNow()
|
4
resources/assets/scripts/app/filters/newlines.coffee
Normal file
4
resources/assets/scripts/app/filters/newlines.coffee
Normal file
|
@ -0,0 +1,4 @@
|
|||
angular.module('ponyfm').filter 'newlines', () ->
|
||||
(input) ->
|
||||
return '' if !input
|
||||
input.replace(/\n/g, '<br/>')
|
7
resources/assets/scripts/app/filters/noHTML.coffee
Normal file
7
resources/assets/scripts/app/filters/noHTML.coffee
Normal file
|
@ -0,0 +1,7 @@
|
|||
angular.module('ponyfm').filter 'noHTML', () ->
|
||||
(input) ->
|
||||
return '' if !input
|
||||
|
||||
input.replace(/&/g, '&')
|
||||
.replace(/>/g, '>')
|
||||
.replace(/</g, '<')
|
222
resources/assets/scripts/app/filters/pfm-date.js
Normal file
222
resources/assets/scripts/app/filters/pfm-date.js
Normal file
|
@ -0,0 +1,222 @@
|
|||
/*
|
||||
If you're wondering, this is indeed a copy/paste of angular's date filter with all of its internal dependencies.
|
||||
Why, you ask? Well, I needed to add lines 190 and 191, and didn't want to edit the source of angular itself.
|
||||
Now this filter supports dates returned directly from Carbon.
|
||||
*/
|
||||
|
||||
angular.module('ponyfm').filter('pfmdate', [
|
||||
'$locale',
|
||||
function($locale) {
|
||||
function isString(value){return typeof value == 'string';}
|
||||
function isNumber(value){return typeof value == 'number';}
|
||||
|
||||
function isDate(value){
|
||||
if (!value)
|
||||
return false;
|
||||
|
||||
return Object.prototype.toString.apply(value) == '[object Date]';
|
||||
}
|
||||
|
||||
function padNumber(num, digits, trim) {
|
||||
var neg = '';
|
||||
if (num < 0) {
|
||||
neg = '-';
|
||||
num = -num;
|
||||
}
|
||||
num = '' + num;
|
||||
while(num.length < digits) num = '0' + num;
|
||||
if (trim)
|
||||
num = num.substr(num.length - digits);
|
||||
return neg + num;
|
||||
}
|
||||
|
||||
function int(str) {
|
||||
return parseInt(str, 10);
|
||||
}
|
||||
|
||||
function concat(array1, array2, index) {
|
||||
return array1.concat([].slice.call(array2, index));
|
||||
}
|
||||
|
||||
function isArrayLike(obj) {
|
||||
if (!obj || (typeof obj.length !== 'number')) return false;
|
||||
|
||||
// We have on object which has length property. Should we treat it as array?
|
||||
if (typeof obj.hasOwnProperty != 'function' &&
|
||||
typeof obj.constructor != 'function') {
|
||||
// This is here for IE8: it is a bogus object treat it as array;
|
||||
return true;
|
||||
} else {
|
||||
return obj instanceof JQLite || // JQLite
|
||||
(jQuery && obj instanceof jQuery) || // jQuery
|
||||
toString.call(obj) !== '[object Object]' || // some browser native object
|
||||
typeof obj.callee === 'function'; // arguments (on IE8 looks like regular obj)
|
||||
}
|
||||
}
|
||||
|
||||
function isFunction(value){return typeof value == 'function';}
|
||||
|
||||
function forEach(obj, iterator, context) {
|
||||
var key;
|
||||
if (obj) {
|
||||
if (isFunction(obj)){
|
||||
for (key in obj) {
|
||||
if (key != 'prototype' && key != 'length' && key != 'name' && obj.hasOwnProperty(key)) {
|
||||
iterator.call(context, obj[key], key);
|
||||
}
|
||||
}
|
||||
} else if (obj.forEach && obj.forEach !== forEach) {
|
||||
obj.forEach(iterator, context);
|
||||
} else if (isArrayLike(obj)) {
|
||||
for (key = 0; key < obj.length; key++)
|
||||
iterator.call(context, obj[key], key);
|
||||
} else {
|
||||
for (key in obj) {
|
||||
if (obj.hasOwnProperty(key)) {
|
||||
iterator.call(context, obj[key], key);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
var uppercase = function(string){return isString(string) ? string.toUpperCase() : string;};
|
||||
|
||||
var DATE_FORMATS_SPLIT = /((?:[^yMdHhmsaZE']+)|(?:'(?:[^']|'')*')|(?:E+|y+|M+|d+|H+|h+|m+|s+|a|Z))(.*)/,
|
||||
NUMBER_STRING = /^\d+$/;
|
||||
|
||||
var DATE_FORMATS = {
|
||||
yyyy: dateGetter('FullYear', 4),
|
||||
yy: dateGetter('FullYear', 2, 0, true),
|
||||
y: dateGetter('FullYear', 1),
|
||||
MMMM: dateStrGetter('Month'),
|
||||
MMM: dateStrGetter('Month', true),
|
||||
MM: dateGetter('Month', 2, 1),
|
||||
M: dateGetter('Month', 1, 1),
|
||||
dd: dateGetter('Date', 2),
|
||||
d: dateGetter('Date', 1),
|
||||
HH: dateGetter('Hours', 2),
|
||||
H: dateGetter('Hours', 1),
|
||||
hh: dateGetter('Hours', 2, -12),
|
||||
h: dateGetter('Hours', 1, -12),
|
||||
mm: dateGetter('Minutes', 2),
|
||||
m: dateGetter('Minutes', 1),
|
||||
ss: dateGetter('Seconds', 2),
|
||||
s: dateGetter('Seconds', 1),
|
||||
// while ISO 8601 requires fractions to be prefixed with `.` or `,`
|
||||
// we can be just safely rely on using `sss` since we currently don't support single or two digit fractions
|
||||
sss: dateGetter('Milliseconds', 3),
|
||||
EEEE: dateStrGetter('Day'),
|
||||
EEE: dateStrGetter('Day', true),
|
||||
a: ampmGetter,
|
||||
Z: timeZoneGetter
|
||||
};
|
||||
|
||||
function dateGetter(name, size, offset, trim) {
|
||||
offset = offset || 0;
|
||||
return function(date) {
|
||||
var value = date['get' + name]();
|
||||
if (offset > 0 || value > -offset)
|
||||
value += offset;
|
||||
if (value === 0 && offset == -12 ) value = 12;
|
||||
return padNumber(value, size, trim);
|
||||
};
|
||||
}
|
||||
|
||||
function dateStrGetter(name, shortForm) {
|
||||
return function(date, formats) {
|
||||
var value = date['get' + name]();
|
||||
var get = uppercase(shortForm ? ('SHORT' + name) : name);
|
||||
|
||||
return formats[get][value];
|
||||
};
|
||||
}
|
||||
|
||||
function timeZoneGetter(date) {
|
||||
var zone = -1 * date.getTimezoneOffset();
|
||||
var paddedZone = (zone >= 0) ? "+" : "";
|
||||
|
||||
paddedZone += padNumber(Math[zone > 0 ? 'floor' : 'ceil'](zone / 60), 2) +
|
||||
padNumber(Math.abs(zone % 60), 2);
|
||||
|
||||
return paddedZone;
|
||||
}
|
||||
|
||||
function ampmGetter(date, formats) {
|
||||
return date.getHours() < 12 ? formats.AMPMS[0] : formats.AMPMS[1];
|
||||
}
|
||||
|
||||
var R_ISO8601_STR = /^(\d{4})-?(\d\d)-?(\d\d)(?:T(\d\d)(?::?(\d\d)(?::?(\d\d)(?:\.(\d+))?)?)?(Z|([+-])(\d\d):?(\d\d))?)?$/;
|
||||
function jsonStringToDate(string) {
|
||||
var match;
|
||||
if (match = string.match(R_ISO8601_STR)) {
|
||||
var date = new Date(0),
|
||||
tzHour = 0,
|
||||
tzMin = 0,
|
||||
dateSetter = match[8] ? date.setUTCFullYear : date.setFullYear,
|
||||
timeSetter = match[8] ? date.setUTCHours : date.setHours;
|
||||
|
||||
if (match[9]) {
|
||||
tzHour = int(match[9] + match[10]);
|
||||
tzMin = int(match[9] + match[11]);
|
||||
}
|
||||
dateSetter.call(date, int(match[1]), int(match[2]) - 1, int(match[3]));
|
||||
var h = int(match[4]||0) - tzHour;
|
||||
var m = int(match[5]||0) - tzMin;
|
||||
var s = int(match[6]||0);
|
||||
var ms = Math.round(parseFloat('0.' + (match[7]||0)) * 1000);
|
||||
timeSetter.call(date, h, m, s, ms);
|
||||
return date;
|
||||
}
|
||||
return string;
|
||||
}
|
||||
|
||||
|
||||
return function(date, format) {
|
||||
var text = '',
|
||||
parts = [],
|
||||
fn, match;
|
||||
|
||||
if (typeof(date) == 'object' && date.date) {
|
||||
date = date.date;
|
||||
}
|
||||
|
||||
format = format || 'mediumDate';
|
||||
format = $locale.DATETIME_FORMATS[format] || format;
|
||||
if (isString(date)) {
|
||||
if (NUMBER_STRING.test(date)) {
|
||||
date = int(date);
|
||||
} else {
|
||||
date = jsonStringToDate(date);
|
||||
}
|
||||
}
|
||||
|
||||
if (isNumber(date)) {
|
||||
date = new Date(date);
|
||||
}
|
||||
|
||||
if (!isDate(date)) {
|
||||
return date;
|
||||
}
|
||||
|
||||
while(format) {
|
||||
match = DATE_FORMATS_SPLIT.exec(format);
|
||||
if (match) {
|
||||
parts = concat(parts, match, 1);
|
||||
format = parts.pop();
|
||||
} else {
|
||||
parts.push(format);
|
||||
format = null;
|
||||
}
|
||||
}
|
||||
|
||||
forEach(parts, function(value){
|
||||
fn = DATE_FORMATS[value];
|
||||
text += fn ? fn(date, $locale.DATETIME_FORMATS)
|
||||
: value.replace(/(^'|'$)/g, '').replace(/''/g, "'");
|
||||
});
|
||||
|
||||
return text;
|
||||
};
|
||||
}]);
|
20
resources/assets/scripts/app/filters/seconds-display.coffee
Normal file
20
resources/assets/scripts/app/filters/seconds-display.coffee
Normal file
|
@ -0,0 +1,20 @@
|
|||
angular.module('ponyfm').filter 'secondsDisplay', () ->
|
||||
(input) ->
|
||||
sec_num = parseInt(input, 10)
|
||||
return '00:00' if !sec_num
|
||||
|
||||
hours = Math.floor(sec_num / 3600)
|
||||
minutes = Math.floor((sec_num - (hours * 3600)) / 60)
|
||||
seconds = sec_num - (hours * 3600) - (minutes * 60)
|
||||
|
||||
if (hours < 10)
|
||||
hours = "0" + hours
|
||||
if (minutes < 10)
|
||||
minutes = "0" + minutes
|
||||
if (seconds < 10)
|
||||
seconds = "0" + seconds
|
||||
|
||||
time = ''
|
||||
time += hours + ':' if hours != "00"
|
||||
time += minutes + ':' + seconds;
|
||||
return time;
|
7
resources/assets/scripts/app/filters/trust.coffee
Normal file
7
resources/assets/scripts/app/filters/trust.coffee
Normal file
|
@ -0,0 +1,7 @@
|
|||
angular.module('ponyfm').filter 'trust', [
|
||||
'$sce'
|
||||
($sce) ->
|
||||
(input) ->
|
||||
console.log input
|
||||
$sce.trustAsHtml input
|
||||
]
|
27
resources/assets/scripts/app/services/account-albums.coffee
Normal file
27
resources/assets/scripts/app/services/account-albums.coffee
Normal file
|
@ -0,0 +1,27 @@
|
|||
angular.module('ponyfm').factory('account-albums', [
|
||||
'$rootScope', '$http'
|
||||
($rootScope, $http) ->
|
||||
def = null
|
||||
albums = []
|
||||
|
||||
self =
|
||||
getEdit: (id, force) ->
|
||||
url = '/api/web/albums/edit/' + id
|
||||
force = force || false
|
||||
return albums[id] if !force && albums[id]
|
||||
|
||||
editDef = new $.Deferred()
|
||||
albums[id] = editDef
|
||||
$http.get(url).success (album) -> editDef.resolve album
|
||||
editDef.promise()
|
||||
|
||||
refresh: (force) ->
|
||||
force = force || false
|
||||
return def if !force && def
|
||||
def = new $.Deferred()
|
||||
$http.get('/api/web/albums/owned').success (ownedAlbums) ->
|
||||
def.resolve(ownedAlbums)
|
||||
def.promise()
|
||||
|
||||
self
|
||||
])
|
31
resources/assets/scripts/app/services/account-tracks.coffee
Normal file
31
resources/assets/scripts/app/services/account-tracks.coffee
Normal file
|
@ -0,0 +1,31 @@
|
|||
angular.module('ponyfm').factory('account-tracks', [
|
||||
'$rootScope', '$http'
|
||||
($rootScope, $http) ->
|
||||
cache = {}
|
||||
|
||||
self =
|
||||
clearCache: () -> cache = {}
|
||||
|
||||
getEdit: (id, force) ->
|
||||
url = '/api/web/tracks/edit/' + id
|
||||
force = force || false
|
||||
return cache[url] if !force && cache[url]
|
||||
|
||||
def = new $.Deferred()
|
||||
cache[url] = def
|
||||
$http.get(url).success (track) -> def.resolve track
|
||||
def.promise()
|
||||
|
||||
refresh: (query, force) ->
|
||||
query = query || 'created_at,desc'
|
||||
url = '/api/web/tracks/owned?' + query
|
||||
force = force || false
|
||||
return cache[url] if !force && cache[url]
|
||||
|
||||
def = new $.Deferred()
|
||||
cache[url] = def
|
||||
$http.get(url).success (tracks) -> def.resolve tracks
|
||||
def.promise()
|
||||
|
||||
self
|
||||
])
|
32
resources/assets/scripts/app/services/albums.coffee
Normal file
32
resources/assets/scripts/app/services/albums.coffee
Normal file
|
@ -0,0 +1,32 @@
|
|||
angular.module('ponyfm').factory('albums', [
|
||||
'$rootScope', '$http'
|
||||
($rootScope, $http) ->
|
||||
albumPages = []
|
||||
albums = {}
|
||||
|
||||
self =
|
||||
filters: {}
|
||||
|
||||
fetchList: (page, force) ->
|
||||
force = force || false
|
||||
page = 1 if !page
|
||||
return albumPages[page] if !force && albumPages[page]
|
||||
albumsDef = new $.Deferred()
|
||||
$http.get('/api/web/albums?page=' + page).success (albums) ->
|
||||
albumsDef.resolve albums
|
||||
$rootScope.$broadcast 'albums-feteched', albums
|
||||
|
||||
albumPages[page] = albumsDef.promise()
|
||||
|
||||
fetch: (id, force) ->
|
||||
force = force || false
|
||||
id = 1 if !id
|
||||
return albums[id] if !force && albums[id]
|
||||
albumsDef = new $.Deferred()
|
||||
$http.get('/api/web/albums/' + id + '?log=true').success (albums) ->
|
||||
albumsDef.resolve albums
|
||||
|
||||
albums[id] = albumsDef.promise()
|
||||
|
||||
self
|
||||
])
|
60
resources/assets/scripts/app/services/artists.coffee
Normal file
60
resources/assets/scripts/app/services/artists.coffee
Normal file
|
@ -0,0 +1,60 @@
|
|||
angular.module('ponyfm').factory('artists', [
|
||||
'$rootScope', '$http'
|
||||
($rootScope, $http) ->
|
||||
artistPage = []
|
||||
artists = {}
|
||||
artistContent = {}
|
||||
artistFavourites = {}
|
||||
|
||||
self =
|
||||
filters: {}
|
||||
|
||||
fetchList: (page, force) ->
|
||||
force = force || false
|
||||
page = 1 if !page
|
||||
return artistPage[page] if !force && artistPage[page]
|
||||
artistsDef = new $.Deferred()
|
||||
$http.get('/api/web/artists?page=' + page).success (albums) ->
|
||||
artistsDef.resolve albums
|
||||
$rootScope.$broadcast 'artists-feteched', albums
|
||||
|
||||
artistPage[page] = artistsDef.promise()
|
||||
|
||||
fetch: (slug, force) ->
|
||||
force = force || false
|
||||
slug = 1 if !slug
|
||||
return artists[slug] if !force && artists[slug]
|
||||
artistsDef = new $.Deferred()
|
||||
$http.get('/api/web/artists/' + slug)
|
||||
.success (albums) ->
|
||||
artistsDef.resolve albums
|
||||
.catch () ->
|
||||
artistsDef.reject()
|
||||
|
||||
artists[slug] = artistsDef.promise()
|
||||
|
||||
fetchContent: (slug, force) ->
|
||||
force = force || false
|
||||
slug = 1 if !slug
|
||||
return artistContent[slug] if !force && artistContent[slug]
|
||||
artistsDef = new $.Deferred()
|
||||
$http.get('/api/web/artists/' + slug + '/content')
|
||||
.success (albums) ->
|
||||
artistsDef.resolve albums
|
||||
.catch () ->
|
||||
artistsDef.reject()
|
||||
|
||||
artistContent[slug] = artistsDef.promise()
|
||||
|
||||
fetchFavourites: (slug, force) ->
|
||||
force = force || false
|
||||
slug = 1 if !slug
|
||||
return artistFavourites[slug] if !force && artistFavourites[slug]
|
||||
artistsDef = new $.Deferred()
|
||||
$http.get('/api/web/artists/' + slug + '/favourites').success (albums) ->
|
||||
artistsDef.resolve albums
|
||||
|
||||
artistFavourites[slug] = artistsDef.promise()
|
||||
|
||||
self
|
||||
])
|
18
resources/assets/scripts/app/services/auth.coffee
Normal file
18
resources/assets/scripts/app/services/auth.coffee
Normal file
|
@ -0,0 +1,18 @@
|
|||
angular.module('ponyfm').factory('auth', [
|
||||
'$rootScope'
|
||||
($rootScope) ->
|
||||
data: {isLogged: window.pfm.auth.isLogged, user: window.pfm.auth.user}
|
||||
login: (email, password, remember) ->
|
||||
def = new $.Deferred()
|
||||
$.post('/api/web/auth/login', {email: email, password: password, remember: remember, _token: pfm.token})
|
||||
.done ->
|
||||
$rootScope.$apply -> def.resolve()
|
||||
|
||||
.fail (res) ->
|
||||
$rootScope.$apply -> def.reject res.responseJSON.messages
|
||||
|
||||
def.promise()
|
||||
|
||||
logout: -> $.post('/api/web/auth/logout', {_token: pfm.token})
|
||||
])
|
||||
|
27
resources/assets/scripts/app/services/comments.coffee
Normal file
27
resources/assets/scripts/app/services/comments.coffee
Normal file
|
@ -0,0 +1,27 @@
|
|||
angular.module('ponyfm').factory('comments', [
|
||||
'$rootScope', '$http'
|
||||
($rootScope, $http) ->
|
||||
commentCache = []
|
||||
|
||||
self =
|
||||
filters: {}
|
||||
|
||||
addComment: (resourceType, resourceId, content) ->
|
||||
commentDef = new $.Deferred()
|
||||
$http.post('/api/web/comments/' + resourceType + '/' + resourceId, {content: content, _token: pfm.token}).success (comment) ->
|
||||
commentDef.resolve comment
|
||||
|
||||
commentDef.promise()
|
||||
|
||||
fetchList: (resourceType, resourceId, force) ->
|
||||
key = resourceType + '-' + resourceId
|
||||
force = force || false
|
||||
return commentCache[key] if !force && commentCache[key]
|
||||
commentDef = new $.Deferred()
|
||||
$http.get('/api/web/comments/' + resourceType + '/' + resourceId).success (comments) ->
|
||||
commentDef.resolve comments
|
||||
|
||||
commentCache[key] = commentDef.promise()
|
||||
|
||||
self
|
||||
])
|
16
resources/assets/scripts/app/services/dashboard.coffee
Normal file
16
resources/assets/scripts/app/services/dashboard.coffee
Normal file
|
@ -0,0 +1,16 @@
|
|||
angular.module('ponyfm').factory('dashboard', [
|
||||
'$rootScope', '$http'
|
||||
($rootScope, $http) ->
|
||||
def = null
|
||||
|
||||
self =
|
||||
refresh: (force) ->
|
||||
force = force || false
|
||||
return def if !force && def
|
||||
def = new $.Deferred()
|
||||
$http.get('/api/web/dashboard').success (dashboardContent) ->
|
||||
def.resolve(dashboardContent)
|
||||
def.promise()
|
||||
|
||||
self
|
||||
])
|
41
resources/assets/scripts/app/services/favourites.coffee
Normal file
41
resources/assets/scripts/app/services/favourites.coffee
Normal file
|
@ -0,0 +1,41 @@
|
|||
angular.module('ponyfm').factory('favourites', [
|
||||
'$rootScope', '$http'
|
||||
($rootScope, $http) ->
|
||||
tracksDef = null
|
||||
playlistsDef = null
|
||||
albumsDef = null
|
||||
|
||||
self =
|
||||
toggle: (type, id) ->
|
||||
def = new $.Deferred()
|
||||
$http.post('/api/web/favourites/toggle', {type: type, id: id, _token: pfm.token}).success (res) ->
|
||||
def.resolve res
|
||||
|
||||
def.promise()
|
||||
|
||||
fetchTracks: (force) ->
|
||||
return tracksDef if !force && tracksDef
|
||||
tracksDef = new $.Deferred()
|
||||
$http.get('/api/web/favourites/tracks').success (res) ->
|
||||
tracksDef.resolve res
|
||||
|
||||
tracksDef
|
||||
|
||||
fetchAlbums: (force) ->
|
||||
return albumsDef if !force && albumsDef
|
||||
albumsDef = new $.Deferred()
|
||||
$http.get('/api/web/favourites/albums').success (res) ->
|
||||
albumsDef.resolve res
|
||||
|
||||
albumsDef
|
||||
|
||||
fetchPlaylists: (force) ->
|
||||
return playlistsDef if !force && playlistsDef
|
||||
playlistsDef = new $.Deferred()
|
||||
$http.get('/api/web/favourites/playlists').success (res) ->
|
||||
playlistsDef.resolve res
|
||||
|
||||
playlistsDef
|
||||
|
||||
self
|
||||
])
|
13
resources/assets/scripts/app/services/follow.coffee
Normal file
13
resources/assets/scripts/app/services/follow.coffee
Normal file
|
@ -0,0 +1,13 @@
|
|||
angular.module('ponyfm').factory('follow', [
|
||||
'$rootScope', '$http'
|
||||
($rootScope, $http) ->
|
||||
self =
|
||||
toggle: (type, id) ->
|
||||
def = new $.Deferred()
|
||||
$http.post('/api/web/follow/toggle', {type: type, id: id, _token: pfm.token}).success (res) ->
|
||||
def.resolve res
|
||||
|
||||
def.promise()
|
||||
|
||||
self
|
||||
])
|
25
resources/assets/scripts/app/services/images.coffee
Normal file
25
resources/assets/scripts/app/services/images.coffee
Normal file
|
@ -0,0 +1,25 @@
|
|||
angular.module('ponyfm').factory('images', [
|
||||
'$rootScope'
|
||||
($rootScope) ->
|
||||
def = null
|
||||
self =
|
||||
images: []
|
||||
isLoading: true
|
||||
refresh: (force) ->
|
||||
return def if !force && def
|
||||
def = new $.Deferred()
|
||||
|
||||
self.images = []
|
||||
self.isLoading = true
|
||||
|
||||
$.getJSON('/api/web/images/owned').done (images) -> $rootScope.$apply ->
|
||||
self.images = images
|
||||
self.isLoading = false
|
||||
def.resolve images
|
||||
|
||||
return def
|
||||
|
||||
self.refresh()
|
||||
return self
|
||||
])
|
||||
|
13
resources/assets/scripts/app/services/lightbox.coffee
Normal file
13
resources/assets/scripts/app/services/lightbox.coffee
Normal file
|
@ -0,0 +1,13 @@
|
|||
angular.module('ponyfm').factory('lightbox', [
|
||||
() ->
|
||||
openDataUrl: (src) ->
|
||||
$.colorbox
|
||||
html: '<img src="' + src + '" />'
|
||||
transition: 'none'
|
||||
|
||||
openImageUrl: (src) ->
|
||||
$.colorbox
|
||||
href: src
|
||||
transition: 'none'
|
||||
])
|
||||
|
142
resources/assets/scripts/app/services/player.coffee
Normal file
142
resources/assets/scripts/app/services/player.coffee
Normal file
|
@ -0,0 +1,142 @@
|
|||
angular.module('ponyfm').factory('player', [
|
||||
'$rootScope'
|
||||
($rootScope) ->
|
||||
readyDef = new $.Deferred()
|
||||
|
||||
play = (track) ->
|
||||
self.currentTrack = track
|
||||
$rootScope.$broadcast 'player-starting-track', track
|
||||
|
||||
streams = []
|
||||
streams.push track.streams.mp3
|
||||
streams.push track.streams.ogg if track.streams.ogg
|
||||
streams.push track.streams.aac if track.streams.aac
|
||||
|
||||
track.progress = 0
|
||||
track.progressSeconds = 0
|
||||
track.loadingProgress = 0
|
||||
|
||||
self.currentSound = soundManager.createSound
|
||||
url: streams,
|
||||
volume: self.volume
|
||||
|
||||
whileloading: () -> $rootScope.safeApply ->
|
||||
track.loadingProgress = (self.currentSound.bytesLoaded / self.currentSound.bytesTotal) * 100
|
||||
|
||||
whileplaying: () -> $rootScope.safeApply ->
|
||||
track.progressSeconds = self.currentSound.position / 1000
|
||||
track.progress = (self.currentSound.position / (track.duration * 1000)) * 100
|
||||
|
||||
onfinish: () -> $rootScope.safeApply ->
|
||||
track.isPlaying = false
|
||||
self.playNext()
|
||||
|
||||
onstop: () -> $rootScope.safeApply ->
|
||||
track.isPlaying = false
|
||||
self.isPlaying = false
|
||||
|
||||
onplay: () -> $rootScope.safeApply ->
|
||||
track.isPlaying = true
|
||||
|
||||
onresume: () -> $rootScope.safeApply ->
|
||||
track.isPlaying = true
|
||||
|
||||
onpause: () -> $rootScope.safeApply ->
|
||||
track.isPlaying = false
|
||||
|
||||
track.isPlaying = true
|
||||
self.isPlaying = true
|
||||
self.currentSound.play()
|
||||
|
||||
updateCanGo = () ->
|
||||
self.canGoNext = self.playlistIndex < self.playlist.length - 1
|
||||
self.canGoPrev = self.playlistIndex > 0
|
||||
|
||||
self =
|
||||
ready: false
|
||||
isPlaying: false
|
||||
currentTrack: null
|
||||
currentSound: null
|
||||
playlist: []
|
||||
playlistIndex: 0
|
||||
volume: 0
|
||||
readyDef: readyDef.promise()
|
||||
canGoPrev: false
|
||||
canGoNext: false
|
||||
|
||||
playPause: () ->
|
||||
return if !self.ready
|
||||
return if !self.isPlaying
|
||||
|
||||
if self.currentSound.paused
|
||||
self.currentSound.play()
|
||||
else
|
||||
self.currentSound.pause()
|
||||
|
||||
playNext: () ->
|
||||
return if !self.canGoNext
|
||||
|
||||
self.currentSound.stop() if self.currentSound != null
|
||||
self.playlistIndex++
|
||||
if self.playlistIndex >= self.playlist.length
|
||||
self.playlist.length = 0
|
||||
self.currentTrack = null
|
||||
self.currentSong = null
|
||||
self.isPlaying = false
|
||||
return
|
||||
|
||||
play self.playlist[self.playlistIndex]
|
||||
updateCanGo()
|
||||
|
||||
playPrev: () ->
|
||||
return if !self.canGoPrev
|
||||
|
||||
self.currentSound.stop() if self.currentSound != null
|
||||
self.playlistIndex--
|
||||
|
||||
if self.playlistIndex < 0
|
||||
self.playlist.length = 0
|
||||
self.currentTrack = null
|
||||
self.currentSong = null
|
||||
self.isPlaying = false
|
||||
return
|
||||
|
||||
play self.playlist[self.playlistIndex]
|
||||
updateCanGo()
|
||||
|
||||
seek: (progress) ->
|
||||
return if !self.currentSound
|
||||
self.currentSound.setPosition(progress)
|
||||
|
||||
setVolume: (theVolume) ->
|
||||
theVolume = 100 if theVolume > 100
|
||||
self.currentSound.setVolume(theVolume) if self.currentSound
|
||||
$.cookie('pfm-volume', theVolume)
|
||||
self.volume = theVolume
|
||||
|
||||
playTracks: (tracks, index) ->
|
||||
return if !self.ready
|
||||
return if tracks.length == 0
|
||||
|
||||
if tracks[index].isPlaying
|
||||
self.playPause()
|
||||
return
|
||||
|
||||
self.currentSound.stop() if self.currentSound != null
|
||||
|
||||
$rootScope.$broadcast 'player-stopping-playlist'
|
||||
self.playlist.length = 0
|
||||
self.playlist.push track for track in tracks
|
||||
self.playlistIndex = index
|
||||
|
||||
$rootScope.$broadcast 'player-starting-playlist', tracks
|
||||
play tracks[index]
|
||||
updateCanGo()
|
||||
|
||||
pfm.soundManager.done () ->
|
||||
self.ready = true
|
||||
self.setVolume($.cookie('pfm-volume') || 100)
|
||||
readyDef.resolve()
|
||||
|
||||
self
|
||||
])
|
133
resources/assets/scripts/app/services/playlists.coffee
Normal file
133
resources/assets/scripts/app/services/playlists.coffee
Normal file
|
@ -0,0 +1,133 @@
|
|||
angular.module('ponyfm').factory('playlists', [
|
||||
'$rootScope', '$state', '$http', 'auth'
|
||||
($rootScope, $state, $http, auth) ->
|
||||
playlistDef = null
|
||||
playlists = {}
|
||||
playlistPages = []
|
||||
|
||||
self =
|
||||
pinnedPlaylists: []
|
||||
|
||||
fetchList: (page, force) ->
|
||||
force = force || false
|
||||
page = 1 if !page
|
||||
return playlistPages[page] if !force && playlistPages[page]
|
||||
playlistDef = new $.Deferred()
|
||||
$http.get('/api/web/playlists?page=' + page).success (playlists) ->
|
||||
playlistDef.resolve playlists
|
||||
$rootScope.$broadcast 'playlists-feteched', playlists
|
||||
|
||||
playlistPages[page] = playlistDef.promise()
|
||||
|
||||
fetch: (id, force) ->
|
||||
force = force || false
|
||||
return playlists[id] if !force && playlists[id]
|
||||
def = new $.Deferred()
|
||||
$http.get('/api/web/playlists/' + id + '?log=true').success (playlist) ->
|
||||
def.resolve playlist
|
||||
|
||||
playlists[id] = def.promise()
|
||||
|
||||
isPlaylistPinned: (id) ->
|
||||
_.find(self.pinnedPlaylists, (p) -> `p.id == id`) != undefined
|
||||
|
||||
refreshOwned: (force) ->
|
||||
force = force || false
|
||||
return playlistDef if !force && playlistDef
|
||||
|
||||
playlistDef = new $.Deferred()
|
||||
|
||||
if auth.data.isLogged
|
||||
$http.get('/api/web/playlists/owned').success (playlists) ->
|
||||
playlistDef.resolve playlists
|
||||
else
|
||||
playlistDef.resolve []
|
||||
|
||||
playlistDef
|
||||
|
||||
addTrackToPlaylist: (playlistId, trackId) ->
|
||||
def = new $.Deferred()
|
||||
$http.post('/api/web/playlists/' + playlistId + '/add-track', {track_id: trackId, _token: pfm.token}).success (res) ->
|
||||
def.resolve(res)
|
||||
|
||||
def
|
||||
|
||||
refresh: () ->
|
||||
if auth.data.isLogged
|
||||
$.getJSON('/api/web/playlists/pinned')
|
||||
.done (playlists) -> $rootScope.$apply ->
|
||||
self.pinnedPlaylists.length = 0
|
||||
self.pinnedPlaylists.push playlist for playlist in playlists
|
||||
|
||||
deletePlaylist: (playlist) ->
|
||||
def = new $.Deferred()
|
||||
$.post('/api/web/playlists/delete/' + playlist.id, {_token: window.pfm.token})
|
||||
.then -> $rootScope.$apply ->
|
||||
if _.some(self.pinnedPlaylists, (p) -> p.id == playlist.id)
|
||||
currentIndex = _.indexOf(self.pinnedPlaylists, (t) -> t.id == playlist.id)
|
||||
self.pinnedPlaylists.splice currentIndex, 1
|
||||
|
||||
if $state.is('playlist') && $state.params.id == playlist.id
|
||||
$state.transitionTo 'home'
|
||||
|
||||
def.resolve()
|
||||
|
||||
def
|
||||
|
||||
editPlaylist: (playlist) ->
|
||||
def = new $.Deferred()
|
||||
playlist._token = pfm.token
|
||||
$.post('/api/web/playlists/edit/' + playlist.id, playlist)
|
||||
.done (res) ->
|
||||
$rootScope.$apply ->
|
||||
currentIndex = _.indexOf(self.pinnedPlaylists, (t) -> t.id == playlist.id)
|
||||
isPinned = _.some(self.pinnedPlaylists, (p) -> p.id == playlist.id)
|
||||
|
||||
if res.is_pinned && !isPinned
|
||||
self.pinnedPlaylists.push res
|
||||
self.pinnedPlaylists.sort (left, right) -> left.title.localeCompare right.title
|
||||
currentIndex = _.indexOf(self.pinnedPlaylists, (t) -> t.id == playlist.id)
|
||||
else if !res.is_pinned && isPinned
|
||||
self.pinnedPlaylists.splice currentIndex, 1
|
||||
currentIndex = _.indexOf(self.pinnedPlaylists, (t) -> t.id == playlist.id)
|
||||
|
||||
if res.is_pinned
|
||||
current = self.pinnedPlaylists[currentIndex]
|
||||
_.forEach res, (value, name) -> current[name] = value
|
||||
self.pinnedPlaylists.sort (left, right) -> left.title.localeCompare right.title
|
||||
|
||||
def.resolve res
|
||||
$rootScope.$broadcast 'playlist-updated', res
|
||||
|
||||
.fail (res)->
|
||||
$rootScope.$apply ->
|
||||
errors = {}
|
||||
_.each res.responseJSON.errors, (value, key) -> errors[key] = value.join ', '
|
||||
def.reject errors
|
||||
|
||||
def
|
||||
|
||||
createPlaylist: (playlist) ->
|
||||
def = new $.Deferred()
|
||||
playlist._token = pfm.token
|
||||
$.post('/api/web/playlists/create', playlist)
|
||||
.done (res) ->
|
||||
$rootScope.$apply ->
|
||||
if res.is_pinned
|
||||
self.pinnedPlaylists.push res
|
||||
self.pinnedPlaylists.sort (left, right) -> left.title.localeCompare right.title
|
||||
|
||||
def.resolve res
|
||||
|
||||
.fail (res)->
|
||||
$rootScope.$apply ->
|
||||
errors = {}
|
||||
_.each res.responseJSON.errors, (value, key) -> errors[key] = value.join ', '
|
||||
def.reject errors
|
||||
|
||||
def
|
||||
|
||||
self.refresh()
|
||||
self
|
||||
])
|
||||
|
38
resources/assets/scripts/app/services/taxonomies.coffee
Normal file
38
resources/assets/scripts/app/services/taxonomies.coffee
Normal file
|
@ -0,0 +1,38 @@
|
|||
angular.module('ponyfm').factory('taxonomies', [
|
||||
'$rootScope', '$http'
|
||||
($rootScope, $http) ->
|
||||
def = null
|
||||
|
||||
self =
|
||||
trackTypes: []
|
||||
trackTypesWithTracks: []
|
||||
licenses: []
|
||||
genres: []
|
||||
genresWithTracks: []
|
||||
showSongs: []
|
||||
showSongsWithTracks: []
|
||||
refresh: () ->
|
||||
return def.promise() if def != null
|
||||
|
||||
def = new $.Deferred()
|
||||
$http.get('/api/web/taxonomies/all')
|
||||
.success (taxonomies) ->
|
||||
for t in taxonomies.track_types
|
||||
self.trackTypes.push t
|
||||
self.trackTypesWithTracks.push t if t.track_count > 0
|
||||
|
||||
for t in taxonomies.genres
|
||||
self.genres.push t
|
||||
self.genresWithTracks.push t if t.track_count > 0
|
||||
|
||||
for t in taxonomies.show_songs
|
||||
self.showSongs.push t
|
||||
self.showSongsWithTracks.push t if t.track_count > 0
|
||||
|
||||
self.licenses.push t for t in taxonomies.licenses
|
||||
def.resolve self
|
||||
|
||||
def.promise()
|
||||
|
||||
self
|
||||
])
|
229
resources/assets/scripts/app/services/tracks.coffee
Normal file
229
resources/assets/scripts/app/services/tracks.coffee
Normal file
|
@ -0,0 +1,229 @@
|
|||
angular.module('ponyfm').factory('tracks', [
|
||||
'$rootScope', '$http', 'taxonomies'
|
||||
($rootScope, $http, taxonomies) ->
|
||||
filterDef = null
|
||||
trackCache = {}
|
||||
|
||||
class Query
|
||||
cachedDef: null
|
||||
page: 1
|
||||
listeners: []
|
||||
|
||||
constructor: (@availableFilters) ->
|
||||
@filters = {}
|
||||
@hasLoadedFilters = false
|
||||
@resetFilters()
|
||||
|
||||
resetFilters: ->
|
||||
_.each @availableFilters, (filter, name) =>
|
||||
if filter.type == 'single'
|
||||
@filters[name] = _.find filter.values, (f) -> f.isDefault
|
||||
else
|
||||
@filters[name] = {title: 'Any', selectedArray: [], selectedObject: {}}
|
||||
|
||||
isIdSelected: (type, id) ->
|
||||
@filters[type].selectedObject[id] != undefined
|
||||
|
||||
listen: (listener) ->
|
||||
@listeners.push listener
|
||||
@cachedDef.done listener if @cachedDef
|
||||
|
||||
setListFilter: (type, id) ->
|
||||
@cachedDef = null
|
||||
@page = 1
|
||||
filterToAdd = _.find @availableFilters[type].values, (f) -> `f.id == id`
|
||||
return if !filterToAdd
|
||||
|
||||
filter = @filters[type]
|
||||
filter.selectedArray = [filterToAdd]
|
||||
filter.selectedObject = {}
|
||||
filter.selectedObject[id] = filterToAdd
|
||||
filter.title = filterToAdd.title
|
||||
|
||||
clearFilter: (type) ->
|
||||
@cachedDef = null
|
||||
@page = 1
|
||||
filter = @availableFilters[type]
|
||||
|
||||
if filter.type == 'single'
|
||||
@filters[type] = _.find filter.values, (f) -> f.isDefault
|
||||
else
|
||||
currentFilter = @filters[type]
|
||||
currentFilter.selectedArray = []
|
||||
currentFilter.selectedObject = {}
|
||||
currentFilter.title = 'Any'
|
||||
|
||||
toggleListFilter: (type, id) ->
|
||||
@cachedDef = null
|
||||
@page = 1
|
||||
filter = @filters[type]
|
||||
|
||||
if filter.selectedObject[id]
|
||||
delete filter.selectedObject[id]
|
||||
filter.selectedArray.splice _.indexOf(filter.selectedArray, (f) -> f.id == id), 1
|
||||
else
|
||||
filterToAdd = _.find @availableFilters[type].values, (f) -> `f.id == id`
|
||||
return if !filterToAdd
|
||||
filter.selectedObject[id] = filterToAdd
|
||||
filter.selectedArray.push filterToAdd
|
||||
|
||||
if filter.selectedArray.length == 0
|
||||
filter.title = 'Any'
|
||||
else if filter.selectedArray.length == 1
|
||||
filter.title = filter.selectedArray[0].title
|
||||
else
|
||||
filter.title = filter.selectedArray.length + ' selected'
|
||||
|
||||
setPage: (page) ->
|
||||
@page = page
|
||||
@cachedDef = null
|
||||
|
||||
setFilter: (type, value) ->
|
||||
@cachedDef = null
|
||||
@page = 1
|
||||
@filters[type] = value
|
||||
|
||||
toFilterString: ->
|
||||
parts = []
|
||||
_.each @availableFilters, (filter, name) =>
|
||||
filterName = filter.name
|
||||
if filter.type == 'single'
|
||||
return if @filters[name].query == ''
|
||||
parts.push(filterName + '-' + @filters[name].query)
|
||||
else
|
||||
return if @filters[name].selectedArray.length == 0
|
||||
parts.push(filterName + '-' + _.map(@filters[name].selectedArray, (f) -> f.id).join '-')
|
||||
|
||||
return parts.join '!'
|
||||
|
||||
fromFilterString: (str) ->
|
||||
@hasLoadedFilters = true
|
||||
@cachedDef = null
|
||||
@resetFilters()
|
||||
|
||||
filters = (str || "").split '!'
|
||||
for queryFilter in filters
|
||||
parts = queryFilter.split '-'
|
||||
queryName = parts[0]
|
||||
|
||||
filterName = null
|
||||
filter = null
|
||||
|
||||
for name,f of @availableFilters
|
||||
continue if f.name != queryName
|
||||
filterName = name
|
||||
filter = f
|
||||
|
||||
return if !filter
|
||||
|
||||
if filter.type == 'single'
|
||||
filterToSet = _.find filter.values, (f) -> f.query == parts[1]
|
||||
filterToSet = (_.find filter.values, (f) -> f.isDefault) if filterToSet == null
|
||||
@setFilter filterName, filterToSet
|
||||
else
|
||||
@toggleListFilter filterName, id for id in _.rest parts, 1
|
||||
|
||||
fetch: () ->
|
||||
return @cachedDef if @cachedDef
|
||||
@cachedDef = new $.Deferred()
|
||||
trackDef = @cachedDef
|
||||
|
||||
query = '/api/web/tracks?'
|
||||
parts = ['page=' + @page]
|
||||
_.each @availableFilters, (filter, name) =>
|
||||
if filter.type == 'single'
|
||||
parts.push @filters[name].filter
|
||||
else
|
||||
queryName = filter.filterName
|
||||
for item in @filters[name].selectedArray
|
||||
parts.push queryName + "[]=" + item.id
|
||||
|
||||
query += parts.join '&'
|
||||
$http.get(query).success (tracks) =>
|
||||
@tracks = tracks
|
||||
for listener in @listeners
|
||||
listener tracks
|
||||
|
||||
|
||||
trackDef.resolve tracks
|
||||
|
||||
trackDef.promise()
|
||||
|
||||
self =
|
||||
filters: {}
|
||||
|
||||
fetch: (id, force) ->
|
||||
force = force || false
|
||||
return trackCache[id] if !force && trackCache[id]
|
||||
trackDef = new $.Deferred()
|
||||
$http.get('/api/web/tracks/' + id + '?log=true').success (track) ->
|
||||
trackDef.resolve track
|
||||
|
||||
trackCache[id] = trackDef.promise()
|
||||
|
||||
createQuery: -> new Query self.filters
|
||||
|
||||
loadFilters: ->
|
||||
return filterDef if filterDef
|
||||
|
||||
filterDef = new $.Deferred()
|
||||
self.filters.isVocal =
|
||||
type: 'single'
|
||||
name: 'vocal'
|
||||
values: [
|
||||
{title: 'Either', query: '', isDefault: true, filter: ''},
|
||||
{title: 'Yes', query: 'yes', isDefault: false, filter: 'is_vocal=true'},
|
||||
{title: 'No', query: 'no', isDefault: false, filter: 'is_vocal=false'}
|
||||
]
|
||||
|
||||
self.filters.sort =
|
||||
type: 'single'
|
||||
name: 'sort'
|
||||
values: [
|
||||
{title: 'Latest', query: '', isDefault: true, filter: 'order=created_at,desc'},
|
||||
{title: 'Most Played', query: 'plays', isDefault: false, filter: 'order=play_count,desc'},
|
||||
{title: 'Most Downloaded', query: 'downloads', isDefault: false, filter: 'order=download_count,desc'},
|
||||
{title: 'Most Favourited', query: 'favourites', isDefault: false, filter: 'order=favourite_count,desc'}
|
||||
]
|
||||
|
||||
self.filters.genres =
|
||||
type: 'list'
|
||||
name: 'genres'
|
||||
values: []
|
||||
filterName: 'genres'
|
||||
|
||||
self.filters.trackTypes =
|
||||
type: 'list'
|
||||
name: 'types'
|
||||
values: []
|
||||
filterName: 'types'
|
||||
|
||||
self.filters.showSongs =
|
||||
type: 'list'
|
||||
name: 'songs'
|
||||
values: []
|
||||
filterName: 'songs'
|
||||
|
||||
taxonomies.refresh().done (taxes) ->
|
||||
for genre in taxes.genresWithTracks
|
||||
self.filters.genres.values.push
|
||||
title: genre.name
|
||||
id: genre.id
|
||||
|
||||
for type in taxes.trackTypesWithTracks
|
||||
self.filters.trackTypes.values.push
|
||||
title: type.title
|
||||
id: type.id
|
||||
|
||||
for song in taxes.showSongsWithTracks
|
||||
self.filters.showSongs.values.push
|
||||
title: song.title
|
||||
id: song.id
|
||||
|
||||
self.mainQuery = self.createQuery()
|
||||
filterDef.resolve self
|
||||
|
||||
filterDef.promise()
|
||||
|
||||
self
|
||||
])
|
51
resources/assets/scripts/app/services/upload.coffee
Normal file
51
resources/assets/scripts/app/services/upload.coffee
Normal file
|
@ -0,0 +1,51 @@
|
|||
angular.module('ponyfm').factory('upload', [
|
||||
'$rootScope'
|
||||
($rootScope) ->
|
||||
self =
|
||||
queue: []
|
||||
|
||||
upload: (files) ->
|
||||
_.each files, (file) ->
|
||||
upload =
|
||||
name: file.name
|
||||
progress: 0
|
||||
uploadedSize: 0
|
||||
size: file.size
|
||||
index: self.queue.length
|
||||
isUploading: true
|
||||
success: false
|
||||
error: null
|
||||
|
||||
self.queue.push upload
|
||||
$rootScope.$broadcast 'upload-added', upload
|
||||
|
||||
xhr = new XMLHttpRequest()
|
||||
xhr.upload.onprogress = (e) ->
|
||||
$rootScope.$apply ->
|
||||
upload.uploadedSize = e.loaded
|
||||
upload.progress = e.loaded / upload.size * 100
|
||||
$rootScope.$broadcast 'upload-progress', upload
|
||||
|
||||
xhr.onload = -> $rootScope.$apply ->
|
||||
upload.isUploading = false
|
||||
if xhr.status != 200
|
||||
error =
|
||||
if xhr.getResponseHeader('content-type') == 'application/json'
|
||||
$.parseJSON(xhr.responseText).errors.track.join ', '
|
||||
else
|
||||
'There was an unknown error!'
|
||||
|
||||
upload.error = error
|
||||
$rootScope.$broadcast 'upload-error', [upload, error]
|
||||
else
|
||||
upload.success = true
|
||||
upload.trackId = $.parseJSON(xhr.responseText).id
|
||||
|
||||
$rootScope.$broadcast 'upload-finished', upload
|
||||
formData = new FormData();
|
||||
formData.append('track', file);
|
||||
|
||||
xhr.open 'POST', '/api/web/tracks/upload', true
|
||||
xhr.setRequestHeader 'X-Token', pfm.token
|
||||
xhr.send formData
|
||||
])
|
121
resources/assets/scripts/base/angular-ui-date.js
vendored
Normal file
121
resources/assets/scripts/base/angular-ui-date.js
vendored
Normal file
|
@ -0,0 +1,121 @@
|
|||
/*global angular */
|
||||
/*
|
||||
jQuery UI Datepicker plugin wrapper
|
||||
|
||||
@note If ≤ IE8 make sure you have a polyfill for Date.toISOString()
|
||||
@param [ui-date] {object} Options to pass to $.fn.datepicker() merged onto uiDateConfig
|
||||
*/
|
||||
|
||||
angular.module('ui.date', [])
|
||||
|
||||
.constant('uiDateConfig', {})
|
||||
|
||||
.directive('uiDate', ['uiDateConfig', '$timeout', function (uiDateConfig, $timeout) {
|
||||
'use strict';
|
||||
var options;
|
||||
options = {};
|
||||
angular.extend(options, uiDateConfig);
|
||||
return {
|
||||
require:'?ngModel',
|
||||
link:function (scope, element, attrs, controller) {
|
||||
var getOptions = function () {
|
||||
return angular.extend({}, uiDateConfig, scope.$eval(attrs.uiDate));
|
||||
};
|
||||
var initDateWidget = function () {
|
||||
var showing = false;
|
||||
var opts = getOptions();
|
||||
|
||||
// If we have a controller (i.e. ngModelController) then wire it up
|
||||
if (controller) {
|
||||
|
||||
// Set the view value in a $apply block when users selects
|
||||
// (calling directive user's function too if provided)
|
||||
var _onSelect = opts.onSelect || angular.noop;
|
||||
opts.onSelect = function (value, picker) {
|
||||
scope.$apply(function() {
|
||||
showing = true;
|
||||
controller.$setViewValue(element.datepicker("getDate"));
|
||||
_onSelect(value, picker);
|
||||
element.blur();
|
||||
});
|
||||
};
|
||||
opts.beforeShow = function() {
|
||||
showing = true;
|
||||
};
|
||||
opts.onClose = function(value, picker) {
|
||||
showing = false;
|
||||
};
|
||||
element.on('blur', function() {
|
||||
if ( !showing ) {
|
||||
scope.$apply(function() {
|
||||
element.datepicker("setDate", element.datepicker("getDate"));
|
||||
controller.$setViewValue(element.datepicker("getDate"));
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Update the date picker when the model changes
|
||||
controller.$render = function () {
|
||||
var date = controller.$viewValue;
|
||||
if ( angular.isDefined(date) && date !== null && !angular.isDate(date) ) {
|
||||
throw new Error('ng-Model value must be a Date object - currently it is a ' + typeof date + ' - use ui-date-format to convert it from a string');
|
||||
}
|
||||
element.datepicker("setDate", date);
|
||||
};
|
||||
}
|
||||
// If we don't destroy the old one it doesn't update properly when the config changes
|
||||
element.datepicker('destroy');
|
||||
// Create the new datepicker widget
|
||||
element.datepicker(opts);
|
||||
if ( controller ) {
|
||||
// Force a render to override whatever is in the input text box
|
||||
controller.$render();
|
||||
}
|
||||
};
|
||||
// Watch for changes to the directives options
|
||||
scope.$watch(getOptions, initDateWidget, true);
|
||||
}
|
||||
};
|
||||
}
|
||||
])
|
||||
|
||||
.constant('uiDateFormatConfig', '')
|
||||
|
||||
.directive('uiDateFormat', ['uiDateFormatConfig', function(uiDateFormatConfig) {
|
||||
var directive = {
|
||||
require:'ngModel',
|
||||
link: function(scope, element, attrs, modelCtrl) {
|
||||
var dateFormat = attrs.uiDateFormat || uiDateFormatConfig;
|
||||
if ( dateFormat ) {
|
||||
// Use the datepicker with the attribute value as the dateFormat string to convert to and from a string
|
||||
modelCtrl.$formatters.push(function(value) {
|
||||
if (angular.isString(value) ) {
|
||||
return jQuery.datepicker.parseDate(dateFormat, value);
|
||||
}
|
||||
return null;
|
||||
});
|
||||
modelCtrl.$parsers.push(function(value){
|
||||
if (value) {
|
||||
return jQuery.datepicker.formatDate(dateFormat, value);
|
||||
}
|
||||
return null;
|
||||
});
|
||||
} else {
|
||||
// Default to ISO formatting
|
||||
modelCtrl.$formatters.push(function(value) {
|
||||
if (angular.isString(value) ) {
|
||||
return new Date(value);
|
||||
}
|
||||
return null;
|
||||
});
|
||||
modelCtrl.$parsers.push(function(value){
|
||||
if (value) {
|
||||
return value.toISOString();
|
||||
}
|
||||
return null;
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
return directive;
|
||||
}]);
|
1037
resources/assets/scripts/base/angular-ui-router.js
vendored
Normal file
1037
resources/assets/scripts/base/angular-ui-router.js
vendored
Normal file
File diff suppressed because it is too large
Load diff
111
resources/assets/scripts/base/angular-ui-sortable.js
vendored
Normal file
111
resources/assets/scripts/base/angular-ui-sortable.js
vendored
Normal file
|
@ -0,0 +1,111 @@
|
|||
/*
|
||||
jQuery UI Sortable plugin wrapper
|
||||
|
||||
@param [ui-sortable] {object} Options to pass to $.fn.sortable() merged onto ui.config
|
||||
*/
|
||||
angular.module('ui.sortable', [])
|
||||
.value('uiSortableConfig',{})
|
||||
.directive('uiSortable', [ 'uiSortableConfig',
|
||||
function(uiSortableConfig) {
|
||||
return {
|
||||
require: '?ngModel',
|
||||
link: function(scope, element, attrs, ngModel) {
|
||||
|
||||
function combineCallbacks(first,second){
|
||||
if( second && (typeof second === "function") ){
|
||||
return function(e,ui){
|
||||
first(e,ui);
|
||||
second(e,ui);
|
||||
};
|
||||
}
|
||||
return first;
|
||||
}
|
||||
|
||||
var opts = {};
|
||||
|
||||
var callbacks = {
|
||||
receive: null,
|
||||
remove:null,
|
||||
start:null,
|
||||
stop:null,
|
||||
update:null
|
||||
};
|
||||
|
||||
angular.extend(opts, uiSortableConfig);
|
||||
|
||||
if (ngModel) {
|
||||
|
||||
ngModel.$render = function() {
|
||||
element.sortable( "refresh" );
|
||||
};
|
||||
|
||||
callbacks.start = function(e, ui) {
|
||||
// Save position of dragged item
|
||||
ui.item.sortable = { index: ui.item.index() };
|
||||
};
|
||||
|
||||
callbacks.update = function(e, ui) {
|
||||
// For some reason the reference to ngModel in stop() is wrong
|
||||
ui.item.sortable.resort = ngModel;
|
||||
};
|
||||
|
||||
callbacks.receive = function(e, ui) {
|
||||
ui.item.sortable.relocate = true;
|
||||
// added item to array into correct position and set up flag
|
||||
ngModel.$modelValue.splice(ui.item.index(), 0, ui.item.sortable.moved);
|
||||
};
|
||||
|
||||
callbacks.remove = function(e, ui) {
|
||||
// copy data into item
|
||||
if (ngModel.$modelValue.length === 1) {
|
||||
ui.item.sortable.moved = ngModel.$modelValue.splice(0, 1)[0];
|
||||
} else {
|
||||
ui.item.sortable.moved = ngModel.$modelValue.splice(ui.item.sortable.index, 1)[0];
|
||||
}
|
||||
};
|
||||
|
||||
callbacks.stop = function(e, ui) {
|
||||
// digest all prepared changes
|
||||
if (ui.item.sortable.resort && !ui.item.sortable.relocate) {
|
||||
|
||||
// Fetch saved and current position of dropped element
|
||||
var end, start;
|
||||
start = ui.item.sortable.index;
|
||||
end = ui.item.index();
|
||||
|
||||
// Reorder array and apply change to scope
|
||||
ui.item.sortable.resort.$modelValue.splice(end, 0, ui.item.sortable.resort.$modelValue.splice(start, 1)[0]);
|
||||
|
||||
}
|
||||
if (ui.item.sortable.resort || ui.item.sortable.relocate) {
|
||||
scope.$apply();
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
scope.$watch(attrs.uiSortable, function(newVal, oldVal){
|
||||
angular.forEach(newVal, function(value, key){
|
||||
|
||||
if( callbacks[key] ){
|
||||
// wrap the callback
|
||||
value = combineCallbacks( callbacks[key], value );
|
||||
}
|
||||
|
||||
element.sortable('option', key, value);
|
||||
});
|
||||
}, true);
|
||||
|
||||
angular.forEach(callbacks, function(value, key ){
|
||||
|
||||
opts[key] = combineCallbacks(value, opts[key]);
|
||||
});
|
||||
|
||||
// Create sortable
|
||||
|
||||
element.sortable(opts);
|
||||
}
|
||||
};
|
||||
}
|
||||
]);
|
17902
resources/assets/scripts/base/angular.js
vendored
Normal file
17902
resources/assets/scripts/base/angular.js
vendored
Normal file
File diff suppressed because it is too large
Load diff
121
resources/assets/scripts/base/angularytics.js
vendored
Normal file
121
resources/assets/scripts/base/angularytics.js
vendored
Normal file
|
@ -0,0 +1,121 @@
|
|||
(function () {
|
||||
angular.module('angularytics', []).provider('Angularytics', function () {
|
||||
var eventHandlersNames = ['Google'];
|
||||
this.setEventHandlers = function (handlers) {
|
||||
if (angular.isString(handlers)) {
|
||||
handlers = [handlers];
|
||||
}
|
||||
eventHandlersNames = [];
|
||||
angular.forEach(handlers, function (handler) {
|
||||
eventHandlersNames.push(capitalizeHandler(handler));
|
||||
});
|
||||
};
|
||||
var capitalizeHandler = function (handler) {
|
||||
return handler.charAt(0).toUpperCase() + handler.substring(1);
|
||||
};
|
||||
var pageChangeEvent = '$locationChangeSuccess';
|
||||
this.setPageChangeEvent = function (newPageChangeEvent) {
|
||||
pageChangeEvent = newPageChangeEvent;
|
||||
};
|
||||
this.$get = [
|
||||
'$injector',
|
||||
'$rootScope',
|
||||
'$location',
|
||||
function ($injector, $rootScope, $location) {
|
||||
var eventHandlers = [];
|
||||
angular.forEach(eventHandlersNames, function (handler) {
|
||||
eventHandlers.push($injector.get('Angularytics' + handler + 'Handler'));
|
||||
});
|
||||
var forEachHandlerDo = function (action) {
|
||||
angular.forEach(eventHandlers, function (handler) {
|
||||
action(handler);
|
||||
});
|
||||
};
|
||||
$rootScope.$on(pageChangeEvent, function () {
|
||||
forEachHandlerDo(function (handler) {
|
||||
var url = $location.path();
|
||||
if (url) {
|
||||
handler.trackPageView(url);
|
||||
}
|
||||
});
|
||||
});
|
||||
var service = {};
|
||||
service.init = function () {
|
||||
};
|
||||
service.trackEvent = function (category, action, opt_label, opt_value, opt_noninteraction) {
|
||||
forEachHandlerDo(function (handler) {
|
||||
if (category && action) {
|
||||
handler.trackEvent(category, action, opt_label, opt_value, opt_noninteraction);
|
||||
}
|
||||
});
|
||||
};
|
||||
return service;
|
||||
}
|
||||
];
|
||||
});
|
||||
}());
|
||||
(function () {
|
||||
angular.module('angularytics').factory('AngularyticsConsoleHandler', [
|
||||
'$log',
|
||||
function ($log) {
|
||||
var service = {};
|
||||
service.trackPageView = function (url) {
|
||||
$log.log('URL visited', url);
|
||||
};
|
||||
service.trackEvent = function (category, action, opt_label, opt_value, opt_noninteraction) {
|
||||
$log.log('Event tracked', category, action, opt_label, opt_value, opt_noninteraction);
|
||||
};
|
||||
return service;
|
||||
}
|
||||
]);
|
||||
}());
|
||||
(function () {
|
||||
angular.module('angularytics').factory('AngularyticsGoogleHandler', [
|
||||
'$log',
|
||||
function ($log) {
|
||||
var service = {};
|
||||
service.trackPageView = function (url) {
|
||||
_gaq.push([
|
||||
'_set',
|
||||
'page',
|
||||
url
|
||||
]);
|
||||
_gaq.push([
|
||||
'_trackPageview',
|
||||
url
|
||||
]);
|
||||
};
|
||||
service.trackEvent = function (category, action, opt_label, opt_value, opt_noninteraction) {
|
||||
_gaq.push([
|
||||
'_trackEvent',
|
||||
category,
|
||||
action,
|
||||
opt_label,
|
||||
opt_value,
|
||||
opt_noninteraction
|
||||
]);
|
||||
};
|
||||
return service;
|
||||
}
|
||||
]).factory('AngularyticsGoogleUniversalHandler', function () {
|
||||
var service = {};
|
||||
service.trackPageView = function (url) {
|
||||
window._gaq.push(['_trackPageview', url]);
|
||||
};
|
||||
service.trackEvent = function (category, action, opt_label, opt_value, opt_noninteraction) {
|
||||
window.ga('send', 'event', category, action, opt_label, opt_value, { 'nonInteraction': opt_noninteraction });
|
||||
};
|
||||
return service;
|
||||
});
|
||||
}());
|
||||
(function () {
|
||||
angular.module('angularytics').filter('trackEvent', [
|
||||
'Angularytics',
|
||||
function (Angularytics) {
|
||||
return function (entry, category, action, opt_label, opt_value, opt_noninteraction) {
|
||||
Angularytics.trackEvent(category, action, opt_label, opt_value, opt_noninteraction);
|
||||
return entry;
|
||||
};
|
||||
}
|
||||
]);
|
||||
}());
|
193
resources/assets/scripts/base/bindonce.js
Normal file
193
resources/assets/scripts/base/bindonce.js
Normal file
|
@ -0,0 +1,193 @@
|
|||
'use strict';
|
||||
/**
|
||||
* Bindonce - Zero watches binding for AngularJs
|
||||
* @version v0.1.1 - 2013-05-07
|
||||
* @link https://github.com/Pasvaz/bindonce
|
||||
* @author Pasquale Vazzana <pasqualevazzana@gmail.com>
|
||||
* @license MIT License, http://www.opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
angular.module('pasvaz.bindonce', [])
|
||||
|
||||
.directive('bindonce', function() {
|
||||
var toBoolean = function(value) {
|
||||
if (value && value.length !== 0) {
|
||||
var v = angular.lowercase("" + value);
|
||||
value = !(v == 'f' || v == '0' || v == 'false' || v == 'no' || v == 'n' || v == '[]');
|
||||
} else {
|
||||
value = false;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
return {
|
||||
restrict: "AM",
|
||||
controller: ['$scope', '$element', '$attrs', function($scope, $element, $attrs) {
|
||||
var showHideBinder = function(elm, attr, value)
|
||||
{
|
||||
var show = (attr == 'show') ? '' : 'none';
|
||||
var hide = (attr == 'hide') ? '' : 'none';
|
||||
elm.css('display', toBoolean(value) ? show : hide);
|
||||
}
|
||||
var classBinder = function(elm, value)
|
||||
{
|
||||
if (angular.isObject(value) && !angular.isArray(value)) {
|
||||
var results = [];
|
||||
angular.forEach(value, function(value, index) {
|
||||
if (value) results.push(index);
|
||||
});
|
||||
value = results;
|
||||
}
|
||||
if (value) {
|
||||
elm.addClass(angular.isArray(value) ? value.join(' ') : value);
|
||||
}
|
||||
}
|
||||
|
||||
var ctrl =
|
||||
{
|
||||
watcherRemover : undefined,
|
||||
binders : [],
|
||||
group : $attrs.boName,
|
||||
element : $element,
|
||||
ran : false,
|
||||
|
||||
addBinder : function(binder)
|
||||
{
|
||||
this.binders.push(binder);
|
||||
|
||||
// In case of late binding (when using the directive bo-name/bo-parent)
|
||||
// it happens only when you use nested bindonce, if the bo-children
|
||||
// are not dom children the linking can follow another order
|
||||
if (this.ran)
|
||||
{
|
||||
this.runBinders();
|
||||
}
|
||||
},
|
||||
|
||||
setupWatcher : function(bindonceValue)
|
||||
{
|
||||
var that = this;
|
||||
this.watcherRemover = $scope.$watch(bindonceValue, function(newValue)
|
||||
{
|
||||
if (newValue == undefined) return;
|
||||
that.removeWatcher();
|
||||
that.runBinders();
|
||||
}, true);
|
||||
},
|
||||
|
||||
removeWatcher : function()
|
||||
{
|
||||
if (this.watcherRemover != undefined)
|
||||
{
|
||||
this.watcherRemover();
|
||||
this.watcherRemover = undefined;
|
||||
}
|
||||
},
|
||||
|
||||
runBinders : function()
|
||||
{
|
||||
for (var data in this.binders)
|
||||
{
|
||||
var binder = this.binders[data];
|
||||
if (this.group && this.group != binder.group ) continue;
|
||||
var value = $scope.$eval(binder.value);
|
||||
switch(binder.attr)
|
||||
{
|
||||
case 'hide':
|
||||
case 'show':
|
||||
showHideBinder(binder.element, binder.attr, value);
|
||||
break;
|
||||
case 'class':
|
||||
classBinder(binder.element, value);
|
||||
break;
|
||||
case 'text':
|
||||
binder.element.text(value);
|
||||
break;
|
||||
case 'html':
|
||||
binder.element.html(value);
|
||||
break;
|
||||
case 'src':
|
||||
case 'href':
|
||||
case 'alt':
|
||||
case 'title':
|
||||
case 'id':
|
||||
case 'style':
|
||||
case 'value':
|
||||
binder.element.attr(binder.attr, value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
this.ran = true;
|
||||
this.binders = [];
|
||||
}
|
||||
}
|
||||
|
||||
return ctrl;
|
||||
}],
|
||||
|
||||
link: function(scope, elm, attrs, bindonceController) {
|
||||
var value = (attrs.bindonce) ? scope.$eval(attrs.bindonce) : true;
|
||||
if (value != undefined)
|
||||
{
|
||||
bindonceController.runBinders();
|
||||
}
|
||||
else
|
||||
{
|
||||
bindonceController.setupWatcher(attrs.bindonce);
|
||||
elm.bind("$destroy", bindonceController.removeWatcher);
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
angular.forEach({
|
||||
'boShow' : 'show',
|
||||
'boHide' : 'hide',
|
||||
'boClass' : 'class',
|
||||
'boText' : 'text',
|
||||
'boHtml' : 'html',
|
||||
'boSrc' : 'src',
|
||||
'boHref' : 'href',
|
||||
'boAlt' : 'alt',
|
||||
'boTitle' : 'title',
|
||||
'boId' : 'id',
|
||||
'boStyle' : 'style',
|
||||
'boValue' : 'value'
|
||||
},
|
||||
function(tag, attribute)
|
||||
{
|
||||
var childPriority = 200;
|
||||
return angular.module('pasvaz.bindonce').directive(attribute, function()
|
||||
{
|
||||
return {
|
||||
priority: childPriority,
|
||||
require: '^bindonce',
|
||||
link: function(scope, elm, attrs, bindonceController)
|
||||
{
|
||||
var name = attrs.boParent;
|
||||
if (name && bindonceController.group != name)
|
||||
{
|
||||
var element = bindonceController.element.parent();
|
||||
bindonceController = undefined;
|
||||
var parentValue;
|
||||
|
||||
while (element[0].nodeType != 9 && element.length)
|
||||
{
|
||||
if ((parentValue = element.data('$bindonceController'))
|
||||
&& parentValue.group == name)
|
||||
{
|
||||
bindonceController = parentValue
|
||||
break;
|
||||
}
|
||||
element = element.parent();
|
||||
}
|
||||
if (!bindonceController)
|
||||
{
|
||||
throw Error("No bindonce controller: " + name);
|
||||
}
|
||||
}
|
||||
bindonceController.addBinder({element: elm, attr:tag, value: attrs[attribute], group: name});
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
8842
resources/assets/scripts/base/jquery-2.0.2.js
vendored
Normal file
8842
resources/assets/scripts/base/jquery-2.0.2.js
vendored
Normal file
File diff suppressed because it is too large
Load diff
15003
resources/assets/scripts/base/jquery-ui.js
vendored
Normal file
15003
resources/assets/scripts/base/jquery-ui.js
vendored
Normal file
File diff suppressed because it is too large
Load diff
1063
resources/assets/scripts/base/jquery.colorbox.js
Normal file
1063
resources/assets/scripts/base/jquery.colorbox.js
Normal file
File diff suppressed because it is too large
Load diff
95
resources/assets/scripts/base/jquery.cookie.js
Normal file
95
resources/assets/scripts/base/jquery.cookie.js
Normal file
|
@ -0,0 +1,95 @@
|
|||
/*!
|
||||
* jQuery Cookie Plugin v1.3.1
|
||||
* https://github.com/carhartl/jquery-cookie
|
||||
*
|
||||
* Copyright 2013 Klaus Hartl
|
||||
* Released under the MIT license
|
||||
*/
|
||||
(function (factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
// AMD. Register as anonymous module.
|
||||
define(['jquery'], factory);
|
||||
} else {
|
||||
// Browser globals.
|
||||
factory(jQuery);
|
||||
}
|
||||
}(function ($) {
|
||||
|
||||
var pluses = /\+/g;
|
||||
|
||||
function raw(s) {
|
||||
return s;
|
||||
}
|
||||
|
||||
function decoded(s) {
|
||||
return decodeURIComponent(s.replace(pluses, ' '));
|
||||
}
|
||||
|
||||
function converted(s) {
|
||||
if (s.indexOf('"') === 0) {
|
||||
// This is a quoted cookie as according to RFC2068, unescape
|
||||
s = s.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\');
|
||||
}
|
||||
try {
|
||||
return config.json ? JSON.parse(s) : s;
|
||||
} catch(er) {}
|
||||
}
|
||||
|
||||
var config = $.cookie = function (key, value, options) {
|
||||
|
||||
// write
|
||||
if (value !== undefined) {
|
||||
options = $.extend({}, config.defaults, options);
|
||||
|
||||
if (typeof options.expires === 'number') {
|
||||
var days = options.expires, t = options.expires = new Date();
|
||||
t.setDate(t.getDate() + days);
|
||||
}
|
||||
|
||||
value = config.json ? JSON.stringify(value) : String(value);
|
||||
|
||||
return (document.cookie = [
|
||||
config.raw ? key : encodeURIComponent(key),
|
||||
'=',
|
||||
config.raw ? value : encodeURIComponent(value),
|
||||
options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
|
||||
options.path ? '; path=' + options.path : '',
|
||||
options.domain ? '; domain=' + options.domain : '',
|
||||
options.secure ? '; secure' : ''
|
||||
].join(''));
|
||||
}
|
||||
|
||||
// read
|
||||
var decode = config.raw ? raw : decoded;
|
||||
var cookies = document.cookie.split('; ');
|
||||
var result = key ? undefined : {};
|
||||
for (var i = 0, l = cookies.length; i < l; i++) {
|
||||
var parts = cookies[i].split('=');
|
||||
var name = decode(parts.shift());
|
||||
var cookie = decode(parts.join('='));
|
||||
|
||||
if (key && key === name) {
|
||||
result = converted(cookie);
|
||||
break;
|
||||
}
|
||||
|
||||
if (!key) {
|
||||
result[name] = converted(cookie);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
config.defaults = {};
|
||||
|
||||
$.removeCookie = function (key, options) {
|
||||
if ($.cookie(key) !== undefined) {
|
||||
// Must not alter options, thus extending a fresh object...
|
||||
$.cookie(key, '', $.extend({}, options, { expires: -1 }));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
}));
|
193
resources/assets/scripts/base/jquery.timeago.js
Normal file
193
resources/assets/scripts/base/jquery.timeago.js
Normal file
|
@ -0,0 +1,193 @@
|
|||
/**
|
||||
* Timeago is a jQuery plugin that makes it easy to support automatically
|
||||
* updating fuzzy timestamps (e.g. "4 minutes ago" or "about 1 day ago").
|
||||
*
|
||||
* @name timeago
|
||||
* @version 1.3.0
|
||||
* @requires jQuery v1.2.3+
|
||||
* @author Ryan McGeary
|
||||
* @license MIT License - http://www.opensource.org/licenses/mit-license.php
|
||||
*
|
||||
* For usage and examples, visit:
|
||||
* http://timeago.yarp.com/
|
||||
*
|
||||
* Copyright (c) 2008-2013, Ryan McGeary (ryan -[at]- mcgeary [*dot*] org)
|
||||
*/
|
||||
|
||||
(function (factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
// AMD. Register as an anonymous module.
|
||||
define(['jquery'], factory);
|
||||
} else {
|
||||
// Browser globals
|
||||
factory(jQuery);
|
||||
}
|
||||
}(function ($) {
|
||||
$.timeago = function(timestamp) {
|
||||
if (timestamp instanceof Date) {
|
||||
return inWords(timestamp);
|
||||
} else if (typeof timestamp === "string") {
|
||||
return inWords($.timeago.parse(timestamp));
|
||||
} else if (typeof timestamp === "number") {
|
||||
return inWords(new Date(timestamp));
|
||||
} else {
|
||||
return inWords($.timeago.datetime(timestamp));
|
||||
}
|
||||
};
|
||||
var $t = $.timeago;
|
||||
|
||||
$.extend($.timeago, {
|
||||
settings: {
|
||||
refreshMillis: 60000,
|
||||
allowFuture: false,
|
||||
localeTitle: false,
|
||||
cutoff: 0,
|
||||
strings: {
|
||||
prefixAgo: null,
|
||||
prefixFromNow: null,
|
||||
suffixAgo: "ago",
|
||||
suffixFromNow: "from now",
|
||||
seconds: "less than a minute",
|
||||
minute: "about a minute",
|
||||
minutes: "%d minutes",
|
||||
hour: "about an hour",
|
||||
hours: "about %d hours",
|
||||
day: "a day",
|
||||
days: "%d days",
|
||||
month: "about a month",
|
||||
months: "%d months",
|
||||
year: "about a year",
|
||||
years: "%d years",
|
||||
wordSeparator: " ",
|
||||
numbers: []
|
||||
}
|
||||
},
|
||||
inWords: function(distanceMillis) {
|
||||
var $l = this.settings.strings;
|
||||
var prefix = $l.prefixAgo;
|
||||
var suffix = $l.suffixAgo;
|
||||
if (this.settings.allowFuture) {
|
||||
if (distanceMillis < 0) {
|
||||
prefix = $l.prefixFromNow;
|
||||
suffix = $l.suffixFromNow;
|
||||
}
|
||||
}
|
||||
|
||||
var seconds = Math.abs(distanceMillis) / 1000;
|
||||
var minutes = seconds / 60;
|
||||
var hours = minutes / 60;
|
||||
var days = hours / 24;
|
||||
var years = days / 365;
|
||||
|
||||
function substitute(stringOrFunction, number) {
|
||||
var string = $.isFunction(stringOrFunction) ? stringOrFunction(number, distanceMillis) : stringOrFunction;
|
||||
var value = ($l.numbers && $l.numbers[number]) || number;
|
||||
return string.replace(/%d/i, value);
|
||||
}
|
||||
|
||||
var words = seconds < 45 && substitute($l.seconds, Math.round(seconds)) ||
|
||||
seconds < 90 && substitute($l.minute, 1) ||
|
||||
minutes < 45 && substitute($l.minutes, Math.round(minutes)) ||
|
||||
minutes < 90 && substitute($l.hour, 1) ||
|
||||
hours < 24 && substitute($l.hours, Math.round(hours)) ||
|
||||
hours < 42 && substitute($l.day, 1) ||
|
||||
days < 30 && substitute($l.days, Math.round(days)) ||
|
||||
days < 45 && substitute($l.month, 1) ||
|
||||
days < 365 && substitute($l.months, Math.round(days / 30)) ||
|
||||
years < 1.5 && substitute($l.year, 1) ||
|
||||
substitute($l.years, Math.round(years));
|
||||
|
||||
var separator = $l.wordSeparator || "";
|
||||
if ($l.wordSeparator === undefined) { separator = " "; }
|
||||
return $.trim([prefix, words, suffix].join(separator));
|
||||
},
|
||||
parse: function(iso8601) {
|
||||
var s = $.trim(iso8601);
|
||||
s = s.replace(/\.\d+/,""); // remove milliseconds
|
||||
s = s.replace(/-/,"/").replace(/-/,"/");
|
||||
s = s.replace(/T/," ").replace(/Z/," UTC");
|
||||
s = s.replace(/([\+\-]\d\d)\:?(\d\d)/," $1$2"); // -04:00 -> -0400
|
||||
return new Date(s);
|
||||
},
|
||||
datetime: function(elem) {
|
||||
var iso8601 = $t.isTime(elem) ? $(elem).attr("datetime") : $(elem).attr("title");
|
||||
return $t.parse(iso8601);
|
||||
},
|
||||
isTime: function(elem) {
|
||||
// jQuery's `is()` doesn't play well with HTML5 in IE
|
||||
return $(elem).get(0).tagName.toLowerCase() === "time"; // $(elem).is("time");
|
||||
}
|
||||
});
|
||||
|
||||
// functions that can be called via $(el).timeago('action')
|
||||
// init is default when no action is given
|
||||
// functions are called with context of a single element
|
||||
var functions = {
|
||||
init: function(){
|
||||
var refresh_el = $.proxy(refresh, this);
|
||||
refresh_el();
|
||||
var $s = $t.settings;
|
||||
if ($s.refreshMillis > 0) {
|
||||
setInterval(refresh_el, $s.refreshMillis);
|
||||
}
|
||||
},
|
||||
update: function(time){
|
||||
$(this).data('timeago', { datetime: $t.parse(time) });
|
||||
refresh.apply(this);
|
||||
},
|
||||
updateFromDOM: function(){
|
||||
$(this).data('timeago', { datetime: $t.parse( $t.isTime(this) ? $(this).attr("datetime") : $(this).attr("title") ) });
|
||||
refresh.apply(this);
|
||||
}
|
||||
};
|
||||
|
||||
$.fn.timeago = function(action, options) {
|
||||
var fn = action ? functions[action] : functions.init;
|
||||
if(!fn){
|
||||
throw new Error("Unknown function name '"+ action +"' for timeago");
|
||||
}
|
||||
// each over objects here and call the requested function
|
||||
this.each(function(){
|
||||
fn.call(this, options);
|
||||
});
|
||||
return this;
|
||||
};
|
||||
|
||||
function refresh() {
|
||||
var data = prepareData(this);
|
||||
var $s = $t.settings;
|
||||
|
||||
if (!isNaN(data.datetime)) {
|
||||
if ( $s.cutoff == 0 || distance(data.datetime) < $s.cutoff) {
|
||||
$(this).text(inWords(data.datetime));
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
function prepareData(element) {
|
||||
element = $(element);
|
||||
if (!element.data("timeago")) {
|
||||
element.data("timeago", { datetime: $t.datetime(element) });
|
||||
var text = $.trim(element.text());
|
||||
if ($t.settings.localeTitle) {
|
||||
element.attr("title", element.data('timeago').datetime.toLocaleString());
|
||||
} else if (text.length > 0 && !($t.isTime(element) && element.attr("title"))) {
|
||||
element.attr("title", text);
|
||||
}
|
||||
}
|
||||
return element.data("timeago");
|
||||
}
|
||||
|
||||
function inWords(date) {
|
||||
return $t.inWords(distance(date));
|
||||
}
|
||||
|
||||
function distance(date) {
|
||||
return (new Date().getTime() - date.getTime());
|
||||
}
|
||||
|
||||
// fix for IE6 suckage
|
||||
document.createElement("abbr");
|
||||
document.createElement("time");
|
||||
}));
|
58
resources/assets/scripts/base/jquery.viewport.js
Normal file
58
resources/assets/scripts/base/jquery.viewport.js
Normal file
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* Viewport - jQuery selectors for finding elements in viewport
|
||||
*
|
||||
* Copyright (c) 2008-2009 Mika Tuupola
|
||||
*
|
||||
* Licensed under the MIT license:
|
||||
* http://www.opensource.org/licenses/mit-license.php
|
||||
*
|
||||
* Project home:
|
||||
* http://www.appelsiini.net/projects/viewport
|
||||
*
|
||||
*/
|
||||
(function($) {
|
||||
|
||||
$.belowthefold = function(element, settings) {
|
||||
var fold = $(window).height() + $(window).scrollTop();
|
||||
return fold <= $(element).offset().top - settings.threshold;
|
||||
};
|
||||
|
||||
$.abovethetop = function(element, settings) {
|
||||
var top = $(window).scrollTop();
|
||||
return top >= $(element).offset().top + $(element).height() - settings.threshold;
|
||||
};
|
||||
|
||||
$.rightofscreen = function(element, settings) {
|
||||
var fold = $(window).width() + $(window).scrollLeft();
|
||||
return fold <= $(element).offset().left - settings.threshold;
|
||||
};
|
||||
|
||||
$.leftofscreen = function(element, settings) {
|
||||
var left = $(window).scrollLeft();
|
||||
return left >= $(element).offset().left + $(element).width() - settings.threshold;
|
||||
};
|
||||
|
||||
$.inviewport = function(element, settings) {
|
||||
return !$.rightofscreen(element, settings) && !$.leftofscreen(element, settings) && !$.belowthefold(element, settings) && !$.abovethetop(element, settings);
|
||||
};
|
||||
|
||||
$.extend($.expr[':'], {
|
||||
"below-the-fold": function(a, i, m) {
|
||||
return $.belowthefold(a, {threshold : 0});
|
||||
},
|
||||
"above-the-top": function(a, i, m) {
|
||||
return $.abovethetop(a, {threshold : 0});
|
||||
},
|
||||
"left-of-screen": function(a, i, m) {
|
||||
return $.leftofscreen(a, {threshold : 0});
|
||||
},
|
||||
"right-of-screen": function(a, i, m) {
|
||||
return $.rightofscreen(a, {threshold : 0});
|
||||
},
|
||||
"in-viewport": function(a, i, m) {
|
||||
return $.inviewport(a, {threshold : 0});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
})(jQuery);
|
1662
resources/assets/scripts/base/moment.js
Normal file
1662
resources/assets/scripts/base/moment.js
Normal file
File diff suppressed because it is too large
Load diff
2643
resources/assets/scripts/base/soundmanager2-nodebug.js
Normal file
2643
resources/assets/scripts/base/soundmanager2-nodebug.js
Normal file
File diff suppressed because it is too large
Load diff
3
resources/assets/scripts/base/tumblr.js
Normal file
3
resources/assets/scripts/base/tumblr.js
Normal file
|
@ -0,0 +1,3 @@
|
|||
var Tumblr=window.Tumblr||{};(function(){Tumblr.share_on_tumblr=function(anchor){var advanced=anchor.href.match(/(www.)?tumblr(\.com)?(\:\d{2,4})?\/share(.+)?/i);advanced=(advanced[4]!==undefined&&advanced[4].length>1);var d=document,w=window,e=w.getSelection,k=d.getSelection,x=d.selection,s=(e?e():(k)?k():(x?x.createRange().text:0)),f="http://www.tumblr.com/share",l=d.location,e=encodeURIComponent,p="?v=3&u="+e(l.href)+"&t="+e(d.title)+"&s="+e(s),u=f+p;if(advanced){u=anchor.href}try{if(!/^(.*\.)?tumblr[^.]*$/.test(l.host)){throw (0)}tstbklt()}catch(z){a=function(){if(!w.open(u,"t","toolbar=0,resizable=0,status=1,width=450,height=430")){l.href=u}};if(/Firefox/.test(navigator.userAgent)){setTimeout(a,0)}else{a()}}void (0)};Tumblr.activate_share_on_tumblr_buttons=function(){var anchors=document.getElementsByTagName("a"),anchors_length=anchors.length,match=false,old_onclick;for(var i=0;i<anchors_length;i++){match=anchors[i].href.match(/(www.)?tumblr(\.com)?(\:\d{2,4})?\/share(.+)?/i);if(match){old_onclick=anchors[i].onclick;anchors[i].onclick=function(e){Tumblr.share_on_tumblr(this);if(old_onclick){old_onclick()}old_onclick=false;e.preventDefault()}}}};(function(i){var u=navigator.userAgent;var e=
|
||||
/*@cc_on!@*/
|
||||
false;var st=setTimeout;if(/webkit/i.test(u)){st(function(){var dr=document.readyState;if(dr=="loaded"||dr=="complete"){i()}else{st(arguments.callee,10)}},10)}else{if((/mozilla/i.test(u)&&!/(compati)/.test(u))||(/opera/i.test(u))){document.addEventListener("DOMContentLoaded",i,false)}else{if(e){(function(){var t=document.createElement("doc:rdy");try{t.doScroll("left");i();t=null}catch(e){st(arguments.callee,0)}})()}else{window.onload=i}}}})(Tumblr.activate_share_on_tumblr_buttons)}());
|
3165
resources/assets/scripts/base/ui-bootstrap-tpls-0.4.0.js
Normal file
3165
resources/assets/scripts/base/ui-bootstrap-tpls-0.4.0.js
Normal file
File diff suppressed because it is too large
Load diff
1227
resources/assets/scripts/base/underscore.js
Normal file
1227
resources/assets/scripts/base/underscore.js
Normal file
File diff suppressed because it is too large
Load diff
28
resources/assets/scripts/debug/prettify.js
Normal file
28
resources/assets/scripts/debug/prettify.js
Normal file
|
@ -0,0 +1,28 @@
|
|||
var q=null;window.PR_SHOULD_USE_CONTINUATION=!0;
|
||||
(function(){function L(a){function m(a){var f=a.charCodeAt(0);if(f!==92)return f;var b=a.charAt(1);return(f=r[b])?f:"0"<=b&&b<="7"?parseInt(a.substring(1),8):b==="u"||b==="x"?parseInt(a.substring(2),16):a.charCodeAt(1)}function e(a){if(a<32)return(a<16?"\\x0":"\\x")+a.toString(16);a=String.fromCharCode(a);if(a==="\\"||a==="-"||a==="["||a==="]")a="\\"+a;return a}function h(a){for(var f=a.substring(1,a.length-1).match(/\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\[0-3][0-7]{0,2}|\\[0-7]{1,2}|\\[\S\s]|[^\\]/g),a=
|
||||
[],b=[],o=f[0]==="^",c=o?1:0,i=f.length;c<i;++c){var j=f[c];if(/\\[bdsw]/i.test(j))a.push(j);else{var j=m(j),d;c+2<i&&"-"===f[c+1]?(d=m(f[c+2]),c+=2):d=j;b.push([j,d]);d<65||j>122||(d<65||j>90||b.push([Math.max(65,j)|32,Math.min(d,90)|32]),d<97||j>122||b.push([Math.max(97,j)&-33,Math.min(d,122)&-33]))}}b.sort(function(a,f){return a[0]-f[0]||f[1]-a[1]});f=[];j=[NaN,NaN];for(c=0;c<b.length;++c)i=b[c],i[0]<=j[1]+1?j[1]=Math.max(j[1],i[1]):f.push(j=i);b=["["];o&&b.push("^");b.push.apply(b,a);for(c=0;c<
|
||||
f.length;++c)i=f[c],b.push(e(i[0])),i[1]>i[0]&&(i[1]+1>i[0]&&b.push("-"),b.push(e(i[1])));b.push("]");return b.join("")}function y(a){for(var f=a.source.match(/\[(?:[^\\\]]|\\[\S\s])*]|\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\\d+|\\[^\dux]|\(\?[!:=]|[()^]|[^()[\\^]+/g),b=f.length,d=[],c=0,i=0;c<b;++c){var j=f[c];j==="("?++i:"\\"===j.charAt(0)&&(j=+j.substring(1))&&j<=i&&(d[j]=-1)}for(c=1;c<d.length;++c)-1===d[c]&&(d[c]=++t);for(i=c=0;c<b;++c)j=f[c],j==="("?(++i,d[i]===void 0&&(f[c]="(?:")):"\\"===j.charAt(0)&&
|
||||
(j=+j.substring(1))&&j<=i&&(f[c]="\\"+d[i]);for(i=c=0;c<b;++c)"^"===f[c]&&"^"!==f[c+1]&&(f[c]="");if(a.ignoreCase&&s)for(c=0;c<b;++c)j=f[c],a=j.charAt(0),j.length>=2&&a==="["?f[c]=h(j):a!=="\\"&&(f[c]=j.replace(/[A-Za-z]/g,function(a){a=a.charCodeAt(0);return"["+String.fromCharCode(a&-33,a|32)+"]"}));return f.join("")}for(var t=0,s=!1,l=!1,p=0,d=a.length;p<d;++p){var g=a[p];if(g.ignoreCase)l=!0;else if(/[a-z]/i.test(g.source.replace(/\\u[\da-f]{4}|\\x[\da-f]{2}|\\[^UXux]/gi,""))){s=!0;l=!1;break}}for(var r=
|
||||
{b:8,t:9,n:10,v:11,f:12,r:13},n=[],p=0,d=a.length;p<d;++p){g=a[p];if(g.global||g.multiline)throw Error(""+g);n.push("(?:"+y(g)+")")}return RegExp(n.join("|"),l?"gi":"g")}function M(a){function m(a){switch(a.nodeType){case 1:if(e.test(a.className))break;for(var g=a.firstChild;g;g=g.nextSibling)m(g);g=a.nodeName;if("BR"===g||"LI"===g)h[s]="\n",t[s<<1]=y++,t[s++<<1|1]=a;break;case 3:case 4:g=a.nodeValue,g.length&&(g=p?g.replace(/\r\n?/g,"\n"):g.replace(/[\t\n\r ]+/g," "),h[s]=g,t[s<<1]=y,y+=g.length,
|
||||
t[s++<<1|1]=a)}}var e=/(?:^|\s)nocode(?:\s|$)/,h=[],y=0,t=[],s=0,l;a.currentStyle?l=a.currentStyle.whiteSpace:window.getComputedStyle&&(l=document.defaultView.getComputedStyle(a,q).getPropertyValue("white-space"));var p=l&&"pre"===l.substring(0,3);m(a);return{a:h.join("").replace(/\n$/,""),c:t}}function B(a,m,e,h){m&&(a={a:m,d:a},e(a),h.push.apply(h,a.e))}function x(a,m){function e(a){for(var l=a.d,p=[l,"pln"],d=0,g=a.a.match(y)||[],r={},n=0,z=g.length;n<z;++n){var f=g[n],b=r[f],o=void 0,c;if(typeof b===
|
||||
"string")c=!1;else{var i=h[f.charAt(0)];if(i)o=f.match(i[1]),b=i[0];else{for(c=0;c<t;++c)if(i=m[c],o=f.match(i[1])){b=i[0];break}o||(b="pln")}if((c=b.length>=5&&"lang-"===b.substring(0,5))&&!(o&&typeof o[1]==="string"))c=!1,b="src";c||(r[f]=b)}i=d;d+=f.length;if(c){c=o[1];var j=f.indexOf(c),k=j+c.length;o[2]&&(k=f.length-o[2].length,j=k-c.length);b=b.substring(5);B(l+i,f.substring(0,j),e,p);B(l+i+j,c,C(b,c),p);B(l+i+k,f.substring(k),e,p)}else p.push(l+i,b)}a.e=p}var h={},y;(function(){for(var e=a.concat(m),
|
||||
l=[],p={},d=0,g=e.length;d<g;++d){var r=e[d],n=r[3];if(n)for(var k=n.length;--k>=0;)h[n.charAt(k)]=r;r=r[1];n=""+r;p.hasOwnProperty(n)||(l.push(r),p[n]=q)}l.push(/[\S\s]/);y=L(l)})();var t=m.length;return e}function u(a){var m=[],e=[];a.tripleQuotedStrings?m.push(["str",/^(?:'''(?:[^'\\]|\\[\S\s]|''?(?=[^']))*(?:'''|$)|"""(?:[^"\\]|\\[\S\s]|""?(?=[^"]))*(?:"""|$)|'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$))/,q,"'\""]):a.multiLineStrings?m.push(["str",/^(?:'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$)|`(?:[^\\`]|\\[\S\s])*(?:`|$))/,
|
||||
q,"'\"`"]):m.push(["str",/^(?:'(?:[^\n\r'\\]|\\.)*(?:'|$)|"(?:[^\n\r"\\]|\\.)*(?:"|$))/,q,"\"'"]);a.verbatimStrings&&e.push(["str",/^@"(?:[^"]|"")*(?:"|$)/,q]);var h=a.hashComments;h&&(a.cStyleComments?(h>1?m.push(["com",/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,q,"#"]):m.push(["com",/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\n\r]*)/,q,"#"]),e.push(["str",/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,q])):m.push(["com",/^#[^\n\r]*/,
|
||||
q,"#"]));a.cStyleComments&&(e.push(["com",/^\/\/[^\n\r]*/,q]),e.push(["com",/^\/\*[\S\s]*?(?:\*\/|$)/,q]));a.regexLiterals&&e.push(["lang-regex",/^(?:^^\.?|[!+-]|!=|!==|#|%|%=|&|&&|&&=|&=|\(|\*|\*=|\+=|,|-=|->|\/|\/=|:|::|;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|[?@[^]|\^=|\^\^|\^\^=|{|\||\|=|\|\||\|\|=|~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\s*(\/(?=[^*/])(?:[^/[\\]|\\[\S\s]|\[(?:[^\\\]]|\\[\S\s])*(?:]|$))+\/)/]);(h=a.types)&&e.push(["typ",h]);a=(""+a.keywords).replace(/^ | $/g,
|
||||
"");a.length&&e.push(["kwd",RegExp("^(?:"+a.replace(/[\s,]+/g,"|")+")\\b"),q]);m.push(["pln",/^\s+/,q," \r\n\t\xa0"]);e.push(["lit",/^@[$_a-z][\w$@]*/i,q],["typ",/^(?:[@_]?[A-Z]+[a-z][\w$@]*|\w+_t\b)/,q],["pln",/^[$_a-z][\w$@]*/i,q],["lit",/^(?:0x[\da-f]+|(?:\d(?:_\d+)*\d*(?:\.\d*)?|\.\d\+)(?:e[+-]?\d+)?)[a-z]*/i,q,"0123456789"],["pln",/^\\[\S\s]?/,q],["pun",/^.[^\s\w"-$'./@\\`]*/,q]);return x(m,e)}function D(a,m){function e(a){switch(a.nodeType){case 1:if(k.test(a.className))break;if("BR"===a.nodeName)h(a),
|
||||
a.parentNode&&a.parentNode.removeChild(a);else for(a=a.firstChild;a;a=a.nextSibling)e(a);break;case 3:case 4:if(p){var b=a.nodeValue,d=b.match(t);if(d){var c=b.substring(0,d.index);a.nodeValue=c;(b=b.substring(d.index+d[0].length))&&a.parentNode.insertBefore(s.createTextNode(b),a.nextSibling);h(a);c||a.parentNode.removeChild(a)}}}}function h(a){function b(a,d){var e=d?a.cloneNode(!1):a,f=a.parentNode;if(f){var f=b(f,1),g=a.nextSibling;f.appendChild(e);for(var h=g;h;h=g)g=h.nextSibling,f.appendChild(h)}return e}
|
||||
for(;!a.nextSibling;)if(a=a.parentNode,!a)return;for(var a=b(a.nextSibling,0),e;(e=a.parentNode)&&e.nodeType===1;)a=e;d.push(a)}var k=/(?:^|\s)nocode(?:\s|$)/,t=/\r\n?|\n/,s=a.ownerDocument,l;a.currentStyle?l=a.currentStyle.whiteSpace:window.getComputedStyle&&(l=s.defaultView.getComputedStyle(a,q).getPropertyValue("white-space"));var p=l&&"pre"===l.substring(0,3);for(l=s.createElement("LI");a.firstChild;)l.appendChild(a.firstChild);for(var d=[l],g=0;g<d.length;++g)e(d[g]);m===(m|0)&&d[0].setAttribute("value",
|
||||
m);var r=s.createElement("OL");r.className="linenums";for(var n=Math.max(0,m-1|0)||0,g=0,z=d.length;g<z;++g)l=d[g],l.className="L"+(g+n)%10,l.firstChild||l.appendChild(s.createTextNode("\xa0")),r.appendChild(l);a.appendChild(r)}function k(a,m){for(var e=m.length;--e>=0;){var h=m[e];A.hasOwnProperty(h)?window.console&&console.warn("cannot override language handler %s",h):A[h]=a}}function C(a,m){if(!a||!A.hasOwnProperty(a))a=/^\s*</.test(m)?"default-markup":"default-code";return A[a]}function E(a){var m=
|
||||
a.g;try{var e=M(a.h),h=e.a;a.a=h;a.c=e.c;a.d=0;C(m,h)(a);var k=/\bMSIE\b/.test(navigator.userAgent),m=/\n/g,t=a.a,s=t.length,e=0,l=a.c,p=l.length,h=0,d=a.e,g=d.length,a=0;d[g]=s;var r,n;for(n=r=0;n<g;)d[n]!==d[n+2]?(d[r++]=d[n++],d[r++]=d[n++]):n+=2;g=r;for(n=r=0;n<g;){for(var z=d[n],f=d[n+1],b=n+2;b+2<=g&&d[b+1]===f;)b+=2;d[r++]=z;d[r++]=f;n=b}for(d.length=r;h<p;){var o=l[h+2]||s,c=d[a+2]||s,b=Math.min(o,c),i=l[h+1],j;if(i.nodeType!==1&&(j=t.substring(e,b))){k&&(j=j.replace(m,"\r"));i.nodeValue=
|
||||
j;var u=i.ownerDocument,v=u.createElement("SPAN");v.className=d[a+1];var x=i.parentNode;x.replaceChild(v,i);v.appendChild(i);e<o&&(l[h+1]=i=u.createTextNode(t.substring(b,o)),x.insertBefore(i,v.nextSibling))}e=b;e>=o&&(h+=2);e>=c&&(a+=2)}}catch(w){"console"in window&&console.log(w&&w.stack?w.stack:w)}}var v=["break,continue,do,else,for,if,return,while"],w=[[v,"auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"],
|
||||
"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"],F=[w,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"],G=[w,"abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"],
|
||||
H=[G,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var"],w=[w,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"],I=[v,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"],
|
||||
J=[v,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"],v=[v,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"],K=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/,N=/\S/,O=u({keywords:[F,H,w,"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END"+
|
||||
I,J,v],hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0}),A={};k(O,["default-code"]);k(x([],[["pln",/^[^<?]+/],["dec",/^<!\w[^>]*(?:>|$)/],["com",/^<\!--[\S\s]*?(?:--\>|$)/],["lang-",/^<\?([\S\s]+?)(?:\?>|$)/],["lang-",/^<%([\S\s]+?)(?:%>|$)/],["pun",/^(?:<[%?]|[%?]>)/],["lang-",/^<xmp\b[^>]*>([\S\s]+?)<\/xmp\b[^>]*>/i],["lang-js",/^<script\b[^>]*>([\S\s]*?)(<\/script\b[^>]*>)/i],["lang-css",/^<style\b[^>]*>([\S\s]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),
|
||||
["default-markup","htm","html","mxml","xhtml","xml","xsl"]);k(x([["pln",/^\s+/,q," \t\r\n"],["atv",/^(?:"[^"]*"?|'[^']*'?)/,q,"\"'"]],[["tag",/^^<\/?[a-z](?:[\w-.:]*\w)?|\/?>$/i],["atn",/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^\s"'>]*(?:[^\s"'/>]|\/(?=\s)))/],["pun",/^[/<->]+/],["lang-js",/^on\w+\s*=\s*"([^"]+)"/i],["lang-js",/^on\w+\s*=\s*'([^']+)'/i],["lang-js",/^on\w+\s*=\s*([^\s"'>]+)/i],["lang-css",/^style\s*=\s*"([^"]+)"/i],["lang-css",/^style\s*=\s*'([^']+)'/i],["lang-css",
|
||||
/^style\s*=\s*([^\s"'>]+)/i]]),["in.tag"]);k(x([],[["atv",/^[\S\s]+/]]),["uq.val"]);k(u({keywords:F,hashComments:!0,cStyleComments:!0,types:K}),["c","cc","cpp","cxx","cyc","m"]);k(u({keywords:"null,true,false"}),["json"]);k(u({keywords:H,hashComments:!0,cStyleComments:!0,verbatimStrings:!0,types:K}),["cs"]);k(u({keywords:G,cStyleComments:!0}),["java"]);k(u({keywords:v,hashComments:!0,multiLineStrings:!0}),["bsh","csh","sh"]);k(u({keywords:I,hashComments:!0,multiLineStrings:!0,tripleQuotedStrings:!0}),
|
||||
["cv","py"]);k(u({keywords:"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END",hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["perl","pl","pm"]);k(u({keywords:J,hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["rb"]);k(u({keywords:w,cStyleComments:!0,regexLiterals:!0}),["js"]);k(u({keywords:"all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,true,try,unless,until,when,while,yes",
|
||||
hashComments:3,cStyleComments:!0,multilineStrings:!0,tripleQuotedStrings:!0,regexLiterals:!0}),["coffee"]);k(x([],[["str",/^[\S\s]+/]]),["regex"]);window.prettyPrintOne=function(a,m,e){var h=document.createElement("PRE");h.innerHTML=a;e&&D(h,e);E({g:m,i:e,h:h});return h.innerHTML};window.prettyPrint=function(a){function m(){for(var e=window.PR_SHOULD_USE_CONTINUATION?l.now()+250:Infinity;p<h.length&&l.now()<e;p++){var n=h[p],k=n.className;if(k.indexOf("prettyprint")>=0){var k=k.match(g),f,b;if(b=
|
||||
!k){b=n;for(var o=void 0,c=b.firstChild;c;c=c.nextSibling)var i=c.nodeType,o=i===1?o?b:c:i===3?N.test(c.nodeValue)?b:o:o;b=(f=o===b?void 0:o)&&"CODE"===f.tagName}b&&(k=f.className.match(g));k&&(k=k[1]);b=!1;for(o=n.parentNode;o;o=o.parentNode)if((o.tagName==="pre"||o.tagName==="code"||o.tagName==="xmp")&&o.className&&o.className.indexOf("prettyprint")>=0){b=!0;break}b||((b=(b=n.className.match(/\blinenums\b(?::(\d+))?/))?b[1]&&b[1].length?+b[1]:!0:!1)&&D(n,b),d={g:k,h:n,i:b},E(d))}}p<h.length?setTimeout(m,
|
||||
250):a&&a()}for(var e=[document.getElementsByTagName("pre"),document.getElementsByTagName("code"),document.getElementsByTagName("xmp")],h=[],k=0;k<e.length;++k)for(var t=0,s=e[k].length;t<s;++t)h.push(e[k][t]);var e=q,l=Date;l.now||(l={now:function(){return+new Date}});var p=0,d,g=/\blang(?:uage)?-([\w.]+)(?!\S)/;m()};window.PR={createSimpleLexer:x,registerLangHandler:k,sourceDecorator:u,PR_ATTRIB_NAME:"atn",PR_ATTRIB_VALUE:"atv",PR_COMMENT:"com",PR_DECLARATION:"dec",PR_KEYWORD:"kwd",PR_LITERAL:"lit",
|
||||
PR_NOCODE:"nocode",PR_PLAIN:"pln",PR_PUNCTUATION:"pun",PR_SOURCE:"src",PR_STRING:"str",PR_TAG:"tag",PR_TYPE:"typ"}})();
|
69
resources/assets/scripts/debug/profiler.coffee
Normal file
69
resources/assets/scripts/debug/profiler.coffee
Normal file
|
@ -0,0 +1,69 @@
|
|||
$profiler = $("<div class='profiler' />").appendTo document.body
|
||||
$toolbar = $('<div class="buttons" />').appendTo $profiler
|
||||
|
||||
$('<a href="#" class="open-button"><i class="icon-chevron-down"></i></a>')
|
||||
.click (e) ->
|
||||
e.preventDefault()
|
||||
$(document.body).toggleClass 'profiler-open'
|
||||
.appendTo $toolbar
|
||||
|
||||
$('<a href="#" class="clear-button">Clear</a>')
|
||||
.click (e) ->
|
||||
e.preventDefault()
|
||||
$profiler.find('.requests').empty()
|
||||
.appendTo $toolbar
|
||||
|
||||
$requestItems = $("<ul class='requests'>").appendTo $profiler
|
||||
|
||||
appendRequest = (method, url, req) ->
|
||||
$requestItem = $("<li />")
|
||||
$requestHeader = ($("<h3 />")).appendTo $requestItem
|
||||
($("<span class='method' />").text method).appendTo $requestHeader
|
||||
($("<span class='url' />").text url).appendTo $requestHeader
|
||||
|
||||
$logItems = $("<ul />").appendTo $requestItem
|
||||
|
||||
for logItem in req.request.log
|
||||
$liItem = $("<li>")
|
||||
|
||||
$("<h4 class='log-" + logItem.level + "' />")
|
||||
.html(logItem.message)
|
||||
.click () ->
|
||||
$(this).toggleClass 'open'
|
||||
.appendTo($liItem)
|
||||
|
||||
$("<div class='clear' />").appendTo $liItem
|
||||
$liItem.appendTo $logItems
|
||||
|
||||
for query in req.request.queries
|
||||
queryText = query.query
|
||||
for binding in query.bindings
|
||||
queryText = queryText.replace '?', '"' + binding + '"'
|
||||
|
||||
$liItem = $("<li>")
|
||||
($("<span class='time' />").text query.time).appendTo $liItem
|
||||
|
||||
$("<h4 class='prettyprint' />")
|
||||
.html(prettyPrintOne(queryText, 'lang-sql'))
|
||||
.click () ->
|
||||
$(this).toggleClass 'open'
|
||||
.appendTo($liItem)
|
||||
|
||||
$("<div class='clear' />").appendTo $liItem
|
||||
$liItem.appendTo $logItems
|
||||
|
||||
$requestItem.appendTo $requestItems
|
||||
$requestItems.animate {scrollTop: $requestItems[0].scrollHeight}, 300
|
||||
|
||||
oldOpen = XMLHttpRequest.prototype.open
|
||||
|
||||
XMLHttpRequest.prototype.open = (method, url) ->
|
||||
intercept = =>
|
||||
return if this.readyState != 4
|
||||
return if !this.getResponseHeader('X-Request-Id')
|
||||
id = this.getResponseHeader('X-Request-Id')
|
||||
|
||||
$.getJSON('/api/web/profiler/' + id).done (res) -> appendRequest method, url, res
|
||||
|
||||
(this.addEventListener "readystatechange", intercept, false) if url.indexOf('/api/web/profiler/') == -1
|
||||
oldOpen.apply this, arguments
|
12
resources/assets/scripts/embed/favourite.coffee
Normal file
12
resources/assets/scripts/embed/favourite.coffee
Normal file
|
@ -0,0 +1,12 @@
|
|||
$player = $ '.player'
|
||||
$favourite = $player.find '.favourite'
|
||||
trackId = $player.data 'track-id'
|
||||
|
||||
$favourite.click (e) ->
|
||||
e.preventDefault()
|
||||
|
||||
$.post('/api/web/favourites/toggle', {type: 'track', id: trackId, _token: pfm.token}).done (res) ->
|
||||
if res.is_favourited
|
||||
$player.addClass 'favourited'
|
||||
else
|
||||
$player.removeClass 'favourited'
|
82
resources/assets/scripts/embed/player.coffee
Normal file
82
resources/assets/scripts/embed/player.coffee
Normal file
|
@ -0,0 +1,82 @@
|
|||
$('.timeago').timeago()
|
||||
|
||||
loaderDef = new $.Deferred()
|
||||
|
||||
soundManager.setup
|
||||
url: '/flash/soundmanager/'
|
||||
flashVersion: 9
|
||||
onready: () ->
|
||||
loaderDef.resolve()
|
||||
|
||||
loaderDef.done ->
|
||||
$player = $('.player')
|
||||
$play = $('.player .play')
|
||||
$progressBar = $player.find '.progressbar'
|
||||
$loadingBar = $progressBar.find '.loader'
|
||||
$seekBar = $progressBar.find '.seeker'
|
||||
currentSound = null
|
||||
isPlaying = false
|
||||
trackId = $player.data('track-id')
|
||||
duration = $player.data('duration')
|
||||
|
||||
$player.removeClass 'loading'
|
||||
|
||||
setPlaying = (playing) ->
|
||||
isPlaying = playing
|
||||
if playing
|
||||
$player.addClass 'playing'
|
||||
$player.removeClass 'paused'
|
||||
else
|
||||
$player.addClass 'paused'
|
||||
$player.removeClass 'playing'
|
||||
|
||||
$progressBar.click (e) ->
|
||||
return if !currentSound
|
||||
percent = ((e.pageX - $progressBar.offset().left) / $progressBar.width())
|
||||
duration = parseFloat(duration)
|
||||
progress = percent * duration
|
||||
currentSound.setPosition(progress)
|
||||
|
||||
$play.click ->
|
||||
if currentSound
|
||||
if isPlaying
|
||||
currentSound.pause()
|
||||
else
|
||||
currentSound.play()
|
||||
else
|
||||
|
||||
currentSound = soundManager.createSound
|
||||
url: ['/t' + trackId + '/stream.mp3', '/t' + trackId + '/stream.ogg', '/t' + trackId + '/stream.m4a'],
|
||||
volume: 50
|
||||
|
||||
whileloading: ->
|
||||
loadingProgress = (currentSound.bytesLoaded / currentSound.bytesTotal) * 100
|
||||
$loadingBar.css
|
||||
width: loadingProgress + '%'
|
||||
|
||||
whileplaying: ->
|
||||
progress = (currentSound.position / (duration)) * 100
|
||||
$seekBar.css
|
||||
width: progress + '%'
|
||||
|
||||
onfinish: ->
|
||||
setPlaying false
|
||||
currentSound = null
|
||||
$loadingBar.css {width: '0'}
|
||||
$seekBar.css {width: '0'}
|
||||
$player.removeClass 'playing'
|
||||
$player.removeClass 'paused'
|
||||
|
||||
onstop: ->
|
||||
setPlaying false
|
||||
|
||||
onplay: ->
|
||||
|
||||
onresume: ->
|
||||
setPlaying true
|
||||
|
||||
onpause: ->
|
||||
setPlaying false
|
||||
|
||||
setPlaying true
|
||||
currentSound.play()
|
9
resources/assets/scripts/shared/init.coffee
Normal file
9
resources/assets/scripts/shared/init.coffee
Normal file
|
@ -0,0 +1,9 @@
|
|||
def = new $.Deferred()
|
||||
|
||||
pfm.soundManager = def.promise()
|
||||
|
||||
soundManager.setup
|
||||
url: '/flash/soundmanager/'
|
||||
flashVersion: 9
|
||||
onready: () ->
|
||||
def.resolve()
|
14
resources/assets/scripts/shared/jquery-extensions.js
vendored
Normal file
14
resources/assets/scripts/shared/jquery-extensions.js
vendored
Normal file
|
@ -0,0 +1,14 @@
|
|||
if (jQuery.when.all===undefined) {
|
||||
jQuery.when.all = function(deferreds) {
|
||||
var deferred = new jQuery.Deferred();
|
||||
$.when.apply(jQuery, deferreds).then(
|
||||
function() {
|
||||
deferred.resolve(Array.prototype.slice.call(arguments));
|
||||
},
|
||||
function() {
|
||||
deferred.fail(Array.prototype.slice.call(arguments));
|
||||
});
|
||||
|
||||
return deferred;
|
||||
}
|
||||
}
|
38
resources/assets/scripts/shared/layout.coffee
Normal file
38
resources/assets/scripts/shared/layout.coffee
Normal file
|
@ -0,0 +1,38 @@
|
|||
window.handleResize = () ->
|
||||
windowHeight = $(window).height()
|
||||
$siteBody = $ '.site-body'
|
||||
$siteBody.height windowHeight - $('header').height()
|
||||
|
||||
$('.dropdown-menu').each () ->
|
||||
$this = $ this
|
||||
newMaxHeight = windowHeight - $this.parent().offset().top - $this.parent().height() - 5
|
||||
$this.css
|
||||
'max-height': newMaxHeight
|
||||
|
||||
$('.stretch-to-bottom').each () ->
|
||||
$this = $ this
|
||||
newHeight = windowHeight - $this.offset().top
|
||||
if newHeight > 0
|
||||
$this.height newHeight
|
||||
|
||||
$('.revealable').each () ->
|
||||
$this = $ this
|
||||
return if $this.data 'real-height'
|
||||
$this.data 'real-height', $this.height()
|
||||
$this.css
|
||||
height: '15em'
|
||||
|
||||
$this.find('.reveal').click (e) ->
|
||||
e.preventDefault()
|
||||
$this.css {height: 'auto'}
|
||||
$(this).fadeOut 200
|
||||
|
||||
window.alignVertically = (element) ->
|
||||
$element = $(element)
|
||||
$parent = $element.parent()
|
||||
$element.css 'top', $parent.height() / 2 - $element.height() / 2
|
||||
|
||||
window.handleResize()
|
||||
$(window).resize window.handleResize
|
||||
|
||||
$('.site-content').empty()
|
23
resources/assets/scripts/shared/underscore-extensions.js
Normal file
23
resources/assets/scripts/shared/underscore-extensions.js
Normal file
|
@ -0,0 +1,23 @@
|
|||
// save a reference to the core implementation
|
||||
var indexOfValue = _.indexOf;
|
||||
|
||||
// using .mixin allows both wrapped and unwrapped calls:
|
||||
// _(array).indexOf(...) and _.indexOf(array, ...)
|
||||
_.mixin({
|
||||
|
||||
// return the index of the first array element passing a test
|
||||
indexOf: function(array, test) {
|
||||
// delegate to standard indexOf if the test isn't a function
|
||||
if (!_.isFunction(test)) return indexOfValue(array, test);
|
||||
// otherwise, look for the index
|
||||
for (var x = 0; x < array.length; x++) {
|
||||
if (test(array[x])) return x;
|
||||
}
|
||||
// not found, return fail value
|
||||
return -1;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
_.indexOf([1,2,3], 3); // 2
|
||||
_.indexOf([1,2,3], function(el) { return el > 2; } ); // 2
|
0
resources/assets/styles/account-content.less
vendored
Normal file
0
resources/assets/styles/account-content.less
vendored
Normal file
0
resources/assets/styles/animations.less
vendored
Normal file
0
resources/assets/styles/animations.less
vendored
Normal file
0
resources/assets/styles/app.less
vendored
Normal file
0
resources/assets/styles/app.less
vendored
Normal file
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue