<commit_before>define(['jquery', './webmaker'],
  function ($, webmaker) {
  'use strict';

  var countLarge = 2,
      countMedium = 8,
      LIMIT_DESKTOP = 20,
      LIMIT_MOBILE = 6;

  var $body = $( 'body' ),
      $mainGallery = $('.main-gallery'),
      mainGallery = $mainGallery[0],
      $makeTemplate = $body.find( 'div.make' ),
      $makeTeachTemplate = $body.find( 'div.make-teach' ),
      $makeBackTemplate = $body.find( 'div.make-back' ),
      $eventBackTemplate = $body.find( 'div.event-back' ),
      isMobile = false;

  function createMakeBack( data, $el ) {
    var $backTemplate = $makeBackTemplate.clone( true ),
        $placeSpan = $('.place', $backTemplate),
        $titleSpan = $('.title', $backTemplate),
        $dateSpan = $('.date', $backTemplate),
        $authorSpan = $('.author', $backTemplate),
        $descSpan = $('.description', $backTemplate),
        createdDate = new Date( data.createdAt );

    $titleSpan.text( data.title );
    $dateSpan = $('.date', $backTemplate),
    $authorSpan.text( data.author );
    $descSpan.text( data.description );
    $el.append( $backTemplate );
  }

  function createSmallMakeBack( data, $el ) {
    var $backTemplate = $('<div>').addClass('make-back-small');
    var $see = $('<div>').addClass('see-more').text('See make details');
    var $arrow = $('<div>').addClass('make-small-arrow');
    $backTemplate.append( $see );
    $backTemplate.append( $arrow );

    $el.append( $backTemplate );
  }

  function createMakeTeach( data, $el ) {
    var $teachTemplate = $makeTeachTemplate.clone( true ),
        $titleSpan = $('.title', $teachTemplate),
        $levelSpan = $('.level', $teachTemplate),
        $skillsSpan = $('.skills', $teachTemplate),
        $authorSpan = $('.author', $teachTemplate);

    $titleSpan.text( data.description );
    $levelSpan.text( data.level );
    $skillsSpan.text( data.skills );
    $authorSpan.text( data.author );
    $el.append( $teachTemplate );
  }

  function createEventBack( data, $el ) {
    var $backTemplate = $eventBackTemplate.clone( true ),
        $eventSpan = $('.event-title', $backTemplate),
        $dateSpan = $('.date', $backTemplate),
        $placeSpan = $('.place', $backTemplate),
        $descSpan = $('.description', $backTemplate),
        $organizerSpan = $('.organizer', $backTemplate);

    $eventSpan.text( data.title );
    $dateSpan.text( date.createdAt );
    $placeSpan.text( 'PLACE' );
    $descSpan.text( data.description );
    $organizerSpan.text( 'MOZILLA' );
    $el.append( $backTemplate );
  }

  // set up mouse over handlers
  if ($body[0].id === 'index' || $body[0].id === 'search-results') {
    $makeTemplate.on('mouseenter focusin, mouseleave focusout', function ( e ) {
      $('.flipContainer', this).toggleClass( 'flip' );
    });
  }

  function searchCallback( data, self ) {
    var $makeContainer = $makeTemplate.clone( true ).addClass('rf'),
        makeContainer = $makeContainer[0],
        randSize = 'large';

    // If we're not in mobile view, we want to display multiple sizes for
    // the home page and the medium size for the teach page.
    if (!isMobile) {
      switch( $body[0].id ) {
        case 'index':
          if (countLarge > 0) {
            randSize = 'large';
            countLarge --;
          } else {
            randSize = 'medium';
            countMedium --;
          }
          break;

        case 'teach':
          randSize = 'medium';
          break;

        case 'search-results':
          randSize = 'medium';
          break;
      }
    }

    // create front Element & populate
    var $frontEl = $('<div class="front"><div class="preview-img"><img src="' + data.thumbnail +
      '" alt="' + data.title + '"><img class="share-icon" alt="Share" src="../img/share-icon.png" /></div></div>');

    // create back element & populate
    var $backEl = $('<div class="back"></div>');
    var tags = data.tags;

    /*
     * Not going to make it for June 15th/MVP
     * so I'm commenting this out. - DK
    if ( tags.popcorn ) {
      $frontEl.addClass( 'popcorn' );
    } else if ( tags.challenge ) {
      $frontEl.addClass( 'challenge' );
    } else if ( tags.event ) {
      $frontEl.addClass( 'event' );
    } else if ( tags.guide ) {
      $frontEl.addClass( 'guide' );
    } else if ( tags['make-demo'] ) {
      $frontEl.addClass( 'make-demo' );
    } else {
      $frontEl.addClass( 'default' );
    }
    */
    $makeContainer.addClass(randSize);

    switch( $body[0].id ) {
      case 'index':
        if(randSize === 'small') createSmallMakeBack( data, $backEl );
        else createMakeBack( data, $backEl );
        break;

      case 'teach':
        createMakeTeach( data, $frontEl );
        break;

      case 'search-results':
        createMakeBack( data, $backEl );
        break;
    }
<commit_msg>fixup for mediaGallery<commit_after>define(['jquery', './webmaker'],
  function ($, webmaker) {
  'use strict';

  var countLarge = 2,
      countMedium = 8,
      LIMIT_DESKTOP = 20,
      LIMIT_MOBILE = 6;

  var $body = $( 'body' ),
      $mainGallery = $('.main-gallery'),
      mainGallery = $mainGallery[0],
      $makeTemplate = $body.find( 'div.make' ),
      $makeTeachTemplate = $body.find( 'div.make-teach' ),
      $makeBackTemplate = $body.find( 'div.make-back' ),
      $eventBackTemplate = $body.find( 'div.event-back' ),
      isMobile = false;

  function createMakeBack( data, $el ) {
    var $backTemplate = $makeBackTemplate.clone( true ),
        $placeSpan = $('.place', $backTemplate),
        $titleSpan = $('.title', $backTemplate),
        $dateSpan = $('.date', $backTemplate),
        $authorSpan = $('.author', $backTemplate),
        $descSpan = $('.description', $backTemplate),
        createdDate = new Date( data.createdAt );

    $titleSpan.text( data.title );
    $dateSpan = $('.date', $backTemplate),
    $authorSpan.text( data.author );
    $descSpan.text( data.description );
    $el.append( $backTemplate );
  }

  function createSmallMakeBack( data, $el ) {
    var $backTemplate = $('<div>').addClass('make-back-small');
    var $see = $('<div>').addClass('see-more').text('See make details');
    var $arrow = $('<div>').addClass('make-small-arrow');
    $backTemplate.append( $see );
    $backTemplate.append( $arrow );

    $el.append( $backTemplate );
  }

  function createMakeTeach( data, $el ) {
    var $teachTemplate = $makeTeachTemplate.clone( true ),
        $titleSpan = $('.title', $teachTemplate),
        $levelSpan = $('.level', $teachTemplate),
        $skillsSpan = $('.skills', $teachTemplate),
        $authorSpan = $('.author', $teachTemplate);

    $titleSpan.text( data.description );
    $levelSpan.text( data.level );
    $skillsSpan.text( data.skills );
    $authorSpan.text( data.author );
    $el.append( $teachTemplate );
  }

  function createEventBack( data, $el ) {
    var $backTemplate = $eventBackTemplate.clone( true ),
        $eventSpan = $('.event-title', $backTemplate),
        $dateSpan = $('.date', $backTemplate),
        $placeSpan = $('.place', $backTemplate),
        $descSpan = $('.description', $backTemplate),
        $organizerSpan = $('.organizer', $backTemplate);

    $eventSpan.text( data.title );
    $dateSpan.text( date.createdAt );
    $placeSpan.text( 'PLACE' );
    $descSpan.text( data.description );
    $organizerSpan.text( 'MOZILLA' );
    $el.append( $backTemplate );
  }

  // set up mouse over handlers
  if ($body[0].id === 'index' || $body[0].id === 'search-results') {
    $makeTemplate.on('mouseenter focusin, mouseleave focusout', function ( e ) {
      $('.flipContainer', this).toggleClass( 'flip' );
    });
  }

  function searchCallback( data, self ) {
    var $makeContainer = $makeTemplate.clone( true ).addClass('rf'),
        makeContainer = $makeContainer[0],
        randSize = 'large';

    // If we're not in mobile view, we want to display multiple sizes for
    // the home page and the medium size for the teach page.
    if (!isMobile) {
      switch( $body[0].id ) {
        case 'index':
          if (countLarge > 0) {
            randSize = 'large';
            countLarge --;
          } else {
            randSize = 'medium';
            countMedium --;
          }
          break;

        case 'teach':
          randSize = 'medium';
          break;

        case 'search-results':
          randSize = 'medium';
          break;
      }
    }

    // create front Element & populate
    var $frontEl = $('<div class="front"><div class="preview-img"><img src="' + data.thumbnail +
      '" alt="' + data.title + '"><img class="share-icon" alt="Share" src="../img/share-icon.png" /></div></div>');

    // create back element & populate
    var $backEl = $('<div class="back"></div>');
    var tags = data.tags;

    /*
     * Not going to make it for June 15th/MVP
     * so I'm commenting this out. - DK
    if ( tags.popcorn ) {
      $frontEl.addClass( 'popcorn' );
    } else if ( tags.challenge ) {
      $frontEl.addClass( 'challenge' );
    } else if ( tags.event ) {
      $frontEl.addClass( 'event' );
    } else if ( tags.guide ) {
      $frontEl.addClass( 'guide' );
    } else if ( tags['make-demo'] ) {
      $frontEl.addClass( 'make-demo' );
    } else {
      $frontEl.addClass( 'default' );
    }
    */
    $makeContainer.addClass(randSize);

    switch( $body[0].id ) {
      case 'index':
        createMakeBack( data, $backEl );
        break;

      case 'teach':
        createMakeTeach( data, $frontEl );
        break;

      case 'search-results':
        createMakeBack( data, $backEl );
        break;
    }

{'fraction_non_alphanumeric': 0.17388594577750077, 'fraction_numerical': 0.0029084865482497143, 'mean_word_length': 2.515151515151515, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 27, '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': '752831', 'n_tokens_mistral': 3098, 'n_tokens_neox': 2969, 'n_words': 676}