Sha256: 90704ae279f8e4332ea767d226e00a7b217f888b06321f248aeaa807acc77f12

Contents?: true

Size: 927 Bytes

Versions: 2

Compression:

Stored size: 927 Bytes

Contents

dialogs = angular.module("mb.dialogs", [])

# Simple wrapper for http://bootboxjs.com library
#
# Usage:
# handler.confirm "the message", (confirmed) ->
#   doSomething() if confirmed
dialogs.factory "dialogsHandler", -> bootbox

dialogs.factory "confirmationDialog", [
  "$log", "dialogsHandler", ($log, handler) ->

    # Options:
    #  message  - a message to display inside the dialog
    #             default: "Are you sure?"
    #  onOk     - a handler for Ok button
    #  onCancel - a handler for Cancel button
    (options = {}) ->
      options.message ||= "Are you sure?"
      $log.info("Displaying confirmation dialog:", options.message)

      handler.confirm options.message, (confirmed) ->
        if confirmed
          $log.info("Confirmation dialog was confirmed")
          (options.onOk || ->)()
        else
          $log.info("Confirmation dialog was disposed")
          (options.onCancel || ->)()
]

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mongo_browser-0.2.5 app/assets/javascripts/app/modules/dialogs.js.coffee
mongo_browser-0.2.0.rc2 app/assets/javascripts/app/modules/dialogs.js.coffee