diff --git a/400-SOURCECODE/AIAHTML5.Web/app/controllers/AIController.js b/400-SOURCECODE/AIAHTML5.Web/app/controllers/AIController.js index 19d0c66..fe9dfdd 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/controllers/AIController.js +++ b/400-SOURCECODE/AIAHTML5.Web/app/controllers/AIController.js @@ -15,17 +15,21 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout $scope.query = { SearchText: '', SearchTextByAlphabet: '', + SelectedDiv: '' }; + var Count = 200; + localStorage.setItem("ImageCount", Count); + var searchByText = $rootScope.getLocalStorageValue("SearchText"); + var searchTextByAlphabet = $rootScope.getLocalStorageValue("SearchByAlphabet"); + var SelectCurrTab = $rootScope.getLocalStorageValue("currentAITabView"); + + $timeout(function () { + $("#ListViewDiv").on('scroll', function () { + if ($scope.query.SelectedDiv == 2) { - $(document).ready(function () { - $timeout(function () { - var Count = 200; - localStorage.setItem("ImageCount", Count); - var searchByText = $rootScope.getLocalStorageValue("SearchText"); - var searchTextByAlphabet = $rootScope.getLocalStorageValue("SearchByAlphabet"); - $("#ListViewDiv").on('scroll', function () { if ($(this).scrollTop() + $(this).innerHeight() >= $(this)[0].scrollHeight - 10) { Count += 100; + //$(window).scrollTop(0); var ImageCount = $rootScope.getLocalStorageValue("ImageCount"); if (typeof (searchByText) !== "undefined" && searchByText !== null && searchByText !== '') { $scope.query.SearchText = searchByText; @@ -49,16 +53,13 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout $scope.ApplySearch($scope.query); } } - }); - }, 10); - }); + } + }); - $(document).ready(function () { - var Count = 200; - localStorage.setItem("ImageCount", Count); - var searchByText = $rootScope.getLocalStorageValue("SearchText"); - var searchTextByAlphabet = $rootScope.getLocalStorageValue("SearchByAlphabet"); - $(window).scroll(function () { + }, 10); + + $(window).scroll(function () { + if ($scope.query.SelectedDiv == 1) { if ($(window).scrollTop() == $(document).height() - $(window).height()) { Count += 100; var ImageCount = $rootScope.getLocalStorageValue("ImageCount"); @@ -84,25 +85,40 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout $scope.ApplySearch($scope.query); } } - }); - + } }); + $scope.setActiveTab = function (tabToSet) { $scope.activeTab = tabToSet; localStorage.setItem("currentAITabView", $scope.activeTab); var ImageCount = $rootScope.getLocalStorageValue("ImageCount"); + var searchText = $rootScope.getLocalStorageValue("SearchText"); if (tabToSet == 2) { var curSelectedRowId = $rootScope.getLocalStorageValue("AISelectedRowId"); $('#' + $rootScope.getLocalStorageValue("currentAIImageId")).addClass("selected"); $scope.idSelected = $rootScope.getLocalStorageValue("currentAIImageId"); var selectedImageId = $rootScope.getLocalStorageValue("currentAIImageId"); - $scope.ReloadListViewImageDiv(selectedImageId, ImageCount); + if (searchText != '') { + $scope.ApplySearch(searchText); + } + else { + $scope.ReloadListViewImageDiv(selectedImageId, ImageCount); + } + + $scope.query.SelectedDiv = tabToSet; } else { $('#' + $rootScope.getLocalStorageValue("currentAIImageId")).find('.thumbnail').addClass('HightLightThumbnail'); $('#' + $rootScope.getLocalStorageValue("currentAIImageId")).removeClass('selected'); - $scope.loadAllAI(ImageCount); + $scope.query.SelectedDiv = tabToSet; + if (searchText != '') { + $scope.ApplySearch(searchText); + } + else { + $scope.loadAllAI(ImageCount); + } + } }; @@ -202,8 +218,6 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout console.log(' $scope.IllustrationData = ' + error.statusText); } ); - - }; $scope.loadAllAI = function (ImageCount) { @@ -239,8 +253,8 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout $timeout(function () { $('#' + $rootScope.getLocalStorageValue("currentAIImageId")).find('.thumbnail').addClass('HightLightThumbnail'); - if ($rootScope.getLocalStorageValue('AIGridViewScroll') !== null && $location.url() == "/ADAM-images") { - //$('html, body').animate({ scrollTop: $rootScope.getLocalStorageValue('AIGridViewScroll') }); + if ($rootScope.getLocalStorageValue('AIGridViewScroll') !== null && $location.url() == "/ADAM-images" && $scope.query.SelectedDiv == 1) { + $('html, body').animate({ scrollTop: $rootScope.getLocalStorageValue('AIGridViewScroll') }); } }, 100); @@ -334,24 +348,22 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout var currentSearchtext = $rootScope.getLocalStorageValue("SearchText"); localStorage.setItem("SearchText", ''); if (currentSearchtext == "undefined" || (currentSearchtext == null || currentSearchtext == "")) { - if (query.SearchText == "undefined" || (query.SearchText == null || query.SearchText == "")) { + if ($scope.query.SearchText == "undefined" || ($scope.query.SearchText == null || $scope.query.SearchText == "")) { $rootScope.errorMessage = AIAConstants.PLEASE_ENTER_SEARCH_TEXT; $("#messageModal").modal('show'); - // alert("Please enter the text !") return false; } } + while ($scope.searchAIListViewData.length) { + $scope.searchAIListViewData.pop(); + } + $rootScope.isLoading = true; $('#aiSpinner').css('visibility', 'visible'); $scope.DisableUI(); $scope.filterstring = true; - - //while ($scope.searchAIListViewData.length) { - // $scope.searchAIListViewData.pop(); - //} - - if (typeof (query.SearchText) !== "undefined" && (query.SearchText !== null && query.SearchText !== "")) { + if (typeof ($scope.query.SearchText) !== "undefined" && ($scope.query.SearchText !== null && $scope.query.SearchText !== "")) { localStorage.setItem("SearchText", query.SearchText); } else { @@ -369,13 +381,12 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout .select(); $('#grid-view').empty(); - angular.forEach($scope.selectedAIListViewData, function (value, key) { var selectimg = true; //var count = 0; - if (typeof (query.SearchText) !== "undefined" && (query.SearchText !== null && query.SearchText !== "")) { - var SearchText = query.SearchText + if (typeof ($scope.query.SearchText) !== "undefined" && ($scope.query.SearchText !== null && $scope.query.SearchText !== "")) { + var SearchText = $scope.query.SearchText var posbodyregion = value._Title.toLowerCase().indexOf(SearchText.toLowerCase()); if (posbodyregion > -1) { selectimg = true; @@ -397,11 +408,6 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout $compile($el)($scope); - - //$(".sidebar").mCustomScrollbar({ - // autoHideScrollbar: true, - // //theme:"rounded" - //}); $scope.searchAIListViewData.push( { "_id": value._id, @@ -426,6 +432,7 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout $('#aiSpinner').css('visibility', 'hidden'); setTimeout(function () { $scope.EnableUI(); + }, 10); }, @@ -446,7 +453,6 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout document.getElementById("imgParent").style.pointerEvents = "auto"; document.getElementById("imgParent").style.opacity = "1.0"; } - $scope.counter = 1; $scope.ApplySearchByAlphabet = function (SearchTextByAlphabet) { $rootScope.SearchTextByAlphabet = SearchTextByAlphabet @@ -462,7 +468,6 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout else { localStorage.setItem("SearchByAlphabet", ''); } - var promise = DataService.getJson('~/../content/data/json/ai/ai_dat_contentlist.json') promise.then( function (result) { @@ -474,6 +479,7 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout $('#grid-view').empty(); + angular.forEach($scope.selectedAIListViewData, function (value, key) { var selectimg = true; @@ -677,8 +683,6 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout $rootScope.isLoading = true; $('#aiSpinner').css('visibility', 'visible'); $('#aiSpinner').css('zIndex', '20000'); - //$scope.DisableUI(); - var promise = DataService.getJson('~/../content/data/json/ai/ai_dat_contentlist.json') promise.then( function (result) { @@ -708,9 +712,7 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout } $rootScope.isLoading = false; $('#aiSpinner').css('visibility', 'hidden'); - //setTimeout(function () { - // $scope.EnableUI(); - //}, 10); + }, function (error) { // handle errors here diff --git a/400-SOURCECODE/AIAHTML5.Web/app/views/ai/ai-view.html b/400-SOURCECODE/AIAHTML5.Web/app/views/ai/ai-view.html index 574d5f6..f05c2b8 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/views/ai/ai-view.html +++ b/400-SOURCECODE/AIAHTML5.Web/app/views/ai/ai-view.html @@ -8,47 +8,47 @@
- - - + @@ -97,7 +97,7 @@ -