Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 963d3db

Browse files
committed
Initial Commit
1 parent 23a14c5 commit 963d3db

18 files changed

+1966
-4
lines changed

gallery/js/lg-autoplay.js

Lines changed: 206 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,206 @@
1+
/*! lg-autoplay - v1.0.4 - 2017-03-28
2+
* http://sachinchoolur.github.io/lightGallery
3+
* Copyright (c) 2017 Sachin N; Licensed GPLv3 */
4+
5+
(function (root, factory) {
6+
if (typeof define === 'function' && define.amd) {
7+
// AMD. Register as an anonymous module unless amdModuleId is set
8+
define(['jquery'], function (a0) {
9+
return (factory(a0));
10+
});
11+
} else if (typeof exports === 'object') {
12+
// Node. Does not work with strict CommonJS, but
13+
// only CommonJS-like environments that support module.exports,
14+
// like Node.
15+
module.exports = factory(require('jquery'));
16+
} else {
17+
factory(jQuery);
18+
}
19+
}(this, function ($) {
20+
21+
22+
(function() {
23+
24+
'use strict';
25+
26+
var defaults = {
27+
autoplay: false,
28+
pause: 5000,
29+
progressBar: true,
30+
fourceAutoplay: false,
31+
autoplayControls: true,
32+
appendAutoplayControlsTo: '.lg-toolbar'
33+
};
34+
35+
/**
36+
* Creates the autoplay plugin.
37+
* @param {object} element - lightGallery element
38+
*/
39+
var Autoplay = function(element) {
40+
41+
this.core = $(element).data('lightGallery');
42+
43+
this.$el = $(element);
44+
45+
// Execute only if items are above 1
46+
if (this.core.$items.length < 2) {
47+
return false;
48+
}
49+
50+
this.core.s = $.extend({}, defaults, this.core.s);
51+
this.interval = false;
52+
53+
// Identify if slide happened from autoplay
54+
this.fromAuto = true;
55+
56+
// Identify if autoplay canceled from touch/drag
57+
this.canceledOnTouch = false;
58+
59+
// save fourceautoplay value
60+
this.fourceAutoplayTemp = this.core.s.fourceAutoplay;
61+
62+
// do not allow progress bar if browser does not support css3 transitions
63+
if (!this.core.doCss()) {
64+
this.core.s.progressBar = false;
65+
}
66+
67+
this.init();
68+
69+
return this;
70+
};
71+
72+
Autoplay.prototype.init = function() {
73+
var _this = this;
74+
75+
// append autoplay controls
76+
if (_this.core.s.autoplayControls) {
77+
_this.controls();
78+
}
79+
80+
// Create progress bar
81+
if (_this.core.s.progressBar) {
82+
_this.core.$outer.find('.lg').append('<div class="lg-progress-bar"><div class="lg-progress"></div></div>');
83+
}
84+
85+
// set progress
86+
_this.progress();
87+
88+
// Start autoplay
89+
if (_this.core.s.autoplay) {
90+
_this.$el.one('onSlideItemLoad.lg.tm', function() {
91+
_this.startlAuto();
92+
});
93+
}
94+
95+
// cancel interval on touchstart and dragstart
96+
_this.$el.on('onDragstart.lg.tm touchstart.lg.tm', function() {
97+
if (_this.interval) {
98+
_this.cancelAuto();
99+
_this.canceledOnTouch = true;
100+
}
101+
});
102+
103+
// restore autoplay if autoplay canceled from touchstart / dragstart
104+
_this.$el.on('onDragend.lg.tm touchend.lg.tm onSlideClick.lg.tm', function() {
105+
if (!_this.interval && _this.canceledOnTouch) {
106+
_this.startlAuto();
107+
_this.canceledOnTouch = false;
108+
}
109+
});
110+
111+
};
112+
113+
Autoplay.prototype.progress = function() {
114+
115+
var _this = this;
116+
var _$progressBar;
117+
var _$progress;
118+
119+
_this.$el.on('onBeforeSlide.lg.tm', function() {
120+
121+
// start progress bar animation
122+
if (_this.core.s.progressBar && _this.fromAuto) {
123+
_$progressBar = _this.core.$outer.find('.lg-progress-bar');
124+
_$progress = _this.core.$outer.find('.lg-progress');
125+
if (_this.interval) {
126+
_$progress.removeAttr('style');
127+
_$progressBar.removeClass('lg-start');
128+
setTimeout(function() {
129+
_$progress.css('transition', 'width ' + (_this.core.s.speed + _this.core.s.pause) + 'ms ease 0s');
130+
_$progressBar.addClass('lg-start');
131+
}, 20);
132+
}
133+
}
134+
135+
// Remove setinterval if slide is triggered manually and fourceautoplay is false
136+
if (!_this.fromAuto && !_this.core.s.fourceAutoplay) {
137+
_this.cancelAuto();
138+
}
139+
140+
_this.fromAuto = false;
141+
142+
});
143+
};
144+
145+
// Manage autoplay via play/stop buttons
146+
Autoplay.prototype.controls = function() {
147+
var _this = this;
148+
var _html = '<span class="lg-autoplay-button lg-icon"></span>';
149+
150+
// Append autoplay controls
151+
$(this.core.s.appendAutoplayControlsTo).append(_html);
152+
153+
_this.core.$outer.find('.lg-autoplay-button').on('click.lg', function() {
154+
if ($(_this.core.$outer).hasClass('lg-show-autoplay')) {
155+
_this.cancelAuto();
156+
_this.core.s.fourceAutoplay = false;
157+
} else {
158+
if (!_this.interval) {
159+
_this.startlAuto();
160+
_this.core.s.fourceAutoplay = _this.fourceAutoplayTemp;
161+
}
162+
}
163+
});
164+
};
165+
166+
// Autostart gallery
167+
Autoplay.prototype.startlAuto = function() {
168+
var _this = this;
169+
170+
_this.core.$outer.find('.lg-progress').css('transition', 'width ' + (_this.core.s.speed + _this.core.s.pause) + 'ms ease 0s');
171+
_this.core.$outer.addClass('lg-show-autoplay');
172+
_this.core.$outer.find('.lg-progress-bar').addClass('lg-start');
173+
174+
_this.interval = setInterval(function() {
175+
if (_this.core.index + 1 < _this.core.$items.length) {
176+
_this.core.index++;
177+
} else {
178+
_this.core.index = 0;
179+
}
180+
181+
_this.fromAuto = true;
182+
_this.core.slide(_this.core.index, false, false, 'next');
183+
}, _this.core.s.speed + _this.core.s.pause);
184+
};
185+
186+
// cancel Autostart
187+
Autoplay.prototype.cancelAuto = function() {
188+
clearInterval(this.interval);
189+
this.interval = false;
190+
this.core.$outer.find('.lg-progress').removeAttr('style');
191+
this.core.$outer.removeClass('lg-show-autoplay');
192+
this.core.$outer.find('.lg-progress-bar').removeClass('lg-start');
193+
};
194+
195+
Autoplay.prototype.destroy = function() {
196+
197+
this.cancelAuto();
198+
this.core.$outer.find('.lg-progress-bar').remove();
199+
};
200+
201+
$.fn.lightGallery.modules.autoplay = Autoplay;
202+
203+
})();
204+
205+
206+
}));

gallery/js/lg-autoplay.min.js

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gallery/js/lg-fullscreen.js

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
/*! lg-fullscreen - v1.0.0 - 2016-09-20
2+
* http://sachinchoolur.github.io/lightGallery
3+
* Copyright (c) 2016 Sachin N; Licensed GPLv3 */
4+
5+
(function (root, factory) {
6+
if (typeof define === 'function' && define.amd) {
7+
// AMD. Register as an anonymous module unless amdModuleId is set
8+
define([], function () {
9+
return (factory());
10+
});
11+
} else if (typeof exports === 'object') {
12+
// Node. Does not work with strict CommonJS, but
13+
// only CommonJS-like environments that support module.exports,
14+
// like Node.
15+
module.exports = factory();
16+
} else {
17+
factory();
18+
}
19+
}(this, function () {
20+
21+
(function($, window, document, undefined) {
22+
23+
'use strict';
24+
25+
var defaults = {
26+
fullScreen: true
27+
};
28+
29+
var Fullscreen = function(element) {
30+
31+
// get lightGallery core plugin data
32+
this.core = $(element).data('lightGallery');
33+
34+
this.$el = $(element);
35+
36+
// extend module defalut settings with lightGallery core settings
37+
this.core.s = $.extend({}, defaults, this.core.s);
38+
39+
this.init();
40+
41+
return this;
42+
};
43+
44+
Fullscreen.prototype.init = function() {
45+
var fullScreen = '';
46+
if (this.core.s.fullScreen) {
47+
48+
// check for fullscreen browser support
49+
if (!document.fullscreenEnabled && !document.webkitFullscreenEnabled &&
50+
!document.mozFullScreenEnabled && !document.msFullscreenEnabled) {
51+
return;
52+
} else {
53+
fullScreen = '<span class="lg-fullscreen lg-icon"></span>';
54+
this.core.$outer.find('.lg-toolbar').append(fullScreen);
55+
this.fullScreen();
56+
}
57+
}
58+
};
59+
60+
Fullscreen.prototype.requestFullscreen = function() {
61+
var el = document.documentElement;
62+
if (el.requestFullscreen) {
63+
el.requestFullscreen();
64+
} else if (el.msRequestFullscreen) {
65+
el.msRequestFullscreen();
66+
} else if (el.mozRequestFullScreen) {
67+
el.mozRequestFullScreen();
68+
} else if (el.webkitRequestFullscreen) {
69+
el.webkitRequestFullscreen();
70+
}
71+
};
72+
73+
Fullscreen.prototype.exitFullscreen = function() {
74+
if (document.exitFullscreen) {
75+
document.exitFullscreen();
76+
} else if (document.msExitFullscreen) {
77+
document.msExitFullscreen();
78+
} else if (document.mozCancelFullScreen) {
79+
document.mozCancelFullScreen();
80+
} else if (document.webkitExitFullscreen) {
81+
document.webkitExitFullscreen();
82+
}
83+
};
84+
85+
// https://developer.mozilla.org/en-US/docs/Web/Guide/API/DOM/Using_full_screen_mode
86+
Fullscreen.prototype.fullScreen = function() {
87+
var _this = this;
88+
89+
$(document).on('fullscreenchange.lg webkitfullscreenchange.lg mozfullscreenchange.lg MSFullscreenChange.lg', function() {
90+
_this.core.$outer.toggleClass('lg-fullscreen-on');
91+
});
92+
93+
this.core.$outer.find('.lg-fullscreen').on('click.lg', function() {
94+
if (!document.fullscreenElement &&
95+
!document.mozFullScreenElement && !document.webkitFullscreenElement && !document.msFullscreenElement) {
96+
_this.requestFullscreen();
97+
} else {
98+
_this.exitFullscreen();
99+
}
100+
});
101+
102+
};
103+
104+
Fullscreen.prototype.destroy = function() {
105+
106+
// exit from fullscreen if activated
107+
this.exitFullscreen();
108+
109+
$(document).off('fullscreenchange.lg webkitfullscreenchange.lg mozfullscreenchange.lg MSFullscreenChange.lg');
110+
};
111+
112+
$.fn.lightGallery.modules.fullscreen = Fullscreen;
113+
114+
})(jQuery, window, document);
115+
116+
}));

gallery/js/lg-fullscreen.min.js

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)