<commit_before>$(function () {
    if (!$("body").hasClass('addon-details')) return;
    $(".previews").zCarousel({
        btnNext: ".previews .next",
        btnPrev: ".previews .prev",
        itemsPerPage: 3
    });
    (function() {
        var $document = $(document),
            $lightbox = $("#lightbox"),
            $content = $("#lightbox .content"),
            $caption = $("#lightbox .caption span"),
            $previews = $('.previews'),
            current, $strip,
            lbImage = template('<img id="preview{0}" src="{1}" alt="">');
        if (!$lightbox.length) return;
        function showLightbox() {
            $lightbox.show();
            showImage(this);
            $(window).bind('keydown.lightboxDismiss', function(e) {
                switch(e.which) {
                    case z.keys.ESCAPE:
                        e.preventDefault();
                        hideLightbox();
                        break;
                    case z.keys.LEFT:
                        e.preventDefault();
                        showPrev();
                        break;
                    case z.keys.RIGHT:
                        e.preventDefault();
                        showNext();
                        break;
                }
            });
            //I want to ensure the lightbox is painted before fading it in.
            setTimeout(function () {
                $lightbox.addClass("show");
            },0);
        }
        function hideLightbox() {
            $lightbox.removeClass("show");
            // We can't trust transitionend to fire in all cases.
            setTimeout(function() {
                $lightbox.hide();
            }, 500);
            $(window).unbind('keydown.lightboxDismiss');
        }
        function showImage(a) {
            var $a = $(a),
                $oldimg = $lightbox.find("img");
            current = $a.parent().index();
            $strip = $a.closest("ul").find("li");
            $previews.find('.panel').removeClass('active')
                     .eq(current).addClass('active');
            var $img = $("#preview"+current);
            if ($img.length) {
                $oldimg.css("opacity", 0);
                $img.css({
                    "opacity": 1
                });
            } else {
                $img = $(lbImage([current, $a.attr("href")]));
                $content.append($img);
                $img.load(function(e) {
                    $oldimg.css("opacity", 0);
                    $img.css({
                        "opacity": 1
                    });
                    for (var i=0; i<$strip.length; i++) {
                        if (i != current) {
                            var $p = $strip.eq(i).find("a");
                            $content.append(lbImage([i, $p.attr("href")]));
                        }
                    }
                });
            }
            $caption.text($a.attr("title"));
            $lightbox.find(".control").removeClass("disabled");
            if (current < 1) {
                $lightbox.find(".control.prev").addClass("disabled");
            }
            if (current == $strip.length-1){
                $lightbox.find(".control.next").addClass("disabled");
            }
        }
        function showNext() {
            if (current < $strip.length-1) {
                showImage($strip.eq(current+1).find("a"));
                if (!this.window) {
                    $(this).blur();
                }
            }
        }
        function showPrev() {
            if (current > 0) {
                showImage($strip.eq(current-1).find("a"));
                if (!this.window) {<commit_msg>Fix lightbox not restacking (bug 752308)<commit_after>$(function () {
    if (!$("body").hasClass('addon-details')) return;
    $(".previews").zCarousel({
        btnNext: ".previews .next",
        btnPrev: ".previews .prev",
        itemsPerPage: 3
    });
    (function() {
        var $document = $(document),
            $lightbox = $("#lightbox"),
            $content = $("#lightbox .content"),
            $caption = $("#lightbox .caption span"),
            $previews = $('.previews'),
            current, $strip,
            lbImage = template('<img id="preview{0}" src="{1}" alt="">');
        if (!$lightbox.length) return;
        function showLightbox() {
            $lightbox.show();
            showImage(this);
            $(window).bind('keydown.lightboxDismiss', function(e) {
                switch(e.which) {
                    case z.keys.ESCAPE:
                        e.preventDefault();
                        hideLightbox();
                        break;
                    case z.keys.LEFT:
                        e.preventDefault();
                        showPrev();
                        break;
                    case z.keys.RIGHT:
                        e.preventDefault();
                        showNext();
                        break;
                }
            });
            //I want to ensure the lightbox is painted before fading it in.
            setTimeout(function () {
                $lightbox.addClass("show");
            },0);
        }
        function hideLightbox() {
            $lightbox.removeClass("show");
            // We can't trust transitionend to fire in all cases.
            setTimeout(function() {
                $lightbox.hide();
            }, 500);
            $(window).unbind('keydown.lightboxDismiss');
        }
        function showImage(a) {
            var $a = $(a),
                $oldimg = $lightbox.find("img");
            current = $a.parent().index();
            $strip = $a.closest("ul").find("li");
            $previews.find('.panel').removeClass('active')
                     .eq(current).addClass('active');
            var $img = $("#preview"+current);
            if ($img.length) {
                $oldimg.css({"opacity": "0", "z-index": "0"});
                $img.css({
                    "opacity": "1", "z-index": "1"
                });
            } else {
                $img = $(lbImage([current, $a.attr("href")]));
                $content.append($img);
                $img.load(function(e) {
                    $oldimg.css({"opacity": "0", "z-index": "0"});
                    $img.css({
                        "opacity": "1", "z-index": "1"
                    });
                    for (var i=0; i<$strip.length; i++) {
                        if (i != current) {
                            var $p = $strip.eq(i).find("a");
                            $content.append(lbImage([i, $p.attr("href")]));
                        }
                    }
                });
            }
            $caption.text($a.attr("title"));
            $lightbox.find(".control").removeClass("disabled");
            if (current < 1) {
                $lightbox.find(".control.prev").addClass("disabled");
            }
            if (current == $strip.length-1){
                $lightbox.find(".control.next").addClass("disabled");
            }
        }
        function showNext() {
            if (current < $strip.length-1) {
                showImage($strip.eq(current+1).find("a"));
                if (!this.window) {
                    $(this).blur();
                }
            }
        }
        function showPrev() {
            if (current > 0) {
                showImage($strip.eq(current-1).find("a"));
                if (!this.window) {
{'fraction_non_alphanumeric': 0.15856434980581224, 'fraction_numerical': 0.006160439266104192, 'mean_word_length': 1.1521613832853026, 'pattern_counts': {'":': 10, '<': 11, '<?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': '344661', 'n_tokens_mistral': 1962, 'n_tokens_neox': 1862, 'n_words': 343}