<commit_before>(function( $ ) {
  /*
   * Private attributes and method
   */

  // Function from <NAME>: http://davidwalsh.name/css-animation-callback licensed with http://opensource.org/licenses/MIT
  var whichTransitionEvent = function() {
    var t, el = document.createElement("fakeelement"),
    transitions = {
      "transition"      : "transitionend",
      "OTransition"     : "oTransitionEnd",
      "MozTransition"   : "transitionend",
      "WebkitTransition": "webkitTransitionEnd"
    };

    for (t in transitions) {
      if (el.style[t] !== undefined) {
        return transitions[t];
      }
    }
  };

  var Flip = function($el, options, callback) {
    // Define default setting
    var setting = $.extend({
      axis: "y",
      reverse: false,
      trigger: "click",
      speed: 500,
      forceHeight: false,
      forceWidth: false,
      autoSize: true,
      front: '.front',
      back: '.back'
    }, options );

    // Attributes
    this.setting = $.extend(setting, options);
    this.element = $el;
    this.frontElement = this.getFrontElement();
    this.backElement = this.getBackElement();
    if (typeof options === 'function') {
      // This allows flip to be called for setup with only a callback (default settings)
      callback = options;
    }
    this.callback = callback;
    this.isFlipped = false;

    this.init();
  };

  /*
   * Public methods
   */
  $.extend(Flip.prototype, {

    flip: function() {
      var self = this;

      if (self.isFlipped) {
        return;
      }

      self.isFlipped = true;

      var rotateAxis = "rotate" + self.setting.axis;
      self.frontElement.css({
        transform: rotateAxis + (self.setting.reverse ? "(-180deg)" : "(180deg)"),
        "z-index": "0"
      });

      self.backElement.css({
        transform: rotateAxis + "(0deg)",
        "z-index": "1"
      });

      // Providing a nicely wrapped up callback because transform is essentially async
      self.element.one(whichTransitionEvent(), function() {
        self.element.trigger('flip:done');
        if (self.callback !== undefined) {
          self.callback.call(self.element);
        }
      });
    },

    unflip: function() {
      var self = this;

      if (!self.isFlipped) {
        return;
      }

      self.isFlipped = false;

      var rotateAxis = "rotate" + self.setting.axis;
      self.frontElement.css({
        transform: rotateAxis + "(0deg)",
        "z-index": "1"
      });

      self.backElement.css({
        transform: rotateAxis + (self.setting.reverse ? "(180deg)" : "(-180deg)"),
        "z-index": "0"
      });

      // Providing a nicely wrapped up callback because transform is essentially async
      self.element.one(whichTransitionEvent(), function(){
        self.element.trigger('flip:done');
        if (self.callback !== undefined){
          self.callback.call(self.element);
        }
      });
    },

    getFrontElement: function() {
      if (this.setting.front instanceof $) {
        return this.setting.front;
      } else {
        return this.element.find(this.setting.front);
      }
    },

    getBackElement: function() {
      if (this.setting.back instanceof $) {
        return this.setting.back;
      } else {
        return this.element.find(this.setting.back);
      }<commit_msg>Move duplicate callback triggering to a method (#triggerCallback)<commit_after>(function( $ ) {
  /*
   * Private attributes and method
   */

  // Function from <NAME>: http://davidwalsh.name/css-animation-callback licensed with http://opensource.org/licenses/MIT
  var whichTransitionEvent = function() {
    var t, el = document.createElement("fakeelement"),
    transitions = {
      "transition"      : "transitionend",
      "OTransition"     : "oTransitionEnd",
      "MozTransition"   : "transitionend",
      "WebkitTransition": "webkitTransitionEnd"
    };

    for (t in transitions) {
      if (el.style[t] !== undefined) {
        return transitions[t];
      }
    }
  };

  var Flip = function($el, options, callback) {
    // Define default setting
    var setting = $.extend({
      axis: "y",
      reverse: false,
      trigger: "click",
      speed: 500,
      forceHeight: false,
      forceWidth: false,
      autoSize: true,
      front: '.front',
      back: '.back'
    }, options );

    // Attributes
    this.setting = $.extend(setting, options);
    this.element = $el;
    this.frontElement = this.getFrontElement();
    this.backElement = this.getBackElement();
    if (typeof options === 'function') {
      // This allows flip to be called for setup with only a callback (default settings)
      callback = options;
    }
    this.callback = callback;
    this.isFlipped = false;

    this.init();
  };

  /*
   * Public methods
   */
  $.extend(Flip.prototype, {

    triggerCallback: function() {
      var self = this;
      // Providing a nicely wrapped up callback because transform is essentially async
      self.element.one(whichTransitionEvent(), function() {
        self.element.trigger('flip:done');
        if (self.callback !== undefined) {
          self.callback.call(self.element);
        }
      });
    },

    flip: function() {
      if (this.isFlipped) {
        return;
      }

      this.isFlipped = true;

      var rotateAxis = "rotate" + this.setting.axis;
      this.frontElement.css({
        transform: rotateAxis + (this.setting.reverse ? "(-180deg)" : "(180deg)"),
        "z-index": "0"
      });

      this.backElement.css({
        transform: rotateAxis + "(0deg)",
        "z-index": "1"
      });
      this.triggerCallback();
    },

    unflip: function() {
      if (!this.isFlipped) {
        return;
      }

      this.isFlipped = false;

      var rotateAxis = "rotate" + this.setting.axis;
      this.frontElement.css({
        transform: rotateAxis + "(0deg)",
        "z-index": "1"
      });

      this.backElement.css({
        transform: rotateAxis + (this.setting.reverse ? "(180deg)" : "(-180deg)"),
        "z-index": "0"
      });
      this.triggerCallback();
    },

    getFrontElement: function() {
      if (this.setting.front instanceof $) {
        return this.setting.front;
      } else {
        return this.element.find(this.setting.front);
      }
    },

    getBackElement: function() {
      if (this.setting.back instanceof $) {
        return this.setting.back;
      } else {
        return this.element.find(this.setting.back);
      }
{'fraction_non_alphanumeric': 0.14199442551873645, 'fraction_numerical': 0.006503561474140601, 'mean_word_length': 2.18962962962963, 'pattern_counts': {'":': 10, '<': 5, '<?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': '5846325', 'n_tokens_mistral': 1940, 'n_tokens_neox': 1871, 'n_words': 424}