Sha256: 9633aac58fb288ca9fd9640b470b1317d8c4e320fcdf32fd344148d0cde5d6ad

Contents?: true

Size: 1.62 KB

Versions: 18

Compression:

Stored size: 1.62 KB

Contents

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

    module FormColumnHelpers
      def self.included(base)
        base.alias_method_chain :onsubmit, :tiny_mce
      end

      def active_scaffold_input_text_editor(column, options)
        options[:class] = "#{options[:class]} mceEditor #{column.options[:class]}".strip

        settings = {:theme => 'modern'}.merge(column.options[:tinymce] || {})
        settings = settings.to_json
        settings = "tinyMCE.settings = #{settings};"

        html = []
        html << send(override_input(:textarea), column, options)
        html << javascript_tag(settings + "tinyMCE.execCommand('mceAddEditor', false, '#{options[:id]}');") if request.xhr? || params[:iframe]
        html.join "\n"
      end

      def onsubmit_with_tiny_mce
        case ActiveScaffold.js_framework
        when :jquery
          submit_js = 'tinyMCE.triggerSave();jQuery(\'textarea.mceEditor\').each(function(index, elem) { tinyMCE.execCommand(\'mceRemoveEditor\', false, jQuery(elem).attr(\'id\')); });'
        when :prototype
          submit_js = 'tinyMCE.triggerSave();this.select(\'textarea.mceEditor\').each(function(elem) { tinyMCE.execCommand(\'mceRemoveEditor\', false, elem.id); });'
        end
        [onsubmit_without_tiny_mce, submit_js].compact.join ';'
      end
    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

18 entries across 18 versions & 1 rubygems

Version Path
active_scaffold-3.4.36 lib/active_scaffold/bridges/tiny_mce/helpers.rb
active_scaffold-3.4.35 lib/active_scaffold/bridges/tiny_mce/helpers.rb
active_scaffold-3.4.34 lib/active_scaffold/bridges/tiny_mce/helpers.rb
active_scaffold-3.4.33 lib/active_scaffold/bridges/tiny_mce/helpers.rb
active_scaffold-3.4.32 lib/active_scaffold/bridges/tiny_mce/helpers.rb
active_scaffold-3.4.31 lib/active_scaffold/bridges/tiny_mce/helpers.rb
active_scaffold-3.4.30 lib/active_scaffold/bridges/tiny_mce/helpers.rb
active_scaffold-3.4.29 lib/active_scaffold/bridges/tiny_mce/helpers.rb
active_scaffold-3.4.28 lib/active_scaffold/bridges/tiny_mce/helpers.rb
active_scaffold-3.4.27 lib/active_scaffold/bridges/tiny_mce/helpers.rb
active_scaffold-3.4.26 lib/active_scaffold/bridges/tiny_mce/helpers.rb
active_scaffold-3.4.25 lib/active_scaffold/bridges/tiny_mce/helpers.rb
active_scaffold-3.4.24 lib/active_scaffold/bridges/tiny_mce/helpers.rb
active_scaffold-3.4.23 lib/active_scaffold/bridges/tiny_mce/helpers.rb
active_scaffold-3.4.22 lib/active_scaffold/bridges/tiny_mce/helpers.rb
active_scaffold-3.4.21.1 lib/active_scaffold/bridges/tiny_mce/helpers.rb
active_scaffold-3.4.21 lib/active_scaffold/bridges/tiny_mce/helpers.rb
active_scaffold-3.4.20 lib/active_scaffold/bridges/tiny_mce/helpers.rb