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 * jQuery('#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(jQuery) { 36 37 jQuery.fn.innerfade = function(options) { 38 return this.each(function() { 39 jQuery.innerfade(this, options); 40 }); 41 }; 42 43 jQuery.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 jQuery.extend(settings, options); 55 if (settings.children === null) 56 var elements = jQuery(container).children(); 57 else 58 var elements = jQuery(container).children(settings.children); 59 if (elements.length > 1) { 60 jQuery(container).css('position', 'relative').css('overflow', 'hidden').addClass(settings.runningclass); 61 for (var i = 0; i < elements.length; i++) { 62 jQuery(elements[i]).css('z-index', String(elements.length-i)).css('position', 'absolute').hide(); 63 }; 64 if (settings.type == "sequence") { 65 setTimeout(function() { 66 jQuery.innerfade.next(container,elements, settings, 1, 0); 67 }, settings.timeout); 68 jQuery(elements[0]).show(); 69 jQuery(container).css('height', jQuery(elements[0]).css('height')); 70 } else if (settings.type == "random") { 71 var last = Math.floor ( Math.random () * ( elements.length ) ); 72 setTimeout(function() { 73 do { 74 current = Math.floor ( Math.random ( ) * ( elements.length ) ); 75 } while (last == current ); 76 jQuery.innerfade.next(container,elements, settings, current, last); 77 }, settings.timeout); 78 jQuery(elements[last]).show(); 79 } else if ( settings.type == 'random_start' ) { 80 settings.type = 'sequence'; 81 var current = Math.floor ( Math.random () * ( elements.length ) ); 82 setTimeout(function(){ 83 jQuery.innerfade.next(container,elements, settings, (current + 1) % elements.length, current); 84 }, settings.timeout); 85 jQuery(elements[current]).show(); 86 } else { 87 alert('Innerfade-Type must either be \'sequence\', \'random\' or \'random_start\''); 88 } 89 } 90 }; 91 92 jQuery.innerfade.next = function(container,elements, settings, current, last) { 93 if (settings.animationtype == 'slide') { 94 if(jQuery(elements[current]).outerHeight() > jQuery(container).outerHeight()) 95 jQuery(container).css('height', jQuery(elements[current]).outerHeight()); 96 jQuery(elements[last]).slideUp(settings.speed); 97 jQuery(elements[current]).slideDown(settings.speed); 98 } else if (settings.animationtype == 'fade') { 99 jQuery(elements[last]).fadeOut(settings.speed); 100 jQuery(elements[current]).fadeIn(settings.speed, function() { 101 removeFilter(jQuery(this)[0]); 102 });
103 } else 104 alert('Innerfade-animationtype must either be \'slide\' or \'fade\''); 105 if (settings.type == "sequence") { 106 if ((current + 1) < elements.length) { 107 current = current + 1; 108 last = current - 1; 109 } else { 110 current = 0; 111 last = elements.length - 1; 112 } 113 } else if (settings.type == "random") { 114 last = current; 115 while (current == last) 116 current = Math.floor(Math.random() * elements.length); 117 } else 118 alert('Innerfade-Type must either be \'sequence\', \'random\' or \'random_start\''); 119 setTimeout((function() { 120 jQuery.innerfade.next(container,elements, settings, current, last); 121 }), settings.timeout); 122 }; 123 124})(jQuery); 125 126// **** remove Opacity-Filter in ie **** 127function removeFilter(element) { 128 if(element.style.removeAttribute){ 129 element.style.removeAttribute('filter'); 130 } 131}
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.