From eabf45a9fe492051ea210df98db848ecba5aa798 Mon Sep 17 00:00:00 2001 From: progrape Date: Mon, 26 Oct 2015 14:12:46 +0800 Subject: [PATCH] banner --- dist/swiper.js | 6 ++++++ gulpfile.js | 15 ++++++++++++--- package.json | 4 +++- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/dist/swiper.js b/dist/swiper.js index 5068399..6be3dc7 100644 --- a/dist/swiper.js +++ b/dist/swiper.js @@ -1 +1,7 @@ +/** + * swiper - swiper.js + * @version v1.3.1 + * @link https://github.com/weui/swiper.git + * @license MIT + */ !function(t,e){"function"==typeof define?define(e):this[t]=e()}("Swiper",function(){function t(t){this.version="1.3.1",this._default={container:".swiper",item:".item",direction:"vertical",threshold:50,duration:300},this._options=e(this._default,t),this._start={},this._move={},this._end={},this._prev=0,this._current=0,this._offset=0,this._eventHandlers={},this._cache={},this.$container=document.querySelector(this._options.container),this.$items=this.$container.querySelectorAll(this._options.item),this.count=this.$items.length,this._width=this.$container.offsetWidth,this._height=this.$container.offsetHeight,this._init(),this._bind()}function e(t,e){for(var n in e)t[n]=e[n];return t}function n(){}return t.prototype._init=function(){var t=this,e=t._width,n=t._height,i=e,r=n*t.count;"horizontal"===t._options.direction&&(i=e*t.count,r=n),t.$container.style.width=i+"px",t.$container.style.height=r+"px",Array.prototype.forEach.call(t.$items,function(t,i){t.style.width=e+"px",t.style.height=n+"px"})},t.prototype._bind=function(){var t=this;this.$container.addEventListener("touchstart",function(e){t._start.x=e.changedTouches[0].pageX,t._start.y=e.changedTouches[0].pageY,t.$container.style["-webkit-transition"]="none",t.$container.style.transition="none"},!1),this.$container.addEventListener("touchmove",function(e){t._move.x=e.changedTouches[0].pageX,t._move.y=e.changedTouches[0].pageY;var n=t._move.y-t._start.y,i="translate3d(0, "+(n-t._offset)+"px, 0)";"horizontal"===t._options.direction&&(n=t._move.x-t._start.x,i="translate3d("+(n-t._offset)+"px, 0, 0)"),t.$container.style["-webkit-transform"]=i,t.$container.style.transform=i,e.preventDefault()},!1),this.$container.addEventListener("touchend",function(e){t._end.x=e.changedTouches[0].pageX,t._end.y=e.changedTouches[0].pageY;var n=t._end.y-t._start.y;"horizontal"===t._options.direction&&(n=t._end.x-t._start.x),t._prev=t._current,n>t._options.threshold?t._current=0===t._current?0:--t._current:n<-t._options.threshold&&(t._current=t._current=this.count-1?void 0:(this._prev=this._current,this._show(++this._current),this)},t.prototype.on=function(t,e){if(this._eventHandlers[t])throw new Error("event "+t+" is already register");if("function"!=typeof e)throw new Error("parameter callback must be a function");return this._eventHandlers[t]=e,this},t}); \ No newline at end of file diff --git a/gulpfile.js b/gulpfile.js index ed817f0..630555b 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -4,6 +4,8 @@ var gulp = require('gulp'); +var gutil = require('gulp-util'); +var header = require('gulp-header'); var uglify = require('gulp-uglify'); var jshint = require('gulp-jshint'); var rename = require('gulp-rename'); @@ -11,8 +13,7 @@ var less = require('gulp-less'); var autoprefixer = require('gulp-autoprefixer'); var tap = require('gulp-tap'); var browserSync = require('browser-sync'); -var config = require('./package.json'); -var version = config.version; +var pkg = require('./package.json'); gulp.task('build', ['lint'], function () { gulp.src('src/example/**/*') @@ -26,13 +27,21 @@ gulp.task('build', ['lint'], function () { .pipe(autoprefixer()) .pipe(gulp.dest('dist')); + var banner = ['/**', + ' * <%= pkg.name %> - <%= pkg.description %>', + ' * @version v<%= pkg.version %>', + ' * @link <%= pkg.repository.url %>', + ' * @license <%= pkg.license %>', + ' */', + ''].join('\n'); gulp.src('src/swiper.js') .pipe(tap(function(file, t){ var contents = file.contents.toString(); - contents = contents.replace('${version}', version); + contents = contents.replace('${version}', pkg.version); file.contents = new Buffer(contents); })) .pipe(uglify()) + .pipe(header(banner, { pkg : pkg } )) .pipe(gulp.dest('dist')); }); diff --git a/package.json b/package.json index 539f84b..638de57 100644 --- a/package.json +++ b/package.json @@ -12,10 +12,12 @@ "browser-sync": "^2.9.11", "gulp": "~3.8.10", "gulp-autoprefixer": "^3.1.0", + "gulp-header": "^1.7.1", "gulp-jshint": "~1.9.0", "gulp-less": "^3.0.3", "gulp-rename": "^1.2.2", "gulp-tap": "^0.1.3", - "gulp-uglify": "^1.0.2" + "gulp-uglify": "^1.0.2", + "gulp-util": "^3.0.7" } }