diff --git a/400-SOURCECODE/AIAHTML5.Web/app/controllers/AIController.js b/400-SOURCECODE/AIAHTML5.Web/app/controllers/AIController.js index 02747a8..dd47505 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/controllers/AIController.js +++ b/400-SOURCECODE/AIAHTML5.Web/app/controllers/AIController.js @@ -16,31 +16,83 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout SearchText: '', SearchTextByAlphabet: '', }; + $(document).ready(function () { + $(window).on('scroll', '#ListViewDiv', function () { + console.log('scroll happened'); + alert("scroll fired"); + }); + $("#ListViewDiv").on('scroll', function () { + alert('Event worked'); + }); + }); + $("#ListViewDiv").on('scroll', function () { + alert('Event worked'); + }); + + + $(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.LoadAIJsonData(); - $scope.ReloadListViewImageDiv(selectedImageId); + $scope.LoadAIJsonData(ImageCount); + $scope.ReloadListViewImageDiv(selectedImageId, ImageCount); $scope.showItem(selectedImageId); } else { $('#' + $rootScope.getLocalStorageValue("currentAIImageId")).find('.thumbnail').addClass('HightLightThumbnail'); $('#' + $rootScope.getLocalStorageValue("currentAIImageId")).removeClass('selected'); - $scope.loadAllAI(); + $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 @@ -55,7 +107,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 }); @@ -69,7 +121,7 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout if (typeof (curSelectedRowId) !== "undefined" && curSelectedRowId !== null && curSelectedRowId !== '') { $scope.reRunSearchOnLoad(); $scope.idSelected = curSelectedRowId; - $scope.ReloadListViewImageDiv($scope.idSelected); + $scope.ReloadListViewImageDiv($scope.idSelected, ImageCount); } else { $scope.reRunSearchOnLoad() @@ -87,6 +139,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; @@ -101,7 +154,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 == "") { @@ -113,7 +166,7 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout } - $scope.LoadAIJsonData = function () { + $scope.LoadAIJsonData = function (ImageCount) { $('ul li a').removeAttr("style"); var promise = DataService.getJson('~/../content/data/json/ai/ai_dat_contentlist.json') promise.then( @@ -122,7 +175,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) { @@ -134,7 +187,7 @@ 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", ''); @@ -149,7 +202,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); @@ -165,7 +218,7 @@ 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); @@ -232,7 +285,7 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout localStorage.setItem("SearchText", ''); localStorage.setItem("SearchByAlphabet", ''); localStorage.setItem("AIListViewScroll", ''); - + var ImageCount = $rootScope.getLocalStorageValue("ImageCount"); if ($('.selected').hasClass("selected")) { $('.selected').removeClass("selected"); } $('#ListViewDiv').scrollTop(0); @@ -243,7 +296,7 @@ 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) { @@ -316,10 +369,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, @@ -411,10 +464,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, @@ -446,7 +499,7 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout $scope.scroll = function () { - $("html,body").scrollTop(0); + //$("html,body").scrollTop(0); } @@ -582,7 +635,7 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout $rootScope.FreeStylePaint(); }); - $scope.ReloadListViewImageDiv = function (id) { + $scope.ReloadListViewImageDiv = function (id,imgCount) { //console.log(id); $scope.idSelected = id; $scope.hiderow = true; @@ -599,7 +652,7 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout SelectedAIthumbImage = new jinqJs() .from($scope.IllustrationData.root.AIData) .where('_id = ' + id) - .select('_ThumbnailImage', '_id', '_Title'); + .select('_ThumbnailImage', '_id', '_Title').slice(0, imgCount); $scope.SelectedAIthumbImage = "~/../content/images/ai/thumbnails/" + SelectedAIthumbImage[0]._ThumbnailImage; $scope.SelectedAIId = SelectedAIthumbImage[0]._id;