UNPKG

grunt-sencha-dependencies

Version:

A Grunt.js plugin which will figure out the order of Ext classes your Ext.application uses so the list can be passed on to further commands like concat, jshint, etc

29 lines (25 loc) 1.05 kB
/** * This is the component used in TweetListItem's to display the text of a tweet. * * This needs to be special so we can: * - linkify URLs in the tweet * - Wrap usernames with spans * - Wrap hashtags with spans. */ Ext.define('Twitter.view.TweetListItemText', { extend: 'Ext.Component', /** * We simply override the applyHtml method, which is called when the {@link #html} configuration is changed. * We run a few regexs and try and match the URLs, hashtags or usernames, and then return the resulting value * so the {@link #html} configuration can be updated (updateHtml). */ applyHtml: function(html) { // replace URLs with proper tags html = html.replace(/(http:\/\/[^\s]*)/g, "<a class=\"link\" target=\"_blank\" href=\"$1\">$1</a>"); // usernames html = html.replace(/(^|\s)@(\w+)/g, "$1<span class=\"username\">@$2</span>"); // hashtags html = html.replace(/(^|\s)#(\w+)/g, "$1<span class=\"hashtag\">#$2</span>"); return html; } });