forked from External/greenlight
		
	Fix clicking buttons inside popovers
They would work only occasionally because of the way bootstrap handles popovers with trigger:focus. Had to change to trigger:click and manually close the popovers when clicking outside of them or in buttons marked to close popovers.
This commit is contained in:
		@@ -106,10 +106,12 @@ class @Recordings
 | 
				
			|||||||
      @getTable().api().clear().draw().destroy()
 | 
					      @getTable().api().clear().draw().destroy()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # enable popovers
 | 
					    # enable popovers
 | 
				
			||||||
 | 
					    # can't use trigger:'focus' because it doesn't work will with buttons inside
 | 
				
			||||||
 | 
					    # the popover
 | 
				
			||||||
    options = {
 | 
					    options = {
 | 
				
			||||||
      selector: '.has-popover',
 | 
					      selector: '.has-popover',
 | 
				
			||||||
      html: true,
 | 
					      html: true,
 | 
				
			||||||
      trigger: 'focus',
 | 
					      trigger: 'click',
 | 
				
			||||||
      title: ->
 | 
					      title: ->
 | 
				
			||||||
        return $(this).data("popover-title");
 | 
					        return $(this).data("popover-title");
 | 
				
			||||||
      content: ->
 | 
					      content: ->
 | 
				
			||||||
@@ -118,6 +120,19 @@ class @Recordings
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
    $('#recordings').popover(options)
 | 
					    $('#recordings').popover(options)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    # close popovers manually when clicking outside of them or in buttons
 | 
				
			||||||
 | 
					    # with [data-dismiss="popover"]
 | 
				
			||||||
 | 
					    # careful to hide only the open popover and not all of them, otherwise they won't reopen
 | 
				
			||||||
 | 
					    $('body').on 'click', (e) ->
 | 
				
			||||||
 | 
					      $('.has-popover').each ->
 | 
				
			||||||
 | 
					        if !$(this).is(e.target) and $(this).has(e.target).length == 0 and $('.popover.in').has(e.target).length == 0
 | 
				
			||||||
 | 
					          if $(this).next(".popover.in").length > 0
 | 
				
			||||||
 | 
					            $(this).popover('hide')
 | 
				
			||||||
 | 
					    $(document).on 'click', '[data-dismiss="popover"]', (e) ->
 | 
				
			||||||
 | 
					      $('.has-popover').each ->
 | 
				
			||||||
 | 
					        if $(this).next(".popover.in").length > 0
 | 
				
			||||||
 | 
					          $(this).popover('hide')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  # Gets the current instance or creates a new one
 | 
					  # Gets the current instance or creates a new one
 | 
				
			||||||
  @getInstance: ->
 | 
					  @getInstance: ->
 | 
				
			||||||
    if _recordingsInstance && Recordings.initialized()
 | 
					    if _recordingsInstance && Recordings.initialized()
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -43,10 +43,10 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
<div hidden class="hidden-elements">
 | 
					<div hidden class="hidden-elements">
 | 
				
			||||||
  <div class="delete-popover-body">
 | 
					  <div class="delete-popover-body">
 | 
				
			||||||
    <button type="button" class="btn btn-danger recording-delete">
 | 
					    <button type="button" class="btn btn-danger recording-delete" data-dismiss="popover">
 | 
				
			||||||
      <%= t('yes') %>
 | 
					      <%= t('yes') %>
 | 
				
			||||||
    </button>
 | 
					    </button>
 | 
				
			||||||
    <button type="button" class="btn btn-default">
 | 
					    <button type="button" class="btn btn-default" data-dismiss="popover">
 | 
				
			||||||
      <%= t('no') %>
 | 
					      <%= t('no') %>
 | 
				
			||||||
    </button>
 | 
					    </button>
 | 
				
			||||||
  </div>
 | 
					  </div>
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user