constructor()

in src/StrippetsVisual.ts [510:562]


    constructor(options: VisualConstructorOptions) {
        const template = require('./../templates/strippets.handlebars');
        this.$loaderElement = $(require('./../templates/loader.handlebars')());
        this.element = $('<div/>');
        this.element.append(template());
        $(options.element).append(this.element);

        this.$container = this.element.find('.strippets-container');
        this.$tabs = this.element.find('.nav');
        this.selectionManager = options.host.createSelectionManager();
        this.host = this.selectionManager['hostServices'];
        this.colors = options.host.colors || (options.host['colorPalette'] ? options.host['colorPalette'].colors : []);

        this.inSandbox = this.element.parents('body.visual-sandbox').length > 0;

        this.viewportSize = { width: this.$container.parent().width(), height: this.$container.parent().height() };
        this.$container.width(this.viewportSize.width - this.$tabs.width());
        this.minOutlineCount = this.viewportSize.width / OUTLINE_WIDTH + 10;
        this.outlines = { $elem: this.$container.find('.outlines-panel') };
        this.thumbnails = { $elem: this.$container.find('.thumbnails-panel') };

        this.initializeTabs(this.$tabs);

        this.resizeOutlines = _.debounce(function () {
            if (this.outlines && this.outlines.instance) {
                this.outlines.instance.resize();
            }
            else if (this.thumbnails && this.thumbnails.instance) {
                this.thumbnails.instance.resize();
            }
        }, ENTITIES_REPOSITION_DELAY).bind(this);

        // Kill touch events to prevent PBI mobile app refreshing while scrolling strippets
        const killEvent = (event) => {
            event.originalEvent.stopPropagation();
            event.originalEvent.stopImmediatePropagation();
            return true;
        };
        this.$container.on('touchstart', killEvent);
        this.$container.on('touchmove', killEvent);
        this.$container.on('touchend', killEvent);

        const findApi = (methodName) => {
            return options.host[methodName] ? (arg) => {
                options.host[methodName](arg);
            } : this.host && this.host[methodName] ? (arg) => {
                this.host[methodName](arg);
            } : null;
        };

        this.loadMoreData = findApi("loadMoreData");
        this.launchUrl = findApi("launchUrl");
    }