Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Grunt cleanup; breaking out and concat-ing JavaScript files.

  • Loading branch information...
commit a5360b0f9084a31d93f4f907c1d61c9c330d5886 1 parent f5723e7
@Wilto Wilto authored
View
4 demo/index.html
@@ -6,7 +6,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Revolver Demo</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
- <link rel="stylesheet" href="../src/Revolver.css">
+ <link rel="stylesheet" href="../dist/Revolver.min.css">
<style>
.wrap {
@@ -24,6 +24,6 @@
</figcaption>
</figure>
<script src="../libs/jquery/jquery.js"></script>
- <script src="../src/Revolver.js"></script>
+ <script src="../dist/Revolver.js"></script>
</body>
</html>
View
19 dist/Revolver.js
@@ -1,4 +1,4 @@
-/*! Revolver - v0.1.0 - 2012-09-12
+/*! Revolver - v0.1.0 - 2012-09-13
* https://github.com/filamentgroup/Revolver
* Copyright (c) 2012 Mat Marquis; Licensed MIT */
@@ -69,16 +69,7 @@
} );
}(jQuery));
-
-/*
- * responsive-carousel touch drag extension
- * https://github.com/filamentgroup/responsive-carousel
- *
- * Copyright (c) 2012 Filament Group, Inc.
- * Licensed under the MIT, GPL licenses.
- */
-
- (function($) {
+(function($) {
var pluginName = "revolver",
initSelector = "." + pluginName,
noTrans = pluginName + "-no-transition",
@@ -94,7 +85,7 @@
$elem = $( e.target ).closest( initSelector );
if( e.type === "touchstart" ){
- origin = {
+ origin = {
x : touches[ 0 ].pageX,
y: touches[ 0 ].pageY
};
@@ -145,6 +136,7 @@
}(jQuery));
+
(function($) {
var pluginName = "revolver",
initSelector = "." + pluginName,
@@ -225,5 +217,4 @@
var $el = $( e.target );
} );
-}(jQuery));
-
+}(jQuery));
View
2  dist/Revolver.min.css
@@ -1,4 +1,4 @@
-/*! Revolver - v0.1.0 - 2012-09-12
+/*! Revolver - v0.1.0 - 2012-09-13
* https://github.com/filamentgroup/Revolver
* Copyright (c) 2012 Mat Marquis; Licensed MIT */
.revolver{position:relative;width:100%;height:100%;overflow:hidden}.revolver{width:100%;position:relative}.revolver .revolver-item{display:none;border-width:0 1px;width:1000px!important;max-width:9999px!important;width:auto!important}.revolver .revolver-active{display:block}.revolver-slide{position:relative;overflow:hidden;-webkit-transform:translate3d(0,0,0);-moz-transform:translate3d(0,0,0);-ms-transform:translate3d(0,0,0);-o-transform:translate3d(0,0,0);transform:translate3d(0,0,0)}.revolver-slide .revolver-item{position:absolute;left:100%;top:0;width:100%;display:block;z-index:1}.revolver-no-transition .revolver-item{-webkit-transition:none;-moz-transition:none;-ms-transition:none;-o-transition:none;transition:none}.revolver-slide .revolver-active{left:0;position:relative;z-index:2}.revolver-slide .revolver-in{left:0}.revolver-slide-reverse .revolver-out{left:100%}.revolver-slide .revolver-out,.revolver-slide-reverse .revolver-item,.revolver-slide-reverse .revolver-in{left:-100%}.revolver-slide-reverse .revolver-active{left:0}.fadeout{-webkit-transition:opacity .25s ease-out;-moz-transition:opacity .25s ease-out;transition:opacity .25s ease-out;opacity:0}
View
2  dist/Revolver.min.js
@@ -1,4 +1,4 @@
-/*! Revolver - v0.1.0 - 2012-09-12
+/*! Revolver - v0.1.0 - 2012-09-13
* https://github.com/filamentgroup/Revolver
* Copyright (c) 2012 Mat Marquis; Licensed MIT */
(function(a){var b="revolver",c="."+b,d=b+"-item",e=b+"-active",f={_create:function(){return a(this).each(function(){var c=a(this).data("init");if(c)return!1;a(this).data("init",!0).trigger("beforecreate."+b)[b]("_init").trigger("create."+b)})},_init:function(){var c=a(this).find("img").clone();return a(this).addClass(b+" "+b+"-slide ").append(c).children().addClass(d).first().addClass(e)},_destroy:function(){}};a.fn[b]=function(c,d,e,f){return this.each(function(){if(c&&typeof c=="string")return a.fn[b].prototype[c].call(this,d,e,f);if(a(this).data(b+"data"))return a(this);a(this).data(b+"active",!0),a.fn[b].prototype._create.call(this)})},a.extend(a.fn[b].prototype,f),a(function(){a(c)[b]()})})(jQuery),function(a){var b="revolver",c="."+b,d=b+"-no-transition",e={_dragBehavior:function(){var b,e={},f,g,h,i=function(d){var f=d.touches||d.originalEvent.touches,g=a(d.target).closest(c);return d.type==="touchstart"&&(b={x:f[0].pageX,y:f[0].pageY}),f[0]&&f[0].pageX&&(e.touches=f,e.deltaX=f[0].pageX-b.x,e.deltaY=f[0].pageY-b.y,e.w=g.first().width(),e.h=g.first().height(),e.xPercent=e.deltaX/e.w,e.yPercent=e.deltaY/e.h,e.srcEvent=d),g.trigger("drag"+d.type.split("touch")[1],e),e};a(this).bind("touchstart",function(b){a(this).addClass(d),i(b)}).bind("touchmove",function(a){var b=i(a);if(Math.abs(b.deltaX)>35&&Math.abs(b.deltaY)<35&&b.touches.length===1)return!1;a.stopPropagation()}).bind("touchend",function(b){a(this).removeClass(d),i(b)})}};a.extend(a.fn[b].prototype,e),a(c).live("create."+b,function(){a(this)[b]("_dragBehavior")})}(jQuery),function(a){var b="revolver",c="."+b,d=b+"-active",e=b+"-item",f,g,h,i,j=function(b){var c={};b.type==="mousedown"&&(g=!0,h={x:b.pageX,e:b},c.srcEvent=h.e,b.preventDefault()),(b.type==="mousedown"||b.type==="mousemove")&&g&&(c.deltaX=b.pageX-h.x,c.srcEvent=h.e,b.type==="mousemove"&&(c.moveEvent=b),a(this).trigger("dragmove",[c])),b.type==="mouseup"&&(g=!1)},k=function(b,c){var d=a(c.srcEvent.target),f=d.prevAll().length+1,g=c.deltaX<0,h=f+(g?1:-1),i=b.find("."+e),j=i.eq(h-1);return j.length||(j=i[g?"first":"last"]()),[d,j]};a(c).live("dragstart dragmove",function(b,c){var d=k(a(this),c),e=c.deltaX*3.5,f=d[0].width(),g=parseInt(d[0].css("left"),10);(b.type==="dragstart"||c.srcEvent.type==="mousedown")&&!c.moveEvent&&(i=g),d[0].css("left",(i||0)+e),d[1].css("left",g<-(f/2)?f+(i||0)+e:-f+(i||0)+e),b.stopPropagation()}).live("dragend dragmove",function(a){a.stopPropagation()}).live("mousedown mousemove mouseup",j)}(jQuery),function(a){var b="revolver",c="."+b;a(c).live("dragstart dragmove drag",function(b){var c=a(b.target)})}(jQuery);
View
7 grunt.js
@@ -13,7 +13,12 @@ module.exports = function(grunt) {
},
concat: {
dist: {
- src: ['<banner:meta.banner>', '<file_strip_banner:src/<%= pkg.name %>.js>'],
+ src: [
+ '<banner:meta.banner>',
+ '<file_strip_banner:src/revolver.core.js>',
+ '<file_strip_banner:src/carousel.touchdrag.js>',
+ '<file_strip_banner:src/revolver.init.js>'
+ ],
dest: 'dist/<%= pkg.name %>.js'
}
},
View
233 src/Revolver.js
@@ -1,233 +0,0 @@
-/*
- * Revolver
- * https://github.com/filamentgroup/revolver
- *
- * Copyright (c) 2012 Filament Group, Inc.
- * Licensed under the MIT, GPL licenses.
- */
-
-(function($) {
- var pluginName = "revolver",
- initSelector = "." + pluginName,
- itemClass = pluginName + "-item",
- activeClass = pluginName + "-active",
- methods = {
- _create: function(){
- return $( this ).each(function() {
- var init = $( this ).data( "init" );
-
- if( init ) {
- return false;
- }
-
- $( this )
- .data( "init", true)
- .trigger( "beforecreate." + pluginName )
- [ pluginName ]( "_init" )
- .trigger( "create." + pluginName );
- });
- },
-
- _init: function(){
- var $dupe = $( this ).find( "img" ).clone();
-
- return $( this ).addClass( pluginName + " " + pluginName + "-slide " )
- .append( $dupe )
- .children()
- .addClass( itemClass )
- .first()
- .addClass( activeClass );
- },
-
- _destroy: function() {
- // TODO
- }
- };
-
- // Collection method.
- $.fn[ pluginName ] = function( arrg, a, b, c ) {
- return this.each(function() {
-
- // if it's a method
- if( arrg && typeof( arrg ) === "string" ){
- return $.fn[ pluginName ].prototype[ arrg ].call( this, a, b, c );
- }
-
- // don't re-init
- if( $( this ).data( pluginName + "data" ) ){
- return $( this );
- }
-
- // otherwise, init
- $( this ).data( pluginName + "active", true );
- $.fn[ pluginName ].prototype._create.call( this );
- });
- };
-
- // add methods
- $.extend( $.fn[ pluginName ].prototype, methods );
-
- // DOM-ready auto-init
- $( function(){
- $( initSelector )[ pluginName ]();
- } );
-
-}(jQuery));
-
-/*
- * responsive-carousel touch drag extension
- * https://github.com/filamentgroup/responsive-carousel
- *
- * Copyright (c) 2012 Filament Group, Inc.
- * Licensed under the MIT, GPL licenses.
- */
-
- (function($) {
- var pluginName = "revolver",
- initSelector = "." + pluginName,
- noTrans = pluginName + "-no-transition",
- touchMethods = {
- _dragBehavior: function(){
- var origin,
- data = {},
- deltaY,
- xPerc,
- yPerc,
- emitEvents = function( e ){
- var touches = e.touches || e.originalEvent.touches,
- $elem = $( e.target ).closest( initSelector );
-
- if( e.type === "touchstart" ){
- origin = {
- x : touches[ 0 ].pageX,
- y: touches[ 0 ].pageY
- };
- }
-
- if( touches[ 0 ] && touches[ 0 ].pageX ){
- data.touches = touches;
- data.deltaX = touches[ 0 ].pageX - origin.x;
- data.deltaY = touches[ 0 ].pageY - origin.y;
- data.w = $elem.first().width();
- data.h = $elem.first().height();
- data.xPercent = data.deltaX / data.w;
- data.yPercent = data.deltaY / data.h;
- data.srcEvent = e;
- }
-
- $elem.trigger( "drag" + e.type.split( "touch" )[ 1 ], data );
- return data;
- };
-
- $( this )
- .bind( "touchstart", function( e ){
- $( this ).addClass( noTrans );
- emitEvents( e );
- } )
- .bind( "touchmove", function( e ){
- var data = emitEvents( e );
-
- if( Math.abs( data.deltaX ) > 35 && Math.abs( data.deltaY ) < 35 && data.touches.length === 1 ){
- return false;
- }
- e.stopPropagation();
- } )
- .bind( "touchend", function( e ){
- $( this ).removeClass( noTrans );
- emitEvents( e );
- } );
- }
- };
-
- // add methods
- $.extend( $.fn[ pluginName ].prototype, touchMethods );
-
- // DOM-ready auto-init
- $( initSelector ).live( "create." + pluginName, function(){
- $( this )[ pluginName ]( "_dragBehavior" );
- } );
-
- }(jQuery));
-
- (function($) {
- var pluginName = "revolver",
- initSelector = "." + pluginName,
- activeClass = pluginName + "-active",
- itemClass = pluginName + "-item",
- current,
- clicked,
- origin,
- adjust,
- mouseDrag = function( e ) {
- var data = {};
- if( e.type === "mousedown" ) {
- clicked = true;
- origin = {
- x : e.pageX,
- e : e
- };
- data.srcEvent = origin.e;
- e.preventDefault();
- }
- if( ( e.type === "mousedown" || e.type === "mousemove" ) && clicked ) {
- data.deltaX = e.pageX - origin.x;
- data.srcEvent = origin.e;
-
- if( e.type === "mousemove" ) {
- data.moveEvent = e;
- }
-
- $( this ).trigger( "dragmove", [ data ] );
- }
- if( e.type === "mouseup" ) {
- clicked = false;
- }
- },
- getActiveSlides = function( $revolver, data ){
- var $from = $( data.srcEvent.target ),
- activeNum = $from.prevAll().length + 1,
- forward = data.deltaX < 0,
- nextNum = activeNum + (forward ? 1 : -1),
- $children = $revolver.find( "." + itemClass ),
- $to = $children.eq( nextNum - 1 );
-
- if( !$to.length ){
- $to = $children[ forward ? "first" : "last" ]();
- }
- return [ $from, $to ];
- };
-
- $( initSelector )
- // Touch handling
- .live( "dragstart dragmove", function( e, data ){
- var activeSlides = getActiveSlides( $( this ), data ),
- swipeSpeed = data.deltaX * 3.5,
- width = activeSlides[ 0 ].width(),
- current = parseInt( activeSlides[ 0 ].css( "left" ), 10 );
-
- if( ( e.type === "dragstart" || data.srcEvent.type === "mousedown" ) && !data.moveEvent ){
- adjust = current;
- }
-
- activeSlides[ 0 ].css( "left", ( adjust || 0 ) + swipeSpeed );
- activeSlides[ 1 ].css( "left", ( current < -( width / 2 ) ) ? width + ( adjust || 0 ) + swipeSpeed : -width + ( adjust || 0 ) + swipeSpeed );
-
- e.stopPropagation();
- } )
- .live( "dragend dragmove", function( e ) {
- e.stopPropagation();
- })
- // Mouse handling
- .live( "mousedown mousemove mouseup", mouseDrag );
-}(jQuery));
-
-(function($) {
- var pluginName = "revolver",
- initSelector = "." + pluginName;
-
- $( initSelector ).live( "dragstart dragmove drag", function( e ) {
- var $el = $( e.target );
- } );
-
-}(jQuery));
-
View
74 src/carousel.touchdrag.js
@@ -0,0 +1,74 @@
+/*
+ * responsive-carousel touch drag extension
+ * https://github.com/filamentgroup/responsive-carousel
+ *
+ * Copyright (c) 2012 Filament Group, Inc.
+ * Licensed under the MIT, GPL licenses.
+ */
+
+ (function($) {
+ var pluginName = "revolver",
+ initSelector = "." + pluginName,
+ noTrans = pluginName + "-no-transition",
+ touchMethods = {
+ _dragBehavior: function(){
+ var origin,
+ data = {},
+ deltaY,
+ xPerc,
+ yPerc,
+ emitEvents = function( e ){
+ var touches = e.touches || e.originalEvent.touches,
+ $elem = $( e.target ).closest( initSelector );
+
+ if( e.type === "touchstart" ){
+ origin = {
+ x : touches[ 0 ].pageX,
+ y: touches[ 0 ].pageY
+ };
+ }
+
+ if( touches[ 0 ] && touches[ 0 ].pageX ){
+ data.touches = touches;
+ data.deltaX = touches[ 0 ].pageX - origin.x;
+ data.deltaY = touches[ 0 ].pageY - origin.y;
+ data.w = $elem.first().width();
+ data.h = $elem.first().height();
+ data.xPercent = data.deltaX / data.w;
+ data.yPercent = data.deltaY / data.h;
+ data.srcEvent = e;
+ }
+
+ $elem.trigger( "drag" + e.type.split( "touch" )[ 1 ], data );
+ return data;
+ };
+
+ $( this )
+ .bind( "touchstart", function( e ){
+ $( this ).addClass( noTrans );
+ emitEvents( e );
+ } )
+ .bind( "touchmove", function( e ){
+ var data = emitEvents( e );
+
+ if( Math.abs( data.deltaX ) > 35 && Math.abs( data.deltaY ) < 35 && data.touches.length === 1 ){
+ return false;
+ }
+ e.stopPropagation();
+ } )
+ .bind( "touchend", function( e ){
+ $( this ).removeClass( noTrans );
+ emitEvents( e );
+ } );
+ }
+ };
+
+ // add methods
+ $.extend( $.fn[ pluginName ].prototype, touchMethods );
+
+ // DOM-ready auto-init
+ $( initSelector ).live( "create." + pluginName, function(){
+ $( this )[ pluginName ]( "_dragBehavior" );
+ } );
+
+ }(jQuery));
View
75 src/revolver.core.js
@@ -0,0 +1,75 @@
+/*
+ * Revolver
+ * https://github.com/filamentgroup/revolver
+ *
+ * Copyright (c) 2012 Filament Group, Inc.
+ * Licensed under the MIT, GPL licenses.
+ */
+
+(function($) {
+ var pluginName = "revolver",
+ initSelector = "." + pluginName,
+ itemClass = pluginName + "-item",
+ activeClass = pluginName + "-active",
+ methods = {
+ _create: function(){
+ return $( this ).each(function() {
+ var init = $( this ).data( "init" );
+
+ if( init ) {
+ return false;
+ }
+
+ $( this )
+ .data( "init", true)
+ .trigger( "beforecreate." + pluginName )
+ [ pluginName ]( "_init" )
+ .trigger( "create." + pluginName );
+ });
+ },
+
+ _init: function(){
+ var $dupe = $( this ).find( "img" ).clone();
+
+ return $( this ).addClass( pluginName + " " + pluginName + "-slide " )
+ .append( $dupe )
+ .children()
+ .addClass( itemClass )
+ .first()
+ .addClass( activeClass );
+ },
+
+ _destroy: function() {
+ // TODO
+ }
+ };
+
+ // Collection method.
+ $.fn[ pluginName ] = function( arrg, a, b, c ) {
+ return this.each(function() {
+
+ // if it's a method
+ if( arrg && typeof( arrg ) === "string" ){
+ return $.fn[ pluginName ].prototype[ arrg ].call( this, a, b, c );
+ }
+
+ // don't re-init
+ if( $( this ).data( pluginName + "data" ) ){
+ return $( this );
+ }
+
+ // otherwise, init
+ $( this ).data( pluginName + "active", true );
+ $.fn[ pluginName ].prototype._create.call( this );
+ });
+ };
+
+ // add methods
+ $.extend( $.fn[ pluginName ].prototype, methods );
+
+ // DOM-ready auto-init
+ $( function(){
+ $( initSelector )[ pluginName ]();
+ } );
+
+}(jQuery));
View
82 src/revolver.init.js
@@ -0,0 +1,82 @@
+
+ (function($) {
+ var pluginName = "revolver",
+ initSelector = "." + pluginName,
+ activeClass = pluginName + "-active",
+ itemClass = pluginName + "-item",
+ current,
+ clicked,
+ origin,
+ adjust,
+ mouseDrag = function( e ) {
+ var data = {};
+ if( e.type === "mousedown" ) {
+ clicked = true;
+ origin = {
+ x : e.pageX,
+ e : e
+ };
+ data.srcEvent = origin.e;
+ e.preventDefault();
+ }
+ if( ( e.type === "mousedown" || e.type === "mousemove" ) && clicked ) {
+ data.deltaX = e.pageX - origin.x;
+ data.srcEvent = origin.e;
+
+ if( e.type === "mousemove" ) {
+ data.moveEvent = e;
+ }
+
+ $( this ).trigger( "dragmove", [ data ] );
+ }
+ if( e.type === "mouseup" ) {
+ clicked = false;
+ }
+ },
+ getActiveSlides = function( $revolver, data ){
+ var $from = $( data.srcEvent.target ),
+ activeNum = $from.prevAll().length + 1,
+ forward = data.deltaX < 0,
+ nextNum = activeNum + (forward ? 1 : -1),
+ $children = $revolver.find( "." + itemClass ),
+ $to = $children.eq( nextNum - 1 );
+
+ if( !$to.length ){
+ $to = $children[ forward ? "first" : "last" ]();
+ }
+ return [ $from, $to ];
+ };
+
+ $( initSelector )
+ // Touch handling
+ .live( "dragstart dragmove", function( e, data ){
+ var activeSlides = getActiveSlides( $( this ), data ),
+ swipeSpeed = data.deltaX * 3.5,
+ width = activeSlides[ 0 ].width(),
+ current = parseInt( activeSlides[ 0 ].css( "left" ), 10 );
+
+ if( ( e.type === "dragstart" || data.srcEvent.type === "mousedown" ) && !data.moveEvent ){
+ adjust = current;
+ }
+
+ activeSlides[ 0 ].css( "left", ( adjust || 0 ) + swipeSpeed );
+ activeSlides[ 1 ].css( "left", ( current < -( width / 2 ) ) ? width + ( adjust || 0 ) + swipeSpeed : -width + ( adjust || 0 ) + swipeSpeed );
+
+ e.stopPropagation();
+ } )
+ .live( "dragend dragmove", function( e ) {
+ e.stopPropagation();
+ })
+ // Mouse handling
+ .live( "mousedown mousemove mouseup", mouseDrag );
+}(jQuery));
+
+(function($) {
+ var pluginName = "revolver",
+ initSelector = "." + pluginName;
+
+ $( initSelector ).live( "dragstart dragmove drag", function( e ) {
+ var $el = $( e.target );
+ } );
+
+}(jQuery));

0 comments on commit a5360b0

Please sign in to comment.
Something went wrong with that request. Please try again.