<commit_before>/*global imagesLoaded, jQuery */

/******************************************
 * jQuery FabrikStrip
 *
 * A lightweight, easy-to-use jQuery plugin for responsive slide layout.
 *
 * Author          @jenkins118 (https://fabrik.io)
 * Copyright       Copyright (c) 2015 <NAME>.
 * License         MIT
 * Version         0.0.0.1
 *
 ******************************************/

(function ($, window, undefined) {

  var PLUGIN_NAME = "fabrikStrip",
      INSTANCE_KEY = "plugin_" + PLUGIN_NAME;

  var originalWindowHeight, originalWindowWidth;

  function FabrikStrip(element, options, defaults) {
      this.element = $(element);
      this.options = $.extend({}, defaults, options);
      this._defaults = defaults;
      this._init();
  }

  FabrikStrip.prototype = {

      goTo: function (index) {
          // Go to specific blade

          var self = this,
              bladesCount = $(self.options.bladesSelector).length;

          if (index > bladesCount - 1) {
              return;
          }

          $('button', $(self.options.pagerSelector)).show();

          if (index <= 0) {
              self.goToFirst();
          }
          else if (index >= bladesCount - 1) {
              self.goToLast();
          }
          else {
              var beforeWidth = 0;

              $(self.options.bladesSelector).each(function () {
                  var $blade = $(this);

                  if ($blade.index() < index) {
                      beforeWidth += $blade.width();
                  }
              });

              var viewableWidth = $(self.element[0]).width(),
                  halfView = (viewableWidth - $(self.options.bladesSelector).eq(index).width()) / 2,
                  pull = beforeWidth - halfView;

              this._setActive(index);
              this._setPull(-pull);

              this.options.afterChange(index);
              return index;
          }
      },

      goToFirst: function () {
          // Go to first blade
          $('.left', $(this.options.pagerSelector)).hide();
          this._setActive(0);
          this._setPull(0);

          this.options.afterChange(0);
          return 0;
      },

      goToLast: function () {
          // Go to last blade
          $('.right', $(this.options.pagerSelector)).hide();
          var pull = $(this.options.innerStripSelector).width() - $(this.element[0]).width(),
              index = $(this.options.bladesSelector).length - 1;

          this._setActive(index);
          this._setPull(-pull);

          this.options.afterChange(index);
          return index;
      },

      _init: function () {
          $('html').addClass('fabrik-strip');
          this._bind();
          this._setSizes();
          this._setActive(this.options.startIndex);
      },

      _windowResize: function () {

          var self = this;
          var h = $(window).height();
          var w = $(window).width();

          var heightChangeFactor = (h - originalWindowHeight) / originalWindowHeight;
          var widthChangeFactor = (w - originalWindowWidth) / originalWindowWidth;

          var containerHeight = $(self.element[0]).data('height');
          var newHeight = containerHeight + (containerHeight * heightChangeFactor);

          $(self.element[0]).css({ 'height': newHeight, 'max-height': newHeight });
          $(self.options.bladesSelector).removeAttr('style');
          $(self.options.innerStripSelector).width('999em');

          var totalWidth = 0;

          $(self.options.bladesSelector).each(function () {

              var $blade = $(this),
                  bladeDataWidth = $blade.data('width'),
                  bladeWidth = bladeDataWidth + (bladeDataWidth * widthChangeFactor);

              // limit blade width
              $blade.width(bladeWidth);

              // limit total width
              totalWidth += bladeWidth;
          });

          $(self.options.innerStripSelector).width(totalWidth);
      },

      _setSizes: function () {

          var self = this,
              windowHeight = $(window).height(),
              windowWidth = $(window).width();

          originalWindowHeight = windowHeight;
          originalWindowWidth = windowWidth;

          if ($(self.options.headerSelector).length) {
              windowHeight -= $(self.options.headerSelector).height();
          }

          $(self.element[0]).data('height', windowHeight).css({ 'height': windowHeight, 'max-height': windowHeight });
          $(self.options.bladesSelector).removeAttr('style');
          $(self.options.innerStripSelector).width('999em');

          // after images are loaded get the widths of the blades so we can set parent container

          var container = self.element[0];

          //var images = container.getElementsByTagName("img");
          //var videos = container.getElementsByTagName("video");

          //var howManyToLoad = images.length + videos.length;

          var imagesAreLoaded = function () {

              var width = 0;

              $(self.options.bladesSelector).each(function () {

                  var $blade = $(this),
                      bladewidth = $(this).width(),
                      $img = $('img', $blade),
                      $video = $('video', $blade);

                  if ($img.length) {
                      bladewidth = $img.width();
                      $blade.data('width', bladewidth).data('height', $img.height());
                  }

                  if ($video.length) {
                      bladewidth = $video.width();
                      $blade.data('width', bladewidth).data('height', $video.height());
                  }

                  // limit blade width
                  $blade.width(bladewidth);

                  // limit total width
                  width += bladewidth;
              });

              $(self.options.innerStripSelector).width(width).addClass('blades-loaded');

          };

         
          container.addEventListener('load', imagesAreLoaded, true);
          container.addEventListener('loadeddata', imagesAreLoaded, true);

          // if (imagesLoaded !== undefined) {
          //   imagesLoaded(self.element[0], function () {
          //     var width = 0;

          //     $(self.options.bladesSelector).each(function () {

          //       var $blade = $(this),
          //           bladewidth = $(this).width(),
          //           $img = $('img', $blade);

          //       if ($img.length) {
          //         bladewidth = $img.width();
          //       }

          //       $blade.width(bladewidth);
          //       width += bladewidth;
          //     });

          //     $(self.options.innerStripSelector).width(width).addClass('blades-loaded');
          //   });
          // }
          // else {
          //   console.info("You need to add images Loaded plugin http://imagesloaded.desandro.com/");
          // }
<commit_msg>trying complete flag<commit_after>/*global imagesLoaded, jQuery */

/******************************************
 * jQuery FabrikStrip
 *
 * A lightweight, easy-to-use jQuery plugin for responsive slide layout.
 *
 * Author          @jenkins118 (https://fabrik.io)
 * Copyright       Copyright (c) 2015 <NAME>.
 * License         MIT
 * Version         0.0.0.1
 *
 ******************************************/

(function ($, window, undefined) {

  var PLUGIN_NAME = "fabrikStrip",
      INSTANCE_KEY = "plugin_" + PLUGIN_NAME;

  var originalWindowHeight, originalWindowWidth;

  function FabrikStrip(element, options, defaults) {
      this.element = $(element);
      this.options = $.extend({}, defaults, options);
      this._defaults = defaults;
      this._init();
  }

  FabrikStrip.prototype = {

      goTo: function (index) {
          // Go to specific blade

          var self = this,
              bladesCount = $(self.options.bladesSelector).length;

          if (index > bladesCount - 1) {
              return;
          }

          $('button', $(self.options.pagerSelector)).show();

          if (index <= 0) {
              self.goToFirst();
          }
          else if (index >= bladesCount - 1) {
              self.goToLast();
          }
          else {
              var beforeWidth = 0;

              $(self.options.bladesSelector).each(function () {
                  var $blade = $(this);

                  if ($blade.index() < index) {
                      beforeWidth += $blade.width();
                  }
              });

              var viewableWidth = $(self.element[0]).width(),
                  halfView = (viewableWidth - $(self.options.bladesSelector).eq(index).width()) / 2,
                  pull = beforeWidth - halfView;

              this._setActive(index);
              this._setPull(-pull);

              this.options.afterChange(index);
              return index;
          }
      },

      goToFirst: function () {
          // Go to first blade
          $('.left', $(this.options.pagerSelector)).hide();
          this._setActive(0);
          this._setPull(0);

          this.options.afterChange(0);
          return 0;
      },

      goToLast: function () {
          // Go to last blade
          $('.right', $(this.options.pagerSelector)).hide();
          var pull = $(this.options.innerStripSelector).width() - $(this.element[0]).width(),
              index = $(this.options.bladesSelector).length - 1;

          this._setActive(index);
          this._setPull(-pull);

          this.options.afterChange(index);
          return index;
      },

      _init: function () {
          $('html').addClass('fabrik-strip');
          this._bind();
          this._setSizes();
          this._setActive(this.options.startIndex);
      },

      _windowResize: function () {

          var self = this;
          var h = $(window).height();
          var w = $(window).width();

          var heightChangeFactor = (h - originalWindowHeight) / originalWindowHeight;
          var widthChangeFactor = (w - originalWindowWidth) / originalWindowWidth;

          var containerHeight = $(self.element[0]).data('height');
          var newHeight = containerHeight + (containerHeight * heightChangeFactor);

          $(self.element[0]).css({ 'height': newHeight, 'max-height': newHeight });
          $(self.options.bladesSelector).removeAttr('style');
          $(self.options.innerStripSelector).width('999em');

          var totalWidth = 0;

          $(self.options.bladesSelector).each(function () {

              var $blade = $(this),
                  bladeDataWidth = $blade.data('width'),
                  bladeWidth = bladeDataWidth + (bladeDataWidth * widthChangeFactor);

              // limit blade width
              $blade.width(bladeWidth);

              // limit total width
              totalWidth += bladeWidth;
          });

          $(self.options.innerStripSelector).width(totalWidth);
      },

      _setSizes: function () {

          var self = this,
              windowHeight = $(window).height(),
              windowWidth = $(window).width();

          originalWindowHeight = windowHeight;
          originalWindowWidth = windowWidth;

          if ($(self.options.headerSelector).length) {
              windowHeight -= $(self.options.headerSelector).height();
          }

          $(self.element[0]).data('height', windowHeight).css({ 'height': windowHeight, 'max-height': windowHeight });
          $(self.options.bladesSelector).removeAttr('style');
          $(self.options.innerStripSelector).width('999em');

          // after images are loaded get the widths of the blades so we can set parent container

          var container = self.element[0];

          //var images = container.getElementsByTagName("img");
          //var videos = container.getElementsByTagName("video");

          //var howManyToLoad = images.length + videos.length;

          //var imagesAreLoaded = function () {

              var width = 0;

              $(self.options.bladesSelector).each(function () {

                  var $blade = $(this),
                  $img = $('img', $blade),
                  $video = $('video', $blade),
                  bladewidth = $(this).width();

                  if ($img.length) {
                    if($img[0].complete) {
                      bladewidth = $img.width();
                      $blade.data('width', bladewidth).data('height', $img.height());
                    }
                    else {
                      $img[0].addEventListener('load', function() {
                        bladewidth = $img.width();
                        $blade.data('width', bladewidth).data('height', $img.height());
                      }, true)
                    }  
                  }

                  if ($video.length) {
                    if($video[0].complete) {
                      bladewidth = $video.width();
                      $blade.data('width', bladewidth).data('height', $video.height());
                    }
                    else {
                      $video[0].addEventListener('loadeddata', function() {
                        bladewidth = $video.width();
                        $blade.data('width', bladewidth).data('height', $video.height());
                      }, true)
                    }  
                  }

                  // limit blade width
                  $blade.width(bladewidth);

                  // limit total width
                  width += bladewidth;
              });

              $(self.options.innerStripSelector).width(width).addClass('blades-loaded');

          //};

         
          //container.addEventListener('load', imagesAreLoaded, true);
          //container.addEventListener('loadeddata', imagesAreLoaded, true);

          // if (imagesLoaded !== undefined) {
          //   imagesLoaded(self.element[0], function () {
          //     var width = 0;

          //     $(self.options.bladesSelector).each(function () {

          //       var $blade = $(this),
          //           bladewidth = $(this).width(),
          //           $img = $('img', $blade);

          //       if ($img.length) {
          //         bladewidth = $img.width();
          //       }

          //       $blade.width(bladewidth);
          //       width += bladewidth;
          //     });

          //     $(self.options.innerStripSelector).width(width).addClass('blades-loaded');
          //   });
          // }
          // else {
          //   console.info("You need to add images Loaded plugin http://imagesloaded.desandro.com/");
          // }

{'fraction_non_alphanumeric': 0.14927823766846823, 'fraction_numerical': 0.005336252308955326, 'mean_word_length': 1.5740447261841874, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '1596445', 'n_tokens_mistral': 3847, 'n_tokens_neox': 3638, 'n_words': 708}