Committer: vvasin
LJSUP-14136: [Friends Feed] Optimize like buttons parsing. Replace iframe creation with createElement.U trunk/htdocs/js/livejournal.js
Modified: trunk/htdocs/js/livejournal.js =================================================================== --- trunk/htdocs/js/livejournal.js 2012-11-01 13:45:42 UTC (rev 23241) +++ trunk/htdocs/js/livejournal.js 2012-11-01 14:40:41 UTC (rev 23242) @@ -448,6 +448,34 @@ } } + /** + * Create iframe node with params + * @param {Object} params Params for iframe {src, width, height...} + * @return {DOM} [description] + */ + function createIframe(params) { + var iframe = document.createElement('iframe'), + param; + + // defaults + iframe.frameBorder = 0; + iframe.scrolling = 'no'; + iframe.allowTransparency = 'true'; + iframe.width = 110; + iframe.height = 20; + + // reassign params + if (params) { + for (param in params) { + if (params.hasOwnProperty(param)) { + iframe[param] = params[param]; + } + } + } + + return iframe; + } + function parseTwitter($node) { var params = null, iframe = null, @@ -462,15 +490,8 @@ lang: link.data('lang') }; - iframe = $('<iframe />', { - frameborder: 0, - scrolling: 'no', - allowtransparency: true, + iframe = createIframe({ src: LiveJournal.constructUrl('http://platform.twitter.com/widgets/tweet_button.html', params) - }) - .css({ - width: 110, - height: 20 }); link.replaceWith(iframe); @@ -487,15 +508,8 @@ layout: 'common' }; - iframe = $('<iframe />', { - frameborder: 0, - scrolling: 'no', - allowtransparency: true, + iframe = createIframe({ src: LiveJournal.constructUrl('http://surfingbird.ru/button', params) - }) - .css({ - width: 110, - height: 20 }); link.replaceWith(iframe);