Removes web/default_preferences.js file.

This commit is contained in:
Yury Delendik 2017-01-10 08:33:32 -06:00
parent f828f07ccd
commit ac2d4abf39
3 changed files with 23 additions and 56 deletions

View File

@ -1,36 +0,0 @@
/* Copyright 2013 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
'use strict';
var DEFAULT_PREFERENCES;
(function defaultPreferencesLoaderWrapper() {
function loaded() {
try {
DEFAULT_PREFERENCES = JSON.parse(xhr.responseText);
} catch (e) {
console.error('Unable to load DEFAULT_PREFERENCES: ' + e);
DEFAULT_PREFERENCES = {};
}
var event = document.createEvent('CustomEvent');
event.initCustomEvent('defaultpreferencesloaded', true, true, null);
document.dispatchEvent(event);
}
var xhr = new XMLHttpRequest();
xhr.open('GET', 'default_preferences.json');
xhr.onload = xhr.onerror = loaded;
xhr.send();
})();

View File

@ -12,7 +12,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* globals DEFAULT_PREFERENCES */
'use strict';
@ -26,21 +25,29 @@
}
}(this, function (exports) {
var defaultPreferences;
if (typeof PDFJSDev !== 'undefined' && PDFJSDev.test('PRODUCTION')) {
defaultPreferences = Promise.resolve(
PDFJSDev.json('$ROOT/web/default_preferences.json'));
} else {
defaultPreferences = new Promise(function (resolve) {
if (DEFAULT_PREFERENCES) {
resolve(DEFAULT_PREFERENCES);
return;
var defaultPreferences = null;
function getDefaultPreferences() {
if (!defaultPreferences) {
if (typeof PDFJSDev !== 'undefined' && PDFJSDev.test('PRODUCTION')) {
defaultPreferences = Promise.resolve(
PDFJSDev.json('$ROOT/web/default_preferences.json'));
} else {
defaultPreferences = new Promise(function (resolve) {
var xhr = new XMLHttpRequest();
xhr.open('GET', 'default_preferences.json');
xhr.onload = xhr.onerror = function loaded() {
try {
resolve(JSON.parse(xhr.responseText));
} catch (e) {
console.error('Unable to load default preferences: ' + e);
resolve({});
}
};
xhr.send();
});
}
document.addEventListener('defaultpreferencesloaded', function loaded() {
resolve(DEFAULT_PREFERENCES);
document.removeEventListener('defaultpreferencesloaded', loaded);
});
});
}
return defaultPreferences;
}
function cloneObj(obj) {
@ -69,7 +76,7 @@ var Preferences = {
* have been initialized.
*/
initialize: function preferencesInitialize() {
return this.initializedPromise = defaultPreferences.then(
return this.initializedPromise = getDefaultPreferences().then(
function (defaults) {
Object.defineProperty(this, 'defaults', {

View File

@ -60,10 +60,6 @@ See https://github.com/adobe-type-tools/cmap-resources
<!--#include viewer-snippet.html-->
<!--#endif-->
<!--#if !PRODUCTION-->
<script src="default_preferences.js"></script>
<!--#endif-->
<!--#if !MINIFIED -->
<script src="viewer.js"></script>
<!--#else-->