initial commit
This commit is contained in:
commit
399bb961a4
18
.gitignore
vendored
Normal file
18
.gitignore
vendored
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
*.gem
|
||||||
|
*.rbc
|
||||||
|
.bundle
|
||||||
|
.config
|
||||||
|
.yardoc
|
||||||
|
Gemfile.lock
|
||||||
|
InstalledFiles
|
||||||
|
_yardoc
|
||||||
|
coverage
|
||||||
|
doc/
|
||||||
|
lib/bundler/man
|
||||||
|
pkg
|
||||||
|
rdoc
|
||||||
|
spec/reports
|
||||||
|
test/tmp
|
||||||
|
test/version_tmp
|
||||||
|
tmp
|
||||||
|
.DS_Store
|
4
Gemfile
Normal file
4
Gemfile
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
source 'https://rubygems.org'
|
||||||
|
|
||||||
|
# Specify your gem's dependencies in caroufredsel-rails.gemspec
|
||||||
|
gemspec
|
22
LICENSE.txt
Normal file
22
LICENSE.txt
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
Copyright (c) 2012 John Bintz
|
||||||
|
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
a copy of this software and associated documentation files (the
|
||||||
|
"Software"), to deal in the Software without restriction, including
|
||||||
|
without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be
|
||||||
|
included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
34
README.md
Normal file
34
README.md
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
Use [CarouFredSel](http://caroufredsel.frebsite.nl/) with Rails. It's pretty good!
|
||||||
|
|
||||||
|
`Gemfile`:
|
||||||
|
|
||||||
|
``` ruby
|
||||||
|
gem 'caroufredsel-rails', :git => 'git://github.com/johnbintz/caroufredsel-rails.git'
|
||||||
|
```
|
||||||
|
|
||||||
|
`app/assets/javascripts/application.js`:
|
||||||
|
|
||||||
|
``` javascript
|
||||||
|
//= require caroufredsel
|
||||||
|
|
||||||
|
carousel = new Carousel(
|
||||||
|
$('#carousel_items'),
|
||||||
|
{
|
||||||
|
onChange: function(items) {
|
||||||
|
// something when the items change
|
||||||
|
},
|
||||||
|
otherCarouFredSelOptions: 'go here'_
|
||||||
|
}
|
||||||
|
);
|
||||||
|
```
|
||||||
|
|
||||||
|
`Carousel` objects respond to the following:
|
||||||
|
|
||||||
|
* `slideTo(index)`: Slide to the target original index
|
||||||
|
* `moveTo(index)`: Immediately move to the target original index
|
||||||
|
* `pause`: Pause the carousel
|
||||||
|
|
||||||
|
Get at the original carousel with `Carousel#carousel`
|
||||||
|
|
||||||
|
Needs CoffeeScript, 'cause I'm lazy right now!
|
||||||
|
|
21
caroufredsel-rails.gemspec
Normal file
21
caroufredsel-rails.gemspec
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
# -*- encoding: utf-8 -*-
|
||||||
|
lib = File.expand_path('../lib', __FILE__)
|
||||||
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
||||||
|
require 'caroufredsel-rails/version'
|
||||||
|
|
||||||
|
Gem::Specification.new do |gem|
|
||||||
|
gem.name = "caroufredsel-rails"
|
||||||
|
gem.version = Caroufredsel::Rails::VERSION
|
||||||
|
gem.authors = ["John Bintz"]
|
||||||
|
gem.email = ["john@coswellproductions.com"]
|
||||||
|
gem.description = %q{TODO: Write a gem description}
|
||||||
|
gem.summary = %q{TODO: Write a gem summary}
|
||||||
|
gem.homepage = ""
|
||||||
|
|
||||||
|
gem.files = `git ls-files`.split($/)
|
||||||
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
||||||
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
||||||
|
gem.require_paths = ["lib"]
|
||||||
|
|
||||||
|
gem.add_dependency 'coffee-script'
|
||||||
|
end
|
33
lib/assets/javascripts/caroufredsel.js.coffee
Normal file
33
lib/assets/javascripts/caroufredsel.js.coffee
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
#= require jquery
|
||||||
|
#= require caroufredsel/jquery.mousewheel.min
|
||||||
|
#= require caroufredsel/jquery.touchSwipe.min
|
||||||
|
#= require caroufredsel/jquery.carouFredSel-6.0.3
|
||||||
|
|
||||||
|
class @Carousel
|
||||||
|
constructor: (@carousel, options) ->
|
||||||
|
if options.onChange
|
||||||
|
@onChange = options.onChange
|
||||||
|
delete options.onChange
|
||||||
|
|
||||||
|
options.scroll ||= {}
|
||||||
|
options.scroll.onBefore = (args) =>
|
||||||
|
@onChange($(args.items.new[0]))
|
||||||
|
|
||||||
|
@carousel.carouFredSel(options)
|
||||||
|
@onChange($(@carousel.children()[0]))
|
||||||
|
|
||||||
|
slideTo: (index, options = {}) =>
|
||||||
|
@carousel.trigger('slideTo', index, true, options)
|
||||||
|
this
|
||||||
|
|
||||||
|
moveTo: (index) =>
|
||||||
|
@slideTo(index, duration: 0)
|
||||||
|
this
|
||||||
|
|
||||||
|
pause: =>
|
||||||
|
@carousel.trigger('pause')
|
||||||
|
this
|
||||||
|
|
||||||
|
onChange: (item) ->
|
||||||
|
null
|
||||||
|
|
2
lib/caroufredsel-rails.rb
Normal file
2
lib/caroufredsel-rails.rb
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
require "caroufredsel-rails/version"
|
||||||
|
require 'caroufredsel-rails/engine' if defined?(Rails::Engine)
|
5
lib/caroufredsel-rails/engine.rb
Normal file
5
lib/caroufredsel-rails/engine.rb
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
module Caroufredsel
|
||||||
|
class Engine < ::Rails::Engine
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
5
lib/caroufredsel-rails/version.rb
Normal file
5
lib/caroufredsel-rails/version.rb
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
module Caroufredsel
|
||||||
|
module Rails
|
||||||
|
VERSION = "0.0.1"
|
||||||
|
end
|
||||||
|
end
|
4284
vendor/assets/javascripts/caroufredsel/jquery.carouFredSel-6.0.3.js
vendored
Normal file
4284
vendor/assets/javascripts/caroufredsel/jquery.carouFredSel-6.0.3.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
12
vendor/assets/javascripts/caroufredsel/jquery.mousewheel.min.js
vendored
Normal file
12
vendor/assets/javascripts/caroufredsel/jquery.mousewheel.min.js
vendored
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
/*! Copyright (c) 2011 Brandon Aaron (http://brandonaaron.net)
|
||||||
|
* Licensed under the MIT License (LICENSE.txt).
|
||||||
|
*
|
||||||
|
* Thanks to: http://adomas.org/javascript-mouse-wheel/ for some pointers.
|
||||||
|
* Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix.
|
||||||
|
* Thanks to: Seamus Leahy for adding deltaX and deltaY
|
||||||
|
*
|
||||||
|
* Version: 3.0.6
|
||||||
|
*
|
||||||
|
* Requires: 1.2.2+
|
||||||
|
*/
|
||||||
|
(function(a){function d(b){var c=b||window.event,d=[].slice.call(arguments,1),e=0,f=!0,g=0,h=0;return b=a.event.fix(c),b.type="mousewheel",c.wheelDelta&&(e=c.wheelDelta/120),c.detail&&(e=-c.detail/3),h=e,c.axis!==undefined&&c.axis===c.HORIZONTAL_AXIS&&(h=0,g=-1*e),c.wheelDeltaY!==undefined&&(h=c.wheelDeltaY/120),c.wheelDeltaX!==undefined&&(g=-1*c.wheelDeltaX/120),d.unshift(b,e,g,h),(a.event.dispatch||a.event.handle).apply(this,d)}var b=["DOMMouseScroll","mousewheel"];if(a.event.fixHooks)for(var c=b.length;c;)a.event.fixHooks[b[--c]]=a.event.mouseHooks;a.event.special.mousewheel={setup:function(){if(this.addEventListener)for(var a=b.length;a;)this.addEventListener(b[--a],d,!1);else this.onmousewheel=d},teardown:function(){if(this.removeEventListener)for(var a=b.length;a;)this.removeEventListener(b[--a],d,!1);else this.onmousewheel=null}},a.fn.extend({mousewheel:function(a){return a?this.bind("mousewheel",a):this.trigger("mousewheel")},unmousewheel:function(a){return this.unbind("mousewheel",a)}})})(jQuery)
|
13
vendor/assets/javascripts/caroufredsel/jquery.touchSwipe.min.js
vendored
Executable file
13
vendor/assets/javascripts/caroufredsel/jquery.touchSwipe.min.js
vendored
Executable file
@ -0,0 +1,13 @@
|
|||||||
|
/*
|
||||||
|
* touchSwipe - jQuery Plugin
|
||||||
|
* https://github.com/mattbryson/TouchSwipe-Jquery-Plugin
|
||||||
|
* http://labs.skinkers.com/touchSwipe/
|
||||||
|
* http://plugins.jquery.com/project/touchSwipe
|
||||||
|
*
|
||||||
|
* Copyright (c) 2010 Matt Bryson (www.skinkers.com)
|
||||||
|
* Dual licensed under the MIT or GPL Version 2 licenses.
|
||||||
|
*
|
||||||
|
* $version: 1.3.3
|
||||||
|
*/
|
||||||
|
|
||||||
|
(function(g){function P(c){if(c&&void 0===c.allowPageScroll&&(void 0!==c.swipe||void 0!==c.swipeStatus))c.allowPageScroll=G;c||(c={});c=g.extend({},g.fn.swipe.defaults,c);return this.each(function(){var b=g(this),f=b.data(w);f||(f=new W(this,c),b.data(w,f))})}function W(c,b){var f,p,r,s;function H(a){var a=a.originalEvent,c,Q=n?a.touches[0]:a;d=R;n?h=a.touches.length:a.preventDefault();i=0;j=null;k=0;!n||h===b.fingers||b.fingers===x?(r=f=Q.pageX,s=p=Q.pageY,y=(new Date).getTime(),b.swipeStatus&&(c= l(a,d))):t(a);if(!1===c)return d=m,l(a,d),c;e.bind(I,J);e.bind(K,L)}function J(a){a=a.originalEvent;if(!(d===q||d===m)){var c,e=n?a.touches[0]:a;f=e.pageX;p=e.pageY;u=(new Date).getTime();j=S();n&&(h=a.touches.length);d=z;var e=a,g=j;if(b.allowPageScroll===G)e.preventDefault();else{var o=b.allowPageScroll===T;switch(g){case v:(b.swipeLeft&&o||!o&&b.allowPageScroll!=M)&&e.preventDefault();break;case A:(b.swipeRight&&o||!o&&b.allowPageScroll!=M)&&e.preventDefault();break;case B:(b.swipeUp&&o||!o&&b.allowPageScroll!= N)&&e.preventDefault();break;case C:(b.swipeDown&&o||!o&&b.allowPageScroll!=N)&&e.preventDefault()}}h===b.fingers||b.fingers===x||!n?(i=U(),k=u-y,b.swipeStatus&&(c=l(a,d,j,i,k)),b.triggerOnTouchEnd||(e=!(b.maxTimeThreshold?!(k>=b.maxTimeThreshold):1),!0===D()?(d=q,c=l(a,d)):e&&(d=m,l(a,d)))):(d=m,l(a,d));!1===c&&(d=m,l(a,d))}}function L(a){a=a.originalEvent;a.preventDefault();u=(new Date).getTime();i=U();j=S();k=u-y;if(b.triggerOnTouchEnd||!1===b.triggerOnTouchEnd&&d===z)if(d=q,(h===b.fingers||b.fingers=== x||!n)&&0!==f){var c=!(b.maxTimeThreshold?!(k>=b.maxTimeThreshold):1);if((!0===D()||null===D())&&!c)l(a,d);else if(c||!1===D())d=m,l(a,d)}else d=m,l(a,d);else d===z&&(d=m,l(a,d));e.unbind(I,J,!1);e.unbind(K,L,!1)}function t(){y=u=p=f=s=r=h=0}function l(a,c){var d=void 0;b.swipeStatus&&(d=b.swipeStatus.call(e,a,c,j||null,i||0,k||0,h));if(c===m&&b.click&&(1===h||!n)&&(isNaN(i)||0===i))d=b.click.call(e,a,a.target);if(c==q)switch(b.swipe&&(d=b.swipe.call(e,a,j,i,k,h)),j){case v:b.swipeLeft&&(d=b.swipeLeft.call(e, a,j,i,k,h));break;case A:b.swipeRight&&(d=b.swipeRight.call(e,a,j,i,k,h));break;case B:b.swipeUp&&(d=b.swipeUp.call(e,a,j,i,k,h));break;case C:b.swipeDown&&(d=b.swipeDown.call(e,a,j,i,k,h))}(c===m||c===q)&&t(a);return d}function D(){return null!==b.threshold?i>=b.threshold:null}function U(){return Math.round(Math.sqrt(Math.pow(f-r,2)+Math.pow(p-s,2)))}function S(){var a;a=Math.atan2(p-s,r-f);a=Math.round(180*a/Math.PI);0>a&&(a=360-Math.abs(a));return 45>=a&&0<=a?v:360>=a&&315<=a?v:135<=a&&225>=a? A:45<a&&135>a?C:B}function V(){e.unbind(E,H);e.unbind(F,t);e.unbind(I,J);e.unbind(K,L)}var O=n||!b.fallbackToMouseEvents,E=O?"touchstart":"mousedown",I=O?"touchmove":"mousemove",K=O?"touchend":"mouseup",F="touchcancel",i=0,j=null,k=0,e=g(c),d="start",h=0,y=p=f=s=r=0,u=0;try{e.bind(E,H),e.bind(F,t)}catch(P){g.error("events not supported "+E+","+F+" on jQuery.swipe")}this.enable=function(){e.bind(E,H);e.bind(F,t);return e};this.disable=function(){V();return e};this.destroy=function(){V();e.data(w,null); return e}}var v="left",A="right",B="up",C="down",G="none",T="auto",M="horizontal",N="vertical",x="all",R="start",z="move",q="end",m="cancel",n="ontouchstart"in window,w="TouchSwipe";g.fn.swipe=function(c){var b=g(this),f=b.data(w);if(f&&"string"===typeof c){if(f[c])return f[c].apply(this,Array.prototype.slice.call(arguments,1));g.error("Method "+c+" does not exist on jQuery.swipe")}else if(!f&&("object"===typeof c||!c))return P.apply(this,arguments);return b};g.fn.swipe.defaults={fingers:1,threshold:75, maxTimeThreshold:null,swipe:null,swipeLeft:null,swipeRight:null,swipeUp:null,swipeDown:null,swipeStatus:null,click:null,triggerOnTouchEnd:!0,allowPageScroll:"auto",fallbackToMouseEvents:!0};g.fn.swipe.phases={PHASE_START:R,PHASE_MOVE:z,PHASE_END:q,PHASE_CANCEL:m};g.fn.swipe.directions={LEFT:v,RIGHT:A,UP:B,DOWN:C};g.fn.swipe.pageScroll={NONE:G,HORIZONTAL:M,VERTICAL:N,AUTO:T};g.fn.swipe.fingers={ONE:1,TWO:2,THREE:3,ALL:x}})(jQuery);
|
Loading…
Reference in New Issue
Block a user