diff --git a/400-SOURCECODE/AIAHTML5.Web/app/controllers/AIController.js b/400-SOURCECODE/AIAHTML5.Web/app/controllers/AIController.js index 38990b7..28bcf8f 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/controllers/AIController.js +++ b/400-SOURCECODE/AIAHTML5.Web/app/controllers/AIController.js @@ -17,16 +17,103 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout SearchTextByAlphabet: '', }; + $(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; + var ImageCount = $rootScope.getLocalStorageValue("ImageCount"); + if (typeof (searchByText) !== "undefined" && searchByText !== null && searchByText !== '') { + $scope.query.SearchText = searchByText; + } + else if (typeof (searchTextByAlphabet) !== "undefined" && searchTextByAlphabet !== null && searchTextByAlphabet !== '') { + $scope.query.SearchTextByAlphabet = searchTextByAlphabet; + } + else { + $scope.query.SearchTextByAlphabet = ""; + } + + if ($scope.query.SearchText == "" && $scope.query.SearchTextByAlphabet == "") { + + $scope.LoadAIJsonData(Count); + $scope.loadAllAI(Count); + } + else if ($scope.query.SearchTextByAlphabet != "" || $scope.query.SearchText == "") { + $scope.ApplySearchByAlphabet($scope.query.SearchTextByAlphabet); + } + else { + $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 () { + if ($(window).scrollTop() == $(document).height() - $(window).height()) { + Count += 100; + var ImageCount = $rootScope.getLocalStorageValue("ImageCount"); + if (typeof (searchByText) !== "undefined" && searchByText !== null && searchByText !== '') { + $scope.query.SearchText = searchByText; + } + else if (typeof (searchTextByAlphabet) !== "undefined" && searchTextByAlphabet !== null && searchTextByAlphabet !== '') { + $scope.query.SearchTextByAlphabet = searchTextByAlphabet; + } + else { + $scope.query.SearchTextByAlphabet = ""; + } + + if ($scope.query.SearchText == "" && $scope.query.SearchTextByAlphabet == "") { + + $scope.LoadAIJsonData(Count); + $scope.loadAllAI(Count); + } + else if ($scope.query.SearchTextByAlphabet != "" || $scope.query.SearchText == "") { + $scope.ApplySearchByAlphabet($scope.query.SearchTextByAlphabet ); + } + else { + $scope.ApplySearch($scope.query); + } + } + }); + + }); + $scope.setActiveTab = function (tabToSet) { $scope.activeTab = tabToSet; localStorage.setItem("currentAITabView", $scope.activeTab); + var ImageCount = $rootScope.getLocalStorageValue("ImageCount"); + 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); + } + else { + $('#' + $rootScope.getLocalStorageValue("currentAIImageId")).find('.thumbnail').addClass('HightLightThumbnail'); + $('#' + $rootScope.getLocalStorageValue("currentAIImageId")).removeClass('selected'); + $scope.loadAllAI(ImageCount); + } }; $scope.$on('$viewContentLoaded', function (event) { + var ImageCount = $rootScope.getLocalStorageValue("ImageCount"); + if ($rootScope.refreshcheck == null) { $location.path('/'); } + // code that will be executed ... // every time this view is loaded @@ -41,7 +128,7 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout $rootScope.currentActiveModuleTitle = selectedModuleName; }) - $scope.LoadAIJsonData(); + $scope.LoadAIJsonData(ImageCount); $scope.scroll(); //push the details of open module in array $rootScope.openModules $rootScope.openModules.push({ "ModuleId": 13 }); @@ -49,13 +136,13 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout //set the local storage var curtab = $rootScope.getLocalStorageValue("currentAITabView"); - if (curtab == 2) { + if (curtab == 2) { $scope.setActiveTab(2); var curSelectedRowId = $rootScope.getLocalStorageValue("AISelectedRowId"); if (typeof (curSelectedRowId) !== "undefined" && curSelectedRowId !== null && curSelectedRowId !== '') { $scope.reRunSearchOnLoad(); $scope.idSelected = curSelectedRowId; - $scope.ReloadListViewImageDiv($scope.idSelected); + $scope.ReloadListViewImageDiv($scope.idSelected, ImageCount); } else { $scope.reRunSearchOnLoad() @@ -73,6 +160,7 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout var searchByText = $rootScope.getLocalStorageValue("SearchText"); var searchTextByAlphabet = $rootScope.getLocalStorageValue("SearchByAlphabet"); + var ImageCount = $rootScope.getLocalStorageValue("ImageCount"); if (typeof (searchByText) !== "undefined" && searchByText !== null && searchByText !== '') { $scope.query.SearchText = searchByText; @@ -86,7 +174,7 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout if ($scope.query.SearchText == "" && $scope.query.SearchTextByAlphabet == "") { - $scope.loadAllAI(); + $scope.loadAllAI(ImageCount); } else if ($scope.query.SearchTextByAlphabet != "" || $scope.query.SearchText == "") { $scope.ApplySearchByAlphabet($scope.query.SearchTextByAlphabet); @@ -97,8 +185,8 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout } - $scope.LoadAIJsonData = function () { - $('ul li a').removeAttr("style"); + $scope.LoadAIJsonData = function (ImageCount) { + $('ul li span').removeAttr("style"); var promise = DataService.getJson('~/../content/data/json/ai/ai_dat_contentlist.json') promise.then( function (result) { @@ -106,7 +194,7 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout $scope.selectedAIListViewData = new jinqJs() .from($scope.IllustrationData.root.AIData) .orderBy([{ field: '_Title', sort: 'asc' }]) - .select(); + .select().slice(0, ImageCount); }, function (error) { @@ -118,13 +206,17 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout }; - $scope.loadAllAI = function () { + $scope.loadAllAI = function (ImageCount) { $rootScope.isLoading = true; localStorage.setItem("SearchText", ''); localStorage.setItem("SearchByAlphabet", ''); - $('ul li a').removeAttr("style"); + $('ul li span').removeAttr("style"); $('#aiSpinner').css('visibility', 'visible'); $('#aiSpinner').css('zIndex', '20000'); + if ($location.url() == "/ADAM-images") + { + $scope.DisableUI(); + } var promise = DataService.getJson('~/../content/data/json/ai/ai_dat_contentlist.json') promise.then( function (result) { @@ -133,7 +225,7 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout $scope.selectedAIListViewData = new jinqJs() .from($scope.IllustrationData.root.AIData) .orderBy([{ field: '_Title', sort: 'asc' }]) - .select(); + .select().slice(0,ImageCount); //console.log($scope.selectedAIListViewData); @@ -149,12 +241,18 @@ 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') }); + //$('html, body').animate({ scrollTop: $rootScope.getLocalStorageValue('AIGridViewScroll') }); } }, 100); $rootScope.isLoading = false; $('#aiSpinner').css('visibility', 'hidden'); + if ($location.url() == "/ADAM-images") { + setTimeout(function () { + $scope.EnableUI(); + }, 10); + } + }, function (error) { @@ -177,7 +275,8 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout //Set the vertical scroll value of the table. var y = $('#ListViewDiv').scrollTop(); localStorage.setItem("AIListViewScroll", y); - + //$('#' + id).find('.thumbnail').addClass('HightLightThumbnail'); + localStorage.setItem("currentAIImageId", id); $scope.hiderow = true; if ($scope.filterstring == false) { @@ -206,20 +305,18 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout $scope.SelectedAITitle = SelectedAIthumbImage[0]._Title; } + } }; $scope.Reset = function (query) { - $('ul li a').removeAttr("style"); + $('ul li span').removeAttr("style"); query.SearchText = ""; - - - //set localstorage values localStorage.setItem("SearchText", ''); localStorage.setItem("SearchByAlphabet", ''); localStorage.setItem("AIListViewScroll", ''); - + var ImageCount = $rootScope.getLocalStorageValue("ImageCount"); if ($('.selected').hasClass("selected")) { $('.selected').removeClass("selected"); } $('#ListViewDiv').scrollTop(0); @@ -230,11 +327,11 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout while ($scope.searchAIListViewData.length) { $scope.searchAIListViewData.pop(); } - $scope.loadAllAI(); + $scope.loadAllAI(ImageCount); } $scope.ApplySearch = function (query) { - $('ul li a').removeAttr("style"); + $('ul li span').removeAttr("style"); var currentSearchtext = $rootScope.getLocalStorageValue("SearchText"); localStorage.setItem("SearchText", ''); if (currentSearchtext == "undefined" || (currentSearchtext == null || currentSearchtext == "")) { @@ -247,29 +344,22 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout } $rootScope.isLoading = true; - $('#spinner').css('visibility', 'visible'); - + $('#aiSpinner').css('visibility', 'visible'); + $scope.DisableUI(); $rootScope.isLoading = true; $('#spinner').css('visibility', 'visible'); - $scope.filterstring = true; - while ($scope.searchAIListViewData.length) { - $scope.searchAIListViewData.pop(); - } - - - + //while ($scope.searchAIListViewData.length) { + // $scope.searchAIListViewData.pop(); + //} if (typeof (query.SearchText) !== "undefined" && (query.SearchText !== null && query.SearchText !== "")) { - localStorage.setItem("SearchText", query.SearchText); - } else { localStorage.setItem("SearchText", ''); - } var promise = DataService.getJson('~/../content/data/json/ai/ai_dat_contentlist.json') @@ -294,13 +384,11 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout if (posbodyregion > -1) { selectimg = true; //count = count + 1; - } else { selectimg = false; //count = count - 1; } - } if (selectimg === true) { @@ -421,12 +509,10 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout $compile($el)($scope); - $(".sidebar").mCustomScrollbar({ - autoHideScrollbar: true, - //theme:"rounded" - }); - - + //$(".sidebar").mCustomScrollbar({ + // autoHideScrollbar: true, + // //theme:"rounded" + //}); $scope.searchAIListViewData.push( { "_id": value._id, @@ -434,8 +520,6 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout "_Title": value._Title, "_contentImage": value._contentImage, "_ThumbnailImage": value._ThumbnailImage, - - }); } }); @@ -447,9 +531,13 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout $('table > #ListViewDiv > #searchItem').remove(); $('#ListViewDiv').append('
' + value._Title + '