From ee455fafa5e8cff733a9cf1130552e4db9a14173 Mon Sep 17 00:00:00 2001 From: Hyunje Alex Jun Date: Mon, 26 Jan 2015 15:01:07 +0000 Subject: [PATCH] Implement adaptors. --- gulpfile.js | 19 ++++++++++++------- src/js/adaptor/global.js | 11 +++++++++++ src/js/{main.js => adaptor/jquery.js} | 4 ++-- 3 files changed, 25 insertions(+), 9 deletions(-) create mode 100644 src/js/adaptor/global.js rename src/js/{main.js => adaptor/jquery.js} (89%) diff --git a/gulpfile.js b/gulpfile.js index d3422e5..789756b 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -19,12 +19,12 @@ gulp.task('lint', function () { }); gulp.task('clean:js', function () { - return gulp.src('./out/js/perfect-scrollbar.js', {read: false}) + return gulp.src('./out/js/*.js', {read: false}) .pipe(rimraf()); }); gulp.task('clean:js:min', function () { - return gulp.src('./out/js/perfect-scrollbar.min.js', {read: false}) + return gulp.src('./out/js/min/*.js', {read: false}) .pipe(rimraf()); }); @@ -36,19 +36,24 @@ function browserified() { } gulp.task('js', ['clean:js'], function () { - return gulp.src('./src/js/main.js') + return gulp.src('./src/js/adaptor/*.js') .pipe(browserified()) - .pipe(rename('perfect-scrollbar.js')) + .pipe(rename({ + prefix: 'perfect-scrollbar.' + })) .pipe(gulp.dest('./out/js')) .pipe(connect.reload()); }); gulp.task('js:min', ['clean:js:min'], function () { - return gulp.src('./src/js/main.js') + return gulp.src('./src/js/adaptor/*.js') .pipe(browserified()) .pipe(uglify()) - .pipe(rename('perfect-scrollbar.min.js')) - .pipe(gulp.dest('./out/js')); + .pipe(rename({ + prefix: 'perfect-scrollbar.', + suffix: '.min' + })) + .pipe(gulp.dest('./out/js/min')); }); gulp.task('clean:css', function () { diff --git a/src/js/adaptor/global.js b/src/js/adaptor/global.js new file mode 100644 index 0000000..b87dd21 --- /dev/null +++ b/src/js/adaptor/global.js @@ -0,0 +1,11 @@ +/* Copyright (c) 2015 Hyunje Alex Jun and other contributors + * Licensed under the MIT License + */ +'use strict'; + +var ps = require('../plugin/ps'); + +window.PerfectScrollbar = ps; +if (typeof window.Ps === 'undefined') { + window.Ps = ps; +} diff --git a/src/js/main.js b/src/js/adaptor/jquery.js similarity index 89% rename from src/js/main.js rename to src/js/adaptor/jquery.js index 150c009..df07e33 100644 --- a/src/js/main.js +++ b/src/js/adaptor/jquery.js @@ -3,8 +3,8 @@ */ 'use strict'; -var ps = require('./plugin/ps') - , psInstances = require('./plugin/instances'); +var ps = require('../plugin/ps') + , psInstances = require('../plugin/instances'); $.fn.perfectScrollbar = function (settingOrCommand) { return this.each(function () {