Sha256: 0111b0a16fdb07eedba71766afd48413a9b29962bfeca7f2029e4a19bb6f40ee

Contents?: true

Size: 1.37 KB

Versions: 3

Compression:

Stored size: 1.37 KB

Contents

class window.TS.EditableText
  constructor: (@elements) ->
    @editor = new MediumEditor @elements,
      disableReturn: true
      buttons: ['bold', 'italic', 'underline', 'anchor']
    @editor.deactivate()

  enable: ->
    @editor.activate()
    @elements.on 'input', ->
      model = window.TS.getModel $(@).data('ts-edit-url')
      if $(@).is(':input')
        model.set($(@).data('ts-field'), { field: $(@).data('ts-field'), value: $(@).val(), type: 'text' })
      else
        model.set($(@).data('ts-field'), { field: $(@).data('ts-field'), value: $(@).html(), type: 'text' })

  disable: ->
    @editor.deactivate()
    @elements.off 'input'


class window.TS.EditableHtml
  constructor: (@elements) ->
    @editor = new MediumEditor @elements,
      buttons: ['bold', 'italic', 'underline', 'anchor', 'header1', 'header2', 'unorderedlist', 'orderedlist', 'justifyLeft', 'justifyFull', 'justifyCenter', 'justifyRight']
    @editor.deactivate()

  enable: ->
    @editor.activate()
    @elements.on 'input', ->
      model = window.TS.getModel $(@).data('ts-edit-url')
      if $(@).is(':input')
        model.set($(@).data('ts-field'), { field: $(@).data('ts-field'), value: $(@).val(), type: 'html' })
      else
        model.set($(@).data('ts-field'), { field: $(@).data('ts-field'), value: $(@).html(), type: 'html' })
  disable: ->
    @editor.deactivate()
    @elements.off 'input'

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
type_station-0.0.3 app/assets/javascripts/type_station/editables/text_html.js.coffee
type_station-0.0.2 app/assets/javascripts/type_station/editables/text_html.js.coffee
type_station-0.0.1 app/assets/javascripts/type_station/editables/text_html.js.coffee