<commit_before>/*jslint browser: true, nomen: true, unparam: true */
/*global angular: false, $: false, CONFIG: false */
(function () {
    'use strict';

    angular.module('tinyCarousel', [])
        .directive('tinyCarousel', ['$timeout', '$raf', function ($timeout, $raf) {

            return {
                templateUrl: 'tinyCarousel.html',
                restrict: 'A',

                scope: {
                    tinycarousel: '='
                },

                link: function (scope, elem, attrs) {

                    var $el = angular.element(elem),
                        $viewport = $el.find('.viewport:first'),
                        $overview = $el.find('.overview:first'),
                        $buttonNext = $el.find('.next:first'),
                        $buttonPrev = $el.find('.prev:first'),

                        start,
                        update,
                        intervalTimer = null,
                        carouselData;

                    scope.carouselID = attrs.tinyCarousel;

                    scope.options = {
                        start: 0,           // The starting slide
                        axis: "x",          // vertical or horizontal scroller? ( x || y ).
                        buttons: true,      // show left and right navigation buttons.
                        bullets: false,     // is there a page number navigation present?
                        interval: false,    // move to another block on intervals.
                        intervalTime: 5000, // interval time in milliseconds.
                        animation: true,    // false is instant, true is animate.
                        animationTime: 500, // how fast must the animation move in ms?
                        infinite: true      // infinite carousel. 
                    };

                    scope.options.interval = attrs.tinyCarouselInterval !== undefined ? true : false;

                    scope.slidesVisible = 0;
                    scope.slideSize = 0;
                    scope.slideIndex = 0;
                    scope.isHorizontal = scope.options.axis === 'x';
                    scope.sizeLabel = scope.isHorizontal ? "Width" : "Height";
                    scope.posiLabel = scope.isHorizontal ? "left" : "top";

                    scope.slideCurrent = 0;

                    scope.carouselTemplate = '';
                    scope.carouselItems = [];
                    scope.carouselItemsMirrored = [];


                    start = function () {

                        if (scope.options.interval) {

                            clearTimeout(intervalTimer);

                            intervalTimer = setTimeout(function () {

                                scope.move((scope.slideIndex + 1));

                            }, scope.options.intervalTime);
                        }
                    };

                    scope.move = function (index) {

                        scope.$broadcast('tinyCarousel:move', index);

                        start();
                    };

                    scope.carouselItemClicked = function (item) {

                        scope.$parent.$broadcast('tinyCarousel:itemClicked', scope.carouselID, item);
                    };

                    update = function () {

                        $timeout(function () {

                            scope.carouselItemsMirrored = [];
                            
                            scope.$broadcast('tinyCarousel:update');

                            scope.move(0);
                        }, 1000);
                    }

                    scope.$watch(function () {
                        return scope.carouselItems;
                    }, function (newVal, oldVal) {

                        if (newVal !== oldVal) {

                            update();
                        }
                    });

                    scope.$on('tinyCarousel:update', function () {

                        var $slides = $overview.children(),
                            viewportOffset,
                            viewportSize;

                        viewportSize = scope.sizeLabel === "Width" ? $viewport.outerWidth(true) : $viewport.outerHeight(true);
                        viewportOffset = !isNaN(parseInt($viewport.css(scope.posiLabel), 10)) ? parseInt($viewport.css(scope.posiLabel), 10) * -1 : 0;

                        scope.slideSize = scope.sizeLabel === "Width" ? $slides.first().outerWidth(true) : $slides.first().outerHeight(true);
                        scope.slideCurrent = scope.options.start || 0;
                        scope.slidesVisible = Math.ceil((viewportSize + viewportOffset) / scope.slideSize);
                        
                        scope.carouselItemsMirrored = scope.carouselItems.slice(0, scope.slidesVisible);

                        $raf(function () {
                            $overview.css(scope.sizeLabel.toLowerCase(), scope.slideSize * (scope.carouselItems.length + scope.slidesVisible));
                            
                            if (scope.sizeLabel === 'Width') {
                                $viewport.css('height', $slides.first().outerHeight(true));<commit_msg>disable auto-sliding if carousel items count less than visible area<commit_after>/*jslint browser: true, nomen: true, unparam: true */
/*global angular: false, $: false, CONFIG: false */
(function () {
    'use strict';

    angular.module('tinyCarousel', [])
        .directive('tinyCarousel', ['$timeout', '$raf', function ($timeout, $raf) {

            return {
                templateUrl: 'tinyCarousel.html',
                restrict: 'A',

                scope: {
                    tinycarousel: '='
                },

                link: function (scope, elem, attrs) {

                    var $el = angular.element(elem),
                        $viewport = $el.find('.viewport:first'),
                        $overview = $el.find('.overview:first'),
                        $buttonNext = $el.find('.next:first'),
                        $buttonPrev = $el.find('.prev:first'),

                        start,
                        update,
                        intervalTimer = null,
                        carouselData;

                    scope.carouselID = attrs.tinyCarousel;

                    scope.options = {
                        start: 0,           // The starting slide
                        axis: "x",          // vertical or horizontal scroller? ( x || y ).
                        buttons: true,      // show left and right navigation buttons.
                        bullets: false,     // is there a page number navigation present?
                        interval: false,    // move to another block on intervals.
                        intervalTime: 5000, // interval time in milliseconds.
                        animation: true,    // false is instant, true is animate.
                        animationTime: 500, // how fast must the animation move in ms?
                        infinite: true      // infinite carousel. 
                    };

                    scope.options.interval = attrs.tinyCarouselInterval !== undefined ? true : false;

                    scope.slidesVisible = 0;
                    scope.slideSize = 0;
                    scope.slideIndex = 0;
                    scope.isHorizontal = scope.options.axis === 'x';
                    scope.sizeLabel = scope.isHorizontal ? "Width" : "Height";
                    scope.posiLabel = scope.isHorizontal ? "left" : "top";

                    scope.slideCurrent = 0;

                    scope.carouselTemplate = '';
                    scope.carouselItems = [];
                    scope.carouselItemsMirrored = [];


                    start = function () {

                        // Set timer only if auto-sliding requested and items count greater than visible area
                        if (scope.options.interval && scope.slidesVisible < scope.carouselItems.length) {

                            clearTimeout(intervalTimer);

                            intervalTimer = setTimeout(function () {

                                scope.move((scope.slideIndex + 1));

                            }, scope.options.intervalTime);
                        }
                    };

                    scope.move = function (index) {

                        scope.$broadcast('tinyCarousel:move', index);

                        start();
                    };

                    scope.carouselItemClicked = function (item) {

                        scope.$parent.$broadcast('tinyCarousel:itemClicked', scope.carouselID, item);
                    };

                    update = function () {

                        $timeout(function () {

                            scope.carouselItemsMirrored = [];
                            
                            scope.$broadcast('tinyCarousel:update');

                            scope.move(0);
                        }, 1000);
                    }

                    scope.$watch(function () {
                        return scope.carouselItems;
                    }, function (newVal, oldVal) {

                        if (newVal !== oldVal) {

                            update();
                        }
                    });

                    scope.$on('tinyCarousel:update', function () {

                        var $slides = $overview.children(),
                            viewportOffset,
                            viewportSize;

                        viewportSize = scope.sizeLabel === "Width" ? $viewport.outerWidth(true) : $viewport.outerHeight(true);
                        viewportOffset = !isNaN(parseInt($viewport.css(scope.posiLabel), 10)) ? parseInt($viewport.css(scope.posiLabel), 10) * -1 : 0;

                        scope.slideSize = scope.sizeLabel === "Width" ? $slides.first().outerWidth(true) : $slides.first().outerHeight(true);
                        scope.slideCurrent = scope.options.start || 0;
                        scope.slidesVisible = Math.ceil((viewportSize + viewportOffset) / scope.slideSize);
                        
                        if (scope.slidesVisible < scope.carouselItems.length) {
                        
                            scope.carouselItemsMirrored = scope.carouselItems.slice(0, scope.slidesVisible);
                        }

                        $raf(function () {
                            $overview.css(scope.sizeLabel.toLowerCase(), scope.slideSize * (scope.carouselItems.length + scope.slidesVisible));
                            
                            if (scope.sizeLabel === 'Width') {
                                $viewport.css('height', $slides.first().outerHeight(true));
{'fraction_non_alphanumeric': 0.10428029952851993, 'fraction_numerical': 0.0048072478506055285, 'mean_word_length': 1.1026239067055394, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '2797733', 'n_tokens_mistral': 2565, 'n_tokens_neox': 2301, 'n_words': 486}