diff --git a/400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js b/400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js index 4406e5c..3a61aac 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js +++ b/400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js @@ -507,13 +507,13 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic $rootScope.secondlaxtext = $("#secondLax option:selected").text(); }); - + $("#laxiconLangRemove").click(function () { if ($rootScope.isActiveLexiconLanguageClicked == true) { $rootScope.isActiveLexiconLanguageClicked = false; $("#secondLax :selected").remove(); $('#lexiconLangDropdown').append(''); - // $rootScope.lexiconLanguageArray.splice($rootScope.secondlaxtext, 1); + // $rootScope.lexiconLanguageArray.splice($rootScope.secondlaxtext, 1); $rootScope.lexiconLanguageArray = []; $("#secondLax > option").each(function () { $rootScope.lexiconLanguageArray.push({ id: $(this).attr("val"), language: this.value }); @@ -1013,7 +1013,10 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic $('#modal-settings').css("display", "block"); $("#modelsettingsbackground").css("display", "block"); } - + + $rootScope.lexiconLanguageArrayLength = $rootScope.lexiconLanguageArray.length; + $rootScope.lexiconPrimaryLanguage = $("#primarylaxican").val(); + $rootScope.primaryLangID = $('#primarylaxican').attr("name"); } //----Annotation Toolbar: Jcanvas----- @@ -3434,22 +3437,30 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic $rootScope.setModestySettings(formsetting.modesty); } - + $rootScope.isApplyBtnClicked = false; $rootScope.CloseSetting = function () { - + $rootScope.setEthncitySettings($rootScope.globalSetting.ethnicity); $rootScope.setModestySettings($rootScope.globalSetting.modesty); - + if ($rootScope.isApplyBtnClicked == false) { + + $rootScope.deSelectLanguageOptions(); + } + else { + + $rootScope.isApplyBtnClicked = false; + } $('#modal-settings').css("display", "none"); $("#modelsettingsbackground").css("display", "none"); } $rootScope.UpdateAndCloseSetting = function (setting) { - // debugger; + $rootScope.UpdateSetting(setting); if ($rootScope.MenuModuleName == "DA" || $rootScope.MenuModuleName == "AA") { $rootScope.loadSearchData(); } + $rootScope.isApplyBtnClicked = false; //$timeout(function () { $('#modal-settings').css("display", "none"); $("#modelsettingsbackground").css("display", "none"); @@ -3457,18 +3468,75 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic if ($rootScope.MenuModuleName == "DA" || $rootScope.MenuModuleName == "AA") { $("#setting-spinner").css("display", "block"); } + + $rootScope.lexiconLanguageArrayLength = $rootScope.lexiconLanguageArray.length; // }, 6000); }; $rootScope.CloseSettingPopup = function () { + if ($rootScope.isApplyBtnClicked == false) { + $rootScope.deSelectLanguageOptions(); + } + else { + $rootScope.isApplyBtnClicked = false; + } $('#modal-settings').css("display", "none"); $("#modelsettingsbackground").css("display", "none"); } + $rootScope.deSelectLanguageOptions = function () { + + var languageDifference = ($rootScope.lexiconLanguageArrayLength) - ($rootScope.lexiconLanguageArray.length); + if (languageDifference > 0) { + for (var i = 0; i <= $rootScope.lexiconRemovedLanguage.length - 1; i++) { + $("#lexiconLangDropdown option").each(function () { + if ($rootScope.lexiconRemovedLanguage[i].language == $(this).val()) { + $(this).remove(); + $('#secondLax').append(''); + $rootScope.lexiconLanguageArray.push({ "id": $rootScope.lexiconRemovedLanguage[i].id, "language": $rootScope.lexiconRemovedLanguage[i].language }); + } + }); + } + } + else if (languageDifference < 0) { + languageDifference = Math.abs(languageDifference); + for (var i = 1; i <= languageDifference; i++) { + var lexiconArrayLength = $rootScope.lexiconLanguageArray.length; + + $("#secondLax option").each(function () { + if ($rootScope.lexiconLanguageArray[lexiconArrayLength - 1].language == $(this).val()) { + $(this).remove(); + } + + }) + $('#lexiconLangDropdown').append(''); + $rootScope.lexiconLanguageArray.pop(); + } + } + + if ($rootScope.lexiconPrimaryLanguage == $("#primarylaxican").val()) { + // alert("same name"); + } + else { + $rootScope.lexiconLanguageArray[0].id = $rootScope.primaryLangID; + $rootScope.lexiconLanguageArray[0].language = $rootScope.lexiconPrimaryLanguage; + $("#lexiconLangDropdown option").each(function () { + if ($rootScope.lexiconPrimaryLanguage == $(this).val()) { + $(this).remove(); + } + }) + $('#lexiconLangDropdown').append(''); + $("#primarylaxican").val($rootScope.lexiconPrimaryLanguage); + $('#primarylaxican').attr("name", $rootScope.primaryLangID); + } + } + + $rootScope.UpdateSetting = function (setting) { + $rootScope.isApplyBtnClicked = true; var isReloadingViewRequired = false; //1. if (typeof (setting.ethnicity) !== "undefined" && setting.ethnicity !== null) { @@ -3525,10 +3593,13 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic } else { - $('#modal-settings').css("display", "none"); - $("#modelsettingsbackground").css("display", "none"); + // $('#modal-settings').css("display", "none"); + // $("#modelsettingsbackground").css("display", "none"); } - + $rootScope.lexiconRemovedLanguage = []; + $("#secondLax option").each(function () { + $rootScope.lexiconRemovedLanguage.push({ "id": $(this).attr("val"), "language": $(this).val() }); + }); };