Dotclear


Ignore:
Timestamp:
11/10/11 16:12:01 (14 years ago)
Author:
Dsls <dsls@…>
Branch:
formfilters
Message:
  • Adapted comments.php do new filters
  • added author filter, with autocompletion
  • added comment_author parameter to dcBlog::getComments
  • removed jquery.autocomplete
  • added jquery UI (should be refined, this is quite raw...)
  • added dcPager::jqueryUI
  • adapted tags plugin to new jquery ui autocomplete
Location:
plugins/tags
Files:
1 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • plugins/tags/_admin.php

    r217 r756  
    108108           
    109109          return  
    110           '<script type="text/javascript" src="index.php?pf=tags/js/jquery.autocomplete.min.js"></script>'. 
     110          dcPage::jqueryUI(). 
    111111          '<script type="text/javascript" src="index.php?pf=tags/js/post.js"></script>'. 
    112112          '<script type="text/javascript">'."\n". 
     
    137137           
    138138          return  
    139           '<script type="text/javascript" src="index.php?pf=tags/js/jquery.autocomplete.min.js"></script>'. 
    140           '<script type="text/javascript" src="index.php?pf=tags/js/posts_actions.js"></script>'. 
    141139          '<script type="text/javascript">'."\n". 
    142140          "//<![CDATA[\n". 
     
    153151          "\n//]]>\n". 
    154152          "</script>\n". 
     153          '<script type="text/javascript" src="index.php?pf=tags/js/posts_actions.js"></script>'. 
     154          dcPage::jqueryUI(). 
    155155          '<link rel="stylesheet" type="text/css" href="index.php?pf=tags/style.css" />'; 
    156156     } 
  • plugins/tags/js/post.js

    r0 r756  
    11$(function() { 
     2     function split( val ) { 
     3          return val.split( /,\s*/ ); 
     4     } 
     5     function extractLast(term) { 
     6          return split(term).pop(); 
     7     } 
    28     $('#edit-entry').onetabload(function() { 
    39          var tags_edit = $('#tags-edit'); 
     
    1824          } 
    1925           
    20           $('#post_meta_input').autocomplete(mEdit.service_uri, { 
    21                extraParams: { 
    22                     'f': 'searchMeta', 
    23                     'metaType': 'tag' 
    24                }, 
    25                delay: 1000, 
    26                multiple: true, 
    27                matchSubset: false, 
    28                matchContains: true, 
    29                parse: function(xml) {  
    30                     var results = []; 
    31                     $(xml).find('meta').each(function(){ 
    32                          results[results.length] = { 
    33                               data: { 
    34                                    "id": $(this).text(), 
    35                                    "count": $(this).attr("count"), 
    36                                    "percent":  $(this).attr("roundpercent") 
    37                               }, 
    38                               result: $(this).text() 
    39                          };  
    40                     }); 
    41                     return results; 
    42                }, 
    43                formatItem: function(tag) { 
    44                     return tag.id + ' <em>(' + 
    45                     dotclear.msg.tags_autocomplete. 
    46                          replace('%p',tag.percent). 
    47                          replace('%e',tag.count + ' ' + 
    48                               (tag.count > 1 ? 
    49                               dotclear.msg.entries : 
    50                               dotclear.msg.entry) 
    51                          ) + 
    52                     ')</em>'; 
    53                }, 
    54                formatResult: function(tag) {  
    55                     return tag.result;  
     26          $('#post_meta_input') 
     27               .bind( "keydown", function( event ) { 
     28          if ( event.keyCode === $.ui.keyCode.TAB && 
     29                    $( this ).data( "autocomplete" ).menu.active ) { 
     30               event.preventDefault(); 
     31          } 
     32     }) 
     33     .autocomplete({ 
     34          minLength: 2, 
     35          delay: 1000, 
     36          source: function(request,response) { 
     37               $.ajax({ 
     38                    url: mEdit.service_uri, 
     39                    data: { 
     40                         'f': 'searchMeta', 
     41                         'metaType': 'tag', 
     42                         'q': extractLast(request.term) 
     43                    }, 
     44                    success:function(data) { 
     45                         results = []; 
     46                         $(data).find('meta').each(function(){ 
     47                              var id = $(this).text(); 
     48                              var roundpercent = $(this).attr("roundpercent"); 
     49                              var count = $(this).attr("count"); 
     50                              console.log(id); 
     51                              console.log(roundpercent); 
     52                              console.log(count); 
     53                              var label = id + ' (' + 
     54                                   dotclear.msg.tags_autocomplete. 
     55                                        replace('%p',roundpercent). 
     56                                        replace('%e',count + ' ' + 
     57                                        ((count > 1) ? 
     58                                             dotclear.msg.entries : 
     59                                             dotclear.msg.entry 
     60                                        )) + ')'; 
     61                                   console.log(label); 
     62                              results.push({label:label,value:id}); 
     63                         }); 
     64                         response(results); 
     65                    } 
     66               }); 
     67          }, 
     68          search: function() { 
     69               var term = extractLast( this.value ); 
     70               if ( term.length < 2 ) { 
     71                    return false; 
    5672               } 
    57           }); 
     73          }, 
     74          focus: function() { 
     75               // prevent value inserted on focus 
     76               return false; 
     77          }, 
     78          select: function( event, ui ) { 
     79               var terms = split( this.value ); 
     80               // remove the current input 
     81               terms.pop(); 
     82               // add the selected item 
     83               terms.push( ui.item.value ); 
     84               // add placeholder to get the comma-and-space at the end 
     85               terms.push( "" ); 
     86               this.value = terms.join( ", " ); 
     87               return false; 
     88          }          
     89     }); 
     90 
    5891     }); 
    5992}); 
  • plugins/tags/js/posts_actions.js

    r0 r756  
    11$(function() { 
     2     function split( val ) { 
     3          return val.split( /,\s*/ ); 
     4     } 
     5     function extractLast(term) { 
     6          return split(term).pop(); 
     7     } 
    28     var tag_field = $('#new_tags'); 
    39      
     
    1925     }); 
    2026      
    21      $('#post_meta_input').autocomplete(mEdit.service_uri, { 
    22           extraParams: { 
    23                'f': 'searchMeta', 
    24                'metaType': 'tag' 
     27     $('#post_meta_input') 
     28     .bind( "keydown", function( event ) { 
     29          if ( event.keyCode === $.ui.keyCode.TAB && 
     30                    $( this ).data( "autocomplete" ).menu.active ) { 
     31               event.preventDefault(); 
     32          } 
     33     }) 
     34     .autocomplete({ 
     35          minLength: 2, 
     36          delay: 1000, 
     37          source: function(request,response) { 
     38               $.ajax({ 
     39                    url: mEdit.service_uri, 
     40                    data: { 
     41                         'f': 'searchMeta', 
     42                         'metaType': 'tag', 
     43                         'q': extractLast(request.term) 
     44                    }, 
     45                    success:function(data) { 
     46                         results = []; 
     47                         $(data).find('meta').each(function(){ 
     48                              var id = $(this).text(); 
     49                              var roundpercent = $(this).attr("roundpercent"); 
     50                              var count = $(this).attr("count"); 
     51                              console.log(id); 
     52                              console.log(roundpercent); 
     53                              console.log(count); 
     54                              var label = id + ' (' + 
     55                                   dotclear.msg.tags_autocomplete. 
     56                                        replace('%p',roundpercent). 
     57                                        replace('%e',count + ' ' + 
     58                                        ((count > 1) ? 
     59                                             dotclear.msg.entries : 
     60                                             dotclear.msg.entry 
     61                                        )) + ')'; 
     62                                   console.log(label); 
     63                              results.push({label:label,value:id}); 
     64                         }); 
     65                         response(results); 
     66                    } 
     67               }); 
    2568          }, 
    26           delay: 1000, 
    27           multiple: true, 
    28           matchSubset: false, 
    29           matchContains: true, 
    30           parse: function(xml) {  
    31                var results = []; 
    32                $(xml).find('meta').each(function(){ 
    33                     results[results.length] = { 
    34                          data: { 
    35                               "id": $(this).text(), 
    36                               "count": $(this).attr("count"), 
    37                               "percent":  $(this).attr("roundpercent") 
    38                          }, 
    39                          result: $(this).text() 
    40                     };  
    41                }); 
    42                return results; 
     69          search: function() { 
     70               var term = extractLast( this.value ); 
     71               if ( term.length < 2 ) { 
     72                    return false; 
     73               } 
    4374          }, 
    44           formatItem: function(tag) { 
    45                return tag.id + ' <em>(' + 
    46                dotclear.msg.tags_autocomplete. 
    47                     replace('%p',tag.percent). 
    48                     replace('%e',tag.count + ' ' + 
    49                          (tag.count > 1 ? 
    50                          dotclear.msg.entries : 
    51                          dotclear.msg.entry) 
    52                     ) + 
    53                ')</em>'; 
     75          focus: function() { 
     76               // prevent value inserted on focus 
     77               return false; 
    5478          }, 
    55           formatResult: function(tag) {  
    56                return tag.result;  
    57           } 
     79          select: function( event, ui ) { 
     80               var terms = split( this.value ); 
     81               // remove the current input 
     82               terms.pop(); 
     83               // add the selected item 
     84               terms.push( ui.item.value ); 
     85               // add placeholder to get the comma-and-space at the end 
     86               terms.push( "" ); 
     87               this.value = terms.join( ", " ); 
     88               return false; 
     89          }          
    5890     }); 
    5991}); 
Note: See TracChangeset for help on using the changeset viewer.

Sites map