Sha256: 2543456cf97770276e867b5ae5ec5005101927526ac2ff470274c6a200a3de6b

Contents?: true

Size: 1.47 KB

Versions: 4

Compression:

Stored size: 1.47 KB

Contents

/* global Fae, modal, FCH */

'use strict';

/**
 * Fae modals
 * @namespace
 */
Fae.modals = {
  init: function() {
    this.imageModals();
    this.markdownModalListener();
  },

  /**
   * Click event to open modal with only an image
   */
  imageModals: function() {
    $('.js-image-modal').click(function(e){
      e.preventDefault();
      var $this = $(this);

      // create invisi-image to get natural width/height
      var image = new Image();
      image.src = $this.attr('src');
      var image_width = image.width;
      var image_height = image.height;

      $this.modal({
        minHeight: image_height,
        minWidth: image_width,
        overlayClose: true
      });
    });
  },

  /**
   * Display markdown guide in a modal
   * @see {@link form.text.overrideMarkdownDefaults}
   * @see {@link modals.markdownModalListener}
   * @has_test {features/form_helpers/fae_input_spec.rb}
   */
  markdownModal: function() {
    var markdown_hint_width = $('.markdown-hint').width() + 40;

    $('.markdown-hint-wrapper').modal({
      minHeight: 430,
      minWidth: markdown_hint_width,
      overlayClose: true,
      zIndex: 1100
    });
  },

  /**
   * Markdown guide shown on document click of "markdown-support" so as to support AJAX'd markdown-support fields.
   * @fires {@link modals.markdownModal}
   * @has_test {features/form_helpers/fae_input_spec.rb}
   */
  markdownModalListener: function() {
    FCH.$document.on('click', '.markdown-support', this.markdownModal);
  }
};

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
fae-rails-1.2.5 app/assets/javascripts/fae/_modals.js
fae-rails-1.2.4 app/assets/javascripts/fae/_modals.js
fae-rails-1.2.3 app/assets/javascripts/fae/_modals.js
fae-rails-1.2.2 app/assets/javascripts/fae/_modals.js