????
Current Path : /home2/morganrand/backup.morganrand.com/coupon/Professor Cloud_files/a_data/ |
Current File : /home2/morganrand/backup.morganrand.com/coupon/Professor Cloud_files/a_data/max.js |
/* MIT License (c) copyright B Cavalier & J Hann */ DISQUS.addBlocks("theme")(function(c){c.blocks.discoveryMain=function(g,e){var b=new c.Builder,h=DISQUS.extend({},g,e);with(h)return b.put('<div id="'),b.put((b.esc||function(a){return a})(id)),b.put('" class="discovery-main"> <div id="discovery-note" style="display:none;"> <div class="alert"> <a href="#" class="close" data-action="discovery-help-close" title="'),b.put(gettext("Close this box")),b.put('">\u00d7</a> '),b.put(c.interpolate(gettext("Disqus helps you find new and interesting content, discussions and products. Some sponsors and ecommerce sites may pay us for these recommendations and links. %(learnMore)s or %(feedback)s."), {learnMore:c.renderBlock("learnMore"),feedback:c.renderBlock("feedback")})),b.put(" </div> </div> "),c.each(sections,function(a){b.put(' <section id="');b.put((b.esc||function(a){return a})(a.id));b.put('" class="');b.put((b.esc||function(a){return a})(a.className));b.put('"> <header class="discovery-col-header"> ');a===sections[sections.length-1]&&(b.put(" "),b.put(' <div class="discovery-options"> <span class="publisher-anchor-color"><a href="#" class="discovery-help" data-action="discovery-help">'), b.put(gettext("What's this?")),b.put("</a></span> </div> "));b.put(" ");a.type==="organic"?(b.put(" <h2>"),b.put(c.interpolate(gettext("Also on %(forumName)s"),{forumName:c.renderBlock("forumName",forum)})),b.put("</h2> ")):a.type==="promoted"&&(b.put(" <h2>"),b.put(gettext("Around The Web")),b.put("</h2> "));b.put(' </header> <ul class="discovery-posts"> </ul> </section> ')}),b.put("</div>"),b.compile()}; c.blocks.discoveryCollection=function(g,e){var b=new c.Builder,h=DISQUS.extend({},g,e);with(h)return b.put(" "),c.each(collection,function(a,m){var d={thread:a,index:m};b.put(' <li class="discovery-post" id="discovery-link-');a.id?(b.put("o"),b.put((b.esc||function(a){return a})(a.id))):(b.put("p"),b.put((b.esc||function(a){return a})(a.body_id)));b.put('"> <header class="discovery-post-header"> <h3 title="');b.put((b.esc||function(a){return a})(a.title));b.put('"> <a '); (function(){var a={};c.extend(a,d);c.extend(a,{});b.put(c.renderBlock("linkAttributes",a))})();b.put(' data-role="discovery-thread-title" class="title publisher-anchor-color line-truncate" data-line-truncate="2"> ');b.put(a.title);b.put(" </a> ");variant.inlineMeta&&(b.put(" "),a.posts>0?(b.put(' <span class="inline-meta"> '),function(){var f={};c.extend(f,d);c.extend(f,{thread:a});b.put(c.renderBlock("discoveryPostCount", f))}(),b.put(" </span> ")):a.createdAgo&&(b.put(' <span class="inline-meta">'),b.put((b.esc||function(a){return a})(a.createdAgo)),b.put("</span> ")),b.put(" "),a.brand&&(b.put(' <span class="inline-meta"> '),b.put((b.esc||function(a){return a})(a.brand)),b.put(" </span> ")),b.put(" "));b.put(" </h3> "); variant.inlineMeta||(b.put(' <ul class="meta"> '),a.posts>0&&(b.put(' <li class="comments"> '),function(){var f={};c.extend(f,d);c.extend(f,{thread:a});b.put(c.renderBlock("discoveryPostCount",f))}(),b.put(" </li> ")),b.put(" "),a.createdAgo&&(b.put(' <li class="time">'),b.put((b.esc||function(a){return a})(a.createdAgo)),b.put("</li> ")),b.put(" </ul> ")); b.put(" </header> ");variant.contentPreviews&&a.preview&&(b.put(" "),function(){var f={};c.extend(f,d);c.extend(f,{post:a.preview});b.put(c.renderBlock("discoveryContentPreview",f))}(),b.put(" "));b.put(" </li> ")}),b.compile()};c.blocks.discoveryPostCount=function(g,e){var b=new c.Builder,h=DISQUS.extend({},g,e);with(h)return b.put(" "),thread.posts===1?(b.put(" "),b.put(gettext("1 comment"))):(b.put(" "),b.put(c.interpolate(gettext("%(numPosts)s comments"), {numPosts:thread.posts}))),b.put(" "),b.compile()};c.blocks.linkAttributes=function(g,e){var b=new c.Builder,h=DISQUS.extend({},g,e);with(h)return b.put('href="'),b.put((b.esc||function(a){return a})(thread.redirectUrl)),b.put('" '),thread.hasOwnProperty("brand")&&b.put('target="_blank"'),b.compile()};c.blocks.learnMore=function(g,e){var b=new c.Builder,h=DISQUS.extend({},g,e);with(h)return b.put('<a href="http://help.disqus.com/customer/portal/articles/666278-introducing-promoted-discovery-and-f-a-q-" target="_blank">'), b.put(gettext("Learn more")),b.put("</a>"),b.compile()};c.blocks.discoveryContentPreview=function(g,e){var b=new c.Builder,h=DISQUS.extend({},g,e);with(h)return b.put("<a "),function(){var a={};c.extend(a,e);c.extend(a,{});b.put(c.renderBlock("linkAttributes",a))}(),b.put(' class="top-comment" data-role="discovery-top-comment"> <img src="'),b.put((b.esc||function(a){return a})(post.author.avatar.cache)),b.put('" alt="'),b.put(gettext("Avatar")),b.put('" data-role="discovery-avatar"> <p><span class="user" data-role="discovery-top-comment-author">'), b.put((b.esc||function(a){return a})(post.author.name)),b.put('</span> — <span data-role="discovery-top-comment-snippet" class="line-truncate" data-line-truncate="3">'),b.put((b.esc||function(a){return a})(post.plaintext)),b.put("</span></p></a>"),b.compile()};c.blocks.forumName=function(g,e){var b=new c.Builder,h=DISQUS.extend({},g,e);with(h)return b.put("<strong>"),b.put((b.esc||function(a){return a})(name)),b.put("</strong>"),b.compile()};c.blocks.feedback=function(g,e){var b=new c.Builder, h=DISQUS.extend({},g,e);with(h)return b.put('<a href="https://www.surveymonkey.com/s/GHK872T" target="_blank"> '),b.put(gettext("give us feedback")),b.put("</a>"),b.compile()}}); DISQUS.define("discovery.collections",function(){var c={},g=DISQUS.testing,e=DISQUS.JSON,b=_.strip,h=DISQUS.use("discovery.helpers"),a=DISQUS.use("discovery.models"),m=Backbone.Collection.extend({url:function(a){return DISQUS.api.getURL(a)},parse:function(a){return a.response}});c.PostCollection=function(a){var d=a.prototype;return a.extend({url:function(){return d.url.call(this,"discovery/listTopPost.json")},parse:function(a){for(var a=d.parse.call(this,a),f=0,m=a.length;f<m;f++)a[f].plaintext=b(a[f].message); return a}})}(m);var d=function(b){var d=b.prototype;return b.extend({initialize:function(b,d){this.model=a[this.modelName];this.sourceThread=d.sourceThread;this.modelAttributes=d.modelAttributes;this.getBanditJSON=_.memoize(this.getBanditJSON)},fetch:function(a){a=a||{};a.data=a.data||{};a.data.thread=this.sourceThread.id;a.parse=!1;return d.fetch.call(this,a)},parse:function(a){a=d.parse.call(this,a);if("bandit"in a)this.bandit=a.bandit,a=a.results;if(!_.isArray(a))return[];for(var b=0,f=a.length;b< f;b++)_.extend(a[b],this.modelAttributes);return a},getBanditJSON:function(){return e.stringify(this.bandit)}})}(m);c.RelatedThreadCollection=function(a){var b=a.prototype;return a.extend({modelName:"RelatedThread",url:function(){return b.url.call(this,"discovery/listRelated.json")},parse:function(a){return this.rejectInvalid(b.parse.call(this,a))},rejectInvalid:function(a){var b=[],d,f=this.sourceThread;if(DISQUS.debug)return a.slice();for(var m=0,c=a.length;m<c;m++)d=a[m],d.id==f.id||d.link==f.link? this.reportInvalid(d,"Link or id of related thread points back to thread on this page (circular reference)"):d.title.search(/^https?:\/\//)===0?this.reportInvalid(d,"Title looks like a url (begins with http:// or https://)"):b.push(d);return b},reportInvalid:function(a,b){var d=h.log;d("An organic link failed validation:",a.title,a.link,"(id =",a.id+")");d("Reason:",b)}})}(d);c.AdvertisementCollection=function(a){var b=a.prototype;return a.extend({modelName:"Advertisement",url:function(){return b.url.call(this, "discovery/listPromoted.json")}})}(d);if(g)c.BaseCollection=m,c.BaseContentCollection=d;return c}); DISQUS.define("discovery.helpers",function(c,g){var e={},b=!1,h=!1;e.config=function(a){b=!!a.lineTruncationEnabled;h=!!a.consoleLoggingEnabled};var a=function(){};c.console&&(a=function(){if(h){var a=_.toArray(arguments);a.unshift("[Discovery]");c.console.log.apply?c.console.log.apply(c.console,a):c.console.log(a.join(" "))}});e.log=a;e.allowLog=function(a){if(a===g)return h;h=!!a};e.allowLineTruncate=function(a){if(a===g)return b;b=!!a};e.lineTruncate=function(a,d){function f(){return g.scrollHeight- g.offsetHeight>0.2*e}function o(){j.lastChild&&!_.contains(["...","\u2026"],j.lastChild.nodeValue)&&(k=j.appendChild(c.document.createTextNode(" "+h)),f()&&(j.removeChild(k),j.removeChild(j.lastChild),o()))}if(b){var i=DISQUS.logError||function(){};if(!a.closest("body").length)return void i("lineTruncate called on el not on DOM");if(a.text().length<1)return void i("lineTruncated called on empty el");if(_.any(a.children(),function(a){return a.nodeType!==3}))return void i("lineTruncate called on non-flat el"); var j=a[0],g=j;if(a.css("display")!=="block")for(;g.parentNode;)if(g=g.parentNode,$(g).css("display")==="block")break;var e=parseFloat(a.css("font-size"),10);if(f()){var d=d||{},i=d.lines||1,h=d.ellipsis,k,l=a.text();if(l.length){var q=a.width()/e,i=parseInt(q*i,10),l=l.split(/\s/),q=0;a.empty();for(var r=0,v=l.length;r<v;r++){q+=l[r].length+1;if(q>=i)break;j.appendChild(document.createTextNode(" "+l[r]))}if(f()){do k=j.removeChild(j.lastChild);while(f())}else{do k=j.appendChild(document.createTextNode(" "+ l[r++]));while(!f()&&r<v);j.removeChild(k)}h&&(_.isString(h)||(h="\u2026"),o())}}}};e.balancedPartition=function(a){var b=_.keys(a),f=Math.floor(_.reduce(a,function(a,b){return a+b},0)/2),c=b.length+1;f+=1;var i=Array(c),j,g;for(j=0;j<c;j++)i[j]=Array(f),i[j][0]={};for(g=1;g<f;g++)i[0][g]=!1;var e,h,k,l={};for(g=1;g<f;g++)for(j=1;j<c;j++){e=b[j-1];h=a[e];k=_.clone(i[j-1][g]);if(!k&&h<=g&&(k=_.clone(i[j-1][g-h])))k[e]=h,l=k;i[j][g]=k}return[l,_.omit(a,_.keys(l))]};return e}); DISQUS.define("discovery.models",function(){var c={},g=DISQUS.ISO_8601,e=function(b){var c=b.prototype;return b.extend({defaults:{redirectUrl:null,signedUrl:null,userId:null,sourceThreadId:null,forumId:null,forum:null,majorVersion:null,variant:null},redirectPayload:function(){var a={url:this.get("signedUrl"),imp:DISQUS.juggler.impId,forum_id:this.get("forumId"),forum:this.get("forum"),thread_id:this.get("sourceThreadId"),major_version:this.get("majorVersion"),variant:this.get("variant")};if(this.has("userId"))a.user_id= this.get("userId");if(this.collection&&this.collection.bandit)a.bandit=this.collection.getBanditJSON();return a},redirectUrl:function(){var a=this.get("redirectUrl"),b=this.redirectPayload();return DISQUS.serialize(a,b)},toJSON:function(){var a=c.toJSON.call(this);a.redirectUrl=this.redirectUrl();return a},toString:function(){return this.get("title")+" "+this.get("link")+" (id = "+this.id+")"}})}(Backbone.Model);c.RelatedThread=function(b){var c=b.prototype;return b.extend({defaults:_.defaults({createdAgo:!1}, c.defaults),initialize:function(){if(this.get("createdAgo")){var a;a=this.get("createdAt");a=a.indexOf("+")>=0?a:a+"+00:00";a=moment(a,g);this.set("createdAgo",a.fromNow())}},redirectPayload:function(){var a=c.redirectPayload.call(this);_.extend(a,{thread:this.id,zone:"internal_discovery"});return a},toJSON:function(){var a=c.toJSON.call(this);if(a.preview)a.preview=a.preview.toJSON();return a},toString:function(){return"organic link: "+c.toString.call(this)}})}(e);c.Advertisement=function(b){var c= b.prototype;return b.extend({idAttribute:"body_id",defaults:_.defaults({brand:"",headline:"",text:"",url:"",advertisement_id:0,body_id:0},c.defaults),get:function(a){if(a==="title")return this.attributes.headline;if(a==="link")return this.attributes.url;return c.get.call(this,a)},redirectPayload:function(){var a=c.redirectPayload.call(this);_.extend(a,{zone:"promoted_discovery",advertisement_id:this.get("advertisement_id"),body_id:this.get("body_id")});return a},toJSON:function(){var a=c.toJSON.call(this); a.title=a.headline;a.link=a.url;return a},toString:function(){return"promoted link: "+c.toString.call(this)}})}(e);if(DISQUS.testing)c.BaseContentModel=e;return c}); (function(c){c(function(){function c(a,b,d,f){return e(a).then(b,d,f)}function e(a){var c;if(!(a instanceof b))d(a)?(c=m(),a.then(function(a){c.resolve(a)},function(a){c.reject(a)},function(a){c.progress(a)}),a=c.promise):a=h(a);return a}function b(a){this.then=a}function h(d){return new b(function(b){try{return e(b?b(d):d)}catch(c){return a(c)}})}function a(d){return new b(function(b,c){try{return c?e(c(d)):a(d)}catch(f){return a(f)}})}function m(){function d(a,b,c){return h(a,b,c)}function c(a){return p(a)} function f(b){return p(a(b))}function i(a){return l(a)}var o,g,k,h,l,p;o=new b(d);o={then:d,resolve:c,reject:f,progress:i,promise:o,resolver:{resolve:c,reject:f,progress:i}};g=[];k=[];h=function(a,b,d){var c,f;c=m();f=typeof d==="function"?function(a){try{c.progress(d(a))}catch(b){c.progress(b)}}:function(a){c.progress(a)};g.push(function(d){d.then(a,b).then(c.resolve,c.reject,f)});k.push(f);return c.promise};l=function(a){j(k,a);return a};p=function(a){a=e(a);h=a.then;p=e;l=u;j(g,a);k=g=q;return a}; return o}function d(a){return a&&typeof a.then==="function"}function f(a,b,d,f,i){p(2,arguments);return c(a,function(a){function j(a){n(a)}function o(a){p(a)}var e,k,h,r,l,p,n,q,t,s;t=a.length>>>0;e=Math.max(0,Math.min(b,t));h=[];k=t-e+1;r=[];l=m();if(e){q=l.progress;n=function(a){r.push(a);--k||(p=n=u,l.reject(r))};p=function(a){h.push(a);--e||(p=n=u,l.resolve(h))};for(s=0;s<t;++s)s in a&&c(a[s],o,j,q)}else l.resolve(h);return l.then(d,f,i)})}function o(a,b,d,c){p(1,arguments);return i(a,n).then(b, d,c)}function i(a,b){return c(a,function(a){var d,f,i,j,o,e;i=f=a.length>>>0;d=[];e=m();if(i){j=function(a,f){c(a,b).then(function(a){d[f]=a;--i||e.resolve(d)},e.reject)};for(o=0;o<f;o++)o in a?j(a[o],o):--i}else e.resolve(d);return e.promise})}function j(a,b){for(var d,c=0;d=a[c++];)d(b)}function p(a,b){for(var d,c=b.length;c>a;)if(d=b[--c],d!=null&&typeof d!="function")throw Error("arg "+c+" must be a function");}function u(){}function n(a){return a}var k,l,q;c.defer=m;c.resolve=e;c.reject=function(b){return c(b, a)};c.join=function(){return i(arguments,n)};c.all=o;c.map=i;c.reduce=function(a,b){var d=l.call(arguments,1);return c(a,function(a){var f;f=a.length;d[0]=function(a,d,i){return c(a,function(a){return c(d,function(d){return b(a,d,i,f)})})};return k.apply(a,d)})};c.any=function(a,b,d,c){return f(a,1,function(a){return b?b(a[0]):a[0]},d,c)};c.some=f;c.chain=function(b,d,f){var i=arguments.length>2;return c(b,function(a){a=i?f:a;d.resolve(a);return a},function(b){d.reject(b);return a(b)},d.progress)}; c.isPromise=d;b.prototype={always:function(a,b){return this.then(a,a,b)},otherwise:function(a){return this.then(q,a)},yield:function(a){return this.then(function(){return a})},spread:function(a){return this.then(function(b){return o(b,function(b){return a.apply(q,b)})})}};l=[].slice;k=[].reduce||function(a){var b,d,c,f,i;i=0;b=Object(this);f=b.length>>>0;d=arguments;if(d.length<=1)for(;;){if(i in b){c=b[i++];break}if(++i>=f)throw new TypeError;}else c=d[1];for(;i<f;++i)i in b&&(c=a(c,b[i],i,b));return c}; return c})})(typeof define=="function"&&define.amd?define:function(c){typeof exports==="object"?module.exports=c():this.when=c()}); DISQUS.define("discovery",function(){var c={},g=DISQUS.use("discovery.collections"),e=DISQUS.use("discovery.views"),b=DISQUS.use("discovery.helpers");c.init=function(a,c){var d=_.object(_.map(["lineTruncationEnabled","consoleLoggingEnabled"],function(b){return b in a?[b,a[b]]:[b,h.prototype.defaults[b]]}));b.config(d);var f=new h(a);if(c)f.on("change:display",function(){if(this.get("display")===!0)f.mainView.render=function(){},c(f.mainView)});return f};var h=c.DiscoveryApp=Backbone.Model.extend({defaults:{name:"default", inlineMeta:!1,contentPreviews:!0,promotedEnabled:!1,topPlacementEnabled:!1,isExperiment:!1,redirectUrl:"//redirect.disqus.com/url",httpTimeout:1E4,sourceThread:null,sourceForum:null,help:!1,display:!1,columnEveningEnabled:!0,numColumns:2,minPerColumn:1,maxPerColumn:2,toleranceCoefficient:1.2,minWidthForColumnLayout:440,containerId:"discovery",topPlacementContainerId:"discovery-top",innerContainerName:"discovery-main",sectionNames:["col-organic","col-promoted"],collectionTagName:"ul",collectionClassName:"discovery-posts", consoleLoggingEnabled:DISQUS.debug,lineTruncationEnabled:!0,session:null,js:null,css:null},initialize:function(){var a=this;!a.has("sourceThread")&&!DISQUS.testing&&a.makeBackwardsCompatible();a.createDataReferences();a.set("innerContainerId",a.get("innerContainerName")+"-"+a.cid);a.set("sectionIds",_.map(a.get("sectionNames"),function(b){return b+"-"+a.cid}));var b=a.get("session");a.get("topPlacementEnabled")&&b.isAnonymous()&&a.set("containerId",a.get("topPlacementContainerId"));a.on("change:display", function f(){a.off("change:display",f);a.onComplete()});_.bindAll(a,"getContentPreviews","validateData","showData");a.run()},makeBackwardsCompatible:function(){var a="default";this.get("variant").indexOf("midway")!==-1&&(a="promoted");this.set("name",a);this.set({"default":{maxPerColumn:2,inlineMeta:!1,contentPreviews:!0,promotedEnabled:!1,topPlacementEnabled:!1},promoted:{maxPerColumn:4,inlineMeta:!0,contentPreviews:!1,promotedEnabled:!0,topPlacementEnabled:!1},max:{maxPerColumn:4,inlineMeta:!0, contentPreviews:!1,promotedEnabled:!0,topPlacementEnabled:!0}}[a]);this.set("topPlacementEnabled",!1);this.set("sourceThread",this.get("thread"));this.set("sourceForum",this.get("forum"));this.on("resize",function(){this.mainView&&this.mainView.trigger("resize")})},commonClickMetadata:function(){var a=this.get("sourceThread"),b=this.get("sourceForum"),a={redirectUrl:this.get("redirectUrl"),sourceThreadId:a.id,forumId:b.pk,forum:b.id,majorVersion:this.majorVersion(),variant:this.get("name")};if((b= this.get("session"))&&b.isRegistered())a.userId=b.user.id;return a},createDataReferences:function(){function a(){return{sourceThread:b.get("sourceThread"),modelAttributes:b.commonClickMetadata()}}var b=this;b.collections=[];var d=a();d.modelAttributes.createdAgo=!0;this.threads=new g.RelatedThreadCollection(null,d);this.collections.push(this.threads);if(this.get("promotedEnabled"))this.ads=new g.AdvertisementCollection(null,a()),this.collections.push(this.ads)},run:function(){var a=_.bind(this.onComplete, this);this.getData().then(this.validateData).then(this.showData).otherwise(a)},getData:function(){var a=this.get("numColumns"),b={timeout:this.get("httpTimeout"),data:{limit:a/this.collections.length*this.get("maxPerColumn")}},a=this.listRelatedRequest=when(this.threads.fetch(b));this.get("contentPreviews")&&(a=a.then(this.getContentPreviews));if(!this.get("promotedEnabled"))return a;b=this.listPromotedRequest=when(this.ads.fetch(b));return when.join(a,b)},getContentPreviews:function(){var a=this.threads.filter(function(a){return!a.get("posts")}); DISQUS.debug||_.each(a,function(a){b.log("Rejecting "+a);b.log("Reason: Thread at that link has no comments");this.threads.remove(a)},this);var a=this.threads.pluck("id"),c=this.collections.length,d=this.get("numColumns"),f=this.get("minPerColumn");if(a.length<d/c*f)return when.resolve();this.previews=new g.PostCollection;return(this.listTopPostRequest=when(this.previews.fetch({data:{thread:a},timeout:this.get("httpTimeout")}))).then(_.bind(this.attachPreviews,this))},attachPreviews:function(){var a= this;a.previews.each(function(b){var d=b.get("thread");(d=a.threads.get(d.id||d))&&d.set("preview",b)})},validateCollections:function(){for(var a=this.collections,b=a.length,d=this.get("numColumns"),c=this.get("minPerColumn"),e,i;b>0;)if(i=d/a.length*c,e=a[--b],e.length<i)a.splice(b,1),b=a.length;b=a.length;if(b>0){d=d/b*this.get("maxPerColumn");for(c=0;c<b;c++)e=a[c],e.length>d&&e.reset(e.slice(0,d))}},validateData:function(){this.validateCollections();if(this.collections.length===0)throw"Not enough data"; },showData:function(){e.BaseView.variant=this.toJSON();var a=document.getElementById(this.get("containerId"));if(!a)throw"No container on the DOM";a=this.mainView=new e.MainView({el:a,model:this});a.render();var b=this.get("sectionIds"),d=this.get("collectionTagName"),c=this.get("collectionClassName");this.views=_.map(this.collections,function(a,j){return new e.BaseCollectionView({collection:a,el:$("#"+b[j]+" "+d+"."+c)})});this.views.length===2&&a.$el.find("#"+this.get("innerContainerId")).addClass("doublesection"); _.invoke(this.views,"render");if(this.get("columnEveningEnabled")&&a.$el.width()>this.get("minWidthForColumnLayout"))(new e.TwoColumn({views:this.views,fudge:this.get("toleranceCoefficient")})).render();else{var g=_.min(_.pluck(this.collections,"length"));_.each(this.views,function(a){for(;a.collection.length>g;)a.collection.pop()})}this.set("display",!0)},onComplete:function(a){var c=b.log;if(this.onCompleteCalled)return c("Error: Final reporting function called more than once");this.onCompleteCalled= !0;a&&c("It looks like there was a problem:",a);this.report()},report:function(){var a=b.log,c=this.snapshot(),d=DISQUS.juggler.client("juggler");if(!d)return void a("Cannot report app state, no client found");a("Sending analytics data about this Discovery impression:");a("init_discovery: ",c);d.emit("init_discovery",c);this.get("darkJester")&&DISQUS.juggler.client("jester",!0).emit("init_discovery",c)},majorVersion:function(){return this.get("promotedEnabled")?"midway":"metadata"},snapshot:function(){var a= this.collections,b=this.threads,b={major_version:this.majorVersion(),internal_organic:b.length,external_organic:0,promoted:0,display:this.get("display"),placement:this.get("containerId")===this.get("topPlacementContainerId")?"top":"bottom"};if(this.get("promotedEnabled")){var d=this.ads;_.extend(b,{promoted:d.length,promoted_ids:DISQUS.JSON.stringify(d.pluck("advertisement_id"))})}a=_.extend.apply(_,[{}].concat(_.pluck(a,"bandit")));if(!_.isEmpty(a))b.bandit=DISQUS.JSON.stringify(a);if(this.get("isExperiment"))b.variant= this.get("name");return b}});return c}); DISQUS.define("discovery.views",function(){var c={},g=DISQUS.use("discovery.helpers"),e=c.BaseView=Backbone.View.extend({template:function(a,b){if(e.variant)a.variant=e.variant;b=b||this.templateName;return DISQUS.renderBlock(b,a)}});c.BaseCollectionView=e.extend({events:{"click [data-redirect]":"handleClick"},handleClick:function(a){this.swapHref(a.currentTarget)},swapHref:function(a){a.setAttribute("data-href",a.getAttribute("href"));a.setAttribute("href",a.getAttribute("data-redirect"));_.delay(function(){a.setAttribute("href", a.getAttribute("data-href"))},100)},templateName:"discoveryCollection",initialize:function(){this.elementsSelector="li.discovery-post";this.$elements=this.$el.find(this.elementsSelector);this.collectionName="collection";var a=this.collection;a.on("remove",this.remove,this);a.on("reset",this.render,this)},truncate:function(){this.$el.find(".line-truncate").each(function(a){a=$(a);g.lineTruncate(a,{lines:a.attr("data-line-truncate"),ellipsis:!0})})},render:function(){var a={};a[this.collectionName]= this.collection.toJSON();this.$el.html(this.template(a));this.$elements=this.$el.find(this.elementsSelector);this.truncate();return this},remove:function(a,b,c){if(arguments.length===0)return e.prototype.remove.call(this);var i=_.toArray(this.$elements),j=i.splice(c.index,1)[0];$(j).remove();this.$elements=$(i);return this}});var b=function(a,b){this.modelIds=a||[];this.$elements=$(b||[])};_.extend(b.prototype,{height:function(){var a=this;a.heights=[];var b=$(a.$elements),c=b.first().offset().top, c=function(){var a=b.last().offset();return a.top+a.height}()-c,i=0;_.each(b,function(b){b=$(b).height();a.heights.push(b);i+=b});this.interstice=(c-i)/(b.length-1);return c}});var h=function(){this.divideIntoColumns=function(){var a=this,c=a.subviews[0];a.left=new b;a.right=new b;var e=0;c.collection.each(function(b,j){var g=e++%2===0?"left":"right";a[g].modelIds.push(b.id);Array.prototype.push.call(a[g].$elements,c.$elements[j])})};this.removeOneFromColumn=function(a,b){var c=_.chain(a.modelIds).map(function(b, c){return[b,a.heights[c]]}).sortBy(function(a){return-1*a[1]}).find(function(a){return a[1]<=b}).value()[0],i=this.subviews[0].collection,e=i.models,g=i.get(c),h=e.indexOf(g),c=[[],[]],n,k=e.length;for(n=0;n<k;n++)c[n%2].push(e[n]);e=c[h%2];e.splice(_.indexOf(e,g),1);e=[];g=(h+1)%2;for(n=0;n<k-1;n++)e.push(c[(n+g)%2].shift());i.reset(e)};this.balanceColumns=function(){var a=this.subviews[0],b=a.collection,c={};b.each(function(b,f){c[f]=a.$elements[f]});var e=g.balancedPartition(c),e=_.sortBy(e,"length"), h=e[0],p=b.models,m=Array(p.length);_.each(e[1],function(a,b){m[2*b]=p[b]});_.each(h,function(a,b){m[2*b+1]=p[b]});b.reset(p)};this.shortenColumn=function(a,b){this.subviews[0].collection.length%2!==0&&a===this.left?this.removeOneFromColumn(a,this.fudge*b):this.balanceColumns()}},a=function(){this.divideIntoColumns=function(){var a=this.subviews,c=a[0],a=a[1];this.left=new b(c.collection.pluck(c.collection.model.prototype.idAttribute),c.$elements);this.right=new b(a.collection.pluck(a.collection.model.prototype.idAttribute), a.$elements)};this.shortenColumn=function(a,b){for(var c=a===this.left?this.right:this.left,e=b/c.$elements.length,g=(a===this.left?this.subviews[0]:this.subviews[1]).collection,h=_.chain(a.modelIds).map(function(b,c){return[b,a.heights[c]]}).sortBy(function(a){return a[1]}).value(),m=[],n=0,k=b,k=e;h.length;){var l=h.pop(),q=l[0],l=l[1]+a.interstice;n+l>b&&(c=a);k=Math.abs(b-(n+l));k/=c.$elements.length;k>=e||(e=k,k=a.modelIds.indexOf(q),a.modelIds.splice(k,1),Array.prototype.splice.call(a.$elements, k,1),n+=l,m.push(q))}g.remove(m)}},m=c.TwoColumn=function(b){this.fudge=b.fudge;this.subviews=b.views.slice(0,2);this.subviews.length===1?h.call(this):a.call(this)};_.extend(m.prototype,{ascendingByHeight:function(){var a=this.left,b=this.right,a=[[a,a.height()],[b,b.height()]];return _.sortBy(a,function(a){return a[1]})},evenColumns:function(a){var b=this.ascendingByHeight(),c=b[0][0],e=b[0][1],g=b[1][0],b=b[1][1];if(e!==b){var e=b-e,h=this.fudge*e,b=_.find(g.heights,function(a){return a+g.interstice< h});if(!a&&b)return this.shortenColumn(g,e),this.divideIntoColumns(),this.evenColumns("do not recurse again");this.increaseMargins(c,e)}},increaseMargins:function(a,b){var c=b/a.$elements.length;_.each(a.$elements,function(a){var a=$(a),b=parseInt(a.css("margin-bottom"),10)+c;a.css("margin-bottom",b+"px")});(a===this.left?this.right:this.left).$elements.css("clear",a===this.right?"left":"right")},render:function(){this.divideIntoColumns();this.evenColumns();return this}});c.MainView=e.extend({templateName:"discoveryMain", events:{"click [data-action=discovery-help]":function(a){a.preventDefault();this.model.set("help",!0)},"click [data-action=discovery-help-close]":function(a){a.preventDefault();this.model.set("help",!1)}},toggleHelp:function(a){this.$el.find("#discovery-note").toggle();a.trigger("resize")},initialize:function(){this.model.on("change:display",this.show,this);this.model.on("change:help",this.toggleHelp,this);this.$el.css({position:"absolute",visibility:"hidden",display:"block"})},createSections:function(){var a= this.model,b=DISQUS.discovery.collections,c=b.RelatedThreadCollection,e=b.AdvertisementCollection,g=a.get("sectionNames"),h=a.get("sectionIds");return _.map(a.collections,function(a,b){var d;a instanceof c?d="organic":a instanceof e&&(d="promoted");return{id:h[b],className:g[b],type:d}})},render:function(){var a=this.model,b=this.createSections();this.$el.html(this.template({id:a.get("innerContainerId"),sections:b,forum:a.get("sourceForum"),session:a.get("session").toJSON()}))},show:function(a){a.get("display")&& (this.$el.css({position:"static",visibility:"visible"}),a.trigger("resize"))}});return c});