<commit_before>(function () {
    var ns = $.namespace("pskl.controller");
    ns.PreviewFilmController = function (framesheet, container, dpi) {

        this.framesheet = framesheet;
        this.container = container;
        this.dpi = this.calculateDPI_();

        this.redrawFlag = true;

        $.subscribe(Events.TOOL_RELEASED, this.flagForRedraw_.bind(this));
        $.subscribe(Events.FRAMESHEET_RESET, this.flagForRedraw_.bind(this));
        $.subscribe(Events.FRAMESHEET_RESET, this.refreshDPI_.bind(this));

        $('#preview-list-scroller').scroll(this.updateScrollerOverflows.bind(this));
        this.updateScrollerOverflows();
    };

    ns.PreviewFilmController.prototype.init = function() {};

    ns.PreviewFilmController.prototype.addFrame = function () {
        this.framesheet.addEmptyFrame();
        this.framesheet.setCurrentFrameIndex(this.framesheet.getFrameCount() - 1);
        this.updateScrollerOverflows();
    };

    ns.PreviewFilmController.prototype.flagForRedraw_ = function () {
        this.redrawFlag = true;
    };

    ns.PreviewFilmController.prototype.refreshDPI_ = function () {
        this.dpi = this.calculateDPI_();
    };

    ns.PreviewFilmController.prototype.render = function () {
        if (this.redrawFlag) {
            // TODO(vincz): Full redraw on any drawing modification, optimize.
            this.createPreviews_();
            this.redrawFlag = false;
        }
    };

    ns.PreviewFilmController.prototype.updateScrollerOverflows = function () {
        var scroller = $('#preview-list-scroller');
        var scrollerHeight = scroller.height();
        var scrollTop = scroller.scrollTop();
        var scrollerContentHeight = $('#preview-list').height();
        var treshold = $('.top-overflow').height();
        var overflowTop = false,
            overflowBottom = false;
        if (scrollerHeight < scrollerContentHeight) {
            if (scrollTop > treshold) {
                overflowTop = true;
            }
            var scrollBottom = (scrollerContentHeight - scrollTop) - scrollerHeight;
            if (scrollBottom > treshold) {
                overflowBottom = true;
            }
        }
        var wrapper = $('#preview-list-wrapper');
        wrapper.toggleClass('top-overflow-visible', overflowTop);
        wrapper.toggleClass('bottom-overflow-visible', overflowBottom);
    };

    ns.PreviewFilmController.prototype.createPreviews_ = function () {
        
        this.container.html("");
        // Manually remove tooltips since mouseout events were shortcut by the DOM refresh:
        $(".tooltip").remove();

        var frameCount = this.framesheet.getFrameCount();

        for (var i = 0, l = frameCount; i < l ; i++) {
            this.container.append(this.createPreviewTile_(i));
        }
        // Append 'new empty frame' button
        var newFrameButton = document.createElement("div");
        newFrameButton.id = "add-frame-action";
        newFrameButton.className = "add-frame-action";
        newFrameButton.innerHTML = "<p class='label'>Add new frame</p>";
        this.container.append(newFrameButton);

        $(newFrameButton).click(this.addFrame.bind(this));

        var needDragndropBehavior = (frameCount > 1);
        if(needDragndropBehavior) {
            this.initDragndropBehavior_();
        }
        this.updateScrollerOverflows();
    };


    /**
     * @private
     */
    ns.PreviewFilmController.prototype.initDragndropBehavior_ = function () {
        
        $("#preview-list").sortable({
          placeholder: "preview-tile-drop-proxy",
          update: $.proxy(this.onUpdate_, this)
        });
        $("#preview-list").disableSelection();
    };
<commit_msg>Exclude add-frame-button from sortable items in preview-film<commit_after>(function () {
    var ns = $.namespace("pskl.controller");
    ns.PreviewFilmController = function (framesheet, container, dpi) {

        this.framesheet = framesheet;
        this.container = container;
        this.dpi = this.calculateDPI_();

        this.redrawFlag = true;

        $.subscribe(Events.TOOL_RELEASED, this.flagForRedraw_.bind(this));
        $.subscribe(Events.FRAMESHEET_RESET, this.flagForRedraw_.bind(this));
        $.subscribe(Events.FRAMESHEET_RESET, this.refreshDPI_.bind(this));

        $('#preview-list-scroller').scroll(this.updateScrollerOverflows.bind(this));
        this.updateScrollerOverflows();
    };

    ns.PreviewFilmController.prototype.init = function() {};

    ns.PreviewFilmController.prototype.addFrame = function () {
        this.framesheet.addEmptyFrame();
        this.framesheet.setCurrentFrameIndex(this.framesheet.getFrameCount() - 1);
        this.updateScrollerOverflows();
    };

    ns.PreviewFilmController.prototype.flagForRedraw_ = function () {
        this.redrawFlag = true;
    };

    ns.PreviewFilmController.prototype.refreshDPI_ = function () {
        this.dpi = this.calculateDPI_();
    };

    ns.PreviewFilmController.prototype.render = function () {
        if (this.redrawFlag) {
            // TODO(vincz): Full redraw on any drawing modification, optimize.
            this.createPreviews_();
            this.redrawFlag = false;
        }
    };

    ns.PreviewFilmController.prototype.updateScrollerOverflows = function () {
        var scroller = $('#preview-list-scroller');
        var scrollerHeight = scroller.height();
        var scrollTop = scroller.scrollTop();
        var scrollerContentHeight = $('#preview-list').height();
        var treshold = $('.top-overflow').height();
        var overflowTop = false,
            overflowBottom = false;
        if (scrollerHeight < scrollerContentHeight) {
            if (scrollTop > treshold) {
                overflowTop = true;
            }
            var scrollBottom = (scrollerContentHeight - scrollTop) - scrollerHeight;
            if (scrollBottom > treshold) {
                overflowBottom = true;
            }
        }
        var wrapper = $('#preview-list-wrapper');
        wrapper.toggleClass('top-overflow-visible', overflowTop);
        wrapper.toggleClass('bottom-overflow-visible', overflowBottom);
    };

    ns.PreviewFilmController.prototype.createPreviews_ = function () {
        
        this.container.html("");
        // Manually remove tooltips since mouseout events were shortcut by the DOM refresh:
        $(".tooltip").remove();

        var frameCount = this.framesheet.getFrameCount();

        for (var i = 0, l = frameCount; i < l ; i++) {
            this.container.append(this.createPreviewTile_(i));
        }
        // Append 'new empty frame' button
        var newFrameButton = document.createElement("div");
        newFrameButton.id = "add-frame-action";
        newFrameButton.className = "add-frame-action";
        newFrameButton.innerHTML = "<p class='label'>Add new frame</p>";
        this.container.append(newFrameButton);

        $(newFrameButton).click(this.addFrame.bind(this));

        var needDragndropBehavior = (frameCount > 1);
        if(needDragndropBehavior) {
            this.initDragndropBehavior_();
        }
        this.updateScrollerOverflows();
    };


    /**
     * @private
     */
    ns.PreviewFilmController.prototype.initDragndropBehavior_ = function () {

        $("#preview-list").sortable({
          placeholder: "preview-tile-drop-proxy",
          update: $.proxy(this.onUpdate_, this),
          items: "li:not(#add-frame-action)"
        });
        $("#preview-list").disableSelection();
    };

{'fraction_non_alphanumeric': 0.12783751493428913, 'fraction_numerical': 0.0007964954201513341, 'mean_word_length': 2.5107176141658902, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 13, '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': '1995318', 'n_tokens_mistral': 2096, 'n_tokens_neox': 2025, 'n_words': 344}