// Common framework data. function GetTimezoneName() { var timeSummer = new Date(Date.UTC(2005, 6, 30, 0, 0, 0, 0)); var summerOffset = -1 * timeSummer.getTimezoneOffset(); var timeWinter = new Date(Date.UTC(2005, 12, 30, 0, 0, 0, 0)); var winterOffset = -1 * timeWinter.getTimezoneOffset(); var timeZoneHiddenField; if (-720 == summerOffset && -720 == winterOffset) { timeZoneHiddenField = 'Dateline Standard Time'; } else if (-660 == summerOffset && -660 == winterOffset) { timeZoneHiddenField = 'UTC-11'; } else if (-420 == summerOffset && -480 == winterOffset) { timeZoneHiddenField = 'Pacific Standard Time'; } else if (-420 == summerOffset && -420 == winterOffset) { timeZoneHiddenField = 'US Mountain Standard Time'; } else if (-360 == summerOffset && -420 == winterOffset) { timeZoneHiddenField = 'Mountain Standard Time'; } else if (-360 == summerOffset && -360 == winterOffset) { timeZoneHiddenField = 'Central America Standard Time'; } else if (-300 == summerOffset && -360 == winterOffset) { timeZoneHiddenField = 'Central Standard Time'; } else if (-240 == summerOffset && -300 == winterOffset) { timeZoneHiddenField = 'Eastern Standard Time'; } else if (-120 == summerOffset && -180 == winterOffset) { timeZoneHiddenField = 'America/Godthab'; } else if (60 == summerOffset && 0 == winterOffset) { timeZoneHiddenField = 'GMT Standard Time'; } else if (330 == summerOffset && 330 == winterOffset) { timeZoneHiddenField = 'India Standard Time'; } else if (660 == summerOffset && 660 == winterOffset) { timeZoneHiddenField = 'West Pacific Standard Time'; } else if (690 == summerOffset && 690 == winterOffset) { timeZoneHiddenField = 'Central Pacific Standard Time'; } else { timeZoneHiddenField = 'US/Pacific'; } return timeZoneHiddenField; } var svcUploadService = UploadService_URL;//"http://192.168.2.14:8010"; //"http://dev.svcuploads.sashank.com:2269"; var ResourceCollection = []; var RegisteredAppsCollection = []; var CurrentModule; var IsLoadingPannelActive = false; var FrameworkData = (function () { function catchException(exception, errorMessage) { alert("Some thing went wrong here!"); }; return { catchException: catchException } })(); var isFirstTime = null; var FilesInFoldersArray = []; //[November 28, 2016 - Shree] : This variable is used in DAMS for Folder Upload, which saves the FileID and the ParentFolderID var dams = (function () { function init() { BindFrameworkEventHandlers(); if (window.location.hash == "") { //if (!$(".Dashboard").hasClass("active")) { // $(".Dashboard").addClass("active"); //} html = "Module/Dashboard/dashboard.html"; //CurrentModule = "Dashboard"; /* if (!$(".DAMS").hasClass("active")) { $(".DAMS").addClass("active"); } html = "Module/filechest/filechest.html"; CurrentModule = "DAMS"; initRegisterApps(); isFirstTime = true;*/ if (!$(".userGroups").hasClass("active")) { $(".userGroups").addClass("active"); } html = "Module/Usergroups/userandgroups.html"; CurrentModule = "userGroups"; initRegisterApps(); isFirstTime = true; } else { /*if (window.location.href.indexOf("access_token") != -1) { html = "Module/Calendar/calendar.html"; CurrentModule = "Calendar"; } else { if (!$(".Dashboard").hasClass("active")) { $(".Dashboard").addClass("active"); } html = "Module/Dashboard/dashboard.html"; CurrentModule = "Dashboard";*/ if (!$(".userGroups").hasClass("active")) { $(".userGroups").addClass("active"); //} html = "Module/Usergroups/userandgroups.html"; CurrentModule = "userGroups"; initRegisterApps(); isFirstTime = true; } } if ($(window).width() >= 991) { $(".sidebar").show("slide", { direction: "left", mode: "show" }, 300); } LoadModuleHTMl(html); }; function BindFrameworkEventHandlers() { $(window).resize(function () { if ($(window).width() >= 991) { $(".sidebar").show("slide", { direction: "left", mode: "show" }, 300); /* $(".blog_left_pane").removeClass("none"); $("#blogleft_pane").removeClass("blogleft_Mpane").addClass("blogleft_pane lftpane_close hidden-sm hidden-xs"); $("#blogleft_pane").show("slide", { direction: "right", mode: "hide" }, 300);*/ } else { $(".sidebar").hide("slide", { direction: "left", mode: "hide" }, 300); /*$(".blog_left_pane").removeClass("none").addClass("none"); $("#blogleft_pane").removeClass("blogleft_pane").addClass("blogleft_Mpane"); $("#blogleft_pane").hide("slide",{direction: "right", mode: "hide"}, 300);*/ } }); } function initRegisterApps() { //for blog /*var BlogControlObj = {}; BlogControlObj.AppID = "blog_postSection"; BlogControlObj.AppName = "BlogControl"; BlogControlObj.Events = []; //{ type: "UpdateAppContent", handler: BlogControlObj.UpdateAppContent }, { type: "contextmenu", handler: BlogControlObj.BindContextMenu }, { type: "OnAuthenticate", handler: BlogControlObj.OnAuthenticate }, { type: "OnLogout", handler: BlogControlObj.OnLogout } BlogControlObj.ContainerID = "blog_postSection"; dams.RegisterApps(BlogControlObj); //for calender var CalendarControlObj = {}; CalendarControlObj.AppID = "calendarControl"; CalendarControlObj.AppName = "CalendarControl"; CalendarControlObj.Events = []; CalendarControlObj.ContainerID = "calendarControl"; dams.RegisterApps(CalendarControlObj);*/ //File chest var FileChestControlObj = {}; FileChestControlObj.AppID = "fileChestMainDiv"; FileChestControlObj.AppName = "FileChestControl"; FileChestControlObj.Events = []; //{ type: "UpdateAppContent", handler: BlogControlObj.UpdateAppContent }, { type: "contextmenu", handler: BlogControlObj.BindContextMenu }, { type: "OnAuthenticate", handler: BlogControlObj.OnAuthenticate }, { type: "OnLogout", handler: BlogControlObj.OnLogout } FileChestControlObj.ContainerID = "fileChestMainDiv"; dams.RegisterApps(FileChestControlObj); //for usergroups var VGControlObj = {}; VGControlObj.AppID = "div_userVgroupsMain"; VGControlObj.AppName = "VGroupControl"; VGControlObj.Events = []; //{ type: "UpdateAppContent", handler: BlogControlObj.UpdateAppContent }, { type: "contextmenu", handler: BlogControlObj.BindContextMenu }, { type: "OnAuthenticate", handler: BlogControlObj.OnAuthenticate }, { type: "OnLogout", handler: BlogControlObj.OnLogout } VGControlObj.ContainerID = "div_userVgroupsMain"; dams.RegisterApps(VGControlObj); //My UserProfile var UProfileControlObj = {}; UProfileControlObj.AppID = "container_myProfileView"; UProfileControlObj.AppName = "MyProfileControl"; UProfileControlObj.Events = []; //{ type: "UpdateAppContent", handler: BlogControlObj.UpdateAppContent }, { type: "contextmenu", handler: BlogControlObj.BindContextMenu }, { type: "OnAuthenticate", handler: BlogControlObj.OnAuthenticate }, { type: "OnLogout", handler: BlogControlObj.OnLogout } UProfileControlObj.ContainerID = "container_myProfileView"; dams.RegisterApps(UProfileControlObj); // for VMS /* var vmsObj = {}; vmsObj.AppID = "div_VmsContent"; vmsObj.AppName = "TvControl"; vmsObj.Events = []; vmsObj.ContainerID = "div_VmsContent"; dams.RegisterApps(vmsObj);*/ }; function LoadModuleHTMl(url) { try { $('#pageContainer').empty(); $.get(url, function (data) { $('#pageContainer').html(data); }).success(function () { }); } catch (exception) { // FrameworkData.catchException(exception, "Error in LoadModuleHTMl: " + exception.message); console.log('Error in LoadModuleHTMl: ' + exception.message); } }; function RegisterApps(controlObj) { try { //check if control already exists or not var App = $.grep(RegisteredAppsCollection, function (App, i) { return App.ContainerID == controlObj.ContainerID; }); if (App.length == 0) { RegisteredAppsCollection.push(controlObj); } else { RegisteredAppsCollection = $.grep(RegisteredAppsCollection, function (App, i) { return App.ContainerID != controlObj.ContainerID; }); RegisteredAppsCollection.push(controlObj); } for (var count = 0; count < controlObj.Events.length; count++) { $(document).on("" + controlObj.Events[count].type, "#" + controlObj.ContainerID, controlObj.Events[count].handler); } } catch (exception) { //FrameworkData.catchException(exception, "Error in RegisterApps: " + exception.message); console.log("Error in RegisterApps: " + exception.message); } }; //this method will create the Upload control for the app at the framework level or override the properties of the control if already exists function SetUploadControl(Upload_properties) { try { var uploadProperties = Upload_properties; var acceptedFormats = "images/*"; if (uploadProperties.acceptedTypes != undefined) acceptedFormats = uploadProperties.acceptedTypes; var controlProp = { accept: acceptedFormats, autoupload: "true", folderUrlPath: "", isCrop: "false", pauseandresume: "true", progressbar: "true", multiselect: "true", chunksize: "32MB", renamefile: "true", totalfilesizeforinstance: "20GB", allowedfileformats: uploadProperties.allowedfileformats, maxfilesize: "5GB", contextid: "FFB7212B-3862-4C58-9311-9E949F0C2508", maxfilecountforinstance: "100", maximumconcurrent: "2", minfilesize: "0KB", isdraggable: "false", background: "null", maxretries: "", templateid: "Script1", relativefilelistid: "fileuplist", serviceurl: svcUploadService, FolderIDToUpload: "", dragupload_id: "" }; uploadProperties.templateid = "Script1"; uploadProperties.relativefilelistid = "fileuplist"; uploadProperties.background = ""; var uploadControl = null; // var uploadFrameWorkEvents = [{ type: "StartUpload", handler: StartUpload }, { type: "FailUpload", handler: FailUpload }, { type: "onFileUploadSuccess", handler: onFileUploadSuccess }, { type: "onfileRemoved", handler: onfileRemoved }]; if ($("#UploadUtility").find('input[id^="' + uploadProperties.ControlId + '"][containerid="' + uploadProperties.ContainerID + '"][FolderIDToUpload="' + uploadProperties.FolderIDToUpload + '"]').length != 1) { uploadProperties.id = uploadProperties.id + "-" + dams.GenerateGUID(); uploadControl = $(''); $(uploadControl).attr({ templateid: "Script1", fileuplist: "fileuplist", background: "" }); $("#UploadUtility").append($(uploadControl)); $.extend(controlProp, uploadProperties); uploadProperties = controlProp; //find the App that requested the upload utlity control in Registered Apps Collection. var App = $.grep(RegisteredAppsCollection, function (obj, i) { return obj.ContainerID == uploadProperties.ContainerID; }); //Add app callback events for uploadcontrol into Registered Apps Collection. if (App.length === 1) { // App[0].UploadEvents = uploadProperties.Events; if (typeof App[0].UploadControlCollection != "undefined") { App[0].UploadControlCollection.push({ ControlId: uploadProperties.id, Properties: uploadProperties }); } else { App[0].UploadControlCollection = []; App[0].UploadControlCollection.push({ ControlId: uploadProperties.id, Properties: uploadProperties }); } } $(uploadControl).attr("clientid", ''+userDetail.ClientID); // getClient ID here $(uploadControl).attr('useruniqueid',''+userDetail.UserID); //get useruniqueid here $(uploadControl).attr('IpAddress', ''); //set the required properties for app upload control for (var property in uploadProperties) { if (property != "Events") $(uploadControl).attr(property, uploadProperties[property]); } // bindControl($(uploadControl)); Upload.BindUploadControl($(uploadControl)); //onfileRemovedhandler, onImageLoadStarted_Handler, onImageLoaded_Handler, onFileUploadSuccess_Handler, onFileUploadFailed_Handler, StartUpload_Handler $(document).off("StartUpload","#" + uploadProperties["id"]); $(document).on("StartUpload","#" + uploadProperties["id"], BOS_StartUpload_Handler); $(document).off("onFileUploadFailed","#" + uploadProperties["id"]); $(document).on("FailUpload","#" + uploadProperties["id"], BOS_onFileUploadFailed_Handler); $(document).off("onFileUploadSuccess","#" + uploadProperties["id"]); $(document).on("onFileUploadSuccess","#" + uploadProperties["id"], BOS_onFileUploadSuccess_Handler); $(document).off("onfileRemoved","#" + uploadProperties["id"]); $(document).on("onfileRemoved","#" + uploadProperties["id"], BOS_onfileRemovedhandler); $(document).off("onImageLoadStarted","#" + uploadProperties["id"]); $(document).on("onImageLoadStarted","#" + uploadProperties["id"], BOS_onImageLoadStarted_Handler); $(document).off("onImageLoaded","#" + uploadProperties["id"]); $(document).on("onImageLoaded","#" + uploadProperties["id"], BOS_onImageLoaded_Handler); $(document).off("OnFileSelectedSuccess","#" + uploadProperties["id"]); $(document).on("OnFileSelectedSuccess", "#" + uploadProperties["id"], OnFileSelectedSuccess); //New Events added $(document).off("OnUploadPause", "#" + uploadProperties["id"]); $(document).on("OnUploadPause", "#" + uploadProperties["id"], OnUploadPause); //$("#" + uploadProperties["id"]).off("onFilesUploadComplete"); //$("#" + uploadProperties["id"]).on("onFilesUploadComplete", CMS_onFilesUploadComplete_Handler); $(uploadControl).trigger("click"); } else { var uploadControl = $("#UploadUtility").find('input[id^="' + uploadProperties.ControlId + '"][containerid="' + uploadProperties.ContainerID + '"][FolderIDToUpload="' + uploadProperties.FolderIDToUpload + '"]'); uploadProperties.id = $(uploadControl).attr("id"); // $(uploadControl).attr(id,""+uploadProperties.id); var properties; var App = $.grep(RegisteredAppsCollection, function (obj, i) { if (obj.ContainerID == uploadProperties.ContainerID) { return true; } else { return false; } }); //Add app callback events for uploadcontrol into Registered Apps Collection. if (App.length === 1) { var UploadControlProp = $.grep(App[0].UploadControlCollection, function (obj, i) { if (obj.ControlId == uploadProperties.id) { return true; } else { return false; } }); if (UploadControlProp.length === 1) { properties = UploadControlProp[0].Properties; uploadProperties.id = properties.id; $.extend(properties, uploadProperties); uploadProperties = properties; for (var property in uploadProperties) { if (property != "Events") $(uploadControl).attr(property, uploadProperties[property]); } $(uploadControl).trigger("click"); } } } } catch (exception) { //FrameworkData.catchException(exception, "Error in initializing the Upload Control: " + exception.message); console.log('Error in initializing the Upload Control: ' + exception.message); } }; ///Date: November 11, 2016 ///Author: Shree ///Purpose: Creates an upload control for folder upload function SetFolderUploadControl(Upload_properties) { try { var uploadProperties = Upload_properties; var acceptedFormats = "images/*"; if (uploadProperties.acceptedTypes != undefined) acceptedFormats = uploadProperties.acceptedTypes; var controlProp = { accept: acceptedFormats, autoupload: "true", folderUrlPath: "", isCrop: "false", pauseandresume: "true", progressbar: "true", multiselect: "true", chunksize: "32MB", renamefile: "true", totalfilesizeforinstance: "20GB", allowedfileformats: uploadProperties.allowedfileformats, maxfilesize: "5GB", contextid: "FFB7212B-3862-4C58-9311-9E949F0C2508", maxfilecountforinstance: "100", maximumconcurrent: "2", minfilesize: "0KB", isdraggable: "false", background: "null", maxretries: "", templateid: "Script1", relativefilelistid: "fileuplist", serviceurl: svcUploadService, FolderIDToUpload: "", dragupload_id: "" }; uploadProperties.templateid = "Script1"; uploadProperties.relativefilelistid = "fileuplist"; uploadProperties.background = ""; var uploadControl = null; uploadProperties.id = uploadProperties.id + "-" + dams.GenerateGUID(); uploadControl = $(''); $(uploadControl).attr({ templateid: "Script1", fileuplist: "fileuplist", background: "" }); $("#UploadUtility").append($(uploadControl)); $.extend(controlProp, uploadProperties); uploadProperties = controlProp; //find the App that requested the upload utlity control in Registered Apps Collection. var App = $.grep(RegisteredAppsCollection, function (obj, i) { return obj.ContainerID == uploadProperties.ContainerID; }); //Add app callback events for uploadcontrol into Registered Apps Collection. if (App.length === 1) { // App[0].UploadEvents = uploadProperties.Events; if (typeof App[0].UploadControlCollection != "undefined") { App[0].UploadControlCollection.push({ ControlId: uploadProperties.id, Properties: uploadProperties }); } else { App[0].UploadControlCollection = []; App[0].UploadControlCollection.push({ ControlId: uploadProperties.id, Properties: uploadProperties }); } } $(uploadControl).attr("clientid", '' + userDetail.ClientID); // getClient ID here $(uploadControl).attr('useruniqueid', '' + userDetail.UserID); //get useruniqueid here $(uploadControl).attr('IpAddress', ''); //set the required properties for app upload control for (var property in uploadProperties) { if (property != "Events") $(uploadControl).attr(property, uploadProperties[property]); } // bindControl($(uploadControl)); Upload.BindUploadControl($(uploadControl)); $(document).off("StartUpload", "#" + uploadProperties["id"]); $(document).on("StartUpload", "#" + uploadProperties["id"], BOS_StartUpload_Handler); $(document).off("onFileUploadFailed", "#" + uploadProperties["id"]); $(document).on("FailUpload", "#" + uploadProperties["id"], BOS_onFileUploadFailed_Handler); $(document).off("onFileUploadSuccess", "#" + uploadProperties["id"]); $(document).on("onFileUploadSuccess", "#" + uploadProperties["id"], BOS_onFileUploadSuccess_Handler); $(document).off("onfileRemoved", "#" + uploadProperties["id"]); $(document).on("onfileRemoved", "#" + uploadProperties["id"], BOS_onfileRemovedhandler); $(document).off("onImageLoadStarted", "#" + uploadProperties["id"]); $(document).on("onImageLoadStarted", "#" + uploadProperties["id"], BOS_onImageLoadStarted_Handler); $(document).off("onImageLoaded", "#" + uploadProperties["id"]); $(document).on("onImageLoaded", "#" + uploadProperties["id"], BOS_onImageLoaded_Handler); $(document).off("OnFileSelectedSuccess", "#" + uploadProperties["id"]); $(document).on("OnFileSelectedSuccess", "#" + uploadProperties["id"], OnFileSelectedSuccess); //New Events added $(document).off("OnUploadPause", "#" + uploadProperties["id"]); $(document).on("OnUploadPause", "#" + uploadProperties["id"], OnUploadPause); $(uploadControl).trigger("click"); } catch (exception) { //FrameworkData.catchException(exception, "Error in initializing the Upload Control: " + exception.message); console.log('Error in initializing the Upload Control: ' + exception.message); } }; function DragDropUploadControl(Upload_properties) { try { var uploadProperties = Upload_properties; var controlProp = { accept: "images/*", autoupload: "true", folderUrlPath: "", isCrop: "false", pauseandresume: "true", progressbar: "true", multiselect: "true", chunksize: "32MB", renamefile: "true", totalfilesizeforinstance: "20GB", allowedfileformats: "jpg,jpeg,png,bmp,gif,mp4,mp3,wav,avi,wmv,wma,mkv,ics,docx,pdf,xls,xlsx,ppt,pptx,rar,zip,txt,m4v,mov,doc,tif,tiff,psd,pages,numbers,keynote,notebook", maxfilesize: "5GB", contextid: "FFB7212B-3862-4C58-9311-9E949F0C2508", maxfilecountforinstance: "100", maximumconcurrent: "2", minfilesize: "0KB", isdraggable: "false", background: "null", maxretries: "", templateid: "Script1", relativefilelistid: "fileuplist", serviceurl: svcUploadService,FolderIDToUpload:"",dragupload_id:""}; uploadProperties.templateid = "Script1"; uploadProperties.relativefilelistid = "fileuplist"; // uploadProperties.background = ""; var uploadControl = null; // var uploadFrameWorkEvents = [{ type: "StartUpload", handler: StartUpload }, { type: "FailUpload", handler: FailUpload }, { type: "onFileUploadSuccess", handler: onFileUploadSuccess }, { type: "onfileRemoved", handler: onfileRemoved }]; //if ($("#UploadUtility").find('input[id^="' + uploadProperties.ControlId + '"][containerid="' + uploadProperties.ContainerID + '"]').length != 1) { uploadProperties.id = uploadProperties.id; uploadProperties.dragupload_id = "dragupload_" + uploadProperties["id"]; // $("." + uploadProperties.DropContainer).attr("id", uploadProperties.id); //$('
') uploadControl = $("#" + uploadProperties.DropContainer); $(uploadControl).attr({ templateid: "Script1", relativefilelistid: "fileuplist", background: "" }); $.extend(controlProp, uploadProperties); uploadProperties = controlProp; uploadProperties.ControlId = "dragupload_" + uploadProperties["id"]; uploadProperties.DropContainer = "dragupload_" + uploadProperties["id"]; //find the App that requested the upload utlity control in Registered Apps Collection. if ($("#UploadUtility").find("div[id^='" + uploadProperties.ControlId + "']").length != 1) { var App = $.grep(RegisteredAppsCollection, function (obj, i) { return obj.ContainerID == uploadProperties.ContainerID; }); //Add app callback events for uploadcontrol into Registered Apps Collection. if (App.length === 1) { // App[0].UploadEvents = uploadProperties.Events; if (typeof App[0].UploadControlCollection != "undefined") { App[0].UploadControlCollection.push({ ControlId: uploadProperties.dragupload_id, Properties: uploadProperties }); } else { App[0].UploadControlCollection = []; App[0].UploadControlCollection.push({ ControlId: uploadProperties.dragupload_id, Properties: uploadProperties }); } } } $(uploadControl).attr("clientid", '' + userDetail.ClientID); // getClient ID here $(uploadControl).attr('useruniqueid', '' + userDetail.UserID); //get useruniqueid here $(uploadControl).attr('IpAddress', ''); //set the required properties for app upload control var uploadcontrol1 = $(uploadControl); if ($("#UploadUtility").find("div[id^='"+ uploadProperties.dragupload_id +"']").length != 1) { $("#UploadUtility").append(""); uploadcontrol1 = $("#" + uploadProperties.dragupload_id); } else { uploadcontrol1 = $("#" + uploadProperties.dragupload_id); } for (var property in uploadProperties) { if (property != "Events") { $(uploadControl).attr(property, uploadProperties[property]); $(uploadcontrol1).attr(property, uploadProperties[property]); } } $(uploadcontrol1).attr("id", "" + uploadProperties.dragupload_id); $(uploadcontrol1).attr("clientid", '' + userDetail.ClientID); // getClient ID here $(uploadcontrol1).attr('useruniqueid', '' + userDetail.UserID); //get useruniqueid here $(uploadcontrol1).attr('IpAddress', ''); // bindControl($(uploadControl)); Upload.BindUploadControl($(uploadControl)); //onfileRemovedhandler, onImageLoadStarted_Handler, onImageLoaded_Handler, onFileUploadSuccess_Handler, onFileUploadFailed_Handler, StartUpload_Handler //if ($("#UploadUtility").find("div[id^='"+ uploadProperties.ControlId + "']").length != 1) { $(document).off("StartUpload", "#"+uploadProperties["dragupload_id"]); $(document).on("StartUpload", "#"+uploadProperties["dragupload_id"], BOS_StartUpload_Handler); $(document).off("onFileUploadFailed", "#"+uploadProperties["dragupload_id"]); $(document).on("FailUpload", "#"+uploadProperties["dragupload_id"], BOS_onFileUploadFailed_Handler); $(document).off("onFileUploadSuccess", "#"+uploadProperties["dragupload_id"]); $(document).on("onFileUploadSuccess", "#"+uploadProperties["dragupload_id"], BOS_onFileUploadSuccess_Handler); $(document).off("onfileRemoved", "#"+ uploadProperties["dragupload_id"]); $(document).on("onfileRemoved", "#"+uploadProperties["dragupload_id"], BOS_onfileRemovedhandler); $(document).off("onImageLoadStarted", "#"+ uploadProperties["dragupload_id"]); $(document).on("onImageLoadStarted", "#"+uploadProperties["dragupload_id"], BOS_onImageLoadStarted_Handler); $(document).off("onImageLoaded", "#"+uploadProperties["dragupload_id"]); $(document).on("onImageLoaded", "#"+uploadProperties["dragupload_id"], BOS_onImageLoaded_Handler); $(document).off("OnFileSelectedSuccess", "#"+uploadProperties["dragupload_id"]); $(document).on("OnFileSelectedSuccess", "#" + uploadProperties["dragupload_id"], OnFileSelectedSuccess); $(document).off("OnFolderSelectedSuccess", "#" + uploadProperties["dragupload_id"]); //[November 15, 2016: Shree]: Binding the callback for Folder Drag-Drop $(document).on("OnFolderSelectedSuccess", "#" + uploadProperties["dragupload_id"], OnFolderSelectedSuccess); //[November 15, 2016: Shree]: Binding the callback for Folder Drag-Drop //added new events $(document).off("OnUploadPause", "#"+uploadProperties["dragupload_id"]); $(document).on("OnUploadPause", "#" + uploadProperties["dragupload_id"], OnUploadPause); //} //$("#" + uploadProperties["id"]).off("onFilesUploadComplete"); //$("#" + uploadProperties["id"]).on("onFilesUploadComplete", CMS_onFilesUploadComplete_Handler); // $(uploadControl).trigger("click"); } catch (exception) { //FrameworkData.catchException(exception, "Error in initializing the Upload Control: " + exception.message); console.log('Error in initializing the Upload Control: ' + exception.message); } }; function LoadResource_RLoader(resourceObj) { var resourceObj = resourceObj; $.rloader(resourceObj); }; function GenerateGUID() { try { var d = new Date().getTime(); var uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) { var r = (d + Math.random() * 16) % 16 | 0; d = Math.floor(d / 16); return (c == 'x' ? r : (r & 0x3 | 0x8)).toString(16); }); return uuid; } catch (exception) { //FrameworkData.catchException(exception, "Error in Loding Resource: " + exception.message); console.log("Error in Loding Resource: " + exception.message); } }; function DownloadFile(dataForDownload) { var downloadProperties = dataForDownload; var defaultDownloadProperties = { ZipFileName: "Mydownload.zip", OnDownloadInit: dams.BOS_OnDownloadIntitalized, OnDownloadStart: dams.BOS_OnDownloadStarted, OnDownloadComplete: dams.BOS_OnDownloadComplete, OnDownloadError: dams.BOS_OnDownladError, NotSupportedDownload: dams.BOS_NotSupportedDownload } $.extend(true,defaultDownloadProperties, downloadProperties); downloadProperties = defaultDownloadProperties; DownloadAll.init(downloadProperties); } function BOS_OnDownloadIntitalized(sender, args) { } function BOS_OnDownloadStarted(sender, args) { } function BOS_OnDownloadComplete(sender, args) { } function BOS_OnDownladError(sender, args) { } function BOS_NotSupportedDownload(sender, args) { } //author: //Description: This method calls the real time function and handles the callback functionality function HandleRealtimeNotification(nofityobj) { proxyRealtime.invoke('SendNotificationMessages', nofityobj); proxyRealtime.on('RaiseNotificationMessage', function (dtoObj) { if(CurrentModule == 'DAMS'){ } }); } return { init: init, LoadModuleHTMl: LoadModuleHTMl, LoadResource: LoadResource_RLoader, RegisterApps: RegisterApps, SetUploadControl: SetUploadControl, GenerateGUID: GenerateGUID, DownloadFile: DownloadFile, DragDropUploadControl:DragDropUploadControl, BOS_OnDownloadIntitalized: BOS_OnDownloadIntitalized, BOS_OnDownloadStarted: BOS_OnDownloadStarted, BOS_OnDownloadComplete: BOS_OnDownloadComplete, BOS_OnDownladError: BOS_OnDownladError, BOS_NotSupportedDownload: BOS_NotSupportedDownload, HandleRealtimeNotification: HandleRealtimeNotification, SetFolderUploadControl: SetFolderUploadControl //Shree [November 11, 2016] : Method for creating an upload control for Folder Upload //SetUploadControlfordragdrop: SetUploadControlfordragdrop } })(); /*******************Upload Utlitiy handlers*************************/ function updateUploadCount() { /*code to update the count in notification start*/ if ($("#fileuplist").children().length > 0) { var alreadycount = $("#fileuplist").children(".countincluded").length; var completeCount = $("#fileuplist").children().length; $("#uploadNtificationCount").html(completeCount - alreadycount); $("#uploadNtificationCount").show(); } /*code to update the count in notification end*/ } //$.fn.lightOrDark = function (element) { // var r, b, g, hsp // , a = $(element).css('background-color'); // if (a.match(/^rgb/)) { // a = a.match(/^rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+(?:\.\d+)?))?\)$/); // r = a[1]; // g = a[2]; // b = a[3]; // } else { // a = +("0x" + a.slice(1).replace( // a.length < 5 && /./g, '$&$&' // ) // ); // r = a >> 16; // b = a >> 8 & 255; // g = a & 255; // } // hsp = Math.sqrt(0.299 (r r) + 0.587 (g g) + 0.114 (b b)); //128; // if (hsp > 127.5) { // $(element).addClass('cal_dark'); // // $(element).addClass('cal_light'); // } else { // $(element).addClass('cal_light'); // // $(element).addClass('cal_dark'); // } //} //function OnFileSelectedSuccess(uploadOject, data) { // alert("FileSeleted"); //} //Added to bind event handlers for on pause function OnUploadPause(sender, responseObj, controlargs) { var uploadControlID = $(sender.target).attr("id"); var appContainerID = $("#" + uploadControlID).attr("ContainerID"); for (var count = 0; count < controlargs.list.length; count++) { if (controlargs.list[count].fileId == responseObj.FileID) { controlargs.list[count].status = "paused"; } } var eventarguments = generateEventParameters(controlargs); var completeObj = { type: "UploadControlEvent", eventType: "OnUploadPause", data: { sender: eventarguments, responseObject: responseObj } }; var outerCount = 0; var filelist = new Array(); for (var count = 0; count < controlargs.list.length; count++) { // if (controlargs.list[count].status == "success" || controlargs.list[count].status == "cancelled" || controlargs.list[count].status == "removed") { filelist.push(new file(controlargs.list[count].fileId, controlargs.list[count].status)); outerCount++; } } UploadCallbackForApp(completeObj.eventType, appContainerID, uploadControlID, completeObj); if (outerCount == controlargs.list.length && controlargs.list.length > 1) { if (typeof (responseObj.serverUploadId) != "undefined") { eventarguments.ServerUploadID = responseObject.serverUploadId; eventarguments.ServerUploadID = responseObj.ServerUploadID; var completeObj123 = { type: "UploadControlEvent", eventType: "onFilesUploadComplete", data: { sender: eventarguments, args: filelist } }; BOS_onFilesUploadComplete_Handler(appContainerID, uploadControlID, completeObj123); // $("#" + sender.target.id).removeFileFromCollection({ id: completeObj123.data.args.FileID }); //UploadCallbackForApp(completeObj123.eventType, appContainerID, uploadControlID, completeObj123); } } var fileIDs=completeObj.data.responseObject.FileID; if ($("#pauseButton-" + fileIDs).hasClass("play_upload_file")) { $("#pauseButton-" + fileIDs).removeClass("fa-pause").removeClass("fa-play").addClass("fa-play"); } else if ($("#pauseButton-" + fileIDs).hasClass("pause_upload_file")) { $("#pauseButton-" + fileIDs).removeClass("fa-play").removeClass("fa-pause").addClass("fa-pause"); } }; ///Date: November 15, 2016 ///Author: Shree ///Purpose: Binding the event handler for Folder Drag- Drop function OnFolderSelectedSuccess(sender, controlargs) { if (CurrentModule == "DAMS") { var eventarguments = generateEventParameters(controlargs); if (eventarguments.IsFolder == "true") { eventarguments.FolderUploadID = $("#" + controlargs.uploadWidgetId).attr("FolderUploadID"); } var completeObj = { type: "UploadControlEvent", eventType: "OnFolderSelectedSuccess", data: { sender: sender, args: controlargs } }; var uploadControlID = $(sender.target).attr("id"); var appContainerID = $("#" + uploadControlID).attr("ContainerID"); UploadCallbackForApp(completeObj.eventType, appContainerID, uploadControlID, completeObj); } //else if (CurrentModule == "Blog") { // var eventarguments = generateEventParameters(sender); // var completeObj = { // type: "UploadControlEvent", // eventType: "OnFolderSelectedSuccess", // data: { // sender: sender, // args: controlargs // } // }; // var uploadControlID = $(sender.target).attr("id"); // var appContainerID = $("#" + uploadControlID).attr("ContainerID"); // var contorl_obj = controlargs.control_object; // // startupload(contorl_obj); // Upload.startupload(contorl_obj); // UploadCallbackForApp(completeObj.eventType, appContainerID, uploadControlID, completeObj); //} /* else if (CurrentModule == "TVOD") { var eventarguments = generateEventParameters(sender); var completeObj = { type: "UploadControlEvent", eventType: "OnFileSelectedSuccess", data: { sender: sender, args: controlargs } }; var uploadControlID = $(sender.target).attr("id"); var appContainerID = $("#" + uploadControlID).attr("ContainerID"); var contorl_obj = controlargs.control_object; Upload.startupload(contorl_obj); UploadCallbackForApp(completeObj.eventType, appContainerID, uploadControlID, completeObj); }*/ else { var contorl_obj = controlargs.control_object; // startupload(contorl_obj); Upload.startupload(contorl_obj); } sender.preventDefault(); }; function OnFileSelectedSuccess(sender, controlargs) { if (CurrentModule == "DAMS") { var eventarguments = generateEventParameters(controlargs); if (eventarguments.IsFolder == "true") { eventarguments.FolderUploadID = $("#" + controlargs.uploadWidgetId).attr("FolderUploadID"); } var completeObj = { type: "UploadControlEvent", eventType: "OnFileSelectedSuccess", data: { sender: sender, args: controlargs } }; var uploadControlID = $(sender.target).attr("id"); var appContainerID = $("#" + uploadControlID).attr("ContainerID"); UploadCallbackForApp(completeObj.eventType, appContainerID, uploadControlID, completeObj); } /*else if (CurrentModule == "Blog") { var eventarguments = generateEventParameters(sender); //[November 15, 2016: Shree] - Added to check if the it is a Folder Upload if (eventarguments.IsFolder == "true") { eventarguments.FolderUploadID = $("#" + controlargs.uploadWidgetId).attr("FolderUploadID"); } var completeObj = { type: "UploadControlEvent", eventType: "OnFileSelectedSuccess", data: { sender: sender, args: controlargs } }; var uploadControlID = $(sender.target).attr("id"); var appContainerID = $("#" + uploadControlID).attr("ContainerID"); var contorl_obj = controlargs.control_object; // startupload(contorl_obj); Upload.startupload(contorl_obj); UploadCallbackForApp(completeObj.eventType, appContainerID, uploadControlID, completeObj); } else if (CurrentModule == "TVOD") { var eventarguments = generateEventParameters(sender); var completeObj = { type: "UploadControlEvent", eventType: "OnFileSelectedSuccess", data: { sender: sender, args: controlargs } }; var uploadControlID = $(sender.target).attr("id"); var appContainerID = $("#" + uploadControlID).attr("ContainerID"); var contorl_obj = controlargs.control_object; Upload.startupload(contorl_obj); UploadCallbackForApp(completeObj.eventType, appContainerID, uploadControlID, completeObj); }*/ else { var contorl_obj = controlargs.control_object; // startupload(contorl_obj); Upload.startupload(contorl_obj); } sender.preventDefault(); }; var uploadInterval; var FinalActualPercentage; var FinalUploadID; function BOS_StartUpload_Handler(sender, controlargs) { uploadInterval = setInterval(function () { var pauseId = $(".pauseButton")[0].id; var PercentageId = pauseId.replace("pauseButton", "span"); var EarlierPercentage = FinalActualPercentage; var EarlierUploadID=FinalUploadID; ActualPercentage = $("#" + PercentageId).html().replace("%", ""); FinalActualPercentage = parseInt(ActualPercentage); FinalUploadID=$(".pauseButton")[0].id; if(FinalActualPercentage==EarlierPercentage) { $(".pauseButton")[0].click(); $(".pauseButton")[0].click() } }, 15000); updateUploadCount(); var eventarguments = generateEventParameters(controlargs); //Shree [November 11, 2016] : Method exclusively for Folder Upload if (eventarguments.IsFolder == "true") { eventarguments.FolderUploadID = $("#" + controlargs.uploadWidgetId).attr("FolderUploadID"); } ////////// eventarguments["Files"] = new Array(); for (var count = 0; count < controlargs.current_file_selection.length; count++) { eventarguments["Files"].push({ filename: controlargs.current_file_selection[count].file.name,filesize: controlargs.current_file_selection[count].file.size, filetype:controlargs.current_file_selection[count].file.type, fileid: controlargs.current_file_selection[count].fileId }); } var completeObj = { type: "UploadControlEvent", eventType: "StartUpload", data: { sender: eventarguments } }; var uploadControlID = $(sender.target).attr("id"); var appContainerID = $("#" + uploadControlID).attr("ContainerID"); UploadCallbackForApp(completeObj.eventType, appContainerID, uploadControlID, completeObj); } function BOS_onFileUploadFailed_Handler(sender, arg, controlargs) { var uploadControlID = $(sender.target).attr("id"); var appContainerID = $("#" + uploadControlID).attr("ContainerID"); var eventarguments = generateEventParameters(controlargs); if (eventarguments.IsFolder == "true") { eventarguments.FolderUploadID = $("#" + controlargs.uploadWidgetId).attr("FolderUploadID"); } var files = new Array(); files.push(args.FileID); var completeObj = { type: "UploadControlEvent", eventType: "onFileUploadFailed", data: { sender: eventarguments, args: files } }; var outerCount = 0; var filelist = new Array(); for (var count = 0; count < controlargs.list.length; count++) { if (controlargs.list[count].status == "success" || controlargs.list[count].status == "cancelled" || controlargs.list[count].status == "removed") { filelist.push(new file(controlargs.list[count].fileId, controlargs.list[count].status)); outerCount++; } } UploadCallbackForApp(completeObj.eventType, appContainerID, uploadControlID, completeObj); if (outerCount == controlargs.list.length && controlargs.list.length > 1) { var completeObj123 = { type: "UploadControlEvent", eventType: "onFilesUploadComplete", data: { sender: eventarguments, args: filelist } }; BOS_onFilesUploadComplete_Handler(appContainerID, uploadControlID, completeObj123); //UploadCallbackForApp(completeObj123.eventType, appContainerID, uploadControlID, completeObj123); } } function BOS_onFileUploadSuccess_Handler(sender, responseObject, controlargs) { var uploadControlID = $(sender.target).attr("id"); var appContainerID = $("#" + uploadControlID).attr("ContainerID"); var eventarguments = generateEventParameters(controlargs); //Shree [November 11, 2016] : Method exclusively for Folder Upload if (eventarguments.IsFolder == "true") { eventarguments.FolderUploadID = $("#" + controlargs.uploadWidgetId).attr("FolderUploadID"); } ///// if (responseObject.File == undefined) { responseObject.Size = responseObject.Size; } else { responseObject.Size = responseObject.File.size; } delete responseObject["File"]; var eventarguments = generateEventParameters(controlargs); var completeObj = { type: "UploadControlEvent", eventType: "onFileUploadSuccess", data: { sender: eventarguments, args: responseObject } }; var outerCount = 0; var filelist = new Array(); for (var count = 0; count < controlargs.list.length; count++) { if (controlargs.list[count].status == "success" || controlargs.list[count].status == "cancelled" || controlargs.list[count].status == "removed") { filelist.push(new file(controlargs.list[count].fileId, controlargs.list[count].status, controlargs.list[count])); outerCount++; } } UploadCallbackForApp(completeObj.eventType, appContainerID, uploadControlID, completeObj); if (controlargs.isCrop == true) { $("#" + completeObj.data.sender.uploadWidgetId).removeFileOnlyFromList({ id: completeObj.data.args.FileID }); } if (outerCount == controlargs.list.length && controlargs.list.length >= 1) { eventarguments.ServerUploadID = responseObject.serverUploadId; var completeObj123 = { type: "UploadControlEvent", eventType: "onFilesUploadComplete", data: { sender: eventarguments, args: filelist } }; BOS_onFilesUploadComplete_Handler(appContainerID, uploadControlID, completeObj123); UploadCallbackForApp(completeObj123.eventType, appContainerID, uploadControlID, completeObj123); //$("#" + completeObj.data.sender.uploadWidgetId).removeFileOnlyFromList({ id: completeObj.data.args.FileID }); } } function BOS_onFilesUploadComplete_Handler(appContainerID, uploadControlID,completeObj123) { clearInterval(uploadInterval); //var completeObj123 = { // type: "UploadControlEvent", // eventType: "onFilesUploadComplete", // data: { // sender: sender, // args: args // } //}; /* if (eventarguments.IsFolder == "true") { eventarguments.FolderUploadID = $("#" + controlargs.uploadWidgetId).attr("FolderUploadID"); }*/ UploadCallbackForApp(completeObj123.eventType, appContainerID, uploadControlID, completeObj123); $.each(completeObj123.data.args, function (i, File) { $("#" + completeObj123.data.sender.uploadWidgetId).removeFileOnlyFromList({ id: File.fileId }); }); }; //this method is the event handler for the cropping image after loading function BOS_onImageLoaded_Handler(sender, args) { $(window).scrollTop(0); var x = Upload.GetControlParameters(sender.target); x = generateEventParameters(x); var completeObj = { type: "UploadControlEvent", eventType: "onImageLoaded", data: { sender: sender, args: x } }; var uploadControlID = $(sender.target).attr("id"); var appContainerID = $("#" + uploadControlID).attr("ContainerID"); UploadCallbackForApp(completeObj.eventType, appContainerID, uploadControlID, completeObj); } //this method is the handler for the cropping image load started function BOS_onImageLoadStarted_Handler(sender) { var x = Upload.GetControlParameters(sender.target); x = generateEventParameters(x); var completeObj = { type: "UploadControlEvent", eventType: "onImageLoadStarted", data: { sender: sender, args: x } }; var uploadControlID = $(sender.target).attr("id"); var appContainerID = $("#" + uploadControlID).attr("ContainerID"); UploadCallbackForApp(completeObj.eventType, appContainerID, uploadControlID, completeObj); } function BOS_onfileRemovedhandler(sender, responseObj, controlargs) { var uploadControlID = $(sender.target).attr("id"); var appContainerID = $("#" + uploadControlID).attr("ContainerID"); for (var count = 0; count < controlargs.list.length; count++) { if (controlargs.list[count].fileId == responseObj.FileID) { controlargs.list[count].status = "removed"; } } var eventarguments = generateEventParameters(controlargs); var completeObj = { type: "UploadControlEvent", eventType: "onfileRemoved", data: { sender: eventarguments, responseObject: responseObj } }; var outerCount = 0; var filelist = new Array(); for (var count = 0; count < controlargs.list.length; count++) { // if (controlargs.list[count].status == "success" || controlargs.list[count].status == "cancelled" || controlargs.list[count].status == "removed") { filelist.push(new file(controlargs.list[count].fileId, controlargs.list[count].status)); outerCount++; } } UploadCallbackForApp(completeObj.eventType, appContainerID, uploadControlID, completeObj); if (outerCount == controlargs.list.length && controlargs.list.length > 1) { if (typeof (responseObj.serverUploadId) != "undefined") { eventarguments.ServerUploadID = responseObject.serverUploadId; eventarguments.ServerUploadID = responseObj.ServerUploadID; var completeObj123 = { type: "UploadControlEvent", eventType: "onFilesUploadComplete", data: { sender: eventarguments, args: filelist } }; BOS_onFilesUploadComplete_Handler(appContainerID, uploadControlID, completeObj123); // $("#" + sender.target.id).removeFileFromCollection({ id: completeObj123.data.args.FileID }); //UploadCallbackForApp(completeObj123.eventType, appContainerID, uploadControlID, completeObj123); } } $("#" + sender.target.id).removeFileFromCollection({ id: responseObj.FileID }); var uploadcount = parseInt($("#uploadNtificationCount").text(), 10); if (uploadcount > 0) $("#uploadNtificationCount").text("" + (uploadcount - 1)); } //function BOS_OnFileSelectedSuccess(sender, responseObj, controlargs) { } function file(fileid, status) { this.fileId = fileid; this.status = status; } //pass upload data to respective app incase function UploadCallbackForApp(eventType, appContainerID, uploadControlID, data) { var App = $.grep(RegisteredAppsCollection, function (obj, i) { return obj.ContainerID == appContainerID; }); //Add app callback events for uploadcontrol into Registered Apps Collection. if (App.length === 1) { // App[0].UploadEvents = uploadProperties.Events; var UploadControlProp = $.grep(App[0].UploadControlCollection, function (obj, i) { if (obj.ControlId == uploadControlID) { // console.log('t'); return true; } else { // console.log('f'); return false; } }); if (UploadControlProp.length === 1) { var properties = UploadControlProp[0].Properties; var EventObj = $.grep(UploadControlProp[0].Properties.Events, function (obj, i) { return obj.type == eventType; }); if (EventObj.length === 1) EventObj[0].handler(data); } } }; function generateEventParameters(args) { var eventParameter = { dragupload_id:args["dragupload_id"] || "", FolderIDToUpload: args["FolderIDToUpload"] || "", FolderUploadID: args["FolderUploadID"] || "", //Shree [November 11, 2016] : Property exclusively for Folder Upload IpAddress: args["IpAddress"] || null, InstanceUserData: args["InstanceUserData"] || null, totalFileCount: args["totalFileCount"] || null, totalSize: args["totalSize"] || null, totalProgress: args["totalProgress"] || null, bytesUploaded: args["bytesUploaded"] || null, isAllCancelled: args["isAllCancelled"] || null, uploadWidgetId: args["uploadWidgetId"] || null, isGlobalDataIncluded: args["isGlobalDataIncluded"] || null, formatsCollection: args["formatsCollection"] || null, MultiSelect: args["MultiSelect"] || null, currentUploadingSetIndex: args["currentUploadingSetIndex"] || null, AllowedFormats: args["AllowedFormats"] || null, TotalFileSizeForInstance: args["TotalFileSizeForInstance"] || null, MaxFileSize: args["MaxFileSize"] || null, MinFileSize: args["MinFileSize"] || null, MaxFileCountForInstance: args["MaxFileCountForInstance"] || null, MaximumConcurrent: args["MaximumConcurrent"] || null, RenameFile: args["RenameFile"] || null, AutoUpload: args["AutoUpload"] || null, IsPauseResume: args["IsPauseResume"] || null, MaxRetries: args["MaxRetries"] || null, IsProgressbarRequired: args["IsProgressbarRequired"] || null, baseUrl: args["baseUrl"] || null, chunkSize: args["chunkSize"] || null, ClientId: args["ClientId"] || null, ContextId: args["ContextId"] || null, UserUniqueId: args["UserUniqueId"] || null, filetobenamed: args["filetobenamed"] || null, folderUrlpath: args["folderUrlpath"] || null, IsFolder: args["IsFolder"] || false,//Shree [November 11, 2016] : Property exclusively for Folder Upload eventargs: args["eventargs"] || null }; return eventParameter; } /*******************Upload Utlitiy handlers*************************/ $(document).on("click", ".module", function (e) { $('.sidebar').find('.active').removeClass("active"); $('#container_myProfileView').addClass('none'); var html = ""; /*if ($(this).hasClass("Blog")) { CurrentModule = "Blog"; html = "Module/Blog/blog.html"; } else if ($(this).hasClass("Dashboard")) { CurrentModule = "Dashboard"; html = "Module/Dashboard/dashboard.html"; } else if ($(this).hasClass("WorkBoard")) { CurrentModule = "WorkBoard"; html = "Module/Workboard/workboard.html"; } else if ($(this).hasClass("Calendar")) { CurrentModule = "Calendar"; html = "Module/Calendar/calendar.html"; } else if ($(this).hasClass("TVOD")) { CurrentModule = "TVOD"; html = "Module/vms/vms.html"; } else if ($(this).hasClass("Notification")) { CurrentModule = "Notification"; html = "Module/Notification/Notification.html"; }else*/ if ($(this).hasClass("DAMS")) { CurrentModule = "DAMS"; html = "Module/filechest/filechest.html"; isFirstTime = false; } else if ($(this).hasClass("userGroups")) { CurrentModule = "userGroups"; html = "Module/Usergroups/userandgroups.html"; } dams.LoadModuleHTMl(html); $(this).addClass("active"); }); $(document).on("click", "#li_MyProfile", function (e) { CurrentModule = 'MyProfile'; $('.sidebar').find('.active').removeClass("active"); var html = "Module/Usergroups/MyProfile.html"; dams.LoadModuleHTMl(html); }); $(document).off("click", "#notificationBell"); $(document).on("click", "#notificationBell", function (event) { //if($(".notifidiv").hasClass("none")) //$(".notifidiv").removeClass("none"); //else //$(".notifidiv").addClass("none"); if ($(".emailbx-popup").hasClass("open")) { $(".emailbx-popup").toggle("down"); $(".emailbx-popup").removeClass("open"); } else { $(".emailbx-popup").toggle('up'); $(".emailbx-popup").removeClass("open").addClass("open"); } event.stopPropagation(); }); $(document).on("click", "#clear_upload_history", function (event) { $("#fileuplist").find(".row").each(function (event) { if ($(this).find(".progress-value").text() == "100%") { $(this).remove(); $("#uploadNtificationCount").text("" + (parseInt($("#uploadNtificationCount").text()) - 1)); } if ($(this).hasClass("downloadText")) { $(this).remove(); $("#uploadNtificationCount").text("" + (parseInt($("#uploadNtificationCount").text()) - 1)); } }); }); /// r_loader logic (function ($) { $.rloader = function (args, requestedBy) { var list = [], resourcestoload = [], eventstohandle = [], attachevents = [], onreadyevent = null; if (args && !(args.propertyIsEnumerable('length')) && typeof args === 'object' && typeof args.length === 'number') { list = args; } else { list[0] = args; } function runFunction(f, arg) { if ($.isFunction(f) || typeof f === 'string') { if ($.isFunction(f)) { f(arg); return true; } else { var fn = window[f]; if (typeof fn === 'function') { fn(arg); return true; } else { if (typeof eval(f) === "function") { eval(f).call(this, arg); return true; } } } return false; } return true; } // alternative IE safe console solution function add2console(text) { if (!(console)) { window.console = { tlog: "", log: function (par) { console.tlog += par + "\n"; return true; } }; } console.log(text); } //================================================================== //================================================================== function processAttachedCallbacks(src) { var j; var callbackstructarray = $.rloader.track[src]._cback; if (callbackstructarray) { for (j = 0; j < callbackstructarray.length; j++) { runFunction(callbackstructarray[j].callback, callbackstructarray[j].arg); } // reset the array to no elements (all callbacks were processed) $.rloader.track[src]._cback = []; } return true; } //================================================================== //================================================================== function processAttachedEvents(src) { var i, j, fire, event; for (j = 0; j < $.rloader.track[src]._evts.length; j++) { event = $.rloader.track[src]._evts[j]; if (event.fired === 0) { fire = true; for (i = 0; i < event.rlist.length; i++) { // -1 is error in loading (ignore this.... we still fire the event even though there was an error !!!) if ($.rloader.track[event.rlist[i]]) { if ($.rloader.track[event.rlist[i]].status === 0) { fire = false; break; } } else { // Bugfix in 1.5.4 fire = false; break; } } if (fire) { runFunction(event.func, event.arg); // make sure this event does not get fired twice $.rloader.track[src]._evts[j].fired = 1; $.rloader.track[src]._evts[j].rlist = null; $.rloader.track[src]._evts[j].event = ""; $.rloader.track[src]._evts[j].arg = null; } } } $.rloader.track[src]._evts = $.grep($.rloader.track[src]._evts, function (val) { return val.fired !== 1; }); } //============================================================================= // this will handle an event //============================================================================= function doEvent(src) { processAttachedCallbacks(src); processAttachedEvents(src); } function loadCSS(options) { var src = options.src; if (!options.cache) { var d = new Date(); src = src + "?" + d.getTime(); } var node = document.createElement('link'); node.type = 'text/css'; node.rel = 'stylesheet'; node.href = src; node.media = 'screen'; document.getElementsByTagName("head")[0].appendChild(node); $.rloader.track[options.src].status = 1; var IsLoaded = $.grep(ResourceCollection, function (obj, i) { if (obj.ResourceName == src.split('/').pop() && obj.Url == src) { return true; } else { return false; } }); if (IsLoaded.length == 0) ResourceCollection.push({ Url: src, ResourceName: src.split('/').pop(), Type: src.split('/').pop().split('.').pop() }); doEvent(options.src); return true; } function loadJS(options) { var src = options.src; $.ajax({ type: "GET", url: src, async: options.async, cache: options.cache, dataType: "script", error: function (jqXHR, textStatus, errorThrown) { $.rloader.track[src].status = -1; $.rloader.track[src].error = "rloader ajax error: " + textStatus + " - " + errorThrown; add2console($.rloader.track[src].error); add2console('rloader error on resource: ' + src); }, statusCode: { 404: function () { $.rloader.track[src].status = -2; $.rloader.track[src].error = "rloader error: 404 - Resource NOT found: " + src; add2console($.rloader.track[src].error); } }, success: function () { $.rloader.track[src].status = 1; var IsLoaded = $.grep(ResourceCollection, function (obj, i) { if (obj.ResourceName == src.split('/').pop() && obj.Url == src) { return true; } else { return false; } }); if (IsLoaded.length == 0) ResourceCollection.push({ Url: src, ResourceName: src.split('/').pop(), Type: src.split('/').pop().split('.').pop() }); doEvent(src); } }); } function getFileType(filename) { return filename.split('.').pop().toLowerCase(); } // process the listed arguments (Split them into resources and events, and do checking) $.each(list, function (i, res) { if (typeof res.defaultcache === "boolean") { $.rloader.track.defaultcache = res.defaultcache; } if (typeof res.defaultasync === "boolean") { $.rloader.track.defaultasync = res.defaultasync; } if (typeof res.event === 'string') { if (res.event === 'onready' || res.event === 'beforeload') { // type check for an event if (typeof res.func === 'string' || typeof res.func === 'function') { var arg = null; if (res.arg) { arg = res.arg; } if (arg === null) { res.arg = {}; } res.fired = 0; eventstohandle.push(res); } } } else { // The fileextension will be the type, in this version the type parameter is ignored completely if (typeof res.src === 'string') { res.type = getFileType(res.src); if (res.type === 'js' || res.type === 'css') { // preprocess all options here to correct format var callback = null; if (res.callback) { // type checking if (typeof res.callback === 'string' || typeof res.callback === 'function') { callback = res.callback; } } res.callback = callback; var argf = {}; if (typeof res.arg !== "undefined") { // type checking if (typeof res.arg === "object") { argf = res.arg; } } res.arg = argf; var async = $.rloader.track.defaultasync; if (typeof res.async !== "undefined") { if (typeof res.async === "boolean") { async = res.async; } if ((typeof res.async === "number") && res.async === 1) { async = true; } } res.async = async; var cache = $.rloader.track.defaultcache; if (typeof res.cache !== "undefined") { if (typeof res.cache === "boolean") { cache = res.cache; } if ((typeof res.cache === "number") && res.cache === 1) { cache = true; } } res.cache = cache; resourcestoload.push(res); } } } }); var i, j, justres; for (i = 0; i < eventstohandle.length; i++) { if (eventstohandle[i].event === "beforeload") { runFunction(eventstohandle[i].func, eventstohandle[i].arg); } if (eventstohandle[i].event === "onready") { justres = []; for (j = 0; j < resourcestoload.length; j++) { //Callback: resourcestoload[j].callback, CallbackArg: resourcestoload[j].arg,LastRequestedApp: requestedBy.AppName,LastRequestedAppContainer:requestedBy.ContainerID } justres.push(resourcestoload[j].src); } eventstohandle[i].rlist = justres; //add //ResourceCollection = resourcestoload; onreadyevent = eventstohandle[i]; } } //==-- process the resources var resname = "", restype = "", xxx, trackstruct, callbstruct, estruct; var addcallback, addevent, allresourcesloaded = true; for (j = 0; j < resourcestoload.length; j++) { // does it need to be loaded ? resname = resourcestoload[j].src; restype = resourcestoload[j].type; if (!$.rloader.track[resname]) { allresourcesloaded = false; trackstruct = {}; trackstruct.status = 0; trackstruct._cback = []; trackstruct._evts = []; callbstruct = {}; callbstruct.callback = resourcestoload[j].callback; callbstruct.arg = resourcestoload[j].arg; trackstruct._cback.push(callbstruct); // add flag to process the onreadyevents if (onreadyevent !== null) { trackstruct._evts.push(onreadyevent); } $.rloader.track[resname] = trackstruct; if (restype === 'css') { loadCSS(resourcestoload[j]); all_loaded = false; } if (restype === 'js') { loadJS(resourcestoload[j]); all_loaded = false; } } else { if ($.rloader.track[resname].status === 1) { callbstruct = {}; callbstruct.callback = resourcestoload[j].callback; callbstruct.arg = resourcestoload[j].arg; $.rloader.track[resname]._cback.push(callbstruct); if (onreadyevent !== null) { $.rloader.track[resname]._evts.push(onreadyevent); } processAttachedCallbacks(resname); // dont have to change all_loaded here, because it was allready loaded ! } else { if ($.rloader.track[resname].status === 0) { addcallback = true; for (xxx = 0; xxx < $.rloader.track[resname]._cback.length; xxx++) { // walk through all existing callbacks and compare those if ($.rloader.track[resname]._cback[xxx].callback === resourcestoload[j].callback && $.rloader.track[resname]._cback[xxx].arg === resourcestoload[j].arg) { addcallback = false; break; } } if (addcallback) { callbstruct = {}; callbstruct.callback = resourcestoload[j].callback; callbstruct.arg = resourcestoload[j].arg; $.rloader.track[resname]._cback.push(callbstruct); } // add flag to process the onreadyevents if (onreadyevent !== null) { addevent = true; for (xxx = 0; xxx < $.rloader.track[resname]._evts.length; xxx++) { estruct = $.rloader.track[resname]._evts[xxx]; // LLS 20110724 if (estruct === null) { continue; } if (estruct.event === onreadyevent.event && estruct.func === onreadyevent.func && estruct.arg === onreadyevent.arg && estruct.rlist === onreadyevent.rlist && estruct.fired === 0) { // if this event is allready in the list and not fired addevent = false; break; } } if (addevent) { $.rloader.track[resname]._evts.push(onreadyevent); } } } else { // the status could be -1 (but that is an error situation) // the resource does not exist or timed out.... something went wrong allresourcesloaded = false; // ???????? should we do this ???? } } } } // All resources are being loaded or are loaded into the list // BUT 1 thing to check if all resources were loaded, then we need to trigger the onready event !!! if (allresourcesloaded && onreadyevent !== null) { runFunction(onreadyevent.func, onreadyevent.arg); } }; $.rloader.track = { defaultcache: true, defaultasync: true }; })(jQuery); //Execute callback functions function ExecuteFunction(f, arg) { if ($.isFunction(f) || typeof f === 'string') { if ($.isFunction(f)) { f(arg); return true; } else { var fn = window[f]; if (typeof fn === 'function') { fn(arg); return true; } else { if (typeof eval(f) === "function") { eval(f).call(this, arg); return true; } } } return false; } return true; } /***************************************** Loading Panel Start *******************************************************/ function StartLoadingPanel() { //if (IsLoadingPannelActive == false) { $("#loadingPanel").removeClass("none"); // IsLoadingPannelActive = true; // } } function StopLoadingPanel() { // if( IsLoadingPannelActive == true) $("#loadingPanel").removeClass("none").addClass("none"); } /****************************************** Loading Panel End ***********************************************************/ var DialogObjTimeOutId = null; function confirmationDialog(messageObject) { if (messageObject.type == "confirmation") { $("#confirmboxText").text(messageObject.message); if (messageObject.OK != "undefined" && messageObject.OK != null && messageObject.OK != "") { $("#confirmboxYes").text(messageObject.OK); } else { $("#confirmboxYes").val("Ok"); } $(document).off("click", "#confirmboxYes"); if (jQuery.isFunction(messageObject.callbackOk)) { $(document).on("click", "#confirmboxYes", messageObject.callbackOk); } else { $(document).on("click", "#confirmboxYes", function (event) { $("#confirmbox").modal("hide"); }); } $(document).off("click", "#confirmboxCancle"); if (jQuery.isFunction(messageObject.callbackCancle)) { $(document).on("click", "#confirmboxCancle", messageObject.callbackCancle); } else { $(document).on("click", "#confirmboxCancle", function (event) { $("#confirmbox").modal("hide"); }); } $("#confirmbox").modal("show"); } } function showDialogMessage(messageObject) { try{ // alert(messageObject.message); var delay = 1000; //1 seconds var val = $("#dialogBox1").is(":visible"); if (val == true) { window.clearTimeout(DialogObjTimeOutId); } setTimeout(function () { try { //your code to be executed after 1 seconds if (messageObject.message.trim().length != 0) { $("#dialogBox1").show(); if (messageObject.type == "information") { $("#notificationClass").removeClass("modal-error-content modal-warning-content modal-info-content"); $("#notificationClass").addClass("modal-info-content"); $("#dialogBox1").find(".bodyMessageConfirmation").text(messageObject.message); clearTimeout(DialogObjTimeOutId); DialogObjTimeOutId = setTimeout(function () { try { $("#dialogBox1").hide(1000); } catch (err) { console.log("Easing error" + err.message); } }, messageObject.timeOut); } if (messageObject.type == "warning") { $("#notificationClass").removeClass("modal-error-content modal-warning-content modal-info-content"); $("#notificationClass").addClass("modal-warning-content"); $("#dialogBox1").find(".bodyMessageConfirmation").text(messageObject.message); clearTimeout(DialogObjTimeOutId); DialogObjTimeOutId = setTimeout(function () { try { $("#dialogBox1").hide(1000); } catch (err) { console.log("Easing error" + err.message); } }, messageObject.timeOut); } if (messageObject.type === "error") { $("#notificationClass").removeClass("modal-error-content modal-warning-content modal-info-content"); $("#notificationClass").addClass("modal-error-content"); $("#dialogBox1").find(".buttonContainer").children().hide(); $("#dialogBox1").find(".bodyMessageConfirmation").css("width", "100%"); $("#dialogBox1").find(".bodyMessageConfirmation").text(messageObject.message); clearTimeout(DialogObjTimeOutId); DialogObjTimeOutId = setTimeout(function () { try { $("#dialogBox1").hide(1000); } catch (err) { console.log("Easing error" + err.message); } }, messageObject.timeOut); } } } catch (err) { console.log("Easing Error:" + err.message); } }, delay); } catch (msg) { } } function CloseDialogBox(element) { $("#dialogBox1").hide(1000); } /*************************************************************************************************************************/