AIA.controller("CurrBuildController", ["$scope", "$rootScope", "pages", "$log", "Modules", "$http", "$compile", "$location", "$timeout", "ModuleService", "$interval","$window",
function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $timeout, ModuleService, $interval, $window) {
// $rootScope.currentActiveModuleTitle = pages[6].name;
$scope.showTabButton = false;
$scope.listCurriculumBuilder = null;
$scope.dataPopup = null;
$scope.countLeftlist;
$scope.countRightlist;
$rootScope.selectedNodeSingle = [];
$scope.selectedNodeSingleObj = [];
$rootScope.structureObjForSaveCB = [];
$rootScope.contentNotesForSaveCB = [];
$rootScope.dynamicUpdatedJsonForSaveCB = "";
//$rootScope.updateSaveDraftCB = [];
$scope.IsVisible = function () {
$scope.scroll();
}
$scope.scroll = function () {
// $window.scrollTo(0, 0);
$("html,body").scrollTop(0);
//alert("scroll");
}
//$scope.showDeleteEditorModel = function () {
// document.getElementById('cbModelDeleteBackground').style.display = "block";
// document.getElementById('cbModelDeleteEditorId').style.display = "block";
//}
$rootScope.closeEditorModel = function () {
document.getElementById('cbModelDeleteBackground').style.display = "none";
document.getElementById('cbModelDeleteEditorId').style.display = "none";
}
angular.element(document).ready(function (e) {
$("#sidebar-wrapper").on('click', function (event) {
//4. on click disable menu option
$scope.$emit("cBEnableDisableMenuOption","");
});
// close all selected open panel in CB
$(document).on("click", " .jsPanel-hdr .jsPanel-hdr-r .jsPanel-btn-close .jsglyph-remove", function () {
// close in case of Curriculum Builder
var id = $(event.target).parent().parent().parent().parent().attr('id');
if (id == "CBTinyMCEPanel") {
tinymce.execCommand('mceRemoveControl', true, 'CBTextArea');
tinymce.execCommand('mceFocus', true, 'CBTextArea');
tinymce.execCommand('mceRemoveEditor', true, 'CBTextArea');
tinymce.execCommand('mceAddEditor', true, 'CBTextArea');
//$rootScope.structureObjForSaveCB = [];
//$rootScope.contentNotesForSaveCB = [];
if ($('#' + id).html() != undefined) {
$('#' + id).remove();
}
}
// remove panel name from dropdown
$('#viwerSelect option[value="' + id + '"]').remove();
//Added code by sandeep for fixed Bug-58066
var ddlViewerLen = $("#viwerSelect option").length;
if (ddlViewerLen == 0) {
$('#viwerSelect').hide();
}
});
$scope.CBDisableUI = function () {
$rootScope.isLoading = true;
$('#spinner').css('visibility', 'visible');
$('#spinner').css('z-index', '1000000001');
// CB module disable all
$('#HomeContainerDiv').css('pointer-events', 'none');
$('#HomeContainerDiv').css('opacity', '0.7');
$timeout(function () {
// in case failed default time out 40 second
var opcity = $("#HomeContainerDiv").css("opacity")
if (opcity != 1)
{
$scope.CBEnableUI();
}
}, 40000);
}
$scope.CBEnableUI = function () {
$rootScope.isLoading = false;
$('#spinner').css('visibility', 'hidden');
// CB module enable all
$('#HomeContainerDiv').css('pointer-events', 'auto');
$('#HomeContainerDiv').css('opacity', '1');
}
});
$rootScope.firstSelectedNodeId = null;
//load json data
$scope.loadCurriculumBuiderData = function () {
if ($rootScope.refreshcheck == null) {
$location.path('/');
}
//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;
})
$http({ method: 'GET', url: 'content/data/json/cb/cb_list_content.json' }).success(function (data) {
$scope.listCurriculumBuilder = data;
//load default body view list
$scope.getCBViewList();
})
.error(function (data, status, headers, config) {
console.log(data);
});
}
$rootScope.ConfirmNewCbProcess=function()
{
if($scope.cbData!=undefined)
{
$("#newCurriculumModal").modal('hide');
window.parent.AIAModuleOpenResourceInfo($scope.cbData);
}
}
$scope.OpenCurriculumConfirmMessage = function ($event) {
$scope.cbData = {
"fileName": $event.target.id.split('.')[0],
"mType": 'cbFileData',
"fileText": $event.target.text
};
$("#newCurriculumModal").modal('show');
$(".modal-backdrop").css("opacity", ".5");
}
//get CB body view list
$scope.getCBViewList = function () {
$('#leftBodyViewList').empty();
$scope.countLeftlist = Object.keys($scope.listCurriculumBuilder.slideshows.slideshow).length / 2;
$scope.loadleftBodyViewList = new jinqJs()
.from($scope.listCurriculumBuilder.slideshows.slideshow)
.select();
var isopenResourceRequest = sessionStorage.getItem('isModuleOpenByOpenResource');
for (var i = 0; i < $scope.countLeftlist; i++) {
if (isopenResourceRequest == "true") {
var $el = $('
' + $scope.listCurriculumBuilder.slideshows.slideshow[i]._label + '').appendTo('#leftBodyViewList');
}
else
{
var $el = $('' + $scope.listCurriculumBuilder.slideshows.slideshow[i]._label + '').appendTo('#leftBodyViewList');
}
$compile($el)($scope);
}
$scope.countRightlist = Object.keys($scope.listCurriculumBuilder.slideshows.slideshow).length;
for (var i = $scope.countLeftlist; i < $scope.countRightlist; i++) {
if (isopenResourceRequest == "true") {
var $el1 = $('' + $scope.listCurriculumBuilder.slideshows.slideshow[i]._label + '').appendTo('#rightBodyViewList');
}
else
{
var $el1 = $('' + $scope.listCurriculumBuilder.slideshows.slideshow[i]._label + '').appendTo('#rightBodyViewList');
}
$compile($el1)($scope);
}
$timeout(function() {
var cbFileDetail = JSON.parse(sessionStorage.getItem("ExitsCBFileDetail"));
if(cbFileDetail!=undefined && cbFileDetail!=null)
{
$scope.loadSlideByFileDetail(cbFileDetail.fileName,cbFileDetail.fileText);
}
},500);
}
$scope.loadSlideByFileDetail = function (fileName,fileTitle) {
sessionStorage.removeItem('ExitsCBFileDetail');
$scope.loadSelectedJsonFile(fileName,fileTitle);
}
$scope.loadSlideShowXmldata = function (e) {
var fileName = e.target.id.split('.')[0];
var fileTitle=e.target.text;
$scope.loadSelectedJsonFile(fileName,fileTitle);
}
$scope.loadSelectedJsonFile = function (fileName,fileTitle) {
$scope.CBDisableUI();
$rootScope.AutherName="";
$rootScope.summary="";
$rootScope.FileTitle=fileTitle;
$scope.fileName = fileName;
$('#modal-CurBuilder').css("display", "block");
$("#CurBuilderbackground").css("display", "block");
$http({ method: 'GET', url: 'content/data/json/cb/SlideShow/json/' + $scope.fileName + '.json' }).success(function (data) {
localStorage.setItem("cbJsonDataObject", JSON.stringify(data));
$rootScope.cbJsonData = JSON.parse(localStorage.getItem("cbJsonDataObject"));
$rootScope.cbDynamicJsonData = data;
$rootScope.getCBsummary();
$scope.CBEnableUI();
})
.error(function (data, status, headers, config) {
console.log(data);
$scope.CBEnableUI();
});
}
$rootScope.OpenExistingCurriculum = function (event) {
var fileupload = document.getElementById("openCBJsonFile");
$timeout(function () {
$(fileupload).trigger('click');
}, 300);
$(fileupload).val('');//old file path
fileupload.onchange = function () {
var fileId, file, objFileRead;
if (typeof window.FileReader !== 'function') {
alert("The file API isn't supported on this browser yet.");
return;
}
fileId = document.getElementById('openCBJsonFile');
if (!fileId) {
alert("File couldn't find the element.");
}
else if (!fileId.files) {
alert("This browser doesn't seem to support the `files` property of file inputs.");
}
else if (!fileId.files[0]) {
alert("Please select a file before clicking 'Load'");
}
else {
file = fileId.files[0];
var extension = file.name.split(".")[1];
if (file.type == "application/json" && extension == "json") {
$location.url('/curriculum-builder');
$timeout(function () {
objFileRead = new FileReader();
objFileRead.onload = receivedFile;
objFileRead.readAsText(file);
}, 300);
} else {
alert("Please select only Saved Curriculum Builder Json file!");
}
}
function receivedFile(e) {
//let lines = e.target.result;
var jsonData = JSON.parse(e.target.result);
localStorage.setItem("cbJsonDataObject", JSON.stringify(jsonData));
$rootScope.cbJsonData = ""; $rootScope.cbDynamicJsonData = "";
$rootScope.cbJsonData = JSON.parse(e.target.result);
$rootScope.cbDynamicJsonData = JSON.parse(e.target.result);
$rootScope.cbTreeFirstLabel = $rootScope.cbJsonData.slideshow.presentation.structure._label;
$rootScope.getCBsummary();
$scope.CBEnableUI();
$rootScope.AutherName = "";
$rootScope.summary = "";
$rootScope.FileTitle = $rootScope.cbTreeFirstLabel;
$timeout(function () {
$('#modal-CurBuilder').css("display", "block");
$("#CurBuilderbackground").css("display", "block");
//$scope.openCurriculumDetail();
}, 200);
}
};
}
$scope.openImagePanel = function () {
var jsImageURL = 'app/views/CBuild/curriculum-builder-image.html';
$.jsPanel({
id: 'CBSourceImagePanel',
selector: '.CBBodyView',
theme: 'success',
currentController: 'CurrBuildController',
parentSlug: 'curriculum-builder-detail',
ajax: {
url: jsImageURL
},
title: $rootScope.windowstitle,
position: {
top: 600,
left: 10,
},
controls: { buttons: 'closeonly' },
size: { width: 850, height: 503 },
});
setTimeout(function () {
$scope.ImagePanelclick();
var imfgEle = document.getElementById("imgtag");
if (imfgEle!=null)
imfgEle.src = "data:image/png;base64," + $rootScope.windowsimageSource;
setTimeout(function () {
var cleintht=imfgEle.clientHeight;
if(cleintht>0)
$('#CBSourceImagePanel .jsPanel-content').css('height', cleintht);
$scope.CBEnableUI();
}, 200)
}, 200)
}
$scope.ImagePanelclick = function () {
$("#CBSourceImagePanel").on('click', function (event) {
var pnlName=event.currentTarget.id;
$scope.$emit("cBEnableDisableMenuOption",pnlName);
});
}
$rootScope.getCBsummary = function () {
$rootScope.summary = $rootScope.cbJsonData.slideshow.content.element[0].summary;
$rootScope.AutherName = $rootScope.cbJsonData.slideshow.content.element[0].author;
$rootScope.note = $rootScope.cbJsonData.slideshow.content.element;
$rootScope.Auther = $rootScope.cbDynamicJsonData.slideshow.content.element;
}
$scope.closeCurBulderModal = function () {
$('#modal-CurBuilder').css("display", "none");
$("#CurBuilderbackground").css("display", "none");
}
$scope.openCurriculumDetail = function () {
$rootScope.structure = $rootScope.cbJsonData.slideshow.presentation.structure.structure;
$rootScope.stru = $rootScope.cbDynamicJsonData.slideshow.presentation;
$rootScope.cbDynamicContents = $rootScope.cbDynamicJsonData.slideshow.content.element;
$rootScope.cbTreeFirstLabel = $rootScope.cbJsonData.slideshow.presentation.structure._label;
$rootScope.cbTreeFirstID = $rootScope.cbJsonData.slideshow.presentation.structure._id;
$location.url("/curriculum-builder-detail");
}
$rootScope.newCurriculumDetail = function () {
$rootScope.selectedNodeSingle.push(
{
"structure": {
"structure": [
{
"_label": "Untitled Slide",
"_id": "51516C76",
"_isRoot": "false",
"_isBranch": "false",
"_isLocked": "false"
}
],
},
"_label": "Untitled Curriculum",
"_id": "111112",
"_isRoot": "true",
"_isBranch": "true",
"_isLocked": "false"
});
$rootScope.stru = $scope.selectedNodeSingle[0];
//$scope.nodeid = $scope.selectedNodeSingle[0].structure.structure[0]._label;
//traverseTreeSelectedSingleObj($rootScope.stru, $scope.nodeid);
//$scope.structure = $scope.selectedNodeSingle[0].structure.structure[0]._label;
$rootScope.cbTreeFirstLabel = $scope.selectedNodeSingle[0]._label;
$rootScope.structure = $scope.selectedNodeSingle[0].structure.structure;
//$rootScope.structureObjForSaveCB = $rootScope.stru.slideshow.presentation.structure.structure;
$rootScope.cbTreeFirstID = $scope.selectedNodeSingle[0]._id;
$location.url("/curriculum-builder-detail");
}
$scope.openCBJsPanel = function () {
$scope.CBDisableUI();
var jsContentURL = 'app/views/CBuild/curriculum-builder-TinyMCEjspanel.html';
var jsImageContentURL = 'app/views/CBuild/curriculum-builder-image-jspanel.html';
$.jsPanel({
id: 'CBTinyMCEPanel',
selector: '.CBBodyView',
theme: 'success',
currentController: 'CurrBuildController',
parentSlug: 'curriculum-builder',
ajax: {
url: jsContentURL
},
title: $rootScope.cbTreeFirstLabel,
position: {
top: 20,
left: 20,
},
controls: { buttons: 'closeonly' },
size: { width: 850, height: 512 },
});
$timeout(function () {
$scope.TinyMCEPanelclick();
},1000);
}
$scope.TinyMCEPanelclick = function () {
$("#CBTinyMCEPanel").on('click', function (event) {
//3. on click disable menu option
$scope.$emit("cBEnableDisableMenuOption","");
});
}
$scope.myeditorclick=function() {
//1. disable menu options
$scope.$emit("cBEnableDisableMenuOption","");
}
function traverseTreeForSetIcons(o, current_id) {
for (var i in o) {
if (o[i] !== null && typeof (o[i]) == "object") {
if (o[i]._isBranch == "false") {
$("#jstree").jstree(true).set_icon(o[i]._id, "../../../content/images/CB/file.png");
//$("#AddSlide").addClass("cbAddSection");
//$("#AddSection").addClass("cbAddSection");
}
if (o[i]._isBranch == "true") {
//$("#AddSlide").removeClass("cbAddSection");
// $("#AddSection").removeClass("cbAddSection");
}
traverseTreeForSetIcons(o[i], current_id);
}
}
}
$scope.loadNotesById = function () {
traverseForLoadDropDown($rootScope.stru);
setTimeout(function () {
var nodeid = document.getElementById('cbSelect').value;
$('#jstree').jstree('select_node', nodeid);
traverseTreeForSetIcons($rootScope.stru, nodeid);
}, 200);
}
$scope.openTinyMCE = function (nodeid) {
$scope.CBDisableUI();
if ($scope.Currentselectednodeid == undefined || $scope.Currentselectednodeid != nodeid) {
console.log("instance create for id : " + nodeid);
$scope.Currentselectednodeid = nodeid;
// close model
$rootScope.CloseAnnotationTool();
$rootScope.CloseListManager();
$rootScope.disableTopMenuOption();
traverseTreeSelectedSingleObj($rootScope.stru, nodeid);
if ($scope.selectedNodeSingleObj._isBranch == "false") {
$("#Deletesection").addClass("DeletesectionClass");
$("#DeleteSlide").removeClass("DeleteslideClass");
$("#AddSlide").addClass("cbAddSection");
$("#AddSection").addClass("cbAddSection");
$("#openResourceId").removeClass("openResources");
}
if ($scope.selectedNodeSingleObj._isBranch == "true") {
$("#Deletesection").removeClass("DeletesectionClass");
$("#DeleteSlide").addClass("DeleteslideClass");
$("#AddSlide").removeClass("cbAddSection");
$("#AddSection").removeClass("cbAddSection");
$("#openResourceId").addClass("openResources");
}
$scope.DropDownSelectNodeClick(nodeid);
$scope.SelectedNotes = "";
traverseTreeSelectedSingleObj($rootScope.note, nodeid);
$scope.SelectedNotes = $scope.selectedNodeSingleObj.notes;
// clear module data
ModuleService.ClearWinData();
$('#CBSourceImagePanel').remove();
$("#viwerSelect").empty();
$("#viwerSelect").hide();
if ($('#cbparentcustomDiv').html() != "") {
$('#cbparentcustomDiv').empty();
}
if ($scope.SelectedNotes != "" && $scope.SelectedNotes != undefined) {
tinymce.get("CBTextArea").setContent($scope.SelectedNotes);
$scope.LoadModuleName = [];
$scope.Slidenumber = $scope.selectedNodeSingleObj._id;
setTimeout(function () {
if ($scope.selectedNodeSingleObj.windows != "") {
$scope.loadContentOfSelectedSlide($scope.selectedNodeSingleObj._id)
}
else
{
$scope.CBEnableUI();
}
},200);
//$scope.CBEnableUI();
}
else
{
tinymce.get("CBTextArea").setContent("");
$scope.CBEnableUI();
}
}
else
{
$scope.CBEnableUI();
}
}
$rootScope.cbSelectOnChange = function (obj) {
$('#jstree').jstree(true).deselect_all();
$('#jstree').jstree('select_node', obj.value);
}
traverseSelectedObjForSaveDraftCB = function (o, current_id) {
for (var i in o) {
if (o[i] !== null && typeof (o[i]) == "object") {
if (o[i]._id == current_id) {
$scope.selectedObjforSaveDraftCB = o[i];
}
traverseSelectedObjForSaveDraftCB(o[i], current_id);
}
}
}
var isActive = false;
//Start Code by Sandeep for TicketNo: 49226(3)
$scope.DropDownSelectNodeClick = function (nodeid) {
if ($rootScope.contentNotesForSaveCB.length == 0) {
$rootScope.contentNotesForSaveCB = $rootScope.cbDynamicContents;//Assign Dnamic Contents
}
var currentCb_id = document.getElementById('cbSelect').value;
$rootScope.updatedContentFromEditor(currentCb_id);//Calling for Update Note for Save CB
if (isActive) {
$scope.updateWindowsContentForSaveCB(currentCb_id);// Calling for Update Window content for Save Cb
}
isActive = true;
traverseTreeSelectedSingleObj($rootScope.stru, nodeid);
traverse($rootScope.stru, nodeid);
$('#cbEditorRightSideBar').css('pointer-events', 'auto');
$('#cbEditorRightSideBar').css('opacity', '1');
if ($scope.selectedNodeSingleObj._isBranch == "true") {
$("#cbSelect").empty();
$('#cbEditorRightSideBar').css('pointer-events', 'none');
$('#cbEditorRightSideBar').css('opacity', '0.7');
localStorage.setItem("cbSelectId", nodeid);
if ($scope.selectedNodeSingleObj._id == nodeid) {
//$scope.currentSlideNumber += 1;
$('#cbSelect').append('');
}
else {
$('#cbSelect').append('');
}
if ($scope.selectedNodeSingleObj._isRoot == "true") {
document.getElementById("slideNumber").innerHTML = "Slide " + 1 + " of " + 1;
}
else if ($scope.selectedNodeSingleObj._isBranch == "true") {
for (var i = 0; i < $scope.selectedNodeSiblingObjs.length; i++) {
if ($scope.selectedNodeSiblingObjs[i]._id == nodeid) {
$scope.currentSlideNumber = i + 1;
}
}
//$scope.currentSlideNumber += 1;
//document.getElementById("slideNumber").innerHTML = "Slide " + $scope.currentSlideNumber + " of " + Object.keys($scope.selectedNodeSingleObj).length;
document.getElementById("slideNumber").innerHTML = "Slide " + $scope.currentSlideNumber + " of " + Object.keys($scope.selectedNodeSiblingObjs).length;
}
else{
document.getElementById("slideNumber").innerHTML = "Slide " + $scope.currentSlideNumber + " of " + Object.keys($scope.selectedNodeSingleObj).length;
}
}
else {
traverse($rootScope.stru, nodeid);
$("#cbSelect").empty();
for (var i = 0; i < $scope.selectedNodeSiblingObjs.length; i++) {
localStorage.setItem("cbSelectId", nodeid);
if ($scope.selectedNodeSiblingObjs[i]._id == nodeid) {
$scope.currentSlideNumber = i + 1;
$('#cbSelect').append('');
}
else {
$('#cbSelect').append('');
}
}
document.getElementById("slideNumber").innerHTML = "Slide " + $scope.currentSlideNumber + " of " + Object.keys($scope.selectedNodeSiblingObjs).length;
}
}
$rootScope.cbNext = function () {
var cbCurrentId = document.getElementById('cbSelect').value;
var counter = 0;
$("#jstree").jstree("open_all");
$('.jstree-container-ul li a span').each(function () {
var span_Id = $(this).attr("id");
if (span_Id == cbCurrentId) {
counter++;
}
if (counter == 2) {
$scope.nextCurrentId = span_Id;
if ($scope.nextCurrentId != undefined) {
$('#jstree').jstree(true).deselect_all();
$('#jstree').jstree('select_node', $scope.nextCurrentId);
}
return false;
}
if (counter == 1) {
counter += 1;
}
});
}
$rootScope.cbBack = function () {
var cbCurrentId = document.getElementById('cbSelect').value;
var counter = 0;
$("#jstree").jstree("open_all");
$($(".jstree-container-ul li a span").get().reverse()).each(function () {
var span_Id = $(this).attr("id");
if (span_Id == cbCurrentId) {
counter++;
}
if (counter == 2) {
$scope.backCurrentId = span_Id;
if ($scope.backCurrentId != undefined) {
$('#jstree').jstree(true).deselect_all();
$('#jstree').jstree('select_node', $scope.backCurrentId);
}
return false;
}
if (counter == 1) {
counter += 1;
}
});
}
//End Code by Sandeep for TicketNo: 49226(3)
function traverse(o, current_id) {
for (var i in o) {
if (o[i] !== null && typeof (o[i]) == "object") {
if (o[i]._id == current_id) {
$scope.selectedNodeSiblingObjs = o;
}
traverse(o[i], current_id);
}
}
}
$rootScope.cbPasswordModelShow = function () {
//var current_id = document.getElementById('cbSelect').value;
//traverseTreeSelectedSingleObj($rootScope.stru, current_id);
//if ($scope.selectedNodeSingleObj._isBranch == "true") {
//traverseTreeSelectedSingleObj($rootScope.Auther, current_id);
//document.getElementById('cbRenameDate').value = $scope.selectedNodeSingleObj.modified;
document.getElementById('cbModelRenameBackground').style.display = "block";
document.getElementById('cbModelUserPassWord').style.display = "block";
//}
//else {
//document.getElementById('cbModelRenameBackground').style.display = "block";
//document.getElementById('cbModelRenameId').style.display = "block";
// }
}
$scope.setProperties = function () {
if ($scope.selectedNodeSingleObj.author != "undefined") {
$('#cbRenameAuthor').val($scope.selectedNodeSingleObj.author);
}
if ($scope.selectedNodeSingleObj.version != "undefined") {
$('#cbRenameSummary').val($scope.selectedNodeSingleObj.summary);
}
if ($scope.selectedNodeSingleObj.summary != "undefined") {
$('#cbRenameVersionNo').val($scope.selectedNodeSingleObj.version);
}
if ($scope.selectedNodeSingleObj.modified != "undefined") {
$('#cbRenameDate').val($scope.selectedNodeSingleObj.modified);
}
}
$rootScope.cbRenameModelShow = function () {
//Add code for Save Draft Content
if ($rootScope.contentNotesForSaveCB.length == 0) {
$rootScope.contentNotesForSaveCB = $rootScope.cbDynamicContents;
}
var current_id = document.getElementById('cbSelect').value;
document.getElementById('renameInputBoxId').value = "";
traverseTreeSelectedSingleObj($rootScope.stru, current_id);
if ($scope.selectedNodeSingleObj._label != "undefined") {
$('#cbRenameSectionTitle').val($scope.selectedNodeSingleObj._label);
}
if ($scope.selectedNodeSingleObj._isLocked != "undefined") {
if ($scope.selectedNodeSingleObj._isLocked != "false" && $scope.selectedNodeSingleObj._isLocked != false) {
$('#cbCheckLocked').prop('checked', true);
}
else {
$('#cbCheckLocked').prop('checked', false);
}
}
if ($scope.selectedNodeSingleObj._isBranch == "true") {
//traverseTreeSelectedSingleObj($rootScope.Auther, current_id);
traverseTreeSelectedSingleObj($rootScope.contentNotesForSaveCB, current_id);
//document.getElementById('cbRenameDate').value = $scope.selectedNodeSingleObj.modified;
$scope.setProperties();
document.getElementById('cbModelRenameBackground').style.display = "block";
document.getElementById('cbModelSectionRenameId').style.display = "block";
}
else {
document.getElementById('cbModelRenameBackground').style.display = "block";
document.getElementById('cbModelRenameId').style.display = "block";
if ($scope.selectedNodeSingleObj._label != "undefined") {
$('#renameInputBoxId').val($scope.selectedNodeSingleObj._label);
}
}
}
$rootScope.cbRenameSlide = function () {
var current_id
if (($rootScope.getLocalStorageValue("cbSelectId")) != '') {
current_id = $rootScope.getLocalStorageValue("cbSelectId");
}
else {
current_id = document.getElementById('cbSelect').value;
}
//var current_id = document.getElementById('cbSelect').value;
var newSlideText = document.getElementById('renameInputBoxId').value;
var newSlideName = ("" + newSlideText + "");
$("#jstree").jstree('set_text', current_id, newSlideName);
traverseTreeSelectedSingleObj($rootScope.stru, current_id);
$scope.selectedNodeSingleObj._label = newSlideText;
if ($rootScope.structureObjForSaveCB.length == 0) {
$rootScope.structureObjForSaveCB = $rootScope.stru.structure.structure;
//$rootScope.structureObjForSaveCB = $rootScope.stru.slideshow.presentation.structure.structure;
}
//Update Save Draft object for Rename slide
for (var i = 0; i < $rootScope.structureObjForSaveCB.length; i++) {
if ($rootScope.structureObjForSaveCB[i]._id == current_id) {
$rootScope.structureObjForSaveCB[i]._label = $scope.selectedNodeSingleObj._label
}
}
$scope.DropDownSelectNodeClick(current_id);
//console.log(JSON.stringify($rootScope.stru));
$rootScope.closeRenameModel();
}
$rootScope.closeRenameModel = function () {
document.getElementById('cbModelRenameBackground').style.display = "none";
if (document.getElementById("cbModelRenameId").style.display == 'block') {
document.getElementById('cbModelRenameId').style.display = "none";
}
if (document.getElementById("cbModelUserPassWord").style.display == 'block') {
document.getElementById('cbModelUserPassWord').style.display = "none";
}
if (document.getElementById("cbModelSectionRenameId").style.display == 'block') {
document.getElementById('cbModelSectionRenameId').style.display = "none";
}
}
$scope.cbSlideLocked = function () {
var nodeid;
if (($rootScope.getLocalStorageValue("cbSelectId")) != '') {
nodeid = $rootScope.getLocalStorageValue("cbSelectId");
}
else {
nodeid = document.getElementById('cbSelect').value;
}
var password = $('#cbPassword').val(); //document.getElementById('cbPassword').value;
var confirm_password = $('#cbConfirmPassWord').val(); //document.getElementById('cbConfirmPassWord').value;
if (password != confirm_password) {
$('#errorMsg').text('Password do not match!');
return false;
}
$('#errorMsg').text('');
$rootScope.closeRenameModel();
traverseTreeSelectedSingleObj($rootScope.stru, nodeid);
if ($scope.selectedNodeSingleObj._isBranch == "true") {
if ($rootScope.contentNotesForSaveCB.length == 0) {
$rootScope.contentNotesForSaveCB = $rootScope.cbDynamicContents;
}
traverseTreeSelectedSingleObj($rootScope.contentNotesForSaveCB, nodeid);
$scope.selectedNodeSingleObj.password = password;
}
}
$rootScope.cbRenameSection = function () {
var nodeid
if (($rootScope.getLocalStorageValue("cbSelectId")) != '') {
nodeid = $rootScope.getLocalStorageValue("cbSelectId");
}
else {
nodeid = document.getElementById('cbSelect').value;
}
//var nodeid = document.getElementById('cbSelect').value;
$scope.cbRenameDate();
traverseTreeSelectedSingleObj($rootScope.stru, nodeid);
//var newSlideName = document.getElementById('cbRenameSectionTitle').value;
var newLockedFlag = $('#cbCheckLocked').is(':checked');
var newAuthorName = document.getElementById('cbRenameAuthor').value;
var newSummary = document.getElementById('cbRenameSummary').value;
var newversion = document.getElementById('cbRenameVersionNo').value;
var newSectionText = document.getElementById('cbRenameSectionTitle').value;
if (newSectionText == ""){
newSectionText = $scope.selectedNodeSingleObj._label;
}
var newSlideName = ("" + newSectionText + "");
$("#jstree").jstree('set_text', nodeid, newSlideName);
$scope.selectedNodeSingleObj._label = newSectionText;
$scope.selectedNodeSingleObj._isLocked = newLockedFlag;
//Update Save Draft object for rename section
if ($rootScope.structureObjForSaveCB.length == 0) {
$rootScope.structureObjForSaveCB = $rootScope.stru.structure.structure;
//$rootScope.structureObjForSaveCB = $rootScope.stru.slideshow.presentation.structure.structure;
}
for (var i = 0; i < $rootScope.structureObjForSaveCB.length; i++) {
if ($rootScope.structureObjForSaveCB[i]._id == nodeid) {
$rootScope.structureObjForSaveCB[i]._label = $scope.selectedNodeSingleObj._label;
//$rootScope.structureObjForSaveCB[i]['structure'] = $scope.selectedNodeSingleObj['structure'];
}
}
if ($rootScope.cbTreeFirstID == nodeid) {
$rootScope.cbTreeFirstLabel = $scope.selectedNodeSingleObj._label;
}
//Add code for Save Draft Content
if ($rootScope.contentNotesForSaveCB.length == 0) {
$rootScope.contentNotesForSaveCB = $rootScope.cbDynamicContents;
}
traverseTreeSelectedSingleObj($rootScope.contentNotesForSaveCB, nodeid);
setTimeout(function () {
$scope.selectedNodeSingleObj.summary = newSummary;
$scope.selectedNodeSingleObj.author = newAuthorName;
$scope.selectedNodeSingleObj.version = newversion;
$scope.selectedNodeSingleObj.modified = $scope.dateTime;
$scope.DropDownSelectNodeClick(nodeid);
console.log("Structure:" + JSON.stringify($rootScope.structureObjForSaveCB));
console.log("Notes:" + JSON.stringify($rootScope.contentNotesForSaveCB));
}, 100);
$rootScope.closeRenameModel();
}
$scope.cbRenameDate = function () {
var currentdate = new Date();
var now = new Date();
var year = now.getFullYear();
var month = now.getMonth() + 1;
var day = now.getDate();
var hours = now.getHours();
var minute = now.getMinutes();
var ampm = hours >= 12 ? 'PM' : 'AM';
hours = hours % 12;
hours = hours ? hours : 12; // the hour '0' should be '12'
if (month.toString().length == 1) {
month = '0' + month;
}
if (day.toString().length == 1) {
day = '0' + day;
}
if (hours.toString().length == 1) {
hours = '0' + hours;
}
if (minute.toString().length == 1) {
minute = '0' + minute;
}
$scope.dateTime = month + '/' + day + '/' + year + ',' + hours + ':' + minute + ' ' + ampm;
}
$rootScope.showDeleteSlideModel = function () {
document.getElementById('cbModelDeleteBackground').style.display = "block";
document.getElementById('cbModelDeleteConfirmBoxId').style.display = "block";
}
$rootScope.DeleteSlideSection = function () {
var cbCurrentSelectedId = document.getElementById('cbSelect').value;
var CurrentSelectedLiId = $('#' + cbCurrentSelectedId).closest('li').attr('id');
var CurrentSelectedParentSpanId = $('#' + cbCurrentSelectedId).parent().parent().parent().parent().find('span').attr('id');
var parentNodeObj = $('#' + cbCurrentSelectedId).parent().parent().parent();
var indexOfCurrentSelectedId = $(parentNodeObj).children('li').index($("#" + CurrentSelectedLiId));
$('#jstree').jstree().delete_node([$("#jstree").jstree().get_selected(true)[0].id]);
var lengthOfCurrentSelectedSlideSiblings = $(parentNodeObj).children('li').length;
if (indexOfCurrentSelectedId <= 0) {
if (lengthOfCurrentSelectedSlideSiblings > 1) {
$rootScope.cbNext();
}
else {
$('#jstree').jstree(true).deselect_all();
$('#jstree').jstree('select_node', CurrentSelectedParentSpanId);
}
}
else {
$rootScope.cbBack();
}
//$scope.deleteSectionForCB(cbCurrentSelectedId, CurrentSelectedParentSpanId);
$scope.DeleteSlide(cbCurrentSelectedId, CurrentSelectedParentSpanId);
var CurrentId = document.getElementById('cbSelect').value;
$scope.DropDownSelectNodeClick(CurrentId);
$rootScope.closeDeleteModel();
}
$rootScope.closeDeleteModel = function () {
document.getElementById('cbModelDeleteBackground').style.display = "none";
document.getElementById('cbModelDeleteConfirmBoxId').style.display = "none";
}
$rootScope.CBAddSlide = function () {
var current_id
if (($rootScope.getLocalStorageValue("cbSelectId")) != '') {
current_id = $rootScope.getLocalStorageValue("cbSelectId");
}
else {
current_id = document.getElementById('cbSelect').value;
}
traverseTreeSelectedSingleObj($rootScope.stru, current_id);
var parentid = $('#' + current_id).parent().parent().parent().parent().find('span').attr('id');
var createNodeId;
if ($scope.selectedNodeSingleObj._isBranch == "true") {
createNodeId = current_id;
}
else {
createNodeId = parentid;
//open other modules
// $scope.loadContentOfSelectedSlide(current_id);
}
var AddSlideId = "";
var AddSlideLiId = "";
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
for (var i = 0; i < 5; i++) {
AddSlideId += possible.charAt(Math.floor(Math.random() * possible.length));
AddSlideLiId += possible.charAt(Math.floor(Math.random() * (possible.length) + 1));
}
// var AddSlideId = 'abcd';
//var AddSlideId = Math.random().toString();
$('#jstree').jstree().create_node(createNodeId, {
li_attr: { "name": "isBranchFalse" },
"id": AddSlideLiId,
"text": 'New Slide'
}, "last", function () {
// //$scope.addCBSlide(current_id, AddSlideId);
$scope.addSlide(createNodeId, AddSlideId);
//$scope.DropDownSelectNodeClick(current_id);
$('#jstree').jstree(true).deselect_all();
$('#jstree').jstree('select_node', AddSlideLiId);
//$('#jstree').jstree('select_node', AddSlideId);
//$scope.openTinyMCE(AddSlideId);
});
}
$rootScope.CBAddSection = function () {
var current_id
if (($rootScope.getLocalStorageValue("cbSelectId")) != '') {
current_id = $rootScope.getLocalStorageValue("cbSelectId");
}
else {
current_id = document.getElementById('cbSelect').value;
}
traverseTreeSelectedSingleObj($rootScope.stru, current_id);
var parentid = $('#' + current_id).parent().parent().parent().parent().find('span').attr('id');
var createNodeId;
if ($scope.selectedNodeSingleObj._isBranch == "true") {
createNodeId = current_id;
}
else {
createNodeId = parentid;
}
var AddSectionId = "";
var AddSectionLiId = "";
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
for (var i = 0; i < 5; i++) {
AddSectionId += possible.charAt(Math.floor(Math.random() * possible.length));
AddSectionLiId += possible.charAt(Math.floor(Math.random() * (possible.length) + 1));
}
// var AddSlideId = 'abcd';
//var AddSlideId = Math.random().toString();
$('#jstree').jstree().create_node(createNodeId, {
li_attr: { "name": "isBranchFalse" },
"id": AddSectionLiId,
"text": 'New Section'
}, "last", function () {
//$scope.addCBSlide(current_id, AddSlideId);
$scope.addSection(createNodeId, AddSectionId);
//$scope.DropDownSelectNodeClick(current_id);
$('#jstree').jstree(true).deselect_all();
//$('#jstree').jstree('select_node', AddSectionId);
$('#jstree').jstree('select_node', AddSectionLiId);
});
}
function traverseForLoadDropDown(o) {
for (var i = 0; i < o.structure.structure.length; i++) {
$('#cbSelect').append('');
}
}
$scope.deleteSectionForCB = function (currentid, CurrentSelectedParentSpanId) {
if ($rootScope.structureObjForSaveCB.length == 0) {
$rootScope.structureObjForSaveCB = $rootScope.stru.structure.structure;
}
if ($rootScope.contentNotesForSaveCB.length == 0) {
//$rootScope.contentNotesForSaveCB = $rootScope.cbJsonData.slideshow.content.element;
$rootScope.contentNotesForSaveCB = $rootScope.cbDynamicContents;//Assign Dnamic Contents
}
traverseTreeSelectedSingleObj($rootScope.structureObjForSaveCB, currentid);
if ($scope.selectedNodeSingleObj._isBranch == "true") {
for (var j = 0; j < $scope.selectedNodeSingleObj['structure'].length; j++) {
if ($scope.selectedNodeSingleObj._id == currentid) {
var childNodesForSelectedSection = $scope.selectedNodeSingleObj['structure'];
if (childNodesForSelectedSection.length > 0) {
for (var l = 0; l < childNodesForSelectedSection.length; l++) {
var childId = childNodesForSelectedSection[l]._id; // Get Child ID for selected Section node
for (var k = 0; k < $rootScope.contentNotesForSaveCB.length; k++) {
if (($rootScope.contentNotesForSaveCB[k]._id == childId)) {
$rootScope.contentNotesForSaveCB.splice(k, 1);
}
}
}
}
}
$scope.selectedNodeSingleObj['structure'].splice(j, 1);
//$rootScope.structureObjForSaveCB = $rootScope.stru.structure.structure;
}
}
//Delete notes for SavedraftCB as per Selected Section from tree
var deleteNotes = $rootScope.contentNotesForSaveCB
var remaingNotesForCB = new jinqJs()
.from(deleteNotes)
.delete().at("_id == " + currentid).select();
$rootScope.contentNotesForSaveCB = remaingNotesForCB;
//$rootScope.contentNotesForSaveCB = $rootScope.cbDynamicContents;
}
function getLoadNodeId(o) {
for (var i in o) {
if (o[i] !== null && typeof (o[i]) == "object") {
if (o[i]._isBranch == "false") {
$rootScope.firstSelectedNodeId = o[i]._id;
}
getLoadNodeId(o[i]);
}
}
}
$scope.DeleteSlide = function (currentid, CurrentSelectedParentSpanId) {
if ($rootScope.structureObjForSaveCB.length == 0) {
$rootScope.structureObjForSaveCB = $rootScope.stru.structure.structure;
}
if ($rootScope.contentNotesForSaveCB.length == 0) {
//$rootScope.contentNotesForSaveCB = $rootScope.cbJsonData.slideshow.content.element;
$rootScope.contentNotesForSaveCB = $rootScope.cbDynamicContents;//Assign Dnamic Contents
}
traverse($rootScope.stru, currentid);
for (var j = 0; j < $rootScope.structureObjForSaveCB.length; j++) {
//if (($rootScope.structureObjForSaveCB[j]._id == currentid)) {
if ($rootScope.structureObjForSaveCB[j]._id == currentid && $rootScope.structureObjForSaveCB[j]._isBranch == "true") {
traverseTreeSelectedSingleObj($rootScope.stru, currentid);
traverse($rootScope.stru, currentid);
var childNodesForSelectedSection = $scope.selectedNodeSingleObj['structure'];
//if ($rootScope.structureObjForSaveCB[j]['structure'].length > 0) {
if (childNodesForSelectedSection.length > 0) {
for (var l = 0; l < childNodesForSelectedSection.length; l++) {
var childId = childNodesForSelectedSection[l]._id; // Get Child ID for selected Section node
for (var k = 0; k < $rootScope.contentNotesForSaveCB.length; k++) {
if (($rootScope.contentNotesForSaveCB[k]._id == childId)) {
$rootScope.contentNotesForSaveCB.splice(k, 1);
}
}
}
}
$rootScope.structureObjForSaveCB.splice(j, 1);
}
}
for (var j = 0; j < $scope.selectedNodeSiblingObjs.length; j++) {
if (($scope.selectedNodeSiblingObjs[j]._id == currentid)) {
$scope.selectedNodeSiblingObjs.splice(j, 1);
//Added Code by Sandeep for Delete slide from node tree for save draft CB
for (var x = 0; x < $rootScope.structureObjForSaveCB.length; x++) {
if (($rootScope.structureObjForSaveCB[x]._id == CurrentSelectedParentSpanId)) {
for (var y = 0; y < $rootScope.structureObjForSaveCB[x]['structure'].length; y++) {
if ($rootScope.structureObjForSaveCB[x]['structure'][y]._id == currentid) {
$rootScope.structureObjForSaveCB[x]['structure'].splice(y, 1);
}
}
}
}
}
}
$rootScope.structureObjForSaveCB = $rootScope.stru.structure.structure;
$scope.selectedNodeSingleObj = "";
//Delete notes for SavedraftCB as per Selected Slide from tree
var deleteNotes = $rootScope.contentNotesForSaveCB
var remaingNotesForCB = new jinqJs()
.from(deleteNotes)
.delete().at("_id == " + currentid).select();
$rootScope.contentNotesForSaveCB = remaingNotesForCB;
//alert("After" + JSON.stringify($rootScope.stru));
console.log($rootScope.structureObjForSaveCB);
console.log($rootScope.contentNotesForSaveCB);
}
$rootScope.saveCurricullam = function (file_Name) {
//$scope.exportToFile(file_Name);
var cbCurrentId = document.getElementById('cbSelect').value;
if ($rootScope.structureObjForSaveCB.length == 0) {
//$rootScope.structureObjForSaveCB = $rootScope.structure;// only Tree Array
//$rootScope.structureObjForSaveCB = $rootScope.stru.slideshow.presentation.structure.structure;
$rootScope.structureObjForSaveCB = $rootScope.stru.structure.structure;
}
if ($rootScope.contentNotesForSaveCB.length == 0) {
//$rootScope.contentNotesForSaveCB = $rootScope.cbJsonData.slideshow.content.element;
$rootScope.contentNotesForSaveCB = $rootScope.cbDynamicContents;//Assign Dnamic Contents
}
$rootScope.updatedContentFromEditor(cbCurrentId);
$scope.updateWindowsContentForSaveCB(cbCurrentId);
$rootScope.dynamicUpdatedJsonForSaveCB =
{
"slideshow": {
"presentation": {
"structure": {
"structure": //[
$rootScope.structureObjForSaveCB,
//],
"_label": $rootScope.cbTreeFirstLabel,
"_id": $rootScope.cbTreeFirstID,
"_isRoot": "true",
"_isBranch": "true",
"_isLocked": "false"
},
"_anchor": "true",
"_window_position": "6,10",
"_window_size": "828,453" // Apply Dynamic
},
"content": {
"element": //[
$rootScope.contentNotesForSaveCB,
//]
}
}
};
$scope.slideshow = $rootScope.dynamicUpdatedJsonForSaveCB;
$scope.filename = "SandySaveCB.json";
var filename = $scope.filename;
var blob = new Blob([angular.toJson($rootScope.dynamicUpdatedJsonForSaveCB, true)], { type: 'text/text' });
if (window.navigator && window.navigator.msSaveOrOpenBlob) {
window.navigator.msSaveOrOpenBlob(blob, filename);
}
else {
document.execCommand("SaveAs", true, filename);
//$("#bo").document.execCommand("SaveAs", true, filename);
//angular.element(document.execCommand("SaveAs", false, filename)).scope();
var event = document.createEvent('MouseEvents'),
saveElement = document.createElement('a');
saveElement.download = filename;
saveElement.href = window.URL.createObjectURL(blob);
saveElement.dataset.downloadurl = ['text/json', saveElement.download, saveElement.href].join(':');
event.initEvent('click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
saveElement.dispatchEvent(event);
//window.URL.revokeObjectURL(url); // clean the url.createObjectURL resource
}
$rootScope.dynamicUpdatedJsonForSaveCB = "";
//$rootScope.contentNotesForSaveCB = [];
//$rootScope.structureObjForSaveCB = [];
}
$rootScope.updatedContentFromEditor = function (cbCurrentId) {
if ($rootScope.contentNotesForSaveCB.length == 0) {
$rootScope.contentNotesForSaveCB = $rootScope.cbDynamicContents;//Assign Dnamic Contents
}
var windowsInSelectedSlide; var notesForSelectedSlide;
var contentWindowsNotes = $rootScope.contentNotesForSaveCB
var selectedSlideContent = new jinqJs()
.from(contentWindowsNotes)
.where("_id == " + cbCurrentId)
.select();
if (selectedSlideContent.length > 0) {
windowsInSelectedSlide = selectedSlideContent[0].windows;
notesForSelectedSlide = tinyMCE.activeEditor.getContent();
if (notesForSelectedSlide == "" || notesForSelectedSlide == undefined) {
notesForSelectedSlide = selectedSlideContent[0].notes;
}
//Calling method for update Windows Data for selected slide
//$scope.windowsContentForSelectedSlide(windowsInSelectedSlide);
}
else {
windowsInSelectedSlide = "";
notesForSelectedSlide = tinyMCE.activeEditor.getContent();
}
//Delete notes for SavedraftCB as per Selected Section from tree
var remaingNotesForCB = new jinqJs()
.from(contentWindowsNotes)
.delete().at("_id == " + cbCurrentId).select();
$rootScope.contentNotesForSaveCB = remaingNotesForCB;
traverseTreeSelectedSingleObj($rootScope.stru, cbCurrentId);
if ($scope.selectedNodeSingleObj._isBranch == "false") {
$rootScope.contentNotesForSaveCB.push(
{
"notes": notesForSelectedSlide,
"windows": windowsInSelectedSlide,
"_id": cbCurrentId
});
}
else if ($scope.selectedNodeSingleObj._isBranch == "true" && $scope.selectedNodeSingleObj._isRoot == "true") {
//traverseTreeSelectedSingleObj($rootScope.Auther, cbCurrentId);
traverseTreeSelectedSingleObj($rootScope.cbDynamicContents, cbCurrentId);
$rootScope.contentNotesForSaveCB.push(
{
"windows": windowsInSelectedSlide,
"summary": $scope.selectedNodeSingleObj.summary,
"author": $scope.selectedNodeSingleObj.author,
"modified": $scope.selectedNodeSingleObj.modified,
"password": "",
"version": $scope.selectedNodeSingleObj.version,
"_id": cbCurrentId
//"notes": notesForSelectedSlide,
//"windows": windowsInSelectedSlide,
//"_id": cbCurrentId
});
}
else if ($scope.selectedNodeSingleObj._isBranch == "true") {
//traverseTreeSelectedSingleObj($rootScope.Auther, cbCurrentId);
traverseTreeSelectedSingleObj($rootScope.cbDynamicContents, cbCurrentId);
$rootScope.contentNotesForSaveCB.push(
{
"summary": $scope.selectedNodeSingleObj.summary,
"author": $scope.selectedNodeSingleObj.author,
"modified": $scope.selectedNodeSingleObj.modified,
"password": "",
"version": $scope.selectedNodeSingleObj.version,
"windows": windowsInSelectedSlide,
"_id": cbCurrentId
//"notes": notesForSelectedSlide,
//"windows": windowsInSelectedSlide,
//"_id": cbCurrentId
});
}
$rootScope.cbDynamicContents = $rootScope.contentNotesForSaveCB;
$rootScope.note = $rootScope.contentNotesForSaveCB;
console.log($rootScope.contentNotesForSaveCB);
}
$rootScope.exportToFile = function () {
var cbCurrentId = document.getElementById('cbSelect').value;
if ($rootScope.structureObjForSaveCB.length == 0) {
//$rootScope.structureObjForSaveCB = $rootScope.structure;// only Tree Array
//$rootScope.structureObjForSaveCB = $rootScope.stru.slideshow.presentation.structure.structure;
$rootScope.structureObjForSaveCB = $rootScope.stru.structure.structure;
}
if ($rootScope.contentNotesForSaveCB.length == 0) {
//$rootScope.contentNotesForSaveCB = $rootScope.cbJsonData.slideshow.content.element;
$rootScope.contentNotesForSaveCB = $rootScope.cbDynamicContents;//Assign Dnamic Contents
}
$rootScope.updatedContentFromEditor(cbCurrentId);
$rootScope.dynamicUpdatedJsonForSaveCB =
{
"slideshow": {
"presentation": {
"structure": {
"structure": //[
$rootScope.structureObjForSaveCB,
//],
"_label": $rootScope.cbTreeFirstLabel,
"_id": $rootScope.cbTreeFirstID,
"_isRoot": "true",
"_isBranch": "true",
"_isLocked": "false"
},
"_anchor": "true",
"_window_position": "6,10",
"_window_size": "828,453" // Apply Dynamic
},
"content": {
"element": //[
$rootScope.contentNotesForSaveCB,
//]
}
}
};
$scope.slideshow = $rootScope.dynamicUpdatedJsonForSaveCB;
$scope.filename = "SandySaveCB.json";
var filename = $scope.filename;
var blob = new Blob([angular.toJson($rootScope.dynamicUpdatedJsonForSaveCB, true)], { type: 'text/text' });
if (window.navigator && window.navigator.msSaveOrOpenBlob) {
window.navigator.msSaveOrOpenBlob(blob, filename);
}
else {
$(document).execCommand("SaveAs", true, filename);
document.execCommand("SaveAs", true, filename);
angular.element(document.execCommand("SaveAs", false, filename)).scope();
//var e = document.createEvent('MouseEvents'),
//a = document.createElement('a');
// a.download = filename;
//a.href = window.URL.createObjectURL(blob);
//a.dataset.downloadurl = ['text/json', a.download, a.href].join(':');
//e.initEvent('click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
//a.dispatchEvent(e);
//window.URL.revokeObjectURL(url); // clean the url.createObjectURL resource
}
$rootScope.dynamicUpdatedJsonForSaveCB = "";
//$rootScope.contentNotesForSaveCB = [];
//$rootScope.structureObjForSaveCB = [];
// $http({ method: 'Post', url: $scope.fileName }).success(function (data) {
// localStorage.setItem("cbJsonDataObject", JSON.stringify(data));
// $rootScope.cbJsonData = JSON.parse(localStorage.getItem("cbJsonDataObject"));
// $rootScope.cbDynamicJsonData = data;
// //$scope.getCBsummary();
// $rootScope.cbJsonData.slideshow.content.element = "Eement data";
// $rootScope.cbDynamicJsonData.slideshow.content.element = "slideshow element data";
// $rootScope.note = "save data"
// //$scope.openCurriculumDetail();
// })
//.error(function (data, status, headers, config) {
// console.log(data);
//});
};
$scope.addSection = function (currentid, AddSecionId) {
if ($rootScope.structureObjForSaveCB.length == 0) {
$rootScope.structureObjForSaveCB = $rootScope.stru.structure.structure;
}
if ($rootScope.contentNotesForSaveCB.length == 0) {
$rootScope.contentNotesForSaveCB = $rootScope.cbDynamicContents;
}
traverseTreeSelectedSingleObj($rootScope.stru, currentid);
traverse($rootScope.stru, currentid);
if (currentid == "-225638207") {
$rootScope.selectedNodeSingle.push(
{
"structure": {
"structure": [
],
"_label": "New Section",
"_id": AddSecionId,
"_isRoot": "false",
"_isBranch": "true",
"_isLocked": "false"
}
});
$rootScope.structureObjForSaveCB.push(
{
"structure": [
],
"_label": "New Section",
"_id": AddSecionId,
"_isRoot": "false",
"_isBranch": "true",
"_isLocked": "false"
});
}
else {
$scope.selectedNodeSingleObj['structure'].push(
{
"structure": [
],
"_label": "New Section",
"_id": AddSecionId,
"_isRoot": "false",
"_isBranch": "true",
"_isLocked": "false"
});
$rootScope.contentNotesForSaveCB.push(
{
"summary": "",
"author": "",
"modified": "",
"password": "",
"version": "",
"windows": "",
"_id": AddSecionId
//"notes": notesForSelectedSlide,
//"windows": windowsInSelectedSlide,
//"_id": cbCurrentId
});
//if (currentid == $rootScope.cbTreeFirstID) {
// $rootScope.structureObjForSaveCB.push(
// {
// "structure": [
// ],
// "_label": "New Section",
// "_id": AddSecionId,
// "_isRoot": "false",
// "_isBranch": "true",
// "_isLocked": "false"
// });
//}
//else {
for (var i = 0; i < $rootScope.structureObjForSaveCB.length; i++) {
if ($rootScope.structureObjForSaveCB[i]._id == currentid) {
$rootScope.structureObjForSaveCB[i]['structure'] = $scope.selectedNodeSingleObj['structure'];
}
}
//}
}
// setTimeout(function () { traverseTreeForSetIcons($rootScope.stru, currentid); }, 1500);
}
$scope.addSlide = function (currentid, AddSlideId) {
if ($rootScope.structureObjForSaveCB.length == 0) {
$rootScope.structureObjForSaveCB = $rootScope.stru.structure.structure;
}
//if ($rootScope.contentNotesForSaveCB.length == 0) {
// $rootScope.contentNotesForSaveCB = $rootScope.cbDynamicContents;
//}
traverseTreeSelectedSingleObj($rootScope.stru, currentid);
// traverse($rootScope.stru, currentid);
//console.log(JSON.stringify($scope.upDateJsonObj))
if (currentid == "-225638207") {
$rootScope.selectedNodeSingle.push(
{
"_label": "NEW Slide1",
"_id": AddSlideId,
"_isRoot": "false",
"_isBranch": "false",
"_isLocked": "false"
});
$rootScope.structureObjForSaveCB.push({
"_label": "NEW Slide1",
"_id": AddSlideId,
"_isRoot": "false",
"_isBranch": "false",
"_isLocked": "false"
});
}
else {
$scope.selectedNodeSingleObj['structure'].push({
"_label": "New Slide",
"_id": AddSlideId,
"_isRoot": "false",
"_isBranch": "false",
"_isLocked": "false"
});
//$rootScope.contentNotesForSaveCB.push({
// "notes": tinyMCE.activeEditor.getContent(),
// "windows": "",
// "_id": AddSlideId
//});
//if (currentid == $rootScope.cbTreeFirstID) {
// $rootScope.structureObjForSaveCB.push({
// "_label": "New Slide",
// "_id": AddSlideId,
// "_isRoot": "false",
// "_isBranch": "false",
// "_isLocked": "false"
// });
//}
//else {
for (var i = 0; i < $rootScope.structureObjForSaveCB.length; i++) {
if ($rootScope.structureObjForSaveCB[i]._id == currentid) {
$rootScope.structureObjForSaveCB[i]['structure'] = $scope.selectedNodeSingleObj['structure'];
}
}
//}
}
// setTimeout(function () { traverseTreeForSetIcons($rootScope.stru, currentid); }, 3000);
setTimeout(function () { $("#jstree").jstree(true).set_icon(AddSlideId, "../../../content/images/CB/file.png"); }, 100);
}
$scope.moveDown = function (currentid) {
traverse($rootScope.stru, currentid);
for (var j = 0; j < $scope.selectedNodeSiblingObjs.length; j++) {
if (($scope.selectedNodeSiblingObjs[j]._id == currentid) && ($scope.selectedNodeSiblingObjs[j + 1] != undefined)) {
var key1 = $scope.selectedNodeSiblingObjs[j];
$scope.selectedNodeSiblingObjs[j] = $scope.selectedNodeSiblingObjs[j + 1];
$scope.selectedNodeSiblingObjs[j + 1] = key1;
break;
}
}
$rootScope.structureObjForSaveCB = $rootScope.stru.structure.structure;
}
$scope.moveUP = function (currentid) {
traverse($rootScope.stru, currentid);
//console.log("cbJsonData Before" + JSON.stringify($rootScope.stru));
//console.log("upDateJsonObj Before" + JSON.stringify($scope.selectedNodeSiblingObjs));
for (var j = 0; j < $scope.selectedNodeSiblingObjs.length; j++) {
if (($scope.selectedNodeSiblingObjs[j]._id == currentid) && ($scope.selectedNodeSiblingObjs[j - 1] != undefined)) {
var key = $scope.selectedNodeSiblingObjs[j];
$scope.selectedNodeSiblingObjs[j] = $scope.selectedNodeSiblingObjs[j - 1];
$scope.selectedNodeSiblingObjs[j - 1] = key;
}
}
$rootScope.structureObjForSaveCB = $rootScope.stru.structure.structure;
//console.log("upDateJsonObjenew after" + JSON.stringify($scope.selectedNodeSiblingObjs));
//console.log("stru after" + JSON.stringify($rootScope.stru));
//console.log("structure after" + JSON.stringify($rootScope.structure));
}
function traverseTreeSelectedSingleObj(o, current_id) {
for (var i in o) {
if (o[i] !== null && typeof (o[i]) == "object") {
if (o[i]._id == current_id) {
$scope.selectedNodeSingleObj = o[i];
}
traverseTreeSelectedSingleObj(o[i], current_id);
}
}
}
$(function () {
$("#modal-CurBuilder").draggable();
});
$scope.loadContentOfSelectedSlide = function (id) {
// alert("Id" + id);
console.log("id= " + id)
//var content = $rootScope.cbJsonData.slideshow.content.element;
if ($rootScope.contentNotesForSaveCB.length == 0) {
$rootScope.contentNotesForSaveCB = $rootScope.cbDynamicContents;
}
var content = $rootScope.contentNotesForSaveCB;
var contenctForSelectedSlide = new jinqJs()
.from(content)
.where("_id == " + id)
.select();
// console.log('contenctForSelectedSlide' + contenctForSelectedSlide[0].notes)
var windowsInSelectedSlide = contenctForSelectedSlide[0].windows;
var allwindowData = windowsInSelectedSlide.window;
var windowData;
var imageSourc;
var DawindowId = 0;
var AtlasWindowId = 0;
var CIWindowId = 0;
var CAWindowId = 0;
var ThreeDWindowId = 0;
//check for multiple windows, if Array.isArray==true
if (allwindowData != undefined && Array.isArray(allwindowData)) {
for (var i = 0; i < allwindowData.length; i++) {
if (allwindowData[i].indexOf('imageSource') != -1) {
// var subS = allwindowData[i].substring(allwindowData.indexOf('imageSource'), allwindowData[i].length - 1);
// var subS1 = allwindowData[i].split('imageSource');
// windowData = JSON.parse(subS1[0]);
// imageSourc = subS1[1];
windowData = JSON.parse(allwindowData[i])
if (windowData.mType == "MY_PICTURES") {
$rootScope.windowsimageSource = windowData.imageSource;
$rootScope.windowstitle = windowData.windowTitle;
$scope.openImagePanel();
}
}
else {
windowData = JSON.parse(allwindowData[i])
// **** Use this code when all module complted
// var isFound = jQuery.inArray(windowData.mType, $scope.LoadModuleName)
// if (isFound == -1) {
// $scope.LoadModuleName.push(windowData.mType);
// }
if (windowData.mType == "DISSECTIBLE_ANATOMY") {
ModuleService.setModuleData(windowData, DawindowId);
DawindowId = DawindowId + 1;
var isFound = jQuery.inArray(windowData.mType, $scope.LoadModuleName)
if (isFound == -1) {
$scope.LoadModuleName.push(windowData.mType);
}
}
else if (windowData.mType == "ATLAS_ANATOMY") {
ModuleService.setModuleData(windowData, AtlasWindowId);
AtlasWindowId = AtlasWindowId + 1;
var isFound = jQuery.inArray(windowData.mType, $scope.LoadModuleName)
if (isFound == -1) {
$scope.LoadModuleName.push(windowData.mType);
}
}
else if (windowData.mType == "CLINICAL_ILLUSTRATIONS") {
ModuleService.setModuleData(windowData, CIWindowId);
CIWindowId = CIWindowId + 1;
var isFound = jQuery.inArray(windowData.mType, $scope.LoadModuleName)
if (isFound == -1) {
$scope.LoadModuleName.push(windowData.mType);
}
}
else if (windowData.mType == "CLINICAL_ANIMATIONS") {
ModuleService.setModuleData(windowData, CAWindowId);
CAWindowId = CAWindowId + 1;
var isFound = jQuery.inArray(windowData.mType, $scope.LoadModuleName)
if (isFound == -1) {
$scope.LoadModuleName.push(windowData.mType);
}
}
else if (windowData.mType == "THREE_D_ANATOMY") {
ModuleService.setModuleData(windowData, ThreeDWindowId);
ThreeDWindowId = ThreeDWindowId + 1;
var isFound = jQuery.inArray(windowData.mType, $scope.LoadModuleName)
if (isFound == -1) {
$scope.LoadModuleName.push(windowData.mType);
}
}
}
}
}
else {
// single window
windowData = JSON.parse(allwindowData);
if (windowData.mType == "MY_PICTURES") {
$rootScope.windowsimageSource = windowData.imageSource;
$rootScope.windowstitle = windowData.windowTitle;
$scope.openImagePanel();
}
else if (windowData.mType == "DISSECTIBLE_ANATOMY") {
var isFound = jQuery.inArray(windowData.mType, $scope.LoadModuleName)
if (isFound == -1) {
$scope.LoadModuleName.push(windowData.mType);
}
ModuleService.setModuleData(windowData, DawindowId);
}
else if (windowData.mType == "ATLAS_ANATOMY") {
var isFound = jQuery.inArray(windowData.mType, $scope.LoadModuleName)
if (isFound == -1) {
$scope.LoadModuleName.push(windowData.mType);
}
ModuleService.setModuleData(windowData, AtlasWindowId);
}
else if (windowData.mType == "CLINICAL_ILLUSTRATIONS") {
var isFound = jQuery.inArray(windowData.mType, $scope.LoadModuleName)
if (isFound == -1) {
$scope.LoadModuleName.push(windowData.mType);
}
ModuleService.setModuleData(windowData, CIWindowId);
}
else if (windowData.mType == "CLINICAL_ANIMATIONS") {
var isFound = jQuery.inArray(windowData.mType, $scope.LoadModuleName)
if (isFound == -1) {
$scope.LoadModuleName.push(windowData.mType);
}
ModuleService.setModuleData(windowData, CAWindowId);
}
else if (windowData.mType == "THREE_D_ANATOMY") {
var isFound = jQuery.inArray(windowData.mType, $scope.LoadModuleName)
if (isFound == -1) {
$scope.LoadModuleName.push(windowData.mType);
}
ModuleService.setModuleData(windowData, ThreeDWindowId);
}
}
// intially call module at index 0
$scope.$emit("LoadModuleComplete", "");
}
$scope.$on("LoadModuleComplete", function (evt, name) {
if ($scope.LoadModuleName != undefined) {
var index = $scope.LoadModuleName.indexOf(name);
if (index != -1) {
// remove module which one is loaded
$scope.LoadModuleName.splice(index, 1);
}
if ($scope.LoadModuleName.length > 0) {
var nextmodulename = $scope.LoadModuleName[0];
$scope.loadModuleWithCB(nextmodulename);
}
else { //Added Code by sandeep for user story-52696
$("#viwerSelect").empty();
var modulePanel = $("#HomeContainerDiv").find("div[id*='ImagePanel']");
if (modulePanel != undefined && modulePanel != null) {
// $('#viwerSelect').append('');
//Added code by sandeep for fixed Bug-58066
if (modulePanel.length > 0) {
$('#viwerSelect').show();
}
}
else {
$('#viwerSelect').hide();
}
for (var i = 0 ; i < modulePanel.length; i++) {
var paneld = modulePanel[i].id;
var panelTitle = document.getElementById(paneld).childNodes[0].innerText;
$('#viwerSelect').append('');
}
$scope.CBEnableUI();
// scroll down to first panel
if (modulePanel.length > 0) {
if (modulePanel[0].id != undefined) {
var lastpanel = modulePanel[0].id;
//$('body,html').animate({ scrollTop: $('#' + lastpanel).position().top }, 1000);
}
}
}
}
});
$scope.loadModuleWithCB = function (moduleName) {
switch (moduleName) {
case "DISSECTIBLE_ANATOMY":
$scope.loadDissectibleAnatomyModule(moduleName);
break;
case "ATLAS_ANATOMY":
$scope.loadAtlasAnatomyModule(moduleName);
break;
case "CLINICAL_ILLUSTRATIONS":
$scope.loadClinicalIllustrationModule(moduleName);
break;
case "CLINICAL_ANIMATIONS":
$scope.loadClinicalAnimationModule(moduleName);
break;
case "THREE_D_ANATOMY":
$scope.load3DAnatomyModule(moduleName);
break;
case "ADAM_IMAGES":
$scope.loadAdamImageModule(moduleName);
break;
case "LAB_EXERCISE":
$scope.loadLabExerciseModule(moduleName);
break;
}
}
$scope.loadLabExerciseModule = function (moduleName) {
var labData = ModuleService.getModuleData(moduleName);
if (labData != undefined && labData.length > 0) {
$rootScope.isCallFromOtherModule = true;
var aiSectionExist = document.getElementById('labCustomModuleDiv');
if (aiSectionExist == null) {
$('#cbparentcustomDiv').append($(''));
$e = $('#labCustomModuleDiv').append("");
$compile($e)($scope);
}
else {
// open lab panel on same slide by open resource
$rootScope.InitializeLabExerciseMain();
}
}
}
$scope.loadAdamImageModule = function (moduleName) {
var AIData = ModuleService.getModuleData(moduleName);
if (AIData != undefined && AIData.length > 0) {
$rootScope.isCallFromOtherModule = true;
var aiSectionExist = document.getElementById('aiCustomModuleDiv');
if (aiSectionExist == null) {
$('#cbparentcustomDiv').append($(''));
$e = $('#aiCustomModuleDiv').append("");
$compile($e)($scope);
}
else {
// open Adam Image panel on same slide by open resource
$rootScope.OpenAdamImageViewMain();
}
}
}
$scope.load3DAnatomyModule = function (moduleName) {
var ThreeDData = ModuleService.getModuleData(moduleName);
if (ThreeDData != undefined && ThreeDData.length > 0) {
$rootScope.isCallFromOtherModule = true;
var threeDSectionExist = document.getElementById('theeDCustomModuleDiv');
if (threeDSectionExist == null) {
$('#cbparentcustomDiv').append($(''));
$e = $('#theeDCustomModuleDiv').append("");
$compile($e)($scope);
}
else {
// open new 3D panel on same slide by open resource
$rootScope.Open3DModelBodyMain();
}
}
}
$scope.loadClinicalAnimationModule = function (moduleName) {
var CAData = ModuleService.getModuleData(moduleName);
if (CAData != undefined && CAData.length > 0) {
$rootScope.isCallFromOtherModule = true;
var caSectionExist = document.getElementById('caCustomModuleDiv');
if (caSectionExist == null) {
$('#cbparentcustomDiv').append($(''));
$e = $('#caCustomModuleDiv').append("");
$compile($e)($scope);
}
else {
// open new aa panel on same slide by open resource
$rootScope.openCABodyViewMain();
}
}
}
$scope.loadClinicalIllustrationModule = function (moduleName) {
var CIData = ModuleService.getModuleData(moduleName);
if (CIData != undefined && CIData.length > 0) {
$rootScope.isCallFromOtherModule = true;
var ciSectionExist = document.getElementById('ciCustomModuleDiv');
if (ciSectionExist == null) {
$('#cbparentcustomDiv').append($(''));
$e = $('#ciCustomModuleDiv').append("");
$compile($e)($scope);
}
else {
// open new aa panel on same slide by open resource
$rootScope.openCIBodyViewMain();
}
}
}
$scope.loadAtlasAnatomyModule = function (moduleName) {
var AAData = ModuleService.getModuleData(moduleName);
if (AAData != undefined && AAData.length > 0) {
$rootScope.isCallFromOtherModule = true;
var aaSectionExist = document.getElementById('aaCustomModuleDiv');
if (aaSectionExist == null) {
$('#cbparentcustomDiv').append($(''));
$e = $('#aaCustomModuleDiv').append("");
$compile($e)($scope);
}
else {
// open new aa panel on same slide by open resource
$rootScope.openAAModuleItemMain();
}
}
}
$scope.loadDissectibleAnatomyModule = function (moduleName) {
var DAData = ModuleService.getModuleData(moduleName);
if (DAData != undefined && DAData.length > 0) {
$rootScope.isCallFromOtherModule = true;
var daSectionExist = document.getElementById('daCustomModuleDiv');
if (daSectionExist==null){
$('#cbparentcustomDiv').append($(''));
$e = $('#daCustomModuleDiv').append("");
$compile($e)($scope);
}
else
{
// open new da panel on same slide by open resource
$rootScope.openDABodyViewMain();
}
}
}
//Added code by sandeep for user story-52696
$rootScope.viwerSelectOnChange = function (obj) {
//var selectedText = $("#viwerSelect option:selected").text();
var selected_Id = $("#viwerSelect option:selected").val();
if (selected_Id != "0") {
$('body,html').animate({ scrollTop: $('#' + selected_Id).position().top }, 500);
}
}
//Start Code for Update Windows Content for DA, CA, CI, AA, 3D Module to Save CB
$scope.windowsContentForSelectedSlide = function (currentId) {
var contentWindowsdata = $rootScope.contentNotesForSaveCB;
$scope.setWinDataToArray = [];
var selectedSlideContent = new jinqJs()
.from(contentWindowsdata)
.where("_id == " + currentId)
.select();
if (selectedSlideContent[0].windows != "") {
if (selectedSlideContent != undefined && Array.isArray(selectedSlideContent[0].windows.window)) {
for (var i = 0 ; i < selectedSlideContent[0].windows.window.length; i++) {
$scope.windowDataforCB = JSON.parse(selectedSlideContent[0].windows.window[i])
$scope.setWinDataToArray.push($scope.windowDataforCB);
}
}
else {
$scope.windowDataforCB = JSON.parse(selectedSlideContent[0].windows.window)
$scope.setWinDataToArray.push($scope.windowDataforCB);
}
$rootScope.updateWindowsContentForSaveCB_Old(currentId);
}
}
$scope.updatedWindowListForSaveCB = [];
$rootScope.updateWindowsContentForSaveCB_Old = function (currentId) {
var isAA = true; var isCI = true; var isDA = true;
for (var j = 0; j < $scope.setWinDataToArray.length; j++) {
switch ($scope.setWinDataToArray[j].mType) {
case "MY_PICTURES":
$scope.savePicWindowActivity($scope.windowDataforCB);
break;
case "DISSECTIBLE_ANATOMY":
$scope.saveDAWindowActivity();
break;
case "ATLAS_ANATOMY":
if (isAA) {
$scope.saveAAWindowActivity();
isAA = false;
}
break;
case "CLINICAL_ILLUSTRATIONS":
if (isCI) {
$scope.saveCIWindowActivity();
isCI = false;
}
break;
case "CLINICAL_ANIMATIONS":
$scope.saveCAWindowActivity();
break;
case "THREE_D_ANATOMY":
$scope.save3DWindowActivity();
break;
default:
}
}
findKeyForChange($rootScope.contentNotesForSaveCB, currentId);
$scope.selectedKey.windows.window = [];
for (var s = 0; s < $scope.updatedWindowListForSaveCB.length; s++)
{
var arrToStrWinObj = JSON.stringify($scope.updatedWindowListForSaveCB[s]);
$scope.selectedKey.windows.window.push(arrToStrWinObj);
}
$scope.updatedWindowListForSaveCB = [];
console.log($scope.selectedKey.windows.window);
}
$scope.saveCIWindowActivity_Old = function (keyName, value) {
for (var i = 0; i < $scope.setWinDataToArray.length; i++) {
$scope.setWinDataToArray[i][keyName] = value;
var current_id;
if (($rootScope.getLocalStorageValue("cbSelectId")) != '') {
current_id = $rootScope.getLocalStorageValue("cbSelectId");
}
else {
current_id = document.getElementById('cbSelect').value;
}
findKeyForChange($rootScope.contentNotesForSaveCB, current_id);
//var modifiedWindowObj = JSON.parse($scope.selectedKey.windows.window);
//modifiedWindowObj.textVisible = value;
//$scope.selectedKey.windows.window = modifiedWindowObj;
$scope.selectedKey.windows.window = "";
if (keyName != "") {
$scope.selectedKey.windows.window = JSON.stringify($scope.setWinDataToArray[i]);
}
}
console.log($rootScope.contentNotesForSaveCB);
//$scope.windowDataforCB = {
//slideId: currentId,//SlideNo,
//currentWindowId: windowId,
//mType: windowData.mType,
//containsCapturedContent: windowData.containsCapturedContent,
//textVisible: checkVisiblity//windowData.textVisible,
//anatomyTitle: windowData.currentViewTitle,
//horizontalScroll: windowData.scrollPosition.horizontal + 'px',
//verticalScroll: windowData.scrollPosition.vertical + 'px',
//imageId: windowData.imageId,//N
//maximised: windowData.maximised,//Not Found
//minimised: windowData.minimised,//Not Found
//id: windowData.id,
//size: windowData.size,
//position: windowData.position,
//position: {
// top: $rootScope.jsPanelTop,
// left: $rootScope.jsPanelLeft,
//},
//size: {
// width: $rootScope.jsPanelWidth,
// height: $rootScope.jsPanelHeight
//},
//contextMenu: windowData.contextMenu,
//annotationData: windowData.annotationData
//};
}
function findKeyForChange(o, keyname) {
var i;
for (i in o) {
if (o[i] !== null && typeof (o[i]) == "object") {
if (o[i]._id == keyname) {
$scope.selectedKey = o[i];
}
findKeyForChange(o[i], keyname);
}
//else {
// if (i == keyname) {
// $scope.selectedKey = i;
// }
//}
}
}
//Save DISSECTIBLE_ANATOMY activity for CB
$scope.saveCIWindowActivity = function (currentId) {
if ($rootScope.CIWindowData != undefined && $rootScope.CIWindowData.length > 0 ) {
for (var i = 0; i < $rootScope.CIWindowData.length; i++) {
$scope.updatedWindowListForSaveCB.push({
containsCapturedContent: true,//$rootScope.CIWindowData[i] // N
annotationData: $rootScope.CIWindowData[i].annotationData,//$rootScope.CIWindowData[i] N
contextMenu: { lockResize: false, hideTitleBar: false }, // N
position: {
top: $rootScope.CIWindowData[i].top,
left: $rootScope.CIWindowData[i].left,
},
size: {
height: $rootScope.CIWindowData[i].height,
width: $rootScope.CIWindowData[i].width
},
textVisible: $rootScope.CIWindowData[i].isTextVisible,
imageId: $rootScope.CIWindowData[i].imageId,
minimised: $rootScope.CIWindowData[i].minimised,
windowTitle: $rootScope.CIWindowData[i].currentViewTitle,
maximised: $rootScope.CIWindowData[i].maximised,
mType: $rootScope.CIWindowData[i].moduleName,
id: $rootScope.CIWindowData[i].imageId,
scrollPosition: { vertical: 0, horizontal: 0 },// N
windowListId: 0 //$rootScope.CIWindowData[i] // N
});
}
$rootScope.CIWindowData = [];
}
}
//Save CLINICAL_ANIMATIONS activity for CB
$scope.saveCAWindowActivity = function (currentId) {
if ($rootScope.CAWindowData != undefined && $rootScope.CAWindowData.length > 0) {
for (var i = 0; i < $rootScope.CAWindowData.length; i++) {
$scope.updatedWindowListForSaveCB.push({
containsCapturedContent: true,//$rootScope.CAWindowData[i] // N
//annotationData: "",//$rootScope.CAWindowData[i] N
contextMenu: { lockResize: false, hideToolBar: false, hideTitleBar: false },//N
position: {
top: $rootScope.CAWindowData[i].top,
left: $rootScope.CAWindowData[i].left,
},
size: {
height: $rootScope.CAWindowData[i].height,
width: $rootScope.CAWindowData[i].width
},
textVisible: $rootScope.CAWindowData[i].isTextVisible,
imageId: $rootScope.CAWindowData[i].imageId,
minimised: $rootScope.CAWindowData[i].minimised,
windowTitle: $rootScope.CAWindowData[i].currentViewTitle,
maximised: $rootScope.CAWindowData[i].maximised,
mType: $rootScope.CAWindowData[i].moduleName,
id: $rootScope.CAWindowData[i].imageId,//Add id in CA.js
scrollFlvPosition: { vertical: 0, horizontal: 0 },// N
windowListId: 0 //$rootScope.CAWindowData[i] // N
});
}
$rootScope.CAWindowData = [];
}
}
//Save THREE_D_ANATOMY activity for CB
$scope.save3DWindowActivity = function (currentId) {
if ($rootScope.TheeDWindowData != undefined && $rootScope.TheeDWindowData.length > 0) {
for (var i = 0; i < $rootScope.TheeDWindowData.length; i++) {
$scope.updatedWindowListForSaveCB.push({
containsCapturedContent: true,//$rootScope.TheeDWindowData[i] // N
//annotationData: "",//$rootScope.TheeDWindowData[i] N
contextMenu:{ lockResize: true, hideTitleBar: true, hideToolBar: false, hideLeftBar: false, hideTopToolBar: false },
position: {
top: $rootScope.TheeDWindowData[i].top,
left: $rootScope.TheeDWindowData[i].left,
},
size: {
height: $rootScope.TheeDWindowData[i].height,
width: $rootScope.TheeDWindowData[i].width
},
//textVisible: $rootScope.TheeDWindowData[i].isTextVisible,
imageId: $rootScope.TheeDWindowData[i].imageId,
minimised: $rootScope.TheeDWindowData[i].minimised,
windowTitle: $rootScope.TheeDWindowData[i].currentViewTitle,
maximised: $rootScope.TheeDWindowData[i].maximised,
mType: $rootScope.TheeDWindowData[i].moduleName,
id: $rootScope.TheeDWindowData[i].imageId,
windowListId: 0, //$rootScope.TheeDWindowData[i] // N
threeDData: $rootScope.TheeDWindowData[i].threeDAnatomyData,
contentPath: $rootScope.TheeDWindowData[i].ImagePath,
scrollPosition: { vertical: $rootScope.TheeDWindowData[i].verticalScroll ? 0 : 0 , horizontal: 0 },
});
}
$rootScope.TheeDWindowData = [];
}
}
//Save MY_PICTURES activity for CB
$scope.saveMyPictureWindowActivity = function (currentId) {
// if ($rootScope.TheeDWindowData != undefined && $rootScope.TheeDWindowData.length > 0) {
for (var i = 0; i < $rootScope.TheeDWindowData.length; i++) {
$scope.updatedWindowListForSaveCB.push({
containsCapturedContent: true,//$rootScope.TheeDWindowData[i] // N
//annotationData: "",//$rootScope.TheeDWindowData[i] N
contextMenu: { lockResize: true, hideTitleBar: true },
position: {
top: $rootScope.TheeDWindowData[i].top,
left: $rootScope.TheeDWindowData[i].left,
},
size: {
height: $rootScope.TheeDWindowData[i].height,
width: $rootScope.TheeDWindowData[i].width
},
imageId: $rootScope.TheeDWindowData[i].imageId,
minimised: $rootScope.TheeDWindowData[i].minimised,
windowTitle: $rootScope.TheeDWindowData[i].currentViewTitle,
maximised: $rootScope.TheeDWindowData[i].maximised,
mType: $rootScope.TheeDWindowData[i].moduleName,
id: $rootScope.TheeDWindowData[i].imageId,
windowListId: 0, //$rootScope.TheeDWindowData[i] // N
scrollPosition: { vertical: 0, horizontal: 0 },
imageSource: ""
});
}
//$rootScope.TheeDWindowData = [];
//}
}
//Save ATLAS_ANATOMY activity for CB
$scope.saveAAWindowActivity = function () {
if ($rootScope.AAWindowData != undefined && $rootScope.AAWindowData.length > 0) {
for (var i = 0; i < $rootScope.AAWindowData.length; i++) {
$scope.updatedWindowListForSaveCB.push({
windowTitle: $rootScope.AAWindowData[i].currentViewTitle,
hideAllPins: $rootScope.AAWindowData[i].isHidePinBtnClicked,
selectedCallouts: $rootScope.AAWindowData[i].CBselectedpinCordinate,
annotationData: $rootScope.AAWindowData[i].annotationData,//No find in AA.js
minimised: $rootScope.AAWindowData[i].minimised,
scrollPosition: {
vertical: $rootScope.AAWindowData[i].verticalScroll,
horizontal: $rootScope.AAWindowData[i].horizontalScroll
},
selectedStructureID: 0,//N
selectedPins: $rootScope.AAWindowData[i].selectedPins,
maximised: $rootScope.AAWindowData[i].maximised,
size: {
width: $rootScope.AAWindowData[i].width,
height: $rootScope.AAWindowData[i].height
},
id: $rootScope.AAWindowData[i].id,
showSelectedPins: $rootScope.AAWindowData[i].isShowSelectedPins,
hideCallOuts: false,//N
showAllPins: $rootScope.AAWindowData[i].isShowAllPins,
scaleIndex: $rootScope.AAWindowData[i].sliderVal,
bodySystemId: $rootScope.AAWindowData[i].SelectedSystemID,
windowListId: "0",//N
imageId: $rootScope.AAWindowData[i].imageId,
//position: { x: 840, y: 263 },
position: {
top: $rootScope.AAWindowData[i].top,
left: $rootScope.AAWindowData[i].left,
},
mType: $rootScope.AAWindowData[i].moduleName,
containsCapturedContent: true,
contextMenu: { hideLeftBar: false, hideTitleBar: false, hideTopToolBar: false, lockResize: false },
//activePinArray: $rootScope.AAWindowData[i].activePinArray,
selectedSearchId: $rootScope.AAWindowData[i].selectedSearchId
//typeOfEvent: $rootScope.AAWindowData[i].typeOfEvent
});
}
$rootScope.AAWindowData = [];
}
}
//Save DISSECTIBLE_ANATOMY activity for CB
$scope.saveDAWindowActivity = function () {
if ($rootScope.DaWindowData != undefined && $rootScope.DaWindowData.length > 0) {
for (var i = 0; i < $rootScope.DaWindowData.length; i++) {
$scope.updatedWindowListForSaveCB.push({
bodySystemTermList: $rootScope.DaWindowData[i].BodySystemData,
isTitleBarVisible: false, //BodySystemData.isTitleBarVisible,//N
highlightOptionsSelectedId: 0,
selectedStructureID: 0,//N
contentDescriptorId: 0,
callOuts: $rootScope.DaWindowData[i].CurriculumTermData,
//hideAllPins: $rootScope.DaWindowData[i].isHidePinBtnClicked,
//selectedCallouts: $rootScope.DaWindowData[i].CBselectedpinCordinate,
layerNumber: parseInt($rootScope.DaWindowData[i].layerNumber) + 1,
isModestyOn: $rootScope.DaWindowData[i].ModestyValue,
isTransparent: $rootScope.DaWindowData[i].isTransparencyActivated,
isTopToolBarVisible: false, //$rootScope.DaWindowData[i].isTopToolBarVisible,
clickedTermList: $rootScope.DaWindowData[i].fullTermlist,
minimised: $rootScope.DaWindowData[i].minimised,
windowTitle: $rootScope.DaWindowData[i].currentViewTitle,
//scrollPosition: {
// vertical: $rootScope.DaWindowData[i].verticalScroll,
// horizontal: $rootScope.DaWindowData[i].horizontalScroll
//},
//selectedPins: $rootScope.DaWindowData[i].clickedPins,
maximised: $rootScope.DaWindowData[i].maximised,
size: {
width: $rootScope.DaWindowData[i].width,
height: $rootScope.DaWindowData[i].height
},
id: $rootScope.DaWindowData[i].voId,
//showSelectedPins: $rootScope.DaWindowData[i].isShowSelectedSystemPinsClicked,
// hideCallOuts: false,//N
//showAllPins: $rootScope.DaWindowData[i].isShowBodyWithCBPinData,//N
//scaleIndex: 0,//N
//bodySystemId: $rootScope.DaWindowData[i].SelectedSystemID,
//position: { x: 840, y: 263 },
imageId: $rootScope.DaWindowData[i].imageId,
position: {
top: $rootScope.DaWindowData[i].top,
left: $rootScope.DaWindowData[i].left,
},
mType: $rootScope.DaWindowData[i].moduleName,
containsCapturedContent: true,
//contextMenu: { hideLeftBar: false, hideTitleBar: false, hideTopToolBar: false, lockResize: false },
//activePinArray: $rootScope.DaWindowData[i].activePinArray, // Selected PINID on Body
//sliderVal: $rootScope.DaWindowData[i].sliderVal,
zoom: $rootScope.DaWindowData[i].zoomInOut,
skinId: $rootScope.DaWindowData[i].curentEthnicity,
isResizeLock: false , //.isResizeLock,//N
mode: $rootScope.DaWindowData[i].mode,
windowListId: 0,//windowData.windowListId,//25
canvasVScrollX: $rootScope.DaWindowData[i].CanvasDivTopPosition,
canvasHScrollX: $rootScope.DaWindowData[i].CanvasDivLeftPosition,
isCallOutVisible: false,
annotationData:$rootScope.DaWindowData[i].annotationData,
transparencyBounds: 0,//windowData.transparencyBounds,
isLeftToolBarVisible: false, //windowData.isLeftToolBarVisible,//N
isModuleLoaded: false, //.isModuleLoaded,//N
transparencyValue: 0,//N
layerNumberTransparency: false, //layerNumberTransparency,//N
searchSelectedText: $rootScope.DaWindowData[i].searchSelectedText,
prevId: $rootScope.DaWindowData[i].prevId //ActualTermnumber for chnages body image
});
}
$rootScope.DaWindowData = [];
}
}
$scope.updateWindowsContentForSaveCB = function (currentId) {
$scope.saveDAWindowActivity(currentId);
$scope.saveAAWindowActivity(currentId);
$scope.saveCIWindowActivity(currentId);
$scope.saveCAWindowActivity(currentId);
$scope.save3DWindowActivity(currentId);
//$scope.savePicWindowActivity($scope.windowDataforCB);
//if ($scope.updatedWindowListForSaveCB.length > 0) {
findKeyForChange($rootScope.contentNotesForSaveCB, currentId);
$scope.selectedKey.windows.window = [];
if ($scope.updatedWindowListForSaveCB.length > 0) {
for (var s = 0; s < $scope.updatedWindowListForSaveCB.length; s++) {
var arrToStrWinObj = JSON.stringify($scope.updatedWindowListForSaveCB[s]);
if ($scope.selectedKey.windows.window != undefined) {
$scope.selectedKey.windows.window.push(arrToStrWinObj);
}
}
}
//}
$scope.updatedWindowListForSaveCB = [];
console.log($rootScope.contentNotesForSaveCB);
}
//open resoruce on slide
$scope.loadResourceOnCurrentSlide = function (newWindowData) {
var newwindowNo = 0;
var ExistData = ModuleService.getModuleData(newWindowData.mType);
if (ExistData != undefined && ExistData.length > 0) {
newwindowNo = newwindowNo + ExistData.length;
// clear all module data before open new module in cb
ModuleService.ClearWinDataByModule(newWindowData.mType);
}
var isFound = jQuery.inArray(newWindowData.mType, $scope.LoadModuleName)
if (isFound == -1) {
$scope.LoadModuleName.push(newWindowData.mType);
}
ModuleService.setModuleData(newWindowData, newwindowNo);
// intially call module at index 0
$scope.$emit("LoadModuleComplete", "");
}
}]
);
function AIAModuleOpenResoureInCB(windowData) {
var scope = angular.element(document.querySelector('[ng-controller="CurrBuildController"]')).scope();
scope.$apply(function () {
scope.loadResourceOnCurrentSlide(windowData);
});
}