Skip to content

Commit

Permalink
Retain string-arg demo for ext-filter sample
Browse files Browse the repository at this point in the history
  • Loading branch information
mar10 committed Apr 29, 2014
1 parent 6f9a432 commit 7aa1fd0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 22 deletions.
38 changes: 17 additions & 21 deletions demo/sample-ext-filter.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<title>Fancytree - Example: Filter</title>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js" type="text/javascript"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1/jquery-ui.min.js" type="text/javascript"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js" type="text/javascript"></script>
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1/jquery-ui.min.js" type="text/javascript"></script>

<link href="../src/skin-win7/ui.fancytree.css" rel="stylesheet" type="text/css">
<script src="../src/jquery.fancytree.js" type="text/javascript"></script>
Expand Down Expand Up @@ -47,23 +47,22 @@
* Event handlers for our little demo interface
*/
$("input[name=search]").keyup(function(e){
var match = $(this).val();
var n,
match = $(this).val();

if(e && e.which === $.ui.keyCode.ESCAPE || $.trim(match) === ""){
$("button#btnResetSearch").click();
return;
}
// Pass function to perform match
var n = tree.applyFilter(function(node) {
if($("#regex").is(":checked")) {
if($("#regex").is(":checked")) {
// Pass function to perform match
n = tree.applyFilter(function(node) {
return new RegExp(match, "i").test(node.title);
}
else if(node.title.indexOf(match) > -1) {
return true;
}
else {
return false;
}
});
});
} else {
// Pass a string to perform case insensitive matching
n = tree.applyFilter(match);
}
$("button#btnResetSearch").attr("disabled", false);
$("span#matches").text("(" + n + " matches)");
}).focus();
Expand All @@ -78,7 +77,6 @@
tree.options.filter.mode = $(this).is(":checked") ? "hide" : "dimm";
tree.clearFilter();
$("input[name=search]").keyup();
// tree.render();
});
$("input#regex").change(function(e){
tree.clearFilter();
Expand Down Expand Up @@ -106,17 +104,15 @@ <h1>Example: 'filter' extension</h1>
<button id="btnResetSearch">&times;</button>
<span id="matches"></span>
</p>
<p>
<label for="hideMode">
<input type="checkbox" id="hideMode">
Hide unmatched nodes
</label>
</p>
<p>
<label for="regex">
<input type="checkbox" id="regex">
Regular expression
</label>
<label for="hideMode">
<input type="checkbox" id="hideMode">
Hide unmatched nodes
</label>
</p>
<!-- Add a <table> element where the tree should appear: -->
<div id="tree">
Expand Down
2 changes: 1 addition & 1 deletion src/jquery.fancytree.persist.js
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ $.ui.fancytree.registerExtension({
this.focusNode ? this.focusNode.key : null,
instOpts.cookie);
}
return res
return res;
},
nodeSetSelected: function(ctx, flag) {
var res,
Expand Down

0 comments on commit 7aa1fd0

Please sign in to comment.