Mercurial > kallithea
changeset 4709:26c3e4708f58
javascripts: pass jQuery object to q_filter
author | Takumi IINO <trot.thunder@gmail.com> |
---|---|
date | Sat, 29 Nov 2014 16:25:13 +0900 |
parents | 4ead043c3349 |
children | e4721f7ba042 |
files | kallithea/public/js/base.js kallithea/templates/bookmarks/bookmarks.html kallithea/templates/branches/branches.html kallithea/templates/tags/tags.html |
diffstat | 4 files changed, 14 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/kallithea/public/js/base.js Sat Nov 29 16:04:48 2014 +0900 +++ b/kallithea/public/js/base.js Sat Nov 29 16:25:13 2014 +0900 @@ -559,19 +559,19 @@ * @param display_element function that takes current node from nodes and * does hide or show based on the node */ -var q_filter = function(target, nodes, display_element){ - var nodes = nodes; +var q_filter = function(target, $nodes, display_element) { + var $nodes = $nodes; var $q_filter_field = $('#' + target); var F = YAHOO.namespace(target); - $q_filter_field.keyup(function(e){ + $q_filter_field.keyup(function (e) { clearTimeout(F.filterTimeout); F.filterTimeout = setTimeout(F.updateFilter, 600); }); F.filterTimeout = null; - F.updateFilter = function() { + F.updateFilter = function () { // Reset timeout F.filterTimeout = null; @@ -579,23 +579,21 @@ var req = $q_filter_field.val().toLowerCase(); - var l = nodes.length; - var i; var showing = 0; - - for (i=0; i<l; i++ ){ - var n = nodes[i]; - var target_element = display_element(n) - if(req && n.innerHTML.toLowerCase().indexOf(req) == -1){ + $nodes.each(function () { + var n = this; + var target_element = display_element(n); + if (req && n.innerHTML.toLowerCase().indexOf(req) == -1) { $(target_element).hide(); } else{ $(target_element).show(); showing += 1; } - } + }); - $('#repo_count').html(showing); /* FIXME: don't hardcode */ + $('#repo_count').html(showing); + /* FIXME: don't hardcode */ } };
--- a/kallithea/templates/bookmarks/bookmarks.html Sat Nov 29 16:04:48 2014 +0900 +++ b/kallithea/templates/bookmarks/bookmarks.html Sat Nov 29 16:25:13 2014 +0900 @@ -91,7 +91,7 @@ var func = function(node){ return node.parentNode.parentNode.parentNode.parentNode.parentNode; } - q_filter('q_filter_bookmarks',YUQ('div.table tr td .logbooks .booktag a'),func); + q_filter('q_filter_bookmarks',$('div.table tr td .logbooks .booktag a'),func); }); </script>
--- a/kallithea/templates/branches/branches.html Sat Nov 29 16:04:48 2014 +0900 +++ b/kallithea/templates/branches/branches.html Sat Nov 29 16:25:13 2014 +0900 @@ -91,7 +91,7 @@ var func = function(node){ return node.parentNode.parentNode.parentNode.parentNode.parentNode; } - q_filter('q_filter_branches',YUQ('div.table tr td .logtags .branchtag a'),func); + q_filter('q_filter_branches',$('div.table tr td .logtags .branchtag a'),func); }); </script>
--- a/kallithea/templates/tags/tags.html Sat Nov 29 16:04:48 2014 +0900 +++ b/kallithea/templates/tags/tags.html Sat Nov 29 16:25:13 2014 +0900 @@ -91,7 +91,7 @@ var func = function(node){ return node.parentNode.parentNode.parentNode.parentNode.parentNode; } - q_filter('q_filter_tags',YUQ('div.table tr td .logtags .tagtag a'),func); + q_filter('q_filter_tags',$('div.table tr td .logtags .tagtag a'),func); }); </script>