decktape/plugins/impress.js

44 lines
1.0 KiB
JavaScript
Raw Normal View History

function Impress(page) {
this.page = page;
2015-06-29 23:56:32 +03:00
}
Impress.prototype = {
2015-08-09 19:02:49 +03:00
getName: function () {
2016-02-22 12:43:33 +03:00
return 'Impress JS';
2015-06-29 23:56:32 +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
if (typeof impress === 'function')
return true;
2016-02-22 12:43:33 +03:00
if (document.getElementById('impress'))
console.log('Impress JS plugin isn\'t compatible with impress.js version < 0.3.0');
return false;
});
2015-06-29 23:56:32 +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 document.querySelectorAll('#impress .step, #impress .substep').length;
});
2015-06-29 23:56:32 +03:00
},
2015-08-09 19:02:49 +03:00
nextSlide: function () {
this.page.evaluate(function () {
impress().next();
});
2015-06-29 23:56:32 +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 window.location.hash.replace(/^#\/?/, '');
});
2015-06-29 23:56:32 +03:00
}
};
2015-08-09 19:02:49 +03:00
exports.create = function (page) {
return new Impress(page);
};