Sha256: 075964419ed42a1bc46f24e8775dbe57d6d95815620140bb6c80b86c5670b94a

Contents?: true

Size: 1.42 KB

Versions: 6

Compression:

Stored size: 1.42 KB

Contents

class @TypeStation.AdminBarEditor
  constructor: (@ts, @$el, @data) ->
    template = @$el.html()
    $('body').append(template)
    vex.defaultOptions.className = 'vex-theme-os'

    $('#ts-admin-bar-edit').on 'click', =>
      @ts.enable()
      false

    $('#ts-admin-bar-cancel').on 'click', =>
      @ts.disable()
      if @ts.isChanged()
        vex.dialog.confirm
          message: 'You have unsaved changes, Do you want to discard them?'
          callback: (value) ->
            if value
              window.location.reload()
      false

    $('#ts-admin-bar-save').on 'click', =>
      vex.dialog.confirm
        message: 'Are you sure you want to save changes?'
        callback: (value) =>
          if value
            @ts.save()
      false


    $titleEditor = $('#ts-admin-bar-title')
    if $titleEditor.length > 0
      editor = new TypeStation.TextHtmlEditor(@ts, $titleEditor, $titleEditor.data('ts'))
      @ts.editors.set $titleEditor.attr('id'), editor

    $editEditor = $('#ts-admin-bar-settings')
    if $editEditor.length > 0
      editor = new TypeStation.EntityEditor(@ts, $editEditor, $editEditor.data('ts'))
      @ts.editors.set $editEditor.attr('id'), editor

  enable: ->
    $('#ts-admin-bar').removeClass('ts-hidden')
    $('#ts-admin-bar-edit').addClass('ts-hidden')

  disable: ->
    $('#ts-admin-bar').addClass('ts-hidden').removeClass 'insert-open'
    $('#ts-admin-bar-edit').removeClass('ts-hidden')

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
type_station-0.4.7 app/assets/javascripts/type_station/editables/admin_bar.js.coffee
type_station-0.4.6 app/assets/javascripts/type_station/editables/admin_bar.js.coffee
type_station-0.4.5 app/assets/javascripts/type_station/editables/admin_bar.js.coffee
type_station-0.4.4 app/assets/javascripts/type_station/editables/admin_bar.js.coffee
type_station-0.4.3 app/assets/javascripts/type_station/editables/admin_bar.js.coffee
type_station-0.4.2 app/assets/javascripts/type_station/editables/admin_bar.js.coffee