Sha256: 02886588856f80dcb9cda4cc0a6b618687bb9f9ecd7438cfad968a168253a1ed

Contents?: true

Size: 1.61 KB

Versions: 3

Compression:

Stored size: 1.61 KB

Contents

format :html do
  view :nest_image,
       unknown: true, cache: :never,
       wrap: { slot: { class: "_overlay d0-card-overlay card nodblclick" } } do
    nest_image_editor :overlay
  end

  view :modal_nest_image, unknown: true, cache: :never,
                          wrap: { slot: { class: "nodblclick" } } do
    nest_image_editor :modal
  end

  view :new_image, perms: :create, unknown: true, cache: :never do
    voo.buttons_view = :new_image_buttons
    framed_create_form success: { tinymce_id: Env.params[:tinymce_id], view: :open }
  end

  view :new_image_buttons do
    button_formgroup do
      [standard_save_button(no_origin_update: true, class: "_change-create-to-update")]
    end
  end

  def nest_image_editor editor_mode
    adapt_reference_editor_for_images
    nest_editor editor_mode
  end

  def adapt_reference_editor_for_images
    nest_name = card.autoname(card.name.field("image01"))
    voo.show! :content_tab
    @nest_content_tab = nest(nest_name, view: :new_image, type: :image, hide: :guide)

    image_name = nest_name.to_name.right
    @nest_snippet = Card::Reference::NestParser.new_image image_name
  end
end

format :js do
  view :change_create_to_update, unknown: true do
    "nest.changeCreateToUpdate(#{tinymce_id});"
  end

  view :open_nest_editor, unknown: true do
    <<-JAVASCRIPT.strip_heredoc
      tm = tinymce.get(#{tinymce_id});
      nest.insertNest(tm, "{{+#{card.name.tag}|view: content; size: medium}}");
    JAVASCRIPT
  end

  def tinymce_id
    if Env.params[:tinymce_id].present?
      "\"#{Env.params[:tinymce_id]}\""
    else
      '$(".tinymce-textarea").attr("id")'
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
card-mod-tinymce_editor-0.14.2 set/all/reference_editor/nest_image.rb
card-mod-tinymce_editor-0.14.1 set/all/reference_editor/nest_image.rb
card-mod-tinymce_editor-0.14.0 set/all/reference_editor/nest_image.rb