');\n this.$timer = $timer;\n this.$elmt.prepend($timer);\n }\n\n // Overlay\n if (overlay) {\n $overlay = $('
');\n\n if (typeof overlay === 'string') {\n $overlay.css('background-image', 'url(' + overlay + ')');\n }\n\n this.$overlay = $overlay;\n this.$elmt.prepend($overlay);\n }\n\n // Container\n this.$elmt.addClass('vegas-container');\n\n if (!isBody) {\n this.$elmt.append($contentScroll);\n $contentScroll.append($content);\n }\n\n setTimeout(function () {\n self.trigger('init');\n self._goto(self.slide);\n\n if (self.settings.autoplay) {\n self.trigger('play');\n }\n }, 1);\n },\n\n _preload: function () {\n var img, i;\n\n for (i = 0; i < this.settings.slides.length; i++) {\n if (this.settings.preload || this.settings.preloadImages) {\n if (this.settings.slides[i].src) {\n img = new Image();\n img.src = this.settings.slides[i].src;\n }\n }\n\n if (this.settings.preload || this.settings.preloadVideos) {\n if (this.settings.slides[i].video) {\n if (this.settings.slides[i].video instanceof Array) {\n this._video(this.settings.slides[i].video);\n } else {\n this._video(this.settings.slides[i].video.src);\n }\n }\n }\n }\n },\n\n _random: function (array) {\n return array[Math.floor(Math.random() * array.length)];\n },\n\n _slideShow: function () {\n var self = this;\n\n if (this.total > 1 && !this.ended && !this.paused && !this.noshow) {\n this.timeout = setTimeout(function () {\n self.next();\n }, this._options('delay'));\n }\n },\n\n _timer: function (state) {\n var self = this;\n\n clearTimeout(this.timeout);\n\n if (!this.$timer) {\n return;\n }\n\n this.$timer\n .removeClass('vegas-timer-running')\n .find('div')\n .css('transition-duration', '0ms');\n\n if (this.ended || this.paused || this.noshow) {\n return;\n }\n\n if (state) {\n setTimeout(function () {\n self.$timer\n .addClass('vegas-timer-running')\n .find('div')\n .css('transition-duration', self._options('delay') - 100 + 'ms');\n }, 100);\n }\n },\n\n _video: function (srcs) {\n var video,\n source,\n cacheKey = this.instance + srcs.toString();\n\n if (videoCache[cacheKey]) {\n return videoCache[cacheKey];\n }\n\n if (!(srcs instanceof Array)) {\n srcs = [ srcs ];\n }\n\n video = document.createElement('video');\n video.preload = true;\n video.playsInline = true;\n video.controls = false;\n\n srcs.forEach(function (src) {\n source = document.createElement('source');\n source.src = src;\n video.appendChild(source);\n });\n\n videoCache[cacheKey] = video;\n\n return video;\n },\n\n _fadeOutSound: function (video, duration) {\n var self = this,\n delay = duration / 10,\n volume = video.volume - 0.09;\n\n if (volume > 0) {\n video.volume = volume;\n\n setTimeout(function () {\n self._fadeOutSound(video, duration);\n }, delay);\n } else {\n video.pause();\n }\n },\n\n _fadeInSound: function (video, duration) {\n var self = this,\n delay = duration / 10,\n volume = video.volume + 0.09;\n\n if (volume < 1) {\n video.volume = volume;\n\n setTimeout(function () {\n self._fadeInSound(video, duration);\n }, delay);\n }\n },\n\n _options: function (key, i) {\n if (i === undefined) {\n i = this.slide;\n }\n\n if (this.settings.slides[i][key] !== undefined) {\n return this.settings.slides[i][key];\n }\n\n return this.settings[key];\n },\n\n _goto: function (nb) {\n if (typeof this.settings.slides[nb] === 'undefined') {\n nb = 0;\n }\n\n this.slide = nb;\n\n var $slide,\n $inner,\n $video,\n $slides = this.$elmt.children('.vegas-slide'),\n src = this.settings.slides[nb].src,\n videoSettings = this.settings.slides[nb].video,\n delay = this._options('delay'),\n align = this._options('align'),\n valign = this._options('valign'),\n cover = this._options('cover'),\n color = this._options('color') || this.$elmt.css('background-color'),\n self = this,\n total = $slides.length,\n video,\n img;\n\n var transition = this._options('transition'),\n transitionDuration = this._options('transitionDuration'),\n animation = this._options('animation'),\n animationDuration = this._options('animationDuration');\n\n if (this.settings.firstTransition && this.first) {\n transition = this.settings.firstTransition || transition;\n }\n\n if (this.settings.firstTransitionDuration && this.first) {\n transitionDuration = this.settings.firstTransitionDuration || transitionDuration;\n }\n\n if (this.first) {\n this.first = false;\n }\n\n if (cover !== 'repeat') {\n if (cover === true) {\n cover = 'cover';\n } else if (cover === false) {\n cover = 'contain';\n }\n }\n\n if (transition === 'random' || transition instanceof Array) {\n if (transition instanceof Array) {\n transition = this._random(transition);\n } else {\n transition = this._random(this.transitions);\n }\n }\n\n if (animation === 'random' || animation instanceof Array) {\n if (animation instanceof Array) {\n animation = this._random(animation);\n } else {\n animation = this._random(this.animations);\n }\n }\n\n if (transitionDuration === 'auto' || transitionDuration > delay) {\n transitionDuration = delay;\n }\n\n if (animationDuration === 'auto') {\n animationDuration = delay;\n }\n\n $slide = $('
');\n\n if (this.support.transition && transition) {\n $slide.addClass('vegas-transition-' + transition);\n }\n\n // Video\n\n if (videoSettings) {\n if (videoSettings instanceof Array) {\n video = this._video(videoSettings);\n } else {\n video = this._video(videoSettings.src);\n }\n\n video.loop = videoSettings.loop !== undefined ? videoSettings.loop : true;\n video.muted = videoSettings.muted !== undefined ? videoSettings.muted : true;\n\n if (video.muted === false) {\n video.volume = 0;\n this._fadeInSound(video, transitionDuration);\n } else {\n video.pause();\n }\n\n $video = $(video)\n .addClass('vegas-video')\n .css('background-color', color);\n\n if (this.support.objectFit) {\n $video\n .css('object-position', align + ' ' + valign)\n .css('object-fit', cover)\n .css('width', '100%')\n .css('height', '100%');\n } else if (cover === 'contain') {\n $video\n .css('width', '100%')\n .css('height', '100%');\n }\n\n $slide.append($video);\n\n // Image\n\n } else {\n img = new Image();\n\n $inner = $('
')\n .css('background-image', 'url(\"' + src + '\")')\n .css('background-color', color)\n .css('background-position', align + ' ' + valign);\n\n if (cover === 'repeat') {\n $inner.css('background-repeat', 'repeat');\n } else {\n $inner.css('background-size', cover);\n }\n\n if (this.support.transition && animation) {\n $inner\n .addClass('vegas-animation-' + animation)\n .css('animation-duration', animationDuration + 'ms');\n }\n\n $slide.append($inner);\n }\n\n if (!this.support.transition) {\n $slide.css('display', 'none');\n }\n\n if (total) {\n $slides.eq(total - 1).after($slide);\n } else {\n this.$elmt.prepend($slide);\n }\n\n $slides\n .css('transition', 'all 0ms')\n .each(function () {\n this.className = 'vegas-slide';\n\n if (this.tagName === 'VIDEO') {\n this.className += ' vegas-video';\n }\n\n if (transition) {\n this.className += ' vegas-transition-' + transition;\n this.className += ' vegas-transition-' + transition + '-in';\n }\n }\n );\n\n self._timer(false);\n\n function go () {\n self._timer(true);\n\n setTimeout(function () {\n if (transition) {\n if (self.support.transition) {\n $slides\n .css('transition', 'all ' + transitionDuration + 'ms')\n .addClass('vegas-transition-' + transition + '-out');\n\n $slides.each(function () {\n var video = $slides.find('video').get(0);\n\n if (video) {\n video.volume = 1;\n self._fadeOutSound(video, transitionDuration);\n }\n });\n\n $slide\n .css('transition', 'all ' + transitionDuration + 'ms')\n .addClass('vegas-transition-' + transition + '-in');\n } else {\n $slide.fadeIn(transitionDuration);\n }\n }\n\n for (var i = 0; i < $slides.length - self.settings.slidesToKeep; i++) {\n $slides.eq(i).remove();\n }\n\n self.trigger('walk');\n self._slideShow();\n }, 100);\n }\n if (video) {\n if (video.readyState === 4) {\n video.currentTime = 0;\n }\n\n video.play();\n go();\n } else {\n img.src = src;\n\n if (img.complete) {\n go();\n } else {\n img.onload = go;\n }\n }\n },\n\n _end: function () {\n this.ended = !this.settings.autoplay;\n this._timer(false);\n this.trigger('end');\n },\n\n shuffle: function () {\n var temp,\n rand;\n\n for (var i = this.total - 1; i > 0; i--) {\n rand = Math.floor(Math.random() * (i + 1));\n temp = this.settings.slides[i];\n\n this.settings.slides[i] = this.settings.slides[rand];\n this.settings.slides[rand] = temp;\n }\n },\n\n play: function () {\n if (this.paused) {\n this.paused = false;\n this.next();\n this.trigger('play');\n }\n },\n\n pause: function () {\n this._timer(false);\n this.paused = true;\n this.trigger('pause');\n },\n\n toggle: function () {\n if (this.paused) {\n this.play();\n } else {\n this.pause();\n }\n },\n\n playing: function () {\n return !this.paused && !this.noshow;\n },\n\n current: function (advanced) {\n if (advanced) {\n return {\n slide: this.slide,\n data: this.settings.slides[this.slide]\n };\n }\n return this.slide;\n },\n\n jump: function (nb) {\n if (nb < 0 || nb > this.total - 1 || nb === this.slide) {\n return;\n }\n\n this.slide = nb;\n this._goto(this.slide);\n },\n\n next: function () {\n this.slide++;\n\n if (this.slide >= this.total) {\n if (!this.settings.loop) {\n return this._end();\n }\n\n this.slide = 0;\n }\n\n this._goto(this.slide);\n },\n\n previous: function () {\n this.slide--;\n\n if (this.slide < 0) {\n if (!this.settings.loop) {\n this.slide++;\n return;\n } else {\n this.slide = this.total - 1;\n }\n }\n\n this._goto(this.slide);\n },\n\n trigger: function (fn) {\n var params = [];\n\n if (fn === 'init') {\n params = [ this.settings ];\n } else {\n params = [\n this.slide,\n this.settings.slides[this.slide]\n ];\n }\n\n this.$elmt.trigger('vegas' + fn, params);\n\n if (typeof this.settings[fn] === 'function') {\n this.settings[fn].apply(this.$elmt, params);\n }\n },\n\n options: function (key, value) {\n var oldSlides = this.settings.slides.slice();\n\n if (typeof key === 'object') {\n this.settings = $.extend({}, defaults, $.vegas.defaults, key);\n } else if (typeof key === 'string') {\n if (value === undefined) {\n return this.settings[key];\n }\n this.settings[key] = value;\n } else {\n return this.settings;\n }\n\n // In case slides have changed\n if (this.settings.slides !== oldSlides) {\n this.total = this.settings.slides.length;\n this.noshow = this.total < 2;\n this._preload();\n }\n },\n\n destroy: function () {\n clearTimeout(this.timeout);\n\n this.$elmt.removeClass('vegas-container');\n this.$elmt.find('> .vegas-slide').remove();\n this.$elmt.find('> .vegas-wrapper').clone(true).children().appendTo(this.$elmt);\n this.$elmt.find('> .vegas-wrapper').remove();\n\n if (this.settings.timer) {\n this.$timer.remove();\n }\n\n if (this.settings.overlay) {\n this.$overlay.remove();\n }\n\n this.elmt._vegas = null;\n }\n };\n\n $.fn.vegas = function(options) {\n var args = arguments,\n error = false,\n returns;\n\n if (options === undefined || typeof options === 'object') {\n return this.each(function () {\n if (!this._vegas) {\n this._vegas = new Vegas(this, options);\n }\n });\n } else if (typeof options === 'string') {\n this.each(function () {\n var instance = this._vegas;\n\n if (!instance) {\n throw new Error('No Vegas applied to this element.');\n }\n\n if (typeof instance[options] === 'function' && options[0] !== '_') {\n returns = instance[options].apply(instance, [].slice.call(args, 1));\n } else {\n error = true;\n }\n });\n\n if (error) {\n throw new Error('No method \"' + options + '\" in Vegas.');\n }\n\n return returns !== undefined ? returns : this;\n }\n };\n\n $.vegas = {};\n $.vegas.defaults = defaults;\n\n $.vegas.isVideoCompatible = function () {\n return true;\n };\n\n})(window.jQuery || window.Zepto || window.m4q);\n"],"names":["$","Vegas","elmt","options","this","settings","extend","defaults","vegas","slide","total","slides","length","noshow","paused","autoplay","ended","$elmt","$timer","$overlay","$slide","timeout","first","instance","instances","transitions","animations","transitionRegister","Array","animationRegister","concat","support","objectFit","document","body","style","transition","shuffle","_init","delay","loop","preload","preloadImage","preloadVideo","timer","overlay","cover","color","align","valign","firstTransition","firstTransitionDuration","transitionDuration","animation","animationDuration","slidesToKeep","init","play","pause","walk","videoCache","prototype","$content","$contentScroll","isBody","tagName","self","_preload","css","clone","children","appendTo","innerHTML","prepend","addClass","append","setTimeout","trigger","_goto","i","preloadImages","src","Image","preloadVideos","video","_video","_random","array","Math","floor","random","_slideShow","next","_options","_timer","state","clearTimeout","removeClass","find","srcs","source","cacheKey","toString","createElement","playsInline","controls","forEach","appendChild","_fadeOutSound","duration","volume","_fadeInSound","key","undefined","nb","img","$slides","videoSettings","go","each","get","fadeIn","eq","remove","muted","$video","$inner","after","className","readyState","currentTime","complete","onload","_end","temp","rand","toggle","playing","current","advanced","data","jump","previous","fn","params","apply","value","oldSlides","slice","destroy","_vegas","returns","args","arguments","error","Error","call","isVideoCompatible","window","jQuery","Zepto","m4q"],"mappings":";;;;;;;;+EAUA;CAAA,SAAWA,GACT,aAsDY,SAARC,EAAkBC,EAAMC,GAC1BC,KAAKF,KAAeA,EACpBE,KAAKC,SAAeL,EAAEM,OAAO,GAAIC,EAAUP,EAAEQ,MAAMD,SAAUJ,CAAO,EACpEC,KAAKK,MAAeL,KAAKC,SAASI,MAClCL,KAAKM,MAAeN,KAAKC,SAASM,OAAOC,OACzCR,KAAKS,OAAeT,KAAKM,MAAQ,EACjCN,KAAKU,OAAe,CAACV,KAAKC,SAASU,UAAYX,KAAKS,OACpDT,KAAKY,MAAe,C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,aAAa,EAGzD,OAAmB8G,KAAAA,IAAZsC,EAAwBA,EAAUnJ,IAC3C,CACF,EAEAJ,EAAEQ,MAAQ,GACVR,EAAEQ,MAAMD,SAAWA,EAEnBP,EAAEQ,MAAMqJ,kBAAoB,WAC1B,MAAO,CAAA,CACT,CAED,EAAEC,OAAOC,QAAUD,OAAOE,OAASF,OAAOG,GAAG"}
--------------------------------------------------------------------------------
/gulpfile.js:
--------------------------------------------------------------------------------
1 | /* Utlimate Jay Mega Gulpfile */
2 | /* global require:true, process:true */
3 | /* jshint laxbreak:true */
4 |
5 | (function() {
6 | 'use strict';
7 |
8 | var pkg = require('./package.json'),
9 | del = require('del'),
10 | yargs = require('yargs'),
11 | exec = require('exec'),
12 | fs = require('fs'),
13 | dateFormat = require('date-format'),
14 | spawn = require('child_process').spawn,
15 | gulp = require('gulp'),
16 | plugins = require('gulp-load-plugins')();
17 |
18 | var bumpVersion = yargs.argv.type || 'patch';
19 |
20 | var settings = {
21 | name: 'vegas',
22 | banner: {
23 | content: [
24 | '/*!-----------------------------------------------------------------------------',
25 | ' * <%= pkg.description %>',
26 | ' * v<%= pkg.version %> - built <%= datetime %>',
27 | ' * Licensed under the MIT License.',
28 | ' * http://vegas.jaysalvat.com/',
29 | ' * ----------------------------------------------------------------------------',
30 | ' * Copyright (C) 2010-<%= year %> Jay Salvat',
31 | ' * http://jaysalvat.com/',
32 | ' * --------------------------------------------------------------------------*/',
33 | ''
34 | ].join('\n'),
35 | vars: {
36 | pkg: pkg,
37 | datetime: dateFormat.asString('yyyy-MM-dd'),
38 | year: dateFormat.asString('yyyy')
39 | }
40 | }
41 | };
42 |
43 | const getPackageJson = function() {
44 | return JSON.parse(fs.readFileSync('./package.json'));
45 | };
46 |
47 | function clean(cb) {
48 | return del([ './dist' ], cb);
49 | }
50 |
51 | exports.clean = clean;
52 |
53 | function tmpClean(cb) {
54 | return del([ './tmp' ], cb);
55 | }
56 |
57 | exports.tmpClean = tmpClean;
58 |
59 | function tmpCreate(cb) {
60 | return exec('mkdir -p ./tmp', cb);
61 | }
62 |
63 | exports.tmpCreate = tmpCreate;
64 |
65 | function tmpCopy() {
66 | return gulp.src('./dist/**/*')
67 | .pipe(gulp.dest('./tmp'));
68 | }
69 |
70 | exports.tmpCopy = gulp.series(tmpCreate, tmpCopy);
71 |
72 | function zip() {
73 | const filename = settings.name + '.zip';
74 |
75 | return gulp.src('./dist/**/*')
76 | .pipe(plugins.zip(filename))
77 | .pipe(gulp.dest('./tmp'));
78 | }
79 |
80 | exports.zip = gulp.series(tmpCreate, zip);
81 |
82 | function failIfDirty(cb) {
83 | return exec('git diff-index HEAD --', function(err, output) {
84 | if (err) {
85 | return cb(err);
86 | }
87 | if (output) {
88 | return cb('Repository is dirty');
89 | }
90 | return cb();
91 | });
92 | }
93 |
94 | exports.zip = failIfDirty;
95 |
96 | function failIfNotMaster(cb) {
97 | exec('git symbolic-ref -q HEAD', function(err, output) {
98 | if (err) {
99 | return cb(err);
100 | }
101 | if (!/refs\/heads\/master/.test(output)) {
102 | return cb('Branch is not Master');
103 | }
104 | return cb();
105 | });
106 | }
107 |
108 | exports.failIfNotMaster = failIfNotMaster;
109 |
110 | function gitTag(cb) {
111 | const message = 'v' + getPackageJson().version;
112 |
113 | return exec('git tag ' + message, cb);
114 | }
115 |
116 | exports.gitTag = gitTag;
117 |
118 | function gitAdd(cb) {
119 | return exec('git add -A', cb);
120 | }
121 |
122 | exports.gitAdd = gitAdd;
123 |
124 | function gitCommit(cb) {
125 | const message = 'Build v' + getPackageJson().version;
126 |
127 | return exec('git commit -m "' + message + '"', cb);
128 | }
129 |
130 | exports.gitCommit = gulp.series(gitAdd, gitCommit);
131 |
132 | function gitPull(cb) {
133 | return exec('git pull origin master', function(err, output, code) {
134 | if (code !== 0) {
135 | return cb(err + output);
136 | }
137 | return cb();
138 | });
139 | }
140 |
141 | exports.gitPull = gitPull;
142 |
143 | function gitPush(cb) {
144 | return exec('git push origin master --tags', function(err, output, code) {
145 | if (code !== 0) {
146 | return cb(err + output);
147 | }
148 | return cb();
149 | });
150 | }
151 |
152 | exports.gitCommit = gulp.series(gitAdd, gitCommit, gitPush);
153 |
154 | function npmPublish(cb) {
155 | exec('npm publish', function(err, output, code) {
156 | if (code !== 0) {
157 | return cb(err + output);
158 | }
159 | return cb();
160 | });
161 | }
162 |
163 | exports.npmPublish = npmPublish;
164 |
165 | function meta(cb) {
166 | const metadata = {
167 | date: dateFormat.asString('yyyy-MM-dd HH:MM'),
168 | version: 'v' + getPackageJson().version
169 | },
170 | json = JSON.stringify(metadata, null, 4);
171 |
172 | fs.writeFileSync('tmp/metadata.json', json);
173 | fs.writeFileSync('tmp/metadata.js', '__metadata(' + json + ');');
174 |
175 | return cb();
176 | }
177 |
178 | exports.npmPublish = gulp.series(tmpCreate, meta);
179 |
180 | function bump() {
181 | return gulp.src([ 'package.json', 'bower.json', 'component.json' ])
182 | .pipe(plugins.bump(
183 | /^[a-z]+$/.test(bumpVersion)
184 | ? { type: bumpVersion }
185 | : { version: bumpVersion }
186 | ))
187 | .pipe(gulp.dest('.'));
188 | }
189 |
190 | exports.npmPublish = npmPublish;
191 |
192 | function year() {
193 | return gulp.src([ './README.md' ])
194 | .pipe(plugins.replace(/(Copyright )(\d{4})/g, '$1' + dateFormat.asString('yyyy')))
195 | .pipe(gulp.dest('.'));
196 | }
197 |
198 | exports.year = year;
199 |
200 | function lint() {
201 | return gulp.src('./src/**.js')
202 | .pipe(plugins.jshint())
203 | .pipe(plugins.jshint.reporter('default'));
204 | }
205 |
206 | exports.lint = lint;
207 |
208 | function copy() {
209 | return gulp.src([ './src/**/*', '!./src/sass', '!./src/sass/**' ])
210 | .pipe(gulp.dest('./dist'));
211 | }
212 |
213 | exports.copy = copy;
214 |
215 | function uglify() {
216 | return gulp.src('./dist/**/!(*.min.js).js')
217 | .pipe(plugins.rename({ suffix: '.min' }))
218 | .pipe(plugins.sourcemaps.init())
219 | .pipe(plugins.uglify({
220 | compress: {
221 |
222 | },
223 | mangle: true,
224 | output: {
225 | comments: /^!/
226 | }
227 | }))
228 | .on('error', function(err) { console.log(err) })
229 | .pipe(plugins.sourcemaps.write('.'))
230 | .pipe(gulp.dest('./dist/'));
231 | }
232 |
233 | exports.copy = copy;
234 |
235 | function cssmin() {
236 | return gulp.src('./dist/**/!(*.min.css).css')
237 | .pipe(plugins.sourcemaps.init())
238 | .pipe(plugins.rename({ suffix: '.min' }))
239 | .pipe(plugins.cssmin())
240 | .pipe(plugins.sourcemaps.write('.'))
241 | .pipe(gulp.dest('./dist/'));
242 | }
243 |
244 | exports.cssmin = cssmin;
245 |
246 | function sass() {
247 | return gulp.src("./src/sass/vegas.sass")
248 | // .pipe(plugins.sourcemaps.init())
249 | .pipe(plugins.sass({
250 | outputStyle: 'expanded',
251 | indentWidth: 4
252 | }).on('error', plugins.sass.logError))
253 | .pipe(plugins.autoprefixer())
254 | // .pipe(plugins.sourcemaps.write('.'))
255 | .pipe(gulp.dest("./dist/"));
256 | }
257 |
258 | exports.sass = sass;
259 |
260 | function header() {
261 | settings.banner.vars.pkg = getPackageJson();
262 |
263 | return gulp.src('./dist/*.js')
264 | .pipe(plugins.header(settings.banner.content, settings.banner.vars ))
265 | .pipe(gulp.dest('./dist/'));
266 | }
267 |
268 | exports.header = header;
269 |
270 | function ghPages(cb) {
271 | var version = getPackageJson().version;
272 |
273 | exec([ 'git checkout gh-pages',
274 | 'rm -rf releases/' + version,
275 | 'mkdir -p releases/' + version,
276 | 'cp -r tmp/* releases/' + version,
277 | 'git add -A releases/' + version,
278 | 'rm -rf releases/latest',
279 | 'mkdir -p releases/latest',
280 | 'cp -r tmp/* releases/latest',
281 | 'git add -A releases/latest',
282 | 'git commit -m "Publish release v' + version + '."',
283 | 'git push origin gh-pages',
284 | 'git checkout -'
285 | ].join(' && '),
286 | function(err, output, code) {
287 | if (code !== 0) {
288 | return cb(err + output);
289 | }
290 | return cb();
291 | }
292 | );
293 | }
294 |
295 | exports.ghPages = ghPages;
296 |
297 | function changelog(cb) {
298 | var filename = 'CHANGELOG.md',
299 | editor = process.env.EDITOR || 'vim',
300 | version = getPackageJson().version,
301 | date = dateFormat.asString('yyyy-MM-dd'),
302 | changelog = fs.readFileSync(filename).toString(),
303 | lastDate = /\d{4}-\d{2}-\d{2}/.exec(changelog)[0];
304 |
305 | exec('git log --since="' + lastDate + ' 00:00:00" --oneline --pretty=format:"%s"', function(err, stdout) {
306 | if (err) {
307 | return cb(err);
308 | }
309 |
310 | if (!stdout) {
311 | return cb();
312 | }
313 |
314 | const updates = [
315 | '### Vegas ' + version + ' ' + date,
316 | '',
317 | '* ' + stdout.replace(/\n/g, '\n* ')
318 | ].join('\n');
319 |
320 | changelog = changelog.replace(/(## CHANGE LOG)/, '$1\n\n' + updates);
321 |
322 | fs.writeFileSync(filename, changelog);
323 |
324 | const vim = spawn(editor, [ filename, '-n', '+7' ], {
325 | stdio: 'inherit'
326 | });
327 |
328 | vim.on('close', function() {
329 | return cb();
330 | });
331 | });
332 | }
333 |
334 | exports.changelog = changelog;
335 |
336 | function watch() {
337 | return gulp.watch("./src/**/*", build);
338 | }
339 |
340 | exports.watch = watch;
341 | exports.default = watch;
342 |
343 | const build = gulp.series(
344 | lint,
345 | clean,
346 | copy,
347 | sass,
348 | header,
349 | cssmin,
350 | uglify
351 | );
352 |
353 | exports.build = build;
354 |
355 | const publish = gulp.series(
356 | failIfNotMaster,
357 | failIfDirty,
358 | tmpCreate,
359 | tmpCopy,
360 | meta,
361 | zip,
362 | ghPages,
363 | tmpClean
364 | );
365 |
366 | exports.publish = publish;
367 |
368 | const release = gulp.series(
369 | failIfNotMaster,
370 | failIfDirty,
371 | gitPull,
372 | bump,
373 | changelog,
374 | year,
375 | clean,
376 | copy,
377 | sass,
378 | header,
379 | uglify,
380 | cssmin,
381 | gitAdd,
382 | gitCommit,
383 | gitTag,
384 | gitPush,
385 | publish,
386 | npmPublish
387 | );
388 |
389 | exports.release = release;
390 | })();
391 |
392 | /*
393 |
394 | NPM Installation
395 | ----------------
396 |
397 | npm install --save-dev del
398 | npm install --save-dev yargs
399 | npm install --save-dev exec
400 | npm install --save-dev jshint
401 | npm install --save-dev gulp
402 | npm install --save-dev gulp-sass
403 | npm install --save-dev gulp-load-plugins
404 | npm install --save-dev gulp-bump
405 | npm install --save-dev gulp-header
406 | npm install --save-dev gulp-cssmin
407 | npm install --save-dev gulp-autoprefixer
408 | npm install --save-dev gulp-uglify
409 | npm install --save-dev gulp-sourcemaps
410 | npm install --save-dev gulp-jshint
411 | npm install --save-dev gulp-util
412 | npm install --save-dev gulp-zip
413 | npm install --save-dev gulp-rename
414 | npm install --save-dev gulp-replace
415 |
416 | Gh-pages creation
417 | -----------------
418 |
419 | git checkout --orphan gh-pages
420 | git rm -rf .
421 | rm -fr
422 | echo 'Welcome' > index.html
423 | git add index.html
424 | git commit -a -m 'First commit'
425 | git push origin gh-pages
426 | git checkout -
427 |
428 | */
429 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "vegas",
3 | "version": "2.6.0",
4 | "description": "Vegas - Fullscreen Backgrounds and Slideshows.",
5 | "homepage": "http://vegas.jaysalvat.com",
6 | "author": "Jay Salvat",
7 | "license": "MIT",
8 | "main": "dist/vegas.min.js",
9 | "repository": {
10 | "type": "git",
11 | "url": "git@github.com:jaysalvat/vegas.git"
12 | },
13 | "scripts": {
14 | "dev": "gulp",
15 | "build": "gulp build",
16 | "release:patch": "gulp release --type patch",
17 | "release:minor": "gulp release --type minor",
18 | "release:major": "gulp release --type major"
19 | },
20 | "keywords": [
21 | "background",
22 | "slideshow",
23 | "fullscreen",
24 | "vegas",
25 | "jquery-plugin",
26 | "jquery",
27 | "zepto"
28 | ],
29 | "devDependencies": {
30 | "date-format": "^3.0.0",
31 | "del": "^6.1.1",
32 | "exec": "^0.2.1",
33 | "gulp": "^4.0.2",
34 | "gulp-autoprefixer": "^7.0.1",
35 | "gulp-bump": "^3.2.0",
36 | "gulp-cssmin": "^0.2.0",
37 | "gulp-header": "^2.0.9",
38 | "gulp-jshint": "^2.1.0",
39 | "gulp-load-plugins": "^2.0.8",
40 | "gulp-rename": "^2.0.0",
41 | "gulp-replace": "^1.1.4",
42 | "gulp-sass": "^4.1.1",
43 | "gulp-sourcemaps": "^3.0.0",
44 | "gulp-sync": "^0.1.4",
45 | "gulp-uglify": "^3.0.2",
46 | "gulp-util": "^3.0.8",
47 | "gulp-zip": "^5.1.0",
48 | "jshint": "^2.13.6",
49 | "yargs": "^16.2.0"
50 | },
51 | "dependencies": {}
52 | }
53 |
--------------------------------------------------------------------------------
/src/overlays/01.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jaysalvat/vegas/5fb29500e9d0fcdcf11b22b83cf13856ab5537fc/src/overlays/01.png
--------------------------------------------------------------------------------
/src/overlays/02.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jaysalvat/vegas/5fb29500e9d0fcdcf11b22b83cf13856ab5537fc/src/overlays/02.png
--------------------------------------------------------------------------------
/src/overlays/03.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jaysalvat/vegas/5fb29500e9d0fcdcf11b22b83cf13856ab5537fc/src/overlays/03.png
--------------------------------------------------------------------------------
/src/overlays/04.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jaysalvat/vegas/5fb29500e9d0fcdcf11b22b83cf13856ab5537fc/src/overlays/04.png
--------------------------------------------------------------------------------
/src/overlays/05.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jaysalvat/vegas/5fb29500e9d0fcdcf11b22b83cf13856ab5537fc/src/overlays/05.png
--------------------------------------------------------------------------------
/src/overlays/06.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jaysalvat/vegas/5fb29500e9d0fcdcf11b22b83cf13856ab5537fc/src/overlays/06.png
--------------------------------------------------------------------------------
/src/overlays/07.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jaysalvat/vegas/5fb29500e9d0fcdcf11b22b83cf13856ab5537fc/src/overlays/07.png
--------------------------------------------------------------------------------
/src/overlays/08.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jaysalvat/vegas/5fb29500e9d0fcdcf11b22b83cf13856ab5537fc/src/overlays/08.png
--------------------------------------------------------------------------------
/src/overlays/09.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jaysalvat/vegas/5fb29500e9d0fcdcf11b22b83cf13856ab5537fc/src/overlays/09.png
--------------------------------------------------------------------------------
/src/sass/animations/kenburns-down-left.sass:
--------------------------------------------------------------------------------
1 | /*******************************************/
2 | /* kenburnsDownLeft animation
3 | /*******************************************/
4 |
5 | .vegas-animation-kenburnsDownLeft
6 | animation: kenburnsDownLeft ease-out
7 |
8 | @keyframes kenburnsDownLeft
9 | 0%
10 | transform: scale($vegas-kenburns-scale) translate($vegas-kenburns-translate, -$vegas-kenburns-translate)
11 | 100%
12 | transform: scale(1) translate(0, 0)
--------------------------------------------------------------------------------
/src/sass/animations/kenburns-down-right.sass:
--------------------------------------------------------------------------------
1 | /*******************************************/
2 | /* kenburnsDownRight animation
3 | /*******************************************/
4 |
5 | .vegas-animation-kenburnsDownRight
6 | animation: kenburnsDownRight ease-out
7 |
8 | @keyframes kenburnsDownRight
9 | 0%
10 | transform: scale($vegas-kenburns-scale) translate(-$vegas-kenburns-translate, -$vegas-kenburns-translate)
11 | 100%
12 | transform: scale(1) translate(0, 0)
--------------------------------------------------------------------------------
/src/sass/animations/kenburns-down.sass:
--------------------------------------------------------------------------------
1 | /*******************************************/
2 | /* kenburnsDown animation
3 | /*******************************************/
4 |
5 | .vegas-animation-kenburnsDown
6 | animation: kenburnsDown ease-out
7 |
8 | @keyframes kenburnsDown
9 | 0%
10 | transform: scale($vegas-kenburns-scale) translate(0, -$vegas-kenburns-translate)
11 | 100%
12 | transform: scale(1) translate(0, 0)
--------------------------------------------------------------------------------
/src/sass/animations/kenburns-left.sass:
--------------------------------------------------------------------------------
1 | /*******************************************/
2 | /* kenburnsLeft animation
3 | /*******************************************/
4 |
5 | .vegas-animation-kenburnsLeft
6 | animation: kenburnsLeft ease-out
7 |
8 | @keyframes kenburnsLeft
9 | 0%
10 | transform: scale($vegas-kenburns-scale) translate($vegas-kenburns-translate, 0)
11 | 100%
12 | transform: scale(1) translate(0, 0)
--------------------------------------------------------------------------------
/src/sass/animations/kenburns-right.sass:
--------------------------------------------------------------------------------
1 | /*******************************************/
2 | /* kenburnsRight animation
3 | /*******************************************/
4 |
5 | .vegas-animation-kenburnsRight
6 | animation: kenburnsRight ease-out
7 |
8 | @keyframes kenburnsRight
9 | 0%
10 | transform: scale($vegas-kenburns-scale) translate(-$vegas-kenburns-translate, 0)
11 | 100%
12 | transform: scale(1) translate(0, 0)
--------------------------------------------------------------------------------
/src/sass/animations/kenburns-up-left.sass:
--------------------------------------------------------------------------------
1 | /*******************************************/
2 | /* kenburnsUpLeft animation
3 | /*******************************************/
4 |
5 | .vegas-animation-kenburnsUpLeft
6 | animation: kenburnsUpLeft ease-out
7 |
8 | @keyframes kenburnsUpLeft
9 | 0%
10 | transform: scale($vegas-kenburns-scale) translate($vegas-kenburns-translate, $vegas-kenburns-translate)
11 | 100%
12 | transform: scale(1) translate(0, 0)
--------------------------------------------------------------------------------
/src/sass/animations/kenburns-up-right.sass:
--------------------------------------------------------------------------------
1 | /*******************************************/
2 | /* kenburnsUpRight animation
3 | /*******************************************/
4 |
5 | .vegas-animation-kenburnsUpRight
6 | animation: kenburnsUpRight ease-out
7 |
8 | @keyframes kenburnsUpRight
9 | 0%
10 | transform: scale($vegas-kenburns-scale) translate(-$vegas-kenburns-translate, $vegas-kenburns-translate)
11 | 100%
12 | transform: scale(1) translate(0, 0)
13 |
--------------------------------------------------------------------------------
/src/sass/animations/kenburns-up.sass:
--------------------------------------------------------------------------------
1 | /*******************************************/
2 | /* kenburnsUp animation
3 | /*******************************************/
4 |
5 | .vegas-animation-kenburnsUp
6 | animation: kenburnsUp ease-out
7 |
8 | @keyframes kenburnsUp
9 | 0%
10 | transform: scale($vegas-kenburns-scale) translate(0, $vegas-kenburns-translate)
11 | 100%
12 | transform: scale(1) translate(0, 0)
--------------------------------------------------------------------------------
/src/sass/animations/kenburns.sass:
--------------------------------------------------------------------------------
1 | /*******************************************/
2 | /* kenburns animation
3 | /*******************************************/
4 |
5 | .vegas-animation-kenburns
6 | animation: kenburns ease-out
7 |
8 | @keyframes kenburns
9 | 0%
10 | transform: scale($vegas-kenburns-scale)
11 | 100%
12 | transform: scale(1)
--------------------------------------------------------------------------------
/src/sass/main/vegas.sass:
--------------------------------------------------------------------------------
1 | .vegas-overlay,
2 | .vegas-content-scrollable,
3 | .vegas-timer,
4 | .vegas-slide,
5 | .vegas-slide-inner
6 | position: absolute
7 | top: 0
8 | left: 0
9 | bottom: 0
10 | right: 0
11 | overflow: hidden
12 | border: none
13 | padding: 0
14 | margin: 0
15 |
16 | .vegas-content-scrollable
17 | position: relative
18 | height: 100%
19 | overflow: auto
20 |
21 | .vegas-overlay
22 | opacity: .5
23 | background: transparent url('./overlays/02.png') center center repeat
24 |
25 | .vegas-timer
26 | top: auto
27 | bottom: 0
28 | height: 2px
29 |
30 | .vegas-timer-progress
31 | width: 0%
32 | height: 100%
33 | background: $vegas-timer-color
34 | transition: width ease-out
35 |
36 | .vegas-timer-running .vegas-timer-progress
37 | width: 100%
38 |
39 | .vegas-slide,
40 | .vegas-slide-inner
41 | margin: 0
42 | padding: 0
43 | background: transparent center center no-repeat
44 | transform: translateZ(0)
45 | will-change: transform, opacity
46 |
47 | body .vegas-container
48 | overflow: hidden !important
49 | position: relative
50 |
51 | .vegas-video
52 | min-width: 100%
53 | min-height: 100%
54 | width: auto
55 | height: auto
56 |
57 | body.vegas-container
58 | overflow: auto
59 | position: static
60 | z-index: -2
61 |
62 | body.vegas-container > .vegas-timer,
63 | body.vegas-container > .vegas-overlay,
64 | body.vegas-container > .vegas-slide
65 | position: fixed
66 | z-index: -1
67 |
68 | /* Target Safari IOS7+ in order to add 76px */
69 | // _::full-page-media, _:future,
70 | // :root body.vegas-container > .vegas-slide,
71 | // :root body.vegas-container > .vegas-overlay
72 | // bottom: -76px
73 |
--------------------------------------------------------------------------------
/src/sass/transitions/blur.sass:
--------------------------------------------------------------------------------
1 | /*******************************************/
2 | /* blur transition
3 | /*******************************************/
4 |
5 | .vegas-transition-blur,
6 | .vegas-transition-blur2
7 | opacity: 0
8 | filter: blur($vegas-blur-value) brightness(1.01)
9 |
10 | .vegas-transition-blur-in,
11 | .vegas-transition-blur2-in
12 | opacity: 1
13 | filter: blur(0px) brightness(1.01)
14 |
15 | .vegas-transition-blur2-out
16 | opacity: 0
17 |
--------------------------------------------------------------------------------
/src/sass/transitions/burn.sass:
--------------------------------------------------------------------------------
1 | /*******************************************/
2 | /* burn transition
3 | /*******************************************/
4 |
5 | .vegas-transition-burn,
6 | .vegas-transition-burn2
7 | opacity: 0
8 | filter: contrast(1000%) saturate(1000%)
9 |
10 | .vegas-transition-burn-in,
11 | .vegas-transition-burn2-in
12 | opacity: 1
13 | filter: contrast(100%) saturate(100%)
14 |
15 | .vegas-transition-burn2-out
16 | opacity: 0
17 | filter: contrast(1000%) saturate(1000%)
--------------------------------------------------------------------------------
/src/sass/transitions/fade.sass:
--------------------------------------------------------------------------------
1 | /*******************************************/
2 | /* fade transition
3 | /*******************************************/
4 |
5 | .vegas-transition-fade,
6 | .vegas-transition-fade2
7 | opacity: 0
8 |
9 | .vegas-transition-fade-in,
10 | .vegas-transition-fade2-in
11 | opacity: 1
12 |
13 | .vegas-transition-fade2-out
14 | opacity: 0
--------------------------------------------------------------------------------
/src/sass/transitions/flash.sass:
--------------------------------------------------------------------------------
1 | /*******************************************/
2 | /* flash transition
3 | /*******************************************/
4 |
5 | .vegas-transition-flash,
6 | .vegas-transition-flash2
7 | opacity: 0
8 | filter: brightness(25)
9 |
10 | .vegas-transition-flash-in,
11 | .vegas-transition-flash2-in
12 | opacity: 1
13 | filter: brightness(1)
14 |
15 | .vegas-transition-flash2-out
16 | opacity: 0
17 | filter: brightness(25)
--------------------------------------------------------------------------------
/src/sass/transitions/negative.sass:
--------------------------------------------------------------------------------
1 | /*******************************************/
2 | /* negative transition
3 | /*******************************************/
4 |
5 | .vegas-transition-negative,
6 | .vegas-transition-negative2
7 | opacity: 0
8 | filter: invert(100%)
9 |
10 | .vegas-transition-negative-in,
11 | .vegas-transition-negative2-in
12 | opacity: 1
13 | filter: invert(0)
14 |
15 | .vegas-transition-negative2-out
16 | opacity: 0
17 | filter: invert(100%)
--------------------------------------------------------------------------------
/src/sass/transitions/slide-down.sass:
--------------------------------------------------------------------------------
1 | /*******************************************/
2 | /* slideDown transition
3 | /*******************************************/
4 |
5 | .vegas-transition-slideDown,
6 | .vegas-transition-slideDown2
7 | transform: translateY(-100%)
8 |
9 | .vegas-transition-slideDown-in,
10 | .vegas-transition-slideDown2-in
11 | transform: translateY(0%)
12 |
13 | .vegas-transition-slideDown2-out
14 | transform: translateY(100%)
--------------------------------------------------------------------------------
/src/sass/transitions/slide-left.sass:
--------------------------------------------------------------------------------
1 | /*******************************************/
2 | /* slideLeft transition
3 | /*******************************************/
4 |
5 | .vegas-transition-slideLeft,
6 | .vegas-transition-slideLeft2
7 | transform: translateX(100%)
8 |
9 | .vegas-transition-slideLeft-in,
10 | .vegas-transition-slideLeft2-in
11 | transform: translateX(0%)
12 |
13 | .vegas-transition-slideLeft2-out
14 | transform: translateX(-100%)
--------------------------------------------------------------------------------
/src/sass/transitions/slide-right.sass:
--------------------------------------------------------------------------------
1 | /*******************************************/
2 | /* slideRight transition
3 | /*******************************************/
4 |
5 | .vegas-transition-slideRight,
6 | .vegas-transition-slideRight2
7 | transform: translateX(-100%)
8 |
9 | .vegas-transition-slideRight-in,
10 | .vegas-transition-slideRight2-in
11 | transform: translateX(0%)
12 |
13 | .vegas-transition-slideRight2-out
14 | transform: translateX(100%)
--------------------------------------------------------------------------------
/src/sass/transitions/slide-up.sass:
--------------------------------------------------------------------------------
1 | /*******************************************/
2 | /* slideUp transition
3 | /*******************************************/
4 |
5 | .vegas-transition-slideUp,
6 | .vegas-transition-slideUp2
7 | transform: translateY(100%)
8 |
9 | .vegas-transition-slideUp-in,
10 | .vegas-transition-slideUp2-in
11 | transform: translateY(0%)
12 |
13 | .vegas-transition-slideUp2-out
14 | transform: translateY(-100%)
--------------------------------------------------------------------------------
/src/sass/transitions/swirl-left.sass:
--------------------------------------------------------------------------------
1 | /*******************************************/
2 | /* swirlLeft transition
3 | /*******************************************/
4 |
5 | .vegas-transition-swirlLeft,
6 | .vegas-transition-swirlLeft2
7 | transform: scale($vegas-swirl-scale) rotate($vegas-swirl-degree)
8 | opacity: 0
9 |
10 | .vegas-transition-swirlLeft-in,
11 | .vegas-transition-swirlLeft2-in
12 | transform: scale(1) rotate(0deg)
13 | opacity: 1
14 |
15 | .vegas-transition-swirlLeft2-out
16 | transform: scale($vegas-swirl-scale) rotate(-$vegas-swirl-degree)
17 | opacity: 0
--------------------------------------------------------------------------------
/src/sass/transitions/swirl-right.sass:
--------------------------------------------------------------------------------
1 | /*******************************************/
2 | /* swirlRight transition
3 | /*******************************************/
4 |
5 | .vegas-transition-swirlRight,
6 | .vegas-transition-swirlRight2
7 | transform: scale($vegas-swirl-scale) rotate(-$vegas-swirl-degree)
8 | opacity: 0
9 |
10 | .vegas-transition-swirlRight-in,
11 | .vegas-transition-swirlRight2-in
12 | transform: scale(1) rotate(0deg)
13 | opacity: 1
14 |
15 | .vegas-transition-swirlRight2-out
16 | transform: scale($vegas-swirl-scale) rotate($vegas-swirl-degree)
17 | opacity: 0
--------------------------------------------------------------------------------
/src/sass/transitions/zoom-in.sass:
--------------------------------------------------------------------------------
1 | /*******************************************/
2 | /* zoomIn transition
3 | /*******************************************/
4 |
5 | .vegas-transition-zoomIn,
6 | .vegas-transition-zoomIn2
7 | transform: scale(0)
8 | opacity: 0
9 |
10 | .vegas-transition-zoomIn-in,
11 | .vegas-transition-zoomIn2-in
12 | transform: scale(1)
13 | opacity: 1
14 |
15 | .vegas-transition-zoomIn2-out
16 | transform: scale($vegas-zoom-scale)
17 | opacity: 0
--------------------------------------------------------------------------------
/src/sass/transitions/zoom-out.sass:
--------------------------------------------------------------------------------
1 | /*******************************************/
2 | /* zoomOut transition
3 | /*******************************************/
4 |
5 | .vegas-transition-zoomOut,
6 | .vegas-transition-zoomOut2
7 | transform: scale($vegas-zoom-scale)
8 | opacity: 0
9 |
10 | .vegas-transition-zoomOut-in,
11 | .vegas-transition-zoomOut2-in
12 | transform: scale(1)
13 | opacity: 1
14 |
15 | .vegas-transition-zoomOut2-out
16 | transform: scale(0)
17 | opacity: 0
--------------------------------------------------------------------------------
/src/sass/vegas.sass:
--------------------------------------------------------------------------------
1 | // Vegas params
2 | $vegas-timer-color: white !default
3 |
4 | // Animation params
5 | $vegas-kenburns-scale: 1.5 !default
6 | $vegas-kenburns-translate: 10% !default
7 |
8 | // Transition params
9 | $vegas-blur-value: 32px !default // blur transition
10 | $vegas-swirl-degree: 35deg !default // swirl transition
11 | $vegas-swirl-scale: 2 !default // swirl transition
12 | $vegas-zoom-scale: 2 !default // zoom transition
13 |
14 | // Main
15 | @import 'main/vegas'
16 |
17 | // Transitions
18 | @import 'transitions/blur'
19 | @import 'transitions/burn'
20 | @import 'transitions/fade'
21 | @import 'transitions/flash'
22 | @import 'transitions/negative'
23 | @import 'transitions/slide-down'
24 | @import 'transitions/slide-left'
25 | @import 'transitions/slide-right'
26 | @import 'transitions/slide-up'
27 | @import 'transitions/swirl-left'
28 | @import 'transitions/swirl-right'
29 | @import 'transitions/zoom-in'
30 | @import 'transitions/zoom-out'
31 |
32 | // Animations
33 | @import 'animations/kenburns'
34 | @import 'animations/kenburns-down-left'
35 | @import 'animations/kenburns-down-right'
36 | @import 'animations/kenburns-down'
37 | @import 'animations/kenburns-left'
38 | @import 'animations/kenburns-right'
39 | @import 'animations/kenburns-up-left'
40 | @import 'animations/kenburns-up-right'
41 | @import 'animations/kenburns-up'
42 |
--------------------------------------------------------------------------------
/src/vegas.js:
--------------------------------------------------------------------------------
1 |
2 | (function ($) {
3 | 'use strict';
4 |
5 | var defaults = {
6 | slide: 0,
7 | delay: 5000,
8 | loop: true,
9 | preload: false,
10 | preloadImage: false,
11 | preloadVideo: false,
12 | timer: true,
13 | overlay: false,
14 | autoplay: true,
15 | shuffle: false,
16 | cover: true,
17 | color: null,
18 | align: 'center',
19 | valign: 'center',
20 | firstTransition: null,
21 | firstTransitionDuration: null,
22 | transition: 'fade',
23 | transitionDuration: 1000,
24 | transitionRegister: [],
25 | animation: null,
26 | animationDuration: 'auto',
27 | animationRegister: [],
28 | slidesToKeep: 1,
29 | init: function () {},
30 | play: function () {},
31 | pause: function () {},
32 | walk: function () {},
33 | slides: [
34 | // {
35 | // src: null,
36 | // color: null,
37 | // delay: null,
38 | // align: null,
39 | // valign: null,
40 | // transition: null,
41 | // transitionDuration: null,
42 | // animation: null,
43 | // animationDuration: null,
44 | // cover: true,
45 | // video: {
46 | // src: [],
47 | // muted: true,
48 | // loop: true
49 | // }
50 | // ...
51 | ]
52 | };
53 |
54 | var videoCache = {};
55 | var instances = 0;
56 |
57 | var Vegas = function (elmt, options) {
58 | this.elmt = elmt;
59 | this.settings = $.extend({}, defaults, $.vegas.defaults, options);
60 | this.slide = this.settings.slide;
61 | this.total = this.settings.slides.length;
62 | this.noshow = this.total < 2;
63 | this.paused = !this.settings.autoplay || this.noshow;
64 | this.ended = false;
65 | this.$elmt = $(elmt);
66 | this.$timer = null;
67 | this.$overlay = null;
68 | this.$slide = null;
69 | this.timeout = null;
70 | this.first = true;
71 |
72 | this.instance = instances++;
73 |
74 | this.transitions = [
75 | 'fade', 'fade2',
76 | 'blur', 'blur2',
77 | 'flash', 'flash2',
78 | 'negative', 'negative2',
79 | 'burn', 'burn2',
80 | 'slideLeft', 'slideLeft2',
81 | 'slideRight', 'slideRight2',
82 | 'slideUp', 'slideUp2',
83 | 'slideDown', 'slideDown2',
84 | 'zoomIn', 'zoomIn2',
85 | 'zoomOut', 'zoomOut2',
86 | 'swirlLeft', 'swirlLeft2',
87 | 'swirlRight', 'swirlRight2'
88 | ];
89 |
90 | this.animations = [
91 | 'kenburns',
92 | 'kenburnsLeft', 'kenburnsRight',
93 | 'kenburnsUp', 'kenburnsUpLeft', 'kenburnsUpRight',
94 | 'kenburnsDown', 'kenburnsDownLeft', 'kenburnsDownRight'
95 | ];
96 |
97 | if (!(this.settings.transitionRegister instanceof Array)) {
98 | this.settings.transitionRegister = [ this.settings.transitionRegister ];
99 | }
100 |
101 | if (!(this.settings.animationRegister instanceof Array)) {
102 | this.settings.animationRegister = [ this.settings.animationRegister ];
103 | }
104 |
105 | this.transitions = this.transitions.concat(this.settings.transitionRegister);
106 | this.animations = this.animations.concat(this.settings.animationRegister);
107 |
108 | this.support = {
109 | objectFit: 'objectFit' in document.body.style,
110 | transition: 'transition' in document.body.style || 'WebkitTransition' in document.body.style
111 | };
112 |
113 | if (this.settings.shuffle === true) {
114 | this.shuffle();
115 | }
116 | this._init();
117 | };
118 |
119 | Vegas.prototype = {
120 | _init: function () {
121 | var $content,
122 | $contentScroll,
123 | $overlay,
124 | $timer,
125 | isBody = this.elmt.tagName === 'BODY',
126 | timer = this.settings.timer,
127 | overlay = this.settings.overlay,
128 | self = this;
129 |
130 | // Preloading
131 | this._preload();
132 |
133 | // Div with scrollable content
134 | if (!isBody) {
135 | $contentScroll = $('
');
136 |
137 | $content = $('
')
138 | .css('overflow', this.$elmt.css('overflow'))
139 | .css('padding', this.$elmt.css('padding'));
140 |
141 | // Some browsers don't compute padding shorthand
142 | if (!this.$elmt.css('padding')) {
143 | $content
144 | .css('padding-top', this.$elmt.css('padding-top'))
145 | .css('padding-bottom', this.$elmt.css('padding-bottom'))
146 | .css('padding-left', this.$elmt.css('padding-left'))
147 | .css('padding-right', this.$elmt.css('padding-right'));
148 | }
149 |
150 | this.$elmt.css('padding', 0);
151 |
152 | this.$elmt.clone(true).children().appendTo($content);
153 | this.elmt.innerHTML = '';
154 | }
155 |
156 | // Timer
157 | if (timer && this.support.transition) {
158 | $timer = $('
');
159 | this.$timer = $timer;
160 | this.$elmt.prepend($timer);
161 | }
162 |
163 | // Overlay
164 | if (overlay) {
165 | $overlay = $('
');
166 |
167 | if (typeof overlay === 'string') {
168 | $overlay.css('background-image', 'url(' + overlay + ')');
169 | }
170 |
171 | this.$overlay = $overlay;
172 | this.$elmt.prepend($overlay);
173 | }
174 |
175 | // Container
176 | this.$elmt.addClass('vegas-container');
177 |
178 | if (!isBody) {
179 | this.$elmt.append($contentScroll);
180 | $contentScroll.append($content);
181 | }
182 |
183 | setTimeout(function () {
184 | self.trigger('init');
185 | self._goto(self.slide);
186 |
187 | if (self.settings.autoplay) {
188 | self.trigger('play');
189 | }
190 | }, 1);
191 | },
192 |
193 | _preload: function () {
194 | var img, i;
195 |
196 | for (i = 0; i < this.settings.slides.length; i++) {
197 | if (this.settings.preload || this.settings.preloadImages) {
198 | if (this.settings.slides[i].src) {
199 | img = new Image();
200 | img.src = this.settings.slides[i].src;
201 | }
202 | }
203 |
204 | if (this.settings.preload || this.settings.preloadVideos) {
205 | if (this.settings.slides[i].video) {
206 | if (this.settings.slides[i].video instanceof Array) {
207 | this._video(this.settings.slides[i].video);
208 | } else {
209 | this._video(this.settings.slides[i].video.src);
210 | }
211 | }
212 | }
213 | }
214 | },
215 |
216 | _random: function (array) {
217 | return array[Math.floor(Math.random() * array.length)];
218 | },
219 |
220 | _slideShow: function () {
221 | var self = this;
222 |
223 | if (this.total > 1 && !this.ended && !this.paused && !this.noshow) {
224 | this.timeout = setTimeout(function () {
225 | self.next();
226 | }, this._options('delay'));
227 | }
228 | },
229 |
230 | _timer: function (state) {
231 | var self = this;
232 |
233 | clearTimeout(this.timeout);
234 |
235 | if (!this.$timer) {
236 | return;
237 | }
238 |
239 | this.$timer
240 | .removeClass('vegas-timer-running')
241 | .find('div')
242 | .css('transition-duration', '0ms');
243 |
244 | if (this.ended || this.paused || this.noshow) {
245 | return;
246 | }
247 |
248 | if (state) {
249 | setTimeout(function () {
250 | self.$timer
251 | .addClass('vegas-timer-running')
252 | .find('div')
253 | .css('transition-duration', self._options('delay') - 100 + 'ms');
254 | }, 100);
255 | }
256 | },
257 |
258 | _video: function (srcs) {
259 | var video,
260 | source,
261 | cacheKey = this.instance + srcs.toString();
262 |
263 | if (videoCache[cacheKey]) {
264 | return videoCache[cacheKey];
265 | }
266 |
267 | if (!(srcs instanceof Array)) {
268 | srcs = [ srcs ];
269 | }
270 |
271 | video = document.createElement('video');
272 | video.preload = true;
273 | video.playsInline = true;
274 | video.controls = false;
275 |
276 | srcs.forEach(function (src) {
277 | source = document.createElement('source');
278 | source.src = src;
279 | video.appendChild(source);
280 | });
281 |
282 | videoCache[cacheKey] = video;
283 |
284 | return video;
285 | },
286 |
287 | _fadeOutSound: function (video, duration) {
288 | var self = this,
289 | delay = duration / 10,
290 | volume = video.volume - 0.09;
291 |
292 | if (volume > 0) {
293 | video.volume = volume;
294 |
295 | setTimeout(function () {
296 | self._fadeOutSound(video, duration);
297 | }, delay);
298 | } else {
299 | video.pause();
300 | }
301 | },
302 |
303 | _fadeInSound: function (video, duration) {
304 | var self = this,
305 | delay = duration / 10,
306 | volume = video.volume + 0.09;
307 |
308 | if (volume < 1) {
309 | video.volume = volume;
310 |
311 | setTimeout(function () {
312 | self._fadeInSound(video, duration);
313 | }, delay);
314 | }
315 | },
316 |
317 | _options: function (key, i) {
318 | if (i === undefined) {
319 | i = this.slide;
320 | }
321 |
322 | if (this.settings.slides[i][key] !== undefined) {
323 | return this.settings.slides[i][key];
324 | }
325 |
326 | return this.settings[key];
327 | },
328 |
329 | _goto: function (nb) {
330 | if (typeof this.settings.slides[nb] === 'undefined') {
331 | nb = 0;
332 | }
333 |
334 | this.slide = nb;
335 |
336 | var $slide,
337 | $inner,
338 | $video,
339 | $slides = this.$elmt.children('.vegas-slide'),
340 | src = this.settings.slides[nb].src,
341 | videoSettings = this.settings.slides[nb].video,
342 | delay = this._options('delay'),
343 | align = this._options('align'),
344 | valign = this._options('valign'),
345 | cover = this._options('cover'),
346 | color = this._options('color') || this.$elmt.css('background-color'),
347 | self = this,
348 | total = $slides.length,
349 | video,
350 | img;
351 |
352 | var transition = this._options('transition'),
353 | transitionDuration = this._options('transitionDuration'),
354 | animation = this._options('animation'),
355 | animationDuration = this._options('animationDuration');
356 |
357 | if (this.settings.firstTransition && this.first) {
358 | transition = this.settings.firstTransition || transition;
359 | }
360 |
361 | if (this.settings.firstTransitionDuration && this.first) {
362 | transitionDuration = this.settings.firstTransitionDuration || transitionDuration;
363 | }
364 |
365 | if (this.first) {
366 | this.first = false;
367 | }
368 |
369 | if (cover !== 'repeat') {
370 | if (cover === true) {
371 | cover = 'cover';
372 | } else if (cover === false) {
373 | cover = 'contain';
374 | }
375 | }
376 |
377 | if (transition === 'random' || transition instanceof Array) {
378 | if (transition instanceof Array) {
379 | transition = this._random(transition);
380 | } else {
381 | transition = this._random(this.transitions);
382 | }
383 | }
384 |
385 | if (animation === 'random' || animation instanceof Array) {
386 | if (animation instanceof Array) {
387 | animation = this._random(animation);
388 | } else {
389 | animation = this._random(this.animations);
390 | }
391 | }
392 |
393 | if (transitionDuration === 'auto' || transitionDuration > delay) {
394 | transitionDuration = delay;
395 | }
396 |
397 | if (animationDuration === 'auto') {
398 | animationDuration = delay;
399 | }
400 |
401 | $slide = $('
');
402 |
403 | if (this.support.transition && transition) {
404 | $slide.addClass('vegas-transition-' + transition);
405 | }
406 |
407 | // Video
408 |
409 | if (videoSettings) {
410 | if (videoSettings instanceof Array) {
411 | video = this._video(videoSettings);
412 | } else {
413 | video = this._video(videoSettings.src);
414 | }
415 |
416 | video.loop = videoSettings.loop !== undefined ? videoSettings.loop : true;
417 | video.muted = videoSettings.muted !== undefined ? videoSettings.muted : true;
418 |
419 | if (video.muted === false) {
420 | video.volume = 0;
421 | this._fadeInSound(video, transitionDuration);
422 | } else {
423 | video.pause();
424 | }
425 |
426 | $video = $(video)
427 | .addClass('vegas-video')
428 | .css('background-color', color);
429 |
430 | if (this.support.objectFit) {
431 | $video
432 | .css('object-position', align + ' ' + valign)
433 | .css('object-fit', cover)
434 | .css('width', '100%')
435 | .css('height', '100%');
436 | } else if (cover === 'contain') {
437 | $video
438 | .css('width', '100%')
439 | .css('height', '100%');
440 | }
441 |
442 | $slide.append($video);
443 |
444 | // Image
445 |
446 | } else {
447 | img = new Image();
448 |
449 | $inner = $('
')
450 | .css('background-image', 'url("' + src + '")')
451 | .css('background-color', color)
452 | .css('background-position', align + ' ' + valign);
453 |
454 | if (cover === 'repeat') {
455 | $inner.css('background-repeat', 'repeat');
456 | } else {
457 | $inner.css('background-size', cover);
458 | }
459 |
460 | if (this.support.transition && animation) {
461 | $inner
462 | .addClass('vegas-animation-' + animation)
463 | .css('animation-duration', animationDuration + 'ms');
464 | }
465 |
466 | $slide.append($inner);
467 | }
468 |
469 | if (!this.support.transition) {
470 | $slide.css('display', 'none');
471 | }
472 |
473 | if (total) {
474 | $slides.eq(total - 1).after($slide);
475 | } else {
476 | this.$elmt.prepend($slide);
477 | }
478 |
479 | $slides
480 | .css('transition', 'all 0ms')
481 | .each(function () {
482 | this.className = 'vegas-slide';
483 |
484 | if (this.tagName === 'VIDEO') {
485 | this.className += ' vegas-video';
486 | }
487 |
488 | if (transition) {
489 | this.className += ' vegas-transition-' + transition;
490 | this.className += ' vegas-transition-' + transition + '-in';
491 | }
492 | }
493 | );
494 |
495 | self._timer(false);
496 |
497 | function go () {
498 | self._timer(true);
499 |
500 | setTimeout(function () {
501 | if (transition) {
502 | if (self.support.transition) {
503 | $slides
504 | .css('transition', 'all ' + transitionDuration + 'ms')
505 | .addClass('vegas-transition-' + transition + '-out');
506 |
507 | $slides.each(function () {
508 | var video = $slides.find('video').get(0);
509 |
510 | if (video) {
511 | video.volume = 1;
512 | self._fadeOutSound(video, transitionDuration);
513 | }
514 | });
515 |
516 | $slide
517 | .css('transition', 'all ' + transitionDuration + 'ms')
518 | .addClass('vegas-transition-' + transition + '-in');
519 | } else {
520 | $slide.fadeIn(transitionDuration);
521 | }
522 | }
523 |
524 | for (var i = 0; i < $slides.length - self.settings.slidesToKeep; i++) {
525 | $slides.eq(i).remove();
526 | }
527 |
528 | self.trigger('walk');
529 | self._slideShow();
530 | }, 100);
531 | }
532 | if (video) {
533 | if (video.readyState === 4) {
534 | video.currentTime = 0;
535 | }
536 |
537 | video.play();
538 | go();
539 | } else {
540 | img.src = src;
541 |
542 | if (img.complete) {
543 | go();
544 | } else {
545 | img.onload = go;
546 | }
547 | }
548 | },
549 |
550 | _end: function () {
551 | this.ended = !this.settings.autoplay;
552 | this._timer(false);
553 | this.trigger('end');
554 | },
555 |
556 | shuffle: function () {
557 | var temp,
558 | rand;
559 |
560 | for (var i = this.total - 1; i > 0; i--) {
561 | rand = Math.floor(Math.random() * (i + 1));
562 | temp = this.settings.slides[i];
563 |
564 | this.settings.slides[i] = this.settings.slides[rand];
565 | this.settings.slides[rand] = temp;
566 | }
567 | },
568 |
569 | play: function () {
570 | if (this.paused) {
571 | this.paused = false;
572 | this.next();
573 | this.trigger('play');
574 | }
575 | },
576 |
577 | pause: function () {
578 | this._timer(false);
579 | this.paused = true;
580 | this.trigger('pause');
581 | },
582 |
583 | toggle: function () {
584 | if (this.paused) {
585 | this.play();
586 | } else {
587 | this.pause();
588 | }
589 | },
590 |
591 | playing: function () {
592 | return !this.paused && !this.noshow;
593 | },
594 |
595 | current: function (advanced) {
596 | if (advanced) {
597 | return {
598 | slide: this.slide,
599 | data: this.settings.slides[this.slide]
600 | };
601 | }
602 | return this.slide;
603 | },
604 |
605 | jump: function (nb) {
606 | if (nb < 0 || nb > this.total - 1 || nb === this.slide) {
607 | return;
608 | }
609 |
610 | this.slide = nb;
611 | this._goto(this.slide);
612 | },
613 |
614 | next: function () {
615 | this.slide++;
616 |
617 | if (this.slide >= this.total) {
618 | if (!this.settings.loop) {
619 | return this._end();
620 | }
621 |
622 | this.slide = 0;
623 | }
624 |
625 | this._goto(this.slide);
626 | },
627 |
628 | previous: function () {
629 | this.slide--;
630 |
631 | if (this.slide < 0) {
632 | if (!this.settings.loop) {
633 | this.slide++;
634 | return;
635 | } else {
636 | this.slide = this.total - 1;
637 | }
638 | }
639 |
640 | this._goto(this.slide);
641 | },
642 |
643 | trigger: function (fn) {
644 | var params = [];
645 |
646 | if (fn === 'init') {
647 | params = [ this.settings ];
648 | } else {
649 | params = [
650 | this.slide,
651 | this.settings.slides[this.slide]
652 | ];
653 | }
654 |
655 | this.$elmt.trigger('vegas' + fn, params);
656 |
657 | if (typeof this.settings[fn] === 'function') {
658 | this.settings[fn].apply(this.$elmt, params);
659 | }
660 | },
661 |
662 | options: function (key, value) {
663 | var oldSlides = this.settings.slides.slice();
664 |
665 | if (typeof key === 'object') {
666 | this.settings = $.extend({}, defaults, $.vegas.defaults, key);
667 | } else if (typeof key === 'string') {
668 | if (value === undefined) {
669 | return this.settings[key];
670 | }
671 | this.settings[key] = value;
672 | } else {
673 | return this.settings;
674 | }
675 |
676 | // In case slides have changed
677 | if (this.settings.slides !== oldSlides) {
678 | this.total = this.settings.slides.length;
679 | this.noshow = this.total < 2;
680 | this._preload();
681 | }
682 | },
683 |
684 | destroy: function () {
685 | clearTimeout(this.timeout);
686 |
687 | this.$elmt.removeClass('vegas-container');
688 | this.$elmt.find('> .vegas-slide').remove();
689 | this.$elmt.find('> .vegas-wrapper').clone(true).children().appendTo(this.$elmt);
690 | this.$elmt.find('> .vegas-wrapper').remove();
691 |
692 | if (this.settings.timer) {
693 | this.$timer.remove();
694 | }
695 |
696 | if (this.settings.overlay) {
697 | this.$overlay.remove();
698 | }
699 |
700 | this.elmt._vegas = null;
701 | }
702 | };
703 |
704 | $.fn.vegas = function(options) {
705 | var args = arguments,
706 | error = false,
707 | returns;
708 |
709 | if (options === undefined || typeof options === 'object') {
710 | return this.each(function () {
711 | if (!this._vegas) {
712 | this._vegas = new Vegas(this, options);
713 | }
714 | });
715 | } else if (typeof options === 'string') {
716 | this.each(function () {
717 | var instance = this._vegas;
718 |
719 | if (!instance) {
720 | throw new Error('No Vegas applied to this element.');
721 | }
722 |
723 | if (typeof instance[options] === 'function' && options[0] !== '_') {
724 | returns = instance[options].apply(instance, [].slice.call(args, 1));
725 | } else {
726 | error = true;
727 | }
728 | });
729 |
730 | if (error) {
731 | throw new Error('No method "' + options + '" in Vegas.');
732 | }
733 |
734 | return returns !== undefined ? returns : this;
735 | }
736 | };
737 |
738 | $.vegas = {};
739 | $.vegas.defaults = defaults;
740 |
741 | $.vegas.isVideoCompatible = function () {
742 | return true;
743 | };
744 |
745 | })(window.jQuery || window.Zepto || window.m4q);
746 |
--------------------------------------------------------------------------------