1/*! 2 * animsition v4.0.2 3 * A simple and easy jQuery plugin for CSS animated page transitions. 4 * http://blivesta.github.io/animsition 5 * License : MIT 6 * Author : blivesta (http://blivesta.com/) 7 */ 8; (function (factory) { 9 'use strict'; 10 if (typeof define === 'function' && define.amd) { 11 define(['jquery'], factory); 12 } else if (typeof exports === 'object') { 13 module.exports = factory(require('jquery')); 14 } else { 15 factory(jQuery); 16 } 17}(function ($) { 18 'use strict'; 19 var windowLoaded = false; 20 $(window).on("load", function () { 21 windowLoaded = true; 22 }); 23 var namespace = 'animsition'; 24 var __ = { 25 init: function (options) { 26 options = $.extend({ 27 inClass: 'fade-in', 28 outClass: 'fade-out', 29 inDuration: 1500, 30 outDuration: 800, 31 linkElement: '.animsition-link', 32 // e.g. linkElement : 'a:not([target="_blank"]):not([href^="#"])' 33 loading: true, 34 loadingParentElement: 'body', //animsition wrapper element 35 loadingClass: 'animsition-loading', 36 loadingInner: '', // e.g '<img src="loading.svg" />' 37 timeout: false, 38 timeoutCountdown: 5000, 39 onLoadEvent: true, 40 browser: ['animation-duration', '-webkit-animation-duration'], 41 // "browser" option allows you to disable the "animsition" in case the css property in the array is not supported by your browser. 42 // The default setting is to disable the "animsition" in a browser that does not support "animation-duration". 43 overlay: false, 44 overlayClass: 'animsition-overlay-slide', 45 overlayParentElement: 'body', 46 transition: function (url) { window.location.href = url; } 47 }, options); 48 49 __.settings = { 50 timer: false, 51 data: { 52 inClass: 'animsition-in-class', 53 inDuration: 'animsition-in-duration', 54 outClass: 'animsition-out-class', 55 outDuration: 'animsition-out-duration', 56 overlay: 'animsition-overlay' 57 }, 58 events: { 59 inStart: 'animsition.inStart', 60 inEnd: 'animsition.inEnd', 61 outStart: 'animsition.outStart', 62 outEnd: 'animsition.outEnd' 63 } 64 }; 65 66 // Remove the "Animsition" in a browser 67 // that does not support the "animaition-duration". 68 var support = __.supportCheck.call(this, options); 69 70 if (!support && options.browser.length > 0) { 71 if (!support || !this.length) { 72 // If do not have a console object to object window 73 if (!('console' in window)) { 74 window.console = {}; 75 window.console.log = function (str) { return str; }; 76 } 77 if (!this.length) console.log('Animsition: Element does not exist on page.'); 78 if (!support) console.log('Animsition: Does not support this browser.'); 79 return __.destroy.call(this); 80 } 81 } 82 83 var overlayMode = __.optionCheck.call(this, options); 84 85 if (overlayMode && $('.' + options.overlayClass).length <= 0) { 86 __.addOverlay.call(this, options); 87 } 88 89 if (options.loading && $('.' + options.loadingClass).length <= 0) { 90 __.addLoading.call(this, options); 91 } 92 93 return this.each(function () { 94 var _this = this; 95 var $this = $(this); 96 var $window = $(window); 97 var $document = $(document); 98 var data = $this.data(namespace); 99 100 if (!data) { 101 options = $.extend({}, options); 102 103 $this.data(namespace, { options: options }); 104 105 if (options.timeout) __.addTimer.call(_this); 106 107 if (options.onLoadEvent) { 108 if (!windowLoaded) { 109 $window.on('load.' + namespace, function () { 110 if (__.settings.timer) clearTimeout(__.settings.timer); 111 __.in.call(_this); 112 }); 113 } else { 114 if (__.settings.timer) clearTimeout(__.settings.timer); 115 __.in.call(_this); 116 } 117 } 118 119 $window.on('pageshow.' + namespace, function (event) { 120 if (event.originalEvent.persisted) __.in.call(_this); 121 }); 122 123 // Firefox back button issue #4 124 $window.on('unload.' + namespace, function () { }); 125 126 $document.on('click.' + namespace, options.linkElement, function (event) { 127 event.preventDefault(); 128 var $self = $(this); 129 var url = $self.attr('href'); 130 131 // middle mouse button issue #24 132 // if(middle mouse button || command key || shift key || win control key) 133 if (event.which === 2 || event.metaKey || event.shiftKey || navigator.platform.toUpperCase().indexOf('WIN') !== -1 && event.ctrlKey) { 134 window.open(url, '_blank'); 135 } else { 136 __.out.call(_this, $self, url); 137 } 138 139 }); 140 } 141 }); // end each 142 }, 143 144 addOverlay: function (options) { 145 $(options.overlayParentElement) 146 .prepend('<div class="' + options.overlayClass + '"></div>'); 147 }, 148 149 addLoading: function (options) { 150 $(options.loadingParentElement) 151 .append('<div class="' + options.loadingClass + '">' + options.loadingInner + '</div>'); 152 }, 153 154 removeLoading: function () { 155 var $this = $(this); 156 var options = $this.data(namespace).options; 157 var $loading = $(options.loadingParentElement).children('.' + options.loadingClass); 158 159 $loading.fadeOut().remove(); 160 }, 161 162 addTimer: function () { 163 var _this = this; 164 var $this = $(this); 165 var options = $this.data(namespace).options; 166 167 __.settings.timer = setTimeout(function () { 168 __.in.call(_this); 169 $(window).off('load.' + namespace); 170 }, options.timeoutCountdown); 171 }, 172 173 supportCheck: function (options) { 174 var $this = $(this); 175 var props = options.browser; 176 var propsNum = props.length; 177 var support = false;
178 179 if (propsNum === 0) { 180 support = true; 181 } 182 for (var i = 0; i < propsNum; i++) { 183 if (typeof $this.css(props[i]) === 'string') { 184 support = true; 185 break; 186 } 187 } 188 return support; 189 }, 190 191 optionCheck: function (options) { 192 var $this = $(this); 193 var overlayMode; 194 if (options.overlay || $this.data(__.settings.data.overlay)) { 195 overlayMode = true; 196 } else { 197 overlayMode = false; 198 } 199 return overlayMode; 200 }, 201 202 animationCheck: function (data, stateClass, stateIn) { 203 var $this = $(this); 204 var options = $this.data(namespace).options; 205 var dataType = typeof data; 206 var dataDuration = !stateClass && dataType === 'number'; 207 var dataClass = stateClass && dataType === 'string' && data.length > 0; 208 209 if (dataDuration || dataClass) { 210 data = data; 211 } else if (stateClass && stateIn) { 212 data = options.inClass; 213 } else if (!stateClass && stateIn) { 214 data = options.inDuration; 215 } else if (stateClass && !stateIn) { 216 data = options.outClass; 217 } else if (!stateClass && !stateIn) { 218 data = options.outDuration; 219 } 220 return data; 221 }, 222 223 in: function () { 224 var _this = this; 225 var $this = $(this); 226 var options = $this.data(namespace).options; 227 var thisInDuration = $this.data(__.settings.data.inDuration); 228 var thisInClass = $this.data(__.settings.data.inClass); 229 var inDuration = __.animationCheck.call(_this, thisInDuration, false, true); 230 var inClass = __.animationCheck.call(_this, thisInClass, true, true); 231 var overlayMode = __.optionCheck.call(_this, options); 232 var outClass = $this.data(namespace).outClass; 233 234 if (options.loading) __.removeLoading.call(_this); 235 236 if (outClass) $this.removeClass(outClass); 237 238 if (overlayMode) { 239 __.inOverlay.call(_this, inClass, inDuration); 240 } else { 241 __.inDefault.call(_this, inClass, inDuration); 242 } 243 }, 244 245 inDefault: function (inClass, inDuration) { 246 var $this = $(this); 247 248 $this 249 .css({ 'animation-duration': inDuration + 'ms' }) 250 .addClass(inClass) 251 .trigger(__.settings.events.inStart) 252 .animateCallback(function () { 253 $this 254 .removeClass(inClass) 255 .css({ 'opacity': 1 }) 256 .trigger(__.settings.events.inEnd); 257 }); 258 }, 259 260 inOverlay: function (inClass, inDuration) { 261 var $this = $(this); 262 var options = $this.data(namespace).options; 263 264 $this 265 .css({ 'opacity': 1 }) 266 .trigger(__.settings.events.inStart); 267 268 $(options.overlayParentElement) 269 .children('.' + options.overlayClass) 270 .css({ 'animation-duration': inDuration + 'ms' }) 271 .addClass(inClass) 272 .animateCallback(function () { 273 $this 274 .trigger(__.settings.events.inEnd); 275 }); 276 }, 277 278 out: function ($self, url) { 279 var _this = this; 280 var $this = $(this); 281 var options = $this.data(namespace).options; 282 var selfOutClass = $self.data(__.settings.data.outClass); 283 var thisOutClass = $this.data(__.settings.data.outClass); 284 var selfOutDuration = $self.data(__.settings.data.outDuration); 285 var thisOutDuration = $this.data(__.settings.data.outDuration); 286 var isOutClass = selfOutClass ? selfOutClass : thisOutClass; 287 var isOutDuration = selfOutDuration ? selfOutDuration : thisOutDuration; 288 var outClass = __.animationCheck.call(_this, isOutClass, true, false); 289 var outDuration = __.animationCheck.call(_this, isOutDuration, false, false); 290 var overlayMode = __.optionCheck.call(_this, options); 291 292 $this.data(namespace).outClass = outClass; 293 294 if (overlayMode) { 295 __.outOverlay.call(_this, outClass, outDuration, url); 296 } else { 297 __.outDefault.call(_this, outClass, outDuration, url); 298 } 299 }, 300 301 outDefault: function (outClass, outDuration, url) { 302 var $this = $(this); 303 var options = $this.data(namespace).options; 304 305 // (outDuration + 1) | #55 outDuration: 0 crashes on Safari only 306 $this 307 .css({ 'animation-duration': (outDuration + 1) + 'ms' }) 308 .addClass(outClass) 309 .trigger(__.settings.events.outStart) 310 .animateCallback(function () { 311 $this.trigger(__.settings.events.outEnd); 312 options.transition(url); 313 }); 314 }, 315 316 317 outOverlay: function (outClass, outDuration, url) { 318 var _this = this; 319 var $this = $(this); 320 var options = $this.data(namespace).options; 321 var thisInClass = $this.data(__.settings.data.inClass); 322 var inClass = __.animationCheck.call(_this, thisInClass, true, true); 323 324 // (outDuration + 1) | #55 outDuration: 0 crashes animsition on Safari only 325 $(options.overlayParentElement) 326 .children('.' + options.overlayClass) 327 .css({ 'animation-duration': (outDuration + 1) + 'ms' }) 328 .removeClass(inClass) 329 .addClass(outClass) 330 .trigger(__.settings.events.outStart) 331 .animateCallback(function () { 332 $this.trigger(__.settings.events.outEnd); 333 options.transition(url); 334 }); 335 }, 336 337 destroy: function () { 338 return this.each(function () { 339 var $this = $(this); 340 $(window).off('.' + namespace); 341 $this 342 .css({ 'opacity': 1 }) 343 .removeData(namespace); 344 }); 345 } 346 347 }; 348 349 $.fn.animateCallback = function (callback) { 350 var end = 'animationend webkitAnimationEnd'; 351 return this.each(function () { 352 var $this = $(this); 353 $this.on(end, function () { 354 $this.off(end); 355 return callback.call(this); 356 }); 357 }); 358 }; 359 360 $.fn.animsition = function (method) { 361 if (__[method]) { 362 return __[method].apply(this, Array.prototype.slice.call(arguments, 1)); 363 } else if (typeof method === 'object' || !method) { 364 return __.init.apply(this, arguments); 365 } else { 366 $.error('Method ' + method + ' does not exist on jQuery.' + namespace); 367 } 368 }; 369 370}));
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.