"use strict"; angular.module("vocabulary") .component("internationalStandards", { templateUrl: "/js/redesign-angular/standardsAndCorrelations/standards/international-standards.html", controller: "InternationalStandardsController" }) .controller("InternationalStandardsController", ["standardsAndCorrelationsService", "$sce", function (standardsAndCorrelationsService, $sce) { var ctrl = this; this.$onInit = init; ctrl.edGateUrl = ""; ctrl.haveEdGateUrl = false; function init() { standardsAndCorrelationsService.setActiveStandardsCategory('international'); ctrl.haveEdGateUrl = false; ctrl.setSelectedCountry('ca'); } function toggleEdGateDisplayOff(){ ctrl.edGateUrl = ""; ctrl.haveEdGateUrl = false; } ctrl.setSelectedCountry = function(country){ if(ctrl.selectedCountry !== country) { ctrl.selectedCountry = country; ctrl.gradeList = standardsAndCorrelationsService.getGradeListForCountry(country); if(ctrl.gradeList !== null){ ctrl.selectedGrade = ctrl.gradeList[0].value; } ctrl.statesList = standardsAndCorrelationsService.getStatesForCountry(country); if(ctrl.statesList !== null ){ ctrl.selectedState = ctrl.statesList[0].value; ctrl.showStatesDropdown = true; }else{ ctrl.showStatesDropdown = false; if(ctrl.selectedCountry === 'cefr'){ ctrl.selectedState = 'cef'; } if(ctrl.selectedCountry === 'uae'){ ctrl.selectedState = 'uaels'; } } toggleEdGateDisplayOff(); } }; ctrl.isSelectedCountry = function(country){ return ctrl.selectedCountry === country; }; ctrl.changeGrade = function(){ toggleEdGateDisplayOff(); }; ctrl.changeState = function(){ toggleEdGateDisplayOff(); }; ctrl.setSelectedState = function(value){ if(ctrl.selectedState !== value){ ctrl.selectedState = value; ctrl.changeState(); } }; ctrl.updateStandards = function(){ console.log ("selected grade is:" + ctrl.selectedGrade ); console.log("selected country is: " + ctrl.selectedCountry); console.log("selected state is: " + ctrl.selectedState); var subject = 'LA'; if(ctrl.selectedCountry === 'cefr'){ subject = 'EL'; } ctrl.edGateUrl = $sce.trustAsResourceUrl(standardsAndCorrelationsService.getRequestUrl(ctrl.selectedGrade, ctrl.selectedState, subject)); ctrl.haveEdGateUrl = true; } } ]);