等待后端更新接口
This commit is contained in:
@@ -1,12 +1,43 @@
|
||||
(function (window, $) {
|
||||
'use strict';
|
||||
|
||||
if (!$) return;
|
||||
|
||||
var profileUI = window.ProfileUI || {};
|
||||
var layuiReady = false;
|
||||
var layerApi = null;
|
||||
var genealogyContextStorageKey = 'genealogy_current_context_v1';
|
||||
var mobileMenuId = 'profile-mobile-menu';
|
||||
var apiStateTypes = ['loading', 'empty', 'error', 'forbidden'];
|
||||
|
||||
function escapeHtml(value) {
|
||||
return String(value === undefined || value === null ? '' : value)
|
||||
.replace(/&/g, '&')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>')
|
||||
.replace(/"/g, '"')
|
||||
.replace(/'/g, ''');
|
||||
}
|
||||
|
||||
function renderApiState(type, message) {
|
||||
var role;
|
||||
var busy;
|
||||
|
||||
if (apiStateTypes.indexOf(type) < 0) throw new TypeError('不支持的业务状态:' + type);
|
||||
role = type === 'error' || type === 'forbidden' ? 'alert' : 'status';
|
||||
busy = type === 'loading' ? ' aria-busy="true"' : '';
|
||||
return '<div class="api-state api-state--' + type + '" data-api-state="' + type +
|
||||
'" role="' + role + '" aria-live="polite"' + busy + '>' + escapeHtml(message) + '</div>';
|
||||
}
|
||||
|
||||
function setApiState(element, type, message) {
|
||||
if (!element) return;
|
||||
element.innerHTML = renderApiState(type, message);
|
||||
}
|
||||
|
||||
profileUI.renderApiState = renderApiState;
|
||||
profileUI.setApiState = setApiState;
|
||||
window.ProfileUI = profileUI;
|
||||
|
||||
if (!$) return;
|
||||
|
||||
function getSessionStorage() {
|
||||
try {
|
||||
@@ -231,13 +262,25 @@
|
||||
|
||||
if (!value || value.charAt(0) === '#' || /^(?:https?:|mailto:|tel:)/i.test(value)) return value;
|
||||
if (value.indexOf('profile-families.html') === 0) return value;
|
||||
return 'profile-families.html?next=' + encodeURIComponent(value.split('?')[0]);
|
||||
return 'profile-families.html?next=' + encodeURIComponent(value);
|
||||
}
|
||||
|
||||
var genealogyContextPagePattern = /(?:^|\/)profile-(?:admin-permissions|album(?:-detail|-edit)?|article(?:-edit)?|ceremony(?:-detail)?|content|family-admin|family-home|feed(?:-detail|-edit)?|generation|gift(?:-edit)?|growth(?:-edit)?|join-review|memo(?:-edit)?|merit(?:-edit)?|relative(?:-edit)?|tree|video(?:-edit)?)\.html(?:[?#]|$)/;
|
||||
|
||||
function isGenealogyContextHref(href) {
|
||||
var value = String(href || '');
|
||||
|
||||
return !/^(?:https?:|mailto:|tel:)/i.test(value) && genealogyContextPagePattern.test(value);
|
||||
}
|
||||
|
||||
function syncGenealogyContextLinks() {
|
||||
var genealogyId = getGenealogyId();
|
||||
|
||||
$('[data-genealogy-context-link]').each(function () {
|
||||
$('[data-genealogy-context-link], a[href]').filter(function () {
|
||||
var $link = $(this);
|
||||
|
||||
return $link.is('[data-genealogy-context-link]') || isGenealogyContextHref($link.attr('href'));
|
||||
}).each(function () {
|
||||
var $link = $(this);
|
||||
|
||||
$link.attr('href', genealogyId ? withGenealogyId($link.attr('href'), genealogyId) : getGenealogyEntryUrl($link.attr('href')));
|
||||
@@ -463,7 +506,7 @@
|
||||
syncGenealogyContextLinks();
|
||||
});
|
||||
|
||||
window.ProfileUI = {
|
||||
Object.assign(profileUI, {
|
||||
confirm: openConfirm,
|
||||
closeLogout: closeLegacyLogout,
|
||||
initLayui: initLayui,
|
||||
@@ -471,10 +514,13 @@
|
||||
normalizeGenealogyId: normalizeGenealogyId,
|
||||
withGenealogyId: withGenealogyId,
|
||||
getGenealogyEntryUrl: getGenealogyEntryUrl,
|
||||
isGenealogyContextHref: isGenealogyContextHref,
|
||||
getCurrentGenealogyContext: getCurrentGenealogyContext,
|
||||
setCurrentGenealogyContext: setCurrentGenealogyContext,
|
||||
clearCurrentGenealogyContext: clearCurrentGenealogyContext,
|
||||
refreshCurrentGenealogyContext: refreshCurrentGenealogyContext,
|
||||
syncGenealogyContextLinks: syncGenealogyContextLinks
|
||||
};
|
||||
syncGenealogyContextLinks: syncGenealogyContextLinks,
|
||||
renderApiState: renderApiState,
|
||||
setApiState: setApiState
|
||||
});
|
||||
})(window, window.jQuery || (window.layui && window.layui.$));
|
||||
|
||||
Reference in New Issue
Block a user