<commit_before>'use strict';

angular.module('psui-datepicker', [])
.directive('psuiDatepicker', ['$timeout', '$compile','$translate', function ($timeout, $compile, $translate) {
	return {
		restrict: 'AE',
		scope: {
			ngModel: "=?"
		},
		require: ['?ngModel'],
		link: function(scope, elm, attrs, ctrls) {
		
		
			var ngModel = null;
			if (ctrls && ctrls[0]) {
				ngModel = ctrls[0];
			}

			// use empty function to commit data, it will be overriden if there is ngModel
			var commitData = function() {
			}
			
			var commitDataDiv = function() {
			}

			if (ngModel) {
				commitData = function() {
					ngModel.$setViewValue(elm.val());
				}
				
				commitDataDiv = function() {
					ngModel.$setViewValue(elm.text());
				}
			}
		
		
		
		
		
		
			var wrapper;
			var isDropdownVisible = false;
			var state = 0;
			// create base html elements
			if (elm.parent().hasClass('psui-wrapper')) {
				// element is wrapped, we are going to use this wrapper
				wrapper = elm.parent();
			} else {
				// there is no wrapper, we have to create one
				wrapper = angular.element('<div class="psui-wrapper"></div>');
				elm.wrap(wrapper);
			}
			
			if (elm.nodeName === "psui-datepicker") {
				// we are element
			} else {
				// we are attribute
			}

			elm.addClass('psui-datepicker');
			var dropdown = angular.element('<div class="psui-dropdown psui-hidden"></div>');
			wrapper.append(dropdown);
			
			dropdown.addClass('psui-datepicker-dropdown');
			
			dropdown.attr('tabindex',0);
			var buttonsHolder = angular.element('<div class="psui-buttons-holder"></div>');
			wrapper.append(buttonsHolder);
			
			var buttonShowDropdown = angular.element('<button class="btn psui-icon-calendar"></button>');
			buttonsHolder.append(buttonShowDropdown);
    
			var dropdownHide = function() {
				dropdown.addClass('psui-hidden');
			};
			
			var hideDropdown;
			
			dropdown.on('focus',function(evt){		
				$timeout.cancel(hideDropdown);
				hideDropdown = null;
				dropdown.removeClass('psui-hidden');
			})
			
			dropdown.on('blur',function(evt){
				//dropdown.addClass('psui-hidden');
				hideDropdown = $timeout(dropdownHide, 3, false);
			})
			
			elm.on('blur',function(evt){
				hideDropdown = $timeout(dropdownHide, 3, false);
				
				state=0;
			})
			
			elm.on('focus',function(evt){
				dropdown.addClass('psui-hidden');
				state=1;
			})
			
			elm.on('click',function(evt){
				if (state =1){
					dropdown.addClass('psui-hidden');
				}
			})
			
			buttonShowDropdown.on('blur',function(evt){
				hideDropdown = $timeout(dropdownHide, 3, false);
			})
			
			var selDate;
			
			buttonShowDropdown.on('click', function(evt) {
				if(hideDropdown>0){
					$timeout.cancel(hideDropdown);
					hideDropdown = null;
					dropdown.removeClass('psui-hidden');
				}
				
				if (dropdown.hasClass('psui-hidden')) {
					dropdown.removeClass('psui-hidden');
					if (elm.val()){
						var arr = elm.val().split(".");
						if((arr[0] && arr[1] && arr[2]) && arr[0]>0 && arr[0]<32 && arr[1]>0 && arr[1]<13){
							scope.$apply(function(){
								arr[1]= arr[1]-1;
								var datum = new Date(arr[2], arr[1], arr[0]);
								selDate = new Date(datum.getTime());
								dateTbody.empty();
								makeDateTable(datum);
								});
						}
					}
					
				} else {
					dropdown.addClass('psui-hidden');
					console.log('alb');
				}
			});
			
			elm.on('dblclick', function(evt){
				if (dropdown.hasClass('psui-hidden')) {
					if(elm.val()){
						var arr = elm.val().split(".");
						if((arr[0] && arr[1] && arr[2]) && arr[0]>0 && arr[0]<32 && arr[1]>0 && arr[1]<13){
							scope.$apply(function(){
								arr[1]= arr[1]-1;
								var datum = new Date(arr[2], arr[1], arr[0]);
								selDate = new Date(datum.getTime());
								dateTbody.empty();
								makeDateTable(datum);
							});
						}<commit_msg>Datepicker dropdown icon cannot get focus anymore<commit_after>'use strict';

angular.module('psui-datepicker', [])
.directive('psuiDatepicker', ['$timeout', '$compile','$translate', function ($timeout, $compile, $translate) {
	return {
		restrict: 'AE',
		scope: {
			ngModel: "=?"
		},
		require: ['?ngModel'],
		link: function(scope, elm, attrs, ctrls) {
		
		
			var ngModel = null;
			if (ctrls && ctrls[0]) {
				ngModel = ctrls[0];
			}

			// use empty function to commit data, it will be overriden if there is ngModel
			var commitData = function() {
			}
			
			var commitDataDiv = function() {
			}

			if (ngModel) {
				commitData = function() {
					ngModel.$setViewValue(elm.val());
				}
				
				commitDataDiv = function() {
					ngModel.$setViewValue(elm.text());
				}
			}
		
		
		
		
		
		
			var wrapper;
			var isDropdownVisible = false;
			var state = 0;
			// create base html elements
			if (elm.parent().hasClass('psui-wrapper')) {
				// element is wrapped, we are going to use this wrapper
				wrapper = elm.parent();
			} else {
				// there is no wrapper, we have to create one
				wrapper = angular.element('<div class="psui-wrapper"></div>');
				elm.wrap(wrapper);
			}
			
			if (elm.nodeName === "psui-datepicker") {
				// we are element
			} else {
				// we are attribute
			}

			elm.addClass('psui-datepicker');
			var dropdown = angular.element('<div class="psui-dropdown psui-hidden"></div>');
			wrapper.append(dropdown);
			
			dropdown.addClass('psui-datepicker-dropdown');
			
			dropdown.attr('tabindex',0);
			var buttonsHolder = angular.element('<div class="psui-buttons-holder"></div>');
			wrapper.append(buttonsHolder);
			
			var buttonShowDropdown = angular.element('<button class="btn psui-icon-calendar"></button>');
			buttonShowDropdown.attr('tabindex', -1);
			buttonsHolder.append(buttonShowDropdown);
    
			var dropdownHide = function() {
				dropdown.addClass('psui-hidden');
			};
			
			var hideDropdown;
			
			dropdown.on('focus',function(evt){		
				$timeout.cancel(hideDropdown);
				hideDropdown = null;
				dropdown.removeClass('psui-hidden');
			})
			
			dropdown.on('blur',function(evt){
				//dropdown.addClass('psui-hidden');
				hideDropdown = $timeout(dropdownHide, 3, false);
			})
			
			elm.on('blur',function(evt){
				hideDropdown = $timeout(dropdownHide, 3, false);
				
				state=0;
			})
			
			elm.on('focus',function(evt){
				dropdown.addClass('psui-hidden');
				state=1;
			})
			
			elm.on('click',function(evt){
				if (state =1){
					dropdown.addClass('psui-hidden');
				}
			})
			
			buttonShowDropdown.on('blur',function(evt){
				hideDropdown = $timeout(dropdownHide, 3, false);
			})
			
			var selDate;
			
			buttonShowDropdown.on('click', function(evt) {
				if(hideDropdown>0){
					$timeout.cancel(hideDropdown);
					hideDropdown = null;
					dropdown.removeClass('psui-hidden');
				}
				
				if (dropdown.hasClass('psui-hidden')) {
					dropdown.removeClass('psui-hidden');
					if (elm.val()){
						var arr = elm.val().split(".");
						if((arr[0] && arr[1] && arr[2]) && arr[0]>0 && arr[0]<32 && arr[1]>0 && arr[1]<13){
							scope.$apply(function(){
								arr[1]= arr[1]-1;
								var datum = new Date(arr[2], arr[1], arr[0]);
								selDate = new Date(datum.getTime());
								dateTbody.empty();
								makeDateTable(datum);
								});
						}
					}
					
				} else {
					dropdown.addClass('psui-hidden');
				}
			});
			
			elm.on('dblclick', function(evt){
				if (dropdown.hasClass('psui-hidden')) {
					if(elm.val()){
						var arr = elm.val().split(".");
						if((arr[0] && arr[1] && arr[2]) && arr[0]>0 && arr[0]<32 && arr[1]>0 && arr[1]<13){
							scope.$apply(function(){
								arr[1]= arr[1]-1;
								var datum = new Date(arr[2], arr[1], arr[0]);
								selDate = new Date(datum.getTime());
								dateTbody.empty();
								makeDateTable(datum);
							});
						}
{'fraction_non_alphanumeric': 0.17865877204273395, 'fraction_numerical': 0.012742952760973099, 'mean_word_length': 2.76271186440678, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 29, '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': '3289034', 'n_tokens_mistral': 3501, 'n_tokens_neox': 2582, 'n_words': 476}