function Controller(){function e(){i.search.blur(),_.defer(function(){c.closeWindow(i.teamSearch)})}function r(){i.teamSearch.open()}function o(e){c.is("search return",e),Alloy.Globals.loading.showHide("show"),_.defer(function(){t(e.source.value)})}function t(e){var r=_.filter(Alloy.Globals.teams,function(r){return-1!==r.name.toLowerCase().indexOf(e.toLowerCase())});d=[],_.each(r,function(e){d.push(Alloy.createController("teamSearchTableRow",{title:e.name,logo:e.logo,id:e.teamId,active:_.contains(Alloy.Globals.favourites.teams,e.teamId)}).getView())}),i.results.data=d,_.defer(function(){i.search.blur(),Alloy.Globals.loading.showHide("hide")})}function a(e){Alloy.Globals.loading.showHide("show");var r=Alloy.Globals.favourites.teams.slice(0);e.row.favorite?(e.source.backgroundImage="images/iconFavouriteOff.png",e.row.favorite=!1,r=_.without(r,e.row.args.id)):(e.source.backgroundImage="images/iconFavouriteOn.png",e.row.favorite=!0,r.push(e.row.args.id)),c.setFaveTeams(r),Alloy.Globals.rebuildMenu()}function l(r){"favoriteIcon"===r.source.id?a(r):(Alloy.Globals.loading.showHide("show"),_.defer(function(){Alloy.Globals.setActiveMenuItem({controller:"team",controllerArgs:r.row.args}),e()}))}require("alloy/controllers/BaseController").apply(this,Array.prototype.slice.call(arguments)),this.__controllerPath="teamSearch",arguments[0]?arguments[0].__parentSymbol:null,arguments[0]?arguments[0].$model:null,arguments[0]?arguments[0].__itemTemplate:null;var i=this,s={},n={};i.__views.teamSearch=Ti.UI.createWindow({backgroundColor:Alloy.CFG.colors.darkBlue,layout:"vertical",id:"teamSearch"}),i.__views.teamSearch&&i.addTopLevelView(i.__views.teamSearch),i.__views.titleBar=Ti.UI.createView({height:40,top:0,id:"titleBar"}),i.__views.teamSearch.add(i.__views.titleBar),i.__views.backButton=Ti.UI.createView({width:33,height:33,left:12,backgroundImage:"images/iconBack.png",id:"backButton"}),i.__views.titleBar.add(i.__views.backButton),e?i.__views.backButton.addEventListener("click",e):n["$.__views.backButton!click!closeWindow"]=!0,i.__views.search=Ti.UI.createTextField({height:30,backgroundColor:Alloy.CFG.colors.black,borderRadius:10,borderColor:"transparent",borderWidth:3,color:Alloy.CFG.colors.white,paddingLeft:10,left:55,width:255,id:"search"}),i.__views.titleBar.add(i.__views.search),o?i.__views.search.addEventListener("return",o):n["$.__views.search!return!searchClicked"]=!0,i.__views.results=Ti.UI.createTableView({separatorColor:Alloy.CFG.colors.darkGrey,backgroundColor:Alloy.CFG.colors.darkBlue,layout:"vertical",contentWidth:Ti.UI.FILL,width:Ti.UI.FILL,id:"results"}),i.__views.teamSearch.add(i.__views.results),l?i.__views.results.addEventListener("click",l):n["$.__views.results!click!tableClicked"]=!0,s.destroy=function(){},_.extend(i,i.__views);var c=require("helpers");require("alloy/moment"),require("feedSigner"),require("netConnect");var d=[];i.teamSearch.addEventListener("focus",function(){_.defer(function(){i.search.focus(),_.defer(function(){Alloy.Globals.loading.showHide("hide")})})}),s.openWin=r,n["$.__views.backButton!click!closeWindow"]&&i.__views.backButton.addEventListener("click",e),n["$.__views.search!return!searchClicked"]&&i.__views.search.addEventListener("return",o),n["$.__views.results!click!tableClicked"]&&i.__views.results.addEventListener("click",l),_.extend(i,s)}var Alloy=require("alloy"),Backbone=Alloy.Backbone,_=Alloy._;module.exports=Controller;