Deduplicate code for iframe title

This commit is contained in:
yflory 2023-09-19 16:39:32 +02:00
parent 48446d2482
commit b78ec996ec
22 changed files with 24 additions and 43 deletions

View File

@ -45,7 +45,6 @@ define([
Flatpickr
)
{
document.title = Messages.adminPage;
var APP = {
'instanceStatus': {}
};

View File

@ -1,7 +1,6 @@
<!DOCTYPE html>
<html class="cp-app-noscroll">
<head>
<title></title>
<meta content="text/html; charset=utf-8" http-equiv="content-type"/>
<script src="/customize/pre-loading.js?ver=1.1"></script>
<link href="/customize/src/pre-loading.css?ver=1.0" rel="stylesheet" type="text/css">

View File

@ -54,7 +54,6 @@ define([
Share, Access, Properties
)
{
document.title = Messages.calendar;
var SaveAs = window.saveAs;
var APP = window.APP = {
calendars: {}

View File

@ -62,9 +62,6 @@ define([
Messages,
CMeditor)
{
Messages.application = "Application"; // XXX
Messages.cryptpad_title = "CryptPad"; // XXX
document.title = Messages.type.code + " " + Messages.application + " - " + Messages.cryptpad_title;
window.CodeMirror = CMeditor;
var MEDIA_TAG_MODES = Object.freeze([

View File

@ -2695,7 +2695,7 @@ define([
gridIcon,
listIcon
]));
$button.attr('aria-label', 'View Mode Button');
$button.attr('aria-label', 'View Mode Button'); // XXX missing key?
var $gridIcon = $(gridIcon);
var $listIcon = $(listIcon);
var showMode = function (mode) {

View File

@ -662,23 +662,17 @@ define([
var loadInitDocument = function (type, useNewDefault) {
var newText;
Messages.application = "Application"; // XXX
Messages.cryptpad_title = "CryptPad"; // XXX
switch (type) {
case 'sheet' :
document.title = Messages.type.sheet + " " + Messages.application + " - " + Messages.cryptpad_title;
newText = EmptyCell(useNewDefault);
break;
case 'doc':
document.title = Messages.type.doc + " " + Messages.application + " - " + Messages.cryptpad_title;
newText = EmptyDoc();
break;
case 'presentation':
document.title = Messages.type.presentation + " " + Messages.application + " - " + Messages.cryptpad_title;
newText = EmptySlide();
break;
default:
document.title = Messages.application + " - " + Messages.cryptpad_title;
newText = '';
}
return new Blob([newText], {type: 'text/plain'});

View File

@ -73,7 +73,6 @@ define([
ApiConfig.httpSafeOrigin + (pathname || window.location.pathname) + 'inner.html?' +
requireConfig.urlArgs + '#' + encodeURIComponent(JSON.stringify(req)));
$i.attr('allowfullscreen', 'true');
// $i.attr('title', 'iframe'); // XXX to be fixed
$('iframe-placeholder').after($i).remove();
// This is a cheap trick to avoid loading sframe-channel in parallel with the
@ -1230,6 +1229,8 @@ define([
};
addCommonRpc(sframeChan, isSafe);
var SecureModal = {};
var currentTitle;
var currentTabTitle;
var titleSuffix = (Utils.Util.find(Utils, ['Instance','name','default']) || '').trim();
@ -1237,12 +1238,16 @@ define([
titleSuffix = window.location.hostname;
}
var setDocumentTitle = function () {
var newTitle;
if (!currentTabTitle) {
document.title = currentTitle || 'CryptPad';
return;
newTitle = currentTitle || 'CryptPad';
} else {
var title = currentTabTitle.replace(/\{title\}/g, currentTitle || 'CryptPad');
newTitle = title + ' - ' + titleSuffix;
}
var title = currentTabTitle.replace(/\{title\}/g, currentTitle || 'CryptPad');
document.title = title + ' - ' + titleSuffix;
document.title = newTitle;
sframeChan.event('EV_IFRAME_TITLE', newTitle);
if (SecureModal.modal) { SecureModal.modal.setTitle(newTitle); }
};
var setPadTitle = function (data, cb) {
@ -1513,7 +1518,6 @@ define([
});
// Secure modal
var SecureModal = {};
// Create or display the iframe and modal
var getPropChannels = function () {
var channels = {};
@ -1558,8 +1562,12 @@ define([
if (!cfg.hidden) {
SecureModal.modal.refresh(cfg, function () {
SecureModal.$iframe.show();
setDocumentTitle();
});
} else {
SecureModal.modal.refresh(cfg, function () {
setDocumentTitle();
});
SecureModal.$iframe.hide();
return;
}

View File

@ -995,6 +995,10 @@ define([
UI.alert(Messages.chrome68);
});
ctx.sframeChan.on('EV_IFRAME_TITLE', function (title) {
document.title = title;
});
funcs.isPadStored(function (err, val) {
if (err || !val) { return; }
UIElements.displayCrowdfunding(funcs);

View File

@ -1,7 +1,6 @@
<!DOCTYPE html>
<html class="cp-app-noscroll">
<head>
<title></title>
<meta content="text/html; charset=utf-8" http-equiv="content-type"/>
<script src="/customize/pre-loading.js?ver=1.1"></script>
<link href="/customize/src/pre-loading.css?ver=1.0" rel="stylesheet" type="text/css">

View File

@ -24,7 +24,6 @@ define([
UI
)
{
document.title = Messages.contacts_title;
var APP = {};
var common;

View File

@ -12,9 +12,6 @@ define([
Messages,
pako,
X2JS) {
Messages.application = "Application"; // XXX
Messages.cryptpad_title = "CryptPad"; // XXX
document.title = Messages.type.diagram + " " + Messages.application + " - " + Messages.cryptpad_title;
const Nacl = window.nacl;
// As described here: https://drawio-app.com/extracting-the-xml-from-mxfiles/

View File

@ -31,7 +31,6 @@ define([
AppConfig,
Messages)
{
document.title = Messages.settings_cat_drive;
var APP = {};
var SHARED_FOLDER_NAME = Messages.fm_sharedFolderName;

View File

@ -75,9 +75,6 @@ define([
Sortable
)
{
Messages.application = "Application"; // XXX
Messages.cryptpad_title = "CryptPad"; // XXX
document.title = Messages.type.form + " " + Messages.application + " - " + Messages.cryptpad_title;
var APP = window.APP = {
blocks: {}
};

View File

@ -52,9 +52,6 @@ define([
jKanban,
Export)
{
Messages.application = "Application"; // XXX
Messages.cryptpad_title = "CryptPad"; // XXX
document.title = Messages.type.kanban + " " + Messages.application + " - " + Messages.cryptpad_title;
var verbose = function (x) { console.log(x); };
verbose = function () {}; // comment out to enable verbose logging
var onRedraw = Util.mkEvent();

View File

@ -75,9 +75,6 @@ define([
AppConfig,
Test */
) {
Messages.application = "Application"; // XXX
Messages.cryptpad_title = "CryptPad"; // XXX
document.title = Messages.type.pad + " " + Messages.application + " - " + Messages.cryptpad_title;
var DiffDom = window.diffDOM;
var slice = function(coll) {

View File

@ -1,7 +1,6 @@
<!DOCTYPE html>
<html class="cp-app-noscroll">
<head>
<title></title>
<meta content="text/html; charset=utf-8" http-equiv="content-type"/>
<script src="/customize/pre-loading.js?ver=1.1"></script>
<link href="/customize/src/pre-loading.css?ver=1.0" rel="stylesheet" type="text/css">

View File

@ -49,7 +49,6 @@ define([
CodeMirror
)
{
document.title = Messages.profileButton;
var APP = window.APP = {
_onRefresh: []
};

View File

@ -187,8 +187,12 @@ define([
sframeChan.event('EV_REFRESH', data);
cb();
};
var setTitle = function (title) {
sframeChan.event('EV_IFRAME_TITLE', title);
};
return {
refresh: refresh
refresh: refresh,
setTitle: setTitle
};
};
return {

View File

@ -1,7 +1,6 @@
<!DOCTYPE html>
<html class="cp-app-noscroll">
<head>
<title></title>
<meta content="text/html; charset=utf-8" http-equiv="content-type"/>
<script src="/customize/pre-loading.js?ver=1.1"></script>
<link href="/customize/src/pre-loading.css?ver=1.0" rel="stylesheet" type="text/css">

View File

@ -41,7 +41,6 @@ define([
Constants,
Login
) {
document.title = Messages.settings_title;
var saveAs = window.saveAs;
var APP = window.APP = {};

View File

@ -59,9 +59,6 @@ define([
Messages,
CMeditor)
{
Messages.application = "Application"; // XXX
Messages.cryptpad_title = "CryptPad"; // XXX
document.title = Messages.type.slide + " " + Messages.application + " - " + Messages.cryptpad_title;
window.CodeMirror = CMeditor;
var SLIDE_BACKCOLOR_ID = "cp-app-slide-toolbar-backcolor";

View File

@ -48,7 +48,6 @@ define([
Backup,
Messages)
{
document.title = Messages.type.teams;
var APP = {
teams: {}
};