/*!
* animsition v4.0.2
* A simple and easy jQuery plugin for CSS animated page transitions.
* http://blivesta.github.io/animsition
* License : MIT
* Author : blivesta (http://blivesta.com/)
*/
;(function (factory) {
'use strict';
if (typeof define === 'function' && define.amd) {
define(['jquery'], factory);
} else if (typeof exports === 'object') {
module.exports = factory(require('jquery'));
} else {
factory(jQuery);
}
}(function ($) {
'use strict';
var namespace = 'animsition';
var __ = {
init: function(options){
options = $.extend({
inClass : 'fade-in',
outClass : 'fade-out',
inDuration : 1500,
outDuration : 800,
linkElement : '.animsition-link',
// e.g. linkElement : 'a:not([target="_blank"]):not([href^="#"])'
loading : true,
loadingParentElement : 'body', //animsition wrapper element
loadingClass : 'animsition-loading',
loadingInner : '', // e.g ''
timeout : false,
timeoutCountdown : 5000,
onLoadEvent : true,
browser : [ 'animation-duration', '-webkit-animation-duration'],
// "browser" option allows you to disable the "animsition" in case the css property in the array is not supported by your browser.
// The default setting is to disable the "animsition" in a browser that does not support "animation-duration".
overlay : false,
overlayClass : 'animsition-overlay-slide',
overlayParentElement : 'body',
transition : function(url){ window.location.href = url; }
}, options);
__.settings = {
timer: false,
data: {
inClass: 'animsition-in-class',
inDuration: 'animsition-in-duration',
outClass: 'animsition-out-class',
outDuration: 'animsition-out-duration',
overlay: 'animsition-overlay'
},
events: {
inStart: 'animsition.inStart',
inEnd: 'animsition.inEnd',
outStart: 'animsition.outStart',
outEnd: 'animsition.outEnd'
}
};
// Remove the "Animsition" in a browser
// that does not support the "animaition-duration".
var support = __.supportCheck.call(this, options);
if(!support && options.browser.length > 0){
if(!support || !this.length){
// If do not have a console object to object window
if (!('console' in window)) {
window.console = {};
window.console.log = function(str){ return str; };
}
if(!this.length) console.log('Animsition: Element does not exist on page.');
if(!support) console.log('Animsition: Does not support this browser.');
return __.destroy.call(this);
}
}
var overlayMode = __.optionCheck.call(this, options);
if (overlayMode && $('.' + options.overlayClass).length <= 0) {
__.addOverlay.call(this, options);
}
if (options.loading && $('.' + options.loadingClass).length <= 0) {
__.addLoading.call(this, options);
}
return this.each(function(){
var _this = this;
var $this = $(this);
var $window = $(window);
var $document = $(document);
var data = $this.data(namespace);
if (!data) {
options = $.extend({}, options);
$this.data(namespace, { options: options });
if(options.timeout) __.addTimer.call(_this);
if(options.onLoadEvent) {
$window.on('load.' + namespace, function() {
if(__.settings.timer) clearTimeout(__.settings.timer);
__.in.call(_this);
});
}
$window.on('pageshow.' + namespace, function(event) {
if(event.originalEvent.persisted) __.in.call(_this);
});
// Firefox back button issue #4
$window.on('unload.' + namespace, function() { });
$document.on('click.' + namespace, options.linkElement, function(event) {
event.preventDefault();
var $self = $(this);
var url = $self.attr('href');
// middle mouse button issue #24
// if(middle mouse button || command key || shift key || win control key)
if (event.which === 2 || event.metaKey || event.shiftKey || navigator.platform.toUpperCase().indexOf('WIN') !== -1 && event.ctrlKey) {
window.open(url, '_blank');
} else {
__.out.call(_this, $self, url);
}
});
}
}); // end each
},
addOverlay: function(options){
$(options.overlayParentElement)
.prepend('