try{(function(e,t){function a(e,t){var n=decodeURI(e),i=s[t||!1?"strict":"loose"].exec(n),a={attr:{},param:{},seg:{}},f=14;while(f--)a.attr[r[f]]=i[f]||"";return a.param.query={},a.param.fragment={},a.attr.query.replace(o,function(e,t,n){t&&(a.param.query[t]=n)}),a.attr.fragment.replace(u,function(e,t,n){t&&(a.param.fragment[t]=n)}),a.seg.path=a.attr.path.replace(/^\/+|\/+$/g,"").split("/"),a.seg.fragment=a.attr.fragment.replace(/^\/+|\/+$/g,"").split("/"),a.attr.base=a.attr.host?a.attr.protocol+"://"+a.attr.host+(a.attr.port?":"+a.attr.port:""):"",a}function f(e){var r=e.tagName;return r!==t?n[r.toLowerCase()]:r}var n={a:"href",img:"src",form:"action",base:"href",script:"src",iframe:"src",link:"href"},r=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","fragment"],i={anchor:"fragment"},s={strict:/^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,loose:/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/},o=/(?:^|&|;)([^&=;]*)=?([^&;]*)/g,u=/(?:^|&|;)([^&=;]*)=?([^&;]*)/g;e.fn.url=function(t){var n="";return this.length&&(n=e(this).attr(f(this[0]))||""),e.url(n,t)},e.url=function(e,n){return arguments.length===1&&e===!0&&(n=!0,e=t),n=n||!1,e=e||window.location.toString(),{data:a(e,n),attr:function(e){return e=i[e]||e,e!==t?this.data.attr[e]:this.data.attr},param:function(e){return e!==t?this.data.param.query[e]:this.data.param.query},fparam:function(e){return e!==t?this.data.param.fragment[e]:this.data.param.fragment},segment:function(e){return e===t?this.data.seg.path:(e=e<0?this.data.seg.path.length+e:e-1,this.data.seg.path[e])},fsegment:function(e){return e===t?this.data.seg.fragment:(e=e<0?this.data.seg.fragment.length+e:e-1,this.data.seg.fragment[e])}}}})(jQuery),function(){var e=this,t=e.Backbone,n=[],r=n.push,i=n.slice,s=n.splice,o;typeof exports!="undefined"?o=exports:o=e.Backbone={},o.VERSION="1.0.0";var u=e._;!u&&typeof require!="undefined"&&(u=require("underscore")),o.$=e.jQuery||e.Zepto||e.ender||e.$,o.noConflict=function(){return e.Backbone=t,this},o.emulateHTTP=!1,o.emulateJSON=!1;var a=o.Events={on:function(e,t,n){if(!l(this,"on",e,[t,n])||!t)return this;this._events||(this._events={});var r=this._events[e]||(this._events[e]=[]);return r.push({callback:t,context:n,ctx:n||this}),this},once:function(e,t,n){if(!l(this,"once",e,[t,n])||!t)return this;var r=this,i=u.once(function(){r.off(e,i),t.apply(this,arguments)});return i._callback=t,this.on(e,i,n)},off:function(e,t,n){var r,i,s,o,a,f,c,h;if(!this._events||!l(this,"off",e,[t,n]))return this;if(!e&&!t&&!n)return this._events={},this;o=e?[e]:u.keys(this._events);for(a=0,f=o.length;a").attr(e);this.setElement(t,!1)}else this.setElement(u.result(this,"el"),!1)}}),o.sync=function(e,t,n){var r=T[e];u.defaults(n||(n={}),{emulateHTTP:o.emulateHTTP,emulateJSON:o.emulateJSON});var i={type:r,dataType:"json"};n.url||(i.url=u.result(t,"url")||B()),n.data==null&&t&&(e==="create"||e==="update"||e==="patch")&&(i.contentType="application/json",i.data=JSON.stringify(n.attrs||t.toJSON(n))),n.emulateJSON&&(i.contentType="application/x-www-form-urlencoded",i.data=i.data?{model:i.data}:{});if(n.emulateHTTP&&(r==="PUT"||r==="DELETE"||r==="PATCH")){i.type="POST",n.emulateJSON&&(i.data._method=r);var s=n.beforeSend;n.beforeSend=function(e){e.setRequestHeader("X-HTTP-Method-Override",r);if(s)return s.apply(this,arguments)}}i.type!=="GET"&&!n.emulateJSON&&(i.processData=!1),i.type==="PATCH"&&window.ActiveXObject&&(!window.external||!window.external.msActiveXFilteringEnabled)&&(i.xhr=function(){return new ActiveXObject("Microsoft.XMLHTTP")});var a=n.xhr=o.ajax(u.extend(i,n));return t.trigger("request",t,a,n),a};var T={create:"POST",update:"PUT",patch:"PATCH","delete":"DELETE",read:"GET"};o.ajax=function(){return o.$.ajax.apply(o.$,arguments)};var N=o.Router=function(e){e||(e={}),e.routes&&(this.routes=e.routes),this._bindRoutes(),this.initialize.apply(this,arguments)},C=/\((.*?)\)/g,k=/(\(\?)?:\w+/g,L=/\*\w+/g,A=/[\-{}\[\]+?.,\\\^$|#\s]/g;u.extend(N.prototype,a,{initialize:function(){},route:function(e,t,n){u.isRegExp(e)||(e=this._routeToRegExp(e)),u.isFunction(t)&&(n=t,t=""),n||(n=this[t]);var r=this;return o.history.route(e,function(i){var s=r._extractParameters(e,i);n&&n.apply(r,s),r.trigger.apply(r,["route:"+t].concat(s)),r.trigger("route",t,s),o.history.trigger("route",r,t,s)}),this},navigate:function(e,t){return o.history.navigate(e,t),this},_bindRoutes:function(){if(!this.routes)return;this.routes=u.result(this,"routes");var e,t=u.keys(this.routes);while((e=t.pop())!=null)this.route(e,this.routes[e])},_routeToRegExp:function(e){return e=e.replace(A,"\\$&").replace(C,"(?:$1)?").replace(k,function(e,t){return t?e:"([^/]+)"}).replace(L,"(.*?)"),new RegExp("^"+e+"$")},_extractParameters:function(e,t){var n=e.exec(t).slice(1);return u.map(n,function(e){return e?decodeURIComponent(e):null})}});var O=o.History=function(){this.handlers=[],u.bindAll(this,"checkUrl"),typeof window!="undefined"&&(this.location=window.location,this.history=window.history)},M=/^[#\/]|\s+$/g,_=/^\/+|\/+$/g,D=/msie [\w.]+/,P=/\/$/;O.started=!1,u.extend(O.prototype,a,{interval:50,getHash:function(e){var t=(e||this).location.href.match(/#(.*)$/);return t?t[1]:""},getFragment:function(e,t){if(e==null)if(this._hasPushState||!this._wantsHashChange||t){e=this.location.pathname;var n=this.root.replace(P,"");e.indexOf(n)||(e=e.substr(n.length))}else e=this.getHash();return e.replace(M,"")},start:function(e){if(O.started)throw new Error("Backbone.history has already been started");O.started=!0,this.options=u.extend({},{root:"/"},this.options,e),this.root=this.options.root,this._wantsHashChange=this.options.hashChange!==!1,this._wantsPushState=!!this.options.pushState,this._hasPushState=!!(this.options.pushState&&this.history&&this.history.pushState);var t=this.getFragment(),n=document.documentMode,r=D.exec(navigator.userAgent.toLowerCase())&&(!n||n<=7);this.root=("/"+this.root+"/").replace(_,"/"),r&&this._wantsHashChange&&(this.iframe=o.$('"+""+""),l=new window.rembeddit.PixelTracker({url:r.config.eventtracker_url});e("body").on("click",".embed-comment",function(e){r.actions.trigger("embed",{target:e.target})}),r.actions.on("embed:success",function(n){function b(t){e(this).select().one("mouseup",function(e){e.preventDefault()});if(!y){var n=o.data(),i=u(n),s=new Date,a=s.getTime();l.send({event_topic:"embed",event_name:"embed_create",event_ts:a,event_ts_utc_offset:s.getTimezoneOffset()/-60,embed_type:i.parent?"comment_and_parent":"comment",user_agent:navigator.userAgent,user_id:r.config.user_id,logged_in_status:!!r.config.logged,sr_id:r.utils.fullnameToId(r.config.cur_site),sr_name:r.config.post_site,embed_id:r.utils.fullnameToId(o.thing_id()),embed_created_ts:a,embed_control:i.live,embed_host_url:location.href,embed_version:window.rembeddit.VERSION}),y=!0}}var o=e(n.target),c=o.data(),h=u(c),p=new r.ui.Popup({className:"embed-modal",content:i(h),footer:s(h)}),d=p.$.find("#embed-code"),v=p.$.find("#facebook-embed-code"),m=p.$.find("#embed-preview"),g=p.$.find("#facebook-embed"),y=!1;p.$.find("[data-toggle]").togglable(),p.$.on("change",'[type="checkbox"]',function(n){var i=n.target.name,s=e(n.target),l=o.data(i);l===t&&(l=h[i]),o.data(n.target.name,!l);var c=o.data(),g=u(c),y=a(g),b=g.html,w=m.height();d.val(b),v.val('
");if(s.data("rerender")!==!1){var E='[data-options="'+r.utils.escapeSelector(y)+'"]',S=m.find(E);S.length?S.show().siblings().hide():(m.height(w).append(e(b).hide()),f(p,y))}}),v.on("focus",b),d.on("focus",b),g.on("click",function(e){e.preventDefault(),p.$.find("#facebook-embed-code").show()}),p.on("closed.r.popup",function(){p.$.remove()}),p.on("show.r.popup",function(){m.find(".reddit-embed").hide()}),p.on("opened.r.popup",function(){f(p,h)}),p.show()})}(window.jQuery),!function(e){"use strict";var t=_.template('
'),n=_.template('
'),r=_.template(''+_.escape(e._("close this window"))+""+'
'+"<% if (options) { %>"+'
'+'
'+_.escape(e._("Share with:"))+"
"+'
'+"<% options.forEach(function(option) { %>"+"<%= option %>"+"<% }) %>"+"
"+"
"+"<% } %>"+"<% if (link) { %>"+'
'+'
'+_.escape(e._("Link:"))+"
"+''+"
"+"<% } %> "+"
"+'
'+'

'+''+_.escape(e._("Share via email as %(username)s").format({username:e.config.logged}))+""+''+_.escape(e._("Share via private message on reddit as %(username)s").format({username:e.config.logged}))+""+"

"+'
'+''+n({ref:"$shareToFeedback"})+"
"+'
'+''+n({ref:"$messageFeedback"})+"
"+'
'+'
'+'"+'"+"
"+n({ref:"$requestStateFeedback"})+'
'+_.escape(e._("sent!"))+"
"+"
"+"
"),i=Backbone.Model.extend({defaults:function(){return{errors:[],options:null,requestState:"UNSENT",selectedOption:null,link:null}}});e.ui.PostSharing=Backbone.View.extend({animationSpeed:200,_template:r,_model:i,events:{"click .post-sharing-link-input":"selectLinkInputText","copy .post-sharing-link-input":"fireCopyEvent","click .post-sharing-option":"setPostSharingOption","click .post-sharing-cancel":"clearPostSharingOption","click .post-sharing-submit":"shareToEmail","click .c-close":"close"},initialize:function(){var e=this.options.$thing,t=e.data("fullname"),n=t.split("_")[1],r=e.find(".entry a.title").text(),i=e.find(".entry a.comments").attr("href");this.thingData={fullname:t,title:r,link:i};var s=this.options.props||{};s.link=this.getShareLink("link"),this.state=new this._model(s),this.listenTo(this.state,"change",this.render),this.initialRender()},initialRender:function(){var e=this.state.toJSON();e.options&&(e.options=e.options.map(t)),this.$el.html(this._template(e)),this.refs={};var n=this.$el.find("[ref]");n.toArray().forEach(function(e){var t=$(e),n=t.attr("ref");this.refs[n]=t},this),this.refs.$mainForm.css("display","block"),this.render()},show:function(){this.$el.slideDown(this.animationSpeed,"swing",function(){this.trigger("show",this),this.selectLinkInputText()}.bind(this))},hide:function(){this.$el.slideUp(this.animationSpeed,"swing",function(){this.trigger("hide")}.bind(this))},unmount:function(){this.remove(),this.trigger("unmount",this)},close:function(){this.once("hide",this.unmount.bind(this)),this.hide(),this.trigger("close")},setPostSharingOption:function(e){var t=$(e.target).closest(".post-sharing-option"),n=t.data("post-sharing-option");switch(n){case"email":case"reddit-pm":return this.state.set({selectedOption:n});case"facebook":return this.shareToFacebook();case"twitter":return this.shareToTwitter();case"tumblr":return this.shareToTumblr();case"embed":return this.shareEmbed();default:this.close()}},getShareLink:function(t){var n={ref:"share",ref_source:t};return e.utils.replaceUrlParams(this.thingData.link,n)},shareEmbed:function(){var t="https://embed.redditmedia.com/widgets/embed",n=this.getShareLink("embed"),r={url:n},i=e.utils.replaceUrlParams(t,r);this.openWebIntent(i,"embed")},shareToFacebook:function(){var t=this.getShareLink("facebook"),n=e.config.currentOrigin+"/share/close",r={app_id:e.config.facebook_app_id,display:"popup",link:t,description:this.thingData.title,redirect_uri:n},i=e.utils.replaceUrlParams("https://www.facebook.com/dialog/feed",r);this.openWebIntent(i,"facebook")},shareToTwitter:function(){var t=this.getShareLink("twitter"),n="reddit",r=this.thingData.title,i=25,s=[r,"via","@"+n].join(" "),o=s.length+i,u=140,a=10,f=r.length-(o-u)-1;s.length>u&&(r=r.slice(0,Math.max(a,f)),r=r.trim()+"…");var l={url:t,text:r,via:n},c=e.utils.replaceUrlParams("https://twitter.com/intent/tweet",l);this.openWebIntent(c,"twitter")},shareToTumblr:function(){var t=this.getShareLink("tumblr"),n=this.thingData.title,r={canonicalUrl:t,posttype:"link",title:n},i=e.utils.replaceUrlParams("https://www.tumblr.com/widgets/share/tool",r);this.openWebIntent(i,"tumblr")},openWebIntent:function(e,t){var n=window.innerWidth,r=window.innerHeight,i=550,s=420,o={height:s,width:i,left:n/2-i/2,top:r/2-s/2},u=Object.keys(o).map(function(e){return e+"="+o[e]}).join(",");window.open(e,t,u),this.trigger("web-intent",t)},shareToEmail:function(){this.state.set({requestState:"LOADING"}),$.request("share",{share_from:"",replyto:"",share_to:this.refs.$shareTo.val(),message:this.refs.$shareMessage.val(),parent:this.thingData.fullname,api_type:"json"},function(e){if(this.state.get("requestState")!=="LOADING")return;var t=e.json;if(!t)throw"share api response error";t.errors.length?this.state.set({errors:t.errors,requestState:"DONE"}):(this.state.set({errors:[],requestState:"DONE"}),setTimeout(function(){this.close()}.bind(this),1500))}.bind(this))},clearPostSharingOption:function(e){this.state.set({requestState:"UNSENT",selectedOption:null})},selectLinkInputText:function(){this.refs.$postSharingLinkInput.focus().select()},fireCopyEvent:function(){this.trigger("link","copy")},getFeedbackRef:function(e){switch(e){case"BAD_EMAIL":case"BAD_EMAILS":case"NO_EMAILS":return this.refs.$shareToFeedback;case"TOO_LONG":return this.refs.$messageFeedback;default:return this.refs.$requestStateFeedback}},onOpenEmailForm:function(){this.refs.$shareTo.focus()},render:function(){var e=this.state.get("requestState"),t=this.state.get("errors"),n=this.state.changed,r=this.state.get("selectedOption");"selectedOption"in n&&(this.refs.$emailFormEmailLabel.toggle(r==="email"),this.refs.$emailFormPMLabel.toggle(r==="reddit-pm"),this.refs.$shareTo.attr("placeholder",this.refs.$shareTo.data("placeholder-"+r)),r==="email"||r==="reddit-pm"?(this.refs.$mainForm.slideUp("fast"),this.refs.$emailForm.slideDown("fast",this.onOpenEmailForm.bind(this))):(this.refs.$mainForm.slideDown("fast"),this.refs.$emailForm.slideUp("fast")));if(r==="email"||r==="reddit-pm")this.refs.$shareToFeedback.stateify("clear"),this.refs.$messageFeedback.stateify("clear"),this.refs.$requestStateFeedback.stateify("clear"),t.length&&t.forEach(function(e){var t=e[0],n=e[1],r=this.getFeedbackRef(t);r.stateify("set","error",n)},this),e==="LOADING"?this.refs.$requestStateFeedback.stateify("set","loading"):e==="DONE"&&!t.length&&(this.refs.$requestStateFeedback.stateify("set","success"),this.refs.$emailForm.addClass("shared"))}}),$(function(){$("body").on("click",".post-sharing-button",function(t){t.preventDefault(),e.actions.trigger("share",{target:t.target})}),e.actions.on("share:success",function(t){var n=$(t.target),r=n.closest(".thing"),i=r.thing_id();if(e.ui.activeShareMenu&&e.ui.activeShareMenu.$el.is(":visible")){var s=e.ui.activeShareMenu.options.$thing[0]===r[0];e.ui.activeShareMenu.close();if(s)return}var o=[{name:"facebook",tooltip:e._("Share to %(name)s").format({name:"Facebook"})},{name:"twitter",tooltip:e._("Share to %(name)s").format({name:"Twitter"})},{name:"tumblr",tooltip:e._("Share to %(name)s").format({name:"Tumblr"})}];e.config.logged&&!e.config.user_in_timeout&&e.config.email_verified&&o.push({name:"email",tooltip:e._("Email to a Friend")}),e.config.logged&&!e.config.user_in_timeout&&o.push({name:"reddit-pm",tooltip:e._("Private Message a Friend on Reddit")}),e.config.feature_post_embed&&o.push({name:"embed",tooltip:e._("Embed Post")});var u=new e.ui.PostSharing({className:"post-sharing",$thing:r,props:{options:o}});r.find(".entry .buttons").after(u.el),e.ui.activeShareMenu=u,u.on("show",function(){e.analytics.fireGAEvent("post-sharing","open",i)}),u.on("unmount",function(){e.ui.activeShareMenu===u&&(e.ui.activeShareMenu=null)}),u.on("close",function(){var t=u.state.get("selectedOption")?"close":"cancel";e.analytics.fireGAEvent("post-sharing",t,i)}),u.on("web-intent",function(t){e.analytics.fireGAEvent("post-sharing","share-to-"+t,i)}),u.on("link",function(t){e.analytics.fireGAEvent("post-sharing","link-"+t,i)}),u.show()})})}(r),!function(e){function u(e){if(!s)return;E(),s.prevAll(".thing").eq(0).find(".entry a.title").click(),o={referrer_medium:e,referrer_element:"lightbox_nav_prev"},w(),o=null}function a(e){if(!s)return;E(),s.nextAll(".thing").eq(0).find(".entry a.title").click(),o={referrer_medium:e,referrer_element:"lightbox_nav_next"},w(),o=null}function m(){var t={comments_preview_enabled:!0};if(r.$thing){var n=r.$thing.data(),i=r.$thing.getThingType();t.link_listing=[n.fullname],t.target_type=i,t.target_fullname=n.fullname,t.target_id=e.utils.fullnameToId(n.fullname),i=="link"&&(t.target_url=n.url,t.target_url_domain=n.domain)}return o&&_.extend(t,o),t}function g(){h=m(),d=$("body > .comments-preview-popup"),v=d.children(".modal-dialog"),c=e.scrollEvent.getScrollUpdater(h,v,d),d.on("scroll",c),c(),p=setTimeout(y,e.scrollEvent.EVENT_DELAY)}function y(){if(!c)return;clearTimeout(p),d.off("scroll",c),e.actions.trigger("events:"+e.scrollEvent.EVENT_TYPE,{eventFields:h}),c=null,h=null,p=null}function b(){e.actions.trigger("expando",{target:r.$thing[0],triggeredBy:"lightbox"})}function w(){e.screenviewEvent&&e.actions.trigger("events:"+e.screenviewEvent.EVENT_TYPE,{eventFields:m()}),b()}function E(){c&&y()}if(!e.config.feature_comments_preview)return;var t=!!e.config.feature_comments_preview_nav_arrows,n=!!e.config.feature_comments_preview_collapsed_form,r=new e.ui.Popup({className:"comments-preview-popup"});r.$body=r.$.find(".modal-body");var i=$(".sitetable.linklisting"),s=null,o=null;if(t){r.$.addClass("comments-preview-nav-arrows-enabled"),e.config.feature_comments_preview_variant=="with_bolder_nav_arrows"&&r.$.addClass("comments-preview-bolder-nav-arrows"),r.$.prepend(''),r.$.on("click",".comments-preview-prev",function(){u("click")}),r.$.on("click",".comments-preview-next",function(){a("click")});var f=!1;$(document.body).on("focus","input, textarea, form",function(){f=!0}),$(document.body).on("blur","input, textarea, form",function(){f=!1}),$(document.body).on("keyup",function(e){if(f)return;if(e.keyCode===37)u("keyboard");else{if(e.keyCode!==39)return;a("keyboard")}})}n&&(r.$.addClass("comments-preview-collapsed-form-enabled"),r.$body.on("click",".comments-preview-add-comment",function(){r.$body.find(".comments-preview-add-comment").hide(),r.$body.find(".menuarea + form.usertext").show()}));var l=$("body").css("background-color");l&&l!=="rgba(0, 0, 0, 0)"&&r.$.find(".modal-content").css("background-color",l),e.commentsPreview={visible:!1},$(".sitetable.linklisting").on("click",".entry a.title, a.thumbnail",function(t){s=$(t.target).thing(),s[0]===i.children(".thing").last()[0]?r.$.addClass("comments-preview-showing-last"):r.$.removeClass("comments-preview-showing-last"),s.is(":first-child")?r.$.addClass("comments-preview-showing-first"):r.$.removeClass("comments-preview-showing-first");var o=$(t.target).thing().clone();r.$thing=o,o.find("a.title, a.thumbnail").on("click",function(t){if(e.utils.isSimpleClickEvent(t))return!1});var u=$($.parseHTML("
")),a=o.find(".bylink.comments").attr("href"),f=$.parseHTML('
');return u.append(f),u.load(a+" .commentarea",function(){n&&e.config.logged&&u.find("form.usertext").length&&u.find(".commentarea").prepend('
+ Add a comment
'),e.scrollEvent&&g()}),r.$body.empty(),r.$body.append(o),r.$body.append(u),r.show(),!1});var c=null,h=null,p=null,d=null,v=null;r.on("opened.r.popup",function(){e.commentsPreview.visible=!0,w()}),r.on("closed.r.popup",function(){e.commentsPreview.visible=!1,r.$body.empty(),E()})}(window.r),!function(e){function r(e){return e.tagName==="A"}function i(e){try{var t=e.$el.find(".entry")[0],n=e.$button[0],r,i,s=new MutationObserver(function(e){e.forEach(function(e){e.addedNodes.length&&$(e.addedNodes[0]).is(".expando-button")&&(r=e.addedNodes[0]),e.removedNodes.length&&e.removedNodes[0]===n&&(i=n),r&&i&&(s.disconnect(),$(r).before(i).remove())})});s.observe(t,{childList:!0}),setTimeout(function(){s.disconnect()},5e3)}catch(o){}}var t=[".linklisting",".organic-listing",".selfserve-subreddit-links"],n=[".expando-button",".expand-media",".expand-title"],s=Backbone.View.extend({buttonSelector:".expando-button",expandoSelector:".expando",expanded:!1,triggeredBy:undefined,events:{"click .expando-button":"toggleExpando","click .expand-media":"toggleExpandoFromLink","click .expand-title":"toggleExpandoFromLink"},constructor:function(){Backbone.View.prototype.constructor.apply(this,_.toArray(arguments)),this.afterInitialize()},initialize:function(){this.$button=this.$el.find(this.buttonSelector),this.$expando=this.$el.find(this.expandoSelector),this.setTriggeredBy(this.options.triggeredBy)},afterInitialize:function(){if(this.triggeredBy&&$(this.triggeredBy.target).closest(".expando-button").length>0&&!e.utils.isSimpleClickEvent(this.triggeredBy))return;this.expand()},setTriggeredBy:function(e){this.triggeredBy=e},toggleExpando:function(e){if(r(e.target))return; this.setTriggeredBy(e),this.expanded?this.collapse():this.expand()},toggleExpandoFromLink:function(t){var n=this.$el.find(this.buttonSelector);if(r(n))return;if(!e.utils.isSimpleClickEvent(t))return;this.setTriggeredBy(t),this.expanded?this.collapse():this.expand()},expand:function(){this.$button.addClass("expanded").removeClass("collapsed"),this.expanded=!0,this.show()},show:function(){this.$expando.show()},collapse:function(){this.$button.addClass("collapsed").removeClass("expanded"),this.expanded=!1,this.hide()},hide:function(){this.$expando.hide()}}),o=s.extend({events:_.extend({},s.prototype.events,{"click .open-expando":"expand"}),_expandoEventData:{},_timings:{initialize:null,loaded:null},initialize:function(){s.prototype.initialize.call(this),this._timings.initialize=new Date,this.cachedHTML=this.$expando.data("cachedhtml")||"",this.loaded=!!this.cachedHTML,this.id=this.$el.thing_id(),this.isNSFW=this.$el.hasClass("over18"),this.isSpoiler=this.$el.hasClass("spoiler"),this.linkType=$.getThingType(this.$el),this.autoexpanded=this.options.triggeredBy==="autoexpand",this.includeComments=this.$el.data("context")!=="comments"&&e.config.feature_preview_comments_in_expandos,!this.autoexpanded&&this.cachedHTML&&this.includeComments&&(this.includeComments="pending"),this.autoexpanded&&(i(this),this.loaded=!0,this.cachedHTML=this.$expando.html());var t=$.Event("expando:create",{expando:this});$(document.body).trigger(t);if(t.isDefaultPrevented())return;$(document).on("hide_thing_"+this.id,function(){this.setTriggeredBy("hide"),this.collapse()}.bind(this));var n=$.getLinkURL(this.$el),r={linkIsNSFW:this.isNSFW,linkIsSpoiler:this.isSpoiler,linkType:this.linkType,linkURL:n},o=this.$el.data();"fullname"in o&&(r.linkFullname=o.fullname),"timestamp"in o&&(r.linkCreated=o.timestamp),"domain"in o&&(r.linkDomain=o.domain),"authorFullname"in o&&(r.authorFullname=o.authorFullname),"subreddit"in o&&(r.subredditName=o.subreddit),"subredditFullname"in o&&(r.subredditFullname=o.subredditFullname),"context"in o&&(r.linkContext=o.context),$.extend(this._expandoEventData,r)},setTriggeredBy:function(e){o.__super__.setTriggeredBy.call(this,e),delete this._expandoEventData.triggerElement;var t=$(this.triggeredBy&&this.triggeredBy.target).closest(n.join(", "));t.is(".expando-button")?this._expandoEventData.triggeredBy=this.triggeredBy.type+"-expando-button":t.is(".expand-media")?this._expandoEventData.triggeredBy=this.triggeredBy.type+"-thumbnail":t.is(".expand-title")?this._expandoEventData.triggeredBy=this.triggeredBy.type+"-title":typeof this.triggeredBy=="string"&&(this._expandoEventData.triggeredBy=this.triggeredBy)},collapse:function(){o.__super__.collapse.call(this),this.autoexpanded=!1},show:function(){this.loaded&&!this._timings.loaded&&(this._timings.loaded=new Date);if(!this.loaded||this.includeComments==="pending"){var t={link_id:this.id,include_comments:!!this.includeComments,exclude_media:this.includeComments==="pending"};return $.request("expando",t,function(e){var t=$.unsafe(e);this.cachedHTML+=t,this.loaded=!0,this.includeComments=!0,this.show()}.bind(this),!1,"html",!0)}var n=$.Event("expando:show",{expando:this});this.$el.trigger(n);if(n.isDefaultPrevented())return;this.autoexpanded||this.$expando.html(this.cachedHTML);if(!this._expandoEventData.provider){var r=this.$expando.children();r.is("iframe")?this._expandoEventData.provider="embedly":this._expandoEventData.provider="reddit"}this.showExpandoContent(),this.fireExpandEvent(),e.analytics.fireRetargetingPixel(this.$el)},showExpandoContent:function(){this.$expando.removeClass("expando-uninitialized"),this.$expando.show()},fireExpandEvent:function(){this._expandoEventData.timingLoaded||this._timings.loaded&&this._timings.initialize&&(this._expandoEventData.timingLoaded=this._timings.loaded-this._timings.initialize);if(this.options.triggeredBy==="lightbox"){e.analytics.expandoEvent("expand_default",this._expandoEventData);return}this.autoexpanded?(this.autoexpanded=!1,e.analytics.expandoEvent("expand_default",this._expandoEventData)):e.analytics.expandoEvent("expand_user",this._expandoEventData)},hide:function(){var e=$.Event("expando:hide",{expando:this});this.$el.trigger(e);if(e.isDefaultPrevented())return;this.hideExpandoContent(),this.fireCollapseEvent()},hideExpandoContent:function(){this.$expando.hide().empty()},fireCollapseEvent:function(){e.analytics.expandoEvent("collapse_user",this._expandoEventData)}}),u=s.extend({buttonSelector:".search-expando-button",expandoSelector:".search-expando",events:{"click .search-expando-button":"toggleExpando"},afterInitialize:function(){var e=this.$expando.innerHeight(),t=this.$expando.find(".search-result-body").innerHeight();t<=e?(this.$button.remove(),this.$expando.removeClass("collapsed"),this.undelegateEvents()):this.options.expanded&&this.expand()},show:function(){this.$expando.removeClass("collapsed")},hide:function(){this.$expando.addClass("collapsed")}});$(function(){function i(e,t){if(e.data("expando"))return;e.data("expando",!0);var n=new o({el:e[0],triggeredBy:t})}function s(t){var n=$(t.target),i=n.thing(),s=i.find(".expando-button")[0];if(r(s))return;if(!e.utils.isSimpleClickEvent(t))return;e.actions.trigger("expando",{target:i[0],triggeredBy:t}),t.preventDefault()}e.hooks.get("expando-pre-init").call(),e.actions.on("expando:success",function(e){i($(e.target),e.triggeredBy)}),$(t.join(",")).on("click",n.join(","),s),$(".link .expando-button.expanded,.comments-page:not(.comment-permalink-page) .link.self").filter(":not(.seo-comments-recommendations .link)").each(function(){var t=$(this).closest(".thing");e.actions.trigger("expando",{target:t[0],triggeredBy:"autoexpand"})});var a=$(".search-expando-button").closest(".search-result-link");a.each(function(){new u({el:this})})})}(r),!function(e,t){var n="embedlyCard";$(window).on("message",function(t){var i=t.originalEvent;if(i.origin.replace(/^https?:\/\//,"")!==e.config.media_domain)return!1;try{var s=JSON.parse(i.data)}catch(t){return}if(s.name!==n)return;var o=$("[id^=media-embed-"+s.updateId+"]");if(!o.hasClass("embedly-card-embed"))return!1;s.action==="dimensionsChange"&&o.attr({height:s.height})})}(r),r.templates.set([{style:"html",name:"ui/formbar",template:'
\n
\n
\n

<%- thing.text %>

\n
\n \n \n
\n \n
\n'}]),!function(e,t){e.ui.FormBar=Backbone.View.extend({templateName:"ui/formbar",defaults:{text:"",buttonLabel:"",key:"",value:""},events:{"submit .form-bar":"onSubmit"},initialize:function(){var e=_.defaults(this.options,this.defaults);this.render(e)},render:function(t){var n=e.templates.make(this.templateName,t);this.$el.html(n)},onSubmit:function(e){e.preventDefault(),this.trigger("submit",get_form_fields(e.target))}})}(r),r.templates.set([{style:"html",name:"expando/gate",template:'
\n
\n \n <% if (thing.text) { %>\n

<%- thing.text %>

\n <% } %>\n
\n
\n'}]),!function(e,t){var n={over18Listing:!1,noProfanity:!0,nsfwMediaAcknowledged:!1,loggedIn:!1};e.hooks.get("setup").register(function(){n.over18Listing=e.config.listing_over_18,n.noProfanity=e.config.pref_no_profanity,n.nsfwMediaAcknowledged=e.config.nsfw_media_acknowledged,n.loggedIn=!!e.config.logged});var r=e.ui.FormBar.extend({doneString:e._("We will ask before showing NSFW media."),defaults:{text:"",buttonLabel:"",key:"show_nsfw_media",value:""},render:function(e){this._lastRenderProps=e,r.__super__.render.call(this,e)},onSubmit:function(e){r.__super__.onSubmit.call(this,e);var t=_.defaults({text:this.doneString},this._lastRenderProps);this.render(t),this.$el.addClass("expando--interstitial-complete"),this.$el.find("button").remove(),this.$el.find("form").attr("disabled",!0)}}),i=Backbone.View.extend({templateName:"expando/gate",events:{"click .expando-gate":"onClick","click .expando-gate__text":"onTextClick"},defaults:{buttonLabel:"",text:"",type:"normal",style:"interstitial"},initialize:function(){this.render(this.options)},render:function(t){t=_.defaults(t,this.defaults);var n=e.templates.make(this.templateName,t);this.$el.html(n)},onClick:function(e){e.preventDefault(),this.trigger("click:button")},onTextClick:function(e){e.preventDefault(),e.stopPropagation(),this.trigger("click:text")}}),s=Backbone.View.extend({strings:{normal:e._("Always show NSFW media?"),changedToShow:e._("Ok, we changed your preferences to always show NSFW media."),changedToShowLabel:e._("Undo"),warning:e._("Your account is set up to always show this content in the future."),alwaysAsk:e._("Change your preferences to hide NSFW media?"),alwaysAskLabel:e._("Hide NSFW"),nsfwButtonLabel:e._("Click to see NSFW"),spoilerButtonLabel:e._("Click to see spoiler"),comboButtonLabel:e._("Click to see NSFW spoiler")},initialize:function(){console.log(this.options);var e=this.options.width,t=this.options.height,r=this.options.isOverlay,s=this.options.isWarning,o=this.options.isNSFW,u=this.options.isSpoiler,a=this.options.isSelfText;this.isOverlay=r,this.isWarning=s,this.isNSFW=o,this.isSpoiler=u,e=this.isSpoiler&&a?!1:e,t=this.isSpoiler&&a?!1:t;var f;o&&u?f=this.strings.comboButtonLabel:o?f=this.strings.nsfwButtonLabel:u&&(f=this.strings.spoilerButtonLabel);var l={width:e?e+"px":"100%",height:t?t+"px":"100%",style:r?"overlay":"interstitial",type:s?"warning":"normal",reason:o?"nsfw":"spoiler",buttonLabel:f};n.loggedIn&&this.isNSFW&&(this.isWarning?l.text=this.strings.warning:l.text=this.strings.normal),this.interstitial=new i(l),this.$el.append(this.interstitial.el),this.listenTo(this.interstitial,"click:button",this.onShowOnce);if(!n.loggedIn)return;this.isNSFW&&this.isWarning?this.initFormBar():this.listenTo(this.interstitial,"click:text",this.onShowAlways)},initFormBar:function(){var e,t;this.isWarning?(e=this.strings.alwaysAsk,t=this.strings.alwaysAskLabel):(e=this.strings.changedToShow,t=this.strings.changedToShowLabel),this.formBar=new r({text:e,buttonLabel:t,value:"off"}),this.$el.append(this.formBar.el),this.listenTo(this.formBar,"submit",this.updatePref)},onShowOnce:function(){n.nsfwMediaAcknowledged?this.show():(n.nsfwMediaAcknowledged=!0,this._updateNsfwMediaPrefs({},this.show.bind(this)))},onShowAlways:function(){this.updatePref({show_nsfw_media:"on"}),this.initFormBar()},updatePref:function(e){n.noProfanity=e.show_nsfw_media==="off",this._updateNsfwMediaPrefs(e,function(){e.show_nsfw_media==="on"&&this.show()}.bind(this))},_updateNsfwMediaPrefs:function(e,t){$.request("set_nsfw_media_pref",e,function(e){t&&t()},!1,"json",!1)},show:function(){this.trigger("show"),this.isOverlay?this.interstitial.$el.fadeOut():this.interstitial.$el.remove()}});e.hooks.get("expando-pre-init").register(function(){$(document.body).on("expando:create",function(e){function u(e){e.preventDefault(),t.autoexpanded||t.$expando.html(t.cachedHTML);var r=t.$expando,i=r.children(),u=i.width(),a=i.height(),l=t.linkType!="self"&&i.hasClass("media-preview"),c=!n.noProfanity;o=new s({width:u,height:a,isOverlay:l,isWarning:c,isNSFW:t.isNSFW,isSpoiler:t.isSpoiler,isSelfText:t.linkType=="self"}),t.$expando.addClass("expando--with-interstitial"),t.listenTo(o,"show",f),o.isOverlay?i.append(o.el):r.html(o.el),t.showExpandoContent()}function a(e){e.preventDefault(),t.hideExpandoContent()}function f(){t.stopListening(o,"show",f),t.$expando.removeClass("expando--with-interstitial"),o.isOverlay||t.$expando.prepend(t.cachedHTML),t.fireExpandEvent(),t.$el.off("expando:show",u),t.$el.off("expando:hide",a)}var t=e.expando,r=!n.over18Listing&&(n.noProfanity||!n.nsfwMediaAcknowledged)&&t.isNSFW&&t.linkType=="link",i=t.isSpoiler;if(!r&&!i)return;var o;t.$el.on("expando:show",u),t.$el.on("expando:hide",a)})})}(r),r.saved={},r.saved.SaveCategories=Backbone.Collection.extend({model:Backbone.Model.extend({idAttribute:"category"}),url:"/api/saved_categories.json",fetchOnce:function(){return this._fetched||(this._fetched=this.fetch()),this._fetched},comparator:function(e){return e.get("category")},parse:function(e){return e.categories}}),r.saved.SaveDialog=r.ui.Bubble.extend({tagName:"form",className:"hover-bubble anchor-left save-selector",confirmTemplate:_.template('
'),events:{click:"clicked",submit:"save",mouseout:"mouseout",mouseover:"cancelTimeout","change select":"change"},mouseout:function(){this.$el.find("select, .savedcategory").is(":focus")||this.queueHide()},clicked:function(e){e.stopPropagation()},initialize:function(e){this.options=e,this.options.trackHover=!1,r.ui.Bubble.prototype.initialize.apply(this),r.saved.categories.fetchOnce().then(_.bind(this.show,this)),$("body").on("click.savedialog",_.bind(this.hideNow,this))},hideNow:function(){r.ui.Bubble.prototype.hideNow.apply(this),$("body").off("click.savedialog"),this.remove()},error:function(){this.$el.find("select, .savedcategory").attr("disabled",!1),this.$el.removeClass("working"),this.$el.find(".error").text(r._("Invalid category name"))},change:function(e){var t=this.$el.find(".savedcategory"),n=this.$el.find("option:selected").val();t.val(n).focus()},success:function(){var e=this.$parent.parents(".thing").find(".save-category");e.length&&this.category?(e.text("category: "+this.category),e.attr("href","/user/"+r.config.logged+"/saved/"+this.category),e.show()):e.hide(),r.saved.SaveButton.setSaved(this.$parent),this.category&&(r.saved.categories.add({category:this.category}),r.saved.categories.sort()),this.hide()},save:function(e){e.preventDefault(),this.category=this.$el.find(".savedcategory").val(),this.$el.find("select, .savedcategory").attr("disabled",!0);if(!this.category)return this.success();this.$el.addClass("working"),r.ajax({type:"POST",url:"/api/save",data:{id:this.$parent.thing_id(),category:this.category},success:this.success,error:this.error,context:this})},addCategory:function(e){var t=e.get("category");this.$el.find("select").append($("