Sha256: 574faec81ec1aa4c12519c0bed9661cfdb6723c29b70289722cc37c0c6710125

Contents?: true

Size: 1.33 KB

Versions: 5

Compression:

Stored size: 1.33 KB

Contents

import $ from 'jquery';

export default class Fullscreen {
  constructor(context) {
    this.context = context;

    this.$editor = context.layoutInfo.editor;
    this.$toolbar = context.layoutInfo.toolbar;
    this.$editable = context.layoutInfo.editable;
    this.$codable = context.layoutInfo.codable;

    this.$window = $(window);
    this.$scrollbar = $('html, body');

    this.onResize = () => {
      this.resizeTo({
        h: this.$window.height() - this.$toolbar.outerHeight()
      });
    };
  }

  resizeTo(size) {
    this.$editable.css('height', size.h);
    this.$codable.css('height', size.h);
    if (this.$codable.data('cmeditor')) {
      this.$codable.data('cmeditor').setsize(null, size.h);
    }
  }

  /**
   * toggle fullscreen
   */
  toggle() {
    this.$editor.toggleClass('fullscreen');
    if (this.isFullscreen()) {
      this.$editable.data('orgHeight', this.$editable.css('height'));
      this.$window.on('resize', this.onResize).trigger('resize');
      this.$scrollbar.css('overflow', 'hidden');
    } else {
      this.$window.off('resize', this.onResize);
      this.resizeTo({ h: this.$editable.data('orgHeight') });
      this.$scrollbar.css('overflow', 'visible');
    }

    this.context.invoke('toolbar.updateFullscreen', this.isFullscreen());
  }

  isFullscreen() {
    return this.$editor.hasClass('fullscreen');
  }
}

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
promethee-1.4.13 node_modules/summernote/src/js/base/module/Fullscreen.js
promethee-1.4.12 node_modules/summernote/src/js/base/module/Fullscreen.js
promethee-1.4.11 node_modules/summernote/src/js/base/module/Fullscreen.js
promethee-1.4.10 node_modules/summernote/src/js/base/module/Fullscreen.js
promethee-1.4.9 node_modules/summernote/src/js/base/module/Fullscreen.js