Sha256: 4e175f4ac3f360c2722b01447be274af910eb775905cec992b1593a3e2ad7556

Contents?: true

Size: 1.35 KB

Versions: 6

Compression:

Stored size: 1.35 KB

Contents

<%
  require 'smalruby_editor'
  require 'smalruby_editor/blockly_message_helper'
%>

# signin dialog view
Smalruby.SigninModalView = Backbone.View.extend
  events:
    'click #signin-modal-ok-button': 'onOk' # FIXME: 本当は#signin-modal .ok-buttonを指定したいができなかった

  initialize: ->
    Smalruby.ignoreEnterKey(@$el)
    @$el.on 'shown', =>
      @$el.find('#signin-modal-username')
        .focus()

  render: ->
    @$el.find('#signin-modal-username')
      .val($('#username-label').text())
    @$el.modal
      backdrop: 'static'
    @$el.modal('show')

  onOk: (e) ->
    username = @$el.find('input[name=username]').val()
    if $.trim(username).length > 0
      $.post('/sessions/', { username: username })
        .then(
          (data) ->
            Smalruby.setPreferences(data)
            Smalruby.username = username
            $('#signin-button').hide()
            $('.signed-in-menu').show()
            $('#username-label').text(username)
            $('#username-button').show()
            successMessage(<%= bm('.signed_in') %>)
            new $.Deferred().resolve().promise()
          ->
            errorMessage(<%= bm('.error') %>)
            new $.Deferred().resolve().promise()
        )
        .done =>
          if Smalruby.username != null || !Smalruby.isEnabled('enabled_must_signin')
            @$el.modal('hide')

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
smalruby-editor-0.3.1-x86-mingw32 app/assets/javascripts/views/signin_modal_view.js.coffee.erb
smalruby-editor-0.3.1 app/assets/javascripts/views/signin_modal_view.js.coffee.erb
smalruby-editor-0.3.0-x86-mingw32 app/assets/javascripts/views/signin_modal_view.js.coffee.erb
smalruby-editor-0.3.0 app/assets/javascripts/views/signin_modal_view.js.coffee.erb
smalruby-editor-0.2.7-x86-mingw32 app/assets/javascripts/views/signin_modal_view.js.coffee.erb
smalruby-editor-0.2.7 app/assets/javascripts/views/signin_modal_view.js.coffee.erb