"use strict";define("recommendations/models",["backbone","moment","core/time"],function(a,b,c){var d=function(a){var d=a.prototype;return a.extend({defaults:{threadId:null,forumId:null,forum:null,threadForum:null,requestBin:null,createdAgo:!1},initialize:function(a,d){if(this.set("threadForum",a.forum),d&&d.humanFriendlyTimestamp){var e=c.assureTzOffset(this.get("createdAt"));e=b(e,c.ISO_8601),this.set("createdAgo",e.fromNow())}},toJSON:function(){var a=d.toJSON.call(this);return a.preview&&(a.preview=a.preview.toJSON()),a},toString:function(){return"organic link: "+this.get("title")+" "+this.get("link")+" (id = "+this.id+")"}})}(a.Model);return{RelatedThread:d}}),define("recommendations/collections",["underscore","backbone","loglevel","moment","core/api","core/utils/html","recommendations/models"],function(a,b,c,d,e,f,g){var h=b.Collection.extend({url:e.getURL("discovery/listTopPost.json"),parse:function(a){for(var c=b.Collection.prototype.parse.call(this,a),d=0,e=c.length;d0){var f=d().subtract(this.settings.maxAgeDays,"days");a.data.since=f.startOf("hour").toISOString()}var g=Promise.resolve(b.Collection.prototype.fetch.call(this,a)),h=this;return e&&(g=g.then(function(){return h.getFeaturedPosts()["catch"](function(a){c.info("There was a problem fetching featured posts: ",a)})})),g},parse:function(a){var c=this,d=b.Collection.prototype.parse.call(this,a).filter(function(a){return Boolean(a.id)&&Boolean(a.images.length)&&Boolean(a.title)&&Boolean(a.description)&&Boolean(a.url)});return c.forumUrl?(c.forumUrl=c.forumUrl.replace(/(^\w+:|^)\/\/(www\.)?/,"").split("/")[0].toLowerCase(),d.filter(function(a){return a.url.indexOf(c.forumUrl)>-1})):d},getFeaturedPosts:function(){var b=this.map(function(a){return parseInt(a.get("id"),10)});if(b.length.2*k}function g(){i.lastChild&&!a.contains(["...","…"],i.lastChild.nodeValue)&&(l=i.appendChild(window.document.createTextNode(" "+o)),f()&&(i.removeChild(l),i.removeChild(i.lastChild),g()))}if(!d.closest("body").length)return void c.info("lineTruncate called on el not on DOM");if(d.text().length<1)return void c.info("lineTruncated called on empty el");var h=function(a){return 3!==a.nodeType};if(a.any(d.children(),h))return void c.info("lineTruncate called on non-flat el");var i=d[0],j=i;if("block"!==d.css("display"))for(;j.parentNode&&(j=j.parentNode,"block"!==b(j).css("display")););var k=parseFloat(d.parent().css("font-size"),10);if(f()){e=e||{};var l,m,n=e.lines||1,o=e.ellipsis,p=d.text();if(p.length){var q=d.width()/k,r=parseInt(q*n,10),s=p.split(/\s/),t=0;d.empty();var u=s.length;for(m=0;m=r));m++)0!==m&&(s[m]=" "+s[m]),i.appendChild(window.document.createTextNode(s[m]));if(f())for(;i.lastChild&&f();)l=i.removeChild(i.lastChild);else{do l=i.appendChild(window.document.createTextNode(" "+s[m])),m+=1;while(!f()&&m0;){d-=1;var e=a[d];e.length0?b.createElement("li",{className:"comments"},1===f.posts?e("1 comment"):e("%(numPosts)s comments",{numPosts:f.posts})," "):null),g.contentPreview?b.createElement(h,_extends({settings:g},f)):null,g.featuredComment&&!g.contentPreview?b.createElement(i,f):null)},h=function(a){return b.createElement("div",{className:"content-preview-wrapper"},b.createElement("div",{className:"recommend-content"},a.settings.titleHidden||!a.settings.disableOverlay?b.createElement("span",{"data-role":"recommend-description-snippet",className:"line-truncate","data-line-truncate":"5"},a.description):b.createElement("h3",{className:"recommend-post-title",title:a.title},b.createElement("span",{"data-role":"recommend-thread-title",className:"title line-truncate","data-line-truncate":3,"data-content":a.title,dangerouslySetInnerHTML:{__html:a.title}}))))},i=function(a){return b.createElement("div",{className:"top-comment","data-role":"recommend-top-comment"},b.createElement("div",{className:"top-comment-header"},b.createElement("span",{className:"top-comment-avatar-wrapper"},b.createElement("img",{"data-src":d(a.preview,["author","avatar","cache"],""),alt:e("Avatar"),"data-role":"recommend-avatar"})),b.createElement("span",{className:"user publisher-color","data-role":"recommend-top-comment-author"},d(a.preview,["author","name"],null))),b.createElement("div",{className:"recommend-top-comment-wrapper"},b.createElement("span",{"data-role":"recommend-top-comment-snippet",className:"line-truncate","data-line-truncate":"3",dangerouslySetInnerHTML:{__html:d(a.preview,["message"],null)}})))};return f}),define("recommendations/views/links/BaseCollectionView",["underscore","jquery","backbone","react","react-dom","recommendations/helpers","templates/recommendations/recommendationsCollection"],function(a,b,c,d,e,f,g){var h=c.View.extend({events:{"click [data-redirect]":"handleClick"},handleClick:function(a){this.swapHref(a.currentTarget)},swapHref:function(b){b.setAttribute("data-href",b.getAttribute("href")),b.setAttribute("href",b.getAttribute("data-redirect")),a.delay(function(){b.setAttribute("href",b.getAttribute("data-href"))},100)},initialize:function(a){this.elementsSelector="div.recommend-post",this.$elements=this.$el.find(this.elementsSelector),this.initContext=a.context,this.settings=a.settings,this.adSupported=a.adSupported;var b=this.collection;this.listenTo(b,{remove:this.remove,reset:this.render})},truncate:function(){var c=this.$el.find(".line-truncate");a.each(c,function(a){var c=b(a);f.lineTruncate(c,{lines:parseInt(c.attr("data-line-truncate"),10),ellipsis:!0})})},metaPlacement:function(){var c=this.$el.find(".meta"),d=this.$el.find(".recommend-post-title");c.length&&"absolute"===b(c[0]).css("position")&&a.each(c,function(a,c){var e="10px";if(d.length){var f=b(d[c]),g=parseInt(f.context.offsetHeight,10),h=Math.ceil(parseFloat(f.css("line-height"))),i=5;e=(h/2+g+i).toString()+"px"}b(a).css({bottom:e})})},resizeImage:function(a){var b=200,c=200,d=0,e=a.images[0];return e.width>b&&e.height>c?e.height