Sha256: fec860baf20b78f66c92763d7c0b9323027490b6588e91c46086acedca4530b1

Contents?: true

Size: 987 Bytes

Versions: 6

Compression:

Stored size: 987 Bytes

Contents

/**
 * @ngdoc directive
 * @name Bastion.components.directive:bstAlert
 *
 * @requires $animate
 * @requires $timeout
 *
 * @description
 *   Simple directive for encapsulating an alert display.
 *
 * @example
 *   <pre>
 *     <div bst-alert="success"></div>
 *   </pre>
 */
angular.module('Bastion.components').directive('bstAlert', ['$animate', '$timeout', function ($animate, $timeout) {
    var SUCCESS_FADEOUT = 3000;

    return {
        templateUrl: 'components/views/bst-alert.html',
        transclude: true,
        scope: {
            type: '@bstAlert',
            close: '&'
        },
        link: function (scope, element, attrs) {
            scope.closeable = 'close' in attrs;

            // Fade out success alerts after five seconds
            if (scope.type === 'success') {
                $timeout(function () {
                    $animate.leave(element.find('.alert'), scope.close);
                }, SUCCESS_FADEOUT);
            }
        }
    };
}]);

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
bastion-3.3.4 app/assets/javascripts/bastion/components/bst-alert.directive.js
bastion-3.3.3 app/assets/javascripts/bastion/components/bst-alert.directive.js
bastion-3.3.2 app/assets/javascripts/bastion/components/bst-alert.directive.js
bastion-3.3.1 app/assets/javascripts/bastion/components/bst-alert.directive.js
bastion-3.3.0 app/assets/javascripts/bastion/components/bst-alert.directive.js
bastion-3.2.2 app/assets/javascripts/bastion/components/bst-alert.directive.js