From f6baf974af9bcdeaf38d753a5a366c4560ede8cc Mon Sep 17 00:00:00 2001 From: nikita Date: Fri, 15 Feb 2019 12:26:58 +0530 Subject: [PATCH] added correct code --- 400-SOURCECODE/AIAHTML5.Web/app/controllers/AIController.js | 251 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 1 file changed, 70 insertions(+), 181 deletions(-) diff --git a/400-SOURCECODE/AIAHTML5.Web/app/controllers/AIController.js b/400-SOURCECODE/AIAHTML5.Web/app/controllers/AIController.js index 28bcf8f..19d0c66 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/controllers/AIController.js +++ b/400-SOURCECODE/AIAHTML5.Web/app/controllers/AIController.js @@ -18,39 +18,39 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout }; $(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); - } + $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; } - }); - }, 10); + 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 () { @@ -78,14 +78,14 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout $scope.loadAllAI(Count); } else if ($scope.query.SearchTextByAlphabet != "" || $scope.query.SearchText == "") { - $scope.ApplySearchByAlphabet($scope.query.SearchTextByAlphabet ); + $scope.ApplySearchByAlphabet($scope.query.SearchTextByAlphabet); } else { $scope.ApplySearch($scope.query); - } + } } }); - + }); $scope.setActiveTab = function (tabToSet) { @@ -99,7 +99,7 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout var selectedImageId = $rootScope.getLocalStorageValue("currentAIImageId"); $scope.ReloadListViewImageDiv(selectedImageId, ImageCount); } - else { + else { $('#' + $rootScope.getLocalStorageValue("currentAIImageId")).find('.thumbnail').addClass('HightLightThumbnail'); $('#' + $rootScope.getLocalStorageValue("currentAIImageId")).removeClass('selected'); $scope.loadAllAI(ImageCount); @@ -136,7 +136,7 @@ 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 !== '') { @@ -213,8 +213,7 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout $('ul li span').removeAttr("style"); $('#aiSpinner').css('visibility', 'visible'); $('#aiSpinner').css('zIndex', '20000'); - if ($location.url() == "/ADAM-images") - { + if ($location.url() == "/ADAM-images") { $scope.DisableUI(); } var promise = DataService.getJson('~/../content/data/json/ai/ai_dat_contentlist.json') @@ -225,7 +224,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().slice(0,ImageCount); + .select().slice(0, ImageCount); //console.log($scope.selectedAIListViewData); @@ -252,7 +251,7 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout $scope.EnableUI(); }, 10); } - + }, function (error) { @@ -305,7 +304,7 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout $scope.SelectedAITitle = SelectedAIthumbImage[0]._Title; } - + } }; @@ -346,9 +345,6 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout $rootScope.isLoading = true; $('#aiSpinner').css('visibility', 'visible'); $scope.DisableUI(); - $rootScope.isLoading = true; - $('#spinner').css('visibility', 'visible'); - $scope.filterstring = true; //while ($scope.searchAIListViewData.length) { @@ -394,7 +390,7 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout if (selectimg === true) { $scope.imagePath = "~/../content/images/ai/thumbnails/" + value._ThumbnailImage; - var $el = $('
' + var $el = $('
' + '
' + '' + '

' + value._Title + '

').appendTo('#grid-view'); @@ -402,113 +398,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, - //"_ImageId": value._ImageId, - "_Title": value._Title, - "_contentImage": value._contentImage, - "_ThumbnailImage": value._ThumbnailImage, - - - }); - } - }); - $('table > #ListViewDiv > #searchItem').remove(); - //Show Error Message in case of gridview if no data is found - if ($scope.searchAIListViewData.length == 0) { - var $el = $('
No illustration found for the selected search criteria!
').appendTo('#grid-view'); - $compile($el)($scope); - $('table > #ListViewDiv > #searchItem').remove(); - - $('#ListViewDiv').append('No illustration found for the selected search criteria!'); - } - $rootScope.isLoading = false; - $('#spinner').css('visibility', 'hidden'); - - }, - function (error) { - // handle errors here - console.log(' $scope.IllustrationData = ' + error.statusText); - } - ); - } - - - - $scope.ApplySearchByAlphabet = function (SearchText) { - - $rootScope.isLoading = true; - $('#spinner').css('visibility', 'visible'); - - $scope.filterstring = true; - - while ($scope.searchAIListViewData.length) { - $scope.searchAIListViewData.pop(); - } - - - - - if (typeof (SearchText) !== "undefined" && (SearchText !== null && SearchText !== "")) { - - localStorage.setItem("AIImageId", SearchText); - - } - else { - localStorage.setItem("AIImageId", ''); - - } - - var promise = DataService.getJson('~/../content/data/json/ai/ai_dat_contentlist.json') - promise.then( - function (result) { - $scope.IllustrationData = result; - - $scope.selectedAIListViewData = new jinqJs() - .from($scope.IllustrationData.root.AIData) - .orderBy([{ field: '_Title', sort: 'asc' }]) - .select(); - - $('#grid-view').empty(); - - angular.forEach($scope.selectedAIListViewData, function (value, key) { - - var selectimg = true; - //var count = 0; - if (typeof (SearchText) !== "undefined" && (SearchText !== null && SearchText !== "")) { - - var firstChar = value._Title[0]; - - if (firstChar == SearchText) { - selectimg = true; - //count = count + 1; - - } - else { - selectimg = false; - //count = count - 1; - } - - } - - if (selectimg === true) { - $scope.imagePath = "~/../content/images/ai/thumbnails/" + value._ThumbnailImage; - - var $el = $('
' - + '
' - + '' - + '

' + value._Title + '

').appendTo('#grid-view'); - - $compile($el)($scope); - - //$(".sidebar").mCustomScrollbar({ // autoHideScrollbar: true, // //theme:"rounded" @@ -540,14 +429,14 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout }, 10); }, - function (error) { - // handle errors here - console.log(' $scope.IllustrationData = ' + error.statusText); - } - ); + function (error) { + // handle errors here + console.log(' $scope.IllustrationData = ' + error.statusText); + } + ); } $scope.DisableUI = function () { - + $('#imgParent').css('z-index', '1'); document.getElementById("imgParent").style.pointerEvents = "none"; document.getElementById("imgParent").style.opacity = "0.5"; @@ -564,7 +453,7 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout $rootScope.isLoading = true; $('#aiSpinner').css('visibility', 'visible'); $scope.DisableUI(); - $('ul li span').removeAttr("style"); + $('ul li span').removeAttr("style"); $('#' + $rootScope.SearchTextByAlphabet).css({ "color": "white", "background-color": "#1B92D0" }); $scope.filterstring = true; if (typeof (SearchTextByAlphabet) !== "undefined" && (SearchTextByAlphabet !== null && SearchTextByAlphabet !== "")) { @@ -581,7 +470,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(); + .orderBy([{ field: '_Title', sort: 'asc' }]).select(); $('#grid-view').empty(); @@ -601,7 +490,7 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout if (selectimg === true) { $scope.imagePath = "~/../content/images/ai/thumbnails/" + value._ThumbnailImage; - var $el = $('
' + var $el = $('
' + '
' + '' + '

' + value._Title + '

').appendTo('#grid-view'); @@ -629,17 +518,17 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout } $rootScope.isLoading = false; - setTimeout(function () { - $scope.EnableUI(); - }, 10); + setTimeout(function () { + $scope.EnableUI(); + }, 10); }, function (error) { console.log(' $scope.IllustrationData = ' + error.statusText); } - + ); - - + + } @@ -704,9 +593,9 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout .select('_contentImage'); $scope.clickedAIImage = "~/../content/images/ai/images/" + clickedAIImage[0]._contentImage; - + if (clickedAIImage.length > 0) { - + $.jsPanel({ id: 'aiImagePanel', selector: '.aiView', @@ -724,7 +613,7 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout title: $rootScope.getLocalStorageValue("currentViewTitle"), position: { top: 70, - left: 20, + left: 20, }, size: { width: $(window).outerWidth() - 20, height: $(window).outerHeight() - 110 }, @@ -732,7 +621,7 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout }); $('#canvasDiv img').load(function () { - + $rootScope.isLoading = false; $('#aiSpinner').css('visibility', 'hidden'); var canvas = document.getElementById("canvas"); @@ -746,14 +635,14 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout "module": $rootScope.currentActiveModuleTitle, "bodyView": tittle, "state": 'max', "BodyViewId": $rootScope.currentAIImageId, "slug": $rootScope.currentSlug }); - - $("#aiImagePanel .img-thumbnail").css("min-height", $("#aiImagePanel .jsPanel-content").height()); + + $("#aiImagePanel .img-thumbnail").css("min-height", $("#aiImagePanel .jsPanel-content").height()); $('.jsPanel-content .jsPanel-theme-success').css('overflow-y', 'auto !important') var jspContentHeight = $('.jsPanel-content').height(); - - - + + + } }, function (error) { @@ -764,7 +653,7 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout // console.log($rootScope.OpenAdamImages); $('#AIView').css("height", $(window).outerHeight()); - $('#AIView').css("width", $(window).outerWidth()); + $('#AIView').css("width", $(window).outerWidth()); } $scope.$on('annotationToolEvent', function (event, data) { @@ -776,12 +665,12 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout $("#canvas").css("display", "block"); $("#canvasPaint").css("display", "block"); - + $rootScope.onDrawingCanvasClick(); $rootScope.FreeStylePaint(); }); - $scope.ReloadListViewImageDiv = function (id,imgCount) { + $scope.ReloadListViewImageDiv = function (id, imgCount) { //console.log(id); $scope.idSelected = id; $scope.hiderow = true; @@ -810,7 +699,7 @@ function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout var curAIListViewScroll = $rootScope.getLocalStorageValue("AIListViewScroll"); if (typeof (curAIListViewScroll) !== "undefined" && curAIListViewScroll !== null && curAIListViewScroll !== '') { if (typeof InstallTrigger !== 'undefined') { - $('#ListViewDiv').animate({ scrollTop: $rootScope.getLocalStorageValue("AIListViewScroll") }); + $('#ListViewDiv').animate({ scrollTop: $rootScope.getLocalStorageValue("AIListViewScroll") }); } else { $('#ListViewDiv').scrollTop($rootScope.getLocalStorageValue("AIListViewScroll")); -- libgit2 0.21.4