decktape/plugins/slidy.js

54 lines
1.4 KiB
JavaScript
Raw Normal View History

function Slidy(page) {
this.page = page;
2015-07-02 19:21:56 +03:00
}
Slidy.prototype = {
2015-08-09 19:02:49 +03:00
getName: function () {
2016-03-06 19:47:47 +03:00
return 'Slidy';
2015-07-02 19:21:56 +03:00
},
2015-08-09 19:02:49 +03:00
isActive: function () {
return this.page.evaluate(function () {
2016-02-22 12:43:33 +03:00
return typeof w3c_slidy === 'object';
});
2015-07-02 19:21:56 +03:00
},
2015-08-09 19:02:49 +03:00
configure: function () {
this.page.evaluate(function () {
w3c_slidy.hide_toolbar();
2016-02-22 12:43:33 +03:00
w3c_slidy.initial_prompt.style.visibility = 'hidden';
});
2015-07-02 19:21:56 +03:00
},
2015-08-09 19:02:49 +03:00
slideCount: function () {
return this.page.evaluate(function () {
2016-02-22 12:43:33 +03:00
return w3c_slidy.slides.length + Array.prototype.slice.call(document.querySelectorAll('.incremental')).reduce(function (incrementals, parent) {
var children = parent.querySelectorAll('*');
return incrementals + (children.length == 0 ? 1 : children.length);
}, 0);
});
2015-07-02 19:21:56 +03:00
},
2015-08-09 19:02:49 +03:00
hasNextSlide: function () {
return this.page.evaluate(function () {
return w3c_slidy.slide_number + 1 < w3c_slidy.slides.length;
});
2015-07-02 19:21:56 +03:00
},
2015-08-09 19:02:49 +03:00
nextSlide: function () {
this.page.evaluate(function () {
w3c_slidy.next_slide(true);
});
2015-07-02 19:21:56 +03:00
},
2015-08-09 19:02:49 +03:00
currentSlideIndex: function () {
return this.page.evaluate(function () {
2016-02-22 12:43:33 +03:00
return '(' + (w3c_slidy.slide_number + 1) + ')';
});
2015-07-02 19:21:56 +03:00
}
};
2015-08-09 19:02:49 +03:00
exports.create = function (page) {
return new Slidy(page);
};