<commit_before>'use strict';

/**
 * @ngdoc directive
 * @name grafterizerApp.directive:resizeHand
 * @description
 * # resizeHand
 */
angular.module('grafterizerApp')
  .directive('resizeHand', function() {
    return {
      template: '<div></div>',
      restrict: 'E',
      link: function postLink(scope, element, attrs) {
        var target = document.getElementById(attrs.
          for);
        if (!target) return;
       
        var mousemove;

        if (window.requestAnimationFrame) {
          var requestAnim = 0;
          mousemove = function(e) {
            if (!requestAnim) {
              requestAnim = window.requestAnimationFrame(function() {
                updateLayout(e.offsetX);
                requestAnim = 0;
              });
            }
          };
        } else {
          mousemove = _.throttle(function(e) {
            updateLayout(e.offsetX);
          }, 1 / 2000);
        }

        var savedW = 0;
        var updateLayout = function(w)  {
          if (window.innerWidth < 600) {
            element.css('display', 'none');
            target.setAttribute('flex', '');
            return;
          }

          element.css('display', 'block');
          target.removeAttribute('flex');

          w = Math.max(Math.round(w), 300);
          element.css('left', (w - 3) + 'px');
          element.css('height', target.clientHeight + 'px');
          target.style.width = w + 'px';
          savedW = w;

          if (window.sessionStorage) {
            window.sessionStorage.setItem('resizeHand' + attrs.for, w);
          }
        };

        window.addEventListener('resize', function() {
          mousemove({
            offsetX: savedW
          });
        });

        var initLayout = function() {
          var key = 'resizeHand' + attrs.for;
          var width = window.sessionStorage && window.sessionStorage.hasOwnProperty(key) ?
            parseInt(window.sessionStorage.getItem(key)) : window.innerWidth / 2;
           
          updateLayout(width);
        };

        initLayout();
        window.setTimeout(initLayout, 1000);

        var mask = document.createElement('div');
        mask.className = 'resize-hand-mask';

        var isDragging = false;
        element.on('mousedown', function(ev) {
          isDragging = true;
          element.parent().append(mask);
          mask.addEventListener('mousemove', mousemove);
        });

        var stopDrag = function() {
          if (isDragging) {
            mask.removeEventListener('mousemove', mousemove);
            element[0].parentNode.removeChild(mask);
            isDragging = false;
          }<commit_msg>Resizing is compatible with angular-material 0.11.0<commit_after>'use strict';

/**
 * @ngdoc directive
 * @name grafterizerApp.directive:resizeHand
 * @description
 * # resizeHand
 */
angular.module('grafterizerApp')
  .directive('resizeHand', function() {
    return {
      template: '<div></div>',
      restrict: 'E',
      link: function postLink(scope, element, attrs) {
        var margin = attrs.margin ? parseInt(attrs.margin) : 300;

        var target = document.getElementById(attrs.
          for);
        if (!target) return;
       
        var mousemove;

        if (window.requestAnimationFrame) {
          var requestAnim = 0;
          mousemove = function(e) {
            if (!requestAnim) {
              requestAnim = window.requestAnimationFrame(function() {
                updateLayout(e.offsetX);
                requestAnim = 0;
              });
            }
          };
        } else {
          mousemove = _.throttle(function(e) {
            updateLayout(e.offsetX);
          }, 1 / 2000);
        }

        var savedW = 0;
        var updateLayout = function(w)  {
          if (window.innerWidth < 600) {
            element.css('display', 'none');
            target.setAttribute('flex', '');
            target.style.width = '';
            angular.element(target).addClass('flex');
            return;
          }

          element.css('display', 'block');
          target.removeAttribute('flex');
          angular.element(target).removeClass('flex');

          var containerWidth = element.parent()[0].clientWidth;

          w = Math.min(Math.max(Math.round(w), margin), containerWidth-margin);
          element.css('left', (w - 3) + 'px');
          element.css('height', target.clientHeight + 'px');
          target.style.width = w + 'px';
          savedW = w;

          if (window.sessionStorage) {
            window.sessionStorage.setItem('resizeHand' + attrs.for, w);
          }
        };

        window.addEventListener('resize', function() {
          mousemove({
            offsetX: savedW
          });
        });

        var initLayout = function() {
          var key = 'resizeHand' + attrs.for;
          var width = window.sessionStorage && window.sessionStorage.hasOwnProperty(key) ?
            parseInt(window.sessionStorage.getItem(key)) : window.innerWidth / 2;
           
          updateLayout(width);
        };

        initLayout();
        window.setTimeout(initLayout, 1000);

        var mask = document.createElement('div');
        mask.className = 'resize-hand-mask';

        var isDragging = false;
        element.on('mousedown', function(ev) {
          isDragging = true;
          element.parent().append(mask);
          mask.addEventListener('mousemove', mousemove);
        });

        element.on('dragstart', function(ev) {
          ev.preventDefault();
        });

        var stopDrag = function() {
          if (isDragging) {
            mask.removeEventListener('mousemove', mousemove);
            element[0].parentNode.removeChild(mask);
            isDragging = false;
          }
{'fraction_non_alphanumeric': 0.13137289020358447, 'fraction_numerical': 0.008178179919958239, 'mean_word_length': 1.8080117244748413, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, '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': '5813908', 'n_tokens_mistral': 1576, 'n_tokens_neox': 1521, 'n_words': 288}