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