(function(n){var t=function(){var n=this;n.plantId="";n.availability="";n.barkTexture="";n.barkStemDetail="";n.commonName="";n.control="";n.otherNames="";n.cultivar="";n.derivation="";n.meaning="";n.ecology="";n.edibility="";n.endemic="";n.familyAckerfieldWithCommonName="";n.familyId="";n.familyName="";n.fiberDye="";n.flowerCluster="";n.flowerColor="";n.flowerDetail="";n.flowerShape="";n.flowerSize="";n.flowerStructure="";n.flowerSymmetry="";n.frequency="";n.fruitColor="";n.fruitType="";n.fruitCone="";n.group="";n.growthForm="";n.habitat="";n.leafArrangement="";n.leafType="";n.leafLeafletShape="";n.legalStatus="";n.lifeCycle="";n.lifeZone="";n.light="";n.livestock="";n.maleFemale="";n.matureHeight="";n.matureSpread="";n.moisture="";n.originArea="";n.origin="";n.otherUses="";n.parkId="";n.petalNumber="";n.scientificName="";n.scientificMeaningAckerfield="";n.seasonOfBloom="";n.soil="";n.speciesDetail="";n.speciesVarForma="";n.subGroup="";n.synonyms="";n.toxicity="";n.twigStemTexture="";n.use="";n.rowVersion="";n.Initialized=!1};n.plantDetails=t})(window.ColoradoPlants);var plantModule=angular.module("plantMiniSpa",["common","settings"]).config(["$routeProvider","$locationProvider",function(n,t){n.when(ColoradoPlants.rootPath+"plantsearch",{caseInsensitiveMatch:!0,templateUrl:ColoradoPlants.rootPath+"app/plant/templates/plantSearch.html",controller:"plantSearchController",reloadOnSearch:!1}).when(ColoradoPlants.rootPath+"plant/details/:plantId",{caseInsensitiveMatch:!0,templateUrl:ColoradoPlants.rootPath+"app/plant/templates/plantDetails.html",controller:"plantDetailsController"}).when(ColoradoPlants.rootPath+"plantabout",{caseInsensitiveMatch:!0,templateUrl:ColoradoPlants.rootPath+"app/plant/templates/plantAbout.html",controller:"plantController"}).when(ColoradoPlants.rootPath+"planthelp",{caseInsensitiveMatch:!0,templateUrl:ColoradoPlants.rootPath+"app/plant/templates/plantHelp.html",controller:"plantController"}).when(ColoradoPlants.rootPath+"plantreference",{caseInsensitiveMatch:!0,templateUrl:ColoradoPlants.rootPath+"app/plant/templates/plantReference.html",controller:"plantReferenceController"}).otherwise({redirectTo:ColoradoPlants.rootPath+"plantAbout"});t.html5Mode(!0)}]);plantModule.factory("plantService",["viewModelHelper",function(n){return{getPlant:function(t,i){return n.apiGet("api/plant/"+t,null,i)},getPlantReference:function(t,i){return n.apiGet("api/plant/plantReference/",null,i)}}}]);plantModule.controller("plantController",["$scope","$rootScope","$http","$location","$window","viewModelHelper","settings","plantService",function(n,t,i,r,u,f){"use strict";t.clearMessages();n.plantModule={};n.viewModelHelper=f;n.plantModule.plantDetails=new ColoradoPlants.plantDetails;n.plantModule.openSite=function(n){u.location.href=n};n.plantModule.previous=function(){u.history.back()}}]);plantModule.controller("plantSearchController",["$scope","$location","settings","$rootScope","$filter","lookupService",function(n,t,i,r,u,f){"use strict";var e,o;n.plantModule.initialize=function(){n.plantModule.getParkLookup();n.plantModule.getBloomingSeasonLookup();n.plantModule.query.season==undefined&&n.plantModule.commonConfig();n.plantModule.query.season!=undefined&&n.plantModule.seasonConfig()};n.plantModule.searchMaxRows=i.searchMaxRows;n.plantModule.query={};e=t.search();for(o in e)n.plantModule.query[o]=e[o];n.plantModule.seasonConfig=function(){n.plantModule.config={entityName:"plant",displayName:"Plants",primaryKey:"plantId",spinnerMessage:"Searching Colorado Plant Database...",columns:[{propertyName:"seasonOfBloom",displayName:"Season"},{propertyName:"scientificName",displayName:"Scientific Name"},{propertyName:"commonName",displayName:"Common Name"},{propertyName:"otherNames",displayName:"Other Names"}]}};n.plantModule.commonConfig=function(){n.plantModule.config={entityName:"plant",displayName:"Plants",primaryKey:"plantId",spinnerMessage:"Searching Native Plant Database...",columns:[{propertyName:"familyName",displayName:"Family"},{propertyName:"scientificName",displayName:"Scientific Name"},{propertyName:"commonName",displayName:"Common Name"},{propertyName:"origin",displayName:"Origin"},{propertyName:"imageExistence",displayName:"Image?"}]}};n.plantModule.openRow=function(n){r.clearMessages();var i="/plant/details/"+n;t.url(i)};n.$watch("plantModule.query",function(){var r,i,u;if(n.plantModule.query){r=!0;for(i in n.plantModule.query)u=n.plantModule.query[i],u?(t.search(i,u),r=!1):t.search(i,null)}n.plantModule.resultsEnabled=r==!1},!0);n.plantModule.clearSearch=function(t){t=="name"&&(n.plantModule.query.word=null,n.plantModule.query.season=null,n.plantModule.query.parkName=null,n.plantModule.commonConfig());t=="word"&&(n.plantModule.query.name=null,n.plantModule.query.season=null,n.plantModule.query.parkName=null,n.plantModule.query.all=null,n.plantModule.commonConfig());t=="season"&&(n.plantModule.query.name=null,n.plantModule.query.word=null,n.plantModule.query.parkName=null,n.plantModule.query.all=null,n.plantModule.seasonConfig());t=="park"&&(n.plantModule.query.name=null,n.plantModule.query.word=null,n.plantModule.query.season=null,n.plantModule.query.all=null,n.plantModule.commonConfig());t=="all"&&(n.plantModule.query.name=null,n.plantModule.query.word=null,n.plantModule.query.season=null,n.plantModule.query.parkName=null,n.plantModule.commonConfig())};n.plantModule.getParkLookup=function(){f.getLookup("ParkLookup","plant","",function(t){n.plantModule.parkLookup=t.data.items})};n.plantModule.getBloomingSeasonLookup=function(){f.getLookup("BloomingSeasonLookup","plant","",function(t){n.plantModule.bloomingSeasonLookup=t.data.items})};n.plantModule.showAll=function(){n.plantModule.query.all="true";n.plantModule.clearSearch("all")};n.plantModule.initialize()}]);plantModule.controller("plantReferenceController",["$scope","$rootScope","$routeParams","$location","$uibModal","$route","plantService","$window","lookupService",function(n,t,i,r,u,f,e,o,s){"use strict";var h=r.path();n.plantModule.initialize=function(){n.plantModule.getPlantReference();n.plantModule.getPlantReferenceGroupLookup()};n.plantModule.getPlantReference=function(){e.getPlantReference(0,function(t){n.plantModule.plantReference=t.data.items})};n.plantModule.getPlantReferenceGroupLookup=function(){s.getLookup("PlantReferenceGroupsLookup","plant","",function(t){n.plantModule.plantReferenceGroupLookup=t.data.items})};n.plantModule.initialize()}]);plantModule.controller("plantDetailsController",["$scope","$rootScope","$routeParams","$location","$uibModal","$route","plantService","$window",function(n,t,i,r,u,f,e){"use strict";var o,s;n.plantModule.plantId=i.plantId;o=[];n.plantModule.myInterval=5e3;n.plantModule.noWrapSlides=!1;n.plantModule.active=0;n.plantModule.minHeight=0;n.plantModule.imagesLoaded=!1;n.plantModule.imageCount=0;s=r.path();n.plantModule.initialize=function(){n.plantModule.getPlant()};n.plantModule.getPlant=function(){e.getPlant(n.plantModule.plantId,function(t){n.plantModule.plantDetails=t.data.plantDetails;n.plantModule.pushPlantImages()})};n.plantModule.pushPlantImages=function(){angular.forEach(n.plantModule.plantDetails.plantImages,function(t,i){n.plantModule.getMeta(n.plantModule.plantDetails.plantImages[i].imageUrl);o.push({image:n.plantModule.plantDetails.plantImages[i].imageUrl,id:i,copyRight:n.plantModule.plantDetails.plantImages[i].acknowledgement});n.plantModule.imageCount++});n.plantModule.plantImages=o};n.plantModule.getMeta=function(t){var i=new Image;i.onload=function(){this.height+40>n.plantModule.minHeight&&(n.plantModule.minHeight=this.height+40);n.plantModule.imageCount===1&&(n.plantModule.imagesLoaded=!0,n.$apply());n.plantModule.imageCount--};i.src=t};n.plantModule.initialize()}]);commonModule.directive("plantSearchGrid",["viewModelHelper",function(n){return{templateUrl:"/app/plant/templates/plantSearchGrid.html",scope:{pageSize:"=",showFooter:"=",tableConfiguration:"=",query:"=",enabled:"=",onSetRow:"&",onSetColumn:"&",onUpdated:"&",totalCount:"=?"},controller:["$scope","$element","$http","$window",function(t){t.currentRequest;t.searchGrid={};t.searchGrid.currentPage;t.rowsLoaded=!1;t.getRows=function(i){var r,u,f;t.searchGrid.currentPage=i;t.skip=(i-1)*t.pageSize;r=t.url;t.url=t.getUrl();u=t.enabled==!0&&t.url!=r;f=t.enabled===!0&&t.rowsLoaded===!1;(u||f)&&(t.showSpinner=!0,t.currentRequest=t.url.toString(),t.rows=null,t.rowsLoaded=!0,n.apiGet(t.url,null,function(n){if(t.errorMessage=null,t.currentRequest.toLowerCase().replace(/%20/g," ")===n.data.uri.toLowerCase()){t.rows=n.data.items;t.rows!=null&&(t.count=n.data.items.length,t.recordStart=t.skip+1,t.recordEnd=t.skip+t.count);t.totalCount=n.data.totalCount;t.filteredCount=n.data.filteredCount;t.executionTime=n.data.executionTimeSeconds;t.onUpdated({data:{totalCount:t.totalCount,filteredCount:t.filteredCount,executionTime:t.executionTime}});t.showSpinner=!1}},function(){t.rows=null;t.errorMessage="Call failed to retrieve "+t.tableConfiguration.entityName+"."}))};t.setRow=function(n){t.onSetRow({id:n})};t.setColumn=function(n,i){t.onSetColumn({entity:n,id:i})};t.getUrl=function(){var i="",r,u,n;if(t.query){r=[];for(u in t.query)r.push(encodeURIComponent(u)+"="+encodeURIComponent(t.query[u]));i=r.join("&")}return t.sortByPropertyName||t.tableConfiguration.sortByPropertyName?t.sortByPropertyName||(t.sortByPropertyName=t.tableConfiguration.sortByPropertyName):t.sortByPropertyName=t.tableConfiguration.columns[0].propertyName,t.sortDirection||t.tableConfiguration.sortDirection?t.sortDirection||(t.sortDirection=t.tableConfiguration.sortDirection):t.sortDirection="asc",n="api/"+t.tableConfiguration.entityName+"?Skip="+t.skip+"&Take="+t.pageSize+"&SortBy="+t.sortByPropertyName+"&SortDirection="+t.sortDirection,t.tableConfiguration.secondaryKey&&(n=n+"&SecondaryKey="+t.tableConfiguration.secondaryKey),t.tableConfiguration.filterKey&&(n=n+"&FilterKey="+t.tableConfiguration.filterKey),i&&(n=n+"&"+i),n};t.sortBy=function(n){t.sortByPropertyName!=n?(t.sortByPropertyName=n,t.sortDirection="asc"):t.sortDirection=t.sortDirection=="asc"?"desc":"asc";t.getRows(1)};t.pageChanged=function(){t.getRows(t.searchGrid.currentPage)};t.$watch("enabled",function(){t.getRows(1)});t.$watch("query",function(){t.getRows(1)},!0);t.getColumnStyle=function(n){var e=0,u=0,o=-1,i=-1,r,f;return t.tableConfiguration.columns.forEach(function(t){o++;t.percentWidth&&(u=parseInt(u,10)+parseInt(t.percentWidth,10),e++,t.propertyName==n&&(i=o))}),r=100-u,r=r/(t.tableConfiguration.columns.length-e),f=i!=-1&&t.tableConfiguration.columns[i].percentWidth?{width:t.tableConfiguration.columns[i].percentWidth+"%"}:{width:r+"%"},n!=t.sortByPropertyName&&(f.background_color="transparent"),f};t.getReservedColumnWidth=function(n,t){console.log("a["+t+"] = "+n)}}]}}])