first commit
This commit is contained in:
27
modules/mod_jt_contentslider/tmpl/assets/js/default.js
Normal file
27
modules/mod_jt_contentslider/tmpl/assets/js/default.js
Normal file
@@ -0,0 +1,27 @@
|
||||
JTCJ = jQuery.noConflict();
|
||||
jQuery(document).ready(function () {
|
||||
if (typeof(jtcModuleIds) != 'undefined') {
|
||||
for (var i = 0; i < jtcModuleIds.length; i++) {
|
||||
jQuery('#jtcontentslider' + jtcModuleIds[i]).css("direction", "ltr");
|
||||
jQuery('#jtcontentslider' + jtcModuleIds[i]).fadeIn("fast");
|
||||
|
||||
if(btcModuleOpts[i].width=='auto'){
|
||||
jQuery('#jtcontentslider' + jtcModuleIds[i] + ' .slide').width(jQuery('#jtcontentslider' + jtcModuleIds[i] + ' .slide').width());
|
||||
}
|
||||
|
||||
JTCJ('#jtcontentslider' + jtcModuleIds[i]).slides(btcModuleOpts[i]);
|
||||
if (jQuery("html").css("direction") == "rtl") {
|
||||
jQuery('#jtcontentslider' + jtcModuleIds[i] + ' .slides_control').css("direction", "rtl");
|
||||
}
|
||||
}
|
||||
}
|
||||
jQuery('img.hovereffect').hover(function () {
|
||||
jQuery(this).stop(true).animate({
|
||||
opacity : 0.5
|
||||
}, 300)
|
||||
}, function () {
|
||||
jQuery(this).animate({
|
||||
opacity : 1
|
||||
}, 300)
|
||||
})
|
||||
})
|
||||
1
modules/mod_jt_contentslider/tmpl/assets/js/index.html
Normal file
1
modules/mod_jt_contentslider/tmpl/assets/js/index.html
Normal file
@@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
||||
205
modules/mod_jt_contentslider/tmpl/assets/js/jquery.easing.1.3.js
Normal file
205
modules/mod_jt_contentslider/tmpl/assets/js/jquery.easing.1.3.js
Normal file
@@ -0,0 +1,205 @@
|
||||
/*
|
||||
* JTCJ Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/
|
||||
*
|
||||
* Uses the built in easing capabilities added In JTCJ 1.1
|
||||
* to offer multiple easing options
|
||||
*
|
||||
* TERMS OF USE - JTCJ Easing
|
||||
*
|
||||
* Open source under the BSD License.
|
||||
*
|
||||
* Copyright © 2008 George McGinley Smith
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* Neither the name of the author nor the names of contributors may be used to endorse
|
||||
* or promote products derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
// t: current time, b: begInnIng value, c: change In value, d: duration
|
||||
JTCJ.easing['jswing'] = JTCJ.easing['swing'];
|
||||
|
||||
JTCJ.extend( JTCJ.easing,
|
||||
{
|
||||
def: 'easeOutQuad',
|
||||
swing: function (x, t, b, c, d) {
|
||||
//alert(JTCJ.easing.default);
|
||||
return JTCJ.easing[JTCJ.easing.def](x, t, b, c, d);
|
||||
},
|
||||
easeInQuad: function (x, t, b, c, d) {
|
||||
return c*(t/=d)*t + b;
|
||||
},
|
||||
easeOutQuad: function (x, t, b, c, d) {
|
||||
return -c *(t/=d)*(t-2) + b;
|
||||
},
|
||||
easeInOutQuad: function (x, t, b, c, d) {
|
||||
if ((t/=d/2) < 1) return c/2*t*t + b;
|
||||
return -c/2 * ((--t)*(t-2) - 1) + b;
|
||||
},
|
||||
easeInCubic: function (x, t, b, c, d) {
|
||||
return c*(t/=d)*t*t + b;
|
||||
},
|
||||
easeOutCubic: function (x, t, b, c, d) {
|
||||
return c*((t=t/d-1)*t*t + 1) + b;
|
||||
},
|
||||
easeInOutCubic: function (x, t, b, c, d) {
|
||||
if ((t/=d/2) < 1) return c/2*t*t*t + b;
|
||||
return c/2*((t-=2)*t*t + 2) + b;
|
||||
},
|
||||
easeInQuart: function (x, t, b, c, d) {
|
||||
return c*(t/=d)*t*t*t + b;
|
||||
},
|
||||
easeOutQuart: function (x, t, b, c, d) {
|
||||
return -c * ((t=t/d-1)*t*t*t - 1) + b;
|
||||
},
|
||||
easeInOutQuart: function (x, t, b, c, d) {
|
||||
if ((t/=d/2) < 1) return c/2*t*t*t*t + b;
|
||||
return -c/2 * ((t-=2)*t*t*t - 2) + b;
|
||||
},
|
||||
easeInQuint: function (x, t, b, c, d) {
|
||||
return c*(t/=d)*t*t*t*t + b;
|
||||
},
|
||||
easeOutQuint: function (x, t, b, c, d) {
|
||||
return c*((t=t/d-1)*t*t*t*t + 1) + b;
|
||||
},
|
||||
easeInOutQuint: function (x, t, b, c, d) {
|
||||
if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
|
||||
return c/2*((t-=2)*t*t*t*t + 2) + b;
|
||||
},
|
||||
easeInSine: function (x, t, b, c, d) {
|
||||
return -c * Math.cos(t/d * (Math.PI/2)) + c + b;
|
||||
},
|
||||
easeOutSine: function (x, t, b, c, d) {
|
||||
return c * Math.sin(t/d * (Math.PI/2)) + b;
|
||||
},
|
||||
easeInOutSine: function (x, t, b, c, d) {
|
||||
return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;
|
||||
},
|
||||
easeInExpo: function (x, t, b, c, d) {
|
||||
return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;
|
||||
},
|
||||
easeOutExpo: function (x, t, b, c, d) {
|
||||
return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
|
||||
},
|
||||
easeInOutExpo: function (x, t, b, c, d) {
|
||||
if (t==0) return b;
|
||||
if (t==d) return b+c;
|
||||
if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
|
||||
return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
|
||||
},
|
||||
easeInCirc: function (x, t, b, c, d) {
|
||||
return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;
|
||||
},
|
||||
easeOutCirc: function (x, t, b, c, d) {
|
||||
return c * Math.sqrt(1 - (t=t/d-1)*t) + b;
|
||||
},
|
||||
easeInOutCirc: function (x, t, b, c, d) {
|
||||
if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b;
|
||||
return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b;
|
||||
},
|
||||
easeInElastic: function (x, t, b, c, d) {
|
||||
var s=1.70158;var p=0;var a=c;
|
||||
if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;
|
||||
if (a < Math.abs(c)) { a=c; var s=p/4; }
|
||||
else var s = p/(2*Math.PI) * Math.asin (c/a);
|
||||
return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
|
||||
},
|
||||
easeOutElastic: function (x, t, b, c, d) {
|
||||
var s=1.70158;var p=0;var a=c;
|
||||
if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;
|
||||
if (a < Math.abs(c)) { a=c; var s=p/4; }
|
||||
else var s = p/(2*Math.PI) * Math.asin (c/a);
|
||||
return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
|
||||
},
|
||||
easeInOutElastic: function (x, t, b, c, d) {
|
||||
var s=1.70158;var p=0;var a=c;
|
||||
if (t==0) return b; if ((t/=d/2)==2) return b+c; if (!p) p=d*(.3*1.5);
|
||||
if (a < Math.abs(c)) { a=c; var s=p/4; }
|
||||
else var s = p/(2*Math.PI) * Math.asin (c/a);
|
||||
if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
|
||||
return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
|
||||
},
|
||||
easeInBack: function (x, t, b, c, d, s) {
|
||||
if (s == undefined) s = 1.70158;
|
||||
return c*(t/=d)*t*((s+1)*t - s) + b;
|
||||
},
|
||||
easeOutBack: function (x, t, b, c, d, s) {
|
||||
if (s == undefined) s = 1.70158;
|
||||
return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
|
||||
},
|
||||
easeInOutBack: function (x, t, b, c, d, s) {
|
||||
if (s == undefined) s = 1.70158;
|
||||
if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
|
||||
return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
|
||||
},
|
||||
easeInBounce: function (x, t, b, c, d) {
|
||||
return c - JTCJ.easing.easeOutBounce (x, d-t, 0, c, d) + b;
|
||||
},
|
||||
easeOutBounce: function (x, t, b, c, d) {
|
||||
if ((t/=d) < (1/2.75)) {
|
||||
return c*(7.5625*t*t) + b;
|
||||
} else if (t < (2/2.75)) {
|
||||
return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
|
||||
} else if (t < (2.5/2.75)) {
|
||||
return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
|
||||
} else {
|
||||
return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
|
||||
}
|
||||
},
|
||||
easeInOutBounce: function (x, t, b, c, d) {
|
||||
if (t < d/2) return JTCJ.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b;
|
||||
return JTCJ.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b;
|
||||
}
|
||||
});
|
||||
|
||||
/*
|
||||
*
|
||||
* TERMS OF USE - EASING EQUATIONS
|
||||
*
|
||||
* Open source under the BSD License.
|
||||
*
|
||||
* Copyright © 2001 Robert Penner
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* Neither the name of the author nor the names of contributors may be used to endorse
|
||||
* or promote products derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
@@ -0,0 +1,554 @@
|
||||
/*!
|
||||
* Lightbox v2.11.2
|
||||
* by Lokesh Dhakar
|
||||
*
|
||||
* More info:
|
||||
* http://lokeshdhakar.com/projects/lightbox2/
|
||||
*
|
||||
* Copyright Lokesh Dhakar
|
||||
* Released under the MIT license
|
||||
* https://github.com/lokesh/lightbox2/blob/master/LICENSE
|
||||
*
|
||||
* @preserve
|
||||
*/
|
||||
|
||||
// Uses Node, AMD or browser globals to create a module.
|
||||
(function (root, factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
// AMD. Register as an anonymous module.
|
||||
define(['jquery'], factory);
|
||||
} else if (typeof exports === 'object') {
|
||||
// Node. Does not work with strict CommonJS, but
|
||||
// only CommonJS-like environments that support module.exports,
|
||||
// like Node.
|
||||
module.exports = factory(require('jquery'));
|
||||
} else {
|
||||
// Browser globals (root is window)
|
||||
root.lightbox = factory(root.jQuery);
|
||||
}
|
||||
}(this, function ($) {
|
||||
|
||||
function Lightbox(options) {
|
||||
this.album = [];
|
||||
this.currentImageIndex = void 0;
|
||||
this.init();
|
||||
|
||||
// options
|
||||
this.options = $.extend({}, this.constructor.defaults);
|
||||
this.option(options);
|
||||
}
|
||||
|
||||
// Descriptions of all options available on the demo site:
|
||||
// http://lokeshdhakar.com/projects/lightbox2/index.html#options
|
||||
Lightbox.defaults = {
|
||||
albumLabel: 'Image %1 of %2',
|
||||
alwaysShowNavOnTouchDevices: false,
|
||||
fadeDuration: 600,
|
||||
fitImagesInViewport: true,
|
||||
imageFadeDuration: 600,
|
||||
// maxWidth: 800,
|
||||
// maxHeight: 600,
|
||||
positionFromTop: 50,
|
||||
resizeDuration: 700,
|
||||
showImageNumberLabel: false,
|
||||
wrapAround: false,
|
||||
disableScrolling: false,
|
||||
/*
|
||||
Sanitize Title
|
||||
If the caption data is trusted, for example you are hardcoding it in, then leave this to false.
|
||||
This will free you to add html tags, such as links, in the caption.
|
||||
|
||||
If the caption data is user submitted or from some other untrusted source, then set this to true
|
||||
to prevent xss and other injection attacks.
|
||||
*/
|
||||
sanitizeTitle: false
|
||||
};
|
||||
|
||||
Lightbox.prototype.option = function(options) {
|
||||
$.extend(this.options, options);
|
||||
};
|
||||
|
||||
Lightbox.prototype.imageCountLabel = function(currentImageNum, totalImages) {
|
||||
return this.options.albumLabel.replace(/%1/g, currentImageNum).replace(/%2/g, totalImages);
|
||||
};
|
||||
|
||||
Lightbox.prototype.init = function() {
|
||||
var self = this;
|
||||
// Both enable and build methods require the body tag to be in the DOM.
|
||||
$(document).ready(function() {
|
||||
self.enable();
|
||||
self.build();
|
||||
});
|
||||
};
|
||||
|
||||
// Loop through anchors and areamaps looking for either data-lightbox attributes or rel attributes
|
||||
// that contain 'lightbox'. When these are clicked, start lightbox.
|
||||
Lightbox.prototype.enable = function() {
|
||||
var self = this;
|
||||
$('body').on('click', 'a[rel^=lightbox], area[rel^=lightbox], a[data-lightbox], area[data-lightbox]', function(event) {
|
||||
self.start($(event.currentTarget));
|
||||
return false;
|
||||
});
|
||||
};
|
||||
|
||||
// Build html for the lightbox and the overlay.
|
||||
// Attach event handlers to the new DOM elements. click click click
|
||||
Lightbox.prototype.build = function() {
|
||||
if ($('#lightbox').length > 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
var self = this;
|
||||
|
||||
// The two root notes generated, #lightboxOverlay and #lightbox are given
|
||||
// tabindex attrs so they are focusable. We attach our keyboard event
|
||||
// listeners to these two elements, and not the document. Clicking anywhere
|
||||
// while Lightbox is opened will keep the focus on or inside one of these
|
||||
// two elements.
|
||||
//
|
||||
// We do this so we can prevent propogation of the Esc keypress when
|
||||
// Lightbox is open. This prevents it from intefering with other components
|
||||
// on the page below.
|
||||
//
|
||||
// Github issue: https://github.com/lokesh/lightbox2/issues/663
|
||||
$('<div id="lightboxOverlay" tabindex="-1" class="lightboxOverlay"></div><div id="lightbox" tabindex="-1" class="lightbox"><div class="lb-outerContainer"><div class="lb-dataContainer"><div class="lb-data"><div class="lb-details"><span class="lb-caption"></span><span class="lb-number"></span></div><div class="lb-closeContainer"><a class="lb-close"></a></div></div></div><div class="lb-container"><img class="lb-image" src="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" alt=""/><div class="lb-nav"><a class="lb-prev" aria-label="Previous image" href="" ></a><a class="lb-next" aria-label="Next image" href="" ></a></div><div class="lb-loader"><a class="lb-cancel"></a></div></div></div></div>').appendTo($('body'));
|
||||
|
||||
// Cache jQuery objects
|
||||
this.$lightbox = $('#lightbox');
|
||||
this.$overlay = $('#lightboxOverlay');
|
||||
this.$outerContainer = this.$lightbox.find('.lb-outerContainer');
|
||||
this.$container = this.$lightbox.find('.lb-container');
|
||||
this.$image = this.$lightbox.find('.lb-image');
|
||||
this.$nav = this.$lightbox.find('.lb-nav');
|
||||
|
||||
// Store css values for future lookup
|
||||
this.containerPadding = {
|
||||
top: parseInt(this.$container.css('padding-top'), 10),
|
||||
right: parseInt(this.$container.css('padding-right'), 10),
|
||||
bottom: parseInt(this.$container.css('padding-bottom'), 10),
|
||||
left: parseInt(this.$container.css('padding-left'), 10)
|
||||
};
|
||||
|
||||
this.imageBorderWidth = {
|
||||
top: parseInt(this.$image.css('border-top-width'), 10),
|
||||
right: parseInt(this.$image.css('border-right-width'), 10),
|
||||
bottom: parseInt(this.$image.css('border-bottom-width'), 10),
|
||||
left: parseInt(this.$image.css('border-left-width'), 10)
|
||||
};
|
||||
|
||||
// Attach event handlers to the newly minted DOM elements
|
||||
this.$overlay.hide().on('click', function() {
|
||||
self.end();
|
||||
return false;
|
||||
});
|
||||
|
||||
this.$lightbox.hide().on('click', function(event) {
|
||||
if ($(event.target).attr('id') === 'lightbox') {
|
||||
self.end();
|
||||
}
|
||||
});
|
||||
|
||||
this.$outerContainer.on('click', function(event) {
|
||||
if ($(event.target).attr('id') === 'lightbox') {
|
||||
self.end();
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
this.$lightbox.find('.lb-prev').on('click', function() {
|
||||
if (self.currentImageIndex === 0) {
|
||||
self.changeImage(self.album.length - 1);
|
||||
} else {
|
||||
self.changeImage(self.currentImageIndex - 1);
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
this.$lightbox.find('.lb-next').on('click', function() {
|
||||
if (self.currentImageIndex === self.album.length - 1) {
|
||||
self.changeImage(0);
|
||||
} else {
|
||||
self.changeImage(self.currentImageIndex + 1);
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
/*
|
||||
Show context menu for image on right-click
|
||||
|
||||
There is a div containing the navigation that spans the entire image and lives above of it. If
|
||||
you right-click, you are right clicking this div and not the image. This prevents users from
|
||||
saving the image or using other context menu actions with the image.
|
||||
|
||||
To fix this, when we detect the right mouse button is pressed down, but not yet clicked, we
|
||||
set pointer-events to none on the nav div. This is so that the upcoming right-click event on
|
||||
the next mouseup will bubble down to the image. Once the right-click/contextmenu event occurs
|
||||
we set the pointer events back to auto for the nav div so it can capture hover and left-click
|
||||
events as usual.
|
||||
*/
|
||||
this.$nav.on('mousedown', function(event) {
|
||||
if (event.which === 3) {
|
||||
self.$nav.css('pointer-events', 'none');
|
||||
|
||||
self.$lightbox.one('contextmenu', function() {
|
||||
setTimeout(function() {
|
||||
this.$nav.css('pointer-events', 'auto');
|
||||
}.bind(self), 0);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
this.$lightbox.find('.lb-loader, .lb-close').on('click', function() {
|
||||
self.end();
|
||||
return false;
|
||||
});
|
||||
};
|
||||
|
||||
// Show overlay and lightbox. If the image is part of a set, add siblings to album array.
|
||||
Lightbox.prototype.start = function($link) {
|
||||
var self = this;
|
||||
var $window = $(window);
|
||||
|
||||
$window.on('resize', $.proxy(this.sizeOverlay, this));
|
||||
|
||||
this.sizeOverlay();
|
||||
|
||||
this.album = [];
|
||||
var imageNumber = 0;
|
||||
|
||||
function addToAlbum($link) {
|
||||
self.album.push({
|
||||
alt: $link.attr('data-alt'),
|
||||
link: $link.attr('href'),
|
||||
title: $link.attr('data-title') || $link.attr('title')
|
||||
});
|
||||
}
|
||||
|
||||
// Support both data-lightbox attribute and rel attribute implementations
|
||||
var dataLightboxValue = $link.attr('data-lightbox');
|
||||
var $links;
|
||||
|
||||
if (dataLightboxValue) {
|
||||
$links = $($link.prop('tagName') + '[data-lightbox="' + dataLightboxValue + '"]');
|
||||
for (var i = 0; i < $links.length; i = ++i) {
|
||||
addToAlbum($($links[i]));
|
||||
if ($links[i] === $link[0]) {
|
||||
imageNumber = i;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ($link.attr('rel') === 'lightbox') {
|
||||
// If image is not part of a set
|
||||
addToAlbum($link);
|
||||
} else {
|
||||
// If image is part of a set
|
||||
$links = $($link.prop('tagName') + '[rel="' + $link.attr('rel') + '"]');
|
||||
for (var j = 0; j < $links.length; j = ++j) {
|
||||
addToAlbum($($links[j]));
|
||||
if ($links[j] === $link[0]) {
|
||||
imageNumber = j;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Position Lightbox
|
||||
var top = $window.scrollTop() + this.options.positionFromTop;
|
||||
var left = $window.scrollLeft();
|
||||
this.$lightbox.css({
|
||||
top: top + 'px',
|
||||
left: left + 'px'
|
||||
}).fadeIn(this.options.fadeDuration);
|
||||
|
||||
// Disable scrolling of the page while open
|
||||
if (this.options.disableScrolling) {
|
||||
$('body').addClass('lb-disable-scrolling');
|
||||
}
|
||||
|
||||
this.changeImage(imageNumber);
|
||||
};
|
||||
|
||||
// Hide most UI elements in preparation for the animated resizing of the lightbox.
|
||||
Lightbox.prototype.changeImage = function(imageNumber) {
|
||||
var self = this;
|
||||
var filename = this.album[imageNumber].link;
|
||||
var filetype = filename.split('.').slice(-1)[0];
|
||||
var $image = this.$lightbox.find('.lb-image');
|
||||
|
||||
// Disable keyboard nav during transitions
|
||||
this.disableKeyboardNav();
|
||||
|
||||
// Show loading state
|
||||
this.$overlay.fadeIn(this.options.fadeDuration);
|
||||
$('.lb-loader').fadeIn('slow');
|
||||
this.$lightbox.find('.lb-image, .lb-nav, .lb-prev, .lb-next, .lb-dataContainer, .lb-numbers, .lb-caption').hide();
|
||||
this.$outerContainer.addClass('animating');
|
||||
|
||||
// When image to show is preloaded, we send the width and height to sizeContainer()
|
||||
var preloader = new Image();
|
||||
preloader.onload = function() {
|
||||
var $preloader;
|
||||
var imageHeight;
|
||||
var imageWidth;
|
||||
var maxImageHeight;
|
||||
var maxImageWidth;
|
||||
var windowHeight;
|
||||
var windowWidth;
|
||||
|
||||
$image.attr({
|
||||
'alt': self.album[imageNumber].alt,
|
||||
'src': filename
|
||||
});
|
||||
|
||||
$preloader = $(preloader);
|
||||
|
||||
$image.width(preloader.width);
|
||||
$image.height(preloader.height);
|
||||
windowWidth = $(window).width();
|
||||
windowHeight = $(window).height();
|
||||
|
||||
// Calculate the max image dimensions for the current viewport.
|
||||
// Take into account the border around the image and an additional 10px gutter on each side.
|
||||
maxImageWidth = windowWidth - self.containerPadding.left - self.containerPadding.right - self.imageBorderWidth.left - self.imageBorderWidth.right - 20;
|
||||
maxImageHeight = windowHeight - self.containerPadding.top - self.containerPadding.bottom - self.imageBorderWidth.top - self.imageBorderWidth.bottom - self.options.positionFromTop - 70;
|
||||
|
||||
/*
|
||||
Since many SVGs have small intrinsic dimensions, but they support scaling
|
||||
up without quality loss because of their vector format, max out their
|
||||
size.
|
||||
*/
|
||||
if (filetype === 'svg') {
|
||||
$image.width(maxImageWidth);
|
||||
$image.height(maxImageHeight);
|
||||
}
|
||||
|
||||
// Fit image inside the viewport.
|
||||
if (self.options.fitImagesInViewport) {
|
||||
|
||||
// Check if image size is larger then maxWidth|maxHeight in settings
|
||||
if (self.options.maxWidth && self.options.maxWidth < maxImageWidth) {
|
||||
maxImageWidth = self.options.maxWidth;
|
||||
}
|
||||
if (self.options.maxHeight && self.options.maxHeight < maxImageHeight) {
|
||||
maxImageHeight = self.options.maxHeight;
|
||||
}
|
||||
|
||||
} else {
|
||||
maxImageWidth = self.options.maxWidth || preloader.width || maxImageWidth;
|
||||
maxImageHeight = self.options.maxHeight || preloader.height || maxImageHeight;
|
||||
}
|
||||
|
||||
// Is the current image's width or height is greater than the maxImageWidth or maxImageHeight
|
||||
// option than we need to size down while maintaining the aspect ratio.
|
||||
if ((preloader.width > maxImageWidth) || (preloader.height > maxImageHeight)) {
|
||||
if ((preloader.width / maxImageWidth) > (preloader.height / maxImageHeight)) {
|
||||
imageWidth = maxImageWidth;
|
||||
imageHeight = parseInt(preloader.height / (preloader.width / imageWidth), 10);
|
||||
$image.width(imageWidth);
|
||||
$image.height(imageHeight);
|
||||
} else {
|
||||
imageHeight = maxImageHeight;
|
||||
imageWidth = parseInt(preloader.width / (preloader.height / imageHeight), 10);
|
||||
$image.width(imageWidth);
|
||||
$image.height(imageHeight);
|
||||
}
|
||||
}
|
||||
self.sizeContainer($image.width(), $image.height());
|
||||
};
|
||||
|
||||
// Preload image before showing
|
||||
preloader.src = this.album[imageNumber].link;
|
||||
this.currentImageIndex = imageNumber;
|
||||
};
|
||||
|
||||
// Stretch overlay to fit the viewport
|
||||
Lightbox.prototype.sizeOverlay = function() {
|
||||
var self = this;
|
||||
/*
|
||||
We use a setTimeout 0 to pause JS execution and let the rendering catch-up.
|
||||
Why do this? If the `disableScrolling` option is set to true, a class is added to the body
|
||||
tag that disables scrolling and hides the scrollbar. We want to make sure the scrollbar is
|
||||
hidden before we measure the document width, as the presence of the scrollbar will affect the
|
||||
number.
|
||||
*/
|
||||
setTimeout(function() {
|
||||
self.$overlay
|
||||
.width($(document).width())
|
||||
.height($(document).height());
|
||||
|
||||
}, 0);
|
||||
};
|
||||
|
||||
// Animate the size of the lightbox to fit the image we are showing
|
||||
// This method also shows the the image.
|
||||
Lightbox.prototype.sizeContainer = function(imageWidth, imageHeight) {
|
||||
var self = this;
|
||||
|
||||
var oldWidth = this.$outerContainer.outerWidth();
|
||||
var oldHeight = this.$outerContainer.outerHeight();
|
||||
var newWidth = imageWidth + this.containerPadding.left + this.containerPadding.right + this.imageBorderWidth.left + this.imageBorderWidth.right;
|
||||
var newHeight = imageHeight + this.containerPadding.top + this.containerPadding.bottom + this.imageBorderWidth.top + this.imageBorderWidth.bottom;
|
||||
|
||||
function postResize() {
|
||||
self.$lightbox.find('.lb-dataContainer').width(newWidth);
|
||||
self.$lightbox.find('.lb-prevLink').height(newHeight);
|
||||
self.$lightbox.find('.lb-nextLink').height(newHeight);
|
||||
|
||||
// Set focus on one of the two root nodes so keyboard events are captured.
|
||||
self.$overlay.focus();
|
||||
|
||||
self.showImage();
|
||||
}
|
||||
|
||||
if (oldWidth !== newWidth || oldHeight !== newHeight) {
|
||||
this.$outerContainer.animate({
|
||||
width: newWidth,
|
||||
height: newHeight
|
||||
}, this.options.resizeDuration, 'swing', function() {
|
||||
postResize();
|
||||
});
|
||||
} else {
|
||||
postResize();
|
||||
}
|
||||
};
|
||||
|
||||
// Display the image and its details and begin preload neighboring images.
|
||||
Lightbox.prototype.showImage = function() {
|
||||
this.$lightbox.find('.lb-loader').stop(true).hide();
|
||||
this.$lightbox.find('.lb-image').fadeIn(this.options.imageFadeDuration);
|
||||
|
||||
this.updateNav();
|
||||
this.updateDetails();
|
||||
this.preloadNeighboringImages();
|
||||
this.enableKeyboardNav();
|
||||
};
|
||||
|
||||
// Display previous and next navigation if appropriate.
|
||||
Lightbox.prototype.updateNav = function() {
|
||||
// Check to see if the browser supports touch events. If so, we take the conservative approach
|
||||
// and assume that mouse hover events are not supported and always show prev/next navigation
|
||||
// arrows in image sets.
|
||||
var alwaysShowNav = false;
|
||||
try {
|
||||
document.createEvent('TouchEvent');
|
||||
alwaysShowNav = (this.options.alwaysShowNavOnTouchDevices) ? true : false;
|
||||
} catch (e) {}
|
||||
|
||||
this.$lightbox.find('.lb-nav').show();
|
||||
|
||||
if (this.album.length > 1) {
|
||||
if (this.options.wrapAround) {
|
||||
if (alwaysShowNav) {
|
||||
this.$lightbox.find('.lb-prev, .lb-next').css('opacity', '1');
|
||||
}
|
||||
this.$lightbox.find('.lb-prev, .lb-next').show();
|
||||
} else {
|
||||
if (this.currentImageIndex > 0) {
|
||||
this.$lightbox.find('.lb-prev').show();
|
||||
if (alwaysShowNav) {
|
||||
this.$lightbox.find('.lb-prev').css('opacity', '1');
|
||||
}
|
||||
}
|
||||
if (this.currentImageIndex < this.album.length - 1) {
|
||||
this.$lightbox.find('.lb-next').show();
|
||||
if (alwaysShowNav) {
|
||||
this.$lightbox.find('.lb-next').css('opacity', '1');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Display caption, image number, and closing button.
|
||||
Lightbox.prototype.updateDetails = function() {
|
||||
var self = this;
|
||||
|
||||
// Enable anchor clicks in the injected caption html.
|
||||
// Thanks Nate Wright for the fix. @https://github.com/NateWr
|
||||
if (typeof this.album[this.currentImageIndex].title !== 'undefined' &&
|
||||
this.album[this.currentImageIndex].title !== '') {
|
||||
var $caption = this.$lightbox.find('.lb-caption');
|
||||
if (this.options.sanitizeTitle) {
|
||||
$caption.text(this.album[this.currentImageIndex].title);
|
||||
} else {
|
||||
$caption.html(this.album[this.currentImageIndex].title);
|
||||
}
|
||||
$caption.fadeIn('fast');
|
||||
}
|
||||
|
||||
if (this.album.length > 1 && this.options.showImageNumberLabel) {
|
||||
var labelText = this.imageCountLabel(this.currentImageIndex + 1, this.album.length);
|
||||
this.$lightbox.find('.lb-number').text(labelText).fadeIn('fast');
|
||||
} else {
|
||||
this.$lightbox.find('.lb-number').hide();
|
||||
}
|
||||
|
||||
this.$outerContainer.removeClass('animating');
|
||||
|
||||
this.$lightbox.find('.lb-dataContainer').fadeIn(this.options.resizeDuration, function() {
|
||||
return self.sizeOverlay();
|
||||
});
|
||||
};
|
||||
|
||||
// Preload previous and next images in set.
|
||||
Lightbox.prototype.preloadNeighboringImages = function() {
|
||||
if (this.album.length > this.currentImageIndex + 1) {
|
||||
var preloadNext = new Image();
|
||||
preloadNext.src = this.album[this.currentImageIndex + 1].link;
|
||||
}
|
||||
if (this.currentImageIndex > 0) {
|
||||
var preloadPrev = new Image();
|
||||
preloadPrev.src = this.album[this.currentImageIndex - 1].link;
|
||||
}
|
||||
};
|
||||
|
||||
Lightbox.prototype.enableKeyboardNav = function() {
|
||||
this.$lightbox.on('keyup.keyboard', $.proxy(this.keyboardAction, this));
|
||||
this.$overlay.on('keyup.keyboard', $.proxy(this.keyboardAction, this));
|
||||
};
|
||||
|
||||
Lightbox.prototype.disableKeyboardNav = function() {
|
||||
this.$lightbox.off('.keyboard');
|
||||
this.$overlay.off('.keyboard');
|
||||
};
|
||||
|
||||
Lightbox.prototype.keyboardAction = function(event) {
|
||||
var KEYCODE_ESC = 27;
|
||||
var KEYCODE_LEFTARROW = 37;
|
||||
var KEYCODE_RIGHTARROW = 39;
|
||||
|
||||
var keycode = event.keyCode;
|
||||
if (keycode === KEYCODE_ESC) {
|
||||
// Prevent bubbling so as to not affect other components on the page.
|
||||
event.stopPropagation();
|
||||
this.end();
|
||||
} else if (keycode === KEYCODE_LEFTARROW) {
|
||||
if (this.currentImageIndex !== 0) {
|
||||
this.changeImage(this.currentImageIndex - 1);
|
||||
} else if (this.options.wrapAround && this.album.length > 1) {
|
||||
this.changeImage(this.album.length - 1);
|
||||
}
|
||||
} else if (keycode === KEYCODE_RIGHTARROW) {
|
||||
if (this.currentImageIndex !== this.album.length - 1) {
|
||||
this.changeImage(this.currentImageIndex + 1);
|
||||
} else if (this.options.wrapAround && this.album.length > 1) {
|
||||
this.changeImage(0);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Closing time. :-(
|
||||
Lightbox.prototype.end = function() {
|
||||
this.disableKeyboardNav();
|
||||
$(window).off('resize', this.sizeOverlay);
|
||||
this.$lightbox.fadeOut(this.options.fadeDuration);
|
||||
this.$overlay.fadeOut(this.options.fadeDuration);
|
||||
|
||||
if (this.options.disableScrolling) {
|
||||
$('body').removeClass('lb-disable-scrolling');
|
||||
}
|
||||
};
|
||||
|
||||
return new Lightbox();
|
||||
}));
|
||||
File diff suppressed because one or more lines are too long
667
modules/mod_jt_contentslider/tmpl/assets/js/slides.js
Normal file
667
modules/mod_jt_contentslider/tmpl/assets/js/slides.js
Normal file
@@ -0,0 +1,667 @@
|
||||
/*
|
||||
* Slides, A Slideshow Plugin for jQuery
|
||||
* Intructions: http://slidesjs.com
|
||||
* By: Nathan Searles, http://nathansearles.com
|
||||
* Version: 1.1.9
|
||||
* Updated: September 5th, 2011
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
(function($){
|
||||
$.fn.slides = function( option ) {
|
||||
// override defaults with specified option
|
||||
option = $.extend( {}, $.fn.slides.option, option );
|
||||
|
||||
return this.each(function(){
|
||||
// wrap slides in control container, make sure slides are block level
|
||||
$('.' + option.container, $(this)).children().wrapAll('<div class="slides_control"/>');
|
||||
var elem = $(this),
|
||||
control = $('.slides_control',elem),
|
||||
total = control.children().size(),
|
||||
width = getWidth(),
|
||||
height = getHeight(),
|
||||
start = option.start - 1,
|
||||
effect = option.effect.indexOf(',') < 0 ? option.effect : option.effect.replace(' ', '').split(',')[0],
|
||||
paginationEffect = option.effect.indexOf(',') < 0 ? effect : option.effect.replace(' ', '').split(',')[1],
|
||||
next = 0, prev = 0, number = 0, current = 0, loaded, active, clicked, position, direction, imageParent, pauseTimeout, playInterval;
|
||||
equalHeight();
|
||||
if(option.width=="auto"){
|
||||
$(window).resize(function(){
|
||||
var width = getWidth();
|
||||
elem.find('.slide').css({
|
||||
left: width,
|
||||
width: width
|
||||
});
|
||||
equalHeight();
|
||||
control.css({
|
||||
left: -width,
|
||||
width: (width * 3),
|
||||
height:getHeight()
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
// is there only one slide?
|
||||
if (total < 2) {
|
||||
// Fade in .slides_container
|
||||
$('.' + option.container, $(this)).fadeIn(option.fadeSpeed, option.fadeEasing, function(){
|
||||
// let the script know everything is loaded
|
||||
loaded = true;
|
||||
// call the loaded funciton
|
||||
option.slidesLoaded();
|
||||
});
|
||||
// Hide the next/previous buttons
|
||||
$('.' + option.next + ', .' + option.prev,elem).fadeOut(0);
|
||||
return false;
|
||||
}
|
||||
|
||||
// animate slides
|
||||
function animate(direction, effect, clicked) {
|
||||
if (!active && loaded) {
|
||||
active = true;
|
||||
// start of animation
|
||||
option.animationStart(current + 1);
|
||||
switch(direction) {
|
||||
case 'next':
|
||||
// change current slide to previous
|
||||
prev = current;
|
||||
// get next from current + 1
|
||||
next = current + 1;
|
||||
// if last slide, set next to first slide
|
||||
next = total === next ? 0 : next;
|
||||
// set position of next slide to right of previous
|
||||
position = option.currentWidth*2;
|
||||
// distance to slide based on width of slides
|
||||
direction = -option.currentWidth*2;
|
||||
// store new current slide
|
||||
current = next;
|
||||
break;
|
||||
case 'prev':
|
||||
// change current slide to previous
|
||||
prev = current;
|
||||
// get next from current - 1
|
||||
next = current - 1;
|
||||
// if first slide, set next to last slide
|
||||
next = next === -1 ? total-1 : next;
|
||||
// set position of next slide to left of previous
|
||||
position = 0;
|
||||
// distance to slide based on width of slides
|
||||
direction = 0;
|
||||
// store new current slide
|
||||
current = next;
|
||||
break;
|
||||
case 'pagination':
|
||||
// get next from pagination item clicked, convert to number
|
||||
next = parseInt(clicked,10);
|
||||
// get previous from pagination item with class of current
|
||||
prev = $('.' + option.paginationClass + ' li.'+ option.currentClass +' a', elem).attr('href').match('[^#/]+$');
|
||||
// if next is greater then previous set position of next slide to right of previous
|
||||
if (next > prev) {
|
||||
position = option.currentWidth*2;
|
||||
direction = -option.currentWidth*2;
|
||||
} else {
|
||||
// if next is less then previous set position of next slide to left of previous
|
||||
position = 0;
|
||||
direction = 0;
|
||||
}
|
||||
// store new current slide
|
||||
current = next;
|
||||
break;
|
||||
}
|
||||
|
||||
// fade animation
|
||||
if (effect === 'fade') {
|
||||
// fade animation with crossfade
|
||||
if (option.crossfade) {
|
||||
// put hidden next above current
|
||||
control.children(':eq('+ next +')', elem).css({
|
||||
zIndex: 10
|
||||
// fade in next
|
||||
}).fadeIn(option.fadeSpeed, option.fadeEasing, function(){
|
||||
if (option.autoHeight) {
|
||||
// animate container to height of next
|
||||
equalHeight(next);
|
||||
control.animate({
|
||||
height: control.children(':eq('+ next +')', elem).outerHeight()
|
||||
}, option.autoHeightSpeed, function(){
|
||||
// hide previous
|
||||
control.children(':eq('+ prev +')', elem).css({
|
||||
display: 'none',
|
||||
zIndex: 0
|
||||
});
|
||||
// reset z index
|
||||
control.children(':eq('+ next +')', elem).css({
|
||||
zIndex: 0
|
||||
});
|
||||
// end of animation
|
||||
option.animationComplete(next + 1);
|
||||
active = false;
|
||||
});
|
||||
} else {
|
||||
// hide previous
|
||||
control.children(':eq('+ prev +')', elem).css({
|
||||
display: 'none',
|
||||
zIndex: 0
|
||||
});
|
||||
// reset zindex
|
||||
control.children(':eq('+ next +')', elem).css({
|
||||
zIndex: 0
|
||||
});
|
||||
// end of animation
|
||||
option.animationComplete(next + 1);
|
||||
active = false;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// fade animation with no crossfade
|
||||
control.children(':eq('+ prev +')', elem).fadeOut(option.fadeSpeed, option.fadeEasing, function(){
|
||||
// animate to new height
|
||||
equalHeight(next);
|
||||
if (option.autoHeight) {
|
||||
control.animate({
|
||||
// animate container to height of next
|
||||
height: control.children(':eq('+ next +')', elem).outerHeight()
|
||||
}, option.autoHeightSpeed,
|
||||
// fade in next slide
|
||||
function(){
|
||||
control.children(':eq('+ next +')', elem).fadeIn(option.fadeSpeed, option.fadeEasing);
|
||||
});
|
||||
} else {
|
||||
// if fixed height
|
||||
control.children(':eq('+ next +')', elem).fadeIn(option.fadeSpeed, option.fadeEasing, function(){
|
||||
// fix font rendering in ie, lame
|
||||
if($.browser.msie) {
|
||||
$(this).get(0).style.removeAttribute('filter');
|
||||
}
|
||||
});
|
||||
}
|
||||
// end of animation
|
||||
option.animationComplete(next + 1);
|
||||
active = false;
|
||||
});
|
||||
}
|
||||
// slide animation
|
||||
} else {
|
||||
// move next slide to right of previous
|
||||
control.children(':eq('+ next +')').css({
|
||||
left: position,
|
||||
display: 'block'
|
||||
});
|
||||
// animate to new height
|
||||
if (option.autoHeight) {
|
||||
equalHeight(next);
|
||||
control.animate({
|
||||
left: direction,
|
||||
height: control.children(':eq('+ next +')').outerHeight()
|
||||
},option.slideSpeed, option.slideEasing, function(){
|
||||
control.css({
|
||||
left: -option.currentWidth
|
||||
});
|
||||
control.children(':eq('+ next +')').css({
|
||||
left: option.currentWidth,
|
||||
zIndex: 5
|
||||
});
|
||||
// reset previous slide
|
||||
control.children(':eq('+ prev +')').css({
|
||||
left: option.currentWidth,
|
||||
display: 'none',
|
||||
zIndex: 0
|
||||
});
|
||||
// end of animation
|
||||
option.animationComplete(next + 1);
|
||||
active = false;
|
||||
});
|
||||
// if fixed height
|
||||
} else {
|
||||
// animate control
|
||||
equalHeight(next);
|
||||
control.animate({
|
||||
left: direction
|
||||
},option.slideSpeed, option.slideEasing, function(){
|
||||
// after animation reset control position
|
||||
control.css({
|
||||
left: -option.currentWidth
|
||||
});
|
||||
// reset and show next
|
||||
control.children(':eq('+ next +')').css({
|
||||
left: option.currentWidth,
|
||||
zIndex: 5
|
||||
});
|
||||
// reset previous slide
|
||||
control.children(':eq('+ prev +')').css({
|
||||
left: option.currentWidth,
|
||||
display: 'none',
|
||||
zIndex: 0
|
||||
});
|
||||
// end of animation
|
||||
option.animationComplete(next + 1);
|
||||
active = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
// set current state for pagination
|
||||
if (option.pagination) {
|
||||
// remove current class from all
|
||||
$('.'+ option.paginationClass +' li.' + option.currentClass, elem).removeClass(option.currentClass);
|
||||
// add current class to next
|
||||
$('.' + option.paginationClass + ' li:eq('+ next +')', elem).addClass(option.currentClass);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} // end animate function
|
||||
|
||||
function stop() {
|
||||
// clear interval from stored id
|
||||
clearInterval(elem.data('interval'));
|
||||
}
|
||||
function equalHeight(pointer){
|
||||
// equal height for title/description
|
||||
if(!pointer) pointer = current;
|
||||
if(option.equalHeight){
|
||||
//setEqualHeight(control.children(':eq('+ pointer +')'));
|
||||
var el = control.children(':eq('+ pointer +')');
|
||||
jQuery('.jt-title,.jt-introtext',el).height('auto');
|
||||
var maxHeight = Math.max.apply(null, jQuery('.jt-title',el).map(function (){return jQuery(this).height();}).get());
|
||||
if(maxHeight) jQuery('.jt-title',el).height(maxHeight);
|
||||
maxHeight = Math.max.apply(null, jQuery('.jt-introtext',el).map(function (){return jQuery(this).height();}).get());
|
||||
if(maxHeight) jQuery('.jt-introtext',el).height(maxHeight);
|
||||
}
|
||||
}
|
||||
function getWidth(){
|
||||
option.currentWidth = option.width!="auto"?option.width:elem.width();
|
||||
return option.currentWidth;
|
||||
}
|
||||
function getHeight(){
|
||||
var mheight = 0;
|
||||
|
||||
if(option.autoHeight){
|
||||
mheight = control.children(':eq('+ current +')').outerHeight();
|
||||
}else{
|
||||
if(option.height=='auto'){
|
||||
mheight= Math.max.apply(null, control.children().map(function (){return $(this).outerHeight();}).get());
|
||||
}else{
|
||||
mheight = option.height;
|
||||
}
|
||||
}
|
||||
return mheight? mheight:'auto';
|
||||
}
|
||||
function pause() {
|
||||
if (option.pause) {
|
||||
// clear timeout and interval
|
||||
clearTimeout(elem.data('pause'));
|
||||
clearInterval(elem.data('interval'));
|
||||
// pause slide show for option.pause amount
|
||||
pauseTimeout = setTimeout(function() {
|
||||
// clear pause timeout
|
||||
clearTimeout(elem.data('pause'));
|
||||
// start play interval after pause
|
||||
playInterval = setInterval( function(){
|
||||
animate("next", effect);
|
||||
},option.play);
|
||||
// store play interval
|
||||
elem.data('interval',playInterval);
|
||||
},option.pause);
|
||||
// store pause interval
|
||||
elem.data('pause',pauseTimeout);
|
||||
} else {
|
||||
// if no pause, just stop
|
||||
stop();
|
||||
}
|
||||
}
|
||||
|
||||
// 2 or more slides required
|
||||
if (total < 2) {
|
||||
return;
|
||||
}
|
||||
|
||||
// error corection for start slide
|
||||
if (start < 0) {
|
||||
start = 0;
|
||||
}
|
||||
|
||||
if (start > total) {
|
||||
start = total - 1;
|
||||
}
|
||||
|
||||
// change current based on start option number
|
||||
if (option.start) {
|
||||
current = start;
|
||||
}
|
||||
|
||||
// randomizes slide order
|
||||
if (option.randomize) {
|
||||
control.randomize();
|
||||
}
|
||||
|
||||
// make sure overflow is hidden, width is set
|
||||
$('.' + option.container, elem).css({
|
||||
overflow: 'hidden',
|
||||
// fix for ie
|
||||
position: 'relative'
|
||||
});
|
||||
|
||||
// set css for slides
|
||||
control.children().css({
|
||||
position: 'absolute',
|
||||
top: 0,
|
||||
left: control.children().outerWidth(),
|
||||
zIndex: 0,
|
||||
display: 'none'
|
||||
});
|
||||
|
||||
// set css for control div
|
||||
control.css({
|
||||
position: 'relative',
|
||||
// size of control 3 x slide width
|
||||
width: (option.currentWidth * 3),
|
||||
// set height to slide height
|
||||
height: height,
|
||||
// center control to slide
|
||||
left: -option.currentWidth
|
||||
});
|
||||
|
||||
// show slides
|
||||
$('.' + option.container, elem).css({
|
||||
display: 'block'
|
||||
});
|
||||
|
||||
// if autoHeight true, get and set height of first slide
|
||||
if (option.autoHeight) {
|
||||
control.children().css({
|
||||
height: 'auto'
|
||||
});
|
||||
control.animate({
|
||||
height: control.children(':eq('+ start +')').outerHeight()
|
||||
},option.autoHeightSpeed);
|
||||
}
|
||||
|
||||
// checks if image is loaded
|
||||
if (option.preload && control.find('img:eq(' + start + ')').length) {
|
||||
// adds preload image
|
||||
$('.' + option.container, elem).css({
|
||||
background: 'url(' + option.preloadImage + ') no-repeat 50% 50%'
|
||||
});
|
||||
|
||||
/*
|
||||
// gets image src, with cache buster
|
||||
var img = control.find('img:eq(' + start + ')').attr('src') + '?' + (new Date()).getTime();
|
||||
|
||||
// check if the image has a parent
|
||||
if ($('img', elem).parent().attr('class') != 'slides_control') {
|
||||
// If image has parent, get tag name
|
||||
imageParent = control.children(':eq(0)')[0].tagName.toLowerCase();
|
||||
} else {
|
||||
// Image doesn't have parent, use image tag name
|
||||
imageParent = control.find('img:eq(' + start + ')');
|
||||
}
|
||||
*/
|
||||
// checks if image is loaded
|
||||
var $imgs = control.find('img');
|
||||
var imgsl = $imgs.length;
|
||||
var u=0;
|
||||
$imgs.each(function(){
|
||||
var img = new Image();
|
||||
$(img).load(function(){
|
||||
++u;
|
||||
if (u == imgsl) {
|
||||
startSlider();
|
||||
}
|
||||
}).error(function () {
|
||||
++u;
|
||||
if (u == imgsl) {
|
||||
startSlider();
|
||||
}
|
||||
}).attr('src',this.src);
|
||||
});
|
||||
} else {
|
||||
// if no preloader fade in start slide
|
||||
control.children(':eq(' + start + ')').fadeIn(option.fadeSpeed, option.fadeEasing, function(){
|
||||
// let the script know everything is loaded
|
||||
loaded = true;
|
||||
// call the loaded funciton
|
||||
option.slidesLoaded();
|
||||
});
|
||||
}
|
||||
function startSlider(){
|
||||
// once image is fully loaded, fade in
|
||||
control.children(':eq(' + start + ')').fadeIn(option.fadeSpeed, option.fadeEasing, function(){
|
||||
$(this).css({
|
||||
zIndex: 5
|
||||
});
|
||||
// removes preload image
|
||||
$('.' + option.container, elem).css({
|
||||
background: ''
|
||||
});
|
||||
control.css({
|
||||
height:getHeight()
|
||||
});
|
||||
// let the script know everything is loaded
|
||||
loaded = true;
|
||||
// call the loaded funciton
|
||||
option.slidesLoaded();
|
||||
});
|
||||
}
|
||||
|
||||
// click slide for next
|
||||
if (option.bigTarget) {
|
||||
// set cursor to pointer
|
||||
control.children().css({
|
||||
cursor: 'pointer'
|
||||
});
|
||||
// click handler
|
||||
control.children().click(function(){
|
||||
// animate to next on slide click
|
||||
animate('next', effect);
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
// pause on mouseover
|
||||
if (option.hoverPause && option.play) {
|
||||
control.bind('mouseover',function(){
|
||||
// on mouse over stop
|
||||
stop();
|
||||
});
|
||||
control.bind('mouseleave',function(){
|
||||
// on mouse leave start pause timeout
|
||||
pause();
|
||||
});
|
||||
}
|
||||
|
||||
// generate next/prev buttons
|
||||
if (option.generateNextPrev) {
|
||||
$('.' + option.container, elem).after('<a href="#" class="'+ option.prev +'"><i class="fa fa-chevron-left" aria-hidden="true"></i></a>');
|
||||
$('.' + option.prev, elem).after('<a href="#" class="'+ option.next +'"><i class="fa fa-chevron-right" aria-hidden="true"></i></a>');
|
||||
}
|
||||
|
||||
// next button
|
||||
$('.' + option.next ,elem).click(function(e){
|
||||
e.preventDefault();
|
||||
if (option.play) {
|
||||
pause();
|
||||
}
|
||||
animate('next', effect);
|
||||
});
|
||||
|
||||
// previous button
|
||||
$('.' + option.prev, elem).click(function(e){
|
||||
e.preventDefault();
|
||||
if (option.play) {
|
||||
pause();
|
||||
}
|
||||
animate('prev', effect);
|
||||
});
|
||||
|
||||
// generate pagination
|
||||
if (option.generatePagination) {
|
||||
// create unordered list
|
||||
if($('.' + option.next ,elem).length){
|
||||
$('.' + option.next ,elem).before('<ul class='+ option.paginationClass +'></ul>');
|
||||
}else
|
||||
if (option.prependPagination){
|
||||
elem.prepend('<ul class='+ option.paginationClass +'></ul>');
|
||||
}else{
|
||||
elem.append('<ul class='+ option.paginationClass +'></ul>');
|
||||
}
|
||||
// for each slide create a list item and link
|
||||
control.children().each(function(){
|
||||
$('.' + option.paginationClass, elem).append('<li><a href="#'+ number +'">'+ (number+1) +'</a></li>');
|
||||
number++;
|
||||
});
|
||||
} else {
|
||||
// if pagination exists, add href w/ value of item number to links
|
||||
$('.' + option.paginationClass + ' li a', elem).each(function(){
|
||||
$(this).attr('href', '#' + number);
|
||||
number++;
|
||||
});
|
||||
}
|
||||
|
||||
// add current class to start slide pagination
|
||||
$('.' + option.paginationClass + ' li:eq('+ start +')', elem).addClass(option.currentClass);
|
||||
|
||||
// click handling
|
||||
$('.' + option.paginationClass + ' li a', elem ).click(function(){
|
||||
// pause slideshow
|
||||
if (option.play) {
|
||||
pause();
|
||||
}
|
||||
// get clicked, pass to animate function
|
||||
clicked = $(this).attr('href').match('[^#/]+$');
|
||||
// if current slide equals clicked, don't do anything
|
||||
if (current != clicked) {
|
||||
animate('pagination', paginationEffect, clicked);
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
// click handling
|
||||
$('a.link', elem).click(function(){
|
||||
// pause slideshow
|
||||
if (option.play) {
|
||||
pause();
|
||||
}
|
||||
// get clicked, pass to animate function
|
||||
clicked = $(this).attr('href').match('[^#/]+$') - 1;
|
||||
// if current slide equals clicked, don't do anything
|
||||
if (current != clicked) {
|
||||
animate('pagination', paginationEffect, clicked);
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
if (option.play) {
|
||||
// set interval
|
||||
playInterval = setInterval(function() {
|
||||
animate('next', effect);
|
||||
}, option.play);
|
||||
// store interval id
|
||||
elem.data('interval',playInterval);
|
||||
}
|
||||
|
||||
|
||||
if(option.touchScreen){
|
||||
var timeStart, xStart, yStart;
|
||||
$(control).on('touchstart', function(e){
|
||||
var touch = e.originalEvent.touches[0];
|
||||
xStart = touch.pageX;
|
||||
yStart = touch.pageY;
|
||||
timeStart = Number(new Date());
|
||||
|
||||
});
|
||||
$(control).on('touchend', function(e){
|
||||
var touch = e.originalEvent.changedTouches[0];
|
||||
var duration = Number(new Date()) - timeStart;
|
||||
var xDistance = touch.pageX - xStart;
|
||||
var yDistance = touch.pageY - yStart;
|
||||
|
||||
if(duration <= 300 && Math.abs(yDistance) <= 20 && xDistance != 0){
|
||||
if (option.play) {
|
||||
pause();
|
||||
}
|
||||
if(xDistance < 0){
|
||||
animate('next', effect);
|
||||
}else{
|
||||
animate('prev', effect);
|
||||
}
|
||||
}else{
|
||||
return;
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
};
|
||||
|
||||
// default options
|
||||
$.fn.slides.option = {
|
||||
preload: false, // boolean, Set true to preload images in an image based slideshow
|
||||
preloadImage: '/img/loading.gif', // string, Name and location of loading image for preloader. Default is "/img/loading.gif"
|
||||
container: 'slides_container', // string, Class name for slides container. Default is "slides_container"
|
||||
generateNextPrev: false, // boolean, Auto generate next/prev buttons
|
||||
next: 'next', // string, Class name for next button
|
||||
prev: 'prev', // string, Class name for previous button
|
||||
pagination: true, // boolean, If you're not using pagination you can set to false, but don't have to
|
||||
generatePagination: true, // boolean, Auto generate pagination
|
||||
prependPagination: false, // boolean, prepend pagination
|
||||
paginationClass: 'pagination', // string, Class name for pagination
|
||||
currentClass: 'current', // string, Class name for current class
|
||||
fadeSpeed: 350, // number, Set the speed of the fading animation in milliseconds
|
||||
fadeEasing: '', // string, must load jQuery's easing plugin before http://gsgd.co.uk/sandbox/jquery/easing/
|
||||
slideSpeed: 350, // number, Set the speed of the sliding animation in milliseconds
|
||||
slideEasing: '', // string, must load jQuery's easing plugin before http://gsgd.co.uk/sandbox/jquery/easing/
|
||||
start: 1, // number, Set the speed of the sliding animation in milliseconds
|
||||
effect: 'slide', // string, '[next/prev], [pagination]', e.g. 'slide, fade' or simply 'fade' for both
|
||||
crossfade: false, // boolean, Crossfade images in a image based slideshow
|
||||
randomize: false, // boolean, Set to true to randomize slides
|
||||
play: 0, // number, Autoplay slideshow, a positive number will set to true and be the time between slide animation in milliseconds
|
||||
pause: 0, // number, Pause slideshow on click of next/prev or pagination. A positive number will set to true and be the time of pause in milliseconds
|
||||
hoverPause: false, // boolean, Set to true and hovering over slideshow will pause it
|
||||
autoHeight: false, // boolean, Set to true to auto adjust height
|
||||
autoHeightSpeed: 350, // number, Set auto height animation time in milliseconds
|
||||
bigTarget: false, // boolean, Set to true and the whole slide will link to next slide on click
|
||||
animationStart: function(){}, // Function called at the start of animation
|
||||
animationComplete: function(){}, // Function called at the completion of animation
|
||||
slidesLoaded: function() {}, // Function is called when slides is fully loaded
|
||||
width:'auto',
|
||||
equalHeight:true,
|
||||
currentWidth: '',
|
||||
};
|
||||
|
||||
// Randomize slide order on load
|
||||
$.fn.randomize = function(callback) {
|
||||
function randomizeOrder() { return(Math.round(Math.random())-0.5); }
|
||||
return($(this).each(function() {
|
||||
var $this = $(this);
|
||||
var $children = $this.children();
|
||||
var childCount = $children.length;
|
||||
if (childCount > 1) {
|
||||
$children.hide();
|
||||
var indices = [];
|
||||
for (i=0;i<childCount;i++) { indices[indices.length] = i; }
|
||||
indices = indices.sort(randomizeOrder);
|
||||
$.each(indices,function(j,k) {
|
||||
var $child = $children.eq(k);
|
||||
var $clone = $child.clone(true);
|
||||
$clone.show().appendTo($this);
|
||||
if (callback !== undefined) {
|
||||
callback($child, $clone);
|
||||
}
|
||||
$child.remove();
|
||||
});
|
||||
}
|
||||
}));
|
||||
};
|
||||
})(jQuery);
|
||||
Reference in New Issue
Block a user