mirror of
https://github.com/Poniverse/Pony.fm.git
synced 2025-02-07 06:16:43 +01:00
#1: Progress commit - the search popup now responds to clicks correctly!
This commit is contained in:
parent
8960d11869
commit
ffca74f45d
2 changed files with 32 additions and 5 deletions
|
@ -1,5 +1,12 @@
|
|||
<div class="search" ng-blur="searchInProgress = false">
|
||||
<input class="search-input" type="text" placeholder="Search…" ng-model="searchQuery" pfm-popup="search-results" />
|
||||
<input
|
||||
class="search-input"
|
||||
type="text"
|
||||
placeholder="Search…"
|
||||
ng-model="searchQuery"
|
||||
pfm-popup="search-results"
|
||||
pfm-popup-close-on-click
|
||||
/>
|
||||
|
||||
<div class="search-results pfm-popup" id="search-results">
|
||||
<h3 class="-section-header">Matching tracks</h3>
|
||||
|
|
|
@ -27,14 +27,29 @@ angular.module('ponyfm').directive 'pfmPopup', () ->
|
|||
$element = $ element
|
||||
$positionParent = null
|
||||
open = false
|
||||
dontCloseOnClick = attrs.pfmPopupCloseOnClick?
|
||||
|
||||
|
||||
close = () ->
|
||||
$popup.removeClass 'open'
|
||||
open = false
|
||||
|
||||
|
||||
documentClickHandler = (event) ->
|
||||
console.log(event)
|
||||
debugger
|
||||
return if !open
|
||||
$popup.removeClass 'open'
|
||||
open = false
|
||||
|
||||
if (dontCloseOnClick and
|
||||
(event.target.id == elementId or
|
||||
$(event.target).parents("##{elementId}").size())
|
||||
)
|
||||
return true
|
||||
|
||||
close()
|
||||
return true
|
||||
|
||||
|
||||
calculatePosition = ->
|
||||
$popup.parents().each () ->
|
||||
$this = $ this
|
||||
|
@ -64,6 +79,7 @@ angular.module('ponyfm').directive 'pfmPopup', () ->
|
|||
top: top - parentPosition.top,
|
||||
height: height - 15}
|
||||
|
||||
|
||||
windowResizeHandler = () ->
|
||||
return if !open
|
||||
$popup.css 'height', 'auto'
|
||||
|
@ -81,8 +97,7 @@ angular.module('ponyfm').directive 'pfmPopup', () ->
|
|||
e.stopPropagation()
|
||||
|
||||
if open and not $element.is(':focus')
|
||||
open = false
|
||||
$popup.removeClass 'open'
|
||||
close
|
||||
return
|
||||
|
||||
$popup.addClass 'open'
|
||||
|
@ -98,6 +113,11 @@ angular.module('ponyfm').directive 'pfmPopup', () ->
|
|||
open = true
|
||||
), 0
|
||||
|
||||
|
||||
scope.$on '$stateChangeStart', () ->
|
||||
close()
|
||||
|
||||
|
||||
scope.$on '$destroy', () ->
|
||||
$(document.body).unbind 'click', documentClickHandler
|
||||
$(window).unbind 'click', windowResizeHandler
|
||||
|
|
Loading…
Reference in a new issue