Sha256: 737abe5b1a6f3384724aa6e73ef440ff0cf9f06a13b786cb903d383703ca38b3

Contents?: true

Size: 1.21 KB

Versions: 17

Compression:

Stored size: 1.21 KB

Contents

Locomotive.Views.EditableElements ||= {}

class Locomotive.Views.EditableElements.TextView extends Backbone.View

  tagName: 'li'

  className: 'text input html'

  default_line_height: 20

  render: ->
    $(@el).html(ich.editable_text_input(@model.toJSON()))

    return @

  after_render: ->
    if @model.get('format') == 'html'
      @$('textarea').tinymce(@tinymce_settings())
    else
      @$('textarea').bind 'keyup', (event) =>
        input = $(event.target)
        @model.set(content: input.val())

  tinymce_settings: ->
    base_settings = window.Locomotive.tinyMCE.defaultSettings

    if @model.get('line_break') == false
      base_settings = window.Locomotive.tinyMCE.minimalSettings

    _.extend {}, base_settings,
      height:   @model.get('rows') * @default_line_height
      oninit:   ((editor) =>
          $.cmd 'S', (() =>
            @model.set(content: editor.getContent())
            $(@el).parents('form').trigger('submit')
          ), [], ignoreCase: true, document: editor.dom.doc),
      onchange_callback: (editor) =>
        @model.set(content: editor.getContent())

  refresh: ->
    # do nothing

  remove: ->
    if @model.get('format') == 'html'
      @$('textarea').tinymce().remove()

    super

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
locomotive_cms-2.5.7 app/assets/javascripts/locomotive/views/editable_elements/text_view.js.coffee
locomotive_cms-2.5.6 app/assets/javascripts/locomotive/views/editable_elements/text_view.js.coffee
locomotive_cms-2.5.6.rc2 app/assets/javascripts/locomotive/views/editable_elements/text_view.js.coffee
locomotive_cms-2.5.6.rc1 app/assets/javascripts/locomotive/views/editable_elements/text_view.js.coffee
locomotive_cms-2.5.5 app/assets/javascripts/locomotive/views/editable_elements/text_view.js.coffee
locomotive_cms-2.5.4 app/assets/javascripts/locomotive/views/editable_elements/text_view.js.coffee
locomotive_cms-2.5.3 app/assets/javascripts/locomotive/views/editable_elements/text_view.js.coffee
locomotive_cms-2.5.2 app/assets/javascripts/locomotive/views/editable_elements/text_view.js.coffee
locomotive_cms-2.5.1 app/assets/javascripts/locomotive/views/editable_elements/text_view.js.coffee
locomotive_cms-2.5.0 app/assets/javascripts/locomotive/views/editable_elements/text_view.js.coffee
locomotive_cms-2.5.0.rc3 app/assets/javascripts/locomotive/views/editable_elements/text_view.js.coffee
locomotive_cms-2.5.0.rc2 app/assets/javascripts/locomotive/views/editable_elements/text_view.js.coffee
locomotive_cms-2.5.0.rc1 app/assets/javascripts/locomotive/views/editable_elements/text_view.js.coffee
locomotive_cms-2.4.1 app/assets/javascripts/locomotive/views/editable_elements/text_view.js.coffee
locomotive_cms-2.4.0 app/assets/javascripts/locomotive/views/editable_elements/text_view.js.coffee
locomotive_cms-2.3.1 app/assets/javascripts/locomotive/views/editable_elements/text_view.js.coffee
locomotive_cms-2.3.0 app/assets/javascripts/locomotive/views/editable_elements/text_view.js.coffee