AIA.controller("AIController", ["$scope", "$window", "$rootScope", "$compile", "$http", "$log", "$location", "$timeout", "pages", "DataService", "AIAConstants",
function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout, pages, DataService, AIAConstants) {
// $rootScope.currentActiveModuleTitle = pages[3].name;
$scope.showTabButton = true;
$scope.IllustrationData;
$scope.searchAIListViewData = [];
$scope.SelectedAIthumbImage = [];
$scope.SelectedAIImage = [];
$scope.SelectedAIId = [];
$scope.SelectedAITitle = [];
$scope.selectedAIListViewData = [];
$scope.filterstring = false;
$scope.idSelected;
$scope.srollListView;
$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");
//Commented by sandeep for fixed bugs related to ADAM Images
//$timeout(function () {
// $("#ListViewDiv").on('scroll', function () {
// var searchByText = $rootScope.getLocalStorageValue("SearchText");
// var searchTextByAlphabet = $rootScope.getLocalStorageValue("SearchByAlphabet");
// var SelectCurrTab = $rootScope.getLocalStorageValue("currentAITabView");
// if ($scope.query.SelectedDiv == 2) {
// 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;
// }
// 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);
//$(window).scroll(function () {
// var searchByText = $rootScope.getLocalStorageValue("SearchText");
// var searchTextByAlphabet = $rootScope.getLocalStorageValue("SearchByAlphabet");
// var SelectCurrTab = $rootScope.getLocalStorageValue("currentAITabView");
// if ($scope.query.SelectedDiv == 1) {
// 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, inderectCall) {
//Modified code by sandeep for fixed Bugs of ADAM Images
$scope.activeTab = tabToSet;
localStorage.setItem("currentAITabView", "");
localStorage.setItem("currentAITabView", $scope.activeTab);
var ImageCount = $rootScope.getLocalStorageValue("ImageCount");
var searchText = $rootScope.getLocalStorageValue("SearchText");
var SearchByAlphabet = $rootScope.getLocalStorageValue("SearchByAlphabet");
if (tabToSet == 2) {
var curSelectedRowId = $rootScope.getLocalStorageValue("AISelectedRowId");
$('#' + $rootScope.getLocalStorageValue("currentAIImageId")).addClass("selected");
$scope.idSelected = $rootScope.getLocalStorageValue("currentAIImageId");
var selectedImageId = $rootScope.getLocalStorageValue("currentAIImageId");
if (searchText != '' && searchText != null && searchText != undefined) {
$scope.ApplySearch(searchText);
if (inderectCall == true) {
if (curSelectedRowId != "") {
$scope.showItem(curSelectedRowId);
}
} else {
if (selectedImageId != "") {
$scope.filterstring = false;
$scope.showItem(selectedImageId);
$scope.filterstring = true;
}
//$scope.ReloadListViewImageDiv(curSelectedRowId, ImageCount);
}
}
else if (SearchByAlphabet != "" && SearchByAlphabet != null && SearchByAlphabet != undefined) {
$scope.ApplySearchByAlphabet(SearchByAlphabet);
if (inderectCall == true) {
if (curSelectedRowId != "") {
$scope.showItem(curSelectedRowId);
}
} else {
if (selectedImageId != "") {
$scope.filterstring = false;
$scope.showItem(selectedImageId);
$scope.filterstring = true;
}
//$scope.ReloadListViewImageDiv(curSelectedRowId, ImageCount);
}
}
else {
//ReloadListViewImageDiv(curSelectedRowId, ImageCount);
$scope.loadAllAI(ImageCount);
if (inderectCall == true) {
if (curSelectedRowId != "") {
$scope.filterstring = true;
$scope.showItem(curSelectedRowId);
$scope.filterstring = false;
}
} else {
if (selectedImageId != "") {
$scope.filterstring = false;
$scope.showItem(selectedImageId);
}
//$scope.ReloadListViewImageDiv(curSelectedRowId, ImageCount);
}
}
$scope.query.SelectedDiv = tabToSet;
//Method call for set position for selected title Bug-57978
//$scope.ReloadListViewImageDiv(curSelectedRowId, ImageCount);
$('#grid-view').css("display", "none");
$('#list-view').css("display", "block");
}
else {
$('#' + $rootScope.getLocalStorageValue("currentAIImageId")).find('.thumbnail').addClass('HightLightThumbnail');
$('#' + $rootScope.getLocalStorageValue("currentAIImageId")).removeClass('selected');
$scope.query.SelectedDiv = tabToSet;
//Modified Code by sandeep for fixed bug-45300
if (searchText != '' && searchText != null && searchText != undefined) {
$scope.ApplySearch(searchText);
}
else if (SearchByAlphabet != "" && SearchByAlphabet != null && SearchByAlphabet != undefined) {
$scope.ApplySearchByAlphabet(SearchByAlphabet);
}
else {
$scope.loadAllAI(ImageCount);
}
$('#grid-view').css("display", "block");
$('#list-view').css("display", "none");
}
setTimeout(function () {
$scope.setImgPosition();
}, 100);
};
//$scope.loadAIModuleById = function (moduleId) {
// var ImageCount = $rootScope.getLocalStorageValue("ImageCount");
// if ($rootScope.refreshcheck == null) {
// $location.path('/');
// }
// // code that will be executed ...
// // every time this view is loaded
// //get current path
// var currentURL = $location.path();
// var selectedModuleName = '';
// //set module title
// angular.forEach($rootScope.userModules, function (value, key) {
// if (value.slug === currentURL.replace('/', '')) {
// selectedModuleName = value.name;
// }
// $rootScope.currentActiveModuleTitle = selectedModuleName;
// })
// $scope.LoadAIJsonData(ImageCount);
// $scope.scroll();
// //push the details of open module in array $rootScope.openModules
// $rootScope.openModules.push({ "ModuleId": 13 });
// //set the local storage
// var curtab = $rootScope.getLocalStorageValue("currentAITabView");
// var inderectCall = true;
// if (curtab == 2) {
// $scope.setActiveTab(2, inderectCall);
// var curSelectedRowId = $rootScope.getLocalStorageValue("AISelectedRowId");
// if (typeof (curSelectedRowId) !== "undefined" && curSelectedRowId !== null && curSelectedRowId !== '') {
// $scope.reRunSearchOnLoad();
// $scope.idSelected = curSelectedRowId;
// $scope.ReloadListViewImageDiv($scope.idSelected, ImageCount);
// }
// else {
// $scope.reRunSearchOnLoad()
// $scope.idSelected = '';
// }
// }
// else {
// $scope.setActiveTab(1, inderectCall);
// $scope.reRunSearchOnLoad();
// }
//}
$scope.loadAIModuleById = function (moduleId) {
var ImageCount = $rootScope.getLocalStorageValue("ImageCount");
if ($rootScope.refreshcheck == null) {
$location.path('/');
}
// code that will be executed ...
// every time this view is loaded
//get current path
var currentURL = $location.path();
var selectedModuleName = '';
//set module title
angular.forEach($rootScope.userModules, function (value, key) {
if (value.slug === currentURL.replace('/', '')) {
selectedModuleName = value.name;
}
$rootScope.currentActiveModuleTitle = selectedModuleName;
})
$scope.LoadAIJsonData(ImageCount);
$scope.scroll();
//push the details of open module in array $rootScope.openModules
$rootScope.openModules.push({ "ModuleId": 13 });
//set the local storage
var curtab = $rootScope.getLocalStorageValue("currentAITabView");
var inderectCall = true;
if (curtab == 2) {
$scope.setActiveTab(2, inderectCall);
var curSelectedRowId = $rootScope.getLocalStorageValue("AISelectedRowId");
if (typeof (curSelectedRowId) !== "undefined" && curSelectedRowId !== null && curSelectedRowId !== '') {
$scope.reRunSearchOnLoad();
$scope.idSelected = curSelectedRowId;
$scope.ReloadListViewImageDiv($scope.idSelected, ImageCount);
}
else {
$scope.reRunSearchOnLoad()
$scope.idSelected = '';
}
}
else {
$scope.setActiveTab(1, inderectCall);
$scope.reRunSearchOnLoad();
}
//setTimeout(function () {
// $scope.setImgPosition();
//}, 100);
//setTimeout(function () {
// if ($('#grid-view').css("display") == "block") {
// if ($rootScope.getLocalStorageValue('AIGridViewHighlightThumbnail') !== null) {
// $('#' + $rootScope.getLocalStorageValue("AIGridViewHighlightThumbnail")).find('.thumbnail').addClass('HightLightThumbnail');
// }
// if ($rootScope.getLocalStorageValue('AIGridViewScroll') !== null && $location.url() == "/tile-view-list") {
// $('html, body').animate({ scrollTop: $rootScope.getLocalStorageValue('AIGridViewScroll') }, 'slow');
// }
// }
// if ($('#list-view').css("display") == "block") {
// var AIListViewScroll = $rootScope.getLocalStorageValue("AIListViewScroll");
// if (typeof (AIListViewScroll) !== "undefined" && AIListViewScroll !== null && AIListViewScroll !== '' && $location.url() == "/tile-view-list") {
// if (typeof InstallTrigger !== 'undefined') {
// $('#ListViewDiv').animate({ scrollTop: $rootScope.getLocalStorageValue('AIListViewScroll') }, 'slow');
// }
// else {
// $('#ListViewDiv').animate({ scrollTop: $rootScope.getLocalStorageValue('AIListViewScroll') }, 'slow');
// }
// $("#list-view table tbody tr").removeClass("active");
// $("#list-view table tbody #" + $rootScope.getLocalStorageValue("listViewSelectedID")).addClass("active");
// }
// }
//}, 100);
//$('#list-view').css('display', 'none');
}
$scope.reRunSearchOnLoad = function () {
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;
}
else if (typeof (searchTextByAlphabet) !== "undefined" && searchTextByAlphabet !== null && searchTextByAlphabet !== '') {
$scope.query.SearchTextByAlphabet = searchTextByAlphabet;
}
else {
$scope.query.SearchTextByAlphabet = "";
}
if ($scope.query.SearchText == "" && $scope.query.SearchTextByAlphabet == "") {
$scope.loadAllAI(ImageCount);
}
}
$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) {
$scope.IllustrationData = result;
$scope.selectedAIListViewData = new jinqJs()
.from($scope.IllustrationData.root.AIData)
.orderBy([{ field: '_Title', sort: 'asc' }])
.select().slice(0, ImageCount);
},
function (error) {
// handle errors here
console.log(' $scope.IllustrationData = ' + error.statusText);
}
);
};
$scope.loadAllAI = function (ImageCount) {
$rootScope.isLoading = true;
localStorage.setItem("SearchText", '');
localStorage.setItem("SearchByAlphabet", '');
$('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) {
$scope.IllustrationData = result;
$scope.selectedAIListViewData = new jinqJs()
.from($scope.IllustrationData.root.AIData)
.orderBy([{ field: '_Title', sort: 'asc' }])
.select().slice(0, ImageCount);
//console.log($scope.selectedAIListViewData);
$('#grid-view').empty();
var $e1 = $('
'
+ '
'
+ '
![]()
'//alt="{{value._Title}}" >'
+ '
').appendTo('#grid-view');
$compile($e1)($scope);
$timeout(function () {
$('#' + $rootScope.getLocalStorageValue("currentAIImageId")).find('.thumbnail').addClass('HightLightThumbnail');
if ($rootScope.getLocalStorageValue('AIGridViewScroll') !== null && $location.url() == "/ADAM-images" && $scope.query.SelectedDiv == 1) {
$('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) {
// handle errors here
console.log(' $scope.IllustrationData = ' + error.statusText);
}
);
}
$scope.IsVisible = function () {
$scope.scroll();
}
$scope.showItem = function (id) {
//Modified code by sandeep for fixed issue of ADAM Images
$scope.idSelected = id;
localStorage.setItem("AISelectedRowId", id);
//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) {
var SelectedAIthumbImage = [];
SelectedAIthumbImage = new jinqJs()
.from($scope.selectedAIListViewData)
.where('_id = ' + id)
.select('_ThumbnailImage', '_id', '_Title');
if (SelectedAIthumbImage.length > 0) {
$scope.SelectedAIthumbImage = "~/../content/images/ai/thumbnails/" + SelectedAIthumbImage[0]._ThumbnailImage;
$scope.SelectedAIId = SelectedAIthumbImage[0]._id;
$scope.SelectedAITitle = SelectedAIthumbImage[0]._Title;
} else { $scope.hiderow = false; }
}
else {
if ($scope.searchAIListViewData.length > 0) {
var SelectedAIthumbImage = [];
SelectedAIthumbImage = new jinqJs()
.from($scope.searchAIListViewData)
.where('_id = ' + id)
.select('_ThumbnailImage', '_id', '_Title');
if (SelectedAIthumbImage.length > 0) {
$scope.SelectedAIthumbImage = "~/../content/images/ai/thumbnails/" + SelectedAIthumbImage[0]._ThumbnailImage;
$scope.SelectedAIId = SelectedAIthumbImage[0]._id;
$scope.SelectedAITitle = SelectedAIthumbImage[0]._Title;
} else { $scope.hiderow = false; }
}
}
};
$scope.Reset = function (query) {
$('ul li span').removeAttr("style");
query.SearchText = "";
$scope.idSelected = '';
//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);
$scope.hideListViewDiv();
$scope.filterstring = false;
while ($scope.searchAIListViewData.length) {
$scope.searchAIListViewData.pop();
}
$scope.loadAllAI(ImageCount);
}
$scope.ApplySearch = function (query) {
//Modified code by sandeep for fixed issue of ADAM Images
$('ul li span').removeAttr("style");
$scope.idSelected = '';
//$scope.hiderow = false;
$scope.hiderow = true;
var currentSearchtext = $rootScope.getLocalStorageValue("SearchText");
//localStorage.setItem("SearchText", '');
localStorage.setItem("SearchByAlphabet", '');
if (typeof (query) !== "undefined" && (query !== null && query !== "")) {
currentSearchtext = query.SearchText;
$scope.query.SearchText = query.SearchText;
if (currentSearchtext == undefined || $scope.query.SearchText == undefined) {
currentSearchtext = query;
$scope.query.SearchText = query;
}
}
localStorage.setItem("SearchText", currentSearchtext);
if (currentSearchtext == "undefined" || (currentSearchtext == null || currentSearchtext == "")) {
if ($scope.query.SearchText == "undefined" || ($scope.query.SearchText == null || $scope.query.SearchText == "")) {
$rootScope.errorMessage = AIAConstants.PLEASE_ENTER_SEARCH_TEXT;
$("#messageModal").modal('show');
return false;
}
}
//$scope.filterstring = false;
while ($scope.searchAIListViewData.length) {
$scope.searchAIListViewData.pop();
}
$rootScope.isLoading = true;
$('#aiSpinner').css('visibility', 'visible');
$('#aiSpinner').css('zIndex', '20000');
//$scope.DisableUI();
$scope.filterstring = true;
if (typeof ($scope.query.SearchText) !== "undefined" && ($scope.query.SearchText !== null && $scope.query.SearchText !== "")) {
//localStorage.setItem("SearchText", query.SearchText);
localStorage.setItem("SearchText", $scope.query.SearchText);
}
else {
localStorage.setItem("SearchText", '');
}
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 ($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;
//count = count + 1;
}
else {
selectimg = false;
//count = count - 1;
}
}
if (selectimg === true) {
$scope.imagePath = "~/../content/images/ai/thumbnails/" + value._ThumbnailImage;
var $el = $(''
+ '
'
+ '
![]()
'
+ '
').appendTo('#grid-view');
$compile($el)($scope);
$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! |
');
localStorage.setItem("SearchText", '');
}
setTimeout(function () {
//$scope.setImgPosition();
$scope.EnableUI();
}, 10);
$rootScope.isLoading = false;
$('#aiSpinner').css('visibility', 'hidden');
//Added code by sandeep for fixed bug-40273
//setTimeout(function () {
// $scope.setImgPosition();
//}, 10);
},
function (error) {
// handle errors here
console.log(' $scope.IllustrationData = ' + error.statusText);
}
);
}
//Added method by sandeep for fixed Bug-57978 to selected Image
$scope.setImgPosition = function () {
var _currentImgId = $rootScope.getLocalStorageValue("currentAIImageId");
if (_currentImgId != "null" && _currentImgId != null) {
$('#' + _currentImgId).find('.thumbnail').addClass('HightLightThumbnail');
//$('html, body').animate({ scrollTop: $('#' + _currentImgId).position().top }, 100);
$scope.hiderow = true;
}
if ($('#grid-view').css("display") == "block") {
var aiGridViewScroll = $rootScope.getLocalStorageValue('AIGridViewScroll');
if (aiGridViewScroll !== null && $location.url() == "/ADAM-images" && aiGridViewScroll != "0") {
$('html, body').animate({ scrollTop: $rootScope.getLocalStorageValue('AIGridViewScroll') }, 'slow');
}
else if (_currentImgId != "null" && _currentImgId != null) {
$('html, body').animate({ scrollTop: $('#' + _currentImgId).position().top }, 100);
}
}
if ($('#list-view').css("display") == "block") {
var AIListViewScroll = $rootScope.getLocalStorageValue("AIListViewScrollPosition");
if (AIListViewScroll !== null && $location.url() == "/ADAM-images" && AIListViewScroll != "0") {
$('#ListViewDiv').animate({ scrollTop: $rootScope.getLocalStorageValue('AIListViewScrollPosition') }, 'slow');
}
else if (_currentImgId != "null" && _currentImgId != null) {
$('html, body').animate({ scrollTop: $('#' + _currentImgId).position().top }, 100);
}
//$("#list-view table tbody tr").removeClass("active");
//$("#list-view table tbody #" + $rootScope.getLocalStorageValue("listViewSelectedID")).addClass("active");
}
}
$scope.DisableUI = function () {
$('#imgParent').css('z-index', '1');
document.getElementById("imgParent").style.pointerEvents = "none";
document.getElementById("imgParent").style.opacity = "0.5";
}
$scope.EnableUI = function () {
document.getElementById("imgParent").style.pointerEvents = "auto";
document.getElementById("imgParent").style.opacity = "1.0";
}
$scope.counter = 1;
$scope.ApplySearchByAlphabet = function (SearchTextByAlphabet) {
//Modified code by sandeep for fixed issue of ADAM Images
$rootScope.SearchTextByAlphabet = SearchTextByAlphabet;
localStorage.setItem("SearchText", '');
$('#txtSerachInput').val("");
//$rootScope.isLoading = true;
$scope.idSelected = '';
//$scope.hiderow = false;//Comment by Sandeep
$scope.hiderow = true;
$scope.DisableUI();
$('ul li span').removeAttr("style");
$('#' + $rootScope.SearchTextByAlphabet).css({ "color": "white", "background-color": "#1B92D0" });
$scope.filterstring = true;
while ($scope.searchAIListViewData.length) {
$scope.searchAIListViewData.pop();
}
$rootScope.isLoading = true;
$('#aiSpinner').css('visibility', 'visible');
$('#aiSpinner').css('zIndex', '20000');
if (typeof (SearchTextByAlphabet) !== "undefined" && (SearchTextByAlphabet !== null && SearchTextByAlphabet !== "")) {
localStorage.setItem("SearchByAlphabet", SearchTextByAlphabet);
}
else {
localStorage.setItem("SearchByAlphabet", '');
}
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 (SearchTextByAlphabet) !== "undefined" && (SearchTextByAlphabet !== null && SearchTextByAlphabet !== "")) {
var firstChar = value._Title[0];
if (firstChar == SearchTextByAlphabet) {
selectimg = true;
}
else {
selectimg = false;
}
}
if (selectimg === true) {
$scope.imagePath = "~/../content/images/ai/thumbnails/" + value._ThumbnailImage;
var $el = $(''
+ '
'
+ '
![]()
'
+ '
').appendTo('#grid-view');
$compile($el)($scope);
$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! |
');
}
setTimeout(function () {
//$scope.setImgPosition();
$scope.EnableUI();
}, 10);
$rootScope.isLoading = false;
$('#aiSpinner').css('visibility', 'hidden');
//Added code by sandeep for fixed bug-40273
//setTimeout(function () {
// $scope.setImgPosition();
//}, 10);
},
function (error) {
console.log(' $scope.IllustrationData = ' + error.statusText);
}
);
}
$scope.scroll = function () {
//$("html,body").scrollTop(0);
}
$scope.OpenAdamImage = function ($event) {
$rootScope.MenuModuleName = "AI";
$rootScope.disableAnnotationTB = false;
$rootScope.AIAnotationIdentifyModeOff = true;
$rootScope.currentAIImageId = $event.currentTarget.id;
if ($event.currentTarget.textContent !== null && typeof ($event.currentTarget.textContent) !== "undefined") {
var AITitle = [];
AITitle = new jinqJs()
.from($scope.selectedAIListViewData)
.where('_id = ' + $event.currentTarget.id)
.select('_Title');
$rootScope.ViewTitle = AITitle[0]._Title;
}
else {
$rootScope.ViewTitle = $event.currentTarget.textContent;
}
localStorage.setItem("currentImageTitleFromJson", $rootScope.ViewTitle);
localStorage.setItem("currentAIImageId", $event.currentTarget.id);
var moduleItemDataToBeSavedID = $event.currentTarget.id;
$("#list-view table tbody tr").removeClass("active");
localStorage.setItem("listViewSelectedID", moduleItemDataToBeSavedID);
$("#list-view table tbody #" + moduleItemDataToBeSavedID).addClass("active");
localStorage.setItem("AIListViewScrollPosition", $("#list-view table tbody").scrollTop());
//Set the vertical scroll value of the Grid-View.
var y = $($window).scrollTop();
localStorage.setItem("AIGridViewScroll", y);
localStorage.setItem("AIGridViewHighlightThumbnail", $(event.target).parent().parent().parent().attr('id'));
var u = $location.url();
$location.url('/adam-images-detail');
}
//$scope.OpenAdamImageView = function () {
// // $rootScope.currentActiveModuleTitle = "A.D.A.M. Images";
// if ($rootScope.refreshcheck == null) {
// $location.path('/');
// }
// $rootScope.isLoading = true;
// $('#aiSpinner').css('visibility', 'visible');
// //$scope.DisableUI();
// $scope.voId = $rootScope.getLocalStorageValue("currentAIImageId");
// var counter = 1;
// var tittle = $rootScope.getLocalStorageValue("currentImageTitleFromJson");
// localStorage.setItem("currentViewTitle", tittle);
// var promise = DataService.getJson('~/../content/data/json/ai/ai_dat_contentlist.json')
// promise.then(
// function (result) {
// $scope.AIllustrationData = result;
// $scope.AIlistViewData = $scope.AIllustrationData.root.AIData;
// var clickedAIImage = [];
// clickedAIImage = new jinqJs()
// .from($scope.AIlistViewData)
// .where('_id == ' + $scope.voId)
// .select('_contentImage');
// $scope.clickedAIImage = "~/../content/images/ai/images/" + clickedAIImage[0]._contentImage;
// // store image for export
// var tittle = $rootScope.getLocalStorageValue("currentViewTitle");
// $rootScope.StoreTitleName(tittle);
// $rootScope.StoreOrgImageName(clickedAIImage[0]._contentImage);
// if (clickedAIImage.length > 0) {
// $.jsPanel({
// id: 'aiImagePanel',
// selector: '.aiView',
// theme: 'success',
// currentController: 'AIController',
// parentSlug: 'ADAM-images',
// content: ' ' +
// '

' +
// '
' +
// '
',
// //ajax: {
// // url: 'app/views/ci/ci-view-detail.html'
// //},
// title: $rootScope.getLocalStorageValue("currentViewTitle"),
// position: {
// top: 70,
// left: 15,
// },
// size: { width: $(window).outerWidth() - 30, height: $(window).outerHeight() - 125 },
// });
// $('#canvasDiv img').load(function () {
// $rootScope.isLoading = false;
// $('#aiSpinner').css('visibility', 'hidden');
// var canvas = document.getElementById("canvas");
// var canvasPaint = document.getElementById("canvasPaint");
// var imageheight = $("#aimage").height();
// var canvasDivheight = $(window).outerHeight() - 150;
// if (canvasDivheight > imageheight)
// {
// canvas.height = canvasDivheight;
// canvasPaint.height = canvasDivheight;
// }
// else
// {
// canvas.height = imageheight;
// canvasPaint.height = imageheight;
// }
// canvas.width = $(window).outerWidth() - 81;
// canvasPaint.width = $(window).outerWidth() - 81;
// });
// $rootScope.currentSlug = 'adam-images-detail';
// $rootScope.openViews.push(
// {
// "module": $rootScope.currentActiveModuleTitle, "bodyView": tittle, "state": 'max', "BodyViewId": $rootScope.currentAIImageId,
// "slug": $rootScope.currentSlug
// });
// $("#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();
// // console.log($rootScope.OpenAdamImages);
// $('#AIView').css("height", $(window).outerHeight() - 65);
// $('#AIView').css("width", $(window).outerWidth() - 15);
// var canvasDIvHeight = parseInt($('#aiImagePanel').outerHeight()) - 90;
// $('#canvasDiv').css('height', canvasDIvHeight);
// }
// },
// function (error) {
// // handle errors here
// console.log(' $scope.AIllustrationData = ' + error.statusText);
// }
// );
//}
$scope.OpenAdamImageView = function () {
// $rootScope.currentActiveModuleTitle = "A.D.A.M. Images";
if ($rootScope.refreshcheck == null) {
$location.path('/');
}
$rootScope.isLoading = true;
$('#aiSpinner').css('visibility', 'visible');
//$scope.DisableUI();
$scope.voId = $rootScope.getLocalStorageValue("currentAIImageId");
var counter = 1;
var tittle = $rootScope.getLocalStorageValue("currentImageTitleFromJson");
localStorage.setItem("currentViewTitle", tittle);
var promise = DataService.getJson('~/../content/data/json/ai/ai_dat_contentlist.json')
promise.then(
function (result) {
$scope.AIllustrationData = result;
$scope.AIlistViewData = $scope.AIllustrationData.root.AIData;
var clickedAIImage = [];
clickedAIImage = new jinqJs()
.from($scope.AIlistViewData)
.where('_id == ' + $scope.voId)
.select('_contentImage');
$scope.clickedAIImage = "~/../content/images/ai/images/" + clickedAIImage[0]._contentImage;
// store image for export
var tittle = $rootScope.getLocalStorageValue("currentViewTitle");
$rootScope.StoreTitleName(tittle);
$rootScope.StoreOrgImageName(clickedAIImage[0]._contentImage);
if (clickedAIImage.length > 0) {
$.jsPanel({
id: 'aiImagePanel',
selector: '.aiView',
theme: 'success',
currentController: 'AIController',
parentSlug: 'ADAM-images',
content: '
' +
'
' +
'

' +
'
',
//ajax: {
// url: 'app/views/ci/ci-view-detail.html'
//},
title: $rootScope.getLocalStorageValue("currentViewTitle"),
position: {
top: 70,
left: 15,
},
size: { width: $(window).outerWidth() - 30, height: $(window).outerHeight() - 125 },
});
//$('#canvasDiv img').load(function () {
// $rootScope.isLoading = false;
// $('#aiSpinner').css('visibility', 'hidden');
// var canvas = document.getElementById("canvas");
// var canvasPaint = document.getElementById("canvasPaint");
// var imageheight = $("#aimage").height();
// var canvasDivheight = $(window).outerHeight() - 150;
// if (canvasDivheight > imageheight) {
// canvas.height = canvasDivheight;
// canvasPaint.height = canvasDivheight;
// }
// else {
// canvas.height = imageheight;
// canvasPaint.height = imageheight;
// }
// canvas.width = $(window).outerWidth() - 81;
// canvasPaint.width = $(window).outerWidth() - 81;
//});
$('#canvasDiv img').load(function () {
$rootScope.isLoading = false;
$('#aiSpinner').css('visibility', 'hidden');
var canvas = document.getElementById("canvas");
var canvasPaint = document.getElementById("canvasPaint");
canvas.height = $("#aiImagePanel .jsPanel-content").height();
canvasPaint.height = $("#aiImagePanel .jsPanel-content").height();
});
$rootScope.currentSlug = 'adam-images-detail';
$rootScope.openViews.push(
{
"module": $rootScope.currentActiveModuleTitle, "bodyView": tittle, "state": 'max', "BodyViewId": $rootScope.currentAIImageId,
"slug": $rootScope.currentSlug
});
$("#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();
// console.log($rootScope.OpenAdamImages);
$('#AIView').css("height", $(window).outerHeight() - 65);
$('#AIView').css("width", $(window).outerWidth() - 15);
//var canvasDIvHeight = parseInt($('#aiImagePanel').outerHeight()) - 30;
var canvasDIvHeight = $("#aiImagePanel .jsPanel-content").height();
$('#canvasDiv').css('height', canvasDIvHeight);
}
},
function (error) {
// handle errors here
console.log(' $scope.AIllustrationData = ' + error.statusText);
}
);
}
$scope.$on('annotationToolEvent', function (event, data) {
$('#editstylebackgroundcolor .minicolors >.minicolors-swatch > .minicolors-swatch-color').css("background-color", "rgb(255,255,255)")
$('#editstylebackgroundcolor .minicolors >.minicolors-panel > .minicolors-grid >.minicolors-picker').css({ "top": "145px", "left": "4px" });
$('#outlineColor .minicolors >.minicolors-swatch > .minicolors-swatch-color').css("background-color", "rgb(0,0,0)")
$('#outlineColor .minicolors >.minicolors-panel > .minicolors-grid >.minicolors-picker').css({ "top": "145px", "left": "4px" });
$("#canvas").css("display", "block");
$("#canvasPaint").css("display", "block");
$rootScope.onDrawingCanvasClick();
//Commented by Sandeep
//$rootScope.FreeStylePaint();
});
$scope.ReloadListViewImageDiv = function (id, imgCount) {
//console.log(id);
$scope.idSelected = id;
$scope.hiderow = true;
$rootScope.isLoading = true;
$('#aiSpinner').css('visibility', 'visible');
$('#aiSpinner').css('zIndex', '20000');
var promise = DataService.getJson('~/../content/data/json/ai/ai_dat_contentlist.json')
promise.then(
function (result) {
$scope.IllustrationData = result;
var SelectedAIthumbImage = [];
SelectedAIthumbImage = new jinqJs()
.from($scope.IllustrationData.root.AIData)
.where('_id = ' + id)
.select('_ThumbnailImage', '_id', '_Title').slice(0, imgCount);
if (SelectedAIthumbImage.length > 0) {
$scope.SelectedAIthumbImage = "~/../content/images/ai/thumbnails/" + SelectedAIthumbImage[0]._ThumbnailImage;
$scope.SelectedAIId = SelectedAIthumbImage[0]._id;
$scope.SelectedAITitle = SelectedAIthumbImage[0]._Title;
} else { $scope.hiderow = false; }
//Set the scroll position of the tablebody to show selected row.
//var curAIListViewScroll = $rootScope.getLocalStorageValue("AIListViewScrollPosition");
////var _currentImgId = $rootScope.getLocalStorageValue("currentAIImageId");
//if (typeof (curAIListViewScroll) !== "undefined" && curAIListViewScroll !== null && curAIListViewScroll !== "null") {
// $('#ListViewDiv').animate({ scrollTop: $rootScope.getLocalStorageValue('AIListViewScrollPosition') }, 'slow');
// //$('html, body').animate({ scrollTop: $('#' + _currentImgId).position().top }, 100);
//}
//else {
// //$('#ListViewDiv').scrollTop($rootScope.getLocalStorageValue("currentImageTitleFromJson"));
// $('#ListViewDiv').animate({ scrollTop: $rootScope.getLocalStorageValue('AIListViewScrollPosition') }, 'slow');
//}
$scope.setImgPosition();
$rootScope.isLoading = false;
$('#aiSpinner').css('visibility', 'hidden');
},
function (error) {
// handle errors here
console.log(' $scope.AnimationData = ' + error.statusText);
}
);
};
$scope.hideListViewDiv = function () {
if ($rootScope.getLocalStorageValue("currentAITabView") == 2) {
//localStorage.setItem("AISelectedRowId", "");
if ($('.selected').hasClass("selected")) { $('.selected').removeClass("selected"); }
$scope.hiderow = false;
}
}
}]
);