|
|
@ -33,37 +33,41 @@ var ProgressBar = (function ProgressBarClosure() { |
|
|
|
return Math.min(Math.max(v, min), max); |
|
|
|
return Math.min(Math.max(v, min), max); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function sizeBar(bar, num, width, height, units) { |
|
|
|
function ProgressBar(id, opts) { |
|
|
|
var progress = bar.querySelector('#progress'); |
|
|
|
|
|
|
|
var remaining = bar.querySelector('#remaining'); |
|
|
|
// Fetch the sub-elements for later
|
|
|
|
progress.style.height = height + units; |
|
|
|
this.progressDiv = document.querySelector(id + ' .progress'); |
|
|
|
remaining.style.height = height + units; |
|
|
|
this.remainingDiv = document.querySelector(id + ' .remaining'); |
|
|
|
progress.style.width = num + units; |
|
|
|
|
|
|
|
remaining.style.width = (width - num) + units; |
|
|
|
// Get options, with sensible defaults
|
|
|
|
} |
|
|
|
this.height = opts.height || 1; |
|
|
|
|
|
|
|
this.width = opts.width || 15; |
|
|
|
function ProgressBar(element, min, max, width, height, units) { |
|
|
|
this.units = opts.units || 'em'; |
|
|
|
this.element = element; |
|
|
|
this.percent = opts.progress || 0; |
|
|
|
this.min = min; |
|
|
|
|
|
|
|
this.max = max; |
|
|
|
// Initialize heights
|
|
|
|
this.width = width; |
|
|
|
this.progressDiv.style.height = this.height + this.units; |
|
|
|
this.height = height; |
|
|
|
this.remainingDiv.style.height = this.height + this.units; |
|
|
|
this.units = units; |
|
|
|
|
|
|
|
this.value = min; |
|
|
|
|
|
|
|
sizeBar(element, 0, this.width, this.height, this.units); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ProgressBar.prototype = { |
|
|
|
ProgressBar.prototype = { |
|
|
|
constructor: ProgressBar, |
|
|
|
constructor: ProgressBar, |
|
|
|
|
|
|
|
|
|
|
|
get value() { |
|
|
|
updateBar: function ProgressBar_updateBar() { |
|
|
|
return this._value; |
|
|
|
var progressSize = this.width * this._percent / 100; |
|
|
|
|
|
|
|
var remainingSize = (this.width - progressSize); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.progressDiv.style.width = progressSize + this.units; |
|
|
|
|
|
|
|
this.remainingDiv.style.width = remainingSize + this.units; |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
get percent() { |
|
|
|
|
|
|
|
return this._percent; |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
set value(val) { |
|
|
|
set percent(val) { |
|
|
|
this._value = clamp(val, this.min, this.max); |
|
|
|
this._percent = clamp(val, 0, 100); |
|
|
|
var num = this.width * (val - this.min) / (this.max - this.min); |
|
|
|
this.updateBar(); |
|
|
|
sizeBar(this.element, num, this.width, this.height, this.units); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
@ -304,10 +308,9 @@ var PDFView = { |
|
|
|
document.title = this.url = url; |
|
|
|
document.title = this.url = url; |
|
|
|
|
|
|
|
|
|
|
|
// FIXME: Probably needs a better place to get initialized
|
|
|
|
// FIXME: Probably needs a better place to get initialized
|
|
|
|
if (!PDFView.loadingProgress) { |
|
|
|
if (!PDFView.loadingBar) { |
|
|
|
PDFView.loadingProgress = new ProgressBar( |
|
|
|
PDFView.loadingBar = new ProgressBar('#loadingBar', { |
|
|
|
document.getElementById('loadingBar'), |
|
|
|
width: 15, height: 1.5, units: 'em'}); |
|
|
|
0, 100, 15, 1.5, 'em'); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var self = this; |
|
|
|
var self = this; |
|
|
@ -451,7 +454,7 @@ var PDFView = { |
|
|
|
var loadingIndicator = document.getElementById('loading'); |
|
|
|
var loadingIndicator = document.getElementById('loading'); |
|
|
|
loadingIndicator.textContent = 'Loading... ' + percent + '%'; |
|
|
|
loadingIndicator.textContent = 'Loading... ' + percent + '%'; |
|
|
|
|
|
|
|
|
|
|
|
PDFView.loadingProgress.value = percent; |
|
|
|
PDFView.loadingBar.percent = percent; |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
load: function pdfViewLoad(data, scale) { |
|
|
|
load: function pdfViewLoad(data, scale) { |
|
|
|