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