Here is the new class:
dojo.provide("toonetown.dijit.form.DropDownSelect");
dojo.require("dijit.form.Button");
dojo.require("dijit.form.FilteringSelect");
dojo.require("dijit.Menu");
dojo.require("dojo.data.ItemFileReadStore");
dojo.declare("toonetown.dijit.form.DropDownSelect", dijit.form.DropDownButton, {
store: null,
dropDown: null,
hasDownArrow: true,
_isPopulated: false,
_lastValue: "",
onChange: function(){},
_getValueField: function(){ return "value"; },
_getItemByValue: function(value){
var ret = null;
this.store.fetch({query: {value: value}, onComplete: function(i, r){
if (i.length && i[0]) ret = i[0];
}});
return ret;
},
postMixInProperties: function(){
this.inherited(arguments);
dijit.form.ComboBoxMixin.prototype.postMixInProperties.apply(this, arguments);
this.dropDown = new dijit.Menu();
dojo.place(dojo.doc.createElement("span"), this.srcNodeRef, "first");
},
postCreate: function(){
this._menuItemClick(this.value);
this.inherited(arguments);
},
_menuItemClick: function(item){
var str = (typeof item == "string"),
i = str ? this._getItemByValue(item) : item,
val = i ? i.value : null;
if (!val || val == this._lastValue)
return;
this.setValue(val);
this.setLabel(i.name);
this._lastValue = val;
if (!str) this.onChange(val);
},
_toggleDropDown: function(){
var _this = this, dropDown = _this.dropDown;
if (dropDown && !dropDown.isShowingNow && !_this._isPopulated)
{
_this.store.fetch({
onItem:function(i){
dropDown.addChild(new dijit.MenuItem({
label: i.name,
onClick: function(){
_this._menuItemClick(i);
}}));
},
onComplete: function(){
_this._isPopulated = true;
toonetown.dijit.form.DropDownSelect.superclass._toggleDropDown.call(_this);
}
});
return;
}
this.inherited(arguments);
}
});
Isn't code reuse nice? :)

2 comments:
Nathan, do you have any inside information on when K9 will be available on Mac OS X?
I really don't any more information on that. I'm guessing sometime in the next few months. I've been reassigned to another team, so I am no more familiar with schedules than you are :) .
You can try to sign up for the beta program for K9. Instructions can be found at http://forums.bluecoat.com (I don't remember the exact address off the top of my head - you'll need to search aroud a bit)
Sorry I don't know more.
Post a Comment