Changeset 653

Show
Ignore:
Timestamp:
2008-06-29 04:06:58 (2 months ago)
Author:
arthus
Message:

Brought in basic Quicksilver-esque livesearch (needs improvement)

Location:
plugins/magic_archives/trunk
Files:
1 added
3 modified

Legend:

Unmodified
Added
Removed
  • plugins/magic_archives/trunk/archives.php

    r652 r653  
    11<div id="magicArchives"> 
    22    <div id="archiveControls"> 
     3        <div class="search"> 
     4            <input type="text" name="archiveSearch" value="" id="archiveSearch"> 
     5        </div> 
    36        <div class="control month"> 
    47            <h4><?php echo _t('Month'); ?></h4> 
  • plugins/magic_archives/trunk/magic_archives.plugin.php

    r652 r653  
    3131 
    3232        Stack::add( 'template_header_javascript', Site::get_url('scripts') . '/jquery.js', 'jquery' ); 
     33        Stack::add( 'template_header_javascript', URL::get_from_filesystem(__FILE__) . '/stringranker.js', 'stringranker' ); 
    3334        Stack::add( 'template_header_javascript', URL::get_from_filesystem(__FILE__) . '/magicarchives.js', 'magicarchives' ); 
    3435    } 
  • plugins/magic_archives/trunk/magicarchives.js

    r652 r653  
    1313        magicArchives.content_type = $('#archiveControls .type ol', magicArchives.archives); 
    1414        magicArchives.posts = $('ol#archiveItems li:not(.headings)', magicArchives.archives); 
     15        magicArchives.search = $('#archiveSearch', magicArchives.archives); 
    1516         
    1617        magicArchives.posts.each(function() { 
    1718            $(this).addClass('searched').addClass('filtered'); 
     19        }); 
     20         
     21        magicArchives.search.keyup(function() { 
     22            magicArchives.filter(); 
    1823        }); 
    1924         
     
    5762        magicArchives.posts.show(); 
    5863         
     64        var i = 0; 
     65         
    5966        magicArchives.posts.each(function() { 
    6067            if(month.hasClass('allofthestuff') == false) { 
     
    8794                } 
    8895            } 
     96             
     97            var score = 0; 
     98             
     99            $('.tags .tag', $(this)).each(function() { 
     100                score = score + $(this).text().score(magicArchives.search.val()); 
     101            }); 
     102             
     103            score = score + $('.month', $(this)).text().toLowerCase().score(magicArchives.search.val()); 
     104            score = score + $('.title', $(this)).text().toLowerCase().score(magicArchives.search.val()); 
     105            score = score + $('.year', $(this)).text().toLowerCase().score(magicArchives.search.val()); 
     106                         
     107            if(score == 0) { 
     108                $(this).hide(); 
     109            } 
    89110        }); 
     111         
     112         
    90113    } 
    91114};