<commit_before>/**
 * Created by moustafabaiou on 3/16/17.
 */
(function () {
    'use strict';

    angular.module('vbr-style-guide')
        .directive('vbrInput',

            function (TEMPLATES) {
                var directive = {
                    bindToController: true,
                    controller: InputCtrl,
                    controllerAs: 'vm',
                    link: link,
                    restrict: 'E',
                    scope: {
                        ngModel: '=',
                        type: '@',
                        form: '=',
                        ngRequired: '=?',
                        ngChange: '&?',
                        ngMinlength: '=?',
                        ngMaxlength: '=?',
                        ngPattern: '=?',
                        ngTrim: '=?',
                        ngDisabled: '=?',
                        inputId: '@?id',
                        label: '@?',
                        placeholder: '@?',
                        validations: '=?',
                        tooltip: '=?'
                    },
                    templateUrl: TEMPLATES + '/vbr-input/input.html'
                };
                return directive;

                function link(scope, element, attrs) {

                }
            });

    InputCtrl.$inject = [];

    /* @ngInject */
    function InputCtrl() {
        var vm = this;


        if(vm.validations){
            angular.forEach(vm.validations, function (error, key) {
                if(typeof (error.message) === 'string' && error.message.length > 0){
                    vm.validations[key].key = key;
                }
            })
        }

        vm.errorClass = function () {
            if (!vm.ngDisabled && vm.validations) {
                return vm.form[vm.inputId].$invalid && (vm.form[vm.inputId].$dirty || vm.form.$submitted)
            } else {
                return vm.form[vm.inputId].$invalid;
            }
        };

        vm.errorsVisible = false;

        vm.focused = function () {
            if(vm.errorsVisible){
                vm.errorsVisible = false;
            }
        };

        vm.blurred = function () {
            if(!vm.errorsVisible){
                vm.errorsVisible = true;
            }
        };


        vm.shouldShowErrors = function () {
            return vm.errorsVisible  && vm.form.$invalid && vm.form[vm.inputId].$invalid && (vm.form[vm.inputId].$dirty ||vm.form.$submitted);
        };

    }

})();
<commit_msg>Feature(Input)<commit_after>/**
 * Created by moustafabaiou on 3/16/17.
 */
(function () {
    'use strict';

    angular.module('vbr-style-guide')
        .directive('vbrInput',

            function (TEMPLATES) {
                var directive = {
                    bindToController: true,
                    controller: InputCtrl,
                    controllerAs: 'vm',
                    link: link,
                    restrict: 'E',
                    scope: {
                        ngModel: '=',
                        type: '@',
                        form: '=',
                        ngRequired: '=?',
                        ngChange: '&?',
                        ngBlur: '&?',
                        ngMinlength: '=?',
                        ngMaxlength: '=?',
                        ngPattern: '=?',
                        ngTrim: '=?',
                        ngDisabled: '=?',
                        inputId: '@?id',
                        label: '@?',
                        placeholder: '@?',
                        validations: '=?',
                        tooltip: '=?'
                    },
                    templateUrl: TEMPLATES + '/vbr-input/input.html'
                };
                return directive;

                function link(scope, element, attrs) {

                }
            });

    InputCtrl.$inject = [];

    /* @ngInject */
    function InputCtrl() {
        var vm = this;


        if(vm.validations){
            angular.forEach(vm.validations, function (error, key) {
                if(typeof (error.message) === 'string' && error.message.length > 0){
                    vm.validations[key].key = key;
                }
            })
        }

        vm.errorClass = function () {
            if (!vm.ngDisabled && vm.validations) {
                return vm.form[vm.inputId].$invalid && (vm.form[vm.inputId].$dirty || vm.form.$submitted)
            } else {
                return vm.form[vm.inputId].$invalid;
            }
        };

        vm.errorsVisible = false;

        vm.focused = function () {
            if(vm.errorsVisible){
                vm.errorsVisible = false;
            }
        };

        vm.blurred = function () {
            if(!vm.errorsVisible){
                vm.errorsVisible = true;
            }
            vm.ngBlur();
        };


        vm.shouldShowErrors = function () {
            return vm.errorsVisible  && vm.form.$invalid && vm.form[vm.inputId].$invalid && (vm.form[vm.inputId].$dirty ||vm.form.$submitted);
        };

    }

})();

{'fraction_non_alphanumeric': 0.13535911602209943, 'fraction_numerical': 0.0023677979479084454, 'mean_word_length': 1.0091161315893777, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7656658', 'n_tokens_mistral': 1397, 'n_tokens_neox': 1272, 'n_words': 206}