Add slide number in the title in slide2

pull/1/head
yflory 7 years ago
parent c3a07e879c
commit 514bff7065

@ -107,12 +107,28 @@ define([
});
});
var currentTitle;
var currentTabTitle;
var setDocumentTitle = function () {
if (!currentTabTitle) {
document.title = currentTitle || 'CryptPad';
return;
}
var title = currentTabTitle.replace(/\{title\}/g, currentTitle || 'CryptPad');
document.title = title;
};
sframeChan.on('Q_SET_PAD_TITLE_IN_DRIVE', function (newTitle, cb) {
document.title = newTitle;
currentTitle = newTitle;
setDocumentTitle();
Cryptpad.renamePad(newTitle, undefined, function (err) {
if (err) { cb('ERROR'); } else { cb(); }
});
});
sframeChan.on('EV_SET_TAB_TITLE', function (newTabTitle) {
currentTabTitle = newTabTitle;
setDocumentTitle();
});
sframeChan.on('Q_SETTINGS_SET_DISPLAY_NAME', function (newName, cb) {
Cryptpad.setDisplayName(newName, function (err) {

@ -32,7 +32,6 @@ define(['jquery'], function ($) {
}
};
// update title: href is optional; if not specified, we use window.location.href
exp.updateTitle = function (newTitle, cb) {
cb = cb || $.noop;
if (newTitle === exp.title) { return; }

@ -83,6 +83,9 @@ define([
funcs.notify = function () {
ctx.sframeChan.event('EV_NOTIFY');
};
funcs.setTabTitle = function (newTitle) {
ctx.sframeChan.event('EV_SET_TAB_TITLE', newTitle);
};
funcs.setLoginRedirect = function (cb) {
cb = cb || $.noop;

@ -43,7 +43,13 @@ define({
// This changes the pad title in drive ONLY, the pad title needs to be changed inside of the
// iframe and synchronized with the other users. This will not trigger a EV_METADATA_UPDATE
// because the metadata contained in EV_METADATA_UPDATE does not contain the pad title.
// It also sets the page (tab) title to the selected title, unles it is overridden by
// the EV_SET_TAB_TITLE event.
'Q_SET_PAD_TITLE_IN_DRIVE': true,
// Set the page title (tab title) to the selected value which will override the pad title.
// The new title value can contain {title}, which will be replaced by the pad title when it
// is set or modified.
'EV_SET_TAB_TITLE': true,
// Update the user's display-name which will be shown to contacts and people in the same pads.
'Q_SETTINGS_SET_DISPLAY_NAME': true,

@ -124,16 +124,6 @@ define([
}
};
var setTabTitle = function (title) {
console.error('TODO'); // TODO iframe
return;
var slideNumber = '';
if (Slide.shown) { //Slide.index && Slide.content.length) {
slideNumber = ' (' + Slide.index + '/' + Slide.content.length + ')';
}
document.title = title + slideNumber;
};
var $contentContainer = $('#cp-app-slide-editor');
var $modal = $('#cp-app-slide-modal');
var $content = $('#cp-app-slide-modal-content');
@ -593,15 +583,13 @@ define([
});
Slide.onChange(function (o, n, l) {
console.log('TODO: remove that part?');
var slideNumber = '';
if (n !== null) {
if (Slide.shown) {
slideNumber = ' (' + (++n) + '/' + l + ')';
}
}
// TODO iframe
document.title = Title.title + slideNumber;
common.setTabTitle('{title}' + slideNumber);
});
setEditable(!readOnly);

@ -128,6 +128,7 @@ define([
updateFontSize();
return;
}
Common.setTabTitle(); // Remove the slide number from the title
Common.setPresentUrl(false);
change(Slide.index, null);
$('.cp-app-slide-present-button').show();

Loading…
Cancel
Save