WRMCB=function(e){var c=console;if(c&&c.log&&c.error){c.log('Error running batched script.');c.error(e);}} ; try { /* module-key = 'com.atlassian.confluence.plugins.confluence-request-access-plugin:confluence-request-access-plugin-resources', location = '/js/request-access-page.js' */ define('confluence-request-access-plugin/request-access', [ 'jquery', 'confluence/legacy', 'confluence/meta', 'ajs', 'skate' ], function ($, Confluence, Meta, AJS, skate) { var getPageId = function() { var pageId = Meta.get("page-id"); var isDirectEditorLink = $("#invite-to-edit-draft").length; if (isDirectEditorLink) { pageId = $("#invite-to-edit-draft").data("draft-id"); } return pageId; }; function init(options) { //Meta.get("page-id") is undefined inside SPA. Therefore FE have to pass in pageId when calling init options = options || {}; var pageId = getPageId() || options.pageId; // Confluence ContextPath var CONTEXT_PATH = Confluence.getContextPath(); // attached to page var attached = function (el) { var $restrictedPage = $(".request-access-container"); var $requestAccessButton = $restrictedPage.find("button"); var accessType = $restrictedPage.data("access-type"); if ($restrictedPage.length) { // Hiding breadcrumbs + title of the 'No Permissions' page $("#breadcrumbs").hide(); $("#title-text.with-breadcrumbs").hide(); if ($requestAccessButton.length) { // Trigger an event for views which have the request access button, so that we can find out // how many users see this page but don't use the feature AJS.trigger('analyticsEvent', { name: 'confluence.request.access.plugin.request.access.to.page.view', data: { accessType: accessType } }); } } $requestAccessButton.prop('disabled', false); $requestAccessButton.removeAttr('aria-disabled'); $requestAccessButton.click(function () { AJS.trigger('analyticsEvent', { name: 'confluence.request.access.plugin.request.access.to.page', data: { accessType: accessType } }); $requestAccessButton.attr("aria-disabled", "true"); var $loading = $(Confluence.Request.Access.loading({})); $requestAccessButton.replaceWith($loading); $.ajax({ url: CONTEXT_PATH + "/rest/request-access/latest/page/restriction/" + pageId + "/request/" + accessType, type: "POST", contentType: "application/json; charset=utf-8", success: function (data) { AJS.flag({ type: 'success', title: "Request sent", body: AJS.format("We\'\'ve asked {0} to give you access. You\'\'ll get an email once the request is approved", Confluence.Request.Access.userProfileLink({ accountId: data.accountId, displayName: data.displayName, name: data.name, fullName: data.fullName }) ) }); }, error: function (request, textStatus) { AJS.flag({ type: 'error', title: "Access request unsuccessful", body: "Your request for access has not been sent. Contact your space admin." }); }, complete: function () { $loading.remove(); Confluence.Binder.userHover(); } }); }); }; // SPA may call initialization function multiple times if (!window.__skate || !window.__skate.registry || !window.__skate.registry['request-access-container'] ) { skate('request-access-container', { type: skate.types.CLASS, attached: attached }); } } return { init: init }; }); require('confluence/module-exporter').safeRequire('confluence-request-access-plugin/request-access', function(requestAccess){ require('ajs').toInit(requestAccess.init) }); }catch(e){WRMCB(e)}; ; try { /* module-key = 'com.atlassian.confluence.plugins.confluence-request-access-plugin:confluence-request-access-plugin-resources', location = '/js/grant-access.js' */ define('confluence-request-access-plugin/grant-access', [ 'jquery', 'confluence/legacy', 'confluence/meta', 'ajs', 'confluence/dark-features' ], function ($, Confluence, Meta, AJS, DarkFeatures) { function getParameterByName(name) { name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]"); var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"); var results = regex.exec(location.search); return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " ")); } /** * @returns {boolean} true if the user is creating/editing a page, or a blogpost, as opposed to a comment, or something. * @private */ function _isEditPage() { return AJS.Rte && AJS.Rte.getEditor && AJS.Rte.getEditor() && (!!AJS.$('#editpageform').length || !!AJS.$('#createpageform').length); } function init(options) { var CONTEXT_PATH = Confluence.getContextPath(); //Meta.get("page-id") is undefined inside SPA. Therefore FE have to pass in pageId when calling init options = options || {}; var pageId = Meta.get("page-id") || options.pageId; var contentType = Meta.get('content-type'); var requestAccountId = getParameterByName("accountId"); var requestDisplayName = getParameterByName("displayName").split('+').join(' '); var requestUsername = getParameterByName("username"); var requestFullName = getParameterByName("userFullName").split('+').join(' '); var requestAccessType = getParameterByName("accessType"); // padlock DOM element will be the trigger var $trigger = $("#content-metadata-page-restrictions"); // Figure out if the padlock is shown var isPageRestricted = $("#content-metadata-page-restrictions.restricted").length !== 0; var $restrictedPadlock = $("#rte-button-restrictions"); var isGrantAccessOnEditPage = _isEditPage() && !!$restrictedPadlock.length && !!getParameterByName("grantAccess") && !!requestAccessType; // If padlock is not present, or URL does not have certain params we can't show grant access dialog var viewPageRestrictionDialogCanBeShown = $trigger.length && isPageRestricted && !!getParameterByName("grantAccess") && !!requestAccessType; if (!viewPageRestrictionDialogCanBeShown && !isGrantAccessOnEditPage) { return; } if (isGrantAccessOnEditPage) { // It's a restricted edit page and someone is requesting access. // Some elements are different on edit pages (as opposed to view pages) $trigger = $restrictedPadlock; pageId = Meta.get("content-id"); } var $loading = $(Confluence.Request.Access.loading()); var grantAccessDialog = AJS.InlineDialog($trigger, "grantAccessDialog", function (content, trigger, showPopup) { content.css({ "padding": "20px" }).html(Confluence.Grant.Access.dialog({ accountId: requestAccountId, displayName: requestDisplayName, username: requestUsername, fullName: requestFullName, contentType: contentType })); content.on("click", '.aui-button.grant-access', function (e) { e.stopPropagation(); var $grantAccessButtons = content.find(".actions-result"); $grantAccessButtons.replaceWith($loading); // Logged in user grants access to the user requesting access AJS.trigger('analyticsEvent', { name: 'confluence.request.access.plugin.grant.access.to.page', data: { accessType: requestAccessType } }); var grantAccessResultMessage = ""; $.ajax({ url: CONTEXT_PATH + "/rest/request-access/latest/page/restriction/" + pageId + "/grant/" + requestAccessType, type: "POST", contentType: "application/json; charset=utf-8", data: requestAccountId ? requestAccountId : requestUsername, success: function (data, textStatus, jqXHR) { if (jqXHR.status == 202) { grantAccessResultMessage = "Access was already granted to the user."; } else { grantAccessResultMessage = "Access was granted, a notification to the user will be sent."; } AJS.flag({ type: 'success', title: "Access request granted", body: grantAccessResultMessage }); }, error: function (xhr) { if (xhr.status == 412) { grantAccessResultMessage = "Access was granted, but there is not a mail server configured so the notification could not be sent."; } else if (xhr.status == 502) { grantAccessResultMessage = "Access was granted, but an unexpected error happened while sending the notification."; } else { grantAccessResultMessage = "Sorry, there was an unexpected error while granting access."; } AJS.flag({ type: 'error', title: "Access request error", body: grantAccessResultMessage }); }, complete: function (xhr) { grantAccessDialog.hide(); } }); }); content.on("click", '.aui-button.deny-access', function (e) { // Logged in user explicitly denies access to the user requesting access AJS.trigger('analyticsEvent', { name: 'confluence.request.access.plugin.deny.access.to.page', data: { accessType: requestAccessType } }); grantAccessDialog.hide(); }); showPopup(); return false; }, { offsetY: 10, offsetX: -20, width: 350, hideDelay: null, noBind: true, hideCallback: function () { setTimeout(grantAccessDialog.hide(), 5000); } } ); grantAccessDialog.show(); } return { init: init, initWhenEditorReady: function() { AJS.bind('rte-collab-ready', init); } }; }); }catch(e){WRMCB(e)}; ; try { /* module-key = 'com.atlassian.confluence.plugins.confluence-request-access-plugin:confluence-request-access-plugin-resources', location = '/templates/soy/request-access.soy' */ // This file was automatically generated from request-access.soy. // Please don't edit this file by hand. /** * @fileoverview Templates in namespace Confluence.Request.Access. */ if (typeof Confluence == 'undefined') { var Confluence = {}; } if (typeof Confluence.Request == 'undefined') { Confluence.Request = {}; } if (typeof Confluence.Request.Access == 'undefined') { Confluence.Request.Access = {}; } Confluence.Request.Access.userProfileLink = function(opt_data, opt_ignored) { return '' + ((opt_data.accountId) ? '' + soy.$$escapeHtml(opt_data.displayName) + '' : '' + soy.$$escapeHtml(opt_data.fullName) + ''); }; if (goog.DEBUG) { Confluence.Request.Access.userProfileLink.soyTemplateName = 'Confluence.Request.Access.userProfileLink'; } Confluence.Request.Access.loading = function(opt_data, opt_ignored) { return '' + soy.$$escapeHtml('Loading, please wait') + '"'; }; if (goog.DEBUG) { Confluence.Request.Access.loading.soyTemplateName = 'Confluence.Request.Access.loading'; } Confluence.Request.Access.dialog = function(opt_data, opt_ignored) { return '

' + soy.$$escapeHtml('You don\x27t have permission to edit') + '

' + ((opt_data.canRequestAccess) ? '

' + soy.$$escapeHtml('Hit request access and we\x27ll find someone who can give you access.') + '

' : '

' + soy.$$escapeHtml('A space admin or the person who shared this page may be able to give you access.') + '

') + '
'; }; if (goog.DEBUG) { Confluence.Request.Access.dialog.soyTemplateName = 'Confluence.Request.Access.dialog'; } }catch(e){WRMCB(e)}; ; try { /* module-key = 'com.atlassian.confluence.plugins.confluence-request-access-plugin:confluence-request-access-plugin-resources', location = '/templates/soy/grant-access.soy' */ // This file was automatically generated from grant-access.soy. // Please don't edit this file by hand. /** * @fileoverview Templates in namespace Confluence.Grant.Access. */ if (typeof Confluence == 'undefined') { var Confluence = {}; } if (typeof Confluence.Grant == 'undefined') { Confluence.Grant = {}; } if (typeof Confluence.Grant.Access == 'undefined') { Confluence.Grant.Access = {}; } Confluence.Grant.Access.dialog = function(opt_data, opt_ignored) { var output = '
'; var usernameLink__soy4 = '' + Confluence.Grant.Access.profileLink(opt_data); var requestAccessDescription__soy10 = '' + ((opt_data.requestAccessType == 'edit') ? (opt_data.contentType == 'blogpost') ? soy.$$filterNoAutoescape(AJS.format('{0} wants to \x3cstrong\x3eedit\x3c/strong\x3e this blog post.',usernameLink__soy4)) : soy.$$filterNoAutoescape(AJS.format('{0} wants to \x3cstrong\x3eedit\x3c/strong\x3e this page.',usernameLink__soy4)) : (opt_data.contentType == 'blogpost') ? soy.$$filterNoAutoescape(AJS.format('{0} wants to \x3cstrong\x3eview\x3c/strong\x3e this blog post.',usernameLink__soy4)) : soy.$$filterNoAutoescape(AJS.format('{0} wants to \x3cstrong\x3eview\x3c/strong\x3e this page.',usernameLink__soy4))); output += '

' + soy.$$escapeHtml('Access request') + '

' + soy.$$filterNoAutoescape(requestAccessDescription__soy10) + '

'; return output; }; if (goog.DEBUG) { Confluence.Grant.Access.dialog.soyTemplateName = 'Confluence.Grant.Access.dialog'; } Confluence.Grant.Access.profileLink = function(opt_data, opt_ignored) { return '' + ((opt_data.accountId) ? '' + soy.$$escapeHtml(opt_data.displayName) + '' : '' + soy.$$escapeHtml(opt_data.fullName) + ' (' + soy.$$escapeHtml(opt_data.username) + ')'); }; if (goog.DEBUG) { Confluence.Grant.Access.profileLink.soyTemplateName = 'Confluence.Grant.Access.profileLink'; } }catch(e){WRMCB(e)};