Sha256: 9a91a03ac369d20c81ac4b64b176f916f42e134e269294ddc2b07671d6cd9bfd

Contents?: true

Size: 1.94 KB

Versions: 5

Compression:

Stored size: 1.94 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
    new_view_frame_and_form new_image_form_opts
  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 = NestEditor::NestParser.new_image image_name
  end


  def new_image_form_opts
    { buttons: new_image_buttons,
      success: { tinymce_id: Env.params[:tinymce_id],
                 view: :open } }
  end

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

format :js do
  view :change_create_to_update, unknown: true do
    tm_id = if Env.params[:tinymce_id].present?
              "\"#{Env.params[:tinymce_id]}\""
            else
              '$(".tinymce-textarea").attr("id")'
            end
    <<-JAVASCRIPT.strip_heredoc
      nest.changeCreateToUpdate(#{tm_id});
    JAVASCRIPT
  end

  view :open_nest_editor, unknown: true do
    tm_id = if Env.params[:tinymce_id].present?
              "\"#{Env.params[:tinymce_id]}\""
            else
              '$(".tinymce-textarea").attr("id")'
            end
    <<-JAVASCRIPT.strip_heredoc
      tm = tinymce.get(#{tm_id});
      nest.insertNest(tm, "{{+#{card.name.tag}|size: medium}}");
    JAVASCRIPT
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
card-1.99.6 mod/tinymce_editor/set/all/reference_editor/nest_image.rb
card-1.99.5 mod/tinymce_editor/set/all/reference_editor/nest_image.rb
card-1.99.4 mod/tinymce_editor/set/all/reference_editor/nest_image.rb
card-1.99.3 mod/tinymce_editor/set/all/reference_editor/nest_image.rb
card-1.99.2 mod/tinymce_editor/set/all/reference_editor/nest_image.rb