|  | @@ -19,10 +19,14 @@ Object.defineProperty(exports, "__esModule", {
 | 
	
		
			
				|  |  |  });
 | 
	
		
			
				|  |  |  exports.PDFSidebar = exports.SidebarView = undefined;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +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; }; }();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  var _ui_utils = require('./ui_utils');
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  var _pdf_rendering_queue = require('./pdf_rendering_queue');
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  var UI_NOTIFICATION_CLASS = 'pdfSidebarNotification';
 | 
	
		
			
				|  |  |  var SidebarView = {
 | 
	
		
			
				|  |  |    NONE: 0,
 | 
	
	
		
			
				|  | @@ -30,8 +34,11 @@ var SidebarView = {
 | 
	
		
			
				|  |  |    OUTLINE: 2,
 | 
	
		
			
				|  |  |    ATTACHMENTS: 3
 | 
	
		
			
				|  |  |  };
 | 
	
		
			
				|  |  | -var PDFSidebar = function PDFSidebarClosure() {
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +var PDFSidebar = function () {
 | 
	
		
			
				|  |  |    function PDFSidebar(options) {
 | 
	
		
			
				|  |  | +    _classCallCheck(this, PDFSidebar);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      this.isOpen = false;
 | 
	
		
			
				|  |  |      this.active = SidebarView.THUMBS;
 | 
	
		
			
				|  |  |      this.isInitialViewSet = false;
 | 
	
	
		
			
				|  | @@ -52,27 +59,19 @@ var PDFSidebar = function PDFSidebarClosure() {
 | 
	
		
			
				|  |  |      this.disableNotification = options.disableNotification || false;
 | 
	
		
			
				|  |  |      this._addEventListeners();
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  | -  PDFSidebar.prototype = {
 | 
	
		
			
				|  |  | -    reset: function PDFSidebar_reset() {
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +  _createClass(PDFSidebar, [{
 | 
	
		
			
				|  |  | +    key: 'reset',
 | 
	
		
			
				|  |  | +    value: function reset() {
 | 
	
		
			
				|  |  |        this.isInitialViewSet = false;
 | 
	
		
			
				|  |  |        this._hideUINotification(null);
 | 
	
		
			
				|  |  |        this.switchView(SidebarView.THUMBS);
 | 
	
		
			
				|  |  |        this.outlineButton.disabled = false;
 | 
	
		
			
				|  |  |        this.attachmentsButton.disabled = false;
 | 
	
		
			
				|  |  | -    },
 | 
	
		
			
				|  |  | -    get visibleView() {
 | 
	
		
			
				|  |  | -      return this.isOpen ? this.active : SidebarView.NONE;
 | 
	
		
			
				|  |  | -    },
 | 
	
		
			
				|  |  | -    get isThumbnailViewVisible() {
 | 
	
		
			
				|  |  | -      return this.isOpen && this.active === SidebarView.THUMBS;
 | 
	
		
			
				|  |  | -    },
 | 
	
		
			
				|  |  | -    get isOutlineViewVisible() {
 | 
	
		
			
				|  |  | -      return this.isOpen && this.active === SidebarView.OUTLINE;
 | 
	
		
			
				|  |  | -    },
 | 
	
		
			
				|  |  | -    get isAttachmentsViewVisible() {
 | 
	
		
			
				|  |  | -      return this.isOpen && this.active === SidebarView.ATTACHMENTS;
 | 
	
		
			
				|  |  | -    },
 | 
	
		
			
				|  |  | -    setInitialView: function PDFSidebar_setInitialView(view) {
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +  }, {
 | 
	
		
			
				|  |  | +    key: 'setInitialView',
 | 
	
		
			
				|  |  | +    value: function setInitialView(view) {
 | 
	
		
			
				|  |  |        if (this.isInitialViewSet) {
 | 
	
		
			
				|  |  |          return;
 | 
	
		
			
				|  |  |        }
 | 
	
	
		
			
				|  | @@ -86,8 +85,12 @@ var PDFSidebar = function PDFSidebarClosure() {
 | 
	
		
			
				|  |  |        if (isViewPreserved) {
 | 
	
		
			
				|  |  |          this._dispatchEvent();
 | 
	
		
			
				|  |  |        }
 | 
	
		
			
				|  |  | -    },
 | 
	
		
			
				|  |  | -    switchView: function PDFSidebar_switchView(view, forceOpen) {
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +  }, {
 | 
	
		
			
				|  |  | +    key: 'switchView',
 | 
	
		
			
				|  |  | +    value: function switchView(view) {
 | 
	
		
			
				|  |  | +      var forceOpen = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |        if (view === SidebarView.NONE) {
 | 
	
		
			
				|  |  |          this.close();
 | 
	
		
			
				|  |  |          return;
 | 
	
	
		
			
				|  | @@ -145,8 +148,10 @@ var PDFSidebar = function PDFSidebarClosure() {
 | 
	
		
			
				|  |  |          this._dispatchEvent();
 | 
	
		
			
				|  |  |        }
 | 
	
		
			
				|  |  |        this._hideUINotification(this.active);
 | 
	
		
			
				|  |  | -    },
 | 
	
		
			
				|  |  | -    open: function PDFSidebar_open() {
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +  }, {
 | 
	
		
			
				|  |  | +    key: 'open',
 | 
	
		
			
				|  |  | +    value: function open() {
 | 
	
		
			
				|  |  |        if (this.isOpen) {
 | 
	
		
			
				|  |  |          return;
 | 
	
		
			
				|  |  |        }
 | 
	
	
		
			
				|  | @@ -160,8 +165,10 @@ var PDFSidebar = function PDFSidebarClosure() {
 | 
	
		
			
				|  |  |        this._forceRendering();
 | 
	
		
			
				|  |  |        this._dispatchEvent();
 | 
	
		
			
				|  |  |        this._hideUINotification(this.active);
 | 
	
		
			
				|  |  | -    },
 | 
	
		
			
				|  |  | -    close: function PDFSidebar_close() {
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +  }, {
 | 
	
		
			
				|  |  | +    key: 'close',
 | 
	
		
			
				|  |  | +    value: function close() {
 | 
	
		
			
				|  |  |        if (!this.isOpen) {
 | 
	
		
			
				|  |  |          return;
 | 
	
		
			
				|  |  |        }
 | 
	
	
		
			
				|  | @@ -171,29 +178,37 @@ var PDFSidebar = function PDFSidebarClosure() {
 | 
	
		
			
				|  |  |        this.outerContainer.classList.remove('sidebarOpen');
 | 
	
		
			
				|  |  |        this._forceRendering();
 | 
	
		
			
				|  |  |        this._dispatchEvent();
 | 
	
		
			
				|  |  | -    },
 | 
	
		
			
				|  |  | -    toggle: function PDFSidebar_toggle() {
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +  }, {
 | 
	
		
			
				|  |  | +    key: 'toggle',
 | 
	
		
			
				|  |  | +    value: function toggle() {
 | 
	
		
			
				|  |  |        if (this.isOpen) {
 | 
	
		
			
				|  |  |          this.close();
 | 
	
		
			
				|  |  |        } else {
 | 
	
		
			
				|  |  |          this.open();
 | 
	
		
			
				|  |  |        }
 | 
	
		
			
				|  |  | -    },
 | 
	
		
			
				|  |  | -    _dispatchEvent: function PDFSidebar_dispatchEvent() {
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +  }, {
 | 
	
		
			
				|  |  | +    key: '_dispatchEvent',
 | 
	
		
			
				|  |  | +    value: function _dispatchEvent() {
 | 
	
		
			
				|  |  |        this.eventBus.dispatch('sidebarviewchanged', {
 | 
	
		
			
				|  |  |          source: this,
 | 
	
		
			
				|  |  |          view: this.visibleView
 | 
	
		
			
				|  |  |        });
 | 
	
		
			
				|  |  | -    },
 | 
	
		
			
				|  |  | -    _forceRendering: function PDFSidebar_forceRendering() {
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +  }, {
 | 
	
		
			
				|  |  | +    key: '_forceRendering',
 | 
	
		
			
				|  |  | +    value: function _forceRendering() {
 | 
	
		
			
				|  |  |        if (this.onToggled) {
 | 
	
		
			
				|  |  |          this.onToggled();
 | 
	
		
			
				|  |  |        } else {
 | 
	
		
			
				|  |  |          this.pdfViewer.forceRendering();
 | 
	
		
			
				|  |  |          this.pdfThumbnailViewer.forceRendering();
 | 
	
		
			
				|  |  |        }
 | 
	
		
			
				|  |  | -    },
 | 
	
		
			
				|  |  | -    _updateThumbnailViewer: function PDFSidebar_updateThumbnailViewer() {
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +  }, {
 | 
	
		
			
				|  |  | +    key: '_updateThumbnailViewer',
 | 
	
		
			
				|  |  | +    value: function _updateThumbnailViewer() {
 | 
	
		
			
				|  |  |        var pdfViewer = this.pdfViewer;
 | 
	
		
			
				|  |  |        var thumbnailViewer = this.pdfThumbnailViewer;
 | 
	
		
			
				|  |  |        var pagesCount = pdfViewer.pagesCount;
 | 
	
	
		
			
				|  | @@ -205,8 +220,10 @@ var PDFSidebar = function PDFSidebarClosure() {
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |        }
 | 
	
		
			
				|  |  |        thumbnailViewer.scrollThumbnailIntoView(pdfViewer.currentPageNumber);
 | 
	
		
			
				|  |  | -    },
 | 
	
		
			
				|  |  | -    _showUINotification: function _showUINotification(view) {
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +  }, {
 | 
	
		
			
				|  |  | +    key: '_showUINotification',
 | 
	
		
			
				|  |  | +    value: function _showUINotification(view) {
 | 
	
		
			
				|  |  |        if (this.disableNotification) {
 | 
	
		
			
				|  |  |          return;
 | 
	
		
			
				|  |  |        }
 | 
	
	
		
			
				|  | @@ -224,21 +241,25 @@ var PDFSidebar = function PDFSidebarClosure() {
 | 
	
		
			
				|  |  |            this.attachmentsButton.classList.add(UI_NOTIFICATION_CLASS);
 | 
	
		
			
				|  |  |            break;
 | 
	
		
			
				|  |  |        }
 | 
	
		
			
				|  |  | -    },
 | 
	
		
			
				|  |  | -    _hideUINotification: function _hideUINotification(view) {
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +  }, {
 | 
	
		
			
				|  |  | +    key: '_hideUINotification',
 | 
	
		
			
				|  |  | +    value: function _hideUINotification(view) {
 | 
	
		
			
				|  |  | +      var _this = this;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |        if (this.disableNotification) {
 | 
	
		
			
				|  |  |          return;
 | 
	
		
			
				|  |  |        }
 | 
	
		
			
				|  |  | -      var removeNotification = function (view) {
 | 
	
		
			
				|  |  | +      var removeNotification = function removeNotification(view) {
 | 
	
		
			
				|  |  |          switch (view) {
 | 
	
		
			
				|  |  |            case SidebarView.OUTLINE:
 | 
	
		
			
				|  |  | -            this.outlineButton.classList.remove(UI_NOTIFICATION_CLASS);
 | 
	
		
			
				|  |  | +            _this.outlineButton.classList.remove(UI_NOTIFICATION_CLASS);
 | 
	
		
			
				|  |  |              break;
 | 
	
		
			
				|  |  |            case SidebarView.ATTACHMENTS:
 | 
	
		
			
				|  |  | -            this.attachmentsButton.classList.remove(UI_NOTIFICATION_CLASS);
 | 
	
		
			
				|  |  | +            _this.attachmentsButton.classList.remove(UI_NOTIFICATION_CLASS);
 | 
	
		
			
				|  |  |              break;
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -      }.bind(this);
 | 
	
		
			
				|  |  | +      };
 | 
	
		
			
				|  |  |        if (!this.isOpen && view !== null) {
 | 
	
		
			
				|  |  |          return;
 | 
	
		
			
				|  |  |        }
 | 
	
	
		
			
				|  | @@ -251,52 +272,77 @@ var PDFSidebar = function PDFSidebarClosure() {
 | 
	
		
			
				|  |  |          removeNotification(SidebarView[view]);
 | 
	
		
			
				|  |  |        }
 | 
	
		
			
				|  |  |        this.toggleButton.title = _ui_utils.mozL10n.get('toggle_sidebar.title', null, 'Toggle Sidebar');
 | 
	
		
			
				|  |  | -    },
 | 
	
		
			
				|  |  | -    _addEventListeners: function PDFSidebar_addEventListeners() {
 | 
	
		
			
				|  |  | -      var self = this;
 | 
	
		
			
				|  |  | -      self.mainContainer.addEventListener('transitionend', function (evt) {
 | 
	
		
			
				|  |  | -        if (evt.target === this) {
 | 
	
		
			
				|  |  | -          self.outerContainer.classList.remove('sidebarMoving');
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +  }, {
 | 
	
		
			
				|  |  | +    key: '_addEventListeners',
 | 
	
		
			
				|  |  | +    value: function _addEventListeners() {
 | 
	
		
			
				|  |  | +      var _this2 = this;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +      this.mainContainer.addEventListener('transitionend', function (evt) {
 | 
	
		
			
				|  |  | +        if (evt.target === _this2.mainContainer) {
 | 
	
		
			
				|  |  | +          _this2.outerContainer.classList.remove('sidebarMoving');
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |        });
 | 
	
		
			
				|  |  | -      self.thumbnailButton.addEventListener('click', function () {
 | 
	
		
			
				|  |  | -        self.switchView(SidebarView.THUMBS);
 | 
	
		
			
				|  |  | +      this.thumbnailButton.addEventListener('click', function () {
 | 
	
		
			
				|  |  | +        _this2.switchView(SidebarView.THUMBS);
 | 
	
		
			
				|  |  |        });
 | 
	
		
			
				|  |  | -      self.outlineButton.addEventListener('click', function () {
 | 
	
		
			
				|  |  | -        self.switchView(SidebarView.OUTLINE);
 | 
	
		
			
				|  |  | +      this.outlineButton.addEventListener('click', function () {
 | 
	
		
			
				|  |  | +        _this2.switchView(SidebarView.OUTLINE);
 | 
	
		
			
				|  |  |        });
 | 
	
		
			
				|  |  | -      self.outlineButton.addEventListener('dblclick', function () {
 | 
	
		
			
				|  |  | -        self.pdfOutlineViewer.toggleOutlineTree();
 | 
	
		
			
				|  |  | +      this.outlineButton.addEventListener('dblclick', function () {
 | 
	
		
			
				|  |  | +        _this2.pdfOutlineViewer.toggleOutlineTree();
 | 
	
		
			
				|  |  |        });
 | 
	
		
			
				|  |  | -      self.attachmentsButton.addEventListener('click', function () {
 | 
	
		
			
				|  |  | -        self.switchView(SidebarView.ATTACHMENTS);
 | 
	
		
			
				|  |  | +      this.attachmentsButton.addEventListener('click', function () {
 | 
	
		
			
				|  |  | +        _this2.switchView(SidebarView.ATTACHMENTS);
 | 
	
		
			
				|  |  |        });
 | 
	
		
			
				|  |  | -      self.eventBus.on('outlineloaded', function (e) {
 | 
	
		
			
				|  |  | -        var outlineCount = e.outlineCount;
 | 
	
		
			
				|  |  | -        self.outlineButton.disabled = !outlineCount;
 | 
	
		
			
				|  |  | +      this.eventBus.on('outlineloaded', function (evt) {
 | 
	
		
			
				|  |  | +        var outlineCount = evt.outlineCount;
 | 
	
		
			
				|  |  | +        _this2.outlineButton.disabled = !outlineCount;
 | 
	
		
			
				|  |  |          if (outlineCount) {
 | 
	
		
			
				|  |  | -          self._showUINotification(SidebarView.OUTLINE);
 | 
	
		
			
				|  |  | -        } else if (self.active === SidebarView.OUTLINE) {
 | 
	
		
			
				|  |  | -          self.switchView(SidebarView.THUMBS);
 | 
	
		
			
				|  |  | +          _this2._showUINotification(SidebarView.OUTLINE);
 | 
	
		
			
				|  |  | +        } else if (_this2.active === SidebarView.OUTLINE) {
 | 
	
		
			
				|  |  | +          _this2.switchView(SidebarView.THUMBS);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |        });
 | 
	
		
			
				|  |  | -      self.eventBus.on('attachmentsloaded', function (e) {
 | 
	
		
			
				|  |  | -        var attachmentsCount = e.attachmentsCount;
 | 
	
		
			
				|  |  | -        self.attachmentsButton.disabled = !attachmentsCount;
 | 
	
		
			
				|  |  | +      this.eventBus.on('attachmentsloaded', function (evt) {
 | 
	
		
			
				|  |  | +        var attachmentsCount = evt.attachmentsCount;
 | 
	
		
			
				|  |  | +        _this2.attachmentsButton.disabled = !attachmentsCount;
 | 
	
		
			
				|  |  |          if (attachmentsCount) {
 | 
	
		
			
				|  |  | -          self._showUINotification(SidebarView.ATTACHMENTS);
 | 
	
		
			
				|  |  | -        } else if (self.active === SidebarView.ATTACHMENTS) {
 | 
	
		
			
				|  |  | -          self.switchView(SidebarView.THUMBS);
 | 
	
		
			
				|  |  | +          _this2._showUINotification(SidebarView.ATTACHMENTS);
 | 
	
		
			
				|  |  | +        } else if (_this2.active === SidebarView.ATTACHMENTS) {
 | 
	
		
			
				|  |  | +          _this2.switchView(SidebarView.THUMBS);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |        });
 | 
	
		
			
				|  |  | -      self.eventBus.on('presentationmodechanged', function (e) {
 | 
	
		
			
				|  |  | -        if (!e.active && !e.switchInProgress && self.isThumbnailViewVisible) {
 | 
	
		
			
				|  |  | -          self._updateThumbnailViewer();
 | 
	
		
			
				|  |  | +      this.eventBus.on('presentationmodechanged', function (evt) {
 | 
	
		
			
				|  |  | +        if (!evt.active && !evt.switchInProgress && _this2.isThumbnailViewVisible) {
 | 
	
		
			
				|  |  | +          _this2._updateThumbnailViewer();
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |        });
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | -  };
 | 
	
		
			
				|  |  | +  }, {
 | 
	
		
			
				|  |  | +    key: 'visibleView',
 | 
	
		
			
				|  |  | +    get: function get() {
 | 
	
		
			
				|  |  | +      return this.isOpen ? this.active : SidebarView.NONE;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +  }, {
 | 
	
		
			
				|  |  | +    key: 'isThumbnailViewVisible',
 | 
	
		
			
				|  |  | +    get: function get() {
 | 
	
		
			
				|  |  | +      return this.isOpen && this.active === SidebarView.THUMBS;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +  }, {
 | 
	
		
			
				|  |  | +    key: 'isOutlineViewVisible',
 | 
	
		
			
				|  |  | +    get: function get() {
 | 
	
		
			
				|  |  | +      return this.isOpen && this.active === SidebarView.OUTLINE;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +  }, {
 | 
	
		
			
				|  |  | +    key: 'isAttachmentsViewVisible',
 | 
	
		
			
				|  |  | +    get: function get() {
 | 
	
		
			
				|  |  | +      return this.isOpen && this.active === SidebarView.ATTACHMENTS;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +  }]);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |    return PDFSidebar;
 | 
	
		
			
				|  |  |  }();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  exports.SidebarView = SidebarView;
 | 
	
		
			
				|  |  |  exports.PDFSidebar = PDFSidebar;
 |