/// /// /// /// /// Umbraco.Sys.registerNamespace("Umbraco.Application"); Umbraco.Application.Actions = function () { /// /// Application actions actions for the context menu, help dialogs, logout, etc... /// This class supports an event listener model. Currently the available events are: /// "nodeDeleting","nodeDeleted","nodeRefresh","beforeLogout" /// return { _utils: Umbraco.Utils, //alias to Umbraco Utils _dialogWindow: null, /// A reference to a dialog window to open, any action that doesn't open in an overlay, opens in a dialog _isDebug: false, //set to true to enable alert debugging _windowTitle: " - Umbraco CMS - ", _currApp: "", addEventHandler: function (fnName, fn) { /// Adds an event listener to the event name event if (typeof (jQuery) != "undefined") jQuery(window.top).bind(fnName, fn); //if there's no jQuery, there is no events }, removeEventHandler: function (fnName, fn) { /// Removes an event listener to the event name event if (typeof (jQuery) != "undefined") jQuery(window.top).unbind(fnName, fn); //if there's no jQuery, there is no events }, showSpeachBubble: function (ico, hdr, msg) { if (typeof (UmbClientMgr.mainWindow().UmbSpeechBubble) != "undefined") { UmbClientMgr.mainWindow().UmbSpeechBubble.ShowMessage(ico, hdr, msg); } else alert(msg); }, launchHelp: function (lang, userType) { /// Launches the contextual help window var rightUrl = UmbClientMgr.contentFrame().document.location.href.split("\/"); if (rightUrl.length > 0) { rightUrl = rightUrl[rightUrl.length - 1]; } if (rightUrl.indexOf("?") > 0) { rightUrl = rightUrl.substring(0, rightUrl.indexOf("?")); } var url = "/umbraco/helpRedirect.aspx?Application=" + this._currApp + '&ApplicationURL=' + rightUrl + '&Language=' + lang + "&UserType=" + userType; window.open(url); return false; }, launchAbout: function () { /// Launches the about Umbraco window UmbClientMgr.openModalWindow("dialogs/about.aspx", UmbClientMgr.uiKeys()['general_about'], true, 450, 390); return false; }, launchCreateWizard: function () { /// Launches the create content wizard if (this._currApp == 'media' || this._currApp == 'content' || this._currApp == '') { if (this._currApp == '') { this._currApp = 'content'; } UmbClientMgr.openModalWindow("dialogs/create.aspx?nodeType=" + this._currApp + "&app=" + this._currApp + "&rnd=" + this._utils.generateRandom(), UmbClientMgr.uiKeys()['actions_create'] + " " + this._currApp, true, 620, 470); return false; } else alert('Not supported - please create by right clicking the parentnode and choose new...'); }, logout: function () { /// Logs the user out if (confirm(UmbClientMgr.uiKeys()["defaultdialogs_confirmlogout"])) { //raise beforeLogout event jQuery(window.top).trigger("beforeLogout", []); document.location.href = 'logout.aspx'; } return false; }, shiftApp: function (whichApp, appName) { /// Changes the application this._debug("shiftApp: " + whichApp + ", " + appName); UmbClientMgr.mainTree().saveTreeState(this._currApp == "" ? "content" : this._currApp); this._currApp = whichApp.toLowerCase(); if (this._currApp != 'media' && this._currApp != 'content' && this._currApp != 'member') { jQuery("#buttonCreate").attr("disabled", "true"); jQuery("#FindDocuments .umbracoSearchHolder").fadeOut(400); } else { // create button should still remain disabled for the memebers section if (this._currApp == 'member') { jQuery("#buttonCreate").attr("disabled", "true"); } else { jQuery("#buttonCreate").removeAttr("disabled"); } jQuery("#FindDocuments .umbracoSearchHolder").fadeIn(500); //need to set the recycle bin node id based on app switch (this._currApp) { case ("media"): UmbClientMgr.mainTree().setRecycleBinNodeId(-21); break; case ("content"): UmbClientMgr.mainTree().setRecycleBinNodeId(-20); break; } } UmbClientMgr.mainTree().rebuildTree(whichApp, function (args) { //the callback will fire when the tree rebuilding is done, we //need to check the args to see if the tree was rebuild from cache //and if it had a previously selected node, if it didn't then load the dashboard. if (!args) { UmbClientMgr.contentFrame('dashboard.aspx?app=' + whichApp); } }); jQuery("#treeWindowLabel").html(appName); UmbClientMgr.mainWindow().document.title = appName + this._windowTitle + window.location.hostname.toLowerCase().replace('www', ''); }, getCurrApp: function () { return this._currApp; }, //TODO: Move this into a window manager class openDialog: function (diaTitle, diaDoc, dwidth, dheight, optionalParams) { /// Opens the dialog window if (this._dialogWindow != null && !this._dialogWindow.closed) { this._dialogWindow.close(); } this._dialogWindow = UmbClientMgr.mainWindow().open(diaDoc, 'dialogpage', "width=" + dwidth + "px,height=" + dheight + "px" + optionalParams); }, openDashboard: function (whichApp) { UmbClientMgr.contentFrame('dashboard.aspx?app=' + whichApp); }, actionTreeEditMode: function () { /// UmbClientMgr.mainTree().toggleEditMode(true); }, actionSort: function () { /// if (UmbClientMgr.mainTree().getActionNode().nodeId != '0' && UmbClientMgr.mainTree().getActionNode().nodeType != '') { UmbClientMgr.openModalWindow("dialogs/sort.aspx?id=" + UmbClientMgr.mainTree().getActionNode().nodeId + '&rnd=' + this._utils.generateRandom(), uiKeys['actions_sort'], true, 600, 450); } }, actionRights: function () { /// if (UmbClientMgr.mainTree().getActionNode().nodeId != '-1' && UmbClientMgr.mainTree().getActionNode().nodeType != '') { UmbClientMgr.openModalWindow("dialogs/cruds.aspx?id=" + UmbClientMgr.mainTree().getActionNode().nodeId + '&rnd=' + this._utils.generateRandom(), uiKeys['actions_rights'], true, 800, 300); } }, actionProtect: function () { /// if (UmbClientMgr.mainTree().getActionNode().nodeId != '-1' && UmbClientMgr.mainTree().getActionNode().nodeType != '') { UmbClientMgr.openModalWindow("dialogs/protectPage.aspx?mode=cut&nodeId=" + UmbClientMgr.mainTree().getActionNode().nodeId + '&rnd=' + this._utils.generateRandom(), uiKeys['actions_protect'], true, 535, 480); } }, actionRollback: function () { /// UmbClientMgr.openModalWindow('dialogs/rollback.aspx?nodeId=' + UmbClientMgr.mainTree().getActionNode().nodeId + '&rnd=' + this._utils.generateRandom(), uiKeys['actions_rollback'], true, 600, 550); }, actionRefresh: function () { /// //raise nodeRefresh event jQuery(window.top).trigger("nodeRefresh", []); }, actionNotify: function () { /// if (UmbClientMgr.mainTree().getActionNode().nodeId != '-1' && UmbClientMgr.mainTree().getActionNode().nodeType != '') { UmbClientMgr.openModalWindow("dialogs/notifications.aspx?id=" + UmbClientMgr.mainTree().getActionNode().nodeId + '&rnd=' + this._utils.generateRandom(), uiKeys['actions_notify'], true, 300, 480); } }, actionUpdate: function () { /// }, actionPublish: function () { /// if (UmbClientMgr.mainTree().getActionNode().nodeId != '' != '-1' && UmbClientMgr.mainTree().getActionNode().nodeType != '') { UmbClientMgr.openModalWindow("dialogs/publish.aspx?id=" + UmbClientMgr.mainTree().getActionNode().nodeId, uiKeys['actions_publish'], true, 540, 280); } }, actionToPublish: function () { /// if (UmbClientMgr.mainTree().getActionNode().nodeId != '-1' && UmbClientMgr.mainTree().getActionNode().nodeType != '') { if (confirm(uiKeys['defaultdialogs_confirmSure'] + '\n\n')) { UmbClientMgr.openModalWindow('dialogs/SendPublish.aspx?id=' + UmbClientMgr.mainTree().getActionNode().nodeId + '&rnd=' + this._utils.generateRandom(), uiKeys['actions_sendtopublish'], true, 300, 200); } } }, actionQuit: function () { /// if (confirm(uiKeys['defaultdialogs_confirmlogout'] + '\n\n')) document.location.href = 'logout.aspx'; }, actionRePublish: function () { /// UmbClientMgr.openModalWindow('dialogs/republish.aspx?rnd=' + this._utils.generateRandom(), 'Republishing entire site', true, 450, 210); }, actionAssignDomain: function () { /// if (UmbClientMgr.mainTree().getActionNode().nodeId != '-1' && UmbClientMgr.mainTree().getActionNode().nodeType != '') { UmbClientMgr.openModalWindow("dialogs/assignDomain.aspx?id=" + UmbClientMgr.mainTree().getActionNode().nodeId, uiKeys['actions_assignDomain'], true, 500, 420); } }, actionLiveEdit: function () { /// window.open("canvas.aspx?redir=/" + UmbClientMgr.mainTree().getActionNode().nodeId + ".aspx", "liveediting"); }, actionNew: function () { /// Show the create new modal overlay var actionNode = UmbClientMgr.mainTree().getActionNode(); if (actionNode.nodeType != '') { if (actionNode.nodeType == "content") { UmbClientMgr.openModalWindow("create.aspx?nodeId=" + actionNode.nodeId + "&nodeType=" + actionNode.nodeType + "&nodeName=" + actionNode.nodeName + '&rnd=' + this._utils.generateRandom(), uiKeys['actions_create'], true, 600, 425); } else if (actionNode.nodeType == "initmember") { UmbClientMgr.openModalWindow("create.aspx?nodeId=" + actionNode.nodeId + "&nodeType=" + actionNode.nodeType + "&nodeName=" + actionNode.nodeName + '&rnd=' + this._utils.generateRandom(), uiKeys['actions_create'], true, 420, 380); } else if (actionNode.nodeType == "initpython" || actionNode.nodeType == "initdlrscripting") { UmbClientMgr.openModalWindow("create.aspx?nodeId=" + actionNode.nodeId + "&nodeType=" + actionNode.nodeType + "&nodeName=" + actionNode.nodeName + '&rnd=' + this._utils.generateRandom(), uiKeys['actions_create'], true, 420, 380); } else { UmbClientMgr.openModalWindow("create.aspx?nodeId=" + actionNode.nodeId + "&nodeType=" + actionNode.nodeType + "&nodeName=" + actionNode.nodeName + '&rnd=' + this._utils.generateRandom(), uiKeys['actions_create'], true, 420, 270); } } }, actionNewFolder: function () { /// if (UmbClientMgr.mainTree().getActionNode().nodeType != '') { this.openDialog("Opret", "createFolder.aspx?nodeId=" + UmbClientMgr.mainTree().getActionNode().nodeId + "&nodeType=" + UmbClientMgr.mainTree().getActionNode().nodeType + "&nodeName=" + nodeName + '&rnd=' + this._utils.generateRandom(), 320, 225); } }, actionSendToTranslate: function () { /// if (UmbClientMgr.mainTree().getActionNode().nodeId != '-1' && UmbClientMgr.mainTree().getActionNode().nodeType != '') { UmbClientMgr.openModalWindow("dialogs/sendToTranslation.aspx?id=" + UmbClientMgr.mainTree().getActionNode().nodeId + '&rnd=' + this._utils.generateRandom(), uiKeys['actions_sendToTranslate'], true, 500, 470); } }, actionEmptyTranscan: function () { /// if (UmbClientMgr.mainTree().getActionNode().nodeId != '-1' && UmbClientMgr.mainTree().getActionNode().nodeType != '') { UmbClientMgr.openModalWindow("dialogs/emptyTrashcan.aspx?type=" + this._currApp, uiKeys['actions_emptyTrashcan'], true, 500, 220); } }, actionImport: function () { /// if (UmbClientMgr.mainTree().getActionNode().nodeType != '') { UmbClientMgr.openModalWindow("dialogs/importDocumentType.aspx?rnd=" + this._utils.generateRandom(), uiKeys['actions_importDocumentType'], true, 460, 400); } }, actionExport: function () { /// if (UmbClientMgr.mainTree().getActionNode().nodeType != '') { this.openDialog("Export", "dialogs/exportDocumentType.aspx?nodeId=" + UmbClientMgr.mainTree().getActionNode().nodeId + "&rnd=" + this._utils.generateRandom(), 320, 205); } }, actionAudit: function () { /// UmbClientMgr.openModalWindow('dialogs/viewAuditTrail.aspx?nodeId=' + UmbClientMgr.mainTree().getActionNode().nodeId + '&rnd=' + this._utils.generateRandom(), uiKeys['actions_auditTrail'], true, 550, 500); }, actionPackage: function () { /// }, actionDelete: function () { /// var actionNode = UmbClientMgr.mainTree().getActionNode(); if (UmbClientMgr.mainTree().getActionNode().nodeType == "content" && UmbClientMgr.mainTree().getActionNode().nodeId == '-1') return; this._debug("actionDelete"); if (confirm(uiKeys['defaultdialogs_confirmdelete'] + ' "' + UmbClientMgr.mainTree().getActionNode().nodeName + '"?\n\n')) { //raise nodeDeleting event jQuery(window.top).trigger("nodeDeleting", []); var _this = this; //check if it's in the recycle bin if (actionNode.jsNode.closest("li[id='-20']").length == 1 || actionNode.jsNode.closest("li[id='-21']").length == 1) { umbraco.presentation.webservices.legacyAjaxCalls.DeleteContentPermanently( UmbClientMgr.mainTree().getActionNode().nodeId, UmbClientMgr.mainTree().getActionNode().nodeType, function () { _this._debug("actionDelete: Raising event"); //raise nodeDeleted event jQuery(window.top).trigger("nodeDeleted", []); }); } else { umbraco.presentation.webservices.legacyAjaxCalls.Delete( UmbClientMgr.mainTree().getActionNode().nodeId, "", UmbClientMgr.mainTree().getActionNode().nodeType, function () { _this._debug("actionDelete: Raising event"); //raise nodeDeleted event jQuery(window.top).trigger("nodeDeleted", []); }); } } }, actionDisable: function () { /// /// Used for users when disable is selected. /// if (confirm(uiKeys['defaultdialogs_confirmdisable'] + ' "' + UmbClientMgr.mainTree().getActionNode().nodeName + '"?\n\n')) { umbraco.presentation.webservices.legacyAjaxCalls.DisableUser(UmbClientMgr.mainTree().getActionNode().nodeId, function () { UmbClientMgr.mainTree().reloadActionNode(); }); } }, actionMove: function () { /// if (UmbClientMgr.mainTree().getActionNode().nodeId != '-1' && UmbClientMgr.mainTree().getActionNode().nodeType != '') { UmbClientMgr.openModalWindow("dialogs/moveOrCopy.aspx?app=" + this._currApp + "&mode=cut&id=" + UmbClientMgr.mainTree().getActionNode().nodeId + '&rnd=' + this._utils.generateRandom(), uiKeys['actions_move'], true, 500, 460); } }, actionCopy: function () { /// if (UmbClientMgr.mainTree().getActionNode().nodeId != '-1' && UmbClientMgr.mainTree().getActionNode().nodeType != '') { UmbClientMgr.openModalWindow("dialogs/moveOrCopy.aspx?app=" + this._currApp + "&mode=copy&id=" + UmbClientMgr.mainTree().getActionNode().nodeId + '&rnd=' + this._utils.generateRandom(), uiKeys['actions_copy'], true, 500, 470); } }, _debug: function (strMsg) { if (this._isDebug) { Sys.Debug.trace("AppActions: " + strMsg); } }, actionExportCode: function () { /// UmbClientMgr.openModalWindow("dialogs/exportCode.aspx", UmbClientMgr.uiKeys()['exportDocumentTypeAsCode'], true, 400, 350); return false; } } }