Sha256: 9288f93953071c3b84186cedd518ec1b7745dbaaea06a2a3a80429c27d9296c8

Contents?: true

Size: 1.41 KB

Versions: 3

Compression:

Stored size: 1.41 KB

Contents

module Liquid
  module Locomotive
    module Tags
      class InlineEditor < ::Liquid::Tag

        def render(context)
          if context.registers[:current_locomotive_account] && context.registers[:inline_editor]

            plugins = 'common/format,common/table,common/list,common/link,common/highlighteditables,common/block,common/undo,common/contenthandler,common/paste,common/commands,common/abbr,common/align,common/horizontalruler,custom/locomotive_media'

            controller = context.registers[:controller]
            controller.instance_variable_set(:@plugins, plugins)

            html = <<-HTML
              %meta{ :content => true, :name => 'inline-editor' }

              = stylesheet_link_tag 'aloha/css/aloha.css'
              = javascript_include_tag 'locomotive/aloha', :'data-aloha-plugins' => @plugins

              %script{ :type => 'text/javascript' }
                :plain
                  Aloha.ready(function() \{
                    window.parent.application_view.set_page(#{controller.view_context.j context.registers[:page].to_presenter.as_json_for_html_view.to_json.html_safe});
                  \});
            HTML

            Haml::Engine.new(html.gsub(/\n+/, "\n").gsub(/^\s{14}/, ''), :escape_html => true).render(controller.view_context)
          else
            ''
          end
        end
      end

      ::Liquid::Template.register_tag('inline_editor', InlineEditor)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
locomotive_cms-2.0.0.rc12 lib/locomotive/liquid/tags/inline_editor.rb
locomotive_cms-2.0.0.rc11 lib/locomotive/liquid/tags/inline_editor.rb
locomotive_cms-2.0.0.rc10 lib/locomotive/liquid/tags/inline_editor.rb