Changeset 470978
- Timestamp:
- 12/04/2011 09:29:57 PM (14 years ago)
- Location:
- featured-posts-scroll/trunk
- Files:
-
- 4 edited
-
. (modified) (1 prop)
-
featured-posts-scroll.php (modified) (1 diff)
-
js/featuredpostslides.php (modified) (1 diff)
-
readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
featured-posts-scroll/trunk
- Property svn:mergeinfo changed
/featured-posts-scroll/branches/varsize merged: 470971
- Property svn:mergeinfo changed
-
featured-posts-scroll/trunk/featured-posts-scroll.php
r429277 r470978 4 4 Plugin URI: http://chasepettit.com 5 5 Description: A basic javascript based scrolling display of post titles and thumbnails. 6 Version: 1.2 06 Version: 1.21 7 7 Author: Chaser324 8 8 Author URI: http://chasepettit.com -
featured-posts-scroll/trunk/js/featuredpostslides.php
r429277 r470978 12 12 ?> 13 13 14 var type = 'none'; // Type of slider present (v1.0 only supports 'single') 15 var fpg_animLocked = new Array(); // Lock object for animations 16 var autoscrollInterval = new Array(); 17 var $j = jQuery.noConflict(); // Prevent jQuery conflicts 18 19 /** Initialize jQuery based animations */ 20 function init() 21 { 22 // determine if the single or triple flavor is in use 23 if ($j('.fps-single').length != 0 && $j('.fps-single li').length > 1) 24 { 25 type = 'single'; 26 27 // hide all but first entry in featured posts list 28 $j('.featured-posts-wrapper').each(function() { 29 $j(this).find('.fps-text').slice(1).fadeOut(); 30 $j(this).find('ul.featured-posts li').slice(1).css('display','none'); 31 }); 32 } 33 34 // init animations 35 initAutoscroll(); 36 37 // initialize the scroll and slide buttons 38 initScrollButtons(); 39 initSlideNumbers(); 40 41 // release animation locks 42 for (var i=1; i<=fpg_animLocked.length; i++) 43 { 44 fpg_animLocked[i-1] = false; 45 } 46 } 47 48 /** Add click event handlers to scroll buttons */ 49 function initScrollButtons() 50 { 51 if (type != 'none') 52 { 53 $j('.scrollFeaturedPostsRight').each(function(index) { 54 $j(this).click(function() { 55 if (fpg_animLocked[index] == false) 14 15 var FeaturedPostsLib = this.FeaturedPostsLib || {}; 16 FeaturedPostsLib.fps = FeaturedPostsLib.fps || {}; 17 18 (function($j) { 19 var type = 'none'; // Type of slider present (v1.0 only supports 'single') 20 var fpg_animLocked = new Array(); // Lock object for animations 21 var autoscrollInterval = new Array(); 22 23 /** Initialize jQuery based animations */ 24 FeaturedPostsLib.fps.init = function() 25 { 26 // determine if the single or triple flavor is in use 27 if ($j('.fps-single').length != 0 && $j('.fps-single li').length > 1) 28 { 29 type = 'single'; 30 31 // hide all but first entry in featured posts list 32 $j('.featured-posts-wrapper').each(function() { 33 $j(this).find('.fps-text').slice(1).fadeOut(); 34 $j(this).find('ul.featured-posts li').slice(1).css('display','none'); 35 }); 36 } 37 38 // init animations 39 initAutoscroll(); 40 41 // initialize the scroll and slide buttons 42 initScrollButtons(); 43 initSlideNumbers(); 44 45 // release animation locks 46 for (var i=1; i<=fpg_animLocked.length; i++) 47 { 48 fpg_animLocked[i-1] = false; 49 } 50 }; 51 52 53 /** Add click event handlers to scroll buttons */ 54 function initScrollButtons() 55 { 56 if (type != 'none') 57 { 58 $j('.scrollFeaturedPostsRight').each(function(index) { 59 $j(this).click(function() { 60 if (fpg_animLocked[index] == false) 61 { 62 scrollFeaturedPosts(this, 'right', index); 63 } 64 clearInterval(autoscrollInterval[index]); 65 }); 66 }); 67 68 $j('.scrollFeaturedPostsLeft').each(function(index) { 69 $j(this).click(function() { 70 if (fpg_animLocked[index] == false) 71 { 72 scrollFeaturedPosts(this, 'left', index); 73 } 74 clearInterval(autoscrollInterval[index]); 75 }); 76 }); 77 78 $j('.scrollFeaturedPostsRight-below').each(function(index) { 79 $j(this).click(function() { 80 if (fpg_animLocked[index] == false) 81 { 82 scrollFeaturedPosts(this, 'right', index); 83 } 84 clearInterval(autoscrollInterval[index]); 85 }); 86 }); 87 88 $j('.scrollFeaturedPostsLeft-below').each(function(index) { 89 $j(this).click(function() { 90 if (fpg_animLocked[index] == false) 91 { 92 scrollFeaturedPosts(this, 'left', index); 93 } 94 clearInterval(autoscrollInterval[index]); 95 }); 96 }); 97 } 98 else 99 { 100 $j('.scrollFeaturedPostsRight').remove(); 101 $j('.scrollFeaturedPostsLeft').remove(); 102 $j('.featured-posts-wrapper ul').css('margin-left', '22px'); 103 } 104 } 105 106 107 function initSlideNumbers() 108 { 109 if (type != 'none') 110 { 111 $j('ul.fps-slideNumberList').each(function(index) { 112 $j(this).children('li').click(function() { 113 if (fpg_animLocked[index] == false) 114 { 115 scrollToPost(this, index); 116 } 117 clearInterval(autoscrollInterval[index]); 118 }); 119 }); 120 } 121 } 122 123 124 function initAutoscroll() 125 { 126 if (type != 'none') 127 { 128 $j('.featured-posts-wrapper').each(function(index) { 129 fpg_animLocked[index] = true; 130 if ($j(this).hasClass('fps-autoscroll')) 56 131 { 57 scrollFeaturedPosts(this, 'right', index); 132 if ($j('.featured-posts-wrapper').slice(index,index+1).children('.scrollFeaturedPostsRight').length > 0) 133 { 134 var callback = 135 "scrollFeaturedPosts($j('.featured-posts-wrapper').slice(" + 136 index + "," + (index + 1) + ").children('.scrollFeaturedPostsRight'), 'right', " + index + ")"; 137 autoscrollInterval[index] = setInterval( 138 callback, <?php echo $post_scroll_interval ?>); 139 } 140 else 141 { 142 var callback = 143 "scrollFeaturedPosts($j('.featured-posts-wrapper').slice(" + 144 index + "," + (index + 1) + ").children('.scrollFeaturedPostsRight-below'), 'right', " + index + ")"; 145 autoscrollInterval[index] = setInterval( 146 callback, <?php echo $post_scroll_interval ?>); 147 } 58 148 } 59 clearInterval(autoscrollInterval[index]); 60 }); 61 }); 62 63 $j('.scrollFeaturedPostsLeft').each(function(index) { 64 $j(this).click(function() { 65 if (fpg_animLocked[index] == false) 149 }); 150 } 151 } 152 153 154 function scrollToPost(slideButton, index) 155 { 156 if (!($j(slideButton).hasClass('fps-selectedSlide'))) 157 { 158 // lock animations 159 fpg_animLocked[index] = true; 160 161 var currentItem = $j(slideButton).parent().siblings('ul.featured-posts').children('li:visible'); 162 163 // get the next item to display 164 var nextItemIndex = parseInt($j(slideButton).text()); 165 166 var nextItem = $j(slideButton).parent().siblings('ul.featured-posts').children('li').eq(nextItemIndex-1); 167 168 setSelectedSlide(nextItem); 169 animate(nextItem, currentItem, 'right', index) 170 } 171 } 172 173 174 function scrollFeaturedPosts(button, dir, index) 175 { 176 if (fpg_animLocked[index] != true) 177 { 178 // lock animations 179 fpg_animLocked[index] = true; 180 181 // get the currently displayed element(s) 182 var currentItem = $j(button).siblings('ul.featured-posts').children('li:visible'); 183 184 var nextItem; 185 186 if (type == 'single') 187 { 188 if (dir == 'right') 66 189 { 67 scrollFeaturedPosts(this, 'left', index); 190 nextItem = currentItem.next(); 191 192 if (nextItem.length == 0) 193 { 194 nextItem = currentItem.siblings().first(); 195 } 68 196 } 69 clearInterval(autoscrollInterval[index]); 70 }); 71 }); 72 73 $j('.scrollFeaturedPostsRight-below').each(function(index) { 74 $j(this).click(function() { 75 if (fpg_animLocked[index] == false) 197 else if (dir == 'left') 76 198 { 77 scrollFeaturedPosts(this, 'right', index); 78 } 79 clearInterval(autoscrollInterval[index]); 80 }); 81 }); 82 83 $j('.scrollFeaturedPostsLeft-below').each(function(index) { 84 $j(this).click(function() { 85 if (fpg_animLocked[index] == false) 86 { 87 scrollFeaturedPosts(this, 'left', index); 88 } 89 clearInterval(autoscrollInterval[index]); 90 }); 91 }); 92 } 93 else 94 { 95 $j('.scrollFeaturedPostsRight').remove(); 96 $j('.scrollFeaturedPostsLeft').remove(); 97 $j('.featured-posts-wrapper ul').css('margin-left', '22px'); 98 } 99 } 100 101 function initSlideNumbers() 102 { 103 if (type != 'none') 104 { 105 $j('ul.fps-slideNumberList').each(function(index) { 106 $j(this).children('li').click(function() { 107 if (fpg_animLocked[index] == false) 108 { 109 scrollToPost(this, index); 110 } 111 clearInterval(autoscrollInterval[index]); 112 }); 113 }); 114 } 115 } 116 117 function initAutoscroll() 118 { 119 if (type != 'none') 120 { 121 $j('.featured-posts-wrapper').each(function(index) { 122 fpg_animLocked[index] = true; 123 if ($j(this).hasClass('fps-autoscroll')) 124 { 125 if ($j('.featured-posts-wrapper').slice(index,index+1).children('.scrollFeaturedPostsRight').length > 0) 126 { 127 var callback = 128 "scrollFeaturedPosts($j('.featured-posts-wrapper').slice(" + 129 index + "," + (index + 1) + ").children('.scrollFeaturedPostsRight'), 'right', " + index + ")"; 130 autoscrollInterval[index] = setInterval( 131 callback, <?php echo $post_scroll_interval ?>); 132 } 133 else 134 { 135 var callback = 136 "scrollFeaturedPosts($j('.featured-posts-wrapper').slice(" + 137 index + "," + (index + 1) + ").children('.scrollFeaturedPostsRight-below'), 'right', " + index + ")"; 138 autoscrollInterval[index] = setInterval( 139 callback, <?php echo $post_scroll_interval ?>); 199 nextItem = currentItem.prev(); 200 201 if (nextItem.length == 0) 202 { 203 nextItem = currentItem.siblings().last(); 204 } 140 205 } 141 206 } 142 }); 143 } 144 } 145 146 function scrollToPost(slideButton, index) 147 { 148 if (!($j(slideButton).hasClass('fps-selectedSlide'))) 149 { 150 // lock animations 151 fpg_animLocked[index] = true; 152 153 var currentItem = $j(slideButton).parent().siblings('ul.featured-posts').children('li:visible'); 154 155 // get the next item to display 156 var nextItemIndex = parseInt($j(slideButton).text()); 157 158 var nextItem = $j(slideButton).parent().siblings('ul.featured-posts').children('li').eq(nextItemIndex-1); 159 160 setSelectedSlide(nextItem); 161 animate(nextItem, currentItem, 'right', index) 162 } 163 } 164 165 function scrollFeaturedPosts(button, dir, index) 166 { 167 if (fpg_animLocked[index] != true) 168 { 169 // lock animations 170 fpg_animLocked[index] = true; 171 172 // get the currently displayed element(s) 173 var currentItem = $j(button).siblings('ul.featured-posts').children('li:visible'); 174 175 var nextItem; 176 177 if (type == 'single') 178 { 207 208 setSelectedSlide(nextItem); 209 animate(nextItem, currentItem, dir, index); 210 } 211 } 212 213 214 function setSelectedSlide(toShow) 215 { 216 // Remove class from current slide 217 $j(toShow).parent().siblings('ul.fps-slideNumberList').children('li.fps-selectedSlide').removeClass('fps-selectedSlide'); 218 219 // Get the index of the next item to be displayed 220 var nextSlideIndex = (($j(toShow).index())); 221 222 $j(toShow).parent().siblings('ul.fps-slideNumberList').children('li').eq(nextSlideIndex).addClass('fps-selectedSlide'); 223 } 224 225 226 function animate(toShow, toHide, dir, index) 227 { 228 var shownWidth = toHide.width(); 229 230 // fade out text on currently displayed item 231 $j(toHide).find('.fps-text').fadeOut(<?php echo $post_scroll_fadeOutSpeed ?>, function() { 232 // Make new item visible. 233 toShow.css('display',''); 234 235 // Position the elements to animate based on direction 179 236 if (dir == 'right') 180 237 { 181 nextItem = currentItem.next(); 182 183 if (nextItem.length == 0) 184 { 185 nextItem = currentItem.siblings().first(); 186 } 238 toShow.css({float:'right'}); 239 toShow.css({width:'0px'}); 240 toHide.css({float:'left'}); 187 241 } 188 else if (dir == 'left')242 else 189 243 { 190 nextItem = currentItem.prev(); 191 192 if (nextItem.length == 0) 193 { 194 nextItem = currentItem.siblings().last(); 195 } 244 toShow.css({float:'left'}); 245 toShow.css({width:'0px'}); 246 toHide.css({float:'right'}); 196 247 } 197 } 198 199 setSelectedSlide(nextItem); 200 animate(nextItem, currentItem, dir, index); 201 } 202 } 203 204 function setSelectedSlide(toShow) 205 { 206 // Remove class from current slide 207 $j(toShow).parent().siblings('ul.fps-slideNumberList').children('li.fps-selectedSlide').removeClass('fps-selectedSlide'); 208 209 // Get the index of the next item to be displayed 210 var nextSlideIndex = (($j(toShow).index())); 211 212 $j(toShow).parent().siblings('ul.fps-slideNumberList').children('li').eq(nextSlideIndex).addClass('fps-selectedSlide'); 213 } 214 215 function animate(toShow, toHide, dir, index) 216 { 217 var shownWidth = toHide.width(); 218 219 // fade out text on currently displayed item 220 $j(toHide).find('.fps-text').fadeOut(<?php echo $post_scroll_fadeOutSpeed ?>, function() { 221 // Make new item visible. 222 toShow.css('display',''); 223 224 // Position the elements to animate based on direction 225 if (dir == 'right') 226 { 227 toShow.css({float:'right'}); 228 toShow.css({width:'0px'}); 229 toHide.css({float:'left'}); 230 } 231 else 232 { 233 toShow.css({float:'left'}); 234 toShow.css({width:'0px'}); 235 toHide.css({float:'right'}); 236 } 237 238 toHide.animate({width:'0px'}, <?php echo $post_scroll_speed ?>, function() { 239 toHide.css('display','none'); 240 toHide.css('width',''); 241 toShow.css('float',''); 242 toHide.css('float',''); 243 $j(toShow).find('.fps-text').fadeIn(<?php echo $post_scroll_fadeInSpeed ?>, function() { 244 fpg_animLocked[index] = false; 245 }); 248 249 toHide.animate({width:'0px'}, <?php echo $post_scroll_speed ?>, function() { 250 toHide.css('display','none'); 251 toHide.css('width',''); 252 toShow.css('float',''); 253 toHide.css('float',''); 254 $j(toShow).find('.fps-text').fadeIn(<?php echo $post_scroll_fadeInSpeed ?>, function() { 255 fpg_animLocked[index] = false; 256 }); 257 }); 258 259 toShow.animate({width: shownWidth},<?php echo $post_scroll_speed ?>); 246 260 }); 247 248 toShow.animate({width: shownWidth},<?php echo $post_scroll_speed ?>); 249 }); 250 } 251 252 jQuery(document).ready(init); 261 } 262 263 }(jQuery)) 264 265 jQuery(document).ready(FeaturedPostsLib.fps.init); -
featured-posts-scroll/trunk/readme.txt
r429277 r470978 7 7 Requires at least: 2.9.1 8 8 Tested up to: 3.2 9 Stable tag: 1.2 09 Stable tag: 1.21 10 10 11 11 A basic javascript based scrolling display of post titles and thumbnails. … … 90 90 == Changelog == 91 91 92 = 1.21 = 93 * Refactored JavaScript to prevent causing issues with plugins that assume "$" references jQuery. 94 92 95 = 1.20 = 93 96 * Fixed slide numbers. … … 170 173 == Upgrade Notice == 171 174 172 = 1.2 0=173 * Fixed slide numbers.175 = 1.21 = 176 * Refactored JavaScript to prevent causing issues with plugins that assume "$" references jQuery.
Note: See TracChangeset
for help on using the changeset viewer.