Skip to content
This repository has been archived by the owner on Nov 18, 2024. It is now read-only.

User pagination #581

Open
wants to merge 3 commits into
base: SlidesJS-3
Choose a base branch
from
Open
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
74 changes: 47 additions & 27 deletions source/jquery.slides.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,12 @@
# Pagination settings
active: true
# [boolean] Create pagination items.
# You cannot use your own pagination.
effect: "slide"
# [string] Can be either "slide" or "fade".
generate: true
# [boolean] Generate pagination nav. If false, search for a
# ul.slidesjs-navigation.slidesjs-pagination > li > a
# structure.
play:
# Play and stop button setting.
active: false
Expand Down Expand Up @@ -232,31 +235,48 @@


if @options.pagination.active
# Create unordered list pagination
pagination = $("<ul>"
class: "slidesjs-pagination"
).appendTo($element)

# Create a list item and anchor for each slide
$.each(new Array(@data.total), (i) =>
paginationItem = $("<li>"
class: "slidesjs-pagination-item"
).appendTo(pagination)

paginationLink = $("<a>"
href: "#"
"data-slidesjs-item": i
html: i + 1
).appendTo(paginationItem)

# bind click events
paginationLink.click (e) =>
e.preventDefault()
# Stop play
@stop(true)
# Goto to selected slide
@goto( ($(e.currentTarget).attr("data-slidesjs-item") * 1) + 1 )
)

if @options.pagination.generate
# Create unordered list pagination
pagination = $("<ul>"
class: "slidesjs-pagination"
).appendTo($element)

# Create a list item and anchor for each slide
$.each(new Array(@data.total), (i) =>
paginationItem = $("<li>"
class: "slidesjs-pagination-item"
).appendTo(pagination)

paginationLink = $("<a>"
href: "#"
"data-slidesjs-item": i
html: i + 1
).appendTo(paginationItem)

# bind click events
paginationLink.click (e) =>
e.preventDefault()
# Stop play
@stop(true)
# Goto to selected slide
@goto( ($(e.currentTarget).attr("data-slidesjs-item") * 1) + 1 )
)
else
paginationLIs = $('.slidesjs-pagination li', $element)

paginationLIs.each (i) =>

# For each link already there, add the index
paginationLIs.eq(i)
.data("slidesjs-item", i)
# and bind click events
.click (e) =>
e.preventDefault()
# Stop play
@stop(true)
# Goto to selected slide
@goto( ($(e.currentTarget).data("slidesjs-item") * 1) + 1 )

# Bind update on browser resize
$(window).bind("resize", () =>
Expand Down Expand Up @@ -516,7 +536,7 @@
# Stop/pause slideshow on mouse enter
slidesContainer.bind "mouseenter", =>
clearTimeout @data.restartDelay
$.data this, "restartDelay", null
$.data this, "restartDelay", null
@stop()

# Play slideshow on mouse leave
Expand Down