<commit_before>angular.module('directives', [])

  .directive('glyptoModel', function($compile, $http, $templateCache) {
    return {
      restrict: 'C',
      scope: true
    };
  })

  .directive('glyptoNavToggle', function() {
    return {
      restrict: 'C',
      link: function($scope, $element, $attrs) {
        $scope.$root.navIsHidden = store.get('glypto-menu-hidden');

        Mousetrap.bind('command+shift+e', function() {
          $scope.toggle();
          $scope.$apply();
        });

        $scope.toggle = function() {
          $scope.$root.navIsHidden = !$scope.$root.navIsHidden;
          store.set('glypto-menu-hidden', $scope.$root.navIsHidden);
        };
      }
    };
  })

  .directive('glyptoMenu', function() {
    return {
      restrict: 'E',
      replace: true,
      scope: true,
      templateUrl: 'glyptotheque/menu.html',
      controller: function($scope) {
        $scope.items = window.APP_CONTEXT.sitemap;
      },
      link: function() {
        // Remove nav placeholder when menu is created
        angular.element(document.getElementById('glypto-nav-placeholder')).remove();
      }
    };
  })

  .directive('glyptoMenuTree', function() {
    return {
      restrict: 'E',
      replace: true,
      transclude: true,
      scope: {
        items: '=',
        filter: '='
      },
      templateUrl: 'glyptotheque/menu-tree.html'
    };
  })

  .directive('glyptoMenuNode', function($compile) {
    return {
      restrict: 'E',
      replace: true,
      templateUrl: 'glyptotheque/menu-node.html',
      link: function($scope, $element, $attrs) {
        $scope.isSelected = $scope.node.url === window.APP_CONTEXT.current_url;

        if ($scope.node.children && $scope.node.children.length > 0) {
          var childNode = $compile('<glypto-menu-tree items="node.children" filter="filter"></glypto-menu-tree>')($scope);
          $element.append(childNode);
        }
      }
    };
  })

  .directive('glyptoSearch', function() {
    return {
      restrict: 'A',
      link: function($scope, $element, $attrs) {
        var activated;
        var placeholderText = $element.attr('placeholder');

        Mousetrap.bind('/', function(evt) {
          if(!activated) {
            evt.preventDefault();
          }
          $element[0].focus();
          $element.attr('placeholder', placeholderText.replace(/\(.*\)/, ''));
        });

        Mousetrap.bind('esc', function(evt) {
          if(!activated) {
            evt.preventDefault();
          }
          $element[0].blur();
          $element.attr('placeholder', placeholderText);
        });

        $element.on('focus', function() {
          activated = true;
        });

        $element.on('blur', function() {
          activated = false;
        });
      }
    };
  })

  .directive('iframe', function() {
    return {
      restrict: 'E',
      link: function($scope, $element, $attrs) {
        var iframe = $element[0];

        $scope.$watch('navIsHidden', function() {
          if(iframe.contentWindow.parentIFrame) {
            // compensata for nav transition
            setTimeout(function() {
              iframe.contentWindow.parentIFrame.size();
            }, 400)
          }<commit_msg>Swap placeholder text on filter focus/blur<commit_after>angular.module('directives', [])

  .directive('glyptoModel', function($compile, $http, $templateCache) {
    return {
      restrict: 'C',
      scope: true
    };
  })

  .directive('glyptoNavToggle', function() {
    return {
      restrict: 'C',
      link: function($scope, $element, $attrs) {
        $scope.$root.navIsHidden = store.get('glypto-menu-hidden');

        Mousetrap.bind('command+shift+e', function() {
          $scope.toggle();
          $scope.$apply();
        });

        $scope.toggle = function() {
          $scope.$root.navIsHidden = !$scope.$root.navIsHidden;
          store.set('glypto-menu-hidden', $scope.$root.navIsHidden);
        };
      }
    };
  })

  .directive('glyptoMenu', function() {
    return {
      restrict: 'E',
      replace: true,
      scope: true,
      templateUrl: 'glyptotheque/menu.html',
      controller: function($scope) {
        $scope.items = window.APP_CONTEXT.sitemap;
      },
      link: function() {
        // Remove nav placeholder when menu is created
        angular.element(document.getElementById('glypto-nav-placeholder')).remove();
      }
    };
  })

  .directive('glyptoMenuTree', function() {
    return {
      restrict: 'E',
      replace: true,
      transclude: true,
      scope: {
        items: '=',
        filter: '='
      },
      templateUrl: 'glyptotheque/menu-tree.html'
    };
  })

  .directive('glyptoMenuNode', function($compile) {
    return {
      restrict: 'E',
      replace: true,
      templateUrl: 'glyptotheque/menu-node.html',
      link: function($scope, $element, $attrs) {
        $scope.isSelected = $scope.node.url === window.APP_CONTEXT.current_url;

        if ($scope.node.children && $scope.node.children.length > 0) {
          var childNode = $compile('<glypto-menu-tree items="node.children" filter="filter"></glypto-menu-tree>')($scope);
          $element.append(childNode);
        }
      }
    };
  })

  .directive('glyptoSearch', function() {
    return {
      restrict: 'A',
      link: function($scope, $element, $attrs) {
        var activated;
        var placeholderText = $element.attr('placeholder');

        Mousetrap.bind('/', function(evt) {
          if(!activated) {
            evt.preventDefault();
          }
          $element[0].focus();
          $element.attr('placeholder', placeholderText.replace(/\(.*\)/, ''));
        });

        Mousetrap.bind('esc', function(evt) {
          if(!activated) {
            evt.preventDefault();
          }
          $element[0].blur();
          $element.attr('placeholder', placeholderText);
        });

        $element.on('focus', function() {
          activated = true;
          this.originalPlaceholder = $element.attr('placeholder');
          $element.attr('placeholder', 'Filter');
        });

        $element.on('blur', function() {
          activated = false;
          $element.attr('placeholder', this.originalPlaceholder);
        });
      }
    };
  })

  .directive('iframe', function() {
    return {
      restrict: 'E',
      link: function($scope, $element, $attrs) {
        var iframe = $element[0];

        $scope.$watch('navIsHidden', function() {
          if(iframe.contentWindow.parentIFrame) {
            // compensata for nav transition
            setTimeout(function() {
              iframe.contentWindow.parentIFrame.size();
            }, 400)
          }
{'fraction_non_alphanumeric': 0.16352483542788748, 'fraction_numerical': 0.002094554159186116, 'mean_word_length': 2.134083450539147, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, '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': '1119493', 'n_tokens_mistral': 1990, 'n_tokens_neox': 1965, 'n_words': 319}