genericcom.js 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /* Copyright 2017 Mozilla Foundation
  2. *
  3. * Licensed under the Apache License, Version 2.0 (the "License");
  4. * you may not use this file except in compliance with the License.
  5. * You may obtain a copy of the License at
  6. *
  7. * http://www.apache.org/licenses/LICENSE-2.0
  8. *
  9. * Unless required by applicable law or agreed to in writing, software
  10. * distributed under the License is distributed on an "AS IS" BASIS,
  11. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. * See the License for the specific language governing permissions and
  13. * limitations under the License.
  14. */
  15. 'use strict';
  16. Object.defineProperty(exports, "__esModule", {
  17. value: true
  18. });
  19. exports.GenericCom = undefined;
  20. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  21. var _app = require('./app');
  22. var _preferences = require('./preferences');
  23. var _download_manager = require('./download_manager');
  24. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  25. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  26. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  27. ;
  28. var GenericCom = {};
  29. var GenericPreferences = function (_BasePreferences) {
  30. _inherits(GenericPreferences, _BasePreferences);
  31. function GenericPreferences() {
  32. _classCallCheck(this, GenericPreferences);
  33. return _possibleConstructorReturn(this, (GenericPreferences.__proto__ || Object.getPrototypeOf(GenericPreferences)).apply(this, arguments));
  34. }
  35. _createClass(GenericPreferences, [{
  36. key: '_writeToStorage',
  37. value: function _writeToStorage(prefObj) {
  38. return new Promise(function (resolve) {
  39. localStorage.setItem('pdfjs.preferences', JSON.stringify(prefObj));
  40. resolve();
  41. });
  42. }
  43. }, {
  44. key: '_readFromStorage',
  45. value: function _readFromStorage(prefObj) {
  46. return new Promise(function (resolve) {
  47. var readPrefs = JSON.parse(localStorage.getItem('pdfjs.preferences'));
  48. resolve(readPrefs);
  49. });
  50. }
  51. }]);
  52. return GenericPreferences;
  53. }(_preferences.BasePreferences);
  54. var GenericExternalServices = Object.create(_app.DefaultExternalServices);
  55. GenericExternalServices.createDownloadManager = function () {
  56. return new _download_manager.DownloadManager();
  57. };
  58. GenericExternalServices.createPreferences = function () {
  59. return new GenericPreferences();
  60. };
  61. _app.PDFViewerApplication.externalServices = GenericExternalServices;
  62. exports.GenericCom = GenericCom;