# SlidesJS 3.0.4 # Documentation and examples http://slidesjs.com # Support forum http://groups.google.com/group/slidesjs # Created by Nathan Searles http://nathansearles.com # Version: 3.0.4 # Updated: June 26th, 2013 # SlidesJS is an open source project, contribute at GitHub: # https://github.com/nathansearles/Slides # (c) 2013 by Nathan Searles # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # http://www.apache.org/licenses/LICENSE-2.0 # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. (($, window, document) -> pluginName = "slidesjs" defaults = width: 940 # Set the default width of the slideshow. height: 528 # Set the default height of the slideshow. start: 1 # Set the first slide in the slideshow. navigation: # Next and previous button settings. active: true # [boolean] Create next and previous buttons. # You can set to false and use your own next/prev buttons. # User defined next/prev buttons must have the following: # previous: class="slidesjs-previous slidesjs-navigation" # next: class="slidesjs-next slidesjs-navigation" effect: "slide" # [string] Can be either "slide" or "fade". pagination: # Pagination settings active: true # [boolean] Create pagination items. # You cannot use your own pagination. effect: "slide" # [string] Can be either "slide" or "fade". play: # Play and stop button setting. active: false # [boolean] Create the play and stop buttons. # You cannot use your own pagination. effect: "slide" # [string] Can be either "slide" or "fade". interval: 5000 # [number] Time spent on each slide in milliseconds. auto: false # [boolean] Start playing the slideshow on load swap: true # [boolean] show/hide stop and play buttons pauseOnHover: false # [boolean] pause a playing slideshow on hover restartDelay: 2500 # [number] restart delay on an inactive slideshow effect: slide: # Slide effect settings. speed: 500 # [number] Speed in milliseconds of the slide animation. fade: speed: 300 # [number] Speed in milliseconds of the fade animation. crossfade: true # [boolean] Cross-fade the transition callback: loaded: () -> # [function] Called when slides is loaded start: () -> # [function] Called when animation has started complete: () -> # [function] Called when animation is complete class Plugin constructor: (@element, options) -> @options = $.extend true, {}, defaults, options @_defaults = defaults @_name = pluginName @init() Plugin::init = -> $element = $(@element) @data = $.data this # Set data $.data this, "animating", false $.data this, "total", $element.children().not(".slidesjs-navigation", $element).length $.data this, "current", @options.start - 1 $.data this, "vendorPrefix", @_getVendorPrefix() # Detect touch device if typeof TouchEvent != "undefined" $.data this, "touch", true # Set slide speed to half for touch @options.effect.slide.speed = this.options.effect.slide.speed / 2 # Hide overflow $element.css overflow: "hidden" # Create container $element.slidesContainer = $element.children().not(".slidesjs-navigation", $element).wrapAll("
", $element).parent().css overflow: "hidden" position: "relative" # Create control div $(".slidesjs-container", $element) .wrapInner("
", $element) .children() # Setup control div $(".slidesjs-control", $element) .css position: "relative" left: 0 # Setup slides $(".slidesjs-control", $element) .children() .addClass("slidesjs-slide") .css position: "absolute" top: 0 left: 0 width: "100%" zIndex: 0 display: "none" webkitBackfaceVisibility: "hidden" # Assign an index to each slide $.each( $(".slidesjs-control", $element).children(), (i) -> $slide = $(this) $slide.attr("slidesjs-index", i) ) if @data.touch # Bind touch events, if supported $(".slidesjs-control", $element).on("touchstart", (e) => @_touchstart(e) ) $(".slidesjs-control", $element).on("touchmove", (e) => @_touchmove(e) ) $(".slidesjs-control", $element).on("touchend", (e) => @_touchend(e) ) # Fades in slideshow, your slideshow ID must be display:none in your CSS $element.fadeIn 0 # Update sets width/height of slideshow @update() # If touch device setup next slides @_setuptouch() if @data.touch # Fade in start slide $(".slidesjs-control", $element) .children(":eq(" + @data.current + ")") .eq(0) .fadeIn 0, -> $(this).css zIndex: 10 if @options.navigation.active # Create next/prev buttons prevButton = $("" class: "slidesjs-previous slidesjs-navigation" href: "#" title: "Previous" text: "Previous" ).appendTo($element) nextButton = $("" class: "slidesjs-next slidesjs-navigation" href: "#" title: "Next" text: "Next" ).appendTo($element) # bind click events $(".slidesjs-next", $element).click (e) => e.preventDefault() @stop(true) @next(@options.navigation.effect) $(".slidesjs-previous", $element).click (e) => e.preventDefault() @stop(true) @previous(@options.navigation.effect) if @options.play.active playButton = $("", class: "slidesjs-play slidesjs-navigation" href: "#" title: "Play" text: "Play" ).appendTo($element) stopButton = $("", class: "slidesjs-stop slidesjs-navigation" href: "#" title: "Stop" text: "Stop" ).appendTo($element) playButton.click (e) => e.preventDefault() @play(true) stopButton.click (e) => e.preventDefault() @stop(true) if @options.play.swap stopButton.css display: "none" if @options.pagination.active # Create unordered list pagination pagination = $("