Outline.prototype.constructLayout = function()

in lib/@uncharted/strippets/src/strippets.outline.js [209:257]


Outline.prototype.constructLayout = function($parent) {
    var s = this;

    /* create the container */
    this.$outlineContainer = $(this.templates.outline.outlineContainerTemplate)
        .addClass(this.classes.outline.outlinecontainer)
        .addClass(this.classes.outline.minimizedmode)
        .appendTo($parent);

    /* create the outline */
    this.$outline = $(this.templates.outline.outlineItemTemplate)
        .addClass(this.classes.outline.outline)
        .css({'border-left-width': '0', 'border-right-width': '0'})
        .appendTo(this.$outlineContainer);

    /* create the header */
    this.$outlineHeader = $(this.templates.outline.outlineHeaderTemplate)
        .appendTo(this.$outline);

    /* create the source icon */
    this.$outlineSourceIcon = $(this.templates.outline.outlineSourceIconTemplate)
        .addClass(this.classes.outline.sourceIcon)
        .appendTo(this.$outlineHeader);

    if (this.data.sourceimage) {
        this.$outlineSourceIcon.css('background-image', "url('" + this.data.sourceimage + "')");
    } else if (this.data.sourceiconname || this.data.source) {
        var size = (this.styles && this.styles.sourceIcon && this.styles.normal &&
            parseInt(this.styles.sourceIcon.normal.height, 10)) || this.$outlineSourceIcon.height();
        var sourceName = (this.data.sourceiconname || this.data.source);
        this.$outlineSourceIcon.css('background-image', "url('" + util.createFallbackIconURL(size, size, sourceName) + "')");
    }

    /* create the source link */
    var outlineSourceTemplate = _.template(this.templates.outline.outlineSourceTemplate);
    /* eslint-disable camelcase */
    this.$outlineSource = $(outlineSourceTemplate({src_url: this.data.sourceUrl, src_title: this.data.source}))
        /* eslint-enable camelcase */
        .addClass(this.classes.outline.sourceText)
        .on('click', 'a', function(event) {
            var href = event.currentTarget.href;
            if (href && s.Settings.reader.onSourceUrlClicked) {
                s.Settings.reader.onSourceUrlClicked(href);
                return false;
            }
            return true;
        })
        .appendTo(this.$outlineSourceIcon);
};