Commit c876b05c authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Convert URL-s to links in video description.

Also don't create the XTemplate object more than once.
parent 2683cbf8
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -12,12 +12,18 @@ Ext.define('Docs.view.videos.Container', {
     * @param {Object} video
     */
    load: function(video) {
        this.tpl = new Ext.XTemplate(
        this.tpl = this.tpl || new Ext.XTemplate(
            '<iframe id="videoplayer"',
            ' src="http://player.vimeo.com/video/{id}?portrait=0&amp;color=4CC208"',
            ' width="640" height="360" frameborder="0"></iframe>',
            '<h1>{title}</h1>',
            '<p>{description}</p>'
            '<p>{[this.linkify(values.description)]}</p>',
            {
                // Detects URL-s in text and converts them to links
                linkify: function(text) {
                    return text.replace(/(\bhttps?:\/\/\S+)/ig, "<a href='$1'>$1</a>");
                }
            }
        );
        this.update(this.tpl.apply(video));
    }