Skip to content
This repository was archived by the owner on May 22, 2020. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions ekko-lightbox.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ EkkoLightbox = ( element, options ) ->
$(document).on 'keydown.ekkoLightbox', @navigate.bind(@)

# add the directional arrows to the modal
if @options.directional_arrows
if @options.directional_arrows && @gallery_items.length > 1
@lightbox_container.prepend('<div class="ekko-lightbox-nav-overlay"><a href="#" class="'+@strip_stops(@options.left_arrow_class)+'"></a><a href="#" class="'+@strip_stops(@options.right_arrow_class)+'"></a></div>')
@modal_arrows = @lightbox_container.find('div.ekko-lightbox-nav-overlay').first()
@lightbox_container.find('a'+@strip_spaces(@options.left_arrow_class)).on 'click', (event) =>
Expand Down Expand Up @@ -130,37 +130,41 @@ EkkoLightbox.prototype = {
do @navigate_left

navigate_left: ->


if @gallery_items.length == 1 then return

if @gallery_index == 0 then @gallery_index = @gallery_items.length-1 else @gallery_index-- #circular

@$element = $(@gallery_items.get(@gallery_index))
@updateTitleAndFooter()
src = @$element.attr('data-remote') || @$element.attr('href')

@detectRemoteType(src)
@detectRemoteType(src, @$element.attr('data-type'))

navigate_right: ->


if @gallery_items.length == 1 then return

if @gallery_index == @gallery_items.length-1 then @gallery_index = 0 else @gallery_index++ #circular

@$element = $(@gallery_items.get(@gallery_index))
src = @$element.attr('data-remote') || @$element.attr('href')
@updateTitleAndFooter()

@detectRemoteType(src)
@detectRemoteType(src, @$element.attr('data-type'))

if @gallery_index + 1 < @gallery_items.length
next = $(@gallery_items.get(@gallery_index + 1), false)
src = next.attr('data-remote') || next.attr('href')
if @isImage(src)
if next.attr('data-type') == 'image' || @isImage(src)
@preloadImage(src, false)

detectRemoteType: (src) ->
if @isImage(src)
detectRemoteType: (src, type) ->
if type == 'image' || @isImage(src)
@preloadImage(src, true)
else if video_id = @getYoutubeId(src)
else if type == 'youtube' || video_id = @getYoutubeId(src)
@showYoutubeVideo(video_id)
else if video_id = @getVimeoId(src)
else if type == 'vimeo' || video_id = @getVimeoId(src)
@showVimeoVideo(video_id)
else
@error "Could not detect remote target type. Force the type using data-type=\"image|youtube|vimeo\""
Expand Down