1 2/* 3 * fadeSlideShow 4 * v.2.1.0 5 * 6 * Copyright (c) 2010 Pascal Bajorat (http://www.pascal-bajorat.com) 7 * Dual licensed under the MIT (below) 8 * and GPL (http://www.gnu.org/licenses/gpl.txt) licenses. 9 * 10 * 11 * http://plugins.jquery.com/project/fadeslideshow 12 * http://www.pascal-bajorat.com 13 14MIT License 15 16Copyright (c) 2013 Pascal Bajorat 17 18Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 19 20The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 21 22THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 */ 24 25jQuery.fn.fadeSlideShow = function(options) { 26 return this.each(function(){ 27 settings = jQuery.extend({ 28 width: 640, // default width of the slideshow 29 height: 480, // default height of the slideshow 30 speed: 'slow', // default animation transition speed 31 interval: 3000, // default interval between image change 32 PlayPauseElement: 'fssPlayPause', // default css id for the play / pause element 33 PlayText: 'Play', // default play text 34 PauseText: 'Pause', // default pause text 35 NextElement: 'fssNext', // default id for next button 36 NextElementText: 'Next >', // default text for next button 37 PrevElement: 'fssPrev', // default id for prev button 38 PrevElementText: '< Prev', // default text for prev button 39 ListElement: 'fssList', // default id for image / content controll list 40 ListLi: 'fssLi', // default class for li's in the image / content controll 41 ListLiActive: 'fssActive', // default class for active state in the controll list 42 addListToId: false, // add the controll list to special id in your code - default false 43 allowKeyboardCtrl: true, // allow keyboard controlls left / right / space 44 autoplay: true // autoplay the slideshow 45 }, options); 46 47 // set style for wrapper element 48 jQuery(this).css({ 49 width: settings.width, 50 height: settings.height, 51 position: 'relative', 52 overflow: 'hidden' 53 }); 54 55 // set styles for child element 56 jQuery('> *',this).css({ 57 position: 'absolute', 58 width: settings.width, 59 height: settings.height 60 }); 61 62 // count number of slides 63 var Slides = jQuery('> *', this).length; 64 Slides = Slides - 1; 65 var ActSlide = Slides; 66 // Set jQuery Slide short var 67 var jQslide = jQuery('> *', this); 68 // save this 69 var fssThis = this; 70 var intval = false; 71 var autoplay = function(){ 72 intval = setInterval(function(){ 73 jQslide.eq(ActSlide).fadeOut(settings.speed); 74 75 // if list is on change the active class 76 if(settings.ListElement){ 77 var setActLi = (Slides - ActSlide) + 1; 78 if(setActLi > Slides){setActLi=0;} 79 jQuery('#'+settings.ListElement+' li').removeClass(settings.ListLiActive); 80 jQuery('#'+settings.ListElement+' li').eq(setActLi).addClass(settings.ListLiActive); 81 } 82 83 if(ActSlide <= 0){ 84 jQslide.fadeIn(settings.speed); 85 ActSlide = Slides; 86 }else{ 87 ActSlide = ActSlide - 1; 88 } 89 }, settings.interval); 90 91 if(settings.PlayPauseElement){ 92 jQuery('#'+settings.PlayPauseElement).html(settings.PauseText); 93 } 94 } 95 96 var stopAutoplay = function(){ 97 clearInterval(intval); 98 intval = false; 99 if(settings.PlayPauseElement){
100 jQuery('#'+settings.PlayPauseElement).html(settings.PlayText); 101 } 102 } 103 104 var jumpTo = function(newIndex){ 105 if(newIndex < 0){newIndex = Slides;} 106 else if(newIndex > Slides){newIndex = 0;} 107 if( newIndex >= ActSlide ){ 108 jQuery('> *:lt('+(newIndex+1)+')', fssThis).fadeIn(settings.speed); 109 }else if(newIndex <= ActSlide){ 110 jQuery('> *:gt('+newIndex+')', fssThis).fadeOut(settings.speed); 111 } 112 113 // set the active slide 114 ActSlide = newIndex; 115 116 if(settings.ListElement){ 117 // set active 118 jQuery('#'+settings.ListElement+' li').removeClass(settings.ListLiActive); 119 jQuery('#'+settings.ListElement+' li').eq((Slides-newIndex)).addClass(settings.ListLiActive); 120 } 121 } 122 123 // if list is on render it 124 if(settings.ListElement){ 125 var i=0; 126 var li = ''; 127 while(i<=Slides){ 128 if(i==0){ 129 li = li+'<li class="'+settings.ListLi+i+' '+settings.ListLiActive+'"><a href="#">'+(i+1)+'<\/a><\/li>'; 130 }else{ 131 li = li+'<li class="'+settings.ListLi+i+'"><a href="#">'+(i+1)+'<\/a><\/li>'; 132 } 133 i++; 134 } 135 var List = '<ul id="'+settings.ListElement+'">'+li+'<\/ul>'; 136 137 // add list to a special id or append after the slideshow 138 if(settings.addListToId){ 139 jQuery('#'+settings.addListToId).append(List); 140 }else{ 141 jQuery(this).after(List); 142 } 143 144 jQuery('#'+settings.ListElement+' a').bind('click', function(){ 145 var index = jQuery('#'+settings.ListElement+' a').index(this); 146 stopAutoplay(); 147 var ReverseIndex = Slides-index; 148 149 jumpTo(ReverseIndex); 150 151 return false; 152 }); 153 } 154 155 if(settings.PlayPauseElement){ 156 if(!jQuery('#'+settings.PlayPauseElement).css('display')){ 157 jQuery(this).after('<a href="#" id="'+settings.PlayPauseElement+'"><\/a>'); 158 } 159 160 if(settings.autoplay){ 161 jQuery('#'+settings.PlayPauseElement).html(settings.PauseText); 162 }else{ 163 jQuery('#'+settings.PlayPauseElement).html(settings.PlayText); 164 } 165 166 jQuery('#'+settings.PlayPauseElement).bind('click', function(){ 167 if(intval){ 168 stopAutoplay(); 169 }else{ 170 autoplay(); 171 } 172 return false; 173 }); 174 } 175 176 if(settings.NextElement){ 177 if(!jQuery('#'+settings.NextElement).css('display')){ 178 jQuery(this).after('<a href="#" id="'+settings.NextElement+'">'+settings.NextElementText+'<\/a>'); 179 } 180 181 jQuery('#'+settings.NextElement).bind('click', function(){ 182 nextSlide = ActSlide-1; 183 stopAutoplay(); 184 jumpTo(nextSlide); 185 return false; 186 }); 187 } 188 189 if(settings.PrevElement){ 190 if(!jQuery('#'+settings.PrevElement).css('display')){ 191 jQuery(this).after('<a href="#" id="'+settings.PrevElement+'">'+settings.PrevElementText+'<\/a>'); 192 } 193 194 jQuery('#'+settings.PrevElement).bind('click', function(){ 195 prevSlide = ActSlide+1; 196 stopAutoplay(); 197 jumpTo(prevSlide); 198 return false; 199 }); 200 } 201 202 if(settings.allowKeyboardCtrl){ 203 jQuery(document).bind('keydown', function(e){ 204 if(e.which==39){ 205 var nextSlide = ActSlide-1; 206 stopAutoplay(); 207 jumpTo(nextSlide); 208 }else if(e.which==37){ 209 var prevSlide = ActSlide+1; 210 stopAutoplay(); 211 jumpTo(prevSlide); 212 }else if(e.which==32){ 213 if(intval){stopAutoplay();} 214 else{autoplay();} 215 return false; 216 } 217 }); 218 } 219 220 // start autoplay or set it to false 221 if(settings.autoplay){autoplay();}else{intval=false;} 222 }); 223};
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.