mirror of
https://github.com/Poniverse/Pony.fm.git
synced 2024-11-28 23:57:59 +01:00
#1: IT'S ALIVE!
This commit is contained in:
parent
6b5d3f67a3
commit
8960d11869
4 changed files with 30 additions and 22 deletions
|
@ -1,7 +1,7 @@
|
|||
<div class="search" ng-blur="searchInProgress = false">
|
||||
<input class="search-input" type="text" placeholder="Search…" ng-model="searchQuery" ng-keyup="quickSearch()" pfm-popup="search-results" />
|
||||
<input class="search-input" type="text" placeholder="Search…" ng-model="searchQuery" pfm-popup="search-results" />
|
||||
|
||||
<div class="search-results pfm-popup" id="search-results" ng-show="searchInProgress">
|
||||
<div class="search-results pfm-popup" id="search-results">
|
||||
<h3 class="-section-header">Matching tracks</h3>
|
||||
<pfm-tracks-list tracks="tracks"></pfm-tracks-list>
|
||||
|
||||
|
|
|
@ -29,10 +29,11 @@ angular.module('ponyfm').directive 'pfmPopup', () ->
|
|||
open = false
|
||||
|
||||
|
||||
documentClickHandler = () ->
|
||||
documentClickHandler = (event) ->
|
||||
return if !open
|
||||
$popup.removeClass 'open'
|
||||
open = false
|
||||
return true
|
||||
|
||||
calculatePosition = ->
|
||||
$popup.parents().each () ->
|
||||
|
@ -79,7 +80,7 @@ angular.module('ponyfm').directive 'pfmPopup', () ->
|
|||
e.preventDefault()
|
||||
e.stopPropagation()
|
||||
|
||||
if open
|
||||
if open and not $element.is(':focus')
|
||||
open = false
|
||||
$popup.removeClass 'open'
|
||||
return
|
||||
|
|
|
@ -24,7 +24,7 @@ angular.module('ponyfm').directive 'pfmSearch', () ->
|
|||
controller: [
|
||||
'$scope', 'search'
|
||||
($scope, search) ->
|
||||
$scope.searchQuery = null
|
||||
$scope.searchQuery = ''
|
||||
$scope.searchInProgress = false
|
||||
|
||||
$scope.tracks = []
|
||||
|
@ -33,17 +33,21 @@ angular.module('ponyfm').directive 'pfmSearch', () ->
|
|||
$scope.users = []
|
||||
|
||||
clearResults = ()->
|
||||
$scope.tracks = []
|
||||
$scope.albums = []
|
||||
$scope.playlists = []
|
||||
$scope.users = []
|
||||
$scope.tracks.length = 0
|
||||
$scope.albums.length = 0
|
||||
$scope.playlists.length = 0
|
||||
$scope.users.length = 0
|
||||
|
||||
$scope.quickSearch = ()->
|
||||
|
||||
$scope.$watch 'searchQuery', _.debounce((searchQuery)->
|
||||
$scope.$apply ()->
|
||||
clearResults()
|
||||
return if searchQuery.length <3
|
||||
|
||||
$scope.searchInProgress = true
|
||||
|
||||
search.searchAllContent($scope.searchQuery)
|
||||
.done (results)->
|
||||
search.searchAllContent(searchQuery)
|
||||
.then (results)->
|
||||
for track in results.tracks
|
||||
$scope.tracks.push(track)
|
||||
|
||||
|
@ -55,5 +59,5 @@ angular.module('ponyfm').directive 'pfmSearch', () ->
|
|||
|
||||
for user in results.users
|
||||
$scope.users.push(user)
|
||||
|
||||
, 500)
|
||||
]
|
||||
|
|
|
@ -26,6 +26,9 @@ angular.module('ponyfm').factory('search', [
|
|||
.success (results)->
|
||||
searchDef.resolve(results.results)
|
||||
|
||||
.error (response)->
|
||||
searchDef.reject(response)
|
||||
|
||||
searchDef.promise()
|
||||
|
||||
self
|
||||
|
|
Loading…
Reference in a new issue