Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

chore(modal): shorter events

  • Loading branch information...
commit f718e5ab486ba07abe671fc9ea9f0a4d2b220df8 1 parent eace094
@mgcrea authored
Showing with 7 additions and 10 deletions.
  1. +7 −10 src/directives/modal.js
View
17 src/directives/modal.js
@@ -39,20 +39,17 @@ angular.module('$strap.directives')
};
scope.dismiss = scope.hide;
- $modal.on('show', function(event) {
- scope.$emit('modal-show', event);
+ // Emit modal events
+ angular.forEach(['show', 'shown', 'hide', 'hidden'], function(name) {
+ $modal.on(name, function(ev) {
+ scope.$emit('modal-' + name, ev);
+ });
});
+
+ // Support autofocus attribute
$modal.on('shown', function(event) {
- scope.$emit('modal-shown', event);
- // Support autofocus attribute
$('input[autofocus]', $modal).first().trigger('focus');
});
- $modal.on('hide', function(event) {
- scope.$emit('modal-hide', event);
- });
- $modal.on('hidden', function(event) {
- scope.$emit('modal-hidden', event);
- });
if(options.show) {
$modal.modal('show');
Please sign in to comment.
Something went wrong with that request. Please try again.