2010-09-02 23:03:20 +00:00
|
|
|
module Liquid
|
|
|
|
module Locomotive
|
|
|
|
module Tags
|
|
|
|
class InlineEditor < ::Liquid::Tag
|
|
|
|
|
|
|
|
def render(context)
|
2012-01-16 22:59:59 +00:00
|
|
|
if context.registers[:current_locomotive_account] && context.registers[:inline_editor]
|
2012-01-20 13:46:09 +00:00
|
|
|
|
|
|
|
plugins = 'common/format,common/table,common/list,common/link,common/highlighteditables,common/block,common/undo,common/contenthandler,common/paste,common/commands,common/abbr,common/horizontalruler'
|
|
|
|
|
2012-01-16 22:59:59 +00:00
|
|
|
%{
|
2012-01-17 16:04:45 +00:00
|
|
|
<meta content="true" name="inline-editor" />
|
2012-01-20 13:46:09 +00:00
|
|
|
|
2012-01-21 00:48:00 +00:00
|
|
|
#{ActionController::Base.helpers.stylesheet_link_tag 'aloha/css/aloha.css'}
|
2012-01-20 13:46:09 +00:00
|
|
|
#{ActionController::Base.helpers.javascript_include_tag 'locomotive/aloha', :'data-aloha-plugins' => plugins}
|
|
|
|
|
2012-01-17 16:04:45 +00:00
|
|
|
|
2012-01-16 22:59:59 +00:00
|
|
|
<script type="text/javascript">
|
2012-01-17 16:04:45 +00:00
|
|
|
Aloha.ready(function() \{
|
|
|
|
window.parent.application_view.set_page(#{context.registers[:page].to_presenter.as_json_for_html_view.to_json});
|
|
|
|
\});
|
2012-01-16 22:59:59 +00:00
|
|
|
</script>
|
2012-01-20 13:46:09 +00:00
|
|
|
|
2010-09-02 23:03:20 +00:00
|
|
|
}
|
2012-01-16 22:59:59 +00:00
|
|
|
else
|
|
|
|
''
|
2010-09-02 23:03:20 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
::Liquid::Template.register_tag('inline_editor', InlineEditor)
|
|
|
|
end
|
|
|
|
end
|
2012-01-21 00:48:00 +00:00
|
|
|
end
|