<commit_before>/*
 (function () {
 var originalAddClassMethod = jQuery.fn.addClass;
 jQuery.fn.addClass = function () {
 var result = originalAddClassMethod.apply(this, arguments);
 jQuery(this).trigger('classAdded');
 return result;
 };
 })();
 */

// STICKY PROTOTYPE
$.fn.dwSticky = function (settings) {
  var toReturn = {};
  var $stElement = $(this).eq(0);
  if (!$stElement || $stElement.length < 1) {
    //console.log("dwSticky :: no element");
    return false;
  }
  settings = settings || {};
  toReturn.settings = settings;
  settings.offsetTop = settings.offsetTop || 0;
  settings.offsetBot = settings.offsetBot || 0;
  settings.offsetAppear = settings.offsetAppear || 0; // start sticky when element is beyond top viewport edge (in PX)
  var $stEnd = settings.$stEnd || $();
  if ($stEnd.length < 1) {
    //console.log("dwSticky :: parameters mismach");
    return false;
  }
  var $stStart = $stElement.parent();
  var calculateAndSet = function () {
    setTimeout(function () {
      var posStart = $stStart.offset()['top'];
      var posEnd = $stEnd.offset()['top'] - $stElement.outerHeight(true);
      var posScooll = $(window).scrollTop() + settings.offsetTop;
      $stElement.css({position: 'fixed'});
      if (posScooll < posStart + settings.offsetAppear) { // scroled above
        $stElement.removeClass('dw-sticked');
        $stElement.css({
          position: 'relative',
          top: 'auto'
        });
      } else if (posScooll > posEnd - settings.offsetBot) { // scroll below
        $stElement.addClass('dw-sticked');
        $stElement.css({
          position: 'fixed',
          top: posEnd - posScooll + settings.offsetTop - settings.offsetBot
        });
      } else { // sticky area
        $stElement.addClass('dw-sticked');
        $stElement.css({
          position: 'fixed',
          top: settings.offsetTop
        });
      }
    }, 0);    
  };
  // event bindings
  $(window).on('scroll', calculateAndSet);
  $(window).on('resize', calculateAndSet);
  $(document).on('ready', calculateAndSet);
  $(window).on('load', calculateAndSet);
  $stElement.addClass('dw-sticky');
  calculateAndSet();
  //$stElement.one('classAdded', calculateAndSet);
  toReturn.destroy = function () {
    $(window).off('scroll', calculateAndSet);
    $(window).off('resize', calculateAndSet);
    $(document).off('ready', calculateAndSet);
    $(window).off('load', calculateAndSet);
    //$stElement.off('classAdded', calculateAndSet);
    $stElement.removeClass('dw-sticky');
    $stElement.css({
      position: '',
      top: ''
    });
    $stElement.removeClass('dw-sticked');
  };
  toReturn.calculateAndSet = calculateAndSet;
  $stElement.data('dwSticky', toReturn);
  return toReturn;
};
// eof sticky  prototype

var observeDOM = function (obj, callback) {
  if (typeof (obj) === "undefined") {
    return false;
  }
  var MutationObserver = window.MutationObserver || window.WebKitMutationObserver, eventListenerSupported = window.addEventListener;
  if (MutationObserver) {
    var obs = new MutationObserver(function (mutations, observer) {
      if (mutations[0].addedNodes.length || mutations[0].removedNodes.length)
        callback();
    });
    obs.observe(obj, {childList: true, subtree: true});
  }
  else if (eventListenerSupported) {
    obj.addEventListener('DOMNodeInserted', callback, false);
    //obj.addEventListener('DOMNodeRemoved', callback, false);
  }
};


<commit_msg>basement class<commit_after>/*
 (function () {
 var originalAddClassMethod = jQuery.fn.addClass;
 jQuery.fn.addClass = function () {
 var result = originalAddClassMethod.apply(this, arguments);
 jQuery(this).trigger('classAdded');
 return result;
 };
 })();
 */

// STICKY PROTOTYPE
$.fn.dwSticky = function (settings) {
  var toReturn = {};
  var $stElement = $(this).eq(0);
  if (!$stElement || $stElement.length < 1) {
    //console.log("dwSticky :: no element");
    return false;
  }
  settings = settings || {};
  toReturn.settings = settings;
  settings.offsetTop = settings.offsetTop || 0;
  settings.offsetBot = settings.offsetBot || 0;
  settings.offsetAppear = settings.offsetAppear || 0; // start sticky when element is beyond top viewport edge (in PX)
  var $stEnd = settings.$stEnd || $();
  if ($stEnd.length < 1) {
    //console.log("dwSticky :: parameters mismach");
    return false;
  }
  var $stStart = $stElement.parent();
  var calculateAndSet = function () {
    setTimeout(function () {
      var posStart = $stStart.offset()['top'];
      var posEnd = $stEnd.offset()['top'] - $stElement.outerHeight(true);
      var posScooll = $(window).scrollTop() + settings.offsetTop;
      $stElement.css({position: 'fixed'});
      if (posScooll < posStart + settings.offsetAppear) { // scroled above
        $stElement.removeClass('dw-sticked');
        $stElement.removeClass('dw-sticked-basement');
        $stElement.css({
          position: 'relative',
          top: 'auto'
        });
      } else if (posScooll > posEnd - settings.offsetBot) { // scroll below
        $stElement.addClass('dw-sticked');
        $stElement.addClass('dw-sticked-basement');
        $stElement.css({
          position: 'fixed',
          top: posEnd - posScooll + settings.offsetTop - settings.offsetBot
        });
      } else { // sticky area
        $stElement.addClass('dw-sticked');
        $stElement.removeClass('dw-sticked-basement');
        $stElement.css({
          position: 'fixed',
          top: settings.offsetTop
        });
      }
    }, 0);
  };
  // event bindings
  $(window).on('scroll', calculateAndSet);
  $(window).on('resize', calculateAndSet);
  $(document).on('ready', calculateAndSet);
  $(window).on('load', calculateAndSet);
  $stElement.addClass('dw-sticky');
  calculateAndSet();
  //$stElement.one('classAdded', calculateAndSet);
  toReturn.destroy = function () {
    $(window).off('scroll', calculateAndSet);
    $(window).off('resize', calculateAndSet);
    $(document).off('ready', calculateAndSet);
    $(window).off('load', calculateAndSet);
    //$stElement.off('classAdded', calculateAndSet);
    $stElement.removeClass('dw-sticky');
    $stElement.css({
      position: '',
      top: ''
    });
    $stElement.removeClass('dw-sticked');
  };
  toReturn.calculateAndSet = calculateAndSet;
  $stElement.data('dwSticky', toReturn);
  return toReturn;
};
// eof sticky  prototype

var observeDOM = function (obj, callback) {
  if (typeof (obj) === "undefined") {
    return false;
  }
  var MutationObserver = window.MutationObserver || window.WebKitMutationObserver, eventListenerSupported = window.addEventListener;
  if (MutationObserver) {
    var obs = new MutationObserver(function (mutations, observer) {
      if (mutations[0].addedNodes.length || mutations[0].removedNodes.length)
        callback();
    });
    obs.observe(obj, {childList: true, subtree: true});
  }
  else if (eventListenerSupported) {
    obj.addEventListener('DOMNodeInserted', callback, false);
    //obj.addEventListener('DOMNodeRemoved', callback, false);
  }
};

{'fraction_non_alphanumeric': 0.16195080335560927, 'fraction_numerical': 0.0025593630029859234, 'mean_word_length': 3.3743781094527363, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 5, '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': '4579378', 'n_tokens_mistral': 2142, 'n_tokens_neox': 2134, 'n_words': 422}