1/* ========================================================= 2 3// jquery.innerfade.js 4 5// Datum: 2008-02-14 6// Firma: Medienfreunde Hofmann & Baldes GbR 7// Author: Torsten Baldes 8// Mail: [email protected] 9// Web: http://medienfreunde.com 10 11// based on the work of Matt Oakes http://portfolio.gizone.co.uk/applications/slideshow/ 12// and Ralf S. Engelschall http://trainofthoughts.org/ 13 14 * 15 * <ul id="news"> 16 * <li>content 1</li> 17 * <li>content 2</li> 18 * <li>content 3</li> 19 * </ul> 20 * 21 * $('#news').innerfade({ 22 * animationtype: Type of animation 'fade' or 'slide' (Default: 'fade'), 23 * speed: Fading-/Sliding-Speed in milliseconds or keywords (slow, normal or fast) (Default: 'normal'), 24 * timeout: Time between the fades in milliseconds (Default: '2000'), 25 * type: Type of slideshow: 'sequence', 'random' or 'random_start' (Default: 'sequence'), 26 * containerheight: Height of the containing element in any css-height-value (Default: 'auto'), 27 * runningclass: CSS-Class which the container getâs applied (Default: 'innerfade'), 28 * children: optional children selector (Default: null) 29 * }); 30 * 31 32// ========================================================= */ 33 34 35(function($) { 36 37 $.fn.innerfade = function(options) { 38 return this.each(function() { 39 $.innerfade(this, options); 40 }); 41 }; 42 43 $.innerfade = function(container, options) { 44 var settings = { 45 'animationtype': 'fade', 46 'speed': 'normal', 47 'type': 'sequence', 48 'timeout': 2000, 49 'containerheight': 'auto', 50 'runningclass': 'innerfade', 51 'children': null 52 }; 53 if (options) 54 $.extend(settings, options); 55 if (settings.children === null) 56 var elements = $(container).children(); 57 else 58 var elements = $(container).children(settings.children); 59 if (elements.length > 1) { 60 $(container).css('position', 'relative').css('height', settings.containerheight).addClass(settings.runningclass); 61 for (var i = 0; i < elements.length; i++) { 62 $(elements[i]).css('z-index', String(elements.length-i)).css('position', 'absolute').hide(); 63 }; 64 if (settings.type == "sequence") { 65 setTimeout(function() { 66 $.innerfade.next(elements, settings, 1, 0); 67 }, settings.timeout); 68 $(elements[0]).show(); 69 } else if (settings.type == "random") { 70 var last = Math.floor ( Math.random () * ( elements.length ) ); 71 setTimeout(function() { 72 do { 73 current = Math.floor ( Math.random ( ) * ( elements.length ) ); 74 } while (last == current ); 75 $.innerfade.next(elements, settings, current, last); 76 }, settings.timeout); 77 $(elements[last]).show(); 78 } else if ( settings.type == 'random_start' ) { 79 settings.type = 'sequence'; 80 var current = Math.floor ( Math.random () * ( elements.length ) ); 81 setTimeout(function(){ 82 $.innerfade.next(elements, settings, (current + 1) % elements.length, current); 83 }, settings.timeout); 84 $(elements[current]).show(); 85 } else { 86 alert('Innerfade-Type must either be \'sequence\', \'random\' or \'random_start\''); 87 } 88 } 89 }; 90 91 $.innerfade.next = function(elements, settings, current, last) { 92 if (settings.animationtype == 'slide') { 93 $(elements[last]).slideUp(settings.speed); 94 $(elements[current]).slideDown(settings.speed); 95 } else if (settings.animationtype == 'fade') { 96 $(elements[last]).fadeOut(settings.speed); 97 $(elements[current]).fadeIn(settings.speed, function() { 98 removeFilter($(this)[0]); 99 }); 100 } else 101 alert('Innerfade-animationtype must either be \'slide\' or \'fade\''); 102 if (settings.type == "sequence") { 103 if ((current + 1) < elements.length) { 104 current = current + 1; 105 last = current - 1; 106 } else { 107 current = 0; 108 last = elements.length - 1; 109 } 110 } else if (settings.type == "random") { 111 last = current; 112 while (current == last) 113 current = Math.floor(Math.random() * elements.length); 114 } else 115 alert('Innerfade-Type must either be \'sequence\', \'random\' or \'random_start\''); 116 setTimeout((function() { 117 $.innerfade.next(elements, settings, current, last); 118 }), settings.timeout); 119 }; 120 121})(jQuery); 122 123// **** remove Opacity-Filter in ie **** 124function removeFilter(element) { 125 if(element.style.removeAttribute){ 126 element.style.removeAttribute('filter'); 127 } 128}
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.