var DISQUS=function(c){var g=c.DISQUS||{};g.AssertionError=function(a){this.message=a};g.AssertionError.prototype.toString=function(){return"Assertion Error: "+(this.message||"[no message]")};g.assert=function(a,e,h){if(!a)if(h)c.console&&c.console.log("DISQUS assertion failed: "+e);else throw new g.AssertionError(e);};var e=[];g.define=function(a,j){typeof a==="function"&&(j=a,a="");for(var h=a.split("."),f=h.shift(),b=g,q=(j||function(){return{}}).call({overwrites:function(b){b.__overwrites__=!0;
return b}},c);f;)b=b[f]?b[f]:b[f]={},f=h.shift();for(var i in q)q.hasOwnProperty(i)&&(!q.__overwrites__&&b[i]!==null&&g.assert(!b.hasOwnProperty(i),"Unsafe attempt to redefine existing module: "+i,!0),b[i]=q[i],e.push(function(b,f){return function(){delete b[f]}}(b,i)));return b};g.use=function(a){return g.define(a)};g.cleanup=function(){for(var a=0;a<e.length;a++)e[a]()};return g}(window);
DISQUS.define(function(c,g){var e=c.DISQUS,a=c.document,j=a.getElementsByTagName("head")[0]||a.body,h={running:!1,timer:null,queue:[]};e.defer=function(f,b){function a(){var b=h.queue;if(b.length===0)h.running=!1,clearInterval(h.timer);for(var f=0,e;e=b[f];f++)e[0]()&&(b.splice(f--,1),e[1]())}h.queue.push([f,b]);a();if(!h.running)h.running=!0,h.timer=setInterval(a,100)};e.each=function(f,b){var a=f.length,e=Array.prototype.forEach;if(isNaN(a))for(var c in f)f.hasOwnProperty(c)&&b(f[c],c,f);else if(e)e.call(f,
b);else for(e=0;e<a;e++)b(f[e],e,f)};e.extend=function(f){e.each(Array.prototype.slice.call(arguments,1),function(b){for(var a in b)f[a]=b[a]});return f};e.serializeArgs=function(f){var b=[];e.each(f,function(f,a){f!==g&&b.push(a+(f!==null?"="+encodeURIComponent(f):""))});return b.join("&")};e.isString=function(f){return Object.prototype.toString.call(f)==="[object String]"};e.serialize=function(f,b,a){b&&(f+=~f.indexOf("?")?f.charAt(f.length-1)=="&"?"":"&":"?",f+=e.serializeArgs(b));if(a)return b=
{},b[(new Date).getTime()]=null,e.serialize(f,b);b=f.length;return f.charAt(b-1)=="&"?f.slice(0,b-1):f};e.require=function(f,b,c,g,h){function o(b){if(b.type=="load"||/^(complete|loaded)$/.test(b.target.readyState))g&&g(),m&&clearTimeout(m),e.bean.remove(b.target,r,o)}var k=a.createElement("script"),r=k.addEventListener?"load":"readystatechange",m=null;k.src=e.serialize(f,b,c);k.async=!0;k.charset="UTF-8";(g||h)&&e.bean.add(k,r,o);h&&(m=setTimeout(function(){h()},2E4));j.appendChild(k);return e};
e.requireStylesheet=function(f,b,c){var g=a.createElement("link");g.rel="stylesheet";g.type="text/css";g.href=e.serialize(f,b,c);j.appendChild(g);return e};e.requireSet=function(f,b,a){var c=f.length;e.each(f,function(f){e.require(f,{},b,function(){--c===0&&a()})})};e.injectCss=function(f){var b=a.createElement("style");b.setAttribute("type","text/css");f=f.replace(/\}/g,"}\n");c.location.href.match(/^https/)&&(f=f.replace(/http:\/\//g,"https://"));b.styleSheet?b.styleSheet.cssText=f:b.appendChild(a.createTextNode(f));
j.appendChild(b)}});
DISQUS.define("JSON",function(){function c(b){return b<10?"0"+b:b}function g(b){f.lastIndex=0;return f.test(b)?'"'+b.replace(f,function(b){var f=i[b];return typeof f==="string"?f:"\\u"+("0000"+b.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+b+'"'}function e(f,l){var a,c,h,i,k=b,o,p=l[f];p&&typeof p==="object"&&typeof p.toJSON==="function"&&!j&&(p=p.toJSON(f));typeof n==="function"&&(p=n.call(l,f,p));switch(typeof p){case "string":return g(p);case "number":return isFinite(p)?String(p):"null";case "boolean":case "null":return String(p);
case "object":if(!p)return"null";b+=q;o=[];if(Object.prototype.toString.apply(p)==="[object Array]"){i=p.length;for(a=0;a<i;a+=1)o[a]=e(a,p)||"null";h=o.length===0?"[]":b?"[\n"+b+o.join(",\n"+b)+"\n"+k+"]":"["+o.join(",")+"]";b=k;return h}if(n&&typeof n==="object"){i=n.length;for(a=0;a<i;a+=1)c=n[a],typeof c==="string"&&(h=e(c,p))&&o.push(g(c)+(b?": ":":")+h)}else for(c in p)Object.hasOwnProperty.call(p,c)&&(h=e(c,p))&&o.push(g(c)+(b?": ":":")+h);h=o.length===0?"{}":b?"{\n"+b+o.join(",\n"+b)+"\n"+
k+"}":"{"+o.join(",")+"}";b=k;return h}}var a={},j=!1;if(typeof Date.prototype.toJSON!=="function")Date.prototype.toJSON=function(){return isFinite(this.valueOf())?this.getUTCFullYear()+"-"+c(this.getUTCMonth()+1)+"-"+c(this.getUTCDate())+"T"+c(this.getUTCHours())+":"+c(this.getUTCMinutes())+":"+c(this.getUTCSeconds())+"Z":null},String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(){return this.valueOf()};var h=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
f=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,b,q,i={"\u0008":"\\b","\t":"\\t","\n":"\\n","\u000c":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},n;a.stringify=function(f,a,c){var g;q=b="";if(typeof c==="number")for(g=0;g<c;g+=1)q+=" ";else typeof c==="string"&&(q=c);if((n=a)&&typeof a!=="function"&&(typeof a!=="object"||typeof a.length!=="number"))throw Error("JSON.stringify");return e("",{"":f})};a.parse=function(b,f){function a(b,
c){var e,g,p=b[c];if(p&&typeof p==="object")for(e in p)Object.hasOwnProperty.call(p,e)&&(g=a(p,e),g!==void 0?p[e]=g:delete p[e]);return f.call(b,c,p)}var c,b=String(b);h.lastIndex=0;h.test(b)&&(b=b.replace(h,function(b){return"\\u"+("0000"+b.charCodeAt(0).toString(16)).slice(-4)}));if(/^[\],:{}\s]*$/.test(b.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,"")))return c=eval("("+b+")"),
typeof f==="function"?a({"":c},""):c;throw new SyntaxError("JSON.parse");};var o={a:[1,2,3]},k,r;if(Object.toJSON&&Object.toJSON(o).replace(/\s/g,"")==='{"a":[1,2,3]}')k=Object.toJSON;typeof String.prototype.evalJSON==="function"&&(o='{"a":[1,2,3]}'.evalJSON(),o.a&&o.a.length===3&&o.a[2]===3&&(r=function(b){return b.evalJSON()}));(function(){var b=[1,2,3];typeof b.toJSON==="function"&&(b=b.toJSON(),j=!(b&&b.length===3&&b[2]===3))})();if(j||!k||!r)return{stringify:a.stringify,parse:a.parse};return{stringify:k,
parse:r}});
DISQUS.define("Bus",function(){function c(f){f=f.split("/");return f[0]+"//"+f[2]}var g=DISQUS.use("JSON"),e=window.location.hash.slice(1),a=window.parent,j=document.referrer,h={};h.client=c(document.location.href);h.host=j?c(j):h.client;return{origins:h,postMessage:function(f){f.sender=e;f=g.stringify(f);a.postMessage(f,h.host)},sendHostMessage:function(f,b){b=b||[];DISQUS.Bus.postMessage({scope:"host",name:f,data:b})},sendGlobalMessage:function(f,b){b=b||[];DISQUS.Bus.postMessage({scope:"global",name:f,
data:b})}}});_.extend(DISQUS.Bus,Backbone.Events);$(document).ready(function(){var c=window.addEventListener?window.addEventListener:window.attachEvent,g=window.addEventListener?"message":"onmessage";if(!c)throw Error("No event support.");c(g,function(c){var a=DISQUS.Bus,g=c.origin;if(!(g!=a.origins.client&&g!=a.origins.host)){var h;try{h=DISQUS.JSON.parse(c.data)}catch(f){return}c=h.data;switch(h.scope){case "client":a.trigger(c.eventName,c.data)}}},!1)});
DISQUS.define(function(c,g){var e={blocks:{},ISO_8601:"YYYY-MM-DDTHH:mm:ssZ",apiKey:"E8Uh5l5fHZ6gD8U3KycjAIAk46f68Zw7C6eW8WSjZvCLXebZ7p0r1yrYDrLilk2F",bean:require("bean"),debug:!1,browser:{mobile:navigator.userAgent.match(/Android|webOS|iPhone|iPad|iPod|BlackBerry/i)},modules:{},strings:{translations:{}}};e.strings.get=_.bind(function(a){var c=this.translations[a];return c!==g?c:a},e.strings);e.interpolate=function(a,c){return a.replace(/%\(\w+\)s/g,function(f){var f=f.slice(2,-2),b="";f in c?b=
c[f]!==g&&c[f]!==null?c[f].toString():"":DISQUS.logError&&DISQUS.logError("Key `"+f+"` not found in context for: ",a);return b})};e.addBlocks=function(){return function(a){a(DISQUS)}};e.templateGlobals={urls:DISQUS.use("urls"),sso:null,trans:e.strings.get};e.renderBlock=function(a,c){return DISQUS.blocks[a](e.templateGlobals,c)};e.assureOffset=function(a){return a.indexOf("+")>=0?a:a+"+00:00"};var a=e.Builder=function(){this.accum=[]};_.extend(a.prototype,{put:function(a){this.accum.push(a)},esc:function(a){return String(a).replace(/&/g,
"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")},compile:function(){return this.accum.join("")}});return e});
DISQUS.define("urls",function(){var c=DISQUS.debug?"/js/src/embed/next/vglnk.js":"/build/next/alfie.js",g=encodeURIComponent(document.referrer),e={root:"http://disqus.com",media:"http://mediacdn.disqus.com/1354046062",loading:"http://mediacdn.disqus.com/1354046062/html/simple-loading.html",realertime:"http://realtime.services.disqus.com",login:"https://disqus.com/next/login/",api:"http://disqus.com/api/3.0/",apiSecure:"https://disqus.com/api/3.0/",logout:"http://disqus.com/logout/?redirect="+g,editProfile:"http://disqus.com/account/",
verifyEmail:"https://disqus.com/next/verify/",authorize:"https://disqus.com/api/oauth/2.0/authorize/",moderate:"http://disqus.com/admin/moderate/",oauth:{twitter:"http://disqus.com/_ax/twitter/begin/",google:"http://disqus.com/_ax/google/begin/",facebook:"http://disqus.com/_ax/facebook/begin/"},avatar:{generic:"http://mediacdn.disqus.com/1354046062/images/noavatar92.png"},linkAffiliatorClient:"http://mediacdn.disqus.com/1354046062"+c};window.location.protocol==="https:"&&(e=_.extend(e,{root:"https://disqus.com",
media:"https://securecdn.disqus.com/1354046062",loading:"https://securecdn.disqus.com/1354046062/html/simple-loading.html",realertime:e.realertime.replace("http://","https://"),api:e.apiSecure,logout:"https://disqus.com/logout/?redirect="+g,editProfile:"https://disqus.com/account/",moderate:"https://disqus.com/admin/moderate/",oauth:{twitter:"https://disqus.com/_ax/twitter/begin/",google:"https://disqus.com/_ax/google/begin/",facebook:"http://disqus.com/_ax/facebook/begin/"},avatar:{generic:"https://securecdn.disqus.com/1354046062/images/noavatar92.png"},
linkAffiliatorClient:"https://securecdn.disqus.com/1354046062"+c}));return e});
DISQUS.define("api",function(){function c(a){function c(f){var e=f.originalEvent.origin;DISQUS.urls.apiSecure.slice(0,e.length)===e&&(f=DISQUS.JSON.parse(f.originalEvent.data),f.requestId===g&&(e=f.code===0?a.success:a.error,delete f.requestId,(e||function(){})(f),document.body.removeChild(i),document.body.removeChild(b),$(window).unbind("message",c)))}var g=_.uniqueId("ft_"),f=document.createElement("div"),b=document.createElement("form"),e="frame_"+g,i;f.innerHTML='<iframe name="'+e+'"></iframe>';
i=f.childNodes[0];b.target=e;b.action=a.url.replace(".json",".pm");b.method=a.method||"GET";a.data=_.extend(a.data,{callback:g,referrer:document.referrer});_.each(a.data,function(f,a){f===!0?f=[1]:f===!1?f=[0]:f===null?f=[""]:_.isArray(f)||(f=[f]);_.each(f,function(f){var c=document.createElement("input");c.type="hidden";c.name=a;c.value=f;b.appendChild(c)})});$(window).bind("message",c);document.body.appendChild(i);document.body.appendChild(b);b.submit()}function g(a){a=_.defaults(a,e);a.data=a.data||
{};a.data.api_key=DISQUS.apiKey;$.ajax(a)}var e={};return{defaults:function(a){var c,g,f;for(c in a)g=a[c],f=e[c],_.isObject(g)&&_.isObject(f)?_.extend(f,g):e[c]=g},headers:function(a){a=_.extend({},e.headers,a);return e.headers=_.pick(a,_.map(a,function(a,c){if(a)return c}))},getURL:function(a,c){c=c||{};if(c.secure||window.location.protocol==="https:")return DISQUS.urls.apiSecure+a;return DISQUS.urls.api+a},ajax:g,call:function(a,e){e=e||{};e.url=DISQUS.api.getURL(a,{secure:e.secure});e.data=_.extend(e.data||
{},{api_key:DISQUS.apiKey});(e.secure?c:g)(e)}}});(function(c){c.ajax=function(c){c.method=c.type;c.type=c.dataType;delete c.dataType;return DISQUS.api.ajax(c)};c.Collection.prototype.parse=function(c){return c.response}})(Backbone);
DISQUS.define("ga",function(c){var g,e=function(a){g?g(a):c._gaq.push(a)},a={component:1,"package":2,forum:3,version:4,userType:5};return{setCaller:function(a){g=a},setAccount:function(a){e(["_setAccount",a])},setCustomVar:function(c,g){e(["_setCustomVar",a[c],c,g])},trackPageview:function(){e(["_trackPageview"])},trackEvent:function(a,c,f){e(["_trackEvent",c,a,f,1])},setDomainName:function(a){e(["_setDomainName",a])}}});
DISQUS.define("juggler",function(c){var g,e,a={},j=["thread","forum","forum_id"],h=j.slice().concat(["imp","event","prev_imp"]),f=[],b=(new Date).getTime().toString(10)+Math.floor(Math.random()*1E6).toString(10);return{load:function(h){function i(){g=function(){};f=[]}e=h.url;if(h.disable)return void i();if(c.location.protocol==="https:"){if(h.disableSSL)return void i();e=e.replace("http:","https:")}DISQUS.each(j,function(b){a[b]=h[b]});a.imp=b;a.prev_imp=DISQUS.cookies.read("__jid");DISQUS.cookies.create("__jid",
b,{expiresIn:18E5});g=function(b){DISQUS.each(a,function(f,c){b[c]=a[c]});DISQUS.require(e,b,!1)};DISQUS.each(f,function(b){g(b)})},emit:function(b,a){DISQUS.each(h,function(b){if(a[b]!=null)throw"Error: cannot overwrite event context '"+b+"'";});a.event=b;g==null?f.push(a):g(a)},impId:b}});
DISQUS.define("intelligence",function(c){function g(c,a){function g(b){if(!(b instanceof DISQUS.lounge.models.User)&&!(b instanceof DISQUS.lounge.models.AnonUser))throw Error("determineUserType(user) needs an instance of User/Anonuser");return b.has("remote")?b.get("remote").domain:b.id?"disqus":r?"guest":"not_logged_in"}function h(b){if(a.switches.length>0)b(a.switches);else a.switches.on("reset",b)}var f=a.initialData;if(_.isObject(f)&&!_.isEmpty(f)){var b=DISQUS.ga.setCustomVar,q=DISQUS.ga.trackPageview,
i=function(b){DISQUS.ga.trackEvent(b,n,o)},n="next",o=f.forum.id,k="not_logged_in",r=!1,m=f.features.support_preferred?"plus":f.features.support_priority?"pro":f.features.support_vip?"vip":"free";a.session.on("identify",function(){var l=this.user;h(function(b){b.enabled("juggler_thread_onReady")&&DISQUS.juggler.emit("init_embed",{thread_slug:f.thread.slug,user_type:l.get("user_type")||"anon",referrer:c.document.referrer,theme:"next"})});k=g(l);b("component","embed");b("package",m);b("forum",o);b("version",
n);b("userType",k);q();a.session.on("change:id",function(f){var a=k;k=g(f);a!=k&&(b("userType",k),i(k=="not_logged_in"||k=="guest"?"logout":"login"))})});h(function(b){DISQUS.juggler.load({disable:!b.enabled("juggler_enabled"),url:"http://juggler.services.disqus.com/event.js",disableSSL:b.enabled("next_disable_ssl_juggler"),thread:f.thread.id,forum:f.forum.id,forum_id:f.forum.pk})});DISQUS.each({inViewport:function(){i("view_embed");a.off("inViewport")},"uiAction:createPost":function(f){k=="not_logged_in"&&
(k="guest",b("userType",k));r=!0;f.get("parent")!=null?i("post_comment_reply"):i("post_comment")},"uiAction:postUpvote":function(){i("like_comment")},"uiAction:postDownvote":function(){i("dislike_comment")},"uiAction:threadUpvote":function(){i("like_thread")},"uiAction:postShare":function(b){i("share_comment_"+b)},"uiAction:threadShare":function(b){i("share_thread_"+b)},"uiAction:navigate":function(b){(b={community:"community",dashboard:"mydisqus",profile:"profile",reactions:"reactions"}[b])&&i("open_"+
b)},"uiAction:followUser":function(){i("follow_user")}},function(b,f){a.on(f,b)})}}return{init:function(e){g(c,e)}}});
DISQUS.define("cookies",function(){return{create:function(c,g,e){c=c+"="+g+"; path=/";e.domain&&(c+="; domain=."+e.domain);e.expiresIn&&(g=new Date,g.setTime(g.getTime()+e.expiresIn),c+="; expires="+g.toGMTString());document.cookie=c},read:function(c){c+="=";for(var g=document.cookie.split(";"),e,a=0;a<g.length;a++){for(e=g[a];e.charAt(0)==" ";)e=e.substring(1,e.length);if(e.indexOf(c)===0)return e.substring(c.length,e.length)}return null},erase:function(c,g){var e=new Date;e.setTime(e.getTime()+
-864E5);e=c+"=; path=/;expires="+e.toGMTString();g.domain&&(e+="; domain=."+g.domain);document.cookie=e}}});
DISQUS.define("lounge.utils",function(){function c(f){function b(b){b=Number(b).toString(16);return b.length==1?"0"+b:b}if(f.substr(0,1)==="#")return f;var a=/.*?rgb\((\d+),\s*(\d+),\s*(\d+)\)/.exec(f);if(!a||a.length!==4)return"";var f=b(a[1]),c=b(a[2]),a=b(a[3]);return"#"+f+c+a}var g=RegExp("[\\u0021-\\u002F\\u003A-\\u0040\\u005B-\\u0060\\u007B-\\u007E\\u00A1-\\u00BF\\u2010-\\u2027\\u2030-\\u205E\\u2300-\\u23FF\\u2E00-\\u2E7F\\u3001-\\u303F\\uFE10-\\uFE19\\uFE30-\\uFE4F\\uFE50-\\uFE6B\\uFF01-\\uFF0F\\uFF1A-\\uFF20\\uFF3B-\\uFF40\\uFF5B-\\uFF60\\uFF5F-\\uFF64]+$"),e=
{domain:DISQUS.urls.root.split("/")[2],create:function(a,b){DISQUS.cookies.create(a,b,{domain:e.domain,expiresIn:31536E6})},read:DISQUS.cookies.read,erase:function(a){DISQUS.cookies.erase(a,{domain:e.domain})}},a=function(){var a={};return{getItem:function(b){return a.hasOwnProperty(b)?a[b]:null},setItem:function(b,c){a[b]=String(c)},removeItem:function(b){delete a[b]}}}(),j=/^[a-z0-9_.%+\-]+@[0-9a-z.\-]+\.[a-z.]{2,6}$/i,h=function(){function a(){this.state=null;this.queue=[]}_.extend(a.prototype,
{highlight:function(b){this.state===null&&this._load();this.queue.push(b);this.state===2&&this._flush()},_load:function(){var b=this;b.state=1;DISQUS.require("http://mediacdn.disqus.com/1354046062/build/js/highlight.js",{},!1,function(){b.state=2;b._flush()})},_flush:function(){_.chainedDefer(this.queue,function(b){var a=$(b).html();$(b).html(a.replace(/^<br>/,""));hljs.highlightBlock(b)},this)}});return new a}();return{attempt:function(a,b){try{_.bind(a,b||{})()}catch(c){return c}return null},extract:function(a,
b){for(var c=b.split("."),e=c.shift();e;){if(c.length===0)return a[e];if(!_.isObject(a[e]))return;a=a[e];e=c.shift()}return a},addStylesheetRules:function(a){function b(){var e=_.find(document.styleSheets,function(b){return(b.ownerNode||b.owningElement).id===c});if(!e)return void setTimeout(b,50);for(var g=0,h=a.length;g<h;g++){var i=1,j=a[g],l=j[0],w="";Object.prototype.toString.call(j[1][0])==="[object Array]"&&(j=j[1],i=0);for(var A=j.length;i<A;i++){var x=j[i];w+=x[0]+":"+x[1]+(x[2]?" !important":
"")+";\n"}e.insertRule?e.insertRule(l+"{"+w+"}",e.cssRules.length):e.addRule(l,w,-1)}}var c="css_"+(new Date).getTime(),e=document.createElement("style");e.id=c;document.getElementsByTagName("head")[0].appendChild(e);window.createPopup||e.appendChild(document.createTextNode(""));b()},escapeColor:function(a){return c(a).replace(/[^#A-Fa-f0-9]/g,"")},makeCORSRequest:function(a,b,c){c=c||function(){};if(typeof XMLHttpRequest=="undefined")return null;var e=new XMLHttpRequest;if("withCredentials"in e)e.open(a,
b,!0),e.onreadystatechange=c;else if(typeof XDomainRequest!="undefined"){if(a!=="GET"&&a!=="POST")return null;e=new XDomainRequest;e.open(a,b);e.onload=c}else e=null;return e},hashStorage:a,cookies:e,niceTruncate:function(a,b){if(a.length<=b)return a;var c=a=a.slice(0,b-1),e=/(^.*\S)\s/.exec(a);e&&(a=e[1]);(e=g.exec(a))&&(a=a.slice(0,a.length-e[0].length));a.length<0.5*c.length&&(a=c);return a+"\u2026"},htmlDecode:function(a){var b=document.createElement("div");b.innerHTML=a;return b.childNodes.length===
0?"":b.childNodes[0].nodeValue},isWindowClosed:function(a){if(!a)return!0;try{return a.closed||a.closed===void 0}catch(b){return!0}},validateEmail:function(a){return j.test(a)},updateURL:function(a,b){var c=document.createElement("a"),b=b||{};c.href=a;b.hostname&&b.hostname.match(/\.$/)&&(b.hostname+=c.hostname);c=_.extend({protocol:c.protocol,hostname:c.hostname,pathname:c.pathname,search:c.search},b);if(!c.pathname.match(/^\//))c.pathname="/"+c.pathname;return c.protocol+"//"+c.hostname+c.pathname+
c.search},syntaxHighlighter:h}});
DISQUS.define("lounge.realtime",function(){function c(a,c,e){this.uid=e||+new Date;this.name=c;this.url=a+"?"+this.uid+"_"+c;this.xhr=null;this.marker=0}function g(a){this.uid=+new Date;this.url=a;this.main=null;this.data=[];this.c1=new c(a,"c1",this.uid);this.c2=new c(a,"c2",this.uid);this.handover=this.chaos=!1;this.interval=1;_([this.c1,this.c2]).each(_.bind(function(a){a.on("progress",this.onProgress,this);a.on("error",this.onError,this);a.on("success",this.onSuccess,this)},this))}var e=DISQUS.use("lounge.utils");
_.extend(c.prototype,Backbone.Events,{onLoad:function(){var a=this.xhr;a.readyState!==void 0&&a.readyState!==4||(a.status!==void 0&&a.status!==200&&this.trigger("error"),this.trigger("success"))},onProgress:function(){var a=this.xhr.responseText,c=0,e=[];if(a&&this.marker!==a.length){for(var a=a.slice(this.marker).split("\n"),f,b,g,i=a.length,n=0;n<i;n++)if(f=a[n],c+=f.length+1,b=f.replace(/^\s+|\s+$/g,"")){try{g=JSON.parse(b)}catch(o){if(n===i-1){c-=f.length+1;break}else{DISQUS.log("RT: unable to parse: ",
b,f);continue}}e.push(g)}else DISQUS.log("RT: empty row, ignoring...");e.length&&this.trigger("progress",e,this.name);c>0&&(this.marker+=c-1)}},run:function(){var a=e.makeCORSRequest("GET",this.url,_.bind(this.onLoad,this));a.onerror=_.bind(this.trigger,this,"error");a.onprogress=_.bind(this.onProgress,this);this.xhr=a;this.marker=0;try{a.send()}catch(c){this.xhr=null,DISQUS.log("Attempt to send a CORS request failed.")}}});_.extend(g.prototype,Backbone.Events,{run:function(a){a=a||"c1";DISQUS.log("Pool.run, chaos: %s, name: %s",
this.chaos,a);if(!(this.chaos&&a!==this.main))this.main=a,this.handover=!0,this[a].run(),DISQUS.log("RT: started a new connection "+a),this.chaos?(DISQUS.logError("RT: chaos mode"),this.interval<=120&&(this.interval*=2),_.delay(_.bind(this.run,this,"c1"),8E4,"c1")):_.delay(_.bind(this.run,this,a==="c1"?"c2":"c1"),8E4)},onProgress:function(a,c){if(this.handover||this.main===c)this.handover=this.main!==c,this.trigger("progress",a)},onError:function(){this.chaos=!0;this.trigger("error")},onSuccess:function(){this.chaos=
!1;this.trigger("success")}});return{Firehose:c,Pool:g}});
DISQUS.define("lounge.models",function(){function c(a,b,e){var f=c.pool(a),g=b&&b[a.prototype.idAttribute];if(!g)return new a(b,e);c.get(a,g)?f[g].set(b):f[g]=new a(b,e);return f[g]}var g=DISQUS.use("lounge.collections"),e=DISQUS.use("lounge.utils"),a=DISQUS.use("Bus"),j=DISQUS.strings.get;c.pool={};c.pool=function(a){a=c.pool[a.__type__];if(!a)throw Error("Model not registered. Use UniqueModel.addType");return a};c.get=function(a,b){return c.pool(a)[b]};c.addType=function(a,b){if(!b.__type__||!c.pool[a])b.__type__=
a,c.pool[a]={}};var h=Backbone.Model.extend({defaults:{settings:{}}}),f={getRelativeCreatedAt:function(){var a=this.get("createdAt");if(a)return a=DISQUS.assureOffset(a),moment(a,DISQUS.ISO_8601).fromNow()}},b=Backbone.Model.extend({defaults:{author:null,category:null,createdAt:null,forum:null,identifiers:[],ipAddress:null,isClosed:!1,isDeleted:!1,hasStreaming:!1,link:null,message:null,slug:null,title:null,userSubscription:!1,posts:0,reactions:0,likes:0,dislikes:0,userScore:0},initialize:function(a,
b){var c=this,b=b||{};c.moderators=b.moderators;c.forum=b.forum;c.users=new g.UserCollection(b.users,{thread:c});c.posts=new g.PostCollection(b.posts,{thread:c,cursor:b.postCursor});c.reactions=new g.ReactionsCollection(null,{thread:c});c.votes=new g.ThreadVoteCollection;c.posts.bind("add reset",function(a){a=a.models?a.models:[a];_.each(a,function(a){c.users.get(a.author.id)||c.users.add(a.author)})});c.posts.bind("destroy",function(){c.set("posts",c.get("posts")-1)});c.bind("change:posts",c.broadcastPostCount,
c);c.queue=new g.QueuedPostCollection(null,{thread:c})},_vote:function(a,b){var c=a-b;if(c===0)return c;this.set("likes",this.get("likes")+c);return c},vote:function(a){var b=this;b._vote(a,b.get("userScore"))!==0&&(this.set("userScore",a),DISQUS.api.call("threads/vote.json",{data:{thread:this.id,vote:a},method:"POST",success:function(c){c.response.id&&(b.votes.get(c.response.id)||b.votes.add({id:c.response.id,score:a}))}}))},broadcastPostCount:function(){a.sendGlobalMessage("lounge.updateCounter",
{count:this.get("posts")})},fetch:function(a){var b=this,c=b.attributes,a=a||{};DISQUS.api.call("threads/details.json",{data:{thread:c.identifier?"ident:"+c.identifier:"link:"+c.url,forum:c.forum},success:function(c){b.set(c.response);a.success&&a.success()},error:function(){DISQUS.debug?b.save({},{success:a.success}):console.log("Couldn't find thread; not creating in production.")}})},_toggleState:function(a,b){b||(b={});var c=a?"open.json":"close.json";this.set("isClosed",!a);DISQUS.api.call("threads/"+
c,{method:"POST",data:{thread:this.id},success:b.success,error:b.error})},open:function(a){this._toggleState(!0,a)},close:function(a){this._toggleState(!1,a)},sync:function(){var a=this,b=a.attributes;DISQUS.api.call("threads/create.json",{data:{title:b.title,forum:b.forum,identifier:b.identifier,url:b.url},method:"POST",success:function(b){a.set(b.response)}})},incrementPostCount:function(a){this.set("posts",this.get("posts")+a)},isModerator:function(a){if(this.moderators)return a=a instanceof m||
_.isObject(a)?a.id:a,a=parseInt(a,10),_(this.moderators).contains(a)},subscribe:function(a,b){var a=a!==!1,c=this.get("userSubscription");if(c!=a){a?this.set("userSubscription",b||!0):this.set("userSubscription",!1);var e={thread:this.id};if(b)e.email=b;else if(!a&&typeof c==="string")e.email=c;DISQUS.api.call("threads/"+(a?"subscribe.json":"unsubscribe.json"),{data:e,method:"POST"})}},relatedIds:function(){var a=this.get("forum");_.isObject(a);return{forum:this.get("forum"),thread:this.id}},twitterText:function(a){var a=
140-(a.length+1),b=DISQUS.lounge.utils.htmlDecode(this.get("title"));return b=DISQUS.lounge.utils.niceTruncate(b,a)},url:function(){var a=this.get("url")||this.get("link");if(!a&&this.currentUrl)a=this.currentUrl;return a}}),q=b.extend({defaults:_.extend({postsInInterval:0,topPost:null},b.prototype.defaults)}),i=Backbone.Model.extend({defaults:function(){return{createdAt:moment().format(DISQUS.ISO_8601),dislikes:0,isApproved:!0,isDeleted:!1,isEdited:!1,isFlagged:!1,isHighlighted:!1,isRealtime:!1,
isImmediateReply:!1,isMinimized:null,message:null,raw_message:null,likes:0,media:[],parent:null,points:0,depth:0,userScore:0}},initialize:function(){this.votes=new g.VoteCollection;this.usersTyping=new g.TypingUserCollection},set:function(a,b,e){if(a&&typeof a!=="string"&&a.author)this.author=new c(m,a.author),delete a.author;return Backbone.Model.prototype.set.call(this,a,b,e)},messageText:function(){var a=this.get("message");return _.strip(a)},relatedIds:function(){var a=this.get("forum");if(_.isObject(a))a=
a.id;var b=this.get("thread");if(_.isObject(b))b=b.id;return{forum:a,thread:b,post:this.id}},twitterText:function(a){var b=140,c;c=this.author.get("name")||this.author.get("username");b-=c.length+3;b-=a.length+1;b-=2;a=this.messageText();a=DISQUS.lounge.utils.niceTruncate(a,b);return'"'+a+'" \u2014 '+c},toJSON:function(){var a=Backbone.Model.prototype.toJSON.call(this);a.isMinimized=this.get("isMinimized")===!1?!1:!this.get("isApproved");if(this.author)a.author=this.author.toJSON();a.relativeCreatedAt=
this.getRelativeCreatedAt();a.formattedCreatedAt=this.getFormattedCreatedAt();return a},getFormattedCreatedAt:function(){var a=this.get("createdAt");if(!a)return null;a=DISQUS.assureOffset(a);return moment.utc(a,DISQUS.ISO_8601).local().format("LLLL")},validate:function(a){if(!this.id&&!a.id){if(_.isString(a.raw_message)){if(a.raw_message==="")return j("Comments can't be blank.");if(a.raw_message.length<2)return j("Comments must have at least 2 characters.")}if(a.author_email===""&&a.author_name===
"")return j("Please sign in or enter a name and email address.");else if(a.author_email===""||a.author_name==="")return j("Please enter both a name and email address.");if(_.isString(a.author_email)&&!e.validateEmail(a.author_email))return j("Invalid email address format.")}},report:function(){this.set("isFlagged",!0);DISQUS.api.call("posts/report.json",{data:{post:this.id},method:"POST"})},_vote:function(a,b){function c(a){f.set("likes",f.get("likes")+a)}function e(a){f.set("dislikes",f.get("dislikes")+
a)}var f=this,g=a-b;if(g===0)return g;f.set("points",f.get("points")+g);a>0?(c(a),e(b)):a<0?(e(-a),c(-b)):b>0?c(-b):e(b);return g},vote:function(a){var b=this;b._vote(a,b.get("userScore"))!==0&&(b.set("userScore",a),DISQUS.api.call("posts/vote.json",{data:{post:b.id,vote:a},method:"POST",success:function(a){b.votes.add({id:a.response.id})}}))},_delete:function(){this.set({isApproved:!1,isDeleted:!0});DISQUS.api.call("posts/remove.json",{data:{post:this.id},method:"POST"})},spam:function(){this.set({isApproved:!1,
isDeleted:!0,isSpam:!0});this.trigger("spam");DISQUS.api.call("posts/spam.json",{data:{post:this.id},method:"POST"})},_create:function(a,b){var c=this,e=a.attributes,f={thread:e.thread,message:e.raw_message};if(e.recaptcha_challenge_field)f.recaptcha_challenge_field=e.recaptcha_challenge_field,f.recaptcha_response_field=e.recaptcha_response_field;if(e.parent)f.parent=e.parent;if(e.author_name)f.author_name=e.author_name,f.author_email=e.author_email;DISQUS.api.call("posts/create.json",{data:f,method:"POST",
success:function(a){c.set(a.response);b.success&&b.success()},error:b.error})},_update:function(a,b){var c=this,e=a.attributes;DISQUS.api.call("posts/update.json",{data:{post:e.id,message:e.raw_message},method:"POST",success:function(a){c.set(a.response);b.success&&b.success()},error:b.error})},_read:function(a,b){var c=this,b=b||{};DISQUS.api.call("posts/details.json",{data:{post:c.id},method:"GET",success:function(a){c.set(a.response);b.success&&b.success()},error:b.error})},sync:function(a,b,c){var c=
c||{},e=c.error;if(e)c.error=function(a){e(JSON.parse(a.responseText||"{}"))};switch(a){case "create":this._create(b,c);break;case "update":this._update(b,c);break;case "delete":this._delete();break;case "read":this._read(b,c)}}});_.extend(i.prototype,f);c.addType("Post",i);var n=Backbone.Model.extend({defaults:{userId:null,message:null,parentId:null,immedReply:!1},initialize:function(){this.set("createdAt",moment().format(DISQUS.ISO_8601))},getVisibleParent:function(a){for(var b=this,c;b.get("parentId");){if(c=
a.posts.get(b.get("parentId")))return c;b=a.queue.get(b.get("parentId"));if(!b)break}return null},toPost:function(a){var b=a.posts.get(this.get("parentId")),b=b?b.get("depth")+1:0,b=new c(i,{id:this.id,thread:a.id,message:this.get("message"),parent:this.get("parentId"),depth:b,createdAt:this.get("createdAt"),isRealtime:!0,isImmediateReply:this.get("immedReply")});b.author=a.users.get(this.get("userId"));return b}}),o=Backbone.Model.extend({defaults:{typing:!0},initialize:function(){this.createdAt=
moment()}}),k=Backbone.Model.extend({defaults:{about:null,avatar:{cache:DISQUS.urls.media+"/images/noavatar92.png",permalink:DISQUS.urls.media+"/images/noavatar92.png"},connections:{},email:null,emailHash:null,isAnonymous:!0,isFollowedBy:!1,isFollowing:!1,joinedAt:null,name:null,profileUrl:null,url:null,username:null,numPosts:null,numFollowing:null,numFollowers:null,numLikesReceived:null},hasValidAvatar:function(a){if(!a)a=this.attributes;return(a=a.avatar)&&a.cache},validate:function(a){if(!this.hasValidAvatar(a))return"None of the avatar related properties can be null, undefined or empty on User models."},
toJSON:function(){var a=Backbone.Model.prototype.toJSON.apply(this,arguments);a.thread={};if(!this.hasValidAvatar())a.avatar=this.defaults.avatar;return a}}),r=k.extend({idAttribute:"emailHash"});c.addType("AnonUser",r);var m=k.extend({fetch:function(a){var b=this,a=a||{};DISQUS.api.call("users/details.json",{data:b.id?{user:b.id}:{},success:function(c){c=c.response;b.set(c);a.success&&a.success(c);a.complete&&a.complete(c)},error:function(b){a.error&&a.error(b);a.complete&&a.complete(b)}})},toJSON:function(){var a=
k.prototype.toJSON.call(this),b=this.collection&&this.collection.thread;a.thread.canModerate=!!b&&b.isModerator(this);return a},follow:function(){var a=this;DISQUS.api.call("users/follow.json",{data:{target:this.id},method:"POST",success:function(){a.set("isFollowing",!0)}})},unfollow:function(){var a=this;DISQUS.api.call("users/unfollow.json",{data:{target:this.id},method:"POST",success:function(){a.set("isFollowing",!1)}})}});c.addType("User",m);var l=m.extend({defaults:_.extend({numPosts:0},m.prototype.defaults)}),
w=function(){var a=Backbone.Model.extend({defaults:{canReply:!0,canModerate:!1,mustVerifyEmail:!1,isReadOnly:!1,audienceSyncVerified:!1,notificationCount:null},initialize:function(){this.user=new c(r);if("defineProperty"in Object)try{_.each(_.keys(a.prototype.defaults),function(a){var b=_.bind(function(){var b="Deprecated SessionModel accessor: "+a+". Use session.get(param) instead.";DISQUS.log&&DISQUS.log(b);Raven&&Raven.captureMessage&&Raven.captureMessage({name:"Warning",message:b});return this.get(a)},
this);Object.defineProperty(this,a,{get:b})},this)}catch(b){}},_eventProxy:function(){this.trigger.apply(this,arguments)},_setProxy:function(){this.user.on("all",this._eventProxy,this)},_clearProxy:function(){this.user&&this.user.off("all",this._eventProxy,this)},_setUser:function(a){this._clearProxy();this.user=a;this._setProxy();this.notifications=new g.NotificationCollection(null,{user:this.user});this.notifications.on("markRead",function(){this.set("notificationCount",0)},this);this.trigger("change:id",
a)},isRegistered:function(){return this.user instanceof m},isAnonymous:function(){return this.user instanceof r},toJSON:function(){var a=this.user.toJSON.apply(this.user,arguments);a.thread.canReply=this.get("canReply");if(!a.thread.canModerate)a.thread.canModerate=this.get("canModerate");return a},fetch:function(a){var b=this,a=a||{thread:{}},e={thread:a.thread.id,post:a.thread.posts.pluck("id")};e["_"+(new Date).getTime()]=1;DISQUS.api.call("embed/threadDetails.json",{data:e,success:function(e){var e=
e.response,f={};e.user&&_.extend(f,e.user,{votes:e.votes});f.id&&(b.set(e.session),b._setUser(new c(m,f)),a.thread.users.add(b.user),e.thread&&(a.thread.set("userScore",e.thread.userScore),a.thread.set("userSubscription",e.thread.userSubscription)));a.success&&a.success(e);a.complete&&a.complete(e)},error:function(b){a.error&&a.error(b);a.complete&&a.complete(b)}})},register:function(a,b){var e=this;DISQUS.api.call("internal/users/register.json",{secure:!0,data:{display_name:a.name,email:a.email},
method:"POST",success:function(a){e._setUser(new c(m,a.response))},error:b.error||function(){}})},logout:function(){var a=this;DISQUS.api.call("internal/users/logout.json",{method:"POST",success:function(){a._setUser(new c(r))}})}}),b;return{get:function(){return b=b||new a},setDefaults:function(c){if(b)throw Error("Session defaults cannot be changed after a session instance is created!");return a.defaults=_.extend(a.prototype.defaults,c)},forget:function(){b=null}}}(),A=Backbone.Model.extend({defaults:{score:0}}),
x=Backbone.Model.extend({defaults:{score:0}}),E=Backbone.Model.extend({defaults:function(){return{object:{},type:"",createdAt:moment().format(DISQUS.ISO_8601)}},toJSON:function(){var a=Backbone.Model.prototype.toJSON.call(this),b=DISQUS.assureOffset(this.get("createdAt"));a.relativeCreatedAt=moment(b,DISQUS.ISO_8601).fromNow();return a}}),y=Backbone.Model.extend({defaults:function(){return{sender:"",timestamp:moment().valueOf(),type:0,formatted:"",theme:"",createdAt:null,post:null}},set:function(a,
b){if(a&&typeof a!=="string"&&a.post)this.post=new i(a.post),delete a.post;return Backbone.Model.prototype.set.call(this,a,b)},toJSON:function(){var a=Backbone.Model.prototype.toJSON.call(this);if(this.post)a.post=this.post.toJSON();a.relativeCreatedAt=this.getRelativeCreatedAt();return a}});_.extend(y.prototype,f);var f=Backbone.Model.extend({defaults:{enabled:!1}}),C=Backbone.Model.extend({defaults:{thread:null,forum:null,body:null,service:{url:null,name:null},url:null,title:null},set:function(a,
b){if(a&&typeof a!=="string"){if(a.author)this.author=new c(a.author.id?m:r,a.author),delete a.author;if(a.createdAt)a.relativeCreatedAt=moment(DISQUS.assureOffset(a.createdAt),DISQUS.ISO_8601).fromNow()}return Backbone.Model.prototype.set.call(this,a,b)},toJSON:function(){var a=Backbone.Model.prototype.toJSON.call(this);if(this.author)a.author=this.author.toJSON();return a},destroy:function(){DISQUS.api.call("reactions/remove.json",{data:{reaction:this.id,forum:this.get("forum")},method:"POST"})}});
return{UniqueModel:c,Forum:h,Thread:b,TopThread:q,Post:i,QueuedPost:n,Reaction:C,TypingUser:o,User:m,AnonUser:r,Session:w,TopUser:l,Vote:A,ThreadVote:x,Notification:y,ActivityItem:E,Switch:f}});
DISQUS.define("lounge.collections",function(){var c=DISQUS.use("lounge.models"),g=DISQUS.use("lounge.utils"),e=Backbone.Collection.extend({model:c.ThreadVote}),a=Backbone.Collection.extend({model:_.bind(c.UniqueModel,{},c.User),initialize:function(a,b){Backbone.Collection.prototype.initialize.apply(this,arguments);this.thread=b&&b.thread}}),j=Backbone.Collection.extend({model:c.Vote}),h=Backbone.Collection.extend({PER_PAGE:10,initialize:function(a,b){b=b||{};this.cursor=b.cursor||{}},fetch:function(a){a=
a||{};a.data=_.defaults(a.data||{},{cursor:a.cursor||"",limit:this.PER_PAGE});return Backbone.Collection.prototype.fetch.call(this,a)},more:function(a){function b(a){e.push(a)}var c=this;if(this.cursor.hasNext){var e=[];this.on("add",b);this.fetch(_.extend({},a||{},{add:!0,cursor:this.cursor.next,success:function(){c.trigger("add:many",e,c,a);c.off("add",b);a.success&&a.success()}}))}else a.error&&a.error()},parse:function(a){this.cursor=a.cursor;return Backbone.Collection.prototype.parse.call(this,
a)}}),f=h.extend({model:c.Notification,url:DISQUS.api.getURL("messagesx/list"),initialize:function(a,b){this.user=b.user;h.prototype.initialize.apply(this,arguments)},markRead:function(){var a=this,b=_.pluck(a.models,"id");DISQUS.api.call("messagesx/markRead.json",{data:{messages:b},method:"POST",success:function(){a.remove(b)}});this.trigger("markRead",b)}}),b=h.extend({PER_PAGE:50,model:_.bind(c.UniqueModel,{},c.Post),url:DISQUS.api.getURL("threads/listPostsThreaded"),initialize:function(a,b){h.prototype.initialize.apply(this,
arguments);this.thread=b.thread;this.order=g.cookies.read("disqus.order")||"popular"},fetch:function(a){a=a||{};this.order==="popular"?g.cookies.erase("disqus.order"):g.cookies.create("disqus.order",this.order);a=_.extend(a,{data:{limit:this.PER_PAGE,thread:this.thread.id,forum:this.thread.get("forum"),order:this.order}});return h.prototype.fetch.call(this,a)},add:function(a,b){_.isArray(a)||(a=[a]);for(var c=[],e=0;e<a.length;e++)this.get(a[e].id)||c.push(a[e]);Backbone.Collection.prototype.add.call(this,
c,b)}}),q=Backbone.Collection.extend({model:c.QueuedPost,initialize:function(a,b){var c=this;c.thread=b.thread;c.counters={comments:0,replies:{}};c.bind("add",function(a){var b=a.getVisibleParent(c.thread);b?(c.counters.replies[b.id]?c.counters.replies[b.id]+=1:c.counters.replies[b.id]=1,b.id==a.get("parentId")&&a.set("immedReply",!0)):c.counters.comments+=1})},comparator:function(a){return parseInt(a.get("id"),10)},isDescendant:function(a,b){var d;var c=a.get("parentId"),c=c?this.get(c):null,e={};
for(_.each(b,function(a){e[a]=!0});c;){if(e[c.get("id")]===!0)return!0;d=(c=c.get("parentId"))?this.get(c):null,c=d}return!1},drain:function(a){function b(a){var c=[];e.each(function(a){a.get("parentId")===null&&c.push(a.get("id"))});e.reset(e.filter(function(b){if(b.get("parentId")!==null&&!e.isDescendant(b,c))return b;a(b)}));e.counters.comments=0}function c(b){var f=[],g=[],g=e.filter(function(b){var c=b.getVisibleParent(e.thread);if(!c||c.get("id")!=a)return b;f.push(b)}),f=_.sortBy(f,function(a){return parseInt(a.get("id"),
10)});_.each(f,function(a){b(a)});e.reset(g);e.counters.replies[a]=0}var e=this;return(a?c:b)(function(a){e.thread.posts.add(a.toPost(e.thread))})}}),i=Backbone.Collection.extend({model:c.Switch,parse:function(a){return _.map(a,function(a,b){return{id:b,enabled:a}})},enabled:function(a){return(a=this.get(a))?a.get("enabled"):!1}}),n=Backbone.Collection.extend({models:c.TypingUser,initialize:function(){var a=this;a.gc=null;a.bind("add remove reset",function(){var b=a.count();if(b>0&&a.gc===null)a.gc=
setInterval(_.bind(a.cleanup,a),6E4);else if(b<=0&&a.gc!==null)clearInterval(a.gc),a.gc=null},a)},count:function(){var a=0;this.each(function(b){a+=b.get("typing")?1:-1});return a},cleanup:function(){var a=moment();this.reset(this.filter(function(b){return b.createdAt.diff(a,"minutes")>5}))}}),o=Backbone.Collection.extend({model:c.ActivityItem,url:DISQUS.api.getURL("users/listActivity"),initialize:function(a,b){this.user=b.user;this.include=b.include||null},fetch:function(){var a={user:"username:"+
this.user.get("username")};if(this.include)a.include=this.include;Backbone.Collection.prototype.fetch.call(this,{data:a})}}),k=h.extend({model:_.bind(c.UniqueModel,{},c.Post),url:DISQUS.api.getURL("users/listPostActivity")}),r=Backbone.Collection.extend({model:c.TopThread,url:DISQUS.api.getURL("threads/listPopular"),initialize:function(a,b){this.forum=b.forum;this.limit=b.limit},add:function(a,b){_.isArray(a)||(a=[a]);var c=[];_.each(a,function(a){a.title.match(/^http/i)||c.push(a)});Backbone.Collection.prototype.add.call(this,
c,b)},fetch:function(){Backbone.Collection.prototype.fetch.call(this,{data:{forum:this.forum,limit:this.limit,interval:"7d",with_top_post:!0}})}}),m=Backbone.Collection.extend({model:c.TopUser,url:DISQUS.api.getURL("forums/listMostActiveUsers"),initialize:function(a,b){this.forum=b.forum;this.limit=b.limit;this.discardLowRep=b.discardLowRep},fetch:function(){Backbone.Collection.prototype.fetch.call(this,{data:{forum:this.forum,limit:this.limit}})},parse:function(a){if(!this.discardLowRep)return a.response;
return _.filter(a.response,function(a){if(parseFloat(a.rep)>0.7)return a})}}),c=h.extend({PER_PAGE:20,model:c.Reaction,url:DISQUS.api.getURL("threads/listReactions"),initialize:function(a,b){this.thread=b.thread},fetch:function(a){a=a||{};a=_.extend(a,{data:{limit:this.PER_PAGE,thread:this.thread.id}});return h.prototype.fetch.call(this,a)}});return{PaginatedCollection:h,UserCollection:a,PostCollection:b,ReactionsCollection:c,TypingUserCollection:n,TopUserCollection:m,TopThreadCollection:r,VoteCollection:j,
ThreadVoteCollection:e,ActivityCollection:o,PostActivityCollection:k,NotificationCollection:f,QueuedPostCollection:q,SwitchCollection:i}});
DISQUS.define("lounge.views",function(){function c(d){return(d=d&&d.match(/discovery\-([\w\-]+)/))&&d[1]}function g(d){return function(a){a&&a.preventDefault&&a.preventDefault();d.apply(this,arguments)}}function e(d,a){var b="[data-action^="+a+"]",c=$(d),c=c.is(b)&&c||c.closest(b);return(c.attr("data-action")||":").split(":")[1]}var a=DISQUS.use("lounge.models"),j=DISQUS.use("lounge.collections"),h=DISQUS.use("lounge.utils"),f=DISQUS.use("lounge.realtime"),b=DISQUS.use("Bus"),q=DISQUS.use("JSON"),
i=DISQUS.strings.get,n,o=1,k={_getShortUrl:function(d){var a=this,b=this._shareUrl(),c=b,b=_.extend({url:b,source:"disqus_embed_next"},this.model.relatedIds());DISQUS.api.call("shortener/create.json",{method:"POST",data:b,timeout:5E3,success:function(d){if(d.code===0)c=d.response.url},complete:function(){d.call(a,c)}})},_shareWaitPopup:function(d){return window.open(DISQUS.urls.loading,"_blank",d||"width=550,height=520")},share:function(d){this.sharers[d].call(this)},sharers:{twitter:function(){var d=
this._shareWaitPopup();this._getShortUrl(function(a){d.location=DISQUS.serialize("https://twitter.com/intent/tweet",{url:a,text:this.model.twitterText(a)})})},facebook:function(){var d=this._shareWaitPopup("width=655,height=352");this._getShortUrl(function(a){d.location=DISQUS.serialize("https://www.facebook.com/sharer.php",{u:a})})}}},r={alert:function(d,a){a?_.isString(a)&&(a={type:a}):a={};this._alert&&this._alert.dismiss();var b=this._alert=new O(_.extend({message:d},a));this.updateDom(function(){b.render().$el.prependTo($("#form")[0])});
return b}},m=Backbone.View.extend({events:{"click [data-action^=auth:]":"handleAuth","click [data-action=verify-email]":"verifyEmail","click [data-action=audiencesync]":"audienceSync","click [data-action=profile]":"handleShowProfile","click [data-action=sort]":"handleSort","click [data-action=close-thread]":"closeThread","click [data-action=open-thread]":"openThread","click [data-action=debug]":"renderDebugInfo"},STREAMING_MAX_VISIBLE:250,initialize:function(d){n=this;d=d||{};d=d.jsonData||{};this.initialData=
d.response||{};if(h.extract(d,"response.forum.id"))DISQUS.urls.moderate=h.updateURL(DISQUS.urls.moderate,{hostname:d.response.forum.id+"."});this.theme=h.extract(this.initialData,"theme.base")||{};a.Session.setDefaults(this.initialData.session);this.session=a.Session.get();this.forum=new a.Forum;this.initialData&&this.initialData.forum&&this.forum.set(this.initialData.forum);this.thread=new a.Thread(null,{forum:this.forum,postCursor:d.cursor,moderators:(this.initialData.thread||{}).moderators});this.posts=
this.thread.posts;this.switches=new j.SwitchCollection;this.realtimePool=null;this.renderJobs=[];this.states={templateReady:!1,realtimeIndicatorsCreated:!1,pollingRunning:!1,ravenConfigured:!1,inViewport:!1,streamingPaused:!1};if(this.forum.get("settings").backplaneAuthOnly)this.backplaneCredentialsReady=!1,b.sendHostMessage("loadBackplane"),this.events["click [data-action=logout]"]=g(function(){b.sendHostMessage("backplane.invalidate",{redirectUrl:DISQUS.urls.logout})}),this.session.on("identify",
function(){if(!this.isRegistered())b.sendHostMessage("backplane.invalidate"),this.backplaneCredentialsReady=!1,DISQUS.api.defaults({headers:{}})}),b.bind("login",function(d){d.backplane!==null&&(this.setBackplaneHeaders(d.backplane),this.initializeSession())},this);b.bind("window.inViewport",function(){this.states.inViewport=!0;this.trigger("inViewport")},this);b.bind("window.scrollOffViewport",function(){this.states.inViewport=!1},this);b.bind("switches.changed",function(d){this.switches.reset(this.switches.parse(d));
if(!this.states.ravenConfigured&&this.switches.enabled("next_raven"))Raven.config({servers:["http://disqus.com/raven/api/store/"],logger:"javascript.next",ignoreErrors:["Script error."]}),window.onerror=Raven.process,DISQUS.api.defaults({error:function(d){Raven.captureMessage({name:"API call failed.",message:d})}}),this.states.ravenConfigured=!0;if(!this.switches.enabled("next_lazy_embed")||this.states.inViewport)this.initializeSession();else this.on("inViewport",this.initializeSession,this);this.initLinkAffiliator()},
this);this.switches.on("reset",function(){DISQUS.defer(_.bind(function(){if(!this.states.templateReady)return!1;return this.thread&&this.thread.id},this),_.bind(this.poll,this))},this);b.bind("init",function(d){n.bootstrap(d)});d={};if(typeof this.initialData==="object"&&!_.isEmpty(this.initialData))d.thread={id:this.initialData.thread.id};b.sendHostMessage("ready",d)},_templateReady:function(){this.updateModeratorText();this.states.templateReady=!0;this.renderLayout();this.trigger("templateReady")},
setBackplaneHeaders:function(d){this.backplaneCredentialsReady=!0;DISQUS.api.defaults({headers:{"X-Disqus-Backplane-Auth":"janrain","X-Disqus-Backplane-Channel-Name":d.channel,"X-Disqus-Backplane-Message-Id-Url":d.messageUrl}})},bootstrap:function(d){var a=this;a.config=d||{};var e={};if(d.apiKey)e["X-Disqus-Publisher-API-Key"]=d.apiKey;if(d.remoteAuthS3)e["X-Disqus-Remote-Auth"]=d.remoteAuthS3;_.isEmpty(e)||DISQUS.api.defaults({headers:e});d.anchorColor&&function(){var a=h.escapeColor(d.anchorColor);
h.addStylesheetRules([[".publisher-anchor-color a",["color",a,!0]],["a.publisher-anchor-color",["color",a,!0]],[".publisher-anchor-hover a:hover",["color",a,!0]],["a.publisher-anchor-hover:hover",["color",a,!0]],[".active .publisher-nav-color:after",["background",a,!0]],[".media-preview .active.publisher-border-color",["border-color",a,!0]]])}();(function(){var a=document.createElement("base");a.target="_parent";a.href=d.referrer;$("head").append(a)})();if(d.referrer)a.thread.currentUrl=d.referrer;
if(d.width)document.body.style.width=d.width+"px";if(d.permalink)a.on("postsRendered",_.once(function(){a.scrollToPost(d.permalink)}));if(d.sso)DISQUS.templateGlobals.sso=d.sso;this.loadTheme(d);a.bind("templateReady",a.renderForm,a);a.bind("templateReady",a.updatePostCount,a);a.bind("templateReady",a.initCommunity,a);a.bind("templateReady",a.initReactions,a);a.bind("templateReady",a.initUserMenu,a);a.bind("templateReady",a.initThreadVotes,a);a.bind("templateReady",a.initThreadShareMenu,a);a.bind("templateReady",
a.initThreadSubscribe,a);a.bind("templateReady",a.renderStreamingToggle,a);a.renderBindings([a.thread,"change:likes",a.updateThreadVotes],[a.thread,"change:userScore",a.updateThreadUserScore],[a.thread,"change:posts",a.updatePostCount],[a.thread.posts,"reset",a.redrawPosts],[a.thread.posts,"add",a.addPosts],[a.thread.posts,"remove",a.removePost],[a.thread.posts,"reset add",a.toggleLoadMorePosts],[a.thread.posts,"reset add",a.toggleNoPosts],[a.thread.posts,"reset",function(){a.poll()}],[a.thread.reactions,
"reset add",a.toggleLoadMoreReactions],[a.session,"change:id",a.updateThreadSessionData],[a.session,"change:id",a.initDashboard],[a.session,"change:id",a.audienceSyncToggle]);a.bind("scroll",function(d){a.position=d;if(a.currentSection==="conversation")a.conversationPosition=d});a.bind("scrollOffViewport",function(){a.states.realtimeIndicatorsCreated&&a.currentSection==="conversation"&&(b.sendHostMessage("realtime.hideNorth"),b.sendHostMessage("realtime.hideSouth"))});a.bind("scroll",function(d){if(a.states.realtimeIndicatorsCreated&&
a.currentSection==="conversation"){var c=_.union([this.queueView],_.values(this.postViews)),e=0,s=0;_.each(c,function(a){if(a&&!a.getDirection)a=a.queueView;if(a&&!(a.options.count<=0)){var b=a.getDirection(d);b===1?e+=a.options.count:b===-1&&(s+=a.options.count)}});var c="realtime.hideNorth",f;e>0&&(c="realtime.showNorth",f=DISQUS.renderBlock("realtimeIndicatorText",{num:e,orientation:"north"}));b.sendHostMessage(c,f);c="realtime.hideSouth";f=void 0;s>0&&(f=DISQUS.renderBlock("realtimeIndicatorText",
{num:s,orientation:"south"}),c="realtime.showSouth");b.sendHostMessage(c,f)}},a);b.bind("window.hashchange",function(d){if(c(d))return void b.sendHostMessage("reset");(d=d&&d.match(/comment\-([0-9]+)/))&&a.scrollToPost(d[1])});b.bind("window.scroll",function(d){a.trigger("scroll",d)});b.bind("window.scrollOffViewport",function(){a.trigger("scrollOffViewport")});b.bind("window.resize",a.resize,a);b.bind("realtime.click",function(d){b.sendHostMessage("realtime.hide"+(d==="north"?"North":"South"));var c=
_.union([a],_.toArray(a.postViews)),e,s,c=_.filter(c,function(b){b=b.queueView;if(!b||b.options.count<=0)return!1;var c=d==="north"?1:-1;if(b.getDirection(a.position)!==c)return!1;return!0}),c=_.sortBy(c,function(d){if(d===a)return 0;return d.offset.top}),c=d==="north"?_.last(c):_.first(c);e=c.queueView;c===a?(s=0,e.model.queue.drain(),e.setCount(e.model.queue.length)):(s=c.offset.top-100,e.options.thread.queue.drain(e.model.id),e.setCount(e.options.thread.queue.length));var f=function(){b.sendHostMessage("scrollTo",
{top:s});m.getInstance().off("domReflow",f)};m.getInstance().on("domReflow",f)});a.thread.queue.bind("add reset",a.toggleRealtimeNotifications,a);a.thread.set(this.initialData.thread);a.posts.reset(this.initialData.posts);e=$("body");a.getTypeface()==="serif"&&e.addClass("serif");a.getColorScheme()==="dark"&&e.addClass("dark");b.bind("auth:success",function(d){d&&d.sessionId&&DISQUS.api.defaults({headers:{"X-Sessionid":d.sessionId}});a.refreshSession()});b.bind("audiencesync:grant",function(){if(this._alert)this._alert.remove(),
this._alert=null;this.windowClose()},this);b.bind("audiencesync:deny",function(){this.windowClose()},this);_.delay(function J(){a.postViews&&!(_.size(a.postViews)<1)&&(_.invoke(a.postViews,"updateRelativeTime"),_.delay(J,6E4))},6E4);a.currentSection="conversation";a.thread.on("create",function(d){b.sendHostMessage("posts.create",d.toJSON())});a.initialized=!0},initLinkAffiliator:function(){if(this.switches.enabled("enable_link_affiliation")&&h.extract(this,"initialData.forum.settings.linkAffiliationEnabled")&&
!this.isHttps()&&!this.initLinkAffiliatorCalled){this.initLinkAffiliatorCalled=!0;var d=h.extract(this,"initialData.forum.pk");if(_.isNumber(d)){var a=new P({el:document.body});b.on("affiliationOptions",function ga(d){b.off("affiliationOptions",ga);d&&_.isNumber(d.timeout)&&a.trigger("options.timeout",d.timeout)});b.sendHostMessage("loadLinkAffiliator",{clientUrl:DISQUS.urls.linkAffiliatorClient,apiUrl:"//links.services.disqus.com/api",key:"cfdfcf52dffd0a702a61bad27507376d",id:d})}}},loadTheme:function(d){var a=
this.theme.js,b=this.theme.css;d.themeUrl&&(a=d.themeUrl+"/theme.js",b=d.themeUrl+"/theme.css");var d=function(d,a){return DISQUS.serialize((a||"js")+"!"+d,null,DISQUS.debug)},c=this.initialData.forum.language||"en";this.language=c;var a=curl([d(b,"css"),d(a)]),e=_.bind(this._templateReady,this);c!=="en"&&(a=a.next([d(DISQUS.urls.media+"/build/lang/"+c+".js"),d(DISQUS.urls.media+(DISQUS.debug?"/js/src/lib/moment/lang/":"/build/lang/moment/")+c+".js")]));a.then(e,function(d){e();DISQUS.log(d)})},externalSessionPending:function(){var d=
this.forum.get("settings");if(d.ssoRequired&&!this.config.remoteAuthS3)return!0;if(d.backplaneAuthOnly&&!this.backplaneCredentialsReady)return!0;return!1},initializeSession:function(){var d=this;d.externalSessionPending()||d.session.fetch({thread:d.thread,complete:function(a){d.session.trigger("identify");d.session.on("authenticated",d.refreshSession,d);var b=a.discovery||h.extract(a,"theme.discovery");b&&d.initDiscovery(b);b=m.getInstance();h.extract(a,"session.isReadOnly")&&b.alert(i("The Disqus comment system is temporarily in maintenance mode. You can still read comments during this time, however posting comments and other actions are temporarily delayed."))}})},
refreshSession:function(){this.session.fetch({thread:this.thread})},initRealtime:function(){var d={width:$("html").width()+"px",position:"fixed"},a={contents:DISQUS.renderBlock("realtimeIndicator",{orientation:"north"}),styles:{top:"0"}},c={contents:DISQUS.renderBlock("realtimeIndicator",{orientation:"south"}),styles:{bottom:"0"}};_.defaults(a.styles,d);_.defaults(c.styles,d);b.sendHostMessage("realtime.init",{north:a,south:c});this.states.realtimeIndicatorsCreated=!0},insertStreamingComments:_.throttle(function(){var d=
this.thread.queue;d.drain();_.each(d.counters.replies,function(a,b){d.drain(b)})},1E3),getTypeface:function(){var d=this.forum.get("settings");return d.typeface==="auto"?this.config.typeface:d.typeface},getColorScheme:function(){var d=this.forum.get("settings");return d.colorScheme==="auto"?this.config.colorScheme:d.colorScheme},updateModeratorText:function(){var d=this.forum.get("settings");if(d.moderatorText)DISQUS.strings.translations.Mod=d.moderatorText},toggleRealtimeNotifications:function(){var d=
this,a=d.thread.queue;d.updateDom(function(){_.defer(function(){b.sendHostMessage("fakeScroll")});if(!a.length)return void $("[data-role=realtime-notification]").hide();if(d.thread.get("hasStreaming"))return void d.insertStreamingComments();var c=d.queueView||new F({model:d.thread,el:d.$el.find("button[data-role=realtime-notification]")});d.queueView=c;c.setCount(a.counters.comments);c.render();_.each(a.counters.replies,function(a,b){var c=d.thread.posts.get(b);if(c){var u=d.postViews[c.cid],e=u.queueView;
if(!e)e=new Q({thread:d.thread,postView:u,model:c,el:u.$el.find("[data-role=realtime-notification:"+b+"] a")}),u.queueView=e;e.setCount(a);e.render()}})})},renderDebugInfo:g(function(){if(this.session.user.get("isGlobalAdmin")){var d=new R({Shortname:this.thread.get("forum"),"Thread ID":this.thread.get("id"),"Thread slug":this.thread.get("slug"),"Anchor color":h.escapeColor(this.config.anchorColor)});d.render();this.updateDom(function(){var a=document.body;a.insertBefore(d.el,a.firstChild)})}}),scrollToPost:function(d,
c,e){var f=this;f.currentSection!=="conversation"&&(e=!0);f.mainNav.navTo("conversation");var g=f.$el.find("#post-"+d);g.length?(c=c||0,_.delay(function(){b.sendHostMessage("scrollTo",{top:g.offset().top+c,force:e||null})},100)):DISQUS.api.call("posts/getContext.json",{method:"GET",data:{post:d},success:function(b){b=_.filter(b.response,function(d){return d.thread==f.thread.get("id")});b.length!==0&&(_.each(b,function(d){f.thread.posts.add(new a.UniqueModel(a.Post,d))}),f.on("domReflow",function ia(){f.off("domReflow",
ia);f.scrollToPost(d,c,e)}))}})},updateThreadSessionData:function(d){d&&(d.get("thread")&&this.thread.set(d.get("thread")),(d=d.get("votes"))&&typeof d==="object"&&_.each(d,function(d,a){var b=this.posts.get(a);b&&b.set("userScore",d)},this))},initDashboard:function(){var d=$("#main-nav [data-nav=dashboard]");if(this.session.isAnonymous())return d.hide();d.show();this.notificationCount=new I({el:d.find("[data-role=notification-count]")[0],session:this.session});this.notificationCount.render();this.session.notifications.on("markRead",
this.notificationCount.remove,this.notificationCount);this.dashboard=new S({el:"#dashboard",session:this.session,notifications:this.notifications});this.dashboard.render()},initCommunity:function(){this.community=new T({el:document.getElementById("community"),forum:this.forum})},initReactions:function(){this.reactions=new ja({el:$("#reaction-list")[0],collection:this.thread.reactions,thread:this.thread,session:this.session});this.forum.get("settings").hasReactions&&$("#global-nav").length===0&&(this.thread.reactions.on("reset",
function(){$("#reactions").show()}),this.thread.reactions.fetch())},_getLogoutUrl:function(){return this.config.sso&&this.session.user.get("user_type")==="sso"?this.config.sso.logout:DISQUS.urls.logout},initUserMenu:function(){var d=this.userMenu=new E({el:this.$el.find("[data-role=logout]")[0],session:this.session,thread:this.thread,showLogin:!this.forum.get("settings").ssoRequired,logoutUrl:this._getLogoutUrl(),referrerUrl:this.config.referrer});this.session.on("change:id",function(){d.logoutUrl=
this._getLogoutUrl();d.render()},this);this.thread.on("change:isClosed",this.render,this);d.render()},initThreadShareMenu:function(){this.threadShareMenu=new w({el:$("#thread-share-menu")[0],model:this.thread})},initDiscovery:function(d){function a(b){if(!i){if(!e.switches.length)return void e.switches.on("reset",function ka(){a(b);e.switches.off("reset",ka)});if(e.switches.enabled("discovery_next"))try{DISQUS.runThemeScript&&(DISQUS.runThemeScript(),i=!0);var c="discovery";z.indexOf("midway-top")===
0&&(c+="-top");z=="midway-4x2-top-conditional"&&f.isAnonymous()&&e.thread.posts.length>5&&h.extract(e,"initialData.forum.settings.discoveryMax")&&(c+="-top");DISQUS.discovery.init(_.extend({},e.config,{isExperiment:!!d.isExperiment,variant:z,thread:e.initialData.thread,forum:e.initialData.forum,switches:e.switches,mainEl:document.getElementById(c),session:f}),b)}catch(s){return void Raven.captureMessage({name:"There is a bug in Discovery JS. Variant: "+z,message:s})}}}function b(d){d.on("allSubviewsRendered",
e.updateDom,e);d.on("resize",e.updateDom,e);e.updateDom(function(){d.render()})}var e=this,f=e.session;if(!e.states.templateReady)return void e.on("templateReady",function ha(){e.initDiscovery(d);e.off("templateReady",ha)});var g=c(e.config.parentWindowHash);g&&(d={js:d.js.replace(RegExp(d.name+"\\.js$"),g+".js"),css:d.css.replace(RegExp(d.name+"\\.css$"),g+".css"),name:g,isExperiment:!1});var z,i=!1;z=d.name;curl(["css!"+DISQUS.serialize(d.css,null,DISQUS.debug),"js!"+DISQUS.serialize(d.js,null,
DISQUS.debug)],function(){a(b)});e.initDiscovery=function(){}},toggleLoadMorePosts:function(){var d=this.$el.find("#posts [data-role=more]");this.updateDom(function(){d[this.thread.posts.cursor.hasNext?"show":"hide"]()},this)},toggleLoadMoreReactions:function(){var d=this.$el.find("#reactions [data-role=more]");this.updateDom(function(){d[this.thread.reactions.cursor.hasNext?"show":"hide"]()},this)},isHttps:function(){return window.location.protocol==="https:"},isRealtimeEnabled:function(){return this.switches.enabled("next_realtime")&&
!this.thread.get("isClosed")&&!this.isHttps()},poll:function(){function d(d){var d=d.message_body,c=b.thread;if(!b.thread.get("hasStreaming")||!b.states.streamingPaused){if(!d.id)return void DISQUS.logError("RT: no post ID");if(!d.author||!d.author.id)return void DISQUS.logError("RT: no author or author ID");if(!d.author.name||!d.author.email_md5)return void DISQUS.logError("RT: no author name or email hash");if(!d.post||!d.post.message)return void DISQUS.logError("RT: no post message");if(c.posts.get(d.id)||
c.queue.get(d.id))return void DISQUS.log("RT: duplicate",d.id);if(d.type!=="approved")return void DISQUS.log("RT: unnaproved",d.id);b.thread.incrementPostCount(1);var e=d.post.parent_post.id;if((e=e!=="0"?e:null)&&!c.posts.get(e)&&!c.queue.get(e))return void DISQUS.log("RT: parent is not on this page",d.id);var f=d.author.id,s=c.users.get(f);s||(s=new a.UniqueModel(a.User,{id:f,name:d.author.name,emailHash:d.author.email_md5,isAnonymous:d.author.id==="0"}),d.author.avatar&&s.set("avatar",{cache:d.author.avatar,
permalink:d.author.avatar}),c.users.add(s));c.queue.add({id:d.id,userId:s.get("id"),parentId:e,message:d.post.message})}}var b=this,c=b.switches.enabled("next_realtime_overlap");if(this.isRealtimeEnabled()){if(c){if(b.realtimePool!==null)return}else{if(b.states.pollingRunning)return;b.states.pollingRunning=!0}b.switches.enabled("next_realtime_indicators")&&(b.states.realtimeIndicatorsCreated||b.initRealtime());var e=DISQUS.urls.realertime+"/api/2/thread/"+b.thread.id,g=function(c){_.each(c,function(c){DISQUS.log("RT: new message:",
c.message_type);switch(c.message_type){case "Post":d(c);break;case "Vote":var e=c.message_body;if(e.id&&e.vote){var f=b.thread.posts.get(e.vote.recipient_post_id);!(b.session.user.id&&e.vote.voter_id===b.session.user.id)&&f&&(c=f.votes.get(e.id),c||(c=new a.Vote({id:e.id}),f.votes.add(c)),e=f._vote(e.vote.vote,c.get("score")),e!==0&&c.set("score",e))}break;case "ThreadVote":e=c.message_body;f=b.thread;e.id&&e.vote&&!(b.session.user.id&&e.vote.voter_id==b.session.user.id)&&(c=f.votes.get(e.id),c||
(c=new a.ThreadVote({id:e.id}),f.votes.add(c)),e=f._vote(e.vote.vote,c.get("score")),e!==0&&c.set("score",e));break;case "IsTyping":e=c.message_body,f=b.thread,e.thread_id==f.id&&e.post.parent_post.id&&(e=f.posts.get(e.post.parent_post.id))&&(e.usersTyping.get(c.firehose_id)||(!(e.usersTyping.count()<=0)||c.typing)&&e.usersTyping.add(new a.TypingUser({id:c.firehose_id,typing:c.typing})))}})};if(c)b.realtimePool=new f.Pool(e),b.realtimePool.on("progress",g),_.defer(function(){b.realtimePool.run()});
else{var h=new f.Firehose(e,"hose");h.on("success",function(){b.states.pollingRunning=!1;o=1;b.poll()});h.on("error",function(){o<=120&&(o*=2);b.states.pollingRunning=!1;_.delay(_.bind(b.poll,b),o*1E3)});h.on("progress",g);_.defer(function(){h.run()})}}},renderBindings:function(){var d=this;_.each(arguments,function(a){var b=a[2];a[0].bind(a[1],function(){var a=arguments;d.states.templateReady?b.apply(d,a):d.bind("templateReady",function(){b.apply(d,a)})})})},updateDom:function(){var d=_.debounce(function(){this.resize();
this.trigger("domReflow")},0);return function(a,b){a&&a.call(b);d.call(this)}}(),audienceSyncToggle:function(){var d;this.needsAudienceSyncAuth()&&(d=DISQUS.interpolate(i("In order to comment, you must %(connectWith)s."),{connectWith:DISQUS.interpolate('<a href="#" data-action="audiencesync">'+i("connect with %(forumName)s")+"</a>",{forumName:this.forum.get("name")})}),this.alert(d,{safe:!0}))},initThreadVotes:_.debounce(function(){var d;this.threadVotes&&this.threadVotes.remove();this.threadVotes=
d=new A({thread:this.thread,session:this.session});d.on("vote:up",_.bind(this.trigger,this,"uiAction:threadUpvote"));d.on("vote:down",_.bind(this.trigger,this,"uiAction:threadDownvote"));d.render();this.updateDom(function(){$("#thread-votes").append(d.el)})},200),initThreadSubscribe:function(){this.threadSubscribeButton=new x({session:this.session,thread:this.thread,el:$("#thread-subscribe-button")[0]})},renderStreamingToggle:function(){var d=this;if(d.thread.get("hasStreaming")&&DISQUS.blocks.realtimeToggleButton){var a=
$(DISQUS.renderBlock("realtimeToggleButton"));$(a).bind("click",g(function(){d.toggleStreamingRealtime()}));d.updateDom(function(){$("#realtime-toggle").empty();$("#realtime-toggle").append(a[0])})}},toggleStreamingRealtime:function(){var d=$("#realtime-toggle a.btn");this.states.streamingPaused?(this.states.streamingPaused=!1,d.addClass("pause")):(this.states.streamingPaused=!0,d.removeClass("pause"))},updateThreadVotes:function(){$("#thread-votes [data-role=like-count]").text(this.thread.get("likes"))},
updateThreadUserScore:function(){var d=this.thread.get("userScore"),a=$("#thread-votes [data-role=vote-button]");a.removeClass("upvoted").removeClass("downvoted");d>0?a.addClass("upvoted"):d<0&&a.addClass("downvoted")},updatePostCount:function(){$("#post-count").html(DISQUS.renderBlock("postCount",{count:this.thread.get("posts")}))},swapMain:function(d){var a=this,c=this.$el.find("#main-nav [data-nav=conversation]").parent("li");d!=="conversation"?c.attr("data-dropdown","disabled"):_.defer(function(){c.attr("data-dropdown",
"enabled")});a.updateDom(function(){a.states.realtimeIndicatorsCreated&&d!="conversation"&&(b.sendHostMessage("realtime.hideNorth"),b.sendHostMessage("realtime.hideSouth"));var c=a[d];c&&!c.isRendered&&(a.freeze(!0),c.on("render:all",_.once(function(){a.freeze(!1)})),c.show());a.$el.find("[data-role=main]").hide();a.$el.find("[data-role=main]#"+d).show();a.prevSection=a.currentSection;a.currentSection=d});a.trigger("uiAction:navigate",d)},returnToConversation:function(){this.mainNav.navTo("conversation");
var d=this.conversationPosition,a=d&&d.pageOffset;a&&this.updateDom(function(){_.delay(function(){b.sendHostMessage("scrollTo",{top:a,relative:"window",force:!0})},100)},this)},setupNavigation:function(){var d=this;d.globalNav=new U({el:d.$el.find("#global-nav")[0]});d.mainNav=new U({el:d.$el.find("#main-nav")[0]});d.globalNav.on("nav",function(a){d.updateDom(function(){var b=d.$el.find("#form"),c=d.$el.find("#main-nav");switch(a){case "conversation":b.show();c.show();d.swapMain(d.prevSection||a);
break;case "reactions":b.hide(),c.hide(),d.swapMain(a)}})});d.mainNav.on("nav",function(a){d.updateDom(function(){d.swapMain(a)})})},renderLayout:function(){function d(d){return function(c){c.preventDefault();var e=$(c.currentTarget);e.addClass("busy");a.thread[d].more({success:function(){e.removeClass("busy")},error:function(){e.removeClass("busy")}});b.sendHostMessage([d,".paginate"].join(""))}}var a=this;a.setElement($(DISQUS.renderBlock("layout",{thread:_.extend(a.thread.toJSON(),{showReactions:a.forum.get("settings").hasReactions}),
order:a.thread.posts.order,showFooter:!0})).appendTo("body"));var c=a.$el;a.setupNavigation();_.each(["posts","reactions"],function(a){c.delegate("[data-action=more-"+a+"]","click",d(a))});a.resize();b.sendHostMessage("mainViewRendered")},renderForm:function(){if(this.thread.get("isClosed"))return void this.alert(i("Comments for this thread are now closed."));if(!this.session.get("canReply"))return void this.session.on("change:id",function s(){this.session.off("change:id",s);this.renderForm()},this);
var d=new v({thread:this.thread,session:this.session});d.render();this.updateDom(function(){$("#form").prepend(d.el);d.resize()},this);this.resize()},toggleNoPosts:function(){this.updateDom(function(){var d=this.thread.posts.models;$("#no-posts")[d.length?"hide":"show"]();$("#post-list").removeClass("loading")},this)},handleShowProfile:g(function(d){d=$(d.currentTarget).attr("data-user");(d=a.UniqueModel.get(a.User,d))&&this.showProfile(d)}),handleSort:g(function(d){var a=$(d.currentTarget),d=a.closest("li"),
a=a.attr("data-sort");d.siblings().removeClass("selected");d.addClass("selected");this.thread.posts.order=a;this.thread.posts.fetch();$("#conversation-menu").removeClass("open");$("#posts [data-role=more]").hide();$("#post-list").addClass("loading").empty()}),closeThread:g(function(){this.thread.close({success:_.bind(b.sendHostMessage,b,"reset"),error:_.bind(this.alert,this,"An error occurred while closing thread. Please try again.","error")})}),openThread:g(function(){this.thread.open({success:_.bind(b.sendHostMessage,
b,"reset"),error:_.bind(this.alert,this,"An error occurred while opening thread. Please try again.","error")})}),redrawPosts:function(){var d=this;d.postViews={};d.addPosts(d.thread.posts,{clearDom:!0});_.each(v.open,function(a,b){var c=d.postViews[b];c&&(c.toggleReply(),c.reply.textarea.set(a.textarea.get()))})},addPosts:_.decorate(Backbone.collectionAddNormalizer(j.PostCollection,a.Post),function(d,a,b){var c=this;if(d.length){var e=[];_.each(d,function(d){var a,u=d.get("parent");u&&(a=(u=c.thread.posts.get(u))&&
c.postViews[u.cid]);a=new H({parent:a,model:d,thread:c.thread,session:c.session,created:b.created});c.postViews[d.cid]=a;a.render();d.get("isRealtime")&&c.removeOldPosts.call(c);u?c.postViews[u.cid].attachChild(a):e.push(a.el)});e.length&&c.updateDom(function(){var a=$("#post-list");b.clearDom&&a.empty();$("#post-list").removeClass("loading");b.created||!d[0].id||d[0].get("isRealtime")?a.prepend(e):a.append(e);c.trigger("postsRendered")})}}),showProfile:function(d){this.profile&&this.profile.remove();
var a=this.profile=new K({user:d,session:this.session});this.freeze(!0);this.updateDom(function(){this.mainNav.clear();$("#profile").empty().append(a.el);this.swapMain("profile");a.show()},this);a.bind("close",function(){this.returnToConversation();this.updateDom(function(){a.remove()},this)},this);a.bind("render:all",_.once(function(){this.freeze(!1)}),this);b.sendHostMessage("scrollTo",{top:0})},removePost:function(d){var a=this.postViews[d.cid];a&&(a.remove(),delete this.postViews[d.cid])},removeOldPosts:_.debounce(function(){if(this.switches&&
this.switches.enabled("next_realtime_cap")){var d=_.size(this.postViews)-this.STREAMING_MAX_VISIBLE;if(!(d<=0))for(var a=this.thread.posts.sortBy(function(d){return moment(d.get("createdAt")).valueOf()}),b,c=0,e=0;c<a.length&&e<=d;c++)if((b=this.postViews[a[c].cid])&&b.childrenNode.children().length===0)this.thread.posts.remove(a[c]),e+=1}},500),resize:function(){var d=$("body").height();if(!this._frozen||!(this._lastHeight&&this._lastHeight>d))this._lastHeight=d,b.sendHostMessage("resize",{height:d})},
freeze:function(d){this._frozen=!!d;this._frozen===!1&&this.resize()},getPostView:function(d){return this.postViews[d]},windowOpen:function(d,a,b){var c=this._commonWin;h.isWindowClosed(c)?this._commonWin=window.open(d,"_blank","width="+a+",height="+b):(c.resizeTo(a,b),c.location.href=d);return this._commonWin},windowClose:function(){var d=this._commonWin;h.isWindowClosed(d)||h.attempt(d.close,d);this._commonWin=null},authenticate:function(d){var a=this.authServices[d];if(!a)return void DISQUS.log("Unknown authentication service: "+
d);if(_.isFunction(a))return a.call(this);this.session.on("change:id",this.postAuthHandler,this);this.windowOpen(a.url,a.width,a.height)},postAuthHandler:function(){this.session.off("change:id",this.postAuthHandler,this);this.needsAudienceSyncAuth()?this.audienceSync():this.windowClose()},handleAuth:g(function(d){this.authenticate(e(d.target,"auth"))}),authServices:{disqus:{url:DISQUS.urls.login,width:460,height:355},twitter:{url:DISQUS.urls.oauth.twitter,width:650,height:680},facebook:{url:DISQUS.urls.oauth.facebook,
width:550,height:300},google:{url:DISQUS.urls.oauth.google,width:650,height:440},sso:function(){var d=parseInt(this.config.sso.width||"800",10),a=parseInt(this.config.sso.height||"500",10),c=window.open(this.config.sso.url,"_blank","width="+d+",height="+a);(function J(){h.isWindowClosed(c)?b.sendHostMessage("reload"):_.delay(J,500)})()}},verifyEmail:g(function(){var d=DISQUS.serialize(DISQUS.urls.verifyEmail,{f:this.forum.id});window.open(d,"_blank","width=460,height=355")}),needsAudienceSyncAuth:function(){return this.forum.get("settings").audienceSyncEnabled&&
this.session.isRegistered()&&!this.session.get("audienceSyncVerified")},getAudienceSyncUrl:_.memoize(function(){return DISQUS.serialize(DISQUS.urls.authorize,{client_id:this.config.apiKey,scope:"read",response_type:"token",audiencesync:"1"})}),audienceSync:g(function(){this.windowOpen(this.getAudienceSyncUrl(),460,355)})});m.getInstance=function(){return n};_.extend(m.prototype,k);_.extend(m.prototype,r);var l=Backbone.View.extend({updateDom:function(d,a){var b=m.getInstance();b&&b.initialized?b.updateDom(d,
a):_.isFunction(d)&&d.call(a)},resize:function(){var d=m.getInstance();d&&d.initialized&&d.resize()}}),w=l.extend({events:{"click [data-action=share:twitter]":"_onShare","click [data-action=share:facebook]":"_onShare"},_onShare:g(function(d){if((d=e(d.target,"share"))&&this.sharers[d])n.trigger("uiAction:threadShare",d),this.share(d)}),_shareUrl:function(){return this.model.url()}});_.extend(w.prototype,k);var A=l.extend({initialize:function(d){_.extend(this,d)},events:{"click [data-action=upvote]":"upvote"},
render:function(){this.setElement($(DISQUS.renderBlock("threadVotes",{thread:this.thread.toJSON(),user:this.session.toJSON()})))},upvote:g(function(){this.vote(1)}),vote:function(d){this.trigger(d===1?"vote:up":"vote:down");var a=this.thread.get("userScore")===d,b;this.thread.vote(a?0:d);a||(b=this.$el.find(".dropdown"),_.defer(function(){b.addClass("open")}))},remove:function(){this.off();Backbone.View.prototype.remove.call(this)}}),x=l.extend({events:{"click [data-action=subscribe]":"subscribe",
"keydown #thread-subscribe-email":"subscribeKeypress"},initialize:function(d){this.thread=d.thread;this.session=d.session;this.thread.on("change:userSubscription",this.updateStatus,this);this.updateStatus()},updateStatus:function(){this.thread.get("userSubscription")?this.$el.addClass("subscribed"):this.$el.removeClass("subscribed")},subscribe:g(function(){var d=this.thread.get("userSubscription");this.session.isAnonymous()&&!d?this.showForm():this.thread.subscribe(!d)}),showForm:function(){function d(b){b.target.id!==
"thread-subscribe-email"&&($(document.body).unbind("click",d),a.hideForm())}var a=this;_.defer(function(){$(document.body).bind("click",d)});a.$el.addClass("show-form").find("input")[0].focus()},hideForm:function(){this.$el.removeClass("show-form").find("input")[0].blur()},subscribeKeypress:function(d){var a=this.$el.find("input");a.removeClass("alert error");if(d.key==="Esc"||d.keyCode===27)return void this.hideForm();if(!(d.key!=="Enter"&&d.keyCode!==13))d=d.target.value,h.validateEmail(d)?(this.hideForm(),
this.thread.subscribe(!0,d)):a.addClass("alert error")}}),E=l.extend({initialize:function(d){_.extend(this,d)},render:function(){var d=DISQUS.renderBlock("userMenu",{user:this.session.toJSON(),thread:this.thread.toJSON(),logoutUrl:this.logoutUrl,showLogin:this.showLogin,feedbackUrl:this.getSurveyMonkeyUrl()});this.updateDom(function(){this.$el.html(d)},this)},getSurveyMonkeyUrl:function(){var d=this.referrerUrl,a=this.session.user.id;return"https://www.surveymonkey.com/s/5RBPTTZ?c="+encodeURIComponent((a?
[a,d]:[d]).join(";"))}}),y=new QueuedStorage(Modernizr.localstorage?window.localStorage:DISQUS.lounge.utils.hashStorage,5,"drafts.queue"),C=function(d){if(!d)throw Error("Cannot instantinate MediaStore without a valid storageKey!");this._storageKey=d;this._store=Modernizr.localstorage?window.localStorage:DISQUS.lounge.utils.hashStorage};_.extend(C.prototype,{getItems:function(){var d=this._store.getItem(this._storageKey);return d&&q.parse(d)||{}},clear:function(){this._store.removeItem(this._storageKey)},
getItem:function(d){return this.getItems()[d]},setItem:function(d,a){var b=this.getItems();b[d]=a;this._store.setItem(this._storageKey,q.stringify(b));return a},removeItem:function(d){var a=this.getItems();if(d in a)return delete a[d],this._store.setItem(this._storageKey,q.stringify(a)),!0;return!1}});var p=l.extend({events:function(){var d={"click [data-action=attach]":"_attachMedia"};window.FormData&&_.extend(d,{dragover:"_dragOn",dragenter:"_dragOn",dragleave:"_dragOff",dragexit:"_dragOff",drop:"_drop"});
return d},initialize:function(d){this.owner=d.owner;this.parent=d.parent;this.url=d.url},setElement:function(){var d=l.prototype.setElement.apply(this,arguments);this.$dragPlaceholder=this.$el.find("[data-role=drag-drop-placeholder]");this.$mediaSelector&&this.$mediaSelector.off();this.$mediaSelector=this.$el.find("input[type=file][data-role=media-upload]");this.$mediaSelector.on("change",_.bind(this._selectorChange,this));return d},_toggleDragPlaceholder:_.throttle(function(d){d?this.$dragPlaceholder.show():
this.$dragPlaceholder.hide()},50),_selectorChange:function(d){this.uploadMedia(d.target.files);if(n.switches.enabled("next_dragdrop_nag")&&d.target.files&&Modernizr.localstorage&&!window.localStorage.getItem("usedDragDrop"))this.owner.alert(i("Did you know you can drag and drop images too? Try it now: drag images below.")).on("dismiss",function(){window.localStorage.setItem("usedDragDrop","1")})},_dragOn:function(d){d.stop();this._toggleDragPlaceholder(!0);this.owner.owner.$el.addClass("expanded")},
_dragOff:function(d){d.stop();this._toggleDragPlaceholder(!1)},_drop:function(d){d.stop();window.localStorage.setItem("usedDragDrop","1");this._toggleDragPlaceholder(!1);this.uploadMedia(d.dataTransfer.files)},_attachMedia:function(d){d.stop();this.$mediaSelector[0].click()},_uploadMediaModern:function(d){for(var a=this,b=new FormData,c=0,e=d[c];e;e=d[++c])e.type.match(/^image\//)&&b.append("attachment",e);b.append("json","true");this.parent&&b.append("id",this.parent.id);var f=h.makeCORSRequest("POST",
this.url,function(){if(!(f.readyState!==void 0&&(f.readyState!==4||f.status!==200))){var d=q.parse(f.responseText);d.success?a.owner.addMedia(d.media):a.owner.alert(d.message,"error")}});f.withCredentials=!0;f.send(b)},_uploadMediaLegacy:function(){var d=this,a=document.createElement("iframe"),b=document.createElement("form"),c=this.$mediaSelector[0];$(c).off();var e=$(c.cloneNode(!0));c.parentNode.replaceChild(e[0],c);e.on("change",_.bind(this._selectorChange,this));this.$mediaSelector=e;a.style.display=
"none";a.name="uploadFrame"+ +new Date;b.style.display="none";b.target=a.name;b.action=this.url;b.method="post";b.appendChild(a);b.appendChild(c);if(this.parent)a=document.createElement("input"),a.type="hidden",a.name="id",a.value=this.parent.id,b.appendChild(a);b.enctype="multipart/form-data";b.encoding="multipart/form-data";var f=function(a){a=q.parse(a.data);a.name==="upload"&&($(b).remove(),$(window).off("message",f),a.data.success?d.owner.addMedia(a.data.media):d.owner.alert(a.data.message,"error"))};
$(window).on("message",f);this.updateDom(function(){this.$el.append(b);b.submit()},this)},uploadMedia:function(d){this.uploadMedia=this["_uploadMedia"+(window.FormData?"Modern":"Legacy")];return this.uploadMedia(d)}}),fa=l.extend({events:{"click [data-action=detach]":"_detachMedia","click ul[data-role=media-preview-list] [data-action=preview]":"_preview"},initialize:function(d){this.alert=_.bind(d.owner.alert,d.owner);this.owner=d.owner;this.parent=d.parent;this.urls=d.urls;this.uploader=new p({owner:this,
parent:this.parent,url:this.urls.add})},setElement:function(){var d=l.prototype.setElement.apply(this,arguments);this.$list=this.$el.find("ul[data-role=media-preview-list]");this.$expandedArea=this.$el.find("[data-role=media-preview-expanded]");this.expandedImg=this.$el.find("img[data-role=media-preview-expanded-image]")[0];return d},clear:function(){this.$el.addClass("empty");this.$list.empty();this._hidePreview();this.owner.mediaStore&&this.owner.mediaStore.clear()},_$oldPreview:null,_preview:function(d){d.stop();
var a=this.$expandedArea,b=this.expandedImg,c=d.currentTarget.href,e=$(d.currentTarget).closest("li");b.src!==c?this.updateDom(function(){b.src=c;a.removeClass("empty");e.addClass("active");this._$oldPreview&&this._$oldPreview.removeClass("active");this._$oldPreview=e},this):this._hidePreview()},_hidePreview:function(){this.updateDom(function(){this.$expandedArea.addClass("empty");if(this._$oldPreview)this._$oldPreview.removeClass("active"),this._$oldPreview=null;this.expandedImg.src=null},this)},
_detachMedia:function(d){d.stop();this.updateDom(function(){this.removeMedia($(d.target).closest("li"))},this)},addMedia:function(d){var a=$(DISQUS.renderBlock("mediaUpload",{media:d}));this.owner.mediaStore.setItem(d.location,d);a.attr("data-media-id",d.location);this.updateDom(function(){this.$list.append(a);this.$el.removeClass("empty")},this)},removeMedia:function(d){var a=this.owner.mediaStore.getItem(d.attr("data-media-id")),b=this._$oldPreview;if(a){b&&d[0]===b[0]&&this._hidePreview();b={media:q.stringify(a)};
if(this.parent)b.id=this.parent.id;(new Image).src=DISQUS.serialize(this.urls.remove,b,!0);this.owner.mediaStore.removeItem(a.location);this.updateDom(function(){d.remove();this.$list.children().length||this.$el.addClass("empty")},this)}}}),v=l.extend({events:{"click [data-nav]":"showAuthSection","click [name=author-register]":"expandRegister"},initialize:function(d){this.session=d.session;this.parent=d.parent;this.thread=d.thread;this.parentView=d.parentView;this.thread.bind("change:id",function(){this.restoreDraft();
if(this.thread.forum.get("settings").allowMedia)this.mediaStore=new C(this.storageKey("media"))},this);this.session.on("change:id",this.redraw,this);this.parent&&(v.open[this.parent.cid]=this);this.textarea=Modernizr.contenteditable&&!DISQUS.browser.mobile&&(!window.opera||!window.opera.version)?new B({thread:this.thread}):new D;if(this.thread.forum.get("settings").allowMedia){if(d=this.storageKey("media"))this.mediaStore=new C(d);this.mediaUploads=new fa({owner:this,parent:this.parent,urls:{add:this.thread.get("uploadAdd"),
remove:this.thread.get("uploadRemove")}})}},storageKey:function(d){if(!this.thread.id)return null;return[d||"drafts","thread",this.thread.id,"parent",this.parent?this.parent.id:0].join(":")},saveDraft:function(){this.storageKey()!==null&&y.setItem(this.storageKey(),q.stringify([this.textarea.get(),(new Date).getTime()]))},getDraft:function(){if(this.storageKey()===null)return null;var d=y.getItem(this.storageKey());if(!d)return null;d=q.parse(d);if(d[1]+86400>(new Date).getTime())return d[0];y.removeItem(this.storageKey());
return null},restoreDraft:function(){this.textarea.set(this.getDraft())},updateAvatar:function(){this.$el.find("[data-role=user-avatar]").attr("src",this.session.user.get("avatar").cache)},expandGuestForm:function(){this.$el.find("[data-role=guest-details]").addClass("expanded")},expandRegister:function(){this.$el.toggleClass("register")},redraw:function(){var d=this.$el.hasClass("expanded"),a=this.el,b=this.$el.find("textarea").val();this.render();this.$el.find("textarea").val(b);d&&this.$el.addClass("expanded");
$(a).parent().length!==0&&this.updateDom(function(){a.parentNode.replaceChild(this.el,a)},this)},render:function(){var d=this,a=d.getDraft()||"";this.setElement($(DISQUS.renderBlock("form",{message:a,parent:d.parent?d.parent.toJSON():null,user:d.session.toJSON(),mediaList:this.mediaStore?_.values(this.mediaStore.getItems()):[],allowAnonPost:d.thread.forum.get("settings").allowAnonPost,allowMedia:d.thread.forum.get("settings").allowMedia})));this.$el.find("form").bind("submit",_.bind(this.submitForm,
this));var b=this.textarea;b.setElement(d.$el.find("textarea")[0]);b.render();b.bind("keychange",_.debounce(this.saveDraft,500),this);b.$el.bind("focus",function(){d.$el.addClass("expanded focus");_.delay(_.bind(d.resize,d),200)});b.$el.bind("blur",function(){b.get()||d.$el.removeClass("focus")});this.mediaUploads&&(this.mediaUploads.setElement(this.$el.find("[data-role=media-preview]")[0]),this.mediaUploads.uploader.setElement(this.$el.find("[data-role=textarea]")[0]));d.$el.find("input[name=author-name]").bind("focus",
function(){d.expandGuestForm()});d.typingStart();d.session.get("mustVerifyEmail")&&d._alertMustVerify()},resize:function(){this.textarea.resize()},showAuthSection:function(d){d&&d.preventDefault&&d.preventDefault();var a=d.currentTarget.getAttribute("data-nav");this.updateDom(function(){var d=this.$el.find("[data-nav]");_.each(d,function(d){$(d.parentNode).removeClass("active")});this.$el.find("[data-nav="+a+"]").parents("*").addClass("active");this.$el.find("section").hide();this.$el.find("[data-tab="+
a+"]").show()},this)},focus:function(){this.textarea.focus()},clear:function(){var d=this;d.textarea.clear();d.$el.removeClass("expanded");d.mediaUploads&&d.mediaUploads.clear();_.delay(function(){d.resize()},200);d.parent?d.$el.hide():d.$el.removeClass("expanded");this.storageKey()&&y.removeItem(this.storageKey())},restore:function(d){var a=this;a.textarea.set(d.get("raw_message"));_.delay(function(){a.resize()},200);a.parent&&a.$el.show()},_alertMustVerify:function(a){this.alert(DISQUS.interpolate(i("%(forumName)s requires you to %(verifyEmail)s before posting"),
{forumName:this.thread.forum.get("name"),verifyEmail:'<a href="#" data-action="verify-email">'+i("verify your email address")+"</a>"}),{safe:!0,type:a?"error":"warn"})},submitForm:function(a){function b(a){a=a.response;/Invalid email address/i.test(a)?c.alert(i("Invalid email address."),"error"):/Missing required argument\: \'email\'/i.test(a)?c.alert(i("Please enter an email address."),"error"):/Unable to create user/i.test(a)?c.alert(i("That email address is already registered with a Disqus account. Log in or enter another email."),
"alert"):c.alert(a,"error")}var c=this;a&&a.preventDefault&&a.preventDefault();if(this._alert)this._alert.remove(),this._alert=null;a=c.$el.find("input[name=author-register]");a=a.length&&a[0].checked;if(c.session.isAnonymous()&&a)return c.session.register({name:c.$el.find("input[name=author-name]").val(),email:c.$el.find("input[name=author-email]").val()},{error:b}),null;return c.createPost()},createPost:function(){var d=this,b={thread:d.thread.id,depth:d.parent?d.parent.get("depth")+1:0,parent:d.parent?
d.parent.id:null,raw_message:d.textarea.get()};d.session.isRegistered()?b.author_id=d.session.user.id:_.extend(b,{author_name:d.$el.find("input[name=author-name]").val(),author_email:d.$el.find("input[name=author-email]").val()});var c=new DISQUS.lounge.models.UniqueModel(DISQUS.lounge.models.Post);if(c.set(b,{error:function(a,b){d.alert(b,"error")}})){var e=null,f=function(a,b){if(b.code===19){if(e)return e.reload();e=new N;e.render();var f=n.getPostView(c.cid);f.el.parentNode.insertBefore(e.el,
f.el);e.start();e.bind("submitted",function(){c.save({recaptcha_challenge_field:e.getChallenge(),recaptcha_response_field:e.getResponse()},{success:function(){e.remove()}})})}else b.code===12&&/verify/.test(b.response)?d._alertMustVerify(!0):_.isString(b.response)&&d.alert(b.response,"error"),d.thread.posts.remove(c),d.restore(c),d.thread.incrementPostCount(-1)};c.on("error",f);c.on("sync",function z(){d.thread.trigger("create",c);c.off("error",f);c.off("sync",z)});c.save(b);c.author=d.session.isRegistered()?
d.session.user:new a.UniqueModel(a.User,{id:md5(b.author_email),name:b.author_name,email:b.author_email});d.thread.posts.add(c,{created:!0});d.clear();d.trigger("submitted");d.thread.incrementPostCount(1);n.trigger("uiAction:createPost",c);return c}},remove:function(){this.updateDom(function(){this.$el.remove()},this);this.parent&&(delete v.open[this.parent.cid],this.typingStop())},toggle:function(){this.$el.toggle();this.isOpen()?this.typingStart():this.typingStop()},isOpen:function(){return this.el.style.display!==
"none"},typingStart:function(){var a=this;if(a.parent){var b=m.getInstance();b.switches&&b.switches.enabled("next_realtime")&&_.delay(function(){var b=DISQUS.urls.realertime+"/api/2/typing/",c;h.attempt(function(){c=h.makeCORSRequest("POST",b)});if(c===null)return void DISQUS.log("CORS is not supported by this browser.");var e=q.stringify({typing:!0,forum_url:a.thread.get("forum"),thread_id:a.thread.get("id"),user_id:a.session.user.id||0,parent_post_id:a.parent.get("id")});h.attempt(function(){c.send(e)})},
500)}},typingStop:function(){var a=this;if(a.parent){var b=m.getInstance();b.switches&&b.switches.enabled("next_realtime")&&_.delay(function(){var b=DISQUS.urls.realertime+"/api/2/typing/",c;h.attempt(function(){c=h.makeCORSRequest("POST",b)});if(c===null)return void DISQUS.log("CORS is not supported by this browser.");var e=q.stringify({typing:!1,forum_url:a.thread.get("forum"),thread_id:a.thread.get("id"),user_id:a.session.user.id||0,parent_post_id:a.parent.get("id")});h.attempt(function(){c.send(e)})},
500)}}});_.extend(v.prototype,r);v.open=v.open||{};var M=l.extend({initialize:function(a){this.post=a.post;this.textarea=new D},render:function(){this.setElement($(DISQUS.renderBlock("edit",{post:this.post.toJSON()})));this.$el.find("form").bind("submit",_.bind(this.submitForm,this));var a=this.textarea;a.setElement(this.$el.find("textarea")[0]);a.render()},resize:function(){this.textarea.resize()},submitForm:function(a){a&&a.preventDefault()&&a.preventDefault();var a={raw_message:this.textarea.get()},
b=this.post.validate(a);if(b!==void 0)return alert(b);this.trigger("submitted");this.post.save(a,{success:function(){}})},remove:function(){this.updateDom(function(){this.$el.remove()},this)}}),H=l.extend({initialize:function(a){this.thread=a.thread;this.session=a.session;this.created=!!a.created;this.model.bind("destroy",this.removeAsDeleted,this);this.model.bind("spam",this.removeAsDeleted,this);this.model.bind("change:message",this.stopLoading,this);this.model.bind("change:points",this.updatePoints,
this);this.model.bind("change:userScore",this.updateVotes,this);this.model.usersTyping.bind("add remove reset",this.updateTypingCount,this);this.session.on("change:id",this.updateEditHide,this);this.session.on("change:id",this.updateFooter,this);this.session.on("change:id",this.updateMenu,this);this.session.on("change:id",this.updateVotes,this);this.model.bind("change",function(){var a=this.model.changedAttributes();(a.id||a.message)&&this.redraw()},this);this.edit=this.reply=null;this.parent=a.parent;
this.trackPosition=!1;m.getInstance().on("domReflow",function(){if(this.trackPosition){var a=this.contentNode;this.offset=a.offset();this.dim=a.dim()}else this.offset={top:-1,height:-1},this.dim={height:-1,width:-1}},this)},updateTypingCount:function(){this.typingUserView&&this.typingUserView.render()},stopLoading:function(){this.contentNode.find(".loading").removeClass("loading")},updateRelativeTime:function(){this.contentNode.find("[data-role=relative-time]").text(this.model.getRelativeCreatedAt())},
updateVotes:function(){var a=this.model,b=this.contentNode.find("[data-role=voting]"),c=DISQUS.renderBlock("postVotes",{session:{id:this.session.user.id},post:{userScore:a.get("userScore"),points:a.get("points"),likes:a.get("likes"),dislikes:a.get("dislikes")}});this.updateDom(function(){b.html(c)})},updateEditHide:function(){var a=this.contentNode.find("[data-role=edit-hide]"),b=DISQUS.renderBlock("postEditHide",{post:{author:{id:this.model.author.id}},session:{id:this.session.user.id}});this.updateDom(function(){a.html(b)})},
updateFooter:function(){var a=this.contentNode.find("footer"),b=DISQUS.renderBlock("postFooter",{post:this.model.toJSON(),session:this.session.toJSON(),thread:this.thread.toJSON()});this.updateDom(function(){a.html(b)})},updateMenu:function(){var a=this.contentNode.find("[data-role=menu]"),b=DISQUS.renderBlock("postMenu",{session:this.session.toJSON(),post:this.model.toJSON()});this.updateDom(function(){a.html(b)})},updatePoints:function(a){var b=function(a){_.delay(function(){a.addClass("update");
_.delay(function(){a.removeClass("update")},1E3)},500)};this.contentNode.find("[data-role=points], [data-role=likes], [data-role=dislikes]").each(function(c){var c=$(c),e=c.html(),f=a.get(c.attr("data-role")).toString();e!==f&&(c.removeClass("count-"+f),c.removeClass("count-"+e),c.html(f),b(c))})},markSeen:function(){function a(e){var f,g;if(!e)return!1;f=b.offset.top+e.frameOffset.top;g=(g=f>e.pageOffset)&&f+b.dim.height<=e.pageOffset+e.height;if(!g)return!1;b.contentNode.addClass("seen");_.delay(function(){b.contentNode.removeClass("seen");
b.contentNode.removeClass("new")},1E4);b.trackPosition=!1;c.off("scroll",a);return!0}var b=this,c=m.getInstance();if(!a(c.position))c.on("scroll",a,b);c.off("domReflow",b.markSeen)},render:function(){var a=this,b=a.parent&&a.parent.model;a.setElement($(DISQUS.renderBlock("post",{post:a.model.toJSON(),session:a.session.toJSON(),thread:a.thread.toJSON(),loading:!a.model.id,created:a.created,parentAuthorName:b?b.author.get("name"):null})));a.contentNode=a.$el.find("[data-role=post-content]");a.childrenNode=
a.$el.find("[data-role=children]");this.highlightSyntax();if(a.model.get("isRealtime"))m.getInstance().switches.enabled("next_realtime_anim_disabled")?a.contentNode.removeClass("new"):(a.trackPosition=!0,n.on("domReflow",a.markSeen,a));n.on("domReflow",_.once(function(){var b=a.$el.find("[data-role=realtime-notification:"+a.model.id+"] .realtime-replies");a.typingUserView=new V({parentView:a,model:a.model,el:b})}));a.processMentions();a.bindDomEvents();if(b&&!b.get("isDeleted"))a.contextCard=L.create({post:this.parent.model,
targetElement:this.$el.find("[data-role=parent-link]")})},highlightSyntax:function(){var a=this.contentNode.find("pre code");a.length&&a.each(function(a){h.syntaxHighlighter.highlight(a)})},redraw:function(){var a=this.$el;if(!a)throw Error("Old child not found on PostView.redraw");var b=this.childrenNode.children();this.render();this.updateDom(function(){a[0].parentNode.replaceChild(this.el,a[0]);this.childrenNode.append(b)},this)},processMentions:function(){this.contentNode.find("[data-dsq-mention]").each(function(){$(this).addClass("mention")})},
attachChild:function(a){var b=a.model;!b.id||b.get("isImmediateReply")?this.childrenNode.prepend(a.el):this.childrenNode.append(a.el)},toggleReply:function(){if(this.reply)return void this.reply.toggle();this.reply=new v({parentView:this,parent:this.model,thread:this.thread,session:this.options.session});this.reply.bind("submitted",function(){this.reply.$el.hide()},this);this.drawReply()},drawReply:function(){this.reply&&(this.reply.render(),this.updateDom(function(){var a=this.childrenNode[0];a.insertBefore(this.reply.el,
a.firstChild);this.reply.focus()},this))},toggleEdit:function(){this.edit?(this.edit.remove(),this.edit=null,this.contentNode.find("[data-role=message]").show()):(this.edit=new M({post:this.model}),this.edit.render(),this.edit.bind("submitted",this.toggleEdit,this),this.updateDom(function(){var a=this.contentNode.find("[data-role=message]");a[0].parentNode.insertBefore(this.edit.el,a[0]);a.hide();this.edit.resize();(a=m.getInstance())&&a.scrollToPost(this.model.id)},this))},removeAsDeleted:function(){this.redraw()},
bindDomEvents:function(){var a=this;a.delegateActions(a.contentNode,{upvote:function(){a.handleVote(1)},downvote:function(){a.handleVote(-1)},reply:"handleReply",flag:"handleFlag",edit:"handleEdit","delete":"handleDelete",spam:"handleSpam",blacklist:"handleBlacklist",collapse:"handleCollapse",reveal:"handleReveal","share:twitter":"_onShare","share:facebook":"_onShare"});var b=a.$el.find(".hovercard");if(b.length)a.profileCard=G.create({session:a.session,user:a.model.author,targetElement:b})},_onShare:function(a){if(a=
e(a.target,"share"))n.trigger("uiAction:postShare",a),this.share(a)},_shareUrl:function(){return this.thread.url()+"#comment-"+this.model.id},handleBlacklist:function(){if(!this.blacklist){var a=this.blacklist=new W({model:this.model});a.render();a.on("success cancel",function(){this.blacklist.remove();this.blacklist=null},this);this.updateDom(function(){this.contentNode.find("[data-role=blacklist-form]").first().append(a.el)},this)}},handleCollapse:function(){this.updateDom(function(){this.$el.toggleClass("collapsed")},
this)},handleVote:function(a){a===1?n.trigger("uiAction:postUpvote"):a===-1&&n.trigger("uiAction:postDownvote");var b=this.model.get("userScore")===a;this.model.vote(b?0:a);var c=this.contentNode.find("[data-role=voting]");c.removeClass("upvoted").removeClass("downvoted");b||(a>0?c.addClass("upvoted"):a<0&&c.addClass("downvoted"))},remove:function(){this.model.off(null,null,this);this.session.off(null,null,this);Backbone.View.prototype.remove.call(this)},handleReply:function(){this.toggleReply()},
handleFlag:function(){window.confirm("Are you sure you want to flag this comment?")&&this.model.report()},handleEdit:function(){this.toggleEdit()},handleDelete:function(){this.model.destroy()},handleSpam:function(){this.model.spam()},handleReveal:function(){this.model.set("isMinimized",!1);this.redraw()}});_.extend(H.prototype,k);var N=l.extend({render:function(){var a=this;a.setElement($(DISQUS.renderBlock("captcha")));a.$el.bind("submit",function(b){b.preventDefault();a.trigger("submitted")})},
start:function(){function a(){b.updateDom(function(){Recaptcha.create("6LdKMrwSAAAAAPPLVhQE9LPRW4LUSZb810_iaa8u",b.el,{theme:"custom",custom_theme_widget:"recaptcha_widget"});b.$el.show()})}var b=this;typeof Recaptcha==="undefined"?DISQUS.require("//www.google.com/recaptcha/api/js/recaptcha_ajax.js",{},!1,a):a()},getChallenge:function(){return Recaptcha.get_challenge()},getResponse:function(){return Recaptcha.get_response()},reload:function(){Recaptcha.reload()}}),I=l.extend({initialize:function(a){this.session=
a.session;this.showZero=a.showZero||!1},render:function(){var a=this.session.get("notificationCount")||0;this.$el.html("<span>"+a+"</span>");a>0||this.showZero?this.$el.show():this.$el.hide();return this}}),F=Backbone.View.extend({__type__:"QueuedPostView",getDirection:function(a){var b=a.pageOffset,c=this.offset.top+a.frameOffset.top;if(c+this.dim.height<b)return 1;if(c>b+a.height)return-1;return 0},setCount:function(a){this.options.count=a},bindDrain:function(){var a=_.bind(this.drainHandler,this);
if(!this.clickEvent)this.$el.attr("data-action")=="load-queued-posts"?this.$el.bind("click",a):this.$el.delegate("[data-action=load-queued-posts]","click",a),this.clickEvent=!0},render:function(){var a=this;if(a.options.count===0)return void a.$el.hide();a.$el.html(DISQUS.renderBlock("realtimeCommentNotification",{comments:a.options.count}));a.bindDrain();m.getInstance().on("domReflow",_.throttle(function(){if(a.options.count!==0)this.offset=a.$el.offset(),this.dim=a.$el.dim()},400),this);a.$el.show()},
drainHandler:function(){this.model.queue.drain();this.setCount(this.model.queue.length);this.render()}}),Q=F.extend({getDirection:function(a){this.offset=this.options.postView.offset;this.dim=this.options.postView.dim;a=F.prototype.getDirection.call(this,a);delete this.offset;delete this.dim;return a},render:function(){var a=this,b=a.options.postView;DISQUS.log("Model:",a.model.id);a.options.count===0?(a.$el.hide(),b.trackPosition=!1):(b.trackPosition=!0,a.$el.html(DISQUS.renderBlock("realtimeReplyNotification",
{replies:a.options.count})),a.bindDrain(),a.$el.show(),_.delay(function(){a.$el.addClass("reveal")},13))},drainHandler:function(){var a=this.model.id,b=this.options.postView,c=this.options.thread.queue;c.drain(a);this.setCount(c.counters.replies[a]);b.trackPosition=!1;this.render()}}),V=Backbone.View.extend({render:function(){var a=this.model.usersTyping.count(),b=this.options.parentView.reply;b&&b.isOpen()&&(a-=1);if(a<=0)return void this.$el.hide();a==1?this.$el.html("One other user is typing&hellip;"):
this.$el.html(a+" other users are typing&hellip;");this.$el.show()}}),X=l.extend({tagName:"ul",className:"loading",initialize:function(a){this.collection.bind("reset",this.render,this);this.session=a.session},render:function(){this.updateDom(function(){this.$el.removeClass("loading");this.$el.empty();this.collection.each(function(a){this.$el.append(DISQUS.renderBlock("activityItem",{activity:a.toJSON(),session:this.session?this.session.toJSON():null}))},this);this.trigger("render")},this);return this}}),
S=l.extend({events:{"click [data-action=network]":"showNetwork","click [data-action=notifications]":"showNotifications"},initialize:function(a){this.network=new Y;this.notifications=new Z({notifications:a.session.notifications});this.notificationCount=new I({session:a.session,showZero:!0});this._views={network:this.network,notifications:this.notifications};this.network.on("render:activity",_.bind(this.trigger,this,"render:all"))},render:function(){this.updateDom(function(){this.$el.html(DISQUS.renderBlock("dashboard"))},
this);this._tabs={network:this.$el.find("[data-role=network-tab]"),notifications:this.$el.find("[data-role=notifications-tab]")};this.network.setElement(this.$el.find("[data-role=network]"));this.notifications.setElement(this.$el.find("[data-role=notifications]"));this.notificationCount.setElement(this.$el.find("[data-role=notification-count]"));this.network.render();this.notifications.render();this.notificationCount.render()},show:function(){this.setActiveTab("network")},setActiveTab:function(a){var b=
m.getInstance();b.freeze(!0);_.chain(this._tabs).invoke("removeClass","active");this._tabs[a].addClass("active");_.chain(this._views).pluck("$el").invoke("hide");var c=this._views[a];this.updateDom(function(){c.$el.show();b.freeze(!1)},this);c.show&&c.show()},showNetwork:g(function(){this.setActiveTab("network")}),showNotifications:g(function(){this.setActiveTab("notifications")})}),aa=l.extend({events:{"click [data-action=more]":g(function(){this.trigger("fire")})},setBusy:function(){this.$el.find("[data-action=more]").addClass("busy").removeAttr("disabled")},
setReady:function(){this.$el.find("[data-action=more]").removeClass("busy").removeAttr("disabled");this.updateDom(function(){this.$el[this.collection.cursor.hasNext?"show":"hide"]()},this)}}),Z=l.extend({initialize:function(a){this.notifications=a.notifications;this.notifications.on("reset",this.resetNotifications,this);this.notifications.on("add:many",this.addNotifications,this);this._fetched=!1;this.moreButton=new aa({collection:this.notifications});this.moreButton.on("fire",this.loadMore,this)},
render:function(){return this.renderLayout()},renderLayout:function(){this.updateDom(function(){this.$el.html(DISQUS.renderBlock("notifications"));this.moreButton.setElement(this.$el.find("[data-role=more-notifications]"));this.$el.addClass("loading")},this);return this},resetNotifications:function(a){var b=this.$el.find("[data-role=no-notifications]");b.hide();this.$el.removeClass("loading");a.size()===0?b.show():(b.hide(),this.addNotifications.apply(this,arguments))},addNotifications:_.decorate(Backbone.collectionAddNormalizer(j.NotificationCollection,
a.Notification),function(a){var b=_.map(a,function(a){return $(DISQUS.renderBlock("notification",{notification:a.toJSON()}))[0]});this.updateDom(function(){this.$el.find("[data-role=entries]").append(b)},this);this.moreButton.setReady();return this}),show:function(){if(!this._fetched)this.notifications.fetch({success:_.bind(this.notifications.markRead,this.notifications)}),this._fetched=!0},loadMore:function(){this.moreButton.setBusy();this.notifications.more()}}),Y=l.extend({initialize:function(){this.posts=
new j.PostActivityCollection;this.posts.on("reset",this.resetActivity,this);this.posts.on("add:many",this.addActivity,this);this._fetched=!1;this.moreButton=new aa({collection:this.posts});this.moreButton.on("fire",this.loadMore,this)},render:function(){return this.renderLayout()},renderLayout:function(){this.updateDom(function(){this.$el.html(DISQUS.renderBlock("networkActivity"));this.moreButton.setElement(this.$el.find("[data-role=more-activity]"));this.$el.addClass("loading")},this);return this},
resetActivity:function(a){var b=this.$el.find("[data-role=no-activity]");b.hide();this.$el.removeClass("loading");a.size()===0?b.show():(b.hide(),this.addActivity.apply(this,arguments))},addActivity:_.decorate(Backbone.collectionAddNormalizer(j.PostActivityCollection,a.Post),function(d){var b=new Backbone.Collection;_.each(d,function(d){var c=b.get(d.get("thread").id)||new a.Thread(_.extend(d.get("thread"),{forum:d.get("forum")}));c.posts.add(d);b.add(c)});var c=b.map(function(a){var d=$(DISQUS.renderBlock("networkActivityThreadEntry",
{thread:a.toJSON()})),a=a.posts.map(function(a){return $(DISQUS.renderBlock("networkActivityPostEntry",{post:a.toJSON()}))[0]});d.find("[data-role=posts]").append(a);return d[0]});this.updateDom(function(){this.$el.find("[data-role=entries]").append(c);this.trigger("render:activity")},this);this.moreButton.setReady();return this}),show:function(){if(!this._fetched)this.posts.fetch(),this._fetched=!0},loadMore:function(){this.moreButton.setBusy();this.posts.more()}}),ba=l.extend({tagName:"ol",className:"loading",
initialize:function(){this.collection.bind("reset",function(){this.updateDom(this.render,this)},this)},render:function(){this.updateDom(function(){this.$el.removeClass("loading");this.$el.empty();this.collection.each(function(a){var b=DISQUS.assureOffset(a.get("createdAt"));this.$el.append(DISQUS.renderBlock("topThread",{id:a.id,title:a.get("title"),url:a.get("link"),numPosts:a.get("postsInInterval"),numLikes:a.get("likes"),timeAgo:moment(b,DISQUS.ISO_8601).fromNow()}))},this);this.trigger("render")},
this);this.attachPosts();return this},attachPosts:function(){this.collection.each(function(a){this.renderPost(a)},this)},renderPost:function(a){var b=a.get("topPost");if(b){var c=_.escape(_.strip(b.message)),c=_.truncate(c,160,"&hellip;"),e=DISQUS.renderBlock("topThreadPost",{message:c,author:b.author});this.updateDom(function(){this.$el.find("[data-role=thread-"+a.id+"] [data-role=top-thread-post]").html(e)},this)}}}),ca=l.extend({tagName:"ol",className:"loading",initialize:function(){this.collection.bind("reset",
function(){n.thread.users.add(this.collection.models,{merge:!0});this.updateDom(this.render,this)},this)},render:function(){this.updateDom(function(){this.$el.removeClass("loading");this.$el.empty();this.collection.each(function(a){this.$el.append(DISQUS.renderBlock("topUser",{user:a.toJSON()}))},this);this.trigger("render")},this);return this}}),T=Backbone.View.extend({initialize:function(a){var b=this;b.forum=a.forum;b.topThreads=new ba({id:"top-threads",collection:new j.TopThreadCollection(null,
{forum:b.forum.id,limit:10})});b.topUsers=new ca({id:"top-users",collection:new j.TopUserCollection(null,{forum:b.forum.id,limit:20,discardLowRep:n.switches.enabled("next_discard_low_rep")})});Backbone.when([b.topUsers,"render"],[b.topThreads,"render"]).then(function(){b.isRendered=!0;b.trigger("render:all")});b.fetched=!1;b.render()},render:function(){this.$el.html(DISQUS.renderBlock("community",{forum:this.forum.toJSON()}));this.$el.find("[data-role=top-threads]").append(this.topThreads.el);this.$el.find("[data-role=top-users]").append(this.topUsers.el);
return this},show:function(){if(!this.fetched)this.topThreads.collection.fetch(),this.topUsers.collection.fetch(),this.fetched=!0}}),ja=l.extend({initialize:function(a){this.$el.addClass("loading");this.thread=a.thread;this.session=a.session;this.collection.on("add reset",this.render,this)},render:function(a,b,c){var e=this,f=(c&&c.index!=null?[e.collection.at(c.index)]:e.collection).map(function(a){a=new da({model:a,thread:e.thread,session:e.session});a.render();return a.el});e.updateDom(function(){e.$el.removeClass("loading");
e.$el.append(f);e.isRendered=!0;e.trigger("render:all")})},show:function(){this.collection.length>0||this.collection.fetch()}}),k={toggleFollow:function(a){a.preventDefault();this.user.get("isFollowing")?(this.user.unfollow(),$(a.target).removeClass("active")):($(a.target).addClass("active"),this.user.follow(),n.trigger("uiAction:followUser"))}},K=Backbone.View.extend({events:{"click [data-action=close]":"close","click [data-action=toggleFollow]":"toggleFollow"},initialize:function(a){var b=this;
b.user=a.user;b.session=a.session;b.user.get("numFollowers")===null&&b.user.fetch({success:function(){b.updateStats()}});b.user.on("change",b.updateStats,b);b.user.on("change:connections",b.updateConnections,b);b.user.on("change:isFollowing",b.updateActions,b);b.activity=new X({id:"activity",collection:new j.ActivityCollection(null,{user:b.user,include:"user"}),session:b.session});b.activity.on("render",function(){b.isRendered=!0;b.trigger("render:all")});b.render()},updateStats:function(){this.$el.find("[data-role=profile-stats]").html(DISQUS.renderBlock("profileStats",
{user:this.user.toJSON()}))},updateActions:function(){this.$el.find("[data-role=actions]").html(DISQUS.renderBlock("profileActions",{user:this.user.toJSON(),sessionId:this.session.user.id}))},updateConnections:function(){DISQUS.blocks.profileConnections&&this.$el.find("[data-role=connections]").html(DISQUS.renderBlock("profileConnections",{user:this.user.toJSON()}))},close:g(function(){this.trigger("close")}),render:function(){this.$el.empty();this.$el.append(DISQUS.renderBlock("profile",{user:this.user.toJSON(),
sessionId:this.session.user.id}));this.$el.find("[data-role=user-activity]").append(this.activity.el)},show:function(){this.activity.collection.fetch()}});_.extend(K.prototype,k);var t=l.extend({initialize:function(){this._id=_.uniqueId();this._hoverState="out";this._leaveTimeout=this._enterTimeout=null;t.open={}},bindEvents:function(){var a=this;a.$el.bind("mouseover",function(){a.enter()});a.$el.bind("mouseout",function(){a.leave()})},target:function(a){var b=this;a.bind("mouseover",function(){b.enter(a)});
a.bind("mouseout",function(){b.leave()})},enter:function(a){var b=this;if(a)this.$target=a;b._leaveTimeout&&clearTimeout(b._leaveTimeout);if(b._hoverState!=="in")b._hoverState="in",b._enterTimeout=_.delay(function(){b._hoverState==="in"&&b.show();b._enterTimeout=null},t.DELAY_ENTER),t.open[this.uid]=this},leave:function(){var a=this;a._enterTimeout&&clearTimeout(a._enterTimeout);if(a._hoverState!=="out")a._hoverState="out",a._leaveTimeout=_.delay(function(){a._hoverState==="out"&&a.hide();a._leaveTimeout=
null},t.DELAY_LEAVE),t.open[this.uid]&&delete t.open[this.uid]},show:function(){this.$target.append(this.el)},hide:function(){this.$el.remove()}},{open:{},instances:{},DELAY_ENTER:350,DELAY_LEAVE:175,exitAll:function(){_.invoke(t.open,"leave")},create:function(a,b,c,e){var f=t.instances[c];f||(t.instances[c]=f={});c=f[a];c||(c=new e(b),f[a]=c,c.render());c.target(b.targetElement);return c}});(function(){$(document).bind("mouseout",_.debounce(function(a){a=a.relatedTarget||a.toElement;(!a||a.nodeName===
"HTML")&&t.exitAll()}),10)})();var G=t.extend({events:{"click [data-action=toggleFollow]":"toggleFollow"},initialize:function(a){var b=this;t.prototype.initialize.call(b,a);b.session=a.session;b.user=a.user;b.user.on("change:numPosts change:numLikesReceived",_.debounce(function(){b.updateCounters()}));b.user.on("change:isFollowing",function(){b.updateActions()});b.session.on("change:id",function(){b.render()})},render:function(){var a=this.user.toJSON();if(a.about)a.about=_.truncate(a.about,80,"...");
this.setElement($(DISQUS.renderBlock("hovercard",{user:a,sessionId:this.session.user.id})));this.bindEvents()},updateCounters:function(){var a=this.$el.find("[data-role=counters]");this.updateDom(function(){a.html(DISQUS.renderBlock("hovercardCounters",{user:this.user.toJSON(),sessionId:this.session.user.id}))},this)},updateActions:function(){var a=this.$el.find("[data-role=actions]");this.updateDom(function(){a.html(DISQUS.renderBlock("hovercardActions",{user:this.user.toJSON(),sessionId:this.session.user.id}))},
this)},show:function(){this.user.get("numLikesReceived")===null&&this.user.fetch();t.prototype.show.call(this)}},{create:function(a){return t.create(a.user.id,a,"ProfileCard",G)}});_.extend(G.prototype,k);var L=t.extend({initialize:function(a){t.prototype.initialize.call(this,a);this.post=a.post},render:function(){var a=this.post.toJSON();a.excerpt=_.truncate(_.escape(_.strip(a.message),40,"..."));this.setElement($(DISQUS.renderBlock("contextCard",{post:a})));this.bindEvents()}},{create:function(a){if(DISQUS.blocks.contextCard)return t.create(a.post.id,
a,"ContextCard",L)}}),da=l.extend({events:{"click [data-action=remove]":"destroyReaction"},initialize:function(a){this.thread=a.thread;this.session=a.session;this.session.on("change:id",this.renderMenu,this)},render:function(){this.setElement($(DISQUS.renderBlock("reaction",{reaction:this.model.toJSON(),thread:this.thread.toJSON()})))},renderMenu:function(){var a=this.$el.find("[data-role=menu]"),b=DISQUS.renderBlock("reactionMenu",{thread:this.session.toJSON().thread});this.updateDom(function(){a.html(b)},
this)},destroyReaction:function(a){a&&a.preventDefault&&a.preventDefault();this.model.destroy();this.updateDom(function(){this.remove()},this)}}),O=l.extend({events:{"click [data-action=dismiss]":"dismiss"},initialize:function(a){_.extend(this,a)},render:function(){this.setElement($(DISQUS.renderBlock("alert",{message:this.message,type:this.type,safe:this.safe})));return this},dismiss:function(a){a&&a.preventDefault&&a.preventDefault();this.remove();this.trigger("dismiss")}}),W=l.extend({events:{"click [data-action=cancel]":"cancel"},
initialize:function(){var a=this;a.loading=!1;if(!a.model.get("ipAddress"))a.loading=!0,a.model.on("change:ipAddress",function s(){a.model.off("change:ipAddress",s);a.loading=!1;a.redraw()}),a.model.fetch()},render:function(){var a=this;a.setElement($(DISQUS.renderBlock("blacklist",{loading:this.loading,post:a.model.toJSON()})));a.$el.bind("submit",function(b){b&&b.preventDefault()&&b.preventDefault();a.submit()});return a},redraw:function(){var a=this.el.parentNode;a&&(this.render(),this.updateDom(function(){$(a).empty().append(this.el)},
this))},cancel:function(a){a&&a.preventDefault()&&a.preventDefault();this.trigger("cancel")},submit:function(){var a={},b=this;b.$el.find("input").each(function(){if(this.checked)a[this.name]=this.value});if(!_.isEmpty(a))a.forum=b.model.get("forum"),DISQUS.api.call("blacklists/add.json",{method:"POST",data:a,success:function(){b.trigger("success")}})}}),D=l.extend({events:{keyup:"handleKeychange",paste:"handleKeychange"},render:function(){this.el.tagName==="TEXTAREA"&&this.$el.autoresize({maxHeight:350});
this.$el.bind("resize",_.debounce(_.bind(this.updateDom,this,function(){}),300));return this},resize:function(){this.$el.trigger("paste")},get:function(){return this.$el.val()},set:function(a){this.$el.val(a)},clear:function(){this.set("")},focus:function(){this.el.focus()},handleKeychange:function(){this.trigger("keychange")}}),B=D.extend({events:{keyup:"handleKeychange",paste:"handleKeychange"},initialize:function(a){a=a||{};this.thread=a.thread;this.mentionsCache=new j.UserCollection;this.suggestions=
new ea({thread:a.thread,mentions:this.mentionsCache});this.placeholder="";this.suggestions.on("select",this.insertMention,this);this.reset()},reset:function(){this.anchorOffset=this.anchorNode=null;this.suggestions.clear()},handleKeychange:function(){this.trigger("keychange");this.$el.trigger("resize")},render:function(){var a=this.el.getAttribute("placeholder"),b=this.el.value,c=document.createElement("div");_.extend(c,{className:"textarea",contentEditable:!0,tabIndex:this.el.tabIndex});c.setAttribute("role",
"textbox");c.setAttribute("aria-multiline","true");c.style.overflow="auto";c.style.maxHeight="350px";var e=this.el.parentNode;e.replaceChild(c,this.el);this.setElement(c);this.bindKeyEvents();e.appendChild(this.suggestions.el);this.content=new Editable(this.el,!0);b&&this.set(b);D.prototype.render.call(this);if(a)this.placeholder='<span class="placeholder">'+a+"</span>",this.content.text()||this.$el.html(this.placeholder),this.$el.bind("focus focusin",_.debounce(_.bind(function(){this.isPlaceholder()&&
this.set("");this.el.focus()},this)),50),this.$el.bind("blur",_.bind(function(){this.content.text()===""&&this.setPlaceholder()},this));return this},isPlaceholder:function(){return this.$el.find(".placeholder").length!==0},setPlaceholder:function(){this.$el.html(this.placeholder)},bindKeyEvents:function(){this.$el.bind("keydown",_.bind(function(a){switch(a.keyCode){case 9:this.suggestions.active&&(this.suggestions.select(),a.preventDefault(),a.stopPropagation());break;case 10:case 13:case 38:case 40:this.suggestions.active&&
(a.preventDefault(),a.stopPropagation())}},this));var a=_.throttle(_.bind(this.suggest,this),500);this.$el.bind("keyup",_.bind(function(b){b.preventDefault();b.stopPropagation();this.checkExistingMentions();switch(b.keyCode){case 50:if(!b.shiftKey)break;this.start(b);break;case 10:case 13:this.suggestions.select();break;case 27:this.reset(b);break;case 38:this.suggestions.move("up");break;case 40:this.suggestions.move("down");break;default:a(b)}},this))},start:function(){this.reset();this.suggest()},
suggest:function(){this.suggestions.suggest(this.parseSearchTerms())},insertMention:function(a){var b=this.thread.users.getByCid(a);this.selectSearchString(b);this.mentionsCache.getByCid(a)||this.mentionsCache.add(b);this.content.insertHTML(B.getMentionHtml(b));a=this.$el.find("span[data-cid]");_.each(a,function(a){if(a.contentEditable!==!1)a.contentEditable=!1})},selectSearchString:function(){this.content.selectNodeText(this.anchorNode,this.anchorOffset-1,this.anchorOffset+Editable.normalizeSpace(this.anchorNode.nodeValue.slice(this.anchorOffset)).toLowerCase().length)},
get:function(){var a=this,b=B.isMention;if(this.isPlaceholder())return"";return this.content.text(function(c){return b(c,!0)?a.mentionToText(c):null})},set:function(a){this.content.setText(a);this.resize()},clear:function(){D.prototype.clear.call(this);this.setPlaceholder();_.defer(function(a){a.updateDom(function(){a.el.blur();a.$el.trigger("blur")})},this)},parseSearchTerms:function(){var a=this.content.selectedTextNode(),b=a?a.nodeValue:"",c=Editable.normalizeSpace;if(b){var e=this.content.selectedTextNodeOffset(a),
f=Editable.normalizeSpace(b.slice(0,e).split("").reverse().join("")).indexOf("@");if(f===-1)return null;this.anchorNode=a;this.anchorOffset=e-f;if(a=c(b.slice(this.anchorOffset-1,e)).match(B.MENTIONS_RE))return a[0].slice(1).split(" ");if(f===0)return[""]}},checkExistingMentions:function(){var a=Editable.normalizeSpace,b=this.$el.find("span"),b=_.filter(b,B.isMention),c=this.mentionsCache,e={};_.each(b,function(b){var f=$(b).attr("data-cid"),g=_.reduce(this.content.getTextNodes(b),function(b,c){return b+
a(c.nodeValue)},""),h=c.getByCid(f);h.get("name")!==g?(this.mentionsCache.remove(h),this.content.removeNode(b),this.content.insertHTML(" "),this.reset()):e[f]=b},this);c.each(function(a){e[a.cid]||c.remove(a)})},mentionToText:function(a){a=this.mentionsCache.getByCid($(a).attr("data-cid"));return["@",a.get("username")||a.get("emailHash"),":disqus"].join("")}},{MENTIONS_RE:/@\w+\s?(?:\w+\s?){0,5}(?:\w+)?$/,isMention:function(a,b){var c;do{c=$(a);if(c.hasClass("mention")&&c.attr("data-cid"))return!0;
a=a.parentElement}while(b&&a);return!1},getMentionHtml:function(a){return'<span contenteditable="true"><span contenteditable="false" data-cid="'+a.cid+'" class="mention">'+a.get("name")+"</span></span>&nbsp;"}}),ea=Backbone.View.extend({events:{"click li":"onclick"},initialize:function(a){this.active=!1;this.thread=a.thread;this.mentionsCache=a.mentions},suggest:function(a){a=this.findMatches(a);if(!a||!a.length)return void this.clear();this.active=!0;this.el.innerHTML=DISQUS.renderBlock("suggestions",
{users:_.map(a,function(a){return _.extend(a.toJSON(),{cid:a.cid})})});this.$el.find("li[data-cid]").first().addClass("active")},clear:function(){this.active=!1;this.el.innerHTML=""},onclick:function(a){this.select($(a.currentTarget).attr("data-cid"))},findMatches:function(a){if(a&&a.length){for(var b=RegExp(a.join(" ").replace(/[^\w\s]/,""),"i"),c=ea.MAX_SUGGESTIONS,e=this.thread.users,f=[],g=0,h,a=a.length===1&&a[0]===""?function(){return!0}:function(a){return b.test(a.get("name"))||b.test(h.get("username"))},
g=0;g<e.models.length&&f.length<c;g++)h=e.models[g],this.mentionsCache.getByCid(h.cid)||a(h)&&f.push(h);return f}},select:function(a){this.active&&(a||(a=this.$el.find(".active").attr("data-cid")),this.trigger("select",a),this.clear())},move:function(a){if(this.active){var b=this.$el.find(".active"),a=b[a==="up"?"previous":"next"]();a.length&&a.attr("data-cid")&&(b.removeClass("active"),a.addClass("active"))}}},{MAX_SUGGESTIONS:5}),R=l.extend({tagName:"ul",className:"debug",initialize:function(a){this.values=
a},render:function(){this.$el.empty();_.each(this.values,function(a,b){var c=document.createElement("li");c.innerHTML="<strong>"+b+"</strong>: "+a;this.$el.append(c)},this);return this}}),U=Backbone.View.extend({events:{"click [data-nav]":"_navTo"},initialize:function(){this.prevDestination=this.activeNav()},_navTo:function(a){a.preventDefault();a=$(a.target);a=a.is("[data-nav]")?a:a.closest("[data-nav]");a=a.attr("data-nav");if(this.prevDestination==a)return!1;this.navTo(a)},navTo:function(a){this.prevDestination=
a;var b=this.$el.find("[data-nav="+a+"]").parent();b.siblings("li").removeClass("active");b.addClass("active");this.trigger("nav",a)},activeNav:function(){if(this.prevDestination!=null)return this.prevDestination;return this.$el.find(".active [data-nav]").attr("data-nav")},clear:function(){this.$el.find("li").removeClass("active");this.prevDestination=null}}),P=Backbone.View.extend({events:{"click [rel=nofollow]":"sendLinkForInspection"},initialize:function(){this.link=null;this.busy=!1;this.timeoutId=
null;this.timeout=1E3;this.token=1;this.on("option.timeout",function(a){this.timeout=a})},setLink:function(a){this.link=a;this.$link=$(this.link)},onAffiliatorResponse:function(a){a=a||{};if(a.token==this.token){b.off("affiliateLink",this.onAffilatorResponse);if(a.url)this.link.href=a.url;this.undelegateEvents();this.$link.click()}},sendLinkForInspection:function(a){if(a.currentTarget===this.link)return void a.preventDefault();var c=a.which&&a.which===1||a.button===0;if(a.ctrlKey||a.metaKey||a.altKey||
a.shiftKey||!c)return!0;if(this.busy){b.off("affiliateLink");if(this.timeoutId&&window.clearTimeout)window.clearTimeout(this.timeoutId),this.timeoutId=null;this.token++}this.busy=!0;this.setLink(a.currentTarget);a.preventDefault();b.on("affiliateLink",this.onAffiliatorResponse,this);b.sendHostMessage("affiliateLink",{token:this.token,url:this.link.href});a=_.bind(function(a){this.onAffiliatorResponse({token:a})},this,this.token);this.timeoutId=_.delay(a,this.timeout)}});return{Lounge:m,LoungeSubView:l,
PostView:H,PostReplyView:v,PostEditView:M,ReactionView:da,UserMenuView:E,ThreadVotesView:A,ThreadSubscribeButton:x,QueuedPostView:F,QueuedReplyView:Q,TypingUserView:V,CommunityView:T,TopThreadCollectionView:ba,TopUserCollectionView:ca,DashboardView:S,NotificationCollectionView:Z,NotificationCountView:I,UserActivityCollectionView:X,NetworkActivityCollectionView:Y,ProfileView:K,HoverCard:t,ProfileCard:G,ContextCard:L,CaptchaView:N,OutboundLinkHandler:P,AlertView:O,BlacklistView:W,ContentEditableView:B,
DebugInfoView:R}});var _comscore,_gaq;
(function(c){var g="",g="UA-1410476-6",e=c.getElementsByTagName("script")[0],a=e.parentNode,j=c.location.protocol=="https:";_comscore=_comscore||[];_comscore.push({c1:"7",c2:"10137436",c3:"1"});var h=document.createElement("script");h.async=!0;h.src=(j?"https://sb":"http://b")+".scorecardresearch.com/beacon.js";a.insertBefore(h,e);_gaq=_gaq||[];_gaq.push(["_setAccount",g]);_gaq.push(["_setDomainName",".disqus.com"]);c=c.createElement("script");c.type="text/javascript";c.async=!0;c.src=(j?"https://ssl":
"http://www")+".google-analytics.com/ga.js";a.insertBefore(c,e)})(document);
(function(){DISQUS.log=function(){var c=DISQUS.lounge.views.Lounge.getInstance();window.console&&c&&c.switches&&c.switches.enabled("next_logging")&&(window.console.log.apply?window.console.log.apply(window.console,arguments):window.console.log(Array.prototype.slice.call(arguments,0).join(" ")))};DISQUS.logError=function(){var c=DISQUS.lounge.views.Lounge.getInstance(),g=Array.prototype.slice.call(arguments,0);DISQUS.log.apply(DISQUS,g);c.switches&&c.switches.enabled("next_raven")&&c.states.ravenConfigured&&
Raven.captureMessage({name:"DISQUS.logError",message:g.join(" ")})};$(document).ready(function(){function c(){$(".dropdown").removeClass("open")}$("html").bind("click",c);$("body").delegate("[data-toggle]","click",function(g){g.stopPropagation();g.preventDefault();var g=$(g.currentTarget),g=g.closest("."+g.attr("data-toggle")),e=g.attr("data-dropdown")!="disabled"&&!g.hasClass("open");g.attr("data-dropdown","enabled");c();e&&g.addClass("open")});DISQUS.Bus.bind("window.click",c)})})();