1/** wpcuFPN front-end jQuery script v.0.1 **/ 2 3var currentSlide = new Array( 0 ); 4var slideLength = 1; 5var slideDirection = 'left'; 6var logging = false; 7//var autoanimate = false; 8//var transition_type = 'slide'; 9 10(function($){ 11 $( document ).ready(function() { 12 //console_log( 'Doc ready.' ); 13 14 /** Enable slideshow navigation arrows **/ 15 $('.slidebtn').click(function(e){ 16 e.preventDefault(); 17 console_log( 'slidebtn clicked' ); 18 autoanimate = false; 19 window.autoanimate = false; 20 scrollSlideshow( e ); 21 return false; 22 }); 23 24 /** Enable slideshow page navigation **/ 25 $('.pagi_p').click(function(e){ 26 e.preventDefault(); 27 console_log( 'pagi_p clicked' ); 28 autoanimate = false; 29 window.autoanimate = false; 30 scrollSlideshow( e ); 31 return false; 32 }); 33 34 /** Setup slideshow containers heights **/ 35 $('.wpcufpn_container').each( function(i){ 36 var cont_id = $(this).attr('id').substr(15); 37 //console.log('container id: '+cont_id); 38 var nbrows = wpfpn_nbrows[cont_id]; 39 console_log('nb rows: '+nbrows); 40 if( $(this).hasClass('horizontal') ) { 41 height = 0; 42 $('li',this).each( function(j){ 43 if( $(this).outerHeight() > height ) 44 height = $(this).outerHeight(); 45 }); 46 var liheight = height; 47 if( nbrows > 1 ) height = height * nbrows; 48 $(this).height(height); 49 $('ul li',this).height(liheight); 50 } else { 51 $(this).height($('ul',this).height()); 52 } 53 }); 54 55 /** Start autoanimate if necessary **/ 56 console_log( 'window.autoanimate: ' + window.autoanimate ); 57 if( window.autoanimate ) { 58 var autoanimate = true; 59 auto_animate(); 60 } 61 }); 62 63 function auto_animate() { 64 if( autoanimate ) { 65 //TODO: use element class to animate'em all 66 scrollSlideshow( $.Event( 'dblclick', { target: $('.wpcufpn_container:first') } ) ); 67 setTimeout(auto_animate,5000); 68 } 69 } 70 71 /** Slideshow controls **/ 72 function scrollSlideshow( event ) { 73 74 //TODO: get transition type from element class 75 if( 'undefined' === typeof transition_type || !transition_type ) 76 transition_type = 'slide'; 77 78 if(autoanimate) { 79 slideLength = Math.floor( $('.wpcufpn_listposts:first',$(event.target).parent()).width() / $('.wpcufpn_container:first',$(event.target).parent()).width() ); 80 slider = $((event.target).parent()); 81 } else { 82 slideLength = Math.floor( $('.wpcufpn_listposts:first',$(event.target.parentElement).parent()).width() / $('.wpcufpn_container:first',$(event.target.parentElement).parent()).width() ); 83 slider = $($(event.target.parentElement).parent()); 84 //slider = $((event.target).parent); 85 } 86 87 var speed = 'fast'; 88 if( 'slide' == transition_type ) { 89 var speed = 'fast'; 90 } 91 if( 'fade' == transition_type ) { 92 var speed = 0; 93 } 94 $('.wpcufpn_listposts',slider).css({ 95 '-moz-transition':'none', 96 '-webkit-transition':'none', 97 '-o-transition':'color 0 ease-in', 98 'transition':'none' 99 }); 100 101 console_log('slider:'); 102 console_log(slider); 103 console_log( 'slideLength: ' + slideLength ); 104 var slideShowClass = $(event.target).parent().parent().attr('class'); 105 var slideShowId = slideShowClass.substr(slideShowClass.indexOf('wpcufpn_widget_')+15,slideShowClass.length); 106 if( !slideShowId ) 107 slideShowId = 0; 108 109 if( !slideShowId in currentSlide || !currentSlide[slideShowId] ) 110 currentSlide[slideShowId] = 0; 111 112 console_log( 'slideShow ID: ' + slideShowId ); 113 console_log( 'currentSlide: ' + currentSlide[slideShowId] ); 114 115 if ( 116 event.type == "swipeleft" || 117 ( event.type == "dblclick" && slideDirection == 'left' ) || 118 $(event.target).hasClass('slide_right') 119 ) { 120 console_log('sliding left ' + transition_type); 121 if( currentSlide[slideShowId] <= -(slideLength-1) ) { 122 if( 'slide' == transition_type ) 123 bounceSlide( 'left', slider, event ); 124 slideDirection = 'right'; 125 return; 126 } else { 127 currentSlide[slideShowId] --; 128 } 129 } 130 if ( 131 event.type == "swiperight" || 132 ( event.type == "dblclick" && slideDirection == 'right' ) || 133 $(event.target).hasClass('slide_left') 134 ) { 135 console_log('sliding right ' + transition_type); 136 if( currentSlide[slideShowId] >= 0 ) { 137 if( 'slide' == transition_type ) 138 bounceSlide( 'right', slider, event ); 139 slideDirection = 'left'; 140 return; 141 } else { 142 currentSlide[slideShowId] ++; 143 } 144 } 145 if( $(event.target).hasClass('pagi_p') ) { 146 var page_to = $(event.target).text(); 147 page_to --; 148 page_to = - page_to; 149 console_log( 'page_to: ' + page_to ); 150 if( page_to == currentSlide[slideShowId] ) 151 return; 152 if( page_to > currentSlide[slideShowId] ) { 153 step = 1 154 } else { 155 step = -1 156 } 157 while( currentSlide[slideShowId] != page_to ) { 158 currentSlide[slideShowId] = currentSlide[slideShowId] + step; 159 console_log( 'sliding to: ' + currentSlide[slideShowId] ); 160 if( 'fade' == transition_type ) { 161 $('.wpcufpn_listposts',slider).fadeOut('slow',function(){$('.wpcufpn_listposts',slider).css({ 162 'marginLeft' : $('.wpcufpn_container:first',slider).width() * currentSlide[slideShowId] 163 })}).fadeIn('slow'); 164 } else { 165 $('.wpcufpn_listposts',slider).animate({ 166 'marginLeft' : $('.wpcufpn_container:first',slider).width() * currentSlide[slideShowId] 167 }, speed); 168 } 169 //if( 'fade' == transition_type ) 170 // $('.wpcufpn_listposts:first',slider).fadeIn(600); 171 } 172 console_log('parent:'); 173 console_log($(event.target).parent().parent()); 174 console_log('ppn_'+(1-currentSlide[slideShowId])); 175 $('div.wpcufpn_nav .pagi_p', $(event.target).parent().parent()).removeClass('active'); 176 $('div.wpcufpn_nav .pagi_p.ppn_'+(1-currentSlide[slideShowId]), $(event.target).parent().parent()).addClass('active'); 177 return; 178 }
179 console_log('currentSlide: ' + currentSlide[slideShowId]); 180 181 if( 'fade' == transition_type ) { 182 $('.wpcufpn_listposts',slider).fadeOut('slow',function(){$('.wpcufpn_listposts',slider).css({ 183 'marginLeft' : $('.wpcufpn_container:first',slider).width() * currentSlide[slideShowId] 184 })}).fadeIn('slow'); 185 } else { 186 $('.wpcufpn_listposts',slider).animate({ 187 'marginLeft' : $('.wpcufpn_container:first',slider).width() * currentSlide[slideShowId] 188 }, speed); 189 } 190 //if( 'fade' == transition_type ) 191 // $('.wpcufpn_listposts:first',slider).fadeIn(600); 192 //$('#image_ph ul#pagination li.on').removeClass('on'); 193 //$('#image_ph ul#pagination li.sp_' + (-currentSlide[slideShowId]) ).addClass('on'); 194 } 195 196 /** Makes slideshow bounce a bit when reaching end of slides **/ 197 function bounceSlide( direction, slider, event ) { 198 199 console_log('bouncing ' + direction); 200 201 var slideShowClass = $(event.target).parent().parent().attr('class'); 202 var slideShowId = slideShowClass.substr(slideShowClass.indexOf('wpcufpn_widget_')+15,slideShowClass.length); 203 if( !slideShowId ) 204 slideShowId = 0; 205 206 if( !slideShowId in currentSlide || !currentSlide[slideShowId] ) 207 currentSlide[slideShowId] = 0; 208 209 if( direction == 'left' ) { 210 amp = -15; 211 } else { 212 amp = 15; 213 } 214 $('.wpcufpn_listposts:first',slider).animate({ 215 'marginLeft' : ( $('.wpcufpn_container:first',slider).width() * currentSlide[slideShowId] ) + amp 216 }, 'fast', 'swing', function() { 217 $('.wpcufpn_listposts:first',slider).animate({ 218 'marginLeft' : ( $('.wpcufpn_container:first',slider).width() * currentSlide[slideShowId] ) 219 }, 'fast'); 220 }); 221 } 222 223 function console_log( msg ) { 224 if(logging && window.console) { 225 window.console.log( msg ); 226 } 227 } 228 229})( jQuery );
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.