Sha256: 2d8d59df4cc91b3fee1c35dd2203de599c52e5762e3040cb2741728e29ce6a8b

Contents?: true

Size: 1.06 KB

Versions: 10

Compression:

Stored size: 1.06 KB

Contents

#= require ../shared/form_view

Locomotive.Views.MyAccount ||= {}

class Locomotive.Views.MyAccount.EditView extends Locomotive.Views.Shared.FormView

  el: '.main'

  events:
    'click .api_key.input button':  'regenerate_api_key'
    'submit form':                  'save'

  initialize: ->

  render: ->
    @render_locale_select()

    super()

  regenerate_api_key: (event) ->
    event.stopPropagation() & event.preventDefault()

    button = $(event.target)

    if confirm(button.data('confirm'))
      $.rails.ajax
        url:        button.data('url')
        type:       'put'
        dataType:   'json'
        success:    (data) =>
          button.prev('code').html(data.api_key)

  render_locale_select: ->
    @$('.locomotive_account_locale.input select').select2
      formatResult:     @format_locale
      formatSelection:  @format_locale
      escapeMarkup:     (m) -> { m }

  format_locale: (state) ->
    return state.text unless state.id?

    flag_url = $(state.element).data('flag')

    "<img class='flag' src='#{flag_url}' width='24px' />" + state.text

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
locomotivecms-3.0.0.rc6 app/assets/javascripts/locomotive/views/my_account/edit_view.js.coffee
locomotivecms-3.0.0.rc5 app/assets/javascripts/locomotive/views/my_account/edit_view.js.coffee
locomotivecms-3.0.0.rc4 app/assets/javascripts/locomotive/views/my_account/edit_view.js.coffee
locomotivecms-3.0.0.rc3 app/assets/javascripts/locomotive/views/my_account/edit_view.js.coffee
locomotivecms-3.0.0.rc2 app/assets/javascripts/locomotive/views/my_account/edit_view.js.coffee
locomotivecms-3.0.0.rc1 app/assets/javascripts/locomotive/views/my_account/edit_view.js.coffee
locomotivecms-3.0.0.pre.beta.1 app/assets/javascripts/locomotive/views/my_account/edit_view.js.coffee
locomotivecms-3.0.0.pre.alpha.3 app/assets/javascripts/locomotive/views/my_account/edit_view.js.coffee
locomotivecms-3.0.0.pre.alpha.2 app/assets/javascripts/locomotive/views/my_account/edit_view.js.coffee
locomotivecms-3.0.0.pre.alpha app/assets/javascripts/locomotive/views/my_account/edit_view.js.coffee