<commit_before>/// <reference path="../../js/jquery.d.ts" />

import baseLeft = require("../coreplayer-shared-module/leftPanel");
import utils = require("../../utils");
import tree = require("./treeView");
import thumbs = require("./thumbsView");
import baseView = require("../coreplayer-shared-module/baseView");
import extension = require("../../extensions/coreplayer-seadragon-extension/extension");

export class TreeViewLeftPanel extends baseLeft.LeftPanel {

    $tabs: JQuery;
    $treeButton: JQuery;
    $thumbsButton: JQuery;
    $tabsContent: JQuery;
    $options: JQuery;
    $views: JQuery;
    $treeView: JQuery;
    $thumbsView: JQuery;
    treeView: tree.TreeView;
    thumbsView: thumbs.ThumbsView;

    static OPEN_TREE_VIEW: string = 'leftPanel.onOpenTreeView';
    static OPEN_THUMBS_VIEW: string = 'leftPanel.onOpenThumbsView';

    constructor($element: JQuery) {
        super($element);
    }

    create(): void {

        this.setConfig('treeViewLeftPanel');

        super.create();

        $.subscribe(extension.Extension.RELOAD, () => {
            this.dataBindThumbsView();
        });

        this.$tabs = utils.Utils.createDiv('tabs');
        this.$main.append(this.$tabs);

        this.$treeButton = $('<a class="tab first">' + this.content.index + '</a>');
        this.$tabs.append(this.$treeButton);

        this.$thumbsButton = $('<a class="tab">' + this.content.thumbnails + '</a>');
        this.$tabs.append(this.$thumbsButton);

        this.$tabsContent = utils.Utils.createDiv('tabsContent');
        this.$main.append(this.$tabsContent);

        this.$options = $('<div class="options"></div>');
        this.$tabsContent.append(this.$options);

        this.$views = $('<div class="views"></div>');
        this.$tabsContent.append(this.$views);

        this.$treeView = utils.Utils.createDiv('treeView');
        this.$views.append(this.$treeView);

        this.$thumbsView = utils.Utils.createDiv('thumbsView');
        this.$views.append(this.$thumbsView);

        this.$treeButton.on('click', (e) => {
            e.preventDefault();

            this.openTreeView();

            $.publish(TreeViewLeftPanel.OPEN_TREE_VIEW);
        });

        this.$thumbsButton.on('click', (e) => {
            e.preventDefault();

            this.openThumbsView();

            $.publish(TreeViewLeftPanel.OPEN_THUMBS_VIEW);
        });
    }

    createTreeView(): void {
        this.treeView = new tree.TreeView(this.$treeView);
        this.dataBindTreeView();
    }

    dataBindTreeView(): void{
        this.treeView.rootNode = this.provider.getTree();
        this.treeView.dataBind();
    }

    createThumbsView(): void {
        this.thumbsView = new thumbs.ThumbsView(this.$thumbsView);
        this.dataBindThumbsView();
    }

    dataBindThumbsView(): void{
        this.thumbsView.thumbs = this.provider.getThumbs();
        this.thumbsView.dataBind();
    }

    toggleComplete(): void {
        super.toggleComplete();

        if (this.isUnopened) {

            var treeEnabled = utils.Utils.getBool(this.config.options.treeEnabled, true);
            var thumbsEnabled = utils.Utils.getBool(this.config.options.thumbsEnabled, true);

            // hide the tabs if either tree or thumbs are disabled.
            if (!treeEnabled || !thumbsEnabled) this.$tabs.hide();

            if (thumbsEnabled && this.defaultToThumbsView()){
                this.$tabs.hide();
                this.openThumbsView();
            } else if (treeEnabled){
                this.openTreeView();
            }
        }
    }

    // todo: should this be in the provider?
    defaultToThumbsView(): boolean{
        var manifestType = this.provider.getManifestType();

        switch (manifestType){
            case 'archive': return true;
            case 'boundmanuscript': return true;
            case 'artwork': return true;
        }

        var sequenceType = this.provider.getSequenceType();

        switch (sequenceType){
            case 'application-pdf': return true;
        }

        return false;
    }

    openTreeView(): void {
        if (!this.treeView) {
            this.createTreeView();
        }

        this.$treeButton.addClass('on');
        this.$thumbsButton.removeClass('on');

        (<tree.TreeView>this.treeView).show();
        if (this.thumbsView) (<thumbs.ThumbsView>this.thumbsView).hide();
    }

    openThumbsView(): void {
        if (!this.thumbsView) {
            this.createThumbsView();
        }

        this.$treeButton.removeClass('on');
        this.$thumbsButton.addClass('on');

        if (this.treeView) (<tree.TreeView>this.treeView).hide();
        (<thumbs.ThumbsView>this.thumbsView).show();
    }

    resize(): void {
        super.resize();
<commit_msg>resize tree and thumbs when shown as options may be shown/hidden<commit_after>/// <reference path="../../js/jquery.d.ts" />

import baseLeft = require("../coreplayer-shared-module/leftPanel");
import utils = require("../../utils");
import tree = require("./treeView");
import thumbs = require("./thumbsView");
import baseView = require("../coreplayer-shared-module/baseView");
import extension = require("../../extensions/coreplayer-seadragon-extension/extension");

export class TreeViewLeftPanel extends baseLeft.LeftPanel {

    $tabs: JQuery;
    $treeButton: JQuery;
    $thumbsButton: JQuery;
    $tabsContent: JQuery;
    $options: JQuery;
    $views: JQuery;
    $treeView: JQuery;
    $thumbsView: JQuery;
    treeView: tree.TreeView;
    thumbsView: thumbs.ThumbsView;

    static OPEN_TREE_VIEW: string = 'leftPanel.onOpenTreeView';
    static OPEN_THUMBS_VIEW: string = 'leftPanel.onOpenThumbsView';

    constructor($element: JQuery) {
        super($element);
    }

    create(): void {

        this.setConfig('treeViewLeftPanel');

        super.create();

        $.subscribe(extension.Extension.RELOAD, () => {
            this.dataBindThumbsView();
        });

        this.$tabs = utils.Utils.createDiv('tabs');
        this.$main.append(this.$tabs);

        this.$treeButton = $('<a class="tab first">' + this.content.index + '</a>');
        this.$tabs.append(this.$treeButton);

        this.$thumbsButton = $('<a class="tab">' + this.content.thumbnails + '</a>');
        this.$tabs.append(this.$thumbsButton);

        this.$tabsContent = utils.Utils.createDiv('tabsContent');
        this.$main.append(this.$tabsContent);

        this.$options = $('<div class="options"></div>');
        this.$tabsContent.append(this.$options);

        this.$views = $('<div class="views"></div>');
        this.$tabsContent.append(this.$views);

        this.$treeView = utils.Utils.createDiv('treeView');
        this.$views.append(this.$treeView);

        this.$thumbsView = utils.Utils.createDiv('thumbsView');
        this.$views.append(this.$thumbsView);

        this.$treeButton.on('click', (e) => {
            e.preventDefault();

            this.openTreeView();

            $.publish(TreeViewLeftPanel.OPEN_TREE_VIEW);
        });

        this.$thumbsButton.on('click', (e) => {
            e.preventDefault();

            this.openThumbsView();

            $.publish(TreeViewLeftPanel.OPEN_THUMBS_VIEW);
        });
    }

    createTreeView(): void {
        this.treeView = new tree.TreeView(this.$treeView);
        this.dataBindTreeView();
    }

    dataBindTreeView(): void{
        this.treeView.rootNode = this.provider.getTree();
        this.treeView.dataBind();
    }

    createThumbsView(): void {
        this.thumbsView = new thumbs.ThumbsView(this.$thumbsView);
        this.dataBindThumbsView();
    }

    dataBindThumbsView(): void{
        this.thumbsView.thumbs = this.provider.getThumbs();
        this.thumbsView.dataBind();
    }

    toggleComplete(): void {
        super.toggleComplete();

        if (this.isUnopened) {

            var treeEnabled = utils.Utils.getBool(this.config.options.treeEnabled, true);
            var thumbsEnabled = utils.Utils.getBool(this.config.options.thumbsEnabled, true);

            // hide the tabs if either tree or thumbs are disabled.
            if (!treeEnabled || !thumbsEnabled) this.$tabs.hide();

            if (thumbsEnabled && this.defaultToThumbsView()){
                this.$tabs.hide();
                this.openThumbsView();
            } else if (treeEnabled){
                this.openTreeView();
            }
        }
    }

    // todo: should this be in the provider?
    defaultToThumbsView(): boolean{
        var manifestType = this.provider.getManifestType();

        switch (manifestType){
            case 'archive': return true;
            case 'boundmanuscript': return true;
            case 'artwork': return true;
        }

        var sequenceType = this.provider.getSequenceType();

        switch (sequenceType){
            case 'application-pdf': return true;
        }

        return false;
    }

    openTreeView(): void {
        if (!this.treeView) {
            this.createTreeView();
        }

        this.$treeButton.addClass('on');
        this.$thumbsButton.removeClass('on');

        (<tree.TreeView>this.treeView).show();
        if (this.thumbsView) (<thumbs.ThumbsView>this.thumbsView).hide();

        this.treeView.resize();
    }

    openThumbsView(): void {
        if (!this.thumbsView) {
            this.createThumbsView();
        }

        this.$treeButton.removeClass('on');
        this.$thumbsButton.addClass('on');

        if (this.treeView) (<tree.TreeView>this.treeView).hide();
        (<thumbs.ThumbsView>this.thumbsView).show();

        this.thumbsView.resize();
    }

    resize(): void {
        super.resize();

{'fraction_non_alphanumeric': 0.15148381759900734, 'fraction_numerical': 0.0, 'mean_word_length': 2.396067415730337, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 35, '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': '5629655', 'n_tokens_mistral': 2861, 'n_tokens_neox': 2763, 'n_words': 464}