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) { sframeChan.on('Q_SET_PAD_TITLE_IN_DRIVE', function (newTitle, cb) {
document.title = newTitle; currentTitle = newTitle;
setDocumentTitle();
Cryptpad.renamePad(newTitle, undefined, function (err) { Cryptpad.renamePad(newTitle, undefined, function (err) {
if (err) { cb('ERROR'); } else { cb(); } 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) { sframeChan.on('Q_SETTINGS_SET_DISPLAY_NAME', function (newName, cb) {
Cryptpad.setDisplayName(newName, function (err) { 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) { exp.updateTitle = function (newTitle, cb) {
cb = cb || $.noop; cb = cb || $.noop;
if (newTitle === exp.title) { return; } if (newTitle === exp.title) { return; }

@ -83,6 +83,9 @@ define([
funcs.notify = function () { funcs.notify = function () {
ctx.sframeChan.event('EV_NOTIFY'); ctx.sframeChan.event('EV_NOTIFY');
}; };
funcs.setTabTitle = function (newTitle) {
ctx.sframeChan.event('EV_SET_TAB_TITLE', newTitle);
};
funcs.setLoginRedirect = function (cb) { funcs.setLoginRedirect = function (cb) {
cb = cb || $.noop; 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 // 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 // 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. // 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, '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. // Update the user's display-name which will be shown to contacts and people in the same pads.
'Q_SETTINGS_SET_DISPLAY_NAME': true, '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 $contentContainer = $('#cp-app-slide-editor');
var $modal = $('#cp-app-slide-modal'); var $modal = $('#cp-app-slide-modal');
var $content = $('#cp-app-slide-modal-content'); var $content = $('#cp-app-slide-modal-content');
@ -593,15 +583,13 @@ define([
}); });
Slide.onChange(function (o, n, l) { Slide.onChange(function (o, n, l) {
console.log('TODO: remove that part?');
var slideNumber = ''; var slideNumber = '';
if (n !== null) { if (n !== null) {
if (Slide.shown) { if (Slide.shown) {
slideNumber = ' (' + (++n) + '/' + l + ')'; slideNumber = ' (' + (++n) + '/' + l + ')';
} }
} }
// TODO iframe common.setTabTitle('{title}' + slideNumber);
document.title = Title.title + slideNumber;
}); });
setEditable(!readOnly); setEditable(!readOnly);

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

Loading…
Cancel
Save