Sha256: ce8b4307616c5ebe116050ef3b7575451fbde93eb9b3965928d898cb3a2bba53

Contents?: true

Size: 1.52 KB

Versions: 23

Compression:

Stored size: 1.52 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/ui,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,common/image,custom/locomotive_media,custom/inputcontrol'

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

            page = context.registers[:page].to_presenter.as_json_for_html_view
            page['lang'] = context['locale']

            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.escape_json page.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

23 entries across 23 versions & 2 rubygems

Version Path
locomotive_cms-2.5.7 lib/locomotive/liquid/tags/inline_editor.rb
locomotivecms-3.0.0.pre.alpha.2 lib/locomotive/previous_liquid/tags/inline_editor.rb
locomotivecms-3.0.0.pre.alpha lib/locomotive/previous_liquid/tags/inline_editor.rb
locomotive_cms-2.5.6 lib/locomotive/liquid/tags/inline_editor.rb
locomotive_cms-2.5.6.rc2 lib/locomotive/liquid/tags/inline_editor.rb
locomotive_cms-2.5.6.rc1 lib/locomotive/liquid/tags/inline_editor.rb
locomotive_cms-2.5.5 lib/locomotive/liquid/tags/inline_editor.rb
locomotive_cms-2.5.4 lib/locomotive/liquid/tags/inline_editor.rb
locomotive_cms-2.5.3 lib/locomotive/liquid/tags/inline_editor.rb
locomotive_cms-2.5.2 lib/locomotive/liquid/tags/inline_editor.rb
locomotive_cms-2.5.1 lib/locomotive/liquid/tags/inline_editor.rb
locomotive_cms-2.5.0 lib/locomotive/liquid/tags/inline_editor.rb
locomotive_cms-2.5.0.rc3 lib/locomotive/liquid/tags/inline_editor.rb
locomotive_cms-2.5.0.rc2 lib/locomotive/liquid/tags/inline_editor.rb
locomotive_cms-2.5.0.rc1 lib/locomotive/liquid/tags/inline_editor.rb
locomotive_cms-2.4.1 lib/locomotive/liquid/tags/inline_editor.rb
locomotive_cms-2.4.0 lib/locomotive/liquid/tags/inline_editor.rb
locomotive_cms-2.3.1 lib/locomotive/liquid/tags/inline_editor.rb
locomotive_cms-2.3.0 lib/locomotive/liquid/tags/inline_editor.rb
locomotive_cms-2.2.3 lib/locomotive/liquid/tags/inline_editor.rb