/*
HTTP Host: b.static.ak.fbcdn.net
Generated: March 21st 2010 2:18:50 PM PDT
Machine: 10.16.139.105
Locale: nu_ll
Path: js/1m2b5fl84u4g8gc0.pkg.js
*/

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


function UIMutableFilterList(controller,item_data,num_visible,data){this.hiddenContainer=controller.find('div.UIMutableFilterList_HiddenSection');this.showLink=DOM.scry(controller,'a.UIMutableFilterList_Show')[0];this.hideLink=DOM.scry(controller,'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(controller,'div.UIMutableFilterList_EmptyBox')[0];this.bottomShown=false;this.numVisible=num_visible;this.orderChangedHandler=bagofholding;return this.parent.construct(this,controller,item_data,data);}
UIMutableFilterList.extend('UIFilterList');UIMutableFilterList.prototype.setOrderChangedHandler=function(handler){this.orderChangedHandler=handler;return this;}
UIMutableFilterList.prototype.getOrderedItems=function(){var ordered={};ordered.shown=[];ordered.hidden=[];var items=this.getItems();var top_order=this.topGroup.getOrder();for(var i=0;i<top_order.length;i++){if(items[top_order[i]]){ordered.shown.push(items[top_order[i]].data);}}
var bottom_order=this.bottomGroup.getOrder();for(var i=0;i<bottom_order.length;i++){if(items[bottom_order[i]]){ordered.hidden.push(items[bottom_order[i]].data);}}
return ordered;}
UIMutableFilterList.prototype.initializeItems=function(item_data){if(item_data[0]){this.setDragHandlers();}
return this.parent.initializeItems(item_data);}
UIMutableFilterList.prototype.setDragHandlers=function(){var ongrabcallback=this.ongrabcallback.bind(this);var ondropcallback=this.ondropcallback.bind(this);this.topGroup=new SortableGroup();this.topGroup.setGrabCallback(ongrabcallback);this.topGroup.setDropCallback(ondropcallback);this.topGroup.setOrderChangeHandler(this.orderChanged.bind(this));this.bottomGroup=new SortableGroup();this.bottomGroup.setGrabCallback(ongrabcallback);this.bottomGroup.setDropCallback(ondropcallback);this.bottomGroup.setOrderChangeHandler(this.orderChanged.bind(this));this.topGroup.link(this.bottomGroup);var items=this.getDragContainers();var link_items=this.getItemLinks();for(var i=0,l=items.length;i<l;i++){if(i<this.numVisible){this.topGroup.addSortable(i,items[i]);this.topGroup.draggables[i].addHandle(items[i]);}else{this.bottomGroup.addSortable(i,items[i]);this.bottomGroup.draggables[i].addHandle(items[i]);}}
if(this.emptyBox){var root=this.hiddenContainer.find('div.UIFilterList_List');this.bottomGroup.addEmptyMessage(this.emptyBox,root);if(items.length==this.numVisible){CSS.removeClass(this.emptyBox,'hidden_elem');}}
this.bottomGroup.setLinkJumpHandler(function(){var footer=this.root.find('div.UIFilterList_Footer');if(!this.emptyBox){return;}
if(root.childNodes.length>1){CSS.addClass(this.emptyBox,'hidden_elem');CSS.removeClass(footer,'UIFilterList_NoBorder');}else{CSS.removeClass(this.emptyBox,'hidden_elem');CSS.addClass(footer,'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(i){var element=this.getDragContainers()[i];CSS.setOpacity(element,0.7);Vector2.getElementDimensions(element).setElementWidth(element);}
UIMutableFilterList.prototype.ondropcallback=function(i){var element=this.getDragContainers()[i];CSS.setOpacity(element,1);element.setStyle('width','auto');this.setBoundingBox(this.getCurrentBoundingBox());}
UIMutableFilterList.prototype.orderChanged=function(){this.orderChangedHandler(this.getOrderedItems());}
UIMutableFilterList.prototype.setBoundingBox=function(bounding_box){this.bottomGroup.setBoundingBox(bounding_box);this.topGroup.setBoundingBox(bounding_box);}
UIMutableFilterList.prototype.getCurrentBoundingBox=function(){var items=this.controller.scry('div.UIFilterList_Item');var top_item_pos=Vector2.getElementCompassPoint(items[0],Vector2.compass.north);var bounding_top=top_item_pos.y;var bounding_left=0;if(this.bottomShown){var last_item=items.length-1;}else{var last_item=this.topGroup.getOrder().length-1;}
var bottom_item_pos=Vector2.getElementCompassPoint(items[last_item],Vector2.compass.south);var bounding_right=0;var bounding_bottom=bottom_item_pos.y;return new Rect(bounding_top,bounding_right,bounding_bottom,bounding_left,'document');}
UIMutableFilterList.prototype.showAnimationEnded=function(){this.bottomShown=true;this.setBoundingBox(this.getCurrentBoundingBox());}
UIMutableFilterList.prototype.hideAnimationEnded=function(){this.bottomShown=false;this.setBoundingBox(this.getCurrentBoundingBox());this.hiddenContainer.addClass('hidden_elem');}
UIMutableFilterList.prototype.showBottom=function(){this.hiddenContainer.setStyle('height','0px');this.hiddenContainer.removeClass('hidden_elem');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;}

function UIHomeFilter(root,assoc_id,item_data,num_visible,data,is_wrapped){this.is_wrapped=is_wrapped;this.parent.construct(this,root,item_data,num_visible,data);copy_properties(this,{root:root,assoc_id:assoc_id});this.finishedSetup=false;this.setOrderChangedHandler(UIHomeFilter.filterOrderChanged.bind(this));}
UIHomeFilter.extend('UIMutableFilterList');UIHomeFilter.filterOrderChanged=function(ordered){this.resetItemContainers();this.resetItemLinks();var shown=[];var hidden=[];for(var i=0;i<ordered.shown.length;i++){shown.push(ordered.shown[i]['filter']);}
for(var i=0;i<ordered.hidden.length;i++){hidden.push(ordered.hidden[i]['filter']);}
this.numVisible=shown.length;var postData={};postData.order=[];postData.visible=shown.length;postData.id=this.assoc_id;postData.order=shown.concat(hidden);new AsyncRequest().setURI('/ajax/filterlist.php').setData(postData).setHandler(bagofholding).send();};UIHomeFilter.prototype.beginEditMode=function(){this.showBottom();if(!this.finishedSetup){var createLink=document.createElement('a');var doneLink=document.createElement('a');CSS.addClass(createLink,'UIFilterList_CreateLink');CSS.addClass(doneLink,'UIFilterList_DoneLink');createLink.innerHTML=_tx("\u5efa\u7acb\u65b0\u540d\u55ae");var createLinkUrl=new URI().parse(DialogBootstrapEndpoints.LIST_EDITOR).addQueryData({'new_list':true}).toString();createLink.setAttribute('href',createLinkUrl);createLink.setAttribute('rel','dialog-post');var itemLinks=this.getItemLinks();if(this.numVisible==itemLinks.length){doneLink.innerHTML=_tx("\u5b8c\u6210");}else{doneLink.innerHTML=_tx("\u96b1\u85cf");}
var footer=this.root.find('div.UIFilterList_Footer');footer.appendChild(createLink);footer.appendChild(doneLink);doneLink=this.root.find('a.UIFilterList_DoneLink');doneLink.listen('click',this.endEditMode.bind(this));for(var i=0;i<itemLinks.length;i++){var dragHandle=document.createElement('span');CSS.addClass(dragHandle,'UIFilterList_DragHandle');itemLinks[i].appendChild(dragHandle);}}
if(this.finishedSetup){this.setDragHandlers();}
CSS.addClass(this.root,'UIFilterList_EditMode');this.finishedSetup=true;}
UIHomeFilter.prototype.hideAnimationEnded=function(){this.parent.hideAnimationEnded();this.topGroup.destroy();this.bottomGroup.destroy();}
UIHomeFilter.prototype.endEditMode=function(){this.hideBottom();var doneLink=this.root.find('a.UIFilterList_DoneLink');var editLink=this.root.find('a.UIFilterList_EditLink');if(this.numVisible==this.getItemLinks().length){doneLink.innerHTML=_tx("\u5b8c\u6210");editLink.innerHTML=_tx("\u7de8\u8f2f");}else{doneLink.innerHTML=_tx("\u96b1\u85cf");editLink.innerHTML=_tx("\u66f4\u591a");}
CSS.removeClass(this.root,'UIFilterList_EditMode');}

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