Sha256: 3613527f3026a4d681f74c6d9489c6835d4b28213c74bf168026b677aa801452

Contents?: true

Size: 1.31 KB

Versions: 80

Compression:

Stored size: 1.31 KB

Contents

window.TinyMCERails = {
  configuration: {
    default: {}
  },

  initialize: function(config, options) {
    if (typeof tinyMCE != 'undefined') {
      // Merge the custom options with the given configuration
      var configuration = TinyMCERails.configuration[config || 'default'];
      configuration = TinyMCERails._merge(configuration, options);

      tinyMCE.init(configuration);
    } else {
      // Wait until TinyMCE is loaded
      setTimeout(function() {
        TinyMCERails.initialize(config, options);
      }, 50);
    }
  },

  setupTurbolinks: function() {
    // Remove all TinyMCE instances before rendering
    document.addEventListener('turbolinks:before-render', function() {
      tinymce.remove();
    });
  },

  _merge: function() {
    var result = {};

    for (var i = 0; i < arguments.length; ++i) {
      var source = arguments[i];

      for (var key in source) {
        if (Object.prototype.hasOwnProperty.call(source, key)) {
          if (Object.prototype.toString.call(source[key]) === '[object Object]') {
            result[key] = TinyMCERails._merge(result[key], source[key]);
          } else {
            result[key] = source[key];
          }
        }
      }
    }

    return result;
  }
};

if (typeof Turbolinks != 'undefined' && Turbolinks.supported) {
  TinyMCERails.setupTurbolinks();
}

Version data entries

80 entries across 80 versions & 3 rubygems

Version Path
tinymce-rails-5.6.0 app/assets/javascripts/tinymce/rails.js
tinymce-rails-5.5.1 app/assets/javascripts/tinymce/rails.js
tinymce-rails-webmely-5.1.5 app/assets/javascripts/tinymce/rails.js
tinymce-rails-webmely-5.1.4 app/assets/javascripts/tinymce/rails.js
tinymce-rails-4.9.11 app/assets/javascripts/tinymce/rails.js
tinymce-rails-5.4.1 app/assets/javascripts/tinymce/rails.js
tinymce-rails-5.4.0 app/assets/javascripts/tinymce/rails.js
tinymce-rails-bach-0.1.1 app/assets/javascripts/tinymce/rails.js
tinymce-rails-5.3.2 app/assets/javascripts/tinymce/rails.js
tinymce-rails-5.3.0 app/assets/javascripts/tinymce/rails.js
tinymce-rails-4.9.10 app/assets/javascripts/tinymce/rails.js
tinymce-rails-5.2.2 app/assets/javascripts/tinymce/rails.js
tinymce-rails-5.2.1 app/assets/javascripts/tinymce/rails.js
tinymce-rails-5.2.0 app/assets/javascripts/tinymce/rails.js
tinymce-rails-5.1.6 app/assets/javascripts/tinymce/rails.js
tinymce-rails-4.9.8 app/assets/javascripts/tinymce/rails.js
tinymce-rails-5.1.5 app/assets/javascripts/tinymce/rails.js
tinymce-rails-4.9.7.1 app/assets/javascripts/tinymce/rails.js
tinymce-rails-5.1.4.1 app/assets/javascripts/tinymce/rails.js
tinymce-rails-4.9.7 app/assets/javascripts/tinymce/rails.js