maintain aspect ratio for slides

display index and slide count in title
This commit is contained in:
ansuz
2016-09-01 12:03:09 +02:00
parent f403d8e2e2
commit 8a659cf887
4 changed files with 182 additions and 14 deletions

View File

@@ -102,7 +102,7 @@ define([
console.log("Couldn't get pad title");
return;
}
document.title = title || window.location.hash.slice(1, 9);
document.title = APP.title = title || window.location.hash.slice(1, 9);
Cryptpad.rememberPad(title, function (err, data) {
if (err) {
console.log("Couldn't remember pad");
@@ -140,7 +140,7 @@ define([
console.log(err);
return;
}
document.title = window.location.hash.slice(1,9);
document.title = APP.title = window.location.hash.slice(1,9);
});
});
});
@@ -167,7 +167,7 @@ define([
console.error(err);
return;
}
document.title = title;
document.title = APP.title = title;
});
});
});
@@ -267,6 +267,15 @@ define([
});
}
Slide.onChange(function (o, n, l) {
if (n !== null) {
document.title = APP.title + ' (' + (++n) + '/' + l + ')';
return;
}
console.log("Exiting presentation mode");
document.title = APP.title;
});
setEditable(true);
initializing = false;
};

View File

@@ -12,6 +12,7 @@ define([
index: 0,
lastIndex: 0,
content: [],
changeHandlers: [],
};
var $modal;
var $content;
@@ -20,6 +21,25 @@ define([
$content = Slide.$content = $c;
};
Slide.onChange = function (f) {
if (typeof(f) === 'function') {
Slide.changeHandlers.push(f);
}
};
var change = function (oldIndex, newIndex) {
if (oldIndex === newIndex) {
return false;
}
if (Slide.changeHandlers.length) {
Slide.changeHandlers.some(function (f, i) {
// HERE
f(oldIndex, newIndex, Slide.content.length);
});
return true;
}
};
var forbiddenTags = Slide.forbiddenTags = [
'SCRIPT',
'IFRAME',
@@ -87,10 +107,10 @@ define([
if (typeof(patch) === 'string') {
$content.html(Marked(c));
return;
} else {
DD.apply($content[0], patch);
}
change(Slide.lastIndex, Slide.index);
};
var show = Slide.show = function (bool, content) {
@@ -99,8 +119,10 @@ define([
Slide.update(content);
Slide.draw(Slide.index);
$modal.addClass('shown');
change(null, Slide.index);
return;
}
change(Slide.index, null);
$modal.removeClass('shown');
};
@@ -115,12 +137,16 @@ define([
var left = Slide.left = function () {
console.log('left');
Slide.lastIndex = Slide.index;
var i = Slide.index = Math.max(0, Slide.index - 1);
Slide.draw(i);
};
var right = Slide.right = function () {
console.log('right');
Slide.lastIndex = Slide.index;
var i = Slide.index = Math.min(Slide.content.length -1, Slide.index + 1);
Slide.draw(i);
};