YUI.add('columnbrowser', function(Y) { var Lang = Y.Lang, Widget = Y.Widget, Node = Y.Node; Widget.ColumnBrowser = ColumnBrowser; var NS = Y.namespace('mazzle'); NS.ColumnBrowser = ColumnBrowser; /* ColumnBrowser class constructor */ function ColumnBrowser(config) { ColumnBrowser.superclass.constructor.apply(this, arguments); } /* * Required NAME static field, to identify the Widget class and * used as an event prefix, to generate class names etc. (set to the * class name in camel case). */ ColumnBrowser.NAME = "columnbrowser"; /* * The attribute configuration for the ColumnBrowser widget. Attributes can be * defined with default values, get/set functions and validator functions * as with any other class extending Base. */ ColumnBrowser.ATTRS = { datasource: { value: null }, columns: { value: null }, columnWidth: { value: 200, validator: Lang.isNumber }, searchEnabled: { value: true, validator: Lang.isBoolean }, maxNumberItems: { value: 100, validator: Lang.isNumber }, minQueryLength: { value: 2, validator: Lang.isNumber }, queryDelay: { value: 0.3, validator: Lang.isNumber }, selected: { value: null }, autoLoad: { value: true } }; /* ColumnBrowser extends the base Widget class */ Y.extend(ColumnBrowser, Widget, { initializer: function(config) { // internal variables this._activeIndex = null; this._selectedIndex = null; // internal references to nodes this.columnsBox = null; this.columnsNode = null; this.publish("itemSelect", {}); }, destructor : function() { // purge itemSelect, optionSelect, offSetSelect, valueChange? }, renderUI : function() { this.columnsBox = this.get("contentBox") .appendChild(Node.create('
')); this.columnsNode = this.columnsBox .appendChild(Node.create('')); }, bindUI : function() { }, syncUI : function() { if(this._activeIndex===0||this._activeIndex) { var columns = this.get("columns"), activeIndex = this._activeIndex, selectedIndex = this._selectedIndex, selectedItem = this._selectedItem; // update the status of the columns // to "selected" or "hidden" for (var i=0; i < columns.length; i++) { var list = columns[i].list; if(list) { if(i==selectedIndex) { list.get("boundingBox").addClass("selected"); } else { list.get("boundingBox").removeClass("selected"); } if(i<=activeIndex) { list.show(); } else { list.hide(); } } } // update the active column this._updateContentSize(); //columns[activeIndex].list._node.scrollIntoView(); } else if(this.get("autoLoad")) { this._activeIndex = 0; this._updateColumn(0); } }, /** * Public functions to fetch ids and labels from result items */ itemId : function(item) { var id = item.id ? item.id : item; return id; }, itemLabel : function(item) { var label = item.label ? item.label : item; return label; }, // this completely sucks :( updateAll : function(params) { var columns = this.get("columns"), activeIndex = this._activeIndex; for (var i=0; i