1. Matthew J Little
  2. RhodeCode

Commits

Marcin Kuzminski  committed 8371458

added quick filter into repo switcher list

  • Participants
  • Parent commits 238bea9
  • Branches beta

Comments (0)

Files changed (3)

File rhodecode/public/css/style.css

View file
 overflow-x:hidden;
 overflow-y:auto;
 }
+#header #header-inner #quick ul.repo_switcher li.qfilter_rs {
+float:none;
+margin:0;
+border-bottom:2px solid #003367;
+}
+
 
 #header #header-inner #quick .repo_switcher_type{
 position:absolute;

File rhodecode/templates/base/base.html

View file
 					</ul>
 					<script type="text/javascript">
 					   YUE.on('repo_switcher','mouseover',function(){
+						      function qfilter(){
+						         var S = YAHOO.util.Selector;
+						         
+						         var q_filter = YUD.get('q_filter_rs');
+						         var F = YAHOO.namespace('q_filter_rs'); 
+						         
+						         YUE.on(q_filter,'click',function(){
+						            q_filter.value = '';
+						         });
+						    
+						         F.filterTimeout = null;
+						         
+						         F.updateFilter  = function() { 
+						            // Reset timeout 
+						            F.filterTimeout = null;
+						            
+						            var obsolete = [];
+						            var nodes = S.query('ul#repo_switcher_list li a.repo_name');
+						            var req = YUD.get('q_filter_rs').value;
+						            for (n in nodes){
+						                YUD.setStyle(nodes[n].parentNode,'display','')
+						            }
+						            if (req){
+						                for (n in nodes){
+						                    console.log(n);
+						                    if (nodes[n].innerHTML.toLowerCase().indexOf(req) == -1) {
+						                        obsolete.push(nodes[n]); 
+						                    }
+						                }
+						                if(obsolete){
+						                    for (n in obsolete){
+						                        YUD.setStyle(obsolete[n].parentNode,'display','none');
+						                    }
+						                }
+						            }
+						         }
+						         
+						         YUE.on(q_filter,'keyup',function(e){
+						             clearTimeout(F.filterTimeout); 
+						             setTimeout(F.updateFilter,600); 
+						         });
+						}
 						   var loaded = YUD.hasClass('repo_switcher','loaded');
 						   if(!loaded){
 							   YUD.addClass('repo_switcher','loaded');
 							   YAHOO.util.Connect.asyncRequest('GET',"${h.url('repo_switcher')}",{
 								   success:function(o){
 								      YUD.get('repo_switcher_list').innerHTML = o.responseText;
+								      qfilter();
 								   },
 								   failure:function(o){
 									   YUD.removeClass('repo_switcher','loaded');   

File rhodecode/templates/repo_switcher_list.html

View file
-## -*- coding: utf-8 -*-    
+## -*- coding: utf-8 -*-
+
+<li class="qfilter_rs">
+<input type="text" 
+style="border:0"        
+value="quick filter..." 
+name="filter" size="15" id="q_filter_rs" />
+</li>
+    
 %for repo in c.repos_list:
      
       %if repo['dbrepo']['private']:
          <li>
              <img src="${h.url("/images/icons/lock.png")}" alt="${_('Private repository')}" class="repo_switcher_type"/>
-             ${h.link_to(repo['name'],h.url('summary_home',repo_name=repo['name']),class_="%s" % repo['dbrepo']['repo_type'])}
+             ${h.link_to(repo['name'],h.url('summary_home',repo_name=repo['name']),class_="repo_name %s" % repo['dbrepo']['repo_type'])}
           </li>
       %else:
          <li>
              <img src="${h.url("/images/icons/lock_open.png")}" alt="${_('Public repository')}" class="repo_switcher_type" />
-             ${h.link_to(repo['name'],h.url('summary_home',repo_name=repo['name']),class_="%s" % repo['dbrepo']['repo_type'])}
+             ${h.link_to(repo['name'],h.url('summary_home',repo_name=repo['name']),class_="repo_name %s" % repo['dbrepo']['repo_type'])}
          </li>
       %endif  
 %endfor