Sha256: 17717e8ec6ac04ae84a79f890621f0ff216faf3d1111426457004021bcaeabd2

Contents?: true

Size: 1.96 KB

Versions: 23

Compression:

Stored size: 1.96 KB

Contents

class ActiveScaffold::Bridges::TinyMce
  module Helpers
    def self.included(base)
      base.class_eval do
        include FormColumnHelpers
        include SearchColumnHelpers
      end
    end

    module FormColumnHelpers
      # The two column options that can be set specifically for the text_editor input
      # is :tinymce, which overrides single values in the tinymce config.
      # E.g. column[:foo].options[:tinymce] = {theme: 'other'} will change the theme
      # but not the plugins, toolbars etc.
      # The other one is :tinymce_config, which selects the config to use from tinymce.yml.
      # See the tinymce-rails gem documentation for usage.
      def active_scaffold_input_text_editor(column, options)
        options[:class] = "#{options[:class]} mceEditor #{column.options[:class]}".strip

        settings = tinymce_configuration(column.options[:tinymce_config] || :default).options
                                                                                     .reject { |k, _v| k == 'selector' }
                                                                                     .merge(column.options[:tinymce] || {})
        options['data-tinymce'] = settings.to_json if ActiveScaffold.js_framework != :prototype

        html = []
        html << send(override_input(:textarea), column, options)
        if ActiveScaffold.js_framework == :prototype && (request.xhr? || params[:iframe])
          html << javascript_tag("tinyMCE.settings = #{settings.to_json}; tinyMCE.execCommand('mceAddEditor', false, '#{options[:id]}');")
        end
        safe_join html
      end

      # The implementation is very tinymce specific, so it makes sense allowing :form_ui
      # to be :tinymce as well
      alias active_scaffold_input_tinymce active_scaffold_input_text_editor
    end

    module SearchColumnHelpers
      def self.included(base)
        base.class_eval { alias_method :active_scaffold_search_text_editor, :active_scaffold_search_text }
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
active_scaffold-3.7.0 lib/active_scaffold/bridges/tiny_mce/helpers.rb
active_scaffold-3.6.20 lib/active_scaffold/bridges/tiny_mce/helpers.rb
active_scaffold-3.6.19 lib/active_scaffold/bridges/tiny_mce/helpers.rb
active_scaffold-3.6.17 lib/active_scaffold/bridges/tiny_mce/helpers.rb
active_scaffold-3.6.15 lib/active_scaffold/bridges/tiny_mce/helpers.rb
active_scaffold-3.6.14 lib/active_scaffold/bridges/tiny_mce/helpers.rb
active_scaffold-3.6.13 lib/active_scaffold/bridges/tiny_mce/helpers.rb
active_scaffold-3.6.12 lib/active_scaffold/bridges/tiny_mce/helpers.rb
active_scaffold-3.6.11.1 lib/active_scaffold/bridges/tiny_mce/helpers.rb
active_scaffold-3.6.11 lib/active_scaffold/bridges/tiny_mce/helpers.rb
active_scaffold-3.6.10 lib/active_scaffold/bridges/tiny_mce/helpers.rb
active_scaffold-3.6.9 lib/active_scaffold/bridges/tiny_mce/helpers.rb
active_scaffold-3.6.8 lib/active_scaffold/bridges/tiny_mce/helpers.rb
active_scaffold-3.6.6 lib/active_scaffold/bridges/tiny_mce/helpers.rb
active_scaffold-3.6.5 lib/active_scaffold/bridges/tiny_mce/helpers.rb
active_scaffold-3.6.4.1 lib/active_scaffold/bridges/tiny_mce/helpers.rb
active_scaffold-3.6.4 lib/active_scaffold/bridges/tiny_mce/helpers.rb
active_scaffold-3.6.3 lib/active_scaffold/bridges/tiny_mce/helpers.rb
active_scaffold-3.6.2 lib/active_scaffold/bridges/tiny_mce/helpers.rb
active_scaffold-3.6.1 lib/active_scaffold/bridges/tiny_mce/helpers.rb