Sha256: 336b338772286d2a115abaa168ddda9a1bfe033225963c921d00f56098de6724

Contents?: true

Size: 1.11 KB

Versions: 3

Compression:

Stored size: 1.11 KB

Contents

module UeditorRails
  module Helpers
    module FormHelper
      extend ActiveSupport::Concern

      include ActionView::Helpers::TagHelper
      include ActionView::Helpers::JavaScriptHelper

      def ueditor_text(object_name, method = nil, options = {})
        instance_tag = ActionView::Base::InstanceTag.new(object_name, method, self, options.delete(:object))
        instance_tag.send(:add_default_name_and_id, options) if options[:id].blank?

        element_id = options.delete('id')
        ue_tag_attributes = {:type => 'text/plain', :id => element_id, :name => options.delete('name')}
        options[:initialFrameWidth] = options.delete(:width) unless options[:width].blank?
        options[:initialFrameHeight] = options.delete(:height) unless options[:height].blank?

        output_buffer = ActiveSupport::SafeBuffer.new
        #output_buffer << instance_tag.to_content_tag(:script, ue_tag_attributes)
        output_buffer << instance_tag.to_text_area_tag(ue_tag_attributes)
        output_buffer << javascript_tag {Util.js_replace(element_id, options.stringify_keys)}
        output_buffer
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ueditor_rails-0.0.4 lib/ueditor_rails/helpers/form_helper.rb
ueditor_rails-0.0.2 lib/ueditor_rails/helpers/form_helper.rb
ueditor_rails-0.0.1 lib/ueditor_rails/helpers/form_helper.rb