Add Shower 2.x plugin

This commit is contained in:
Antonin Stefanutti 2016-04-14 11:53:08 +02:00
parent 455d48fb44
commit 328e443818
2 changed files with 66 additions and 2 deletions

View File

@ -5,12 +5,12 @@ function Shower(page) {
Shower.prototype = {
getName: function () {
return 'Shower';
return 'Shower 1.x';
},
isActive: function () {
return this.page.evaluate(function () {
return typeof shower === 'object';
return typeof shower === 'object' && typeof shower.modules === 'undefined';
});
},

64
plugins/shower-2.x.js Normal file
View File

@ -0,0 +1,64 @@
function Shower(page) {
this.page = page;
}
Shower.prototype = {
getName: function () {
return 'Shower 2.x';
},
isActive: function () {
return this.page.evaluate(function () {
return typeof shower === 'object' && typeof shower.modules === 'object';
});
},
configure: function () {
var resolved;
var promise = new Promise(function (fulfill) {
resolved = fulfill;
});
this.page.onCallback = function () {
resolved();
};
this.page.evaluate(function () {
shower.modules.require(['shower.global'], function (sh) {
window.decktape = {};
decktape.shower = sh.getInited()[0];
decktape.shower.container.enterSlideMode();
window.callPhantom();
});
});
return promise;
},
slideCount: function () {
// FIXME: this does not take fragments into account which ideally should be deactivated
return this.page.evaluate(function () {
return decktape.shower.getSlidesCount();
});
},
hasNextSlide: function () {
return this.page.evaluate(function () {
return decktape.shower.player.getCurrentSlideIndex() + 1 < decktape.shower.getSlidesCount();
});
},
nextSlide: function () {
this.page.evaluate(function () {
decktape.shower.player.next();
});
},
currentSlideIndex: function () {
return this.page.evaluate(function () {
return decktape.shower.player.getCurrentSlideIndex() + 1;
});
}
};
exports.create = function (page) {
return new Shower(page);
};