Changeset 656
- Timestamp:
- 2008-06-29 23:06:21 (2 months ago)
- Location:
- plugins/magic_archives/trunk
- Files:
-
- 4 modified
-
archives.php (modified) (1 diff)
-
magic_archives.plugin.php (modified) (1 diff)
-
magicarchives.css (modified) (2 diffs)
-
magicarchives.js (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
plugins/magic_archives/trunk/archives.php
r653 r656 65 65 <span class="tags section"><?php echo _t('Tags'); ?></span> 66 66 </div></li> 67 <?php foreach( $magic_archivesas $post) { ?>67 <?php foreach(MagicArchives::get_magic_archives() as $post) { ?> 68 68 <li id="post-<?php echo $post->id; ?>" class="<?php echo Post::type_name($post->content_type); ?> <?php echo Post::status_name($post->status); ?>"> 69 69 <a href="<?php echo $post->permalink; ?>" title="<?php echo sprintf( _t('Read %s'), $post->title ); ?>"> -
plugins/magic_archives/trunk/magic_archives.plugin.php
r653 r656 21 21 } 22 22 23 public function action_add_template_vars($theme, $handler_vars) {24 $ archives = Posts::get(array('nolimit' => true));23 public function get_magic_archives() { 24 $cache = 'magicarchives__posts'; 25 25 26 $theme->magic_archives = $archives; 26 if(Cache::has($cache)) { 27 $archives = Cache::get($cache); 28 29 } else { 30 $archives = Posts::get(array('nolimit' => true)); 31 Cache::set( $cache, $archives, 4000); 32 33 } 34 35 return $archives; 27 36 } 28 37 -
plugins/magic_archives/trunk/magicarchives.css
r652 r656 66 66 } 67 67 ol#archiveItems li span.comments { 68 margin-left:5px;69 width:15px;68 width:5%; 69 text-align:center; 70 70 } 71 71 ol#archiveItems li span.comments strong { … … 84 84 display:none; 85 85 } 86 ol#archiveItems li span.tags { 87 width:30%; 88 } 86 89 ol#archiveItems li.headings { 87 90 background:#DEDCDE; -
plugins/magic_archives/trunk/magicarchives.js
r653 r656 20 20 21 21 magicArchives.search.keyup(function() { 22 magicArchives. filter();22 magicArchives.doSearch(); 23 23 }); 24 25 magicArchives.posts.addClass('unfiltered'); 24 26 25 27 magicArchives.createFilters(); … … 54 56 }); 55 57 }, 58 doSearch: function() { 59 var scores = []; 60 61 62 magicArchives.posts.filter('.unfiltered').each(function() { 63 64 $(this).show(); 65 66 var score = 0; 67 68 score = $(this).text().toLowerCase().score( magicArchives.search.val() ); 69 70 if(score == 0) { 71 $(this).hide(); 72 } 73 74 scores.push([score, $(this)]); 75 76 }); 77 78 magicArchives.posts.remove(); 79 80 scores = scores.sort(function(a, b) { 81 return b[0] - a[0]; 82 }); 83 84 $(scores).each(function() { 85 if($(this[1]).is(':visible')) { 86 console.log(this); 87 } 88 $(this[1]).appendTo($('#archiveItems')); 89 }); 90 91 }, 56 92 filter: function() { 57 93 var month = $('.active', magicArchives.month); … … 60 96 var tag = $('.active', magicArchives.tag); 61 97 62 magicArchives.posts.show() ;98 magicArchives.posts.show().addClass('unfiltered'); 63 99 64 100 var i = 0; … … 67 103 if(month.hasClass('allofthestuff') == false) { 68 104 if(month.text() != $('.month', $(this)).text()) { 69 $(this).hide() ;105 $(this).hide().removeClass('unfiltered'); 70 106 } 71 107 } 72 108 if(year.hasClass('allofthestuff') == false) { 73 109 if(year.text() != $('.year', $(this)).text()) { 74 $(this).hide() ;110 $(this).hide().removeClass('unfiltered'); 75 111 } 76 112 } 77 113 if(type.hasClass('allofthestuff') == false) { 78 114 if(type.text() != $('.type', $(this)).text()) { 79 $(this).hide() ;115 $(this).hide().removeClass('unfiltered'); 80 116 } 81 117 } … … 91 127 92 128 if(hide) { 93 $(this).hide() ;129 $(this).hide().removeClass('visible'); 94 130 } 95 131 } 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 } 132 110 133 }); 111 134 112 135 magicArchives.doSearch(); 136 113 137 } 114 138 };
