Plugin Directory

Changeset 470968


Ignore:
Timestamp:
12/04/2011 09:11:39 PM (14 years ago)
Author:
Chaser324
Message:

Version 1.4 updates

Location:
featured-posts-grid/branches/dev
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • featured-posts-grid/branches/dev/featured-posts-grid.php

    r433035 r470968  
    44Plugin URI: http://chasepettit.com
    55Description: A javascript based display of post titles and thumbnails in a grid layout.
    6 Version: 1.3
     6Version: 1.4
    77Author: Chaser324
    88Author URI: http://chasepettit.com
  • featured-posts-grid/branches/dev/js/featuredpostsgrid.js.php

    r433018 r470968  
    99?>
    1010
    11 var animationLocked = false; // Lock object for animations
    12 var $j = jQuery.noConflict(); // Prevent jQuery conflicts
    13 
    14 /** Initialize jQuery based animations */
    15 function fpgInit()
    16 {
    17     // lock animations while initializing
    18     animationLocked = true;
    19 
    20     // hide all pages on first entry in featured posts list
    21     $j('.fpg-wrapper').each(function() {
    22        $j(this).children('.fpg-page').slice(1).find('.fpg-item').css(
    23            {'margin-top':'3px','opacity':0.0});
    24     });
    25 
    26     // initialize the scroll buttons and autoscroll
    27     fpgInitScrollButtons();
    28     fpgInitPips();
    29 
    30     animationLocked = false;
    31 }
    32 
    33 
    34 
    35 /** Add click event handlers to scroll buttons */
    36 function fpgInitScrollButtons()
    37 {
    38     $j('.fpg-arrow-right').each(function(index) {
    39         $j(this).click(function() {
    40             if (animationLocked == false)
    41             {
    42                 fpgScrollPages(this, 'right');
    43             }
    44         });
    45     });
    46 
    47     $j('.fpg-arrow-left').each(function(index) {
    48         $j(this).click(function() {
    49             if (animationLocked == false)
    50             {
    51                 fpgScrollPages(this, 'left');
    52             }
    53         });
    54     });
    55 }
    56 
    57 
    58 
    59 function fpgInitPips()
    60 {
    61     $j('.fpg-arrow-wrapper').each(function(index) {
    62         $j(this).children('.fpg-arrow-pip').click(function() {
    63             if (animationLocked == false)
    64             {
    65                 fpgScrollToPage(this);
    66             }
    67         });
    68     });
    69 }
    70 
    71 
    72 
    73 function fpgScrollToPage(slideButton)
    74 {
    75     if (!($j(slideButton).hasClass('fpg-selected-pip')))
    76     {
    77         // lock animations
     11var FeaturedPostsLib = this.FeaturedPostsLib || {};
     12FeaturedPostsLib.fpg = FeaturedPostsLib.fpg || {};
     13
     14(function($j) {
     15    var animationLocked = false; // Lock object for animations
     16
     17    /** Initialize jQuery based animations */
     18    FeaturedPostsLib.fpg.init = function()
     19    {
     20        // lock animations while initializing
    7821        animationLocked = true;
    7922
    80         // get the currently displayed element(s)
    81         var currentItem = $j(slideButton).parent().siblings('.fpg-page:visible');
    82 
    83         // get the next item to display
    84         var nextItemIndex = parseInt($j(slideButton).text());
     23        // hide all pages on first entry in featured posts list
     24        $j('.fpg-wrapper').each(function() {
     25           $j(this).children('.fpg-page').slice(1).find('.fpg-item').css(
     26               {'margin-top':'3px','opacity':0.0});
     27        });
     28
     29        // initialize the scroll buttons and autoscroll
     30        initScrollButtons();
     31        initPips();
     32
     33        animationLocked = false;
     34    };
     35
     36
     37    /** Add click event handlers to scroll buttons */
     38    function initScrollButtons()
     39    {
     40        $j('.fpg-arrow-right').each(function(index) {
     41            $j(this).click(function() {
     42                if (animationLocked == false)
     43                {
     44                    fpgScrollPages(this, 'right');
     45                }
     46            });
     47        });
     48
     49        $j('.fpg-arrow-left').each(function(index) {
     50            $j(this).click(function() {
     51                if (animationLocked == false)
     52                {
     53                    fpgScrollPages(this, 'left');
     54                }
     55            });
     56        });
     57    }
     58
     59
     60    function initPips()
     61    {
     62        $j('.fpg-arrow-wrapper').each(function(index) {
     63            $j(this).children('.fpg-arrow-pip').click(function() {
     64                if (animationLocked == false)
     65                {
     66                    fpgScrollToPage(this);
     67                }
     68            });
     69        });
     70    }
     71
     72
     73    function fpgScrollToPage(slideButton)
     74    {
     75        if (!($j(slideButton).hasClass('fpg-selected-pip')))
     76        {
     77            // lock animations
     78            animationLocked = true;
     79
     80            // get the currently displayed element(s)
     81            var currentItem = $j(slideButton).parent().siblings('.fpg-page:visible');
     82
     83            // get the next item to display
     84            var nextItemIndex = parseInt($j(slideButton).text());
     85           
     86            var nextItem = $j(slideButton).parent().siblings('.fpg-page').eq(nextItemIndex-1);
     87
     88            fpgSetSelectedPip(nextItem);
     89            fpgAnimate(nextItem, currentItem, 'right');
     90        }
     91    }
     92
     93
     94    function fpgScrollPages(button, dir)
     95    {
     96        if (animationLocked != true)
     97        {
     98            // lock animations
     99            animationLocked = true;
     100
     101            // get the currently displayed element(s)
     102            var currentItem = $j(button).parent().siblings('.fpg-page:visible');
     103
     104            var nextItem;
     105         
     106            if (dir == 'right')
     107            {
     108                nextItem = currentItem.next('.fpg-page');
     109            }
     110            else if (dir == 'left')
     111            {
     112                nextItem = currentItem.prev('.fpg-page');
     113            }
     114
     115            if (nextItem.length > 0)
     116            {
     117                fpgSetSelectedPip(nextItem);
     118                fpgAnimate(nextItem, currentItem, dir);
     119            }
     120            else
     121            {
     122                animationLocked = false;
     123            }
     124        }
     125    }
     126
     127
     128    function fpgSetSelectedPip(toShow)
     129    {
     130        // Remove class from current slide
     131        $j(toShow).siblings('.fpg-arrow-wrapper').children('.fpg-selected-pip').removeClass('fpg-selected-pip');
     132
     133        // Get the index of the next item to be displayed
     134        var nextSlideIndex = $j(toShow).index();
     135
     136        $j(toShow).siblings('.fpg-arrow-wrapper').children('.fpg-arrow-pip').eq(nextSlideIndex).addClass('fpg-selected-pip');
     137    }
     138
     139
     140    function fpgAnimate(toShow, toHide, dir)
     141    {
     142        // fade out items on currently shown page
     143        var itemToHide;
     144        if (dir == 'right')
     145        {
     146            itemToHide = $j(toHide).children().children('.fpg-item.fpg-first-col');
     147        }
     148        else
     149        {
     150            itemToHide = $j(toHide).children().children('.fpg-item').last();
     151        }
    85152       
    86         var nextItem = $j(slideButton).parent().siblings('.fpg-page').eq(nextItemIndex-1);
    87 
    88         fpgSetSelectedPip(nextItem);
    89         fpgAnimate(nextItem, currentItem, 'right');
    90     }
    91 }
    92 
    93 
    94 
    95 function fpgScrollPages(button, dir)
    96 {
    97     if (animationLocked != true)
    98     {
    99         // lock animations
    100         animationLocked = true;
    101 
    102         // get the currently displayed element(s)
    103         var currentItem = $j(button).parent().siblings('.fpg-page:visible');
    104 
    105         var nextItem;
    106      
    107         if (dir == 'right')
    108         {
    109             nextItem = currentItem.next('.fpg-page');
    110         }
    111         else if (dir == 'left')
    112         {
    113             nextItem = currentItem.prev('.fpg-page');
    114         }
    115 
    116         if (nextItem.length > 0)
    117         {
    118             fpgSetSelectedPip(nextItem);
    119             fpgAnimate(nextItem, currentItem, dir);
    120         }
    121         else
    122         {
    123             animationLocked = false;
    124         }
    125     }
    126 }
    127 
    128 
    129 
    130 function fpgSetSelectedPip(toShow)
    131 {
    132     // Remove class from current slide
    133     $j(toShow).siblings('.fpg-arrow-wrapper').children('.fpg-selected-pip').removeClass('fpg-selected-pip');
    134 
    135     // Get the index of the next item to be displayed
    136     var nextSlideIndex = $j(toShow).index();
    137 
    138     $j(toShow).siblings('.fpg-arrow-wrapper').children('.fpg-arrow-pip').eq(nextSlideIndex).addClass('fpg-selected-pip');
    139 }
    140 
    141 
    142 
    143 function fpgAnimate(toShow, toHide, dir)
    144 {
    145     // fade out items on currently shown page
    146     var itemToHide;
    147     if (dir == 'right')
    148     {
    149         itemToHide = $j(toHide).children().children('.fpg-item.fpg-first-col');
    150     }
    151     else
    152     {
    153         itemToHide = $j(toHide).children().children('.fpg-item').last();
     153
     154        fpgFadeOutItems(itemToHide, dir, function() {
     155            toHide.css('display','none');
     156            toShow.css('display','');
     157
     158            var itemToShow;
     159            if (dir == 'right')
     160            {
     161                itemToShow = $j(toShow).children().children('.fpg-item.fpg-first-col');
     162            }
     163            else
     164            {
     165                itemToShow = $j(toShow).children().children('.fpg-item.fpg-last-col');
     166            }
     167
     168            fpgFadeInItems(itemToShow, dir, function() {
     169                animationLocked = false;
     170            });
     171        });
     172    }
     173
     174
     175    function fpgFadeOutItems(itemToHide, dir, callback)
     176    {
     177        var itemCount = itemToHide.length;
     178        $j(itemToHide).animate({ 'opacity': 0.0,
     179                                 'margin-top': '3' },
     180            <?php echo $fpg_page_speed; ?>, 'linear', function() {
     181                if (--itemCount <= 0)
     182                {
     183                    var nextItem;
     184                    if (dir == 'right')
     185                    {
     186                        nextItem = $j(itemToHide).next('.fpg-item');
     187                    }
     188                    else
     189                    {
     190                        nextItem = $j(itemToHide).prev('.fpg-item');
     191                    }
     192
     193                    if (nextItem.length > 0)
     194                        fpgFadeOutItems(nextItem, dir, callback);
     195                    else
     196                        callback();
     197                }
     198            }
     199        );
     200    }
     201
     202
     203    function fpgFadeInItems(itemToShow, dir, callback)
     204    {
     205        var itemCount = itemToShow.length;
     206        $j(itemToShow).animate({ 'opacity': 1.0,
     207                                 'margin-top': '0' },
     208            <?php echo $fpg_page_speed; ?>, 'linear', function() {
     209                if (--itemCount <= 0)
     210                {
     211                    var nextItem;
     212                    if (dir == 'right')
     213                    {
     214                        nextItem = $j(itemToShow).next('.fpg-item');
     215                    }
     216                    else
     217                    {
     218                        nextItem = $j(itemToShow).prev('.fpg-item');
     219                    }
     220
     221                    if (nextItem.length >0 )
     222                        fpgFadeInItems(nextItem, dir, callback);
     223                    else
     224                        callback();
     225                }
     226            }
     227        );
    154228    }
    155229   
    156 
    157     fpgFadeOutItems(itemToHide, dir, function() {
    158         toHide.css('display','none');
    159         toShow.css('display','');
    160 
    161         var itemToShow;
    162         if (dir == 'right')
    163         {
    164             itemToShow = $j(toShow).children().children('.fpg-item.fpg-first-col');
    165         }
    166         else
    167         {
    168             itemToShow = $j(toShow).children().children('.fpg-item.fpg-last-col');
    169         }
    170 
    171         fpgFadeInItems(itemToShow, dir, function() {
    172             animationLocked = false;
    173         });
    174     });
    175 
    176    
    177 
    178    
    179 
    180    
    181 }
    182 
    183 function fpgFadeOutItems(itemToHide, dir, callback)
    184 {
    185     var itemCount = itemToHide.length;
    186     $j(itemToHide).animate({ 'opacity': 0.0,
    187                              'margin-top': '3' },
    188         <?php echo $fpg_page_speed; ?>, 'linear', function() {
    189             if (--itemCount <= 0)
    190             {
    191                 var nextItem;
    192                 if (dir == 'right')
    193                 {
    194                     nextItem = $j(itemToHide).next('.fpg-item');
    195                 }
    196                 else
    197                 {
    198                     nextItem = $j(itemToHide).prev('.fpg-item');
    199                 }
    200 
    201                 if (nextItem.length > 0)
    202                     fpgFadeOutItems(nextItem, dir, callback);
    203                 else
    204                     callback();
    205             }
    206         }
    207     );
    208 }
    209 
    210 function fpgFadeInItems(itemToShow, dir, callback)
    211 {
    212     var itemCount = itemToShow.length;
    213     $j(itemToShow).animate({ 'opacity': 1.0,
    214                              'margin-top': '0' },
    215         <?php echo $fpg_page_speed; ?>, 'linear', function() {
    216             if (--itemCount <= 0)
    217             {
    218                 var nextItem;
    219                 if (dir == 'right')
    220                 {
    221                     nextItem = $j(itemToShow).next('.fpg-item');
    222                 }
    223                 else
    224                 {
    225                     nextItem = $j(itemToShow).prev('.fpg-item');
    226                 }
    227 
    228                 if (nextItem.length >0 )
    229                     fpgFadeInItems(nextItem, dir, callback);
    230                 else
    231                     callback();
    232             }
    233         }
    234     );
    235 }
    236 
    237 jQuery(document).ready(fpgInit);
     230}(jQuery))
     231
     232jQuery(document).ready(FeaturedPostsLib.fpg.init);
  • featured-posts-grid/branches/dev/readme.txt

    r433038 r470968  
    77Requires at least: 2.9.1
    88Tested up to: 3.2
    9 Stable tag: 1.3
     9Stable tag: 1.4
    1010
    1111A javascript based display of post titles and thumbnails in a grid layout.
     
    8888== Changelog ==
    8989
     90= 1.4 =
     91* Refactored JavaScript to prevent causing issues with plugins that assume "$" references jQuery.
     92
    9093= 1.3 =
    9194* Fixed issue where only last row appeared when scrolling left.
     
    105108== Upgrade Notice ==
    106109
    107 = 1.3 =
    108 * Fixed issue where only last row appeared when scrolling left.
    109 * Added option to display post author and date
    110 * Removed max_width from some fields on admin page.
     110= 1.4 =
     111* Refactored JavaScript to prevent causing issues with plugins that assume "$" references jQuery.
Note: See TracChangeset for help on using the changeset viewer.