<commit_before>/**
* @ngdoc directive
* @name umbraco.directives.directive:headline
**/
angular.module("umbraco.directives")
  .directive('hotkey', function ($window, keyboardService, $log) {

      return function (scope, el, attrs) {

          var options = {};
          var keyCombo = attrs.hotkey;

          if (!keyCombo) {
            //support data binding
            keyCombo = scope.$eval(attrs["hotkey"]);
          }

          // disable shortcuts in input fields if keycombo is 1 character
          if(keyCombo.length === 1) {
            options = {
              inputDisabled: true
            };
          }

          keyboardService.bind(keyCombo, function(){

              var element = $(el);
              var activeElementType = document.activeElement.tagName;
              var clickableElements = ["A", "BUTTON"];

              if(element.is("a,div,button,input[type='button'],input[type='submit'],input[type='checkbox']") && !element.is(':disabled') ){

                // when keycombo is enter and a link or button has focus - click the link or button instead of using the hotkey
                if(keyCombo === "enter" && clickableElements.indexOf(activeElementType) === 0) {
                  document.activeElement.click();
                } else {
                  element.click();
                }

              }else{
                element.focus();
              }

          }, options);

          el.on('$destroy', function(){
            keyboardService.unbind(keyCombo);
          });

      };
  });<commit_msg>check for key combo<commit_after>/**
* @ngdoc directive
* @name umbraco.directives.directive:headline
**/
angular.module("umbraco.directives")
  .directive('hotkey', function ($window, keyboardService, $log) {

      return function (scope, el, attrs) {

          var options = {};
          var keyCombo = attrs.hotkey;

          if (!keyCombo) {
            //support data binding
            keyCombo = scope.$eval(attrs["hotkey"]);
          }

          // disable shortcuts in input fields if keycombo is 1 character
          if(keyCombo) {

             if(keyCombo.length === 1) {
               options = {
                 inputDisabled: true
               };
             }

             keyboardService.bind(keyCombo, function(){

                var element = $(el);
                var activeElementType = document.activeElement.tagName;
                var clickableElements = ["A", "BUTTON"];

                if(element.is("a,div,button,input[type='button'],input[type='submit'],input[type='checkbox']") && !element.is(':disabled') ){

                  // when keycombo is enter and a link or button has focus - click the link or button instead of using the hotkey
                  if(keyCombo === "enter" && clickableElements.indexOf(activeElementType) === 0) {
                    document.activeElement.click();
                  } else {
                    element.click();
                  }

                }else{
                  element.focus();
                }

            }, options);

            el.on('$destroy', function(){
              keyboardService.unbind(keyCombo);
            });

          }

      };
  });
{'fraction_non_alphanumeric': 0.12659013341607198, 'fraction_numerical': 0.001861619609059882, 'mean_word_length': 1.6491372226787182, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6542863', 'n_tokens_mistral': 848, 'n_tokens_neox': 817, 'n_words': 186}