Sha256: 60669f87be12785517bf14e453668c0e47f250bcd1c90790327f40fa3b55ed07

Contents?: true

Size: 1.44 KB

Versions: 14

Compression:

Stored size: 1.44 KB

Contents

@RedactorPlugins ?= {}

$ ->
  RedactorPlugins.scrivito_editors_link_manager = -> self =
    init: ->
      @modal.addTemplate 'scrivito_link_manager_browse', self.browseButtonHtml
      @modal.addTemplate 'scrivito_link_manager_url', '/$id'
      @modal.addCallback 'imageEdit', self.addBrowseToModal
      @modal.addCallback 'link', self.addBrowseToModal

    browseButtonHtml: """
      <button class="editing-button editing-green">
        <i class="editing-icon editing-icon-search"></i>
        Browse
      </button>
    """

    urlInput: ->
      @modal.getModal().find '#redactor-link-url, #redactor-image-link'

    addBrowseToModal: ->
      self.urlInput()
        .wrap '<div id="scrivito-link-manager-url"></div>'
        .after @modal.getTemplate 'scrivito_link_manager_browse'
        .siblings 'button'
        .on 'click', self.browse

    browse: ->
      scrivito.content_browser.open
        filter: @$element.data('filter')
        filter_context: @$element.data('filterContext')
        selection: self.getObjIds()
        selection_mode: 'single'
      .done (selection) =>
        id = selection[0]
        self.setObjId id if id?

    getObjIds: ->
      matches = self.urlInput()
        .val()
        .match(/[\/:]([a-f0-9]{16})\b/)
      if matches? then [matches[1]] else []

    setObjId: (id) ->
      self.urlInput()
        .val self.toUrl id

    toUrl: (id) ->
      @modal.getTemplate('scrivito_link_manager_url').replace("$id", id)

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
scrivito_editors-0.70.2 app/assets/javascripts/scrivito_editors/redactor_plugins/scrivito_editors_link_manager.js.coffee
scrivito_editors-0.71.2 app/assets/javascripts/scrivito_editors/redactor_plugins/scrivito_editors_link_manager.js.coffee
scrivito_editors-0.71.1 app/assets/javascripts/scrivito_editors/redactor_plugins/scrivito_editors_link_manager.js.coffee
scrivito_editors-0.70.1 app/assets/javascripts/scrivito_editors/redactor_plugins/scrivito_editors_link_manager.js.coffee
scrivito_editors-0.71.0 app/assets/javascripts/scrivito_editors/redactor_plugins/scrivito_editors_link_manager.js.coffee
scrivito_editors-0.71.0.rc2 app/assets/javascripts/scrivito_editors/redactor_plugins/scrivito_editors_link_manager.js.coffee
scrivito_editors-0.71.0.rc1 app/assets/javascripts/scrivito_editors/redactor_plugins/scrivito_editors_link_manager.js.coffee
scrivito_editors-0.70.0 app/assets/javascripts/scrivito_editors/redactor_plugins/scrivito_editors_link_manager.js.coffee
scrivito_editors-0.70.0.rc3 app/assets/javascripts/scrivito_editors/redactor_plugins/scrivito_editors_link_manager.js.coffee
scrivito_editors-0.70.0.rc2 app/assets/javascripts/scrivito_editors/redactor_plugins/scrivito_editors_link_manager.js.coffee
scrivito_editors-0.70.0.rc1 app/assets/javascripts/scrivito_editors/redactor_plugins/scrivito_editors_link_manager.js.coffee
scrivito_editors-0.66.0 app/assets/javascripts/scrivito_editors/redactor_plugins/scrivito_editors_link_manager.js.coffee
scrivito_editors-0.66.0.rc2 app/assets/javascripts/scrivito_editors/redactor_plugins/scrivito_editors_link_manager.js.coffee
scrivito_editors-0.66.0.rc1 app/assets/javascripts/scrivito_editors/redactor_plugins/scrivito_editors_link_manager.js.coffee