1/** 2 * Vertical scroll recent post 3 * Copyright (C) 2011 - 2021 www.gopiplus.com 4 * http://www.gopiplus.com/work/2010/07/18/vertical-scroll-recent-post/ 5 * 6 * This program is free software: you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation, either version 3 of the License, or 9 * (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program. If not, see <http://www.gnu.org/licenses/>. 18 */ 19 20;!(function ($) { 21 $.fn.classes = function (callback) { 22 var classes = []; 23 $.each(this, function (i, v) { 24 var splitClassName = v.className.split(/\s+/); 25 for (var j in splitClassName) { 26 var className = splitClassName[j]; 27 if (-1 === classes.indexOf(className)) { 28 classes.push(className); 29 } 30 } 31 }); 32 if ('function' === typeof callback) { 33 for (var i in classes) { 34 callback(classes[i]); 35 } 36 } 37 return classes; 38 }; 39})(jQuery); 40 41function slideDown( element ) { 42 var divs = element.children(); 43 var speed = element.attr( 'data-speed' ) * 1000; 44 var height = jQuery( divs[1] ).outerHeight(); 45 var moving = 0; 46 /* Find which vsrp element we are handling, it has the form vsrp_id_X */ 47 var classes = element.classes(); 48 var special_class = jQuery.grep( classes, function( n, i ) { 49 n = String( n ); 50 if ( n.indexOf( 'vsrp_id' ) > -1 ) 51 return i; 52 }); 53 /* 54 * If it's the first run of the cycle, meaning no div is marked to be removed, 55 * clone the last div to the top of the list and mark the last to be removed. 56 */ 57 special_class += 'vsrp_remove'; 58 var count = jQuery( '.'+special_class ); 59 if ( count.length == 0 ) { 60 var last = jQuery( divs[ divs.length - 1 ] ); 61 var last_cloned = last.clone(); 62 element.prepend( last_cloned ); 63 last.addClass( special_class ); 64 /* 65 * As a new element is prepended in the top of the list, all elements are moved down 66 * but we want the new element to be hidden and to slideDown slowly rather than appearing 67 * in an instant. So all elements should be moved up (with a negative top attribute) so the 68 * new first element shall be hidden. 69 */ 70 divs = element.children(); 71 divs.css( 'top', height * -1 ); 72 /* In this case the moving distance should be a divs height */ 73 moving = height; 74 } else { 75 /* 76 * In case we continue a cycle, after a mouseover for example 77 * the moving distance should be less than the divs height 78 * so we check how much was left before the mouseover 79 */ 80 var top = jQuery( divs[0] ).css( 'top' ); 81 top = parseInt( top, 10 ) || 0; 82 if( top < 0 ) { 83 moving = top * -1; 84 } 85 } 86 /* 87 * After the animation, remove the div that has been cloned 88 * and reset the top attribute of divs to zero. 89 */ 90 jQuery( divs ).animate( 91 { top: "+="+moving }, 92 speed, 93 'linear', 94 function(){ 95 jQuery( '.'+special_class ).remove(); 96 divs.css( "top", 0 ); 97 } 98 ); 99} 100 101function slideUp( element ) { 102 var divs = element.children(); 103 var speed = element.attr( 'data-speed' ) * 1000; 104 var height = jQuery( divs[1] ).outerHeight(); 105 var moving = 0; 106 /* Find which vsrp element we are handling, it has the form vsrp_id_X */ 107 var classes = element.classes(); 108 var special_class = jQuery.grep( classes, function( n, i ) { 109 if ( n.indexOf( 'vsrp_id' ) > -1 ) 110 return i; 111 });
112 /* 113 * If it's the first run of the cycle, meaning no div is marked to be removed, 114 * clone the first div to the bottom of the list and mark the first to be removed. 115 */ 116 special_class += 'vsrp_remove'; 117 var count = jQuery( '.'+special_class ); 118 if ( count.length == 0 ) { 119 var first = jQuery( divs[0] ); 120 var first_cloned = first.clone(); 121 element.append( first_cloned ); 122 first.addClass( special_class ); 123 divs = element.children(); 124 /* In this case the moving distance should be a divs height */ 125 moving = height; 126 } else { 127 /* 128 * In case we continue a cycle, after a mouseover for example 129 * the moving distance should be less than the divs height 130 * so we check how much was left before the mouseover 131 */ 132 var top = jQuery( divs[0] ).css( 'top' ); 133 top = parseInt( top, 10 ) || 0; 134 if( top < 0 ) { 135 moving = height - ( top * -1 ); 136 } 137 } 138 /* 139 * After the animation, remove the div that has been cloned 140 * and reset the top attribute of divs to zero. 141 */ 142 jQuery( divs ).animate( 143 { top: "-="+moving }, 144 speed, 145 'linear', 146 function(){ 147 jQuery( '.'+special_class ).remove(); 148 divs.css( "top", 0 ); 149 } 150 ); 151} 152 153jQuery( document ).ready( function(){ 154 var tmp = 0; 155 jQuery.each( jQuery( '.vsrp_wrapper' ), function() { 156 var intervalID; 157 var element = jQuery( this ); 158 var class_element = 'vsrp_id_' + (tmp++); 159 element.addClass( class_element ); 160 var direction = element.attr( 'data-direction' ); 161 /* 162 * Time of interval must be greater than the animation's speed 163 * otherwise the behavior is unstable, so no matter the settings 164 * if the delay is lesser than speed, delay becomes speed plus 1/2 second. 165 */ 166 var delay = element.attr( 'data-delay-seconds' ) * 1000; 167 var speed = element.attr( 'data-speed' ) * 1000; 168 if ( delay < speed ) 169 delay = speed + 500; 170 /* Depending on direction call the correct function */ 171 if ( direction == 1 ) { 172 intervalID = setInterval( slideUp, delay, element ); 173 } else { 174 intervalID = setInterval( slideDown, delay, element ); 175 } 176 /* On mouseover enable the "pause" feature */ 177 element.on( 'mouseenter', function() { 178 var tmp = jQuery( this ).children(); 179 tmp.stop(); 180 clearInterval( intervalID ); 181 }); 182 element.on( 'mouseleave', function() { 183 if ( direction == 1 ) { 184 slideUp( element ); 185 intervalID = setInterval( slideUp, delay, element ); 186 } else { 187 slideDown( element ); 188 intervalID = setInterval( slideDown, delay, element ); 189 } 190 }); 191 }); 192 193 if ( jQuery( ".nav-tab-wrapper > a" ).length >= 1 ) { 194 jQuery( ".nav-tab-wrapper > a" ).click( function() { 195 jQuery( ".nav-tab-wrapper > a" ).removeClass( "nav-tab-active" ); 196 jQuery( this ).addClass( "nav-tab-active" ); 197 jQuery( ".table" ).addClass( "ui-tabs-hide" ); 198 199 var item_clicked = jQuery( this ).attr( "href" ); 200 jQuery( item_clicked ).removeClass( "ui-tabs-hide" ); 201 return false; 202 }); 203 } 204 if ( jQuery( ".fade" ).length >= 1 ) { 205 jQuery( ".fade" ).delay( 1500 ).fadeOut(); 206 } 207} );
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.