Commit 1a963976aeafee9e7e146424228d87bbf9a1b718

Authored by Nikita Kulshreshtha
2 parents 8ae0cd10 8d552386

Merge branch 'settingPopupIssue_2_Merge' into Develop

400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js
... ... @@ -507,13 +507,13 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic
507 507 $rootScope.secondlaxtext = $("#secondLax option:selected").text();
508 508  
509 509 });
510   -
  510 +
511 511 $("#laxiconLangRemove").click(function () {
512 512 if ($rootScope.isActiveLexiconLanguageClicked == true) {
513 513 $rootScope.isActiveLexiconLanguageClicked = false;
514 514 $("#secondLax :selected").remove();
515 515 $('#lexiconLangDropdown').append('<option val="' + $rootScope.secondlaxdid + '">' + $rootScope.secondlaxtext + '</option>');
516   - // $rootScope.lexiconLanguageArray.splice($rootScope.secondlaxtext, 1);
  516 + // $rootScope.lexiconLanguageArray.splice($rootScope.secondlaxtext, 1);
517 517 $rootScope.lexiconLanguageArray = [];
518 518 $("#secondLax > option").each(function () {
519 519 $rootScope.lexiconLanguageArray.push({ id: $(this).attr("val"), language: this.value });
... ... @@ -1013,7 +1013,10 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic
1013 1013 $('#modal-settings').css("display", "block");
1014 1014 $("#modelsettingsbackground").css("display", "block");
1015 1015 }
1016   -
  1016 +
  1017 + $rootScope.lexiconLanguageArrayLength = $rootScope.lexiconLanguageArray.length;
  1018 + $rootScope.lexiconPrimaryLanguage = $("#primarylaxican").val();
  1019 + $rootScope.primaryLangID = $('#primarylaxican').attr("name");
1017 1020 }
1018 1021  
1019 1022 //----Annotation Toolbar: Jcanvas-----
... ... @@ -3434,22 +3437,30 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic
3434 3437 $rootScope.setModestySettings(formsetting.modesty);
3435 3438  
3436 3439 }
3437   -
  3440 + $rootScope.isApplyBtnClicked = false;
3438 3441 $rootScope.CloseSetting = function () {
3439   -
  3442 +
3440 3443 $rootScope.setEthncitySettings($rootScope.globalSetting.ethnicity);
3441 3444 $rootScope.setModestySettings($rootScope.globalSetting.modesty);
3442   -
  3445 + if ($rootScope.isApplyBtnClicked == false) {
  3446 +
  3447 + $rootScope.deSelectLanguageOptions();
  3448 + }
  3449 + else {
  3450 +
  3451 + $rootScope.isApplyBtnClicked = false;
  3452 + }
3443 3453 $('#modal-settings').css("display", "none");
3444 3454 $("#modelsettingsbackground").css("display", "none");
3445 3455 }
3446 3456  
3447 3457 $rootScope.UpdateAndCloseSetting = function (setting) {
3448   - // debugger;
  3458 +
3449 3459 $rootScope.UpdateSetting(setting);
3450 3460 if ($rootScope.MenuModuleName == "DA" || $rootScope.MenuModuleName == "AA") {
3451 3461 $rootScope.loadSearchData();
3452 3462 }
  3463 + $rootScope.isApplyBtnClicked = false;
3453 3464 //$timeout(function () {
3454 3465 $('#modal-settings').css("display", "none");
3455 3466 $("#modelsettingsbackground").css("display", "none");
... ... @@ -3457,18 +3468,75 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic
3457 3468 if ($rootScope.MenuModuleName == "DA" || $rootScope.MenuModuleName == "AA") {
3458 3469 $("#setting-spinner").css("display", "block");
3459 3470 }
  3471 +
  3472 + $rootScope.lexiconLanguageArrayLength = $rootScope.lexiconLanguageArray.length;
3460 3473  
3461 3474 // }, 6000);
3462 3475 };
3463 3476  
3464 3477  
3465 3478 $rootScope.CloseSettingPopup = function () {
  3479 + if ($rootScope.isApplyBtnClicked == false) {
  3480 + $rootScope.deSelectLanguageOptions();
  3481 + }
  3482 + else {
  3483 + $rootScope.isApplyBtnClicked = false;
  3484 + }
3466 3485 $('#modal-settings').css("display", "none");
3467 3486 $("#modelsettingsbackground").css("display", "none");
3468 3487 }
3469 3488  
  3489 + $rootScope.deSelectLanguageOptions = function () {
  3490 +
  3491 + var languageDifference = ($rootScope.lexiconLanguageArrayLength) - ($rootScope.lexiconLanguageArray.length);
  3492 + if (languageDifference > 0) {
  3493 + for (var i = 0; i <= $rootScope.lexiconRemovedLanguage.length - 1; i++) {
  3494 + $("#lexiconLangDropdown option").each(function () {
  3495 + if ($rootScope.lexiconRemovedLanguage[i].language == $(this).val()) {
  3496 + $(this).remove();
  3497 + $('#secondLax').append('<option val="' + $rootScope.lexiconRemovedLanguage[i].id + '">' + $rootScope.lexiconRemovedLanguage[i].language + '</option>');
  3498 + $rootScope.lexiconLanguageArray.push({ "id": $rootScope.lexiconRemovedLanguage[i].id, "language": $rootScope.lexiconRemovedLanguage[i].language });
  3499 + }
  3500 + });
  3501 + }
  3502 + }
  3503 + else if (languageDifference < 0) {
  3504 + languageDifference = Math.abs(languageDifference);
  3505 + for (var i = 1; i <= languageDifference; i++) {
  3506 + var lexiconArrayLength = $rootScope.lexiconLanguageArray.length;
  3507 +
  3508 + $("#secondLax option").each(function () {
  3509 + if ($rootScope.lexiconLanguageArray[lexiconArrayLength - 1].language == $(this).val()) {
  3510 + $(this).remove();
  3511 + }
  3512 +
  3513 + })
  3514 + $('#lexiconLangDropdown').append('<option val="' + $rootScope.lexiconLanguageArray[lexiconArrayLength - 1].id + '">' + $rootScope.lexiconLanguageArray[lexiconArrayLength - 1].language + '</option>');
  3515 + $rootScope.lexiconLanguageArray.pop();
  3516 + }
  3517 + }
  3518 +
3470 3519  
  3520 + if ($rootScope.lexiconPrimaryLanguage == $("#primarylaxican").val()) {
  3521 + // alert("same name");
  3522 + }
  3523 + else {
  3524 + $rootScope.lexiconLanguageArray[0].id = $rootScope.primaryLangID;
  3525 + $rootScope.lexiconLanguageArray[0].language = $rootScope.lexiconPrimaryLanguage;
  3526 + $("#lexiconLangDropdown option").each(function () {
  3527 + if ($rootScope.lexiconPrimaryLanguage == $(this).val()) {
  3528 + $(this).remove();
  3529 + }
  3530 + })
  3531 + $('#lexiconLangDropdown').append('<option val="' + $('#primarylaxican').attr("name") + '">' + $("#primarylaxican").val() + '</option>');
  3532 + $("#primarylaxican").val($rootScope.lexiconPrimaryLanguage);
  3533 + $('#primarylaxican').attr("name", $rootScope.primaryLangID);
  3534 + }
  3535 + }
  3536 +
  3537 +
3471 3538 $rootScope.UpdateSetting = function (setting) {
  3539 + $rootScope.isApplyBtnClicked = true;
3472 3540 var isReloadingViewRequired = false;
3473 3541 //1.
3474 3542 if (typeof (setting.ethnicity) !== "undefined" && setting.ethnicity !== null) {
... ... @@ -3525,10 +3593,13 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic
3525 3593 }
3526 3594 else {
3527 3595  
3528   - $('#modal-settings').css("display", "none");
3529   - $("#modelsettingsbackground").css("display", "none");
  3596 + // $('#modal-settings').css("display", "none");
  3597 + // $("#modelsettingsbackground").css("display", "none");
3530 3598 }
3531   -
  3599 + $rootScope.lexiconRemovedLanguage = [];
  3600 + $("#secondLax option").each(function () {
  3601 + $rootScope.lexiconRemovedLanguage.push({ "id": $(this).attr("val"), "language": $(this).val() });
  3602 + });
3532 3603 };
3533 3604  
3534 3605  
... ...