Sha256: e07491cb8b9184d80154b35d6137f27e66025be4a418bd708757c5ae8ac636aa

Contents?: true

Size: 1.04 KB

Versions: 20

Compression:

Stored size: 1.04 KB

Contents

$(document).bind 'confirm', (event) ->
  element = $(event.target)
  message = element.data("confirm")
  title = element.data("confirm-title")
  confirm_dialog = """
    <div class="ui-confirm-dialog ui small modal">
      <div class="header">#{title}</div>
      <div class="content">#{message}</div>
      <div class="actions">
        <div class="ui red basic cancel button">
          <i class="remove icon"></i>No
        </div>
        <div class="ui green ok button">
          <i class="checkmark icon"></i>Yes
        </div>
      </div>
    </div>
  """
  # remove old confirm dialog from the body
  $('.ui-confirm-dialog').parent().remove()
  # attach new confirm dialog to the body
  $('body').append(confirm_dialog)
  $('.ui-confirm-dialog').modal(
    closable: false
    duration: 100
    transition: 'fade'
    onApprove: ->
# remove data-confirm
      element.data 'confirm', null
      # re-click link
      element.trigger 'click.rails'
  ).modal('show')
  # Prevent rails from popping up a browser box, we've already done the work
  return false

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
semantic-rails-ui-1.0.5 app/assets/javascripts/semantic-rails-ui/confirm.coffee
semantic-rails-ui-1.0.4 app/assets/javascripts/semantic-rails-ui/confirm.coffee
semantic-rails-ui-0.3.0 app/assets/javascripts/semantic-rails-ui/confirm.coffee
semantic-rails-ui-0.2.5 app/assets/javascripts/semantic-rails-ui/confirm.coffee
semantic-rails-ui-0.2.4 app/assets/javascripts/semantic-rails-ui/confirm.coffee
semantic-rails-ui-0.2.3 app/assets/javascripts/semantic-rails-ui/confirm.coffee
semantic-rails-ui-0.2.2 app/assets/javascripts/semantic-rails-ui/confirm.coffee
semantic-rails-ui-0.2.1 app/assets/javascripts/semantic-rails-ui/confirm.coffee
semantic-rails-ui-0.2.0 app/assets/javascripts/semantic-rails-ui/confirm.coffee
semantic-rails-ui-0.1.0 app/assets/javascripts/semantic-rails-ui/confirm.coffee
semantic-rails-ui-0.0.20 app/assets/javascripts/semantic-rails-ui/confirm.coffee
semantic-rails-ui-0.0.19 app/assets/javascripts/semantic-rails-ui/confirm.coffee
semantic-rails-ui-0.0.18 app/assets/javascripts/semantic-rails-ui/confirm.coffee
semantic-rails-ui-0.0.17 app/assets/javascripts/semantic-rails-ui/confirm.coffee
semantic-rails-ui-0.0.16 app/assets/javascripts/semantic-rails-ui/confirm.coffee
semantic-rails-ui-0.0.15 app/assets/javascripts/semantic-rails-ui/confirm.coffee
semantic-rails-ui-0.0.14 app/assets/javascripts/semantic-rails-ui/confirm.coffee
semantic-rails-ui-0.0.13 app/assets/javascripts/semantic-rails-ui/confirm.coffee
semantic-rails-ui-0.0.12 app/assets/javascripts/semantic-rails-ui/confirm.coffee
semantic-rails-ui-0.0.11 app/assets/javascripts/semantic-rails-ui/confirm.coffee