<commit_before>/* ng-FitText.js v3.3.3
 * https://github.com/patrickmarabeas/ng-FitText.js
 *
 * Original jQuery project: https://github.com/davatron5000/FitText.js
 *
 * Copyright 2015, <NAME> http://marabeas.io
 * Released under the MIT license
 * http://opensource.org/licenses/mit-license.php
 *
 * Date: 06/05/2015
 */

(function(window, document, angular, undefined) {

  'use strict';

  angular.module('ngFitText', [])
    .value('fitTextDefaultConfig', {
      'debounce'    : false,
      'delay'       : 250,
      'loadDelay'   : 10,
      'compressor'  : 1,
      'min'         : Number.NEGATIVE_INFINITY,
      'max'         : Number.POSITIVE_INFINITY
    })

    .directive('fittext', [
      '$timeout',
      'fitTextDefaultConfig',
      'fitTextConfig',

      function($timeout, config, fitTextConfig) {
        return {
          restrict: 'A',
          scope: true,
          link: function(scope, element, attrs) {

            angular.extend(config, fitTextConfig.config);

            var parent          = element.parent()
              , computed        = window.getComputedStyle(element[0], null)
              , newlines        = element.children().length || 1
              , loadDelay       = attrs.fittextLoadDelay || config.loadDelay
              , compressor      = attrs.fittext || config.compressor
              , minFontSize     = attrs.fittextMin || config.min
              , maxFontSize     = (attrs.fittextMax === 'initial' ? computed['font-size'] : attrs.fittextMax) || config.max
              , lineHeight      = computed['line-height']
              , display         = computed['display']
              ;

            function calculate() {
              var ratio = element[0].offsetHeight / element[0].offsetWidth / newlines;
              return Math.floor(
                Math.max(
                  Math.min(parent[0].offsetWidth * ratio * compressor,
                    parseFloat(maxFontSize)
                  ),
                  parseFloat(minFontSize)
                )
              )
            }

            function resizer() {
              // Don't calculate for elements with no width or height
              if (element[0].offsetHeight * element[0].offsetWidth === 0)
                return;

              // Set standard values for calculation
              element[0].style.fontSize       = '12px'; // TODO: I feel like this should be 1em
              element[0].style.lineHeight     = '1';
              element[0].style.display        = 'inline-block';

              // Set usage values
              element[0].style.fontSize       = calculate() + 'px';
              element[0].style.lineHeight     = lineHeight;
              element[0].style.display        = display;
            }

            $timeout( function() { resizer() }, loadDelay);

            scope.$watch(attrs.ngBind, function() { resizer() });

            config.debounce
              ? angular.element(window).bind('resize', config.debounce(function(){ scope.$apply(resizer)}, config.delay))
              : angular.element(window).bind('resize', function(){ scope.$apply(resizer)});
          }
        }
      }
    ])

    .provider('fitTextConfig', function() {
      var self = this;
      this.config = {};
      this.$get = function() {<commit_msg>Magic number still very much needed<commit_after>/* ng-FitText.js v3.3.3
 * https://github.com/patrickmarabeas/ng-FitText.js
 *
 * Original jQuery project: https://github.com/davatron5000/FitText.js
 *
 * Copyright 2015, <NAME> http://marabeas.io
 * Released under the MIT license
 * http://opensource.org/licenses/mit-license.php
 *
 * Date: 06/05/2015
 */

(function(window, document, angular, undefined) {

  'use strict';

  angular.module('ngFitText', [])
    .value('fitTextDefaultConfig', {
      'debounce'    : false,
      'delay'       : 250,
      'loadDelay'   : 10,
      'compressor'  : 1,
      'min'         : 0,
      'max'         : Number.POSITIVE_INFINITY
    })

    .directive('fittext', [
      '$timeout',
      'fitTextDefaultConfig',
      'fitTextConfig',

      function($timeout, config, fitTextConfig) {
        return {
          restrict: 'A',
          scope: true,
          link: function(scope, element, attrs) {

            angular.extend(config, fitTextConfig.config);

            var parent          = element.parent()
              , computed        = window.getComputedStyle(element[0], null)
              , newlines        = element.children().length || 1
              , loadDelay       = attrs.fittextLoadDelay || config.loadDelay
              , compressor      = attrs.fittext || config.compressor
              , minFontSize     = attrs.fittextMin || config.min
              , maxFontSize     = (attrs.fittextMax === 'initial' ? computed['font-size'] : attrs.fittextMax) || config.max
              , lineHeight      = computed['line-height']
              , display         = computed['display']
              ;

            function calculate() {
              var ratio = element[0].offsetHeight / element[0].offsetWidth / newlines;
              return Math.max(
                Math.min((parent[0].offsetWidth - 6) * ratio * compressor,
                  parseFloat(maxFontSize)
                ),
                parseFloat(minFontSize)
              )
            }

            function resizer() {
              // Don't calculate for elements with no width or height
              if (element[0].offsetHeight * element[0].offsetWidth === 0)
                return;

              // Set standard values for calculation
              element[0].style.fontSize       = '10px';
              element[0].style.lineHeight     = '1';
              element[0].style.display        = 'inline-block';

              // Set usage values
              element[0].style.fontSize       = calculate() + 'px';
              element[0].style.lineHeight     = lineHeight;
              element[0].style.display        = display;
            }

            $timeout( function() { resizer() }, loadDelay);

            scope.$watch(attrs.ngBind, function() { resizer() });

            config.debounce
              ? angular.element(window).bind('resize', config.debounce(function(){ scope.$apply(resizer)}, config.delay))
              : angular.element(window).bind('resize', function(){ scope.$apply(resizer)});
          }
        }
      }
    ])

    .provider('fitTextConfig', function() {
      var self = this;
      this.config = {};
      this.$get = function() {
{'fraction_non_alphanumeric': 0.12842911877394636, 'fraction_numerical': 0.013333333333333334, 'mean_word_length': 1.7056384742951907, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 4, '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': '1730176', 'n_tokens_mistral': 1834, 'n_tokens_neox': 1734, 'n_words': 335}