This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Spun reorder-custom-circles.js

By: a guest on Jan 11th, 2014  |  syntax: JavaScript  |  size: 0.82 KB  |  views: 51  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. $ = jQuery;
  2.  
  3. $(document).ready(function(){
  4.  
  5.     reorderCustomCircles();
  6.    
  7. });
  8.  
  9. /* Re-order the Custom Circles
  10.  * Based on the element to have an attribute of "data-order"
  11.  */
  12. function reorderCustomCircles() {
  13.  
  14.     var circles = $('.hentry'),
  15.         orderAttr = 'data-order';
  16.  
  17.     circles.each(function(){
  18.         $this = $(this);
  19.  
  20.         // If the circle has been set an order
  21.         if ( typeof $this.attr(orderAttr) !== 'undefined' && $this.attr(orderAttr) !== false) {
  22.  
  23.             var order = $this.attr(orderAttr),
  24.                 // Should only need to check nth-child for the order
  25.                 target = $this.siblings(':nth-child(' + order + ')');
  26.            
  27.             // Move the circle that has an order to that order
  28.             $this.insertAfter(target);
  29.         }
  30.  
  31.     });
  32.    
  33. }
clone this paste RAW Paste Data