AIA.controller("CurrBuildController", ["$scope", "$rootScope", "pages", "$log", "Modules", "$http", "$compile", "$location", "$timeout", "ModuleService", "$interval","$window","AuthenticationService","AIAConstants",
function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location, $timeout, ModuleService, $interval, $window, AuthenticationService, AIAConstants) {
$scope.showTabButton = false;
$scope.listCurriculumBuilder = null;
$scope.dataPopup = null;
$scope.countLeftlist;
$scope.countRightlist;
$rootScope.selectedNodeSingle = [];
$scope.selectedNodeSingleObj = [];
$rootScope.structureObjForSaveCB = [];
$rootScope.contentNotesForSaveCB = [];
$rootScope.dynamicUpdatedJsonForSaveCB = "";
$scope.isChangeFromDropDown=false;
$rootScope.collectAnimationSource = [];
$rootScope.closeAfterSaveCurriculum = false;
$rootScope.UnsaveCurriculum = $rootScope.isnewcurriculum == true? true:false;
$scope.SectionContentForExportCB=[];
$scope.IsVisible = function () {
$scope.scroll();
}
$scope.scroll = function () {
$("html,body").scrollTop(0);
}
$rootScope.closeEditorModel = function () {
document.getElementById('cbModelDeleteBackground').style.display = "none";
document.getElementById('cbModelDeleteEditorId').style.display = "none";
}
angular.element(document).ready(function (e) {
var $ua = navigator.userAgent;
if (($ua.match(/(iPod|iPhone|iPad|android)/i))) {
$("#treecontent").css('height',screen.height-140);
$("#cbdivarea").css('height',screen.height-70);
}
else
{
$("#treecontent").css('height',screen.height-280);
$("#cbdivarea").css('height',screen.height-210);
}
$('#sidebar-wrapper').unbind('click');
$("#sidebar-wrapper").on('click', function (event) {
//4. on click disable menu option
$rootScope.resetMenuOptionOnClick("CBTinyMCEPanel");
});
$(".toggle-icon").on('click', function (event) {
if ($('.CBLeft-Sidebar').hasClass('active')) {
$(".CB-JS-Panel").css('margin-left','0px');
}
else{
$(".CB-JS-Panel").css('margin-left','285px');
}
});
// close selected open panel in CB
$(document).on("click", " .jsPanel-hdr .jsPanel-hdr-r .jsPanel-btn-close .jsglyph-remove", function (event) {
// close in case of Curriculum Builder
var id = $(event.target).parent().parent().parent().parent().attr('id');
// remove panel name from dropdown
$('#viwerSelect option[value="' + id + '"]').remove();
$rootScope.UnsaveCurriculum = true;
//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');
$('#CBTextArea_ifr').css('pointer-events', 'none');
$('#CBTextArea_ifr').css('opacity', '0.7');
$('#jstree').css('pointer-events', 'none');
$('#jstree').css('opacity', '0.7');
$('#cbEditorTopMenuBar').css('pointer-events', 'none');
$('#cbEditorTopMenuBar').css('opacity', '0.7');
$('#cbEditorLeftSideBar').css('pointer-events', 'none');
$('#cbEditorLeftSideBar').css('opacity', '0.7');
$('#cbEditorRightSideBar').css('pointer-events', 'none');
$('#cbEditorRightSideBar').css('opacity', '0.7');
$('.tox-editor-header').css('pointer-events', 'none');
$('.tox-editor-header').css('opacity', '0.7');
$timeout(function () {
// in case failed default time out 40 second
var opcity = $("#HomeContainerDiv").css("opacity")
if (opcity != 1 && $scope.SectionContentForExportCB.length<=0) {
if($rootScope.loadingAnimationstatus==undefined || $rootScope.loadingAnimationstatus==0)
{
$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');
$('#CBTextArea_ifr').css('pointer-events', 'auto');
$('#CBTextArea_ifr').css('opacity', '1');
$('#jstree').css('pointer-events', 'auto');
$('#jstree').css('opacity', '1');
$('#cbEditorTopMenuBar').css('pointer-events', 'auto');
$('#cbEditorTopMenuBar').css('opacity', '1');
$('#cbEditorLeftSideBar').css('pointer-events', 'auto');
$('#cbEditorLeftSideBar').css('opacity', '1');
$('#cbEditorRightSideBar').css('pointer-events', 'auto');
$('#cbEditorRightSideBar').css('opacity', '01');
$('.tox-editor-header').css('pointer-events', 'auto');
$('.tox-editor-header').css('opacity', '1');
$scope.SlideUnlockevent();
$scope.Slidelockevent();
}
$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();
$scope.CBEnableUI();
})
.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;
var $ua = navigator.userAgent;
if (($ua.match(/(iPod|iPhone|iPad|android)/i))) {
if(screen.width<=768)
$('#modal-CurBuilder').css("left", "10%");
}
$('#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 extension='';
var fileId, file, objFileRead;
if (typeof window.FileReader !== 'function') {
$rootScope.errorMessage = "The file API isn't supported on this browser yet.";
$("#messageModal").modal('show');
return;
}
fileId = document.getElementById('openCBJsonFile');
if (!fileId) {
$rootScope.errorMessage = "File couldn't find the element.";
$("#messageModal").modal('show');
}
else if (!fileId.files) {
$rootScope.errorMessage = "This browser doesn't seem to support the `files` property of file inputs.";
$("#messageModal").modal('show');
}
else if (!fileId.files[0]) {
$rootScope.errorMessage = "Please select a file before clicking 'Load'.";
$("#messageModal").modal('show');
}
else
{
file = fileId.files[0];
extension = file.name.split(".")[1];
if ((file.type == "application/json" && extension == "json")||extension == "sldshw") {
objFileRead = new FileReader();
objFileRead.onload = ReceivedFile;
objFileRead.readAsText(file);
}
else
{
$rootScope.errorMessage = AIAConstants.CB_FILE_FORMAT_ISSUE;
$("#messageModal").modal('show');
}
}
function ReceivedFile(file) {
if(extension == "json")
{
$location.url('/curriculum-builder');
var jsonData = JSON.parse(file.target.result);
$timeout(function () {
$scope.jsonReceivedFile(jsonData)
}, 300);
}
else
{
// convert xml to json object
var x2js = new X2JS();
var curriculumobject = x2js.xml_str2json(file.target.result);
var isIncompatible= $scope.checkCompatibility(curriculumobject);
if(isIncompatible)
{
$("#btnConvertOpen").removeAttr("style");
$("#btnImportOpen").css({"display":"none"}) ;
$("#btnConvertDownLoad").css({"display":"none"}) ;
$rootScope.confirmMessage =AIAConstants.OPEN_CB_OLD_TO_NEW_ISSUE;
$timeout(function () {
$rootScope.newCurriculumObject=curriculumobject;
$("#cbMessageModal").modal('show');
}, 200);
}
else
{
$location.url('/curriculum-builder');
$timeout(function () {
$rootScope.isnewcurriculum = true;
$scope.jsonReceivedFile(curriculumobject) ;
}, 300);
}
}
}
};
}
$rootScope.ConvertOpen = function () {
$location.url('/curriculum-builder');
$timeout(function () {
$rootScope.isnewcurriculum = true;
$scope.jsonReceivedFile($rootScope.newCurriculumObject) ;
}, 300);
}
$scope.jsonReceivedFile = function (jsonData) {
localStorage.setItem("cbJsonDataObject", JSON.stringify(jsonData));
$rootScope.cbJsonData = "";
$rootScope.cbDynamicJsonData = "";
$rootScope.cbJsonData = jsonData;
$rootScope.cbDynamicJsonData = jsonData;
$rootScope.cbTreeFirstLabel = $rootScope.cbJsonData.slideshow.presentation.structure._label;
$rootScope.AutherName = "";
$rootScope.summary = "";
$rootScope.getCBsummary();
$rootScope.FileTitle = $rootScope.cbTreeFirstLabel;
$timeout(function () {
var $ua = navigator.userAgent;
if (($ua.match(/(iPod|iPhone|iPad|android)/i))) {
if(screen.width<=768)
$('#modal-CurBuilder').css("left", "10%");
}
$('#modal-CurBuilder').css("display", "block");
$("#CurBuilderbackground").css("display", "block");
}, 200);
}
$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;
//clear all module data if exist last time
$rootScope.DaWindowData=[];
$rootScope.AAWindowData=[];
$rootScope.VideoWindowData=[];
$rootScope.PICWindowData=[];
$rootScope.TheeDWindowData=[];
$rootScope.CAWindowData=[];
$rootScope.CIWindowData=[];
$rootScope.AIWindowData=[];
$rootScope.LEWindowData=[];
$location.url("/curriculum-builder-detail");
}
$rootScope.ConvertCurriculum = function () {
var fileupload = document.getElementById("xmltojsonfile");
$timeout(function () {
$(fileupload).trigger('click');
}, 300);
$(fileupload).val('');//old file path
fileupload.onchange = function () {
var myfileName='';
var fileId, file, objFileRead;
if (typeof window.FileReader !== 'function') {
$rootScope.errorMessage = "The file API isn't supported on this browser yet.";
$("#messageModal").modal('show');
return;
}
fileId = document.getElementById('xmltojsonfile');
if (!fileId) {
$rootScope.errorMessage = "File couldn't find the element.";
$("#messageModal").modal('show');
}
else if (!fileId.files) {
$rootScope.errorMessage = "This browser doesn't seem to support the `files` property of file inputs.";
$("#messageModal").modal('show');
}
else if (!fileId.files[0]) {
$rootScope.errorMessage = "Please select a file before clicking 'Load'.";
$("#messageModal").modal('show');
}
else
{
file = fileId.files[0];
myfileName=file.name.split(".")[0];
var extension = file.name.split(".")[1];
if (extension == "sldshw") {
$timeout(function () {
objFileRead = new FileReader();
objFileRead.onload = convertfile;
objFileRead.readAsText(file);
}, 300);
}
else
{
$rootScope.errorMessage = AIAConstants.CB_FILE_FORMAT_ISSUE;"";
$("#messageModal").modal('show');
}
}
function convertfile(file) {
//add extension
myfileName += '.json';
var x2js = new X2JS();
var curriculumobject = x2js.xml_str2json(file.target.result);
var isIncompatible= $scope.checkCompatibility(curriculumobject);
if(isIncompatible)
{
$("#btnConvertDownLoad").removeAttr("style");
$("#btnImportOpen").css({"display":"none"}) ;
$("#btnConvertOpen").css({"display":"none"}) ;
$rootScope.newCurriculumObject=curriculumobject;
$rootScope.convertedfileName=myfileName;
$rootScope.confirmMessage =AIAConstants.CONVERT_CB_OLD_TO_NEW_ISSUE;
$timeout(function () {
$("#cbMessageModal").modal('show');
}, 200);
}
else
{
$scope.convertDownLoad(curriculumobject,myfileName);
}
}
}
}
$rootScope.ConvertSave = function () {
$scope.convertDownLoad($rootScope.newCurriculumObject, $rootScope.convertedfileName);
}
$scope.convertDownLoad = function (curriculumobject,myfileName) {
var blob = new Blob([angular.toJson(curriculumobject, true)], { type: 'text/json' });
// document.execCommand("SaveAs", true, myfileName);
// var event = document.createEvent('MouseEvents'),
// saveElement = document.createElement('a');
// saveElement.download = myfileName;
// 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);
//save file saver handle for all browser
saveAs(blob, filename);
}
$scope.checkCompatibility = function (curriculumobject) {
var isIncompatible=false;
var cbcontent = curriculumobject.slideshow.content.element;
for (var i = 0; i < cbcontent.length; i++) {
var windowsData = cbcontent[i].windows;
if(windowsData=="")continue
var allwindowData = windowsData.window;
if(!Array.isArray(allwindowData))
{
allwindowData=[];
allwindowData.push(windowsData.window);
}
if (allwindowData != undefined) {
for (var j = 0; j < allwindowData.length; j++) {
windowData = JSON.parse(allwindowData[j]);
var annotation= windowData.annotationData;
if(annotation!="" && annotation!=undefined)
{
var shapeStates = 'shapeStates';
var paintCanvasState = 'paintCanvasState';
if (!annotation.hasOwnProperty(shapeStates) || !annotation.hasOwnProperty(paintCanvasState))
{
isIncompatible=true;
}
}
}
}
}
return isIncompatible;
}
$rootScope.CreateNewCurriculum = function () {
$scope.CBDisableUI();
var date = new Date();
var newId = date.getTime();//timestamp is the number of milliseconds that have passed since January 1, 1970
var sectionid='sn'+newId;
var slideid='sd'+newId;
var newstruct= [
{ "_label": "New Slide",
"_id": slideid,
"_isRoot": "false",
"_isBranch": "false",
"_isLocked": "false"
}
] ;
var newcontent=[
{
"summary": "",
"author": "",
"modified": "",
"password": "",
"version": "",
"windows": "",
"_id": sectionid
},
{
"notes": "",
"windows": "",
"_id": slideid
}
];
var newCbData =
{
"slideshow": {
"presentation": {
"structure": {
"structure":newstruct,
"_label": "untitled Curriculum",
"_id": sectionid,
"_isRoot": "true",
"_isBranch": "true",
"_isLocked": "false"
},
"_anchor": "true",
"_window_position": "6,10",
"_window_size": "828,453" // Apply Dynamic
},
"content": {
"element": newcontent,
}
}
};
localStorage.setItem("cbJsonDataObject", JSON.stringify(newCbData));
$rootScope.cbJsonData = "";
$rootScope.cbDynamicJsonData = "";
$rootScope.cbJsonData = newCbData;
$rootScope.cbDynamicJsonData = newCbData;
$rootScope.AutherName = "";
$rootScope.summary = "";
$rootScope.getCBsummary();
$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;
//clear all module data if exist last time
$rootScope.DaWindowData=[];
$rootScope.AAWindowData=[];
$rootScope.VideoWindowData=[];
$rootScope.PICWindowData=[];
$rootScope.TheeDWindowData=[];
$rootScope.CAWindowData=[];
$rootScope.CIWindowData=[];
$rootScope.AIWindowData=[];
$rootScope.LEWindowData=[];
$rootScope.selectedNodeSingle = [];
$scope.selectedNodeSingleObj = [];
$rootScope.structureObjForSaveCB = [];
$rootScope.contentNotesForSaveCB = [];
$rootScope.dynamicUpdatedJsonForSaveCB = "";
$scope.isChangeFromDropDown=false;
$rootScope.collectAnimationSource = [];
$scope.SectionContentForExportCB=[];
$rootScope.closeAfterSaveCurriculum = false;
$rootScope.UnsaveCurriculum = false;
$rootScope.isnewcurriculum = true;
if (($location.url() == "/curriculum-builder")) {
$location.url("/curriculum-builder-detail");
}
else
{
$scope.openNewCurriculum();
$rootScope.UnsaveCurriculum = true;
}
}
$scope.openNewCurriculum = function () {
$scope.CBDisableUI();
tinymce.get("CBTextArea").setContent("");
$('#jstree').jstree('destroy');
var $e1 = $('- '
+ '{{cbTreeFirstLabel}}'
+'"
+ ""
+ '
').appendTo('#jstree');
$compile($e1)($scope);
// initialize jstree after reset for new curriculum
callEditorOnInit();
}
$scope.openCBJsPanel = function () {
$scope.CBDisableUI();
$rootScope.isnewcurriculum = false;
$('#jstree').empty();
var $e1 = $('- '
+ '{{cbTreeFirstLabel}}'
+'"
+ ""
+ '
').appendTo('#jstree');
$compile($e1)($scope);
$timeout(function () {
$scope.openCBEditorPanel();
}, 500);
}
$scope.openCBEditorPanel = function () {
var jsContentURL = 'app/views/CBuild/curriculum-builder-TinyMCEjspanel.html';
$.jsPanel({
id: 'CBTinyMCEPanel',
selector: '.CBBodyView',
theme: 'success',
currentController: 'CurrBuildController',
parentSlug: 'curriculum-builder',
ajax: {
url: jsContentURL
},
title: $rootScope.cbTreeFirstLabel,
position: {
top: 10,
left: 10,
},
controls: { buttons: 'closeonly' },
size: { width: 820, height: 450 },
});
$timeout(function () {
$rootScope.resetMenuOptionOnClick("CBTinyMCEPanel");
$("#CBTinyMCEPanel").resize(function(){
$("#CBTextArea_ifr").css("display", "block");
});
$('#CBTinyMCEPanel').draggable({ containment: '#cbdivarea', scroll: false });
}, 200);
}
$scope.myeditorclick = function () {
//1. disable menu options
//$rootScope.resetMenuOptionOnClick("CBTinyMCEPanel");
}
$scope.loadNotesById = function () {
$("#cbSelect").empty();
traverseForLoadDropDown($rootScope.stru);
setTimeout(function () {
var nodeid = document.getElementById('cbSelect').value;
$('#jstree').jstree('select_node', nodeid);
}, 200);
}
$scope.openTinyMCE = function (nodeid) {
if ($scope.Currentselectednodeid == undefined || $scope.Currentselectednodeid != nodeid) {
$scope.CBDisableUI();
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");
$("#openPictureId").removeClass("OpenPitures");
$("#openAnimationId").removeClass("OpenPitures");
$("#export_btn").addClass("importExportSection");
$("#import_btn").addClass("importExportSection");
}
if ($scope.selectedNodeSingleObj._isBranch == "true") {
$("#Deletesection").removeClass("DeletesectionClass");
$("#DeleteSlide").addClass("DeleteslideClass");
$("#AddSlide").removeClass("cbAddSection");
$("#AddSection").removeClass("cbAddSection");
$("#openResourceId").addClass("openResources");
$("#openPictureId").addClass("OpenPitures");
$("#openAnimationId").addClass("OpenPitures");
$("#export_btn").removeClass("importExportSection");
$("#import_btn").removeClass("importExportSection");
}
$scope.nodeTypeIsBranch = $scope.selectedNodeSingleObj._isBranch;
$scope.isSlideLock = $scope.selectedNodeSingleObj._isLocked;
$scope.DropDownSelectNodeClick(nodeid);
$scope.SelectedNotes = "";
traverseTreeSelectedSingleObj($rootScope.note, nodeid);
$scope.SelectedNotes = $scope.selectedNodeSingleObj.notes;
// clear module data
ModuleService.ClearWinData();
$("#viwerSelect").empty();
$("#viwerSelect").hide();
if ($('#cbparentcustomDiv').html() != "") {
$('#cbparentcustomDiv').empty();
}
if ($('#jsPanel-min-container').html() != "") {
$('#jsPanel-min-container').empty();
}
if ($scope.nodeTypeIsBranch == "false") {
if (($scope.SelectedNotes != "" && $scope.SelectedNotes != undefined)||
($scope.selectedNodeSingleObj.windows != "" && $scope.selectedNodeSingleObj.windows != 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);
}
else {
tinymce.get("CBTextArea").setContent("");
$scope.CBEnableUI();
}
}
else {
tinymce.get("CBTextArea").setContent("");
$scope.CBEnableUI();
}
}
}
$rootScope.cbSelectOnChange = function (obj,prevValue) {
$scope.isChangeFromDropDown=true;
$scope.lastSlideValue=prevValue;
$('#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
}
if($scope.isChangeFromDropDown==true)
{
// modified by birendra
// in case of select dropdown current and prev id come same.
var lastslideid = $scope.lastSlideValue;
$scope.isChangeFromDropDown=false;
$scope.lastSlideValue="";
}
else
{
var lastslideid = document.getElementById('cbSelect').value;
}
$rootScope.updatedContentFromEditor(lastslideid);//Calling for Update Note for Save CB
if (isActive) {
$scope.updateWindowsContentForSaveCB(lastslideid,true);// 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;
}
}
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 () {
$scope.isChangeFromDropDown=false;
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 () {
$scope.isChangeFromDropDown=false;
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 () {
if( $scope.isSlideLock=="true")
{
$("#slidepass").val("");
$(".unlock-slidemodal").modal("show").draggable({ handle: ".modal-header" });
$(".modal-backdrop").css("opacity", ".5");
$(".modal-backdrop").css("z-index", "1200001");
}
else
{
$('#cbPassword').val("");
$('#cbConfirmPassWord').val("");
$('#errorMsg').text('');
document.getElementById('cbModelRenameBackground').style.display = "block";
document.getElementById('cbModelUserPassWord').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.contentNotesForSaveCB, current_id);
$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 oldslidetext = $("#cbSelect option:selected").text();
var newSlideText = document.getElementById('renameInputBoxId').value;
if (oldslidetext != newSlideText) {
$rootScope.UnsaveCurriculum = true;
}
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;
}
//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.SlideUnlockevent=function(){
if( $scope.isSlideLock=="false")
{
$('.tox-editor-header').css('pointer-events', 'auto');
$('.tox-editor-header').css('opacity', '1');
$('#CBTextArea_ifr').css('pointer-events', 'auto');
$('#CBTextArea_ifr').css('opacity', '1');
document.getElementById("iconimage").src="../../../content/images/CB/unlock.png";
$("#btnLocking").removeClass("slidelockclass");
$("#DeleteSlide").removeClass("slidelockclass");
$("#deletecurrentslide").removeClass("slidelockclass");
$("#btnRenameSlide").removeClass("slidelockclass");
//menu option
$("#openResourceId").removeClass("openResources");
$("#openPictureId").removeClass("OpenPitures");
$("#openAnimationId").removeClass("OpenPitures");
}
}
$scope.Slidelockevent=function()
{
if( $scope.isSlideLock=="true" ||$scope.nodeTypeIsBranch=="true")
{
$('.tox-editor-header').css('pointer-events', 'none');
$('.tox-editor-header').css('opacity', '0.7');
$('#CBTextArea_ifr').css('pointer-events', 'none');
$('#CBTextArea_ifr').css('opacity', '0.7');
document.getElementById("iconimage").src="../../../content/images/CB/icon-lock.png";
if( $scope.isSlideLock=="true")
{
$("#btnLocking").removeClass("slidelockclass");
$("#DeleteSlide").addClass("slidelockclass");
$("#deletecurrentslide").addClass("slidelockclass");
$("#btnRenameSlide").addClass("slidelockclass");
//menu option
$("#openResourceId").addClass("openResources");
$("#openPictureId").addClass("OpenPitures");
$("#openAnimationId").addClass("OpenPitures");
}
else if($scope.nodeTypeIsBranch=="true")
{
$("#btnLocking").addClass("slidelockclass");
$("#openResourceId").addClass("openResources");
$("#openPictureId").addClass("OpenPitures");
$("#openAnimationId").addClass("OpenPitures");
}
}
}
$scope.cbSlideLocked = function () {
var nodeid = document.getElementById('cbSelect').value;
var password = $('#cbPassword').val();
var confirm_password = $('#cbConfirmPassWord').val();
if (password.trim() == "")
{
$('#errorMsg').text('password required!');
return;
}
if (confirm_password.trim() == "")
{
$('#errorMsg').text('confirm password required!');
return;
}
if (password != confirm_password) {
$('#errorMsg').text('confirm password not matched!');
return false;
}
$('#errorMsg').text('');
$rootScope.closeRenameModel();
if ($rootScope.structureObjForSaveCB.length == 0) {
$rootScope.structureObjForSaveCB = $rootScope.stru.structure.structure;
}
traverseTreeSelectedSingleObj($rootScope.structureObjForSaveCB, nodeid);
if ($scope.selectedNodeSingleObj._isBranch == "false") {
$scope.selectedNodeSingleObj._password = password;
$scope.selectedNodeSingleObj._isLocked = "true";
$scope.isSlideLock="true";
$rootScope.UnsaveCurriculum = true;
$scope.Slidelockevent();
$scope.DisableCbModule();
}
}
$scope.cbUnlockSlide = function () {
var nodeid = document.getElementById('cbSelect').value;
var password = $('#slidepass').val();
if (password.trim() == "")
{
$rootScope.errorMessage = "Password field is empty.please try again!";
$("#messageModal").modal('show');
return;
}
if ($rootScope.structureObjForSaveCB.length == 0) {
$rootScope.structureObjForSaveCB = $rootScope.stru.structure.structure;
}
traverseTreeSelectedSingleObj($rootScope.structureObjForSaveCB, nodeid);
if ($scope.selectedNodeSingleObj._isBranch == "false") {
if (password != $scope.selectedNodeSingleObj._password) {
$rootScope.errorMessage = "Password is not matched.please try again!";
$("#messageModal").modal('show');
return false;
}
else
{
$scope.selectedNodeSingleObj._password = "";
$scope.selectedNodeSingleObj._isLocked = "false";
$scope.isSlideLock="false";
$rootScope.UnsaveCurriculum = true;
$scope.SlideUnlockevent();
$scope.EnableCbModule();
}
}
}
$scope.EnableCbModule = function () {
// unlock module
if( $scope.isSlideLock=="false")
{
$("#Menuoptionid").removeClass("disableMenuoption");
$("#annotationButton").removeClass("disableMenuoption");
var modulePanel = $(document).find("div[id*='ImagePanel']");
if (modulePanel != undefined && modulePanel.length>0) {
for (var index = 0 ; index < modulePanel.length; index++) {
var paneld = modulePanel[index].id;
$( "#"+paneld).css({ "pointer-events": "auto"});
$( "#"+paneld+" .jsPanel-content").css({ "pointer-events": "auto"});
// remove dimlight of module
$("#" + paneld).removeClass("slidelockmoduleContrast");
var len = (paneld).split("_").length;
var MultiWinId = (paneld).split("_")[len - 1];
// lab exercise
if(paneld.match('labImagePanel'))
{
$("#annotationButton").addClass("disableMenuoption");
$("#btnBackward_" + MultiWinId).css('pointer-events', 'auto');
$("#btnForward_" + MultiWinId).css('pointer-events', 'auto');
}
else if(paneld.match('caImagePanel')|| paneld.match('vidImagePanel')||paneld.match('ThreeDImagePanel'))
{
$("#Menuoptionid").addClass("disableMenuoption");
$("#annotationButton").addClass("disableMenuoption");
}
}
}
}
}
$scope.DisableCbModule = function () {
if( $scope.isSlideLock=="true")
{
// after load module override menu option
$timeout(function () {
var modulePanel = $(document).find("div[id*='ImagePanel']");
if (modulePanel != undefined && modulePanel.length>0) {
for (var index = 0 ; index < modulePanel.length; index++) {
var paneld = modulePanel[index].id;
$( "#"+paneld).css({ "pointer-events": "none"});
$( "#"+paneld+" .jsPanel-content").css({ "pointer-events": "none"});
// dimlight of module
$("#" + paneld).addClass("slidelockmoduleContrast");
var len = (paneld).split("_").length;
var MultiWinId = (paneld).split("_")[len - 1];
// lab exercise
if(paneld.match('labImagePanel'))
{
$("#btnBackward_" + MultiWinId).css('pointer-events', 'none');
$("#btnForward_" + MultiWinId).css('pointer-events', 'none');
}
}
}
$("#openResourceId").addClass("openResources");
$("#openPictureId").addClass("OpenPitures");
$("#openAnimationId").addClass("OpenPitures");
$("#Menuoptionid").addClass("disableMenuoption");
$("#annotationButton").addClass("disableMenuoption");
}, 600);
}
}
$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();
$rootScope.UnsaveCurriculum = true;
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.ImportSection = function () {
var fileupload = document.getElementById("openCBJsonFile");
$timeout(function () {
$(fileupload).trigger('click');
}, 300);
$(fileupload).val('');//old file path
fileupload.onchange = function () {
var extension='';
var fileId, file, objFileRead;
if (typeof window.FileReader !== 'function') {
$rootScope.errorMessage = "The file API isn't supported on this browser yet.";
$("#messageModal").modal('show');
return;
}
fileId = document.getElementById('openCBJsonFile');
if (!fileId) {
$rootScope.errorMessage = "File couldn't find the element.";
$("#messageModal").modal('show');
}
else if (!fileId.files) {
$rootScope.errorMessage = "This browser doesn't seem to support the `files` property of file inputs.";
$("#messageModal").modal('show');
}
else if (!fileId.files[0]) {
$rootScope.errorMessage = "Please select a file before clicking 'Load'.";
$("#messageModal").modal('show');
}
else {
file = fileId.files[0];
extension = file.name.split(".")[1];
if ((file.type == "application/json" && extension == "json")||extension == "sldshw") {
$timeout(function () {
objFileRead = new FileReader();
objFileRead.onload = CbFileData;
objFileRead.readAsText(file,extension);
}, 300);
}
else
{
$rootScope.errorMessage = AIAConstants.CB_FILE_FORMAT_ISSUE;
$("#messageModal").modal('show');
}
}
function CbFileData(file) {
if(extension == "json")
{ var importdata = JSON.parse(file.target.result);
$rootScope.ImportCurriculum(importdata);
}
else
{
// convert xml to json object
var x2js = new X2JS();
var curriculumobject = x2js.xml_str2json(file.target.result);
var isIncompatible= $scope.checkCompatibility(curriculumobject);
if(isIncompatible)
{
$("#btnImportOpen").removeAttr("style");
$("#btnConvertDownLoad").css({"display":"none"}) ;
$("#btnConvertOpen").css({"display":"none"}) ;
$rootScope.newCurriculumObject=curriculumobject;
$rootScope.confirmMessage = AIAConstants.IMPORT_CB_OLD_TO_NEW_ISSUE;
$timeout(function () {
$("#cbMessageModal").modal('show');
}, 200);
}
else
{
$rootScope.isnewcurriculum = true;
$rootScope.ImportCurriculum(curriculumobject);
}
}
}
};
}
$rootScope.importOpen = function () {
$rootScope.isnewcurriculum = true;
$rootScope.ImportCurriculum($rootScope.newCurriculumObject);
}
$rootScope.ImportCurriculum = function (importdata) {
var cbCurrentId = document.getElementById('cbSelect').value;
if ($rootScope.structureObjForSaveCB.length == 0) {
$rootScope.structureObjForSaveCB = $rootScope.stru.structure.structure;
}
if ($rootScope.contentNotesForSaveCB.length == 0) {
$rootScope.contentNotesForSaveCB = $rootScope.cbDynamicContents;//Assign Dnamic Contents
}
$rootScope.updatedContentFromEditor(cbCurrentId);
$scope.updateWindowsContentForSaveCB(cbCurrentId,false);
$scope.newstructure = importdata.slideshow.presentation.structure;
$scope.newcontent = importdata.slideshow.content.element;
//set false for root for import
$scope.newstructure._isRoot="false";
// modify with new slide resolve conflict of id while import on same curriculum
var date = new Date();
var newId =date.getTime().toString();//timestamp is the number of milliseconds that have passed since January 1, 1970
$scope.newstructure._id+="-"+newId;
var newData=[];
var parentid = $('#jstree').jstree('get_selected')[0];
newData.push({ "id" : $scope.newstructure._id,"chid":$scope.newstructure._id+'_imp', "isBranch":$scope.newstructure._isBranch , "parent" : parentid, "label" : $scope.newstructure._label})
function traverseTreeforImportContent(o,pid) {
for (var i in o) {
if (o[i] !== null && typeof (o[i]) == "object") {
var selectedNode = o[i];
var childId = selectedNode._id;
if(childId!=undefined)
{
for (var k = 0; k < $scope.newcontent.length; k++) {
if (($scope.newcontent[k]._id == childId)) {
childId=childId +'-'+newId;
o[i]._id= childId;
$scope.newcontent[k]._id=childId;
newData.push({ "id" : childId, "chid":childId+'_imp' ,"isBranch":selectedNode._isBranch, "parent" : pid+'_imp', "label" : selectedNode._label})
break;
}
}
}
var newpid= i=="structure"?pid: childId;
traverseTreeforImportContent(o[i],newpid);
}
}
}
traverseTreeforImportContent($scope.newstructure,$scope.newstructure._id);
//expend parent if collapse
$("#jstree").jstree("open_node", $('#'+parentid));
traverseTreeSelectedSingleObj($rootScope.stru, cbCurrentId);
$scope.selectedNodeSingleObj['structure'].push($scope.newstructure);
$.merge($rootScope.contentNotesForSaveCB,$scope.newcontent);
$rootScope.cbDynamicContents=$rootScope.contentNotesForSaveCB;
$rootScope.cbDynamicJsonData.slideshow.content.element=$rootScope.cbDynamicContents;
$rootScope.structure = $rootScope.cbDynamicJsonData.slideshow.presentation.structure.structure
// add new node to tree
for (var i = 0 ; i < newData.length; i++) {
$('#jstree').jstree().create_node(newData[i].parent, {
"id": newData[i].chid,
"text":''+newData[i].label+''
}, "last");
}
$rootScope.UnsaveCurriculum = true;
$timeout(function(){
for (var i = 0 ; i < newData.length; i++) {
$("#jstree").jstree("open_node", $('#'+newData[i].chid));
var span_Id = newData[i].id;
var isbranch = newData[i].isBranch;
if (isbranch == "false") {
$("#jstree").jstree(true).set_icon(span_Id, "../../../content/images/CB/file.png");
}
}
},500);
}
$rootScope.ExportSection = function () {
var currentid = document.getElementById('cbSelect').value;
if ($rootScope.contentNotesForSaveCB.length == 0) {
$rootScope.contentNotesForSaveCB = $rootScope.cbDynamicContents;
}
$scope.SectionContentForExportCB=[];
traverseTreeSelectedSingleObj($rootScope.stru, currentid);
var strFromParent=$scope.selectedNodeSingleObj['structure'];
if(strFromParent.length<=0)
{
$rootScope.errorMessage = "Please add slide first to export this section.";
$("#messageModal").modal('show');
return;
}
$("#filename").val("");
$("#btnExportCB").removeAttr("style");
$("#btnSaveCB").css({"display":"none"}) ;
$("#saveAsCurriculum").modal('show');
$(".modal-backdrop").css("opacity", ".5");
}
$rootScope.ExportCurriculum =function()
{
var filename = document.getElementById("filename").value;
if (filename == "" ||filename == " ")
{
$rootScope.errorMessage = "Curriculum name is empty!";
$("#messageModal").modal('show');
return;
}
$scope.CBDisableUI();
$rootScope.dynamicUpdatedJsonForExportCB="";
var strFromParent=$scope.selectedNodeSingleObj['structure'];
var parentLevel=$scope.selectedNodeSingleObj._label;
var parentId=$scope.selectedNodeSingleObj._id ;
var rootNoteSummary = new jinqJs()
.from($rootScope.contentNotesForSaveCB)
.where("_id == " + $scope.selectedNodeSingleObj._id)
.select();
$scope.SectionContentForExportCB.push(
{
"summary":rootNoteSummary[0].summary,
"author": rootNoteSummary[0].author,
"modified":rootNoteSummary[0].modified,
"password":rootNoteSummary[0].password,
"version":rootNoteSummary[0].version,
"windows":rootNoteSummary[0].windows,
"_id":rootNoteSummary[0]._id,
});
function traverseTreeforExportContent(o) {
for (var i in o) {
if (o[i] !== null && typeof (o[i]) == "object") {
var selectedNode = o[i];
var childId = selectedNode._id;
if(childId!=undefined)
{
for (var k = 0; k < $rootScope.contentNotesForSaveCB.length; k++) {
if (($rootScope.contentNotesForSaveCB[k]._id == childId)) {
$scope.SectionContentForExportCB.push($rootScope.contentNotesForSaveCB[k]);
break;
}
}
}
traverseTreeforExportContent(o[i]);
}
}
}
traverseTreeforExportContent(strFromParent);
$rootScope.dynamicUpdatedJsonForExportCB =
{
"slideshow": {
"presentation": {
"structure": {
"structure":strFromParent,
"_label": parentLevel,
"_id": parentId,
"_isRoot": "true",
"_isBranch": "true",
"_isLocked": "false"
},
"_anchor": "true",
"_window_position": "6,10",
"_window_size": "828,453" // Apply Dynamic
},
"content": {
"element": $scope.SectionContentForExportCB,
}
}
};
$scope.saveCBwithAnimation("exportcb",filename);
}
$scope.saveCBwithAnimation=function(downloadtype,filename)
{
if($rootScope.collectAnimationSource.length>0)
{
$rootScope.loadingAnimationstatus=1;
$("#saveAsCurriculum").modal('hide');
var AnimationData=[];
function getBase64Image(base64string) {
return base64string.replace(/^data:video\/(mp4);base64,/, "");
}
for (var k = 0; k < $rootScope.collectAnimationSource.length; k++) {
AnimationData.push({
"Data":getBase64Image($rootScope.collectAnimationSource[k].Source),
//"folderNo":$rootScope.collectAnimationSource[k].imageId,
"FileName":$rootScope.collectAnimationSource[k].windowTitle,
});
}
AuthenticationService.saveAnimationVideo(AnimationData)
.then(
function (result) {
if(result!=null)
{
$scope.downloadCurriculum(downloadtype,filename);
$rootScope.collectAnimationSource = [];
//clear video source after save on server
// next time it load from server
for (var i = 0; i < $rootScope.VideoWindowData.length; i++) {
$rootScope.VideoWindowData[i].videoSource="";
$rootScope.VideoWindowData[i].isSourceExist=false;
}
}
},
function (error) {
console.log(' Error in Saving video = ' + error.statusText);
$scope.CBEnableUI();
$rootScope.loadingAnimationstatus=0;
$scope.SectionContentForExportCB=[];
$rootScope.dynamicUpdatedJsonForExportCB = "";
$rootScope.dynamicUpdatedJsonForSaveCB = "";
$('#uploading-curriculum').css("display", "none");
$("#filename").val("");
$rootScope.errorMessage = AIAConstants.SAVE_ANIMATION_ERROR+"\n"+error.ExceptionMessage;;
$("#messageModal").modal('show');
},
function(progress){
$('#uploading-curriculum').css("display", "block");
//console.log('uploading: ' + Math.floor(progress) + '%');
$rootScope.loadingstatus= + Math.floor(progress) + '%';
$rootScope.loadingAnimationstatus=1;
}
)
}
else
{
$scope.downloadCurriculum(downloadtype,filename);
}
}
$scope.downloadCurriculum=function(downloadtype,filename)
{
//add extension
filename += '.json';
if(downloadtype=="exportcb")
{
var blob = new Blob([angular.toJson($rootScope.dynamicUpdatedJsonForExportCB, true)], { type: 'text/json' });
}
else
{
$rootScope.UnsaveCurriculum = false;
var blob = new Blob([angular.toJson($rootScope.dynamicUpdatedJsonForSaveCB, true)], { type: 'text/json' });
}
// document.execCommand("SaveAs", true, filename);
// 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);
//save file saver handle for all browser
saveAs(blob, filename);
// }
$rootScope.loadingAnimationstatus=0;
$scope.SectionContentForExportCB=[];
$rootScope.dynamicUpdatedJsonForExportCB = "";
$rootScope.dynamicUpdatedJsonForSaveCB = "";
$("#filename").val("");
$('#uploading-curriculum').css("display", "none");
$scope.CBEnableUI();
$("#saveAsCurriculum").modal('hide');
//disable tiny editor while section active
if($scope.nodeTypeIsBranch=="true")
{
$('.tox-editor-header').css('pointer-events', 'none');
$('.tox-editor-header').css('opacity', '0.7');
$('#CBTextArea_ifr').css('pointer-events', 'none');
$('#CBTextArea_ifr').css('opacity', '0.7');
}
if($rootScope.closeAfterSaveCurriculum==true)
{
//clear cb content data
$rootScope.saveConfirmNo();
}
}
$rootScope.DeleteSlideSection = function () {
var selectNodeAfterDelete=0;
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));
var lengthOfCurrentSelectedSlideSiblings = $(parentNodeObj).children('li').length;
if (indexOfCurrentSelectedId <= 0) {
if (lengthOfCurrentSelectedSlideSiblings > 1) {
$scope.nextnodebeforedelete();
selectNodeAfterDelete= $scope.nextCurrentId
$('#jstree').jstree().delete_node([$("#jstree").jstree().get_selected(true)[0].id]);
}
else {
$('#jstree').jstree().delete_node([$("#jstree").jstree().get_selected(true)[0].id]);
selectNodeAfterDelete=CurrentSelectedParentSpanId
}
}
else {
$scope.backnodebeforedelete();
selectNodeAfterDelete= $scope.backCurrentId
$('#jstree').jstree().delete_node([$("#jstree").jstree().get_selected(true)[0].id]);
}
$scope.DeleteSlide(cbCurrentSelectedId, CurrentSelectedParentSpanId);
$rootScope.closeDeleteModel();
$('#jstree').jstree(true).deselect_all();
$('#jstree').jstree('select_node', selectNodeAfterDelete);
}
$scope.backnodebeforedelete = function () {
$scope.isChangeFromDropDown=false;
var cbCurrentId = document.getElementById('cbSelect').value;
var counter = 0;
$scope.backCurrentId=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;
return false;
}
if (counter == 1) {
counter += 1;
}
});
}
$scope.nextnodebeforedelete = function () {
$scope.isChangeFromDropDown=false;
var cbCurrentId = document.getElementById('cbSelect').value;
var counter = 0;
$scope.nextCurrentId=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;
return false;
}
if (counter == 1) {
counter += 1;
}
});
}
$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;
}
var date = new Date();
var newSlideId = 'sd'+date.getTime();//timestamp is the number of milliseconds that have passed since January 1, 1970
var treeliId=newSlideId+'li';
$('#jstree').jstree().create_node(createNodeId, {
"id": treeliId,
"text": 'New Slide'
}, "last", function () {
//expend parent if collapse
$("#jstree").jstree("open_node", $('#'+createNodeId));
$scope.addSlide(createNodeId, newSlideId);
$('#jstree').jstree(true).deselect_all();
$('#jstree').jstree('select_node', newSlideId);
});
}
$scope.addSlide = function (currentid, AddSlideId) {
if ($rootScope.structureObjForSaveCB.length == 0) {
$rootScope.structureObjForSaveCB = $rootScope.stru.structure.structure;
}
$rootScope.UnsaveCurriculum = true;
traverseTreeSelectedSingleObj($rootScope.stru, currentid);
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"
});
for (var i = 0; i < $rootScope.structureObjForSaveCB.length; i++) {
if ($rootScope.structureObjForSaveCB[i]._id == currentid) {
$rootScope.structureObjForSaveCB[i]['structure'] = $scope.selectedNodeSingleObj['structure'];
}
}
}
setTimeout(function () {
$("#jstree").jstree(true).set_icon(AddSlideId, "../../../content/images/CB/file.png");
}, 50);
}
$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 date = new Date();
var newSectionId = 'sn'+date.getTime();//timestamp is the number of milliseconds that have passed since January 1, 1970
var treeliId=newSectionId+'li';
$('#jstree').jstree().create_node(createNodeId, {
"id": treeliId,
"text": 'New Section'
}, "last", function () {
//expend parent if collapse
$("#jstree").jstree("open_node", $('#'+createNodeId));
$scope.addSection(createNodeId, newSectionId);
$('#jstree').jstree(true).deselect_all();
$('#jstree').jstree('select_node', newSectionId);
});
}
$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;
}
$rootScope.UnsaveCurriculum = true;
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
});
for (var i = 0; i < $rootScope.structureObjForSaveCB.length; i++) {
if ($rootScope.structureObjForSaveCB[i]._id == currentid) {
$rootScope.structureObjForSaveCB[i]['structure'] = $scope.selectedNodeSingleObj['structure'];
}
}
}
}
function traverseForLoadDropDown(o) {
for (var i = 0; i < o.structure.structure.length; i++) {
$('#cbSelect').append('');
}
}
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.cbDynamicContents;//Assign Dnamic Contents
}
$rootScope.UnsaveCurriculum = true;
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;
console.log($rootScope.structureObjForSaveCB);
console.log($rootScope.contentNotesForSaveCB);
}
$rootScope.saveConfirmNo = function () {
$rootScope.UnsaveCurriculum = false;
$rootScope.closeAfterSaveCurriculum = false;
$("#confirmCurriculumModal").modal('hide');
tinymce.execCommand('mceRemoveControl', true, 'CBTextArea');
tinymce.execCommand('mceFocus', true, 'CBTextArea');
tinymce.execCommand('mceRemoveEditor', true, 'CBTextArea');
tinymce.execCommand('mceAddEditor', true, 'CBTextArea');
//remove minized module
if ($('#jsPanel-min-container').html() != undefined) {
$('#jsPanel-min-container').remove();
}
//clear if animation data exist
$rootScope.collectAnimationSource=[];
if ($('#CBTinyMCEPanel').html() != undefined) {
$('#CBTinyMCEPanel').remove();
}
$location.url('/curriculum-builder');
}
$rootScope.saveCurricullam = function (closevalue) {
$("#confirmCurriculumModal").modal('hide');
$rootScope.closeAfterSaveCurriculum = closevalue;
$scope.SectionContentForExportCB=[];
$("#filename").val("");
$("#btnSaveCB").removeAttr("style");
$("#btnExportCB").css({"display":"none"}) ;
$("#saveAsCurriculum").modal('show');
$(".modal-backdrop").css("opacity", ".5");
}
$rootScope.saveMyCurricullam = function () {
var filename = document.getElementById("filename").value;
if (filename == "" ||filename == " ")
{
$rootScope.errorMessage = "Curriculum name is empty!";
$("#messageModal").modal('show');
return;
}
$scope.CBDisableUI();
$rootScope.dynamicUpdatedJsonForSaveCB="";
var cbCurrentId = document.getElementById('cbSelect').value;
if ($rootScope.structureObjForSaveCB.length == 0) {
$rootScope.structureObjForSaveCB = $rootScope.stru.structure.structure;
}
if ($rootScope.contentNotesForSaveCB.length == 0) {
$rootScope.contentNotesForSaveCB = $rootScope.cbDynamicContents;//Assign Dnamic Contents
}
$rootScope.updatedContentFromEditor(cbCurrentId);
$scope.updateWindowsContentForSaveCB(cbCurrentId,false);
$scope.SectionContentForExportCB=$rootScope.contentNotesForSaveCB;
$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": $scope.SectionContentForExportCB,
}
}
};
$scope.saveCBwithAnimation("savecb",filename);
}
$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;
}
}
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.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
});
}
else if ($scope.selectedNodeSingleObj._isBranch == "true") {
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
});
}
$rootScope.cbDynamicContents = $rootScope.contentNotesForSaveCB;
$rootScope.note = $rootScope.contentNotesForSaveCB;
console.log($rootScope.contentNotesForSaveCB);
}
$scope.EditorChangeEvent=function()
{
$rootScope.UnsaveCurriculum =true;
}
$scope.moveDown = function (currentid) {
$rootScope.UnsaveCurriculum =true;
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) {
$rootScope.UnsaveCurriculum =true;
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 key = $scope.selectedNodeSiblingObjs[j];
$scope.selectedNodeSiblingObjs[j] = $scope.selectedNodeSiblingObjs[j - 1];
$scope.selectedNodeSiblingObjs[j - 1] = key;
}
}
$rootScope.structureObjForSaveCB = $rootScope.stru.structure.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) {
console.log("id= " + id)
if ($rootScope.contentNotesForSaveCB.length == 0) {
$rootScope.contentNotesForSaveCB = $rootScope.cbDynamicContents;
}
var content = $rootScope.contentNotesForSaveCB;
var contenctForSelectedSlide = new jinqJs()
.from(content)
.where("_id == " + id)
.select();
var windowsInSelectedSlide = contenctForSelectedSlide[0].windows;
var allwindowData = windowsInSelectedSlide.window;
if(!Array.isArray(allwindowData))
{
allwindowData=[];
allwindowData.push(windowsInSelectedSlide.window);
}
var windowData;
var DawindowId = 0;
var AtlasWindowId = 0;
var CIWindowId = 0;
var CAWindowId = 0;
var ThreeDWindowId = 0;
var ADAMIMGWindowId = 0;
var LabWindowId = 0;
var PicWindowId = 0;
var AniWindowId = 0;
//check for multiple windows, if Array.isArray==true
if (allwindowData != undefined) {
for (var i = 0; i < allwindowData.length; i++) {
windowData = JSON.parse(allwindowData[i]);
var annotation= windowData.annotationData;
if(annotation!="" && annotation!=undefined)
{
var shapeStates = 'shapeStates';
var paintCanvasState = 'paintCanvasState';
if (!annotation.hasOwnProperty(shapeStates) || !annotation.hasOwnProperty(paintCanvasState))
{
$rootScope.UnsaveCurriculum = true;
$rootScope.errorMessage =AIAConstants.CB_OLD_SLIDE_ANNOTATION_ISSUE;
$("#messageModal").modal('show');
windowData.annotationData="";
}
}
if (windowData.mType == "MY_PICTURES") {
ModuleService.setModuleData(windowData, PicWindowId);
PicWindowId = PicWindowId + 1;
var isFound = jQuery.inArray(windowData.mType, $scope.LoadModuleName)
if (isFound == -1) {
$scope.LoadModuleName.push(windowData.mType);
}
}
else if (windowData.mType == "MY_ANIMATIONS") {
for (var k = 0; k < $rootScope.collectAnimationSource.length; k++) {
if($rootScope.collectAnimationSource[k].SlideId==id && $rootScope.collectAnimationSource[k].imageId==windowData.imageId)
{
windowData.videoSource=$rootScope.collectAnimationSource[k].Source;
}
}
ModuleService.setModuleData(windowData, AniWindowId);
AniWindowId = AniWindowId + 1;
var isFound = jQuery.inArray(windowData.mType, $scope.LoadModuleName)
if (isFound == -1) {
$scope.LoadModuleName.push(windowData.mType);
}
}
else 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 if (windowData.mType == "ADAM_IMAGES") {
ModuleService.setModuleData(windowData, ADAMIMGWindowId);
ADAMIMGWindowId = ADAMIMGWindowId + 1;
var isFound = jQuery.inArray(windowData.mType, $scope.LoadModuleName)
if (isFound == -1) {
$scope.LoadModuleName.push(windowData.mType);
}
}
else if (windowData.mType == "LAB_EXERCISE") {
ModuleService.setModuleData(windowData, LabWindowId);
LabWindowId = LabWindowId + 1;
var isFound = jQuery.inArray(windowData.mType, $scope.LoadModuleName)
if (isFound == -1) {
$scope.LoadModuleName.push(windowData.mType);
}
}
}
}
// 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) {
//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('');
$('#'+paneld).draggable({ containment: '#cbdivarea', scroll: false });
}
$scope.CBEnableUI();
// scroll down to first panel
if (modulePanel.length > 0) {
if (modulePanel[0].id != undefined) {
var lastpanel = modulePanel[0].id;
//$('#cbdivarea').animate({ scrollTop: $('#' + lastpanel).position().top }, 1000);
}
}
if( $scope.isSlideLock=="true")
{
$scope.DisableCbModule();
}
else
{
$scope.EnableCbModule();
}
}
}
});
$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;
case "MY_PICTURES":
$scope.loadMyPictureModule(moduleName);
break;
case "MY_ANIMATIONS":
$scope.loadMyAnimationModule(moduleName);
break;
}
}
$scope.loadMyPictureModule = function (moduleName) {
var picData = ModuleService.getModuleData(moduleName);
if (picData != undefined && picData.length > 0) {
$rootScope.isCallFromOtherModule = true;
var picSectionExist = document.getElementById('picCustomModuleDiv');
if (picSectionExist == null) {
$('#cbparentcustomDiv').append($(''));
$e = $('#picCustomModuleDiv').append("");
$compile($e)($scope);
}
else {
// open lab panel on same slide by open resource
$rootScope.OpenMyPictureViewMain();
}
}
}
$scope.loadMyAnimationModule = function (moduleName) {
var aniData = ModuleService.getModuleData(moduleName);
if (aniData != undefined && aniData.length > 0) {
$rootScope.isCallFromOtherModule = true;
var vidSectionExist = document.getElementById('vidCustomModuleDiv');
if (vidSectionExist == null) {
$('#cbparentcustomDiv').append($(''));
$e = $('#vidCustomModuleDiv').append("");
$compile($e)($scope);
}
else {
// open lab panel on same slide by open resource
$rootScope.OpenMyAnimationViewMain();
}
}
}
$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") {
$('#cbdivarea').animate({ scrollTop: $('#' + selected_Id).position().top }, 500);
}
}
$scope.updatedWindowListForSaveCB = [];
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);
}
}
}
//Save Lab Exercise activity for CB
$scope.saveLABWindowActivity = function (isNotSaved) {
if ($rootScope.LEWindowData != undefined && $rootScope.LEWindowData.length > 0) {
for (var i = 0; i < $rootScope.LEWindowData.length; i++) {
var isLabExChanged= $rootScope.LEWindowData[i].isLabExChanged;
if(isLabExChanged)
{
if (confirm("Do you want to save Lab Exercise changes?")) {
//save to database
var windowid= $rootScope.LEWindowData[i].multiwinid;
$rootScope.SaveAnswer(undefined,windowid);
}
else
{
$rootScope.LEWindowData[i].isLabExChanged=false;
}
}
$scope.updatedWindowListForSaveCB.push({
containsCapturedContent: true,
contextMenu: { lockResize: false, hideToolBar: false, hideTitleBar: false },
position: {
y: $rootScope.LEWindowData[i].y,
x: $rootScope.LEWindowData[i].x,
},
size: {
height: $rootScope.LEWindowData[i].height,
width: $rootScope.LEWindowData[i].width
},
keywords: $rootScope.LEWindowData[i].keywords,
minimised: $rootScope.LEWindowData[i].minimised,
windowTitle: $rootScope.LEWindowData[i].currentViewTitle,
maximised: $rootScope.LEWindowData[i].maximised,
mType: $rootScope.LEWindowData[i].moduleName,
id: $rootScope.LEWindowData[i].keywords,
lastQuize: $rootScope.LEWindowData[i].lastQuize,
scrollPosition: { vertical: 0, horizontal: 0 },
windowListId: 0
});
}
if(isNotSaved)
$rootScope.LEWindowData = [];
}
}
//Save ADAM Image activity for CB
$scope.saveAIWindowActivity = function (isNotSaved) {
if ($rootScope.AIWindowData != undefined && $rootScope.AIWindowData.length > 0 ) {
for (var i = 0; i < $rootScope.AIWindowData.length; i++) {
$scope.updatedWindowListForSaveCB.push({
containsCapturedContent: true,
annotationData: $rootScope.AIWindowData[i].annotationData,
contextMenu: { lockResize: false, hideTitleBar: false },
position: {
y: $rootScope.AIWindowData[i].y,
x: $rootScope.AIWindowData[i].x,
},
size: {
height: $rootScope.AIWindowData[i].height,
width: $rootScope.AIWindowData[i].width
},
imageId: $rootScope.AIWindowData[i].imageId,
minimised: $rootScope.AIWindowData[i].minimised,
windowTitle: $rootScope.AIWindowData[i].currentViewTitle,
maximised: $rootScope.AIWindowData[i].maximised,
mType: $rootScope.AIWindowData[i].moduleName,
id: $rootScope.AIWindowData[i].imageId,
scrollPosition: { vertical: 0, horizontal: 0 },
windowListId: 0
});
}
if(isNotSaved)
$rootScope.AIWindowData=[];
}
}
//Save Clinical Illustration activity for CB
$scope.saveCIWindowActivity = function (isNotSaved) {
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: {
y: $rootScope.CIWindowData[i].y,
x: $rootScope.CIWindowData[i].x,
},
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
});
}
if(isNotSaved)
$rootScope.CIWindowData = [];
}
}
//Save CLINICAL_ANIMATIONS activity for CB
$scope.saveCAWindowActivity = function (isNotSaved) {
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: {
y: $rootScope.CAWindowData[i].y,
x: $rootScope.CAWindowData[i].x,
},
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
});
}
if(isNotSaved)
$rootScope.CAWindowData = [];
}
}
//Save THREE_D_ANATOMY activity for CB
$scope.save3DWindowActivity = function (isNotSaved) {
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: {
y: $rootScope.TheeDWindowData[i].y,
x: $rootScope.TheeDWindowData[i].x,
},
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 },
});
}
if(isNotSaved)
$rootScope.TheeDWindowData = [];
}
}
//Save MY_PICTURES activity for CB
$scope.saveMyPictureWindowActivity = function (isNotSaved) {
if ($rootScope.PICWindowData != undefined && $rootScope.PICWindowData.length > 0) {
for (var i = 0; i < $rootScope.PICWindowData.length; i++) {
$scope.updatedWindowListForSaveCB.push({
containsCapturedContent: true,
annotationData: $rootScope.PICWindowData[i].annotationData,
contextMenu: { lockResize: true, hideTitleBar: true },
position: {
y: $rootScope.PICWindowData[i].y,
x: $rootScope.PICWindowData[i].x,
},
size: {
height: $rootScope.PICWindowData[i].height,
width: $rootScope.PICWindowData[i].width
},
imageId: $rootScope.PICWindowData[i].imageId,
minimised: $rootScope.PICWindowData[i].minimised,
windowTitle: $rootScope.PICWindowData[i].currentViewTitle,
maximised: $rootScope.PICWindowData[i].maximised,
mType: $rootScope.PICWindowData[i].moduleName,
id: $rootScope.PICWindowData[i].imageId,
windowListId: 0,
scrollPosition: { vertical: 0, horizontal: 0 },
imageSource: $rootScope.PICWindowData[i].imageSource
});
}
if(isNotSaved)
$rootScope.PICWindowData = [];
}
}
//Save My-Animation activity for CB
$scope.saveMyAnimationWindowActivity = function (isNotSaved,slideId) {
if ($rootScope.VideoWindowData != undefined && $rootScope.VideoWindowData.length > 0) {
for (var i = 0; i < $rootScope.VideoWindowData.length; i++) {
var isSourceExist = $rootScope.VideoWindowData[i].isSourceExist;
if(isSourceExist==true)
{
var imageId = $rootScope.VideoWindowData[i].imageId;
var exist = new jinqJs()
.from($rootScope.collectAnimationSource)
.where('imageId == ' + imageId)
.select();
if(exist.length<=0)
{
$rootScope.collectAnimationSource.push(
{
"SlideId": slideId,
"Source": $rootScope.VideoWindowData[i].videoSource,
"imageId": $rootScope.VideoWindowData[i].imageId,//use for other purpose until save or export cb
"windowTitle": $rootScope.VideoWindowData[i].currentViewTitle
});
}
}
$scope.updatedWindowListForSaveCB.push({
containsCapturedContent: true,
contextMenu: { lockResize: false, hideToolBar: false, hideTitleBar: false },
position: {
y: $rootScope.VideoWindowData[i].y,
x: $rootScope.VideoWindowData[i].x,
},
size: {
height: $rootScope.VideoWindowData[i].height,
width: $rootScope.VideoWindowData[i].width
},
imageId: $rootScope.VideoWindowData[i].imageId,
minimised: $rootScope.VideoWindowData[i].minimised,
windowTitle: $rootScope.VideoWindowData[i].currentViewTitle,
maximised: $rootScope.VideoWindowData[i].maximised,
mType: $rootScope.VideoWindowData[i].moduleName,
id: $rootScope.VideoWindowData[i].imageId,
scrollFlvPosition: { vertical: 0, horizontal: 0 },
windowListId: 0,
videoSource: ""//keeping source in $scope.collectAnimationSource
});
}
if(isNotSaved)
$rootScope.VideoWindowData = [];
}
}
//Save ATLAS_ANATOMY activity for CB
$scope.saveAAWindowActivity = function (isNotSaved) {
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: {
y: $rootScope.AAWindowData[i].y,
x: $rootScope.AAWindowData[i].x,
},
mType: $rootScope.AAWindowData[i].moduleName,
containsCapturedContent: true,
showHideAnnotations: $rootScope.AAWindowData[i].showHideAnnotations,
contextMenu: { hideLeftBar: false, hideTitleBar: false, hideTopToolBar: false, lockResize: false },
//activePinArray: $rootScope.AAWindowData[i].activePinArray,
//selectedSearchId: $rootScope.AAWindowData[i].selectedSearchId
//typeOfEvent: $rootScope.AAWindowData[i].typeOfEvent
});
}
if(isNotSaved)
$rootScope.AAWindowData = [];
}
}
//Save DISSECTIBLE_ANATOMY activity for CB
$scope.saveDAWindowActivity = function (isNotSaved) {
if ($rootScope.DaWindowData != undefined && $rootScope.DaWindowData.length > 0) {
for (var i = 0; i < $rootScope.DaWindowData.length; i++) {
$scope.updatedWindowListForSaveCB.push({
isTitleBarVisible: false,
highlightOptionsSelectedId: 0,
selectedStructureID: 0,//N
contentDescriptorId: 0,
callOuts: $rootScope.DaWindowData[i].CurriculumTermData,
//selectedCallouts: $rootScope.DaWindowData[i].CBselectedpinCordinate,
layerNumber: parseInt($rootScope.DaWindowData[i].layerNumber) + 1,
isModestyOn: $rootScope.DaWindowData[i].ModestyValue,
isTopToolBarVisible: false, //$rootScope.DaWindowData[i].isTopToolBarVisible,
clickedTermList: $rootScope.DaWindowData[i].fullTermlist,
minimised: $rootScope.DaWindowData[i].minimised,
windowTitle: $rootScope.DaWindowData[i].currentViewTitle,
maximised: $rootScope.DaWindowData[i].maximised,
size: {
width: $rootScope.DaWindowData[i].width,
height: $rootScope.DaWindowData[i].height
},
id: $rootScope.DaWindowData[i].voId,
imageId: $rootScope.DaWindowData[i].imageId,
position: {
y: $rootScope.DaWindowData[i].y,
x: $rootScope.DaWindowData[i].x,
},
mType: $rootScope.DaWindowData[i].moduleName,
containsCapturedContent: true,
zoom: $rootScope.DaWindowData[i].zoomInOut,
skinId: $rootScope.DaWindowData[i].curentEthnicity,
isResizeLock: false , //N
mode: $rootScope.DaWindowData[i].mode,
windowListId: 0,//N
canvasVScrollX: $rootScope.DaWindowData[i].CanvasDivTopPosition,
canvasHScrollX: $rootScope.DaWindowData[i].CanvasDivLeftPosition,
isCallOutVisible: false,
annotationData:$rootScope.DaWindowData[i].annotationData,
isLeftToolBarVisible: false,
isModuleLoaded: false,
searchSelectedText: $rootScope.DaWindowData[i].searchSelectedText,
prevId: $rootScope.DaWindowData[i].prevId, //ActualTermnumber for chnages body image
isTransparent: $rootScope.DaWindowData[i].isTransparent,
transparencyBounds: $rootScope.DaWindowData[i].transparencyBounds,
transparencyValue: $rootScope.DaWindowData[i].transNumber,
layerNumberTransparency: $rootScope.DaWindowData[i].layerNumberTransparency,
transparencyX: $rootScope.DaWindowData[i].transparencyX,
transparencyY: $rootScope.DaWindowData[i].transparencyY,
layerNumberBeforeTBDraw: $rootScope.DaWindowData[i].layerNumberBeforeTBDraw,
showHideAnnotations: $rootScope.DaWindowData[i].showHideAnnotations
});
}
if(isNotSaved)
$rootScope.DaWindowData = [];
}
}
$scope.updateWindowsContentForSaveCB = function (currentId,isNotSaved) {
$scope.saveMyPictureWindowActivity(isNotSaved);
$scope.saveMyAnimationWindowActivity(isNotSaved,currentId);
$scope.saveDAWindowActivity(isNotSaved);
$scope.saveAAWindowActivity(isNotSaved);
$scope.saveCIWindowActivity(isNotSaved);
$scope.saveAIWindowActivity(isNotSaved);
$scope.saveCAWindowActivity(isNotSaved);
$scope.save3DWindowActivity(isNotSaved);
$scope.saveLABWindowActivity(isNotSaved);
findKeyForChange($rootScope.contentNotesForSaveCB, currentId);
$scope.selectedKey.windows.window = [];
if ($scope.updatedWindowListForSaveCB.length > 0) {
$scope.selectedKey.windows.window = [];
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:[]}; //fixed issue when slide has not attached inbuilt module.
}
$scope.selectedKey.windows.window.push(arrToStrWinObj);
}
}
$scope.updatedWindowListForSaveCB = [];
console.log($rootScope.contentNotesForSaveCB);
}
//open resoruce on slide
$scope.loadResourceOnCurrentSlide = function (newWindowData) {
var newwindowNo = 0;
$scope.LoadModuleName=[];
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);
$rootScope.UnsaveCurriculum = true;
// 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);
});
}