function Controller(){function e(){c.toggleMenu(a.league,Alloy.Globals.animations.menu)}function t(){c.i("toggle favorite"),Alloy.Globals.loading.showHide("show");var e=Alloy.Globals.favourites.leagues.slice(0);a.favouriteButton.active?(a.favouriteButton.backgroundImage="images/iconFavouriteOff.png",a.favouriteButton.active=!1,e=_.without(e,d.id)):(a.favouriteButton.backgroundImage="images/iconFavouriteOn.png",a.favouriteButton.active=!0,e.push(d.id)),c.setFaveLeagues(e),Alloy.Globals.rebuildMenu()}function i(e){l(e.source.clickArgs)}function o(){c.toggleMenu(a.sectionOptions,v)}function l(e){var t=!1;(void 0===u||u.id!==e.id)&&(void 0!==u?(void 0!==u.cancelRefresh&&u.cancelRefresh(),a.detailWrapper.remove(u.getView()),u.destroy&&u.destroy(),u=null):t=!0,u=Alloy.createController(e.id,e.args),a.detailWrapper.add(u.getView()),a.sectionSelector.text="    "+e.label,a.league.cancelRefresh=u.cancelRefresh),t||o()}function n(){_.contains(Alloy.Globals.favourites.leagues,d.id)&&(a.favouriteButton.backgroundImage="images/iconFavouriteOn.png",a.favouriteButton.active=!0),a.league.args=d,a.title.text=g.competitionName,_.each(w,function(e){a.sectionOptions.add(Alloy.createController("detailSelectorItem",e).getView())}),l(w[0]),Alloy.Globals.loading.showHide("hide")}require("alloy/controllers/BaseController").apply(this,Array.prototype.slice.call(arguments)),this.__controllerPath="league",arguments[0]?arguments[0].__parentSymbol:null,arguments[0]?arguments[0].$model:null,arguments[0]?arguments[0].__itemTemplate:null;var a=this,r={},s={};a.__views.league=Ti.UI.createView({backgroundColor:Alloy.CFG.colors.darkBlue,id:"league"}),a.__views.league&&a.addTopLevelView(a.__views.league),a.__views.detailWrapper=Ti.UI.createScrollView({top:88,backgroundColor:Alloy.CFG.colors.white,contentWidth:Ti.UI.FILL,id:"detailWrapper"}),a.__views.league.add(a.__views.detailWrapper),a.__views.sectionOptions=Ti.UI.createView({backgroundColor:Alloy.CFG.colors.darkGrey,layout:"vertical",height:123,top:-123,id:"sectionOptions"}),a.__views.league.add(a.__views.sectionOptions),i?a.__views.sectionOptions.addEventListener("click",i):s["$.__views.sectionOptions!click!sectionOptionClicked"]=!0,a.__views.titleBar=Ti.UI.createView({backgroundColor:Alloy.CFG.colors.darkBlue,height:40,top:0,id:"titleBar"}),a.__views.league.add(a.__views.titleBar),a.__views.menuButton=Ti.UI.createView({width:33,height:33,left:12,backgroundImage:"images/iconMenu.png",id:"menuButton"}),a.__views.titleBar.add(a.__views.menuButton),e?a.__views.menuButton.addEventListener("click",e):s["$.__views.menuButton!click!toggleMenu"]=!0,a.__views.title=Ti.UI.createLabel({font:{fontSize:20,fontFamily:Alloy.CFG.fonts.bold},color:Alloy.CFG.colors.white,id:"title"}),a.__views.titleBar.add(a.__views.title),a.__views.favouriteButton=Ti.UI.createView({width:33,height:33,right:12,backgroundImage:"images/iconFavouriteOff.png",id:"favouriteButton"}),a.__views.titleBar.add(a.__views.favouriteButton),t?a.__views.favouriteButton.addEventListener("click",t):s["$.__views.favouriteButton!click!toggleFavourite"]=!0,a.__views.sectionSelector=Ti.UI.createLabel({font:{fontSize:16,fontFamily:Alloy.CFG.fonts.bold},color:Alloy.CFG.colors.white,width:Ti.UI.FILL,height:48,top:40,backgroundColor:Alloy.CFG.colors.darkBlue,backgroundImage:"/images/bgDropDown.png",id:"sectionSelector"}),a.__views.league.add(a.__views.sectionSelector),o?a.__views.sectionSelector.addEventListener("click",o):s["$.__views.sectionSelector!click!toggleSectionMenu"]=!0,r.destroy=function(){},_.extend(a,a.__views);var c=require("helpers");require("feedSigner"),require("netConnect");var u,d=arguments[0]||{},g=_.find(Alloy.Globals.competitions,function(e){return e.competitionId===d.id}),v={open:Ti.UI.createAnimation({top:88,height:123,duration:300,curve:Ti.UI.ANIMATION_CURVE_EASE_IN_OUT}),close:Ti.UI.createAnimation({top:-123,height:123,duration:300,curve:Ti.UI.ANIMATION_CURVE_EASE_IN_OUT})},w=[{id:"newsItems",label:L("News_Title").toUpperCase(),args:{feedUrl:Alloy.CFG.feedUrls.newsArchiveCompetition.replace("{{id}}",d.id)}},{id:"matchListTable",label:L("Matches_Title").toUpperCase(),args:{feedUrl:Alloy.CFG.feedUrls.matchesLeague.replace("{{id}}",d.id)}},{id:"standingsTable",label:L("Tables_Title").toUpperCase(),args:{competitionId:d.id}}];n(),s["$.__views.sectionOptions!click!sectionOptionClicked"]&&a.__views.sectionOptions.addEventListener("click",i),s["$.__views.menuButton!click!toggleMenu"]&&a.__views.menuButton.addEventListener("click",e),s["$.__views.favouriteButton!click!toggleFavourite"]&&a.__views.favouriteButton.addEventListener("click",t),s["$.__views.sectionSelector!click!toggleSectionMenu"]&&a.__views.sectionSelector.addEventListener("click",o),_.extend(a,r)}var Alloy=require("alloy"),Backbone=Alloy.Backbone,_=Alloy._;module.exports=Controller;