Skip to content

Commit

Permalink
Add option to disable backdrop. Fixes #39
Browse files Browse the repository at this point in the history
  • Loading branch information
mpowaga committed Mar 27, 2015
1 parent 5f9c9dd commit 2c45cc0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ inputColClass='col-sm-9'
```
* ```placeholder``` set to true if you wish to use the schema label for the input placeholder.
* ```formId``` defines id of the `quickForm` template. Useful when you want to set your custom autoform hooks.
* ```backdrop``` disables or enables modal-backdrop. Defaults to true (modal can be dismissed by mouse click). To disable use 'static' value. (See more [here](http://getbootstrap.com/javascript/#modals-options))

## Callbacks/Hooks ##
It's possible to add your own autoform [callbacks/hooks](https://github.com/aldeed/meteor-autoform#callbackshooks) by setting the `formId`.
11 changes: 8 additions & 3 deletions lib/client/modals.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ collectionObj = (name) ->
, window

Template.autoformModals.rendered = ->
$('#afModal').modal(show: false)

onEscKey = (e) ->
if e.keyCode == 27
$('#afModal').modal 'hide'
Expand All @@ -35,7 +37,7 @@ Template.autoformModals.rendered = ->

$('#afModal').on 'hidden.bs.modal', ->
$(window).unbind 'keyup', onEscKey

sessionKeys = [
'cmCollection',
'cmOperation',
Expand All @@ -50,7 +52,7 @@ Template.autoformModals.rendered = ->
'cmTemplate',
'cmLabelClass',
'cmInputColClass',
'cmPlaceholder'
'cmPlaceholder',
]
delete Session.keys[key] for key in sessionKeys

Expand Down Expand Up @@ -159,4 +161,7 @@ Template.afModal.events
else if t.data.operation == 'remove'
Session.set 'cmPrompt', 'Are you sure?'
else
Session.set 'cmPrompt', ''
Session.set 'cmPrompt', ''

$('#afModal').data('bs.modal').options.backdrop = t.data.backdrop or true
$('#afModal').modal 'show'
2 changes: 1 addition & 1 deletion lib/client/modals.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ <h4 class="modal-title">{{{title}}}</h4>
</template>

<template name="afModal">
<a href="#afModal" class="{{class}}" data-toggle="modal" collection="{{collection}}" operation="{{operation}}">
<a href="#afModal" class="{{class}}" collection="{{collection}}" operation="{{operation}}">
{{> UI.contentBlock}}
</a>
</template>

0 comments on commit 2c45cc0

Please sign in to comment.