Sha256: 129935a4fb69b5b04ce2706284bc7d79a1eb223df4499cfc4d2c52d49bd45637

Contents?: true

Size: 1.52 KB

Versions: 45

Compression:

Stored size: 1.52 KB

Contents

/**
 * @ngdoc directive
 * @name Bastion.components.directive:bstAlerts
 *
 * @description
 *   Simple directive for encapsulating alert displays.
 *
 * @example
 *   <pre>
 *     <div bst-alerts
 *          successMessages="successMessages"
 *          errorMessages="errorMessages">
 *     </div>
 */
angular.module('Bastion.components').directive('bstAlerts', function () {
    return {
        templateUrl: 'components/views/bst-alerts.html',
        scope: {
            successMessages: '=',
            infoMessages: '=',
            warningMessages: '=',
            errorMessages: '='
        },

        link: function (scope) {
            scope.alerts = {};
            scope.types = ['success', 'info', 'warning', 'danger'];

            function handleMessages(type, messages) {
                scope.alerts[type] = messages;
            }

            scope.$watch('successMessages', function (messages) {
                handleMessages('success', messages);
            }, true);

            scope.$watch('infoMessages', function (messages) {
                handleMessages('info', messages);
            }, true);

            scope.$watch('warningMessages', function (messages) {
                handleMessages('warning', messages);
            }, true);

            scope.$watch('errorMessages', function (messages) {
                handleMessages('danger', messages);
            }, true);

            scope.closeAlert = function (type, index) {
                scope.alerts[type].splice(index, 1);
            };
        }
    };
});

Version data entries

45 entries across 45 versions & 1 rubygems

Version Path
bastion-5.1.1 app/assets/javascripts/bastion/components/bst-alerts.directive.js
bastion-5.1.0 app/assets/javascripts/bastion/components/bst-alerts.directive.js
bastion-5.0.10 app/assets/javascripts/bastion/components/bst-alerts.directive.js
bastion-5.0.9 app/assets/javascripts/bastion/components/bst-alerts.directive.js
bastion-5.0.8 app/assets/javascripts/bastion/components/bst-alerts.directive.js
bastion-5.0.7 app/assets/javascripts/bastion/components/bst-alerts.directive.js
bastion-5.0.6 app/assets/javascripts/bastion/components/bst-alerts.directive.js
bastion-5.0.5 app/assets/javascripts/bastion/components/bst-alerts.directive.js
bastion-5.0.4 app/assets/javascripts/bastion/components/bst-alerts.directive.js
bastion-5.0.3 app/assets/javascripts/bastion/components/bst-alerts.directive.js
bastion-5.0.2 app/assets/javascripts/bastion/components/bst-alerts.directive.js
bastion-5.0.1 app/assets/javascripts/bastion/components/bst-alerts.directive.js
bastion-5.0.0 app/assets/javascripts/bastion/components/bst-alerts.directive.js
bastion-4.3.1 app/assets/javascripts/bastion/components/bst-alerts.directive.js
bastion-4.3.0 app/assets/javascripts/bastion/components/bst-alerts.directive.js
bastion-4.2.2 app/assets/javascripts/bastion/components/bst-alerts.directive.js
bastion-4.2.1 app/assets/javascripts/bastion/components/bst-alerts.directive.js
bastion-4.2.0 app/assets/javascripts/bastion/components/bst-alerts.directive.js
bastion-4.1.0 app/assets/javascripts/bastion/components/bst-alerts.directive.js
bastion-4.0.0 app/assets/javascripts/bastion/components/bst-alerts.directive.js