This repository has been archived on 2024-01-19. You can view files and clone it, but cannot push or open issues or pull requests.
epubreader/public/pdfjs/controllers/progress_controller.js

58 lines
1.3 KiB
JavaScript
Raw Normal View History

2020-04-21 20:37:42 +00:00
PDFJS.reader.ProgressController = function() {
var reader = this,
settings = reader.settings,
percentage = 0;
var $progress = $("#progress"),
$bar = $(".bar"),
$download_icon = $("#download_icon"),
$message = $(".message-text");
var show = function () {
$progress.removeClass("hide");
};
var hide = function () {
$progress.addClass("hide");
};
var setSize = function (size) {
settings.fileSize = size;
};
var setProgress = function (progress) {
if (percentage < 1)
$download_icon.addClass("active");
percentage = Math.floor((progress.loaded / progress.total) * 100);
$bar.css("width", percentage + "%");
if (percentage === 100)
$download_icon.removeClass("active").addClass("ok");
};
var reset = function() {
$bar.css("width", 0);
};
var setMessage = function (text, category, state) {
var $category_icon = $("#" + category + "_icon");
$message.text(text);
$category_icon[0].classList.remove("ok", "active", "error");
$category_icon.addClass(state);
};
return {
"show": show,
"hide": hide,
"setSize": setSize,
"setProgress": setProgress,
"setMessage": setMessage
};
};