Merge pull request #6587 from timvandermeij/view-history-memory
Move VIEW_HISTORY_MEMORY constant to `view_history.js`
This commit is contained in:
commit
cbce05b893
@ -14,10 +14,12 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
/* globals PDFJS, VIEW_HISTORY_MEMORY, Promise */
|
/* globals PDFJS, Promise */
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
var DEFAULT_VIEW_HISTORY_CACHE_SIZE = 20;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* View History - This is a utility for saving various view parameters for
|
* View History - This is a utility for saving various view parameters for
|
||||||
* recently opened files.
|
* recently opened files.
|
||||||
@ -28,8 +30,9 @@
|
|||||||
* - GENERIC or CHROME - uses localStorage, if it is available.
|
* - GENERIC or CHROME - uses localStorage, if it is available.
|
||||||
*/
|
*/
|
||||||
var ViewHistory = (function ViewHistoryClosure() {
|
var ViewHistory = (function ViewHistoryClosure() {
|
||||||
function ViewHistory(fingerprint) {
|
function ViewHistory(fingerprint, cacheSize) {
|
||||||
this.fingerprint = fingerprint;
|
this.fingerprint = fingerprint;
|
||||||
|
this.cacheSize = cacheSize || DEFAULT_VIEW_HISTORY_CACHE_SIZE;
|
||||||
this.isInitializedPromiseResolved = false;
|
this.isInitializedPromiseResolved = false;
|
||||||
this.initializedPromise =
|
this.initializedPromise =
|
||||||
this._readFromStorage().then(function (databaseStr) {
|
this._readFromStorage().then(function (databaseStr) {
|
||||||
@ -39,7 +42,7 @@ var ViewHistory = (function ViewHistoryClosure() {
|
|||||||
if (!('files' in database)) {
|
if (!('files' in database)) {
|
||||||
database.files = [];
|
database.files = [];
|
||||||
}
|
}
|
||||||
if (database.files.length >= VIEW_HISTORY_MEMORY) {
|
if (database.files.length >= this.cacheSize) {
|
||||||
database.files.shift();
|
database.files.shift();
|
||||||
}
|
}
|
||||||
var index;
|
var index;
|
||||||
|
@ -31,7 +31,6 @@ var DEFAULT_URL = 'compressed.tracemonkey-pldi-09.pdf';
|
|||||||
var DEFAULT_SCALE_DELTA = 1.1;
|
var DEFAULT_SCALE_DELTA = 1.1;
|
||||||
var MIN_SCALE = 0.25;
|
var MIN_SCALE = 0.25;
|
||||||
var MAX_SCALE = 10.0;
|
var MAX_SCALE = 10.0;
|
||||||
var VIEW_HISTORY_MEMORY = 20;
|
|
||||||
var SCALE_SELECT_CONTAINER_PADDING = 8;
|
var SCALE_SELECT_CONTAINER_PADDING = 8;
|
||||||
var SCALE_SELECT_PADDING = 22;
|
var SCALE_SELECT_PADDING = 22;
|
||||||
var PAGE_NUMBER_LOADING_INDICATOR = 'visiblePageIsLoading';
|
var PAGE_NUMBER_LOADING_INDICATOR = 'visiblePageIsLoading';
|
||||||
|
Loading…
Reference in New Issue
Block a user