/*    HTTP Host:  static.ak.fbcdn.net                                          */
/*    Generated:  January 26th 2010 9:08:31 PM PST                             */
/*      Machine:  10.16.140.110                                                */
/*       Source:  Global Cache                                                 */
/*     Location:  js/UIMutableFilterList.js h:6zmmoge5                         */
/*       Locale:  nu_ll                                                        */
/*         Path:  js/UIMutableFilterList.js                                    */

if (window.CavalryLogger) { CavalryLogger.start_js(["js\/UIMutableFilterList.js"]); }

function UIMutableFilterList(a,c,d,b){this.hiddenContainer=a.find('div.UIMutableFilterList_HiddenSection');this.showLink=DOM.scry(a,'a.UIMutableFilterList_Show')[0];this.hideLink=DOM.scry(a,'a.UIMutableFilterList_Hide')[0];if(this.showLink){this.showLink.listen('click',this.showBottom.bind(this));this.hideLink.listen('click',this.hideBottom.bind(this));}this.emptyBox=DOM.scry(a,'div.UIMutableFilterList_EmptyBox')[0];this.bottomShown=false;this.numVisible=d;this.orderChangedHandler=bagofholding;return this.parent.construct(this,a,c,b);}UIMutableFilterList.extend('UIFilterList');UIMutableFilterList.prototype.setOrderChangedHandler=function(a){this.orderChangedHandler=a;return this;};UIMutableFilterList.prototype.getOrderedItems=function(){var d={};d.shown=[];d.hidden=[];var c=this.getItems();var e=this.topGroup.getOrder();for(var b=0;b<e.length;b++)if(c[e[b]])d.shown.push(c[e[b]].data);var a=this.bottomGroup.getOrder();for(var b=0;b<a.length;b++)if(c[a[b]])d.hidden.push(c[a[b]].data);return d;};UIMutableFilterList.prototype.initializeItems=function(a){if(a[0])this.setDragHandlers();return this.parent.initializeItems(a);};UIMutableFilterList.prototype.setDragHandlers=function(){var f=this.ongrabcallback.bind(this);var e=this.ondropcallback.bind(this);this.topGroup=new SortableGroup();this.topGroup.setGrabCallback(f);this.topGroup.setDropCallback(e);this.topGroup.setOrderChangeHandler(this.orderChanged.bind(this));this.bottomGroup=new SortableGroup();this.bottomGroup.setGrabCallback(f);this.bottomGroup.setDropCallback(e);this.bottomGroup.setOrderChangeHandler(this.orderChanged.bind(this));this.topGroup.link(this.bottomGroup);var b=this.getDragContainers();var d=this.getItemLinks();for(var a=0,c=b.length;a<c;a++)if(a<this.numVisible){this.topGroup.addSortable(a,b[a]);this.topGroup.draggables[a].addHandle(b[a]);}else{this.bottomGroup.addSortable(a,b[a]);this.bottomGroup.draggables[a].addHandle(b[a]);}if(this.emptyBox){var g=this.hiddenContainer.find('div.UIFilterList_List');this.bottomGroup.addEmptyMessage(this.emptyBox,g);if(b.length==this.numVisible)CSS.removeClass(this.emptyBox,'hidden_elem');}this.bottomGroup.setLinkJumpHandler(function(){var h=this.root.find('div.UIFilterList_Footer');if(!this.emptyBox)return;if(g.childNodes.length>1){CSS.addClass(this.emptyBox,'hidden_elem');CSS.removeClass(h,'UIFilterList_NoBorder');}else{CSS.removeClass(this.emptyBox,'hidden_elem');CSS.addClass(h,'UIFilterList_NoBorder');}}.bind(this));this.topGroup.setNeverEmpty(true);this.setBoundingBox(this.getCurrentBoundingBox());};UIMutableFilterList.prototype.getDragContainers=function(){if(!this.dragContainers)this.dragContainers=this.getItemContainers();return this.dragContainers;};UIMutableFilterList.prototype.resetDragContainers=function(){this.dragContainers=null;};UIMutableFilterList.prototype.ongrabcallback=function(b){var a=this.getDragContainers()[b];CSS.setOpacity(a,.7);Vector2.getElementDimensions(a).setElementWidth(a);};UIMutableFilterList.prototype.ondropcallback=function(b){var a=this.getDragContainers()[b];CSS.setOpacity(a,1);a.setStyle('width','auto');this.setBoundingBox(this.getCurrentBoundingBox());};UIMutableFilterList.prototype.orderChanged=function(){this.orderChangedHandler(this.getOrderedItems());};UIMutableFilterList.prototype.setBoundingBox=function(a){this.bottomGroup.setBoundingBox(a);this.topGroup.setBoundingBox(a);};UIMutableFilterList.prototype.getCurrentBoundingBox=function(){var f=this.controller.scry('div.UIFilterList_Item');var h=Vector2.getElementCompassPoint(f[0],Vector2.compass.north);var e=h.y;var c=0;if(this.bottomShown){var g=f.length-1;}else var g=this.topGroup.getOrder().length-1;var a=Vector2.getElementCompassPoint(f[g],Vector2.compass.south);var d=0;var b=a.y;return new Rect(e,d,b,c,'document');};UIMutableFilterList.prototype.showAnimationEnded=function(){this.bottomShown=true;this.setBoundingBox(this.getCurrentBoundingBox());};UIMutableFilterList.prototype.hideAnimationEnded=function(){this.bottomShown=false;this.setBoundingBox(this.getCurrentBoundingBox());this.root.removeClass('UIFilterList_ShowHiddenSection');};UIMutableFilterList.prototype.showBottom=function(){this.hiddenContainer.setStyle('height','0px');animation(this.hiddenContainer).to('height','auto').from('opacity',0).to('opacity',1).ease(animation.ease.both).duration(200).ondone(function(){this.showAnimationEnded();}.bind(this)).go();if(this.showLink){this.showLink.addClass('hidden_elem');this.hideLink.removeClass('hidden_elem');}return false;};UIMutableFilterList.prototype.hideBottom=function(){animation(this.hiddenContainer).to('height','0px').from('opacity',1).to('opacity',0).ease(animation.ease.both).duration(200).ondone(function(){this.hideAnimationEnded();}.bind(this)).go();if(this.showLink){this.showLink.removeClass('hidden_elem');this.hideLink.addClass('hidden_elem');}this.resetDragContainers();return false;};

if (window.Bootloader) { Bootloader.done(["js\/UIMutableFilterList.js"]); }