|
|
@ -19,6 +19,9 @@ define([
|
|
|
|
var $content;
|
|
|
|
var $content;
|
|
|
|
var $pad;
|
|
|
|
var $pad;
|
|
|
|
var placeholder;
|
|
|
|
var placeholder;
|
|
|
|
|
|
|
|
var separator = '<hr data-pewpew="pezpez">';
|
|
|
|
|
|
|
|
var separatorReg = /<hr data\-pewpew="pezpez">/g;
|
|
|
|
|
|
|
|
var slideClass = 'slide-frame';
|
|
|
|
|
|
|
|
|
|
|
|
Slide.onChange = function (f) {
|
|
|
|
Slide.onChange = function (f) {
|
|
|
|
if (typeof(f) === 'function') {
|
|
|
|
if (typeof(f) === 'function') {
|
|
|
@ -26,11 +29,15 @@ define([
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var getNumberOfSlides = function () {
|
|
|
|
|
|
|
|
return $content.find('.' + slideClass).length;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var change = function (oldIndex, newIndex) {
|
|
|
|
var change = function (oldIndex, newIndex) {
|
|
|
|
if (Slide.changeHandlers.length) {
|
|
|
|
if (Slide.changeHandlers.length) {
|
|
|
|
Slide.changeHandlers.some(function (f, i) {
|
|
|
|
Slide.changeHandlers.some(function (f, i) {
|
|
|
|
// HERE
|
|
|
|
// HERE
|
|
|
|
f(oldIndex, newIndex, Slide.content.length);
|
|
|
|
f(oldIndex, newIndex, getNumberOfSlides());
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
@ -76,7 +83,7 @@ define([
|
|
|
|
var Err;
|
|
|
|
var Err;
|
|
|
|
var Els = [A, B].map(function (frag) {
|
|
|
|
var Els = [A, B].map(function (frag) {
|
|
|
|
if (typeof(frag) === 'object') {
|
|
|
|
if (typeof(frag) === 'object') {
|
|
|
|
if (!frag && frag.body) {
|
|
|
|
if (!frag || (frag && !frag.body)) {
|
|
|
|
Err = "No body";
|
|
|
|
Err = "No body";
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -108,19 +115,23 @@ define([
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var draw = Slide.draw = function (i) {
|
|
|
|
var draw = Slide.draw = function (i) {
|
|
|
|
console.log("Trying to draw slide #%s", i);
|
|
|
|
i = i || 0;
|
|
|
|
if (typeof(Slide.content[i]) !== 'string') { return; }
|
|
|
|
if (typeof(Slide.content) !== 'string') { return; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var c = Slide.content;
|
|
|
|
|
|
|
|
var m = '<span class="'+slideClass+'">'+Marked(c).replace(separatorReg, '</span><span class="'+slideClass+'">')+'</span>';
|
|
|
|
|
|
|
|
|
|
|
|
var c = Slide.content[i];
|
|
|
|
var Dom = domFromHTML('<div id="content">' + m + '</div>');
|
|
|
|
var Dom = domFromHTML('<div id="content">' + Marked(c) + '</div>');
|
|
|
|
|
|
|
|
removeListeners(Dom.body);
|
|
|
|
removeListeners(Dom.body);
|
|
|
|
var patch = makeDiff(domFromHTML($content[0].outerHTML), Dom);
|
|
|
|
var patch = makeDiff(domFromHTML($content[0].outerHTML), Dom);
|
|
|
|
|
|
|
|
|
|
|
|
if (typeof(patch) === 'string') {
|
|
|
|
if (typeof(patch) === 'string') {
|
|
|
|
$content.html(Marked(c));
|
|
|
|
$content.html(m);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
DD.apply($content[0], patch);
|
|
|
|
DD.apply($content[0], patch);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$content.find('.' + slideClass).hide();
|
|
|
|
|
|
|
|
$content.find('.' + slideClass + ':eq( ' + i + ' )').show();
|
|
|
|
change(Slide.lastIndex, Slide.index);
|
|
|
|
change(Slide.lastIndex, Slide.index);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
@ -161,11 +172,11 @@ define([
|
|
|
|
|
|
|
|
|
|
|
|
var update = Slide.update = function (content) {
|
|
|
|
var update = Slide.update = function (content) {
|
|
|
|
if (!Slide.shown) { return; }
|
|
|
|
if (!Slide.shown) { return; }
|
|
|
|
if (!content) { content = placeholder; }
|
|
|
|
if (!content) { content = ''; }
|
|
|
|
var old = Slide.content[Slide.index];
|
|
|
|
var old = Slide.content;
|
|
|
|
Slide.content = content.split(/\n\s*\-\-\-\s*\n/).filter(truthy);
|
|
|
|
Slide.content = content.replace(/\n\s*\-\-\-\s*\n/g, '\n\n'+separator+'\n\n');
|
|
|
|
if (old !== Slide.content[Slide.index]) {
|
|
|
|
if (old !== Slide.content) {
|
|
|
|
draw(Slide.index);
|
|
|
|
draw();
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
change(Slide.lastIndex, Slide.index);
|
|
|
|
change(Slide.lastIndex, Slide.index);
|
|
|
@ -183,7 +194,7 @@ define([
|
|
|
|
console.log('right');
|
|
|
|
console.log('right');
|
|
|
|
Slide.lastIndex = Slide.index;
|
|
|
|
Slide.lastIndex = Slide.index;
|
|
|
|
|
|
|
|
|
|
|
|
var i = Slide.index = Math.min(Slide.content.length -1, Slide.index + 1);
|
|
|
|
var i = Slide.index = Math.min(getNumberOfSlides() -1, Slide.index + 1);
|
|
|
|
Slide.draw(i);
|
|
|
|
Slide.draw(i);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
@ -199,7 +210,7 @@ define([
|
|
|
|
console.log('end');
|
|
|
|
console.log('end');
|
|
|
|
Slide.lastIndex = Slide.index;
|
|
|
|
Slide.lastIndex = Slide.index;
|
|
|
|
|
|
|
|
|
|
|
|
var i = Slide.index = Slide.content.length - 1;
|
|
|
|
var i = Slide.index = getNumberOfSlides() - 1;
|
|
|
|
Slide.draw(i);
|
|
|
|
Slide.draw(i);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|