Sha256: b23200a848b1e50c28d565a46e2ab3b1e039a86e559cde95eeb8a1677ffbd6c5

Contents?: true

Size: 1.23 KB

Versions: 18

Compression:

Stored size: 1.23 KB

Contents

@app.directive 'ptConfirmReveal', ->
  ($scope, $el, $attrs) ->
    # Options
    defaults =
      title:  'Are you sure?'
      body:   'This action cannot be undone.'
    option = (name) -> $el.data(name) || defaults[name]

    # Define modal
    $modal = $("""
      <div data-reveal class="reveal-modal small">
        <h2 pt-title></h2>
        <p pt-body></p>
        <div>
          <button class="button alert" pt-confirm>OK</button>
          <button class="button secondary" pt-cancel>Cancel</button>
        </div>
      </div>
    """)

    $modal.find('[pt-title]').html option('title')
    $modal.find('[pt-body]').html option('body')

    # Define confirm callback
    callbackFn = new Function('$scope', "$scope.#{ $attrs.ptConfirmReveal }")

    # Bind events
    $modal.find('[pt-confirm]').on 'click', (e) ->
      e.preventDefault()
      callbackFn($scope)
      $modal.foundation('reveal', 'close')
    $modal.find('[pt-cancel]').on 'click', (e) ->
      e.preventDefault()
      $modal.foundation('reveal', 'close')

    # Reveal the modal
    $el.on 'click', (e) ->
      e.preventDefault()
      $modal
        .appendTo('body')
        .foundation('reveal', 'open')
        .on 'closed.fndtn.reveal', (e) ->
          $modal.remove()

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
push_type_admin-0.7.0 app/assets/javascripts/push_type/directives.js.coffee
push_type_admin-0.7.0.beta.1 app/assets/javascripts/push_type/directives.js.coffee
push_type_admin-0.6.0 app/assets/javascripts/push_type/directives.js.coffee
push_type_admin-0.6.0.beta.4 app/assets/javascripts/push_type/directives.js.coffee
push_type_admin-0.6.0.beta.3 app/assets/javascripts/push_type/directives.js.coffee
push_type_admin-0.6.0.beta.2 app/assets/javascripts/push_type/directives.js.coffee
push_type_admin-0.6.0.beta.1 app/assets/javascripts/push_type/directives.js.coffee
push_type_admin-0.5.3 app/assets/javascripts/push_type/directives.js.coffee
push_type_admin-0.5.2 app/assets/javascripts/push_type/directives.js.coffee
push_type_admin-0.5.1 app/assets/javascripts/push_type/directives.js.coffee
push_type_admin-0.5.0 app/assets/javascripts/push_type/directives.js.coffee
push_type_admin-0.5.0.alpha.5 app/assets/javascripts/push_type/directives.js.coffee
push_type_admin-0.5.0.alpha.4 app/assets/javascripts/push_type/directives.js.coffee
push_type_admin-0.5.0.alpha.3 app/assets/javascripts/push_type/directives.js.coffee
push_type_admin-0.5.0.alpha.2 app/assets/javascripts/push_type/directives.js.coffee
push_type_admin-0.5.0.alpha.1 app/assets/javascripts/push_type/directives.js.coffee
push_type_admin-0.4.0 app/assets/javascripts/push_type/directives.js.coffee
push_type_admin-0.4.0.beta.3 app/assets/javascripts/push_type/directives.js.coffee