Author: croberts
Date: 2011-09-28 14:52:08 +0000 (Wed, 28 Sep 2011)
New Revision: 5023
Modified:
trunk/wooly/resources/mootools.js
Log:
Some changes for the hybrid filtered select widget. The clear button will now clear the
filter box and unselect everything. In addition, each time you change your filter, your
selections will be reset. Also, fixing the "counting" bug that would
occasionally pop-up when selecting/unselecting/filtering things.
Modified: trunk/wooly/resources/mootools.js
===================================================================
--- trunk/wooly/resources/mootools.js 2011-09-28 12:54:17 UTC (rev 5022)
+++ trunk/wooly/resources/mootools.js 2011-09-28 14:52:08 UTC (rev 5023)
@@ -1867,6 +1867,7 @@
item.selected = false;
}
);
+ this.filterbox.value = "";
this.fireEvent('rebuild', [this.options.datasrc.getChildren()]);
this.update(0);
return false;
@@ -1875,14 +1876,22 @@
// list is the list of option dom elements from the select elem
// test is a function that gets used in the filter
filter: function(list, test, reset){
+ var matched = false;
+ var num_unselected = 0;
results = list.filter(function(item, index){
- return test(item);
+ matched = test(item);
+ if(!matched && item.selected) {
+ item.selected = false;
+ num_unselected++;
+ }
+ return matched;
});
if(reset){
this.filterbox.value = "";
}
this.fireEvent('rebuild', [results]);
+ this.update(this.numselected - num_unselected);
return results; //returning in the even that someone wants to do a
filter(...).each()
},
@@ -1909,6 +1918,7 @@
},
update: function(numselected){
+ this.numselected = numselected;
var total = this.options.datasrc.getChildren().length;
this.totalbtn.getElement('span').set('text', total);
this.selectedbtn.getElement('span').set('text', numselected);
Show replies by date