Permalink
Browse files

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

  • Loading branch information...
1 parent f5723e7 commit a5360b0f9084a31d93f4f907c1d61c9c330d5886 @Wilto Wilto committed Sep 13, 2012
Showing with 246 additions and 252 deletions.
  1. +2 −2 demo/index.html
  2. +5 −14 dist/Revolver.js
  3. +1 −1 dist/Revolver.min.css
  4. +1 −1 dist/Revolver.min.js
  5. +6 −1 grunt.js
  6. +0 −233 src/Revolver.js
  7. +74 −0 src/carousel.touchdrag.js
  8. +75 −0 src/revolver.core.js
  9. +82 −0 src/revolver.init.js
View
@@ -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
@@ -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

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -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
@@ -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));
-
Oops, something went wrong.

0 comments on commit a5360b0

Please sign in to comment.