define("discourse/plugins/discourse-topic-voting/discourse/feature-voting-route-map",["exports"],(function(e){"use strict"
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default={resource:"user",path:"users/:username",map(){this.route("userActivity",{path:"activity",resetNamespace:!0},(function(){this.route("votes")}))}}})),define("discourse/plugins/discourse-topic-voting/discourse/initializers/discourse-topic-voting",["exports","discourse/lib/plugin-api","discourse/models/nav-item","discourse-i18n"],(function(e,t,o,i){"use strict"
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default={name:"discourse-topic-voting",initialize(){(0,t.withPluginApi)("0.8.32",(e=>{if(e.container.lookup("service:site-settings").topic_voting_enabled){e.container.lookup("controller:full-page-search").sortOrders.pushObject({name:(0,i.i18n)("search.most_votes"),id:5,term:"order:votes"}),e.addNavigationBarItem({name:"votes",before:"top",customFilter:e=>e&&e.can_vote,customHref:(e,t)=>`${o.default.pathFor("latest",t)}?order=votes`,forceActive:(e,t,o)=>{const i=o.currentRoute.queryParams
return i&&1===Object.keys(i).length&&"votes"===i.order}}),e.addNavigationBarItem({name:"my_votes",before:"top",customFilter:t=>t&&t.can_vote&&e.getCurrentUser(),customHref:(e,t)=>`${o.default.pathFor("latest",t)}?state=my_votes`,forceActive:(e,t,o)=>{const i=o.currentRoute.queryParams
return i&&1===Object.keys(i).length&&"my_votes"===i.state}})}})),(0,t.withPluginApi)("0.11.7",(e=>{e.container.lookup("service:site-settings").topic_voting_enabled&&e.addSearchSuggestion("order:votes")})),(0,t.withPluginApi)("2.1.0",(e=>{e.registerValueTransformer("category-available-views",(e=>{let{value:t,context:o}=e
o.customFields.enable_topic_voting&&t.push({name:(0,i.i18n)("filters.votes.title"),value:"votes"})}))}))}}})),define("discourse/plugins/discourse-topic-voting/discourse/pre-initializers/extend-category-for-voting",["exports","discourse/lib/plugin-api","discourse-i18n"],(function(e,t,o){"use strict"
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default={name:"extend-category-for-voting",before:"inject-discourse-objects",initialize(){(0,t.withPluginApi)("0.8.4",(e=>function(e){e.addPostClassesCallback((e=>{if(1===e.post_number&&e.can_vote)return["voting-post"]})),e.addTrackedPostProperties("can_vote"),e.addTagsHtmlCallback((e=>{if(!e.can_vote)return
let t=[],i=""
e.user_voted&&(i=` title='${(0,o.i18n)("topic_voting.voted")}'`)
let s=e.user_voted?" voted":""
return t.push(``),t.push((0,o.i18n)("topic_voting.votes",{count:e.vote_count})),t.push(""),t.length>0?t.join(""):void 0}),{priority:-100})}(e))),(0,t.withPluginApi)("0.8.30",(e=>e.addCategorySortCriteria("votes")))}}})),define("discourse/plugins/discourse-topic-voting/discourse/pre-initializers/transformers",["exports","discourse/lib/plugin-api"],(function(e,t){"use strict"
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default={name:"discourse-topic-voting-transformers",before:"freeze-valid-transformers",initialize(){(0,t.withPluginApi)("1.35.0",(e=>{e.addBehaviorTransformerName("topic-vote-button-click")}))}}})),define("discourse/plugins/discourse-topic-voting/discourse/routes/user-activity-votes",["exports","discourse/models/user-action","discourse/routes/user-topic-list","discourse-i18n"],(function(e,t,o,i){"use strict"
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
class s extends o.default{userActionType=(()=>t.default.TYPES.topics)()
model(){return this.store.findFiltered("topicList",{filter:"topics/voted-by/"+this.modelFor("user").get("username_lower")}).then((e=>(e.set("emptyState",this.emptyState()),e)))}emptyState(){const e=this.modelFor("user")
return{title:this.isCurrentUser(e)?(0,i.i18n)("topic_voting.no_votes_title_self"):(0,i.i18n)("topic_voting.no_votes_title_others",{username:e.username}),body:""}}}e.default=s})),define("discourse/plugins/discourse-topic-voting/discourse/templates/connectors/category-custom-settings/feature-voting-settings",["exports","@ember/template-factory"],(function(e,t){"use strict"
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default=(0,t.createTemplateFactory)({id:"iTtA3x+r",block:'[[[10,"h3"],[12],[1,[28,[35,1],["topic_voting.title"],null]],[13],[1,"\\n"],[10,"section"],[14,0,"field"],[12],[1,"\\n "],[10,0],[14,0,"enable-topic-voting"],[12],[1,"\\n "],[10,"label"],[14,0,"checkbox-label"],[12],[1,"\\n "],[8,[39,5],null,[["@type","@checked"],["checkbox",[30,0,["category","custom_fields","enable_topic_voting"]]]],null],[1,"\\n "],[1,[28,[35,1],["topic_voting.allow_topic_voting"],null]],[1,"\\n "],[13],[1,"\\n "],[13],[1,"\\n"],[13]],[],false,["h3","i18n","section","div","label","input"]]',moduleName:"discourse/plugins/discourse-topic-voting/discourse/templates/connectors/category-custom-settings/feature-voting-settings.hbs",isStrictMode:!1})})),define("discourse/plugins/discourse-topic-voting/discourse/templates/connectors/topic-above-post-stream/topic-title-voting",["exports","@ember/template-factory"],(function(e,t){"use strict"
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default=(0,t.createTemplateFactory)({id:"jKEO7jg0",block:'[[[41,[30,0,["model","can_vote"]],[[[41,[30,0,["model","postStream","loaded"]],[[[41,[30,0,["model","postStream","firstPostPresent"]],[[[1," "],[10,0],[14,0,"voting title-voting"],[12],[1,"\\n"],[1," "],[8,[39,2],null,[["@widget","@args","@showLogin"],["vote-box",[30,0,["model"]],[28,[37,3],["showLogin"],null]]],null],[1,"\\n "],[13],[1,"\\n"]],[]],null]],[]],null]],[]],null]],[],false,["if","div","mount-widget","route-action"]]',moduleName:"discourse/plugins/discourse-topic-voting/discourse/templates/connectors/topic-above-post-stream/topic-title-voting.hbs",isStrictMode:!1})})),define("discourse/plugins/discourse-topic-voting/discourse/templates/connectors/user-activity-bottom/user-voted-topics",["exports","@ember/template-factory"],(function(e,t){"use strict"
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default=(0,t.createTemplateFactory)({id:"XjZhW1Bp",block:'[[[41,[30,0,["siteSettings","topic_voting_show_votes_on_profile"]],[[[1," "],[8,[39,1],null,[["@route"],["userActivity.votes"]],[["default"],[[[[1,"\\n "],[1,[28,[35,2],["heart"],null]],[1,"\\n "],[1,[28,[35,3],["topic_voting.vote_title_plural"],null]],[1,"\\n "]],[]]]]],[1,"\\n"]],[]],null]],[],false,["if","link-to","d-icon","i18n"]]',moduleName:"discourse/plugins/discourse-topic-voting/discourse/templates/connectors/user-activity-bottom/user-voted-topics.hbs",isStrictMode:!1})})),define("discourse/plugins/discourse-topic-voting/discourse/widgets/remove-vote",["exports","discourse/lib/icon-library","discourse/widgets/widget","discourse-i18n"],(function(e,t,o,i){"use strict"
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default=(0,o.createWidget)("remove-vote",{tagName:"div.remove-vote",buildClasses:()=>"vote-option",html:()=>[(0,t.iconNode)("xmark"),(0,i.i18n)("topic_voting.remove_vote")],click(){this.sendWidgetAction("removeVote")}})})),define("discourse/plugins/discourse-topic-voting/discourse/widgets/vote-box",["exports","discourse/lib/ajax","discourse/lib/ajax-error","discourse/widgets/raw-html","discourse/widgets/widget","discourse-i18n"],(function(e,t,o,i,s,r){"use strict"
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default=(0,s.createWidget)("vote-box",{tagName:"div.voting-wrapper",buildKey:()=>"vote-box",buildClasses(){if(this.siteSettings.topic_voting_show_who_voted)return"show-pointer"},defaultState:()=>({allowClick:!0,initialVote:!1}),html(e,t){let o=[this.attach("vote-count",e),this.attach("vote-button",e),this.attach("vote-options",e)]
if(t.votesAlert>0){const e=""
o.push(new i.default({html:e}))}return o},hideVotesAlert(){this.state.votesAlert&&(this.state.votesAlert=null,this.scheduleRerender())},click(){this.hideVotesAlert()},clickOutside(){this.hideVotesAlert()},addVote(){let e=this.attrs,i=this.state
return(0,t.ajax)("/voting/vote",{type:"POST",data:{topic_id:e.id}}).then((t=>{e.set("vote_count",t.vote_count),e.set("user_voted",!0),this.currentUser.setProperties({votes_exceeded:!t.can_vote,votes_left:t.votes_left}),t.alert&&(i.votesAlert=t.votes_left),e.set("who_voted",t.who_voted),i.allowClick=!0,this.scheduleRerender()})).catch(o.popupAjaxError)},removeVote(){let e=this.attrs,i=this.state
return(0,t.ajax)("/voting/unvote",{type:"POST",data:{topic_id:e.id}}).then((t=>{e.set("vote_count",t.vote_count),e.set("user_voted",!1),this.currentUser.setProperties({votes_exceeded:!t.can_vote,votes_left:t.votes_left}),e.set("who_voted",t.who_voted),i.allowClick=!0,this.scheduleRerender()})).catch(o.popupAjaxError)}})})),define("discourse/plugins/discourse-topic-voting/discourse/widgets/vote-button",["exports","virtual-dom","discourse/lib/cookie","discourse/lib/transformer","discourse/widgets/widget","discourse-i18n"],(function(e,t,o,i,s,r){"use strict"
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default=(0,s.createWidget)("vote-button",{tagName:"div",buildClasses(e){let t=""
return t=e.closed?"voting-closed":e.user_voted?this.currentUser&&this.currentUser.votes_exceeded?"vote-limited nonvote":"vote":"nonvote",this.siteSettings.topic_voting_show_who_voted&&(t+=" show-pointer"),t},buildButtonTitle(e){return this.currentUser?e.closed?(0,r.i18n)("topic_voting.voting_closed_title"):e.user_voted?(0,r.i18n)("topic_voting.voted_title"):this.currentUser.votes_exceeded?(0,r.i18n)("topic_voting.voting_limit"):(0,r.i18n)("topic_voting.vote_title"):e.vote_count?(0,r.i18n)("topic_voting.anonymous_button",{count:e.vote_count}):(0,r.i18n)("topic_voting.anonymous_button",{count:1})},html(e){return(0,t.h)("button",{attributes:{title:this.currentUser?(0,r.i18n)("topic_voting.votes_left_button_title",{count:this.currentUser.votes_left}):""},className:"btn btn-primary vote-button"},this.buildButtonTitle(e))},click(){(0,i.applyBehaviorTransformer)("topic-vote-button-click",(()=>{if(!this.currentUser)return this.sendWidgetAction("showLogin"),void(0,o.default)("destination_url",window.location.href,{path:"/"})
this.attrs.closed||!this.parentWidget.state.allowClick||this.attrs.user_voted||this.currentUser.votes_exceeded||(this.parentWidget.state.allowClick=!1,this.parentWidget.state.initialVote=!0,this.sendWidgetAction("addVote")),(this.attrs.user_voted||this.currentUser.votes_exceeded)&&document.querySelector(".vote-options").classList.toggle("hidden")}))},clickOutside(){document.querySelector(".vote-options").classList.add("hidden"),this.parentWidget.state.initialVote=!1}})})),define("discourse/plugins/discourse-topic-voting/discourse/widgets/vote-count",["exports","virtual-dom","discourse/lib/ajax","discourse/lib/cookie","discourse/lib/get-url","discourse/widgets/widget"],(function(e,t,o,i,s,r){"use strict"
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default=(0,r.createWidget)("vote-count",{tagName:"div.vote-count-wrapper",buildKey:()=>"vote-count",buildClasses(){if(0===this.attrs.vote_count)return"no-votes"},defaultState:()=>({whoVotedUsers:null}),html(e){let o=(0,t.h)("div.vote-count",e.vote_count.toString()),i=null
this.siteSettings.topic_voting_show_who_voted&&this.state.whoVotedUsers&&this.state.whoVotedUsers.length>0&&(i=this.attach("small-user-list",{users:this.state.whoVotedUsers,addSelf:e.liked,listClassName:"regular-votes"}))
let s=[o]
return i&&s.push((0,t.h)("div.who-voted.popup-menu.voting-popup-menu",[i])),s},click(){if(!this.currentUser)return this.sendWidgetAction("showLogin"),void(0,i.default)("destination_url",window.location.href,{path:"/"})
if(this.siteSettings.topic_voting_show_who_voted&&this.attrs.vote_count>0){if(null===this.state.whoVotedUsers)return this.getWhoVoted()
{const e=document.querySelector(".who-voted")
e.style.display="none"===e.style.display?"block":"none"}}},clickOutside(){const e=document.querySelector(".who-voted")
e&&(e.style.display="none")},getWhoVoted(){return(0,o.ajax)("/voting/who",{type:"GET",data:{topic_id:this.attrs.id}}).then((e=>{this.state.whoVotedUsers=e.map(n)}))}})
function n(e){return{template:e.avatar_template,username:e.username,post_url:e.post_url,url:(0,s.default)("/u/")+e.username.toLowerCase()}}})),define("discourse/plugins/discourse-topic-voting/discourse/widgets/vote-options",["exports","virtual-dom","discourse/widgets/widget","discourse-i18n"],(function(e,t,o,i){"use strict"
Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0
e.default=(0,o.createWidget)("vote-options",{tagName:"div.vote-options",buildClasses:()=>"voting-popup-menu popup-menu hidden",html(e){let o=[]
return e.user_voted?o.push(this.attach("remove-vote",e)):this.currentUser&&this.currentUser.votes_exceeded&&!e.user_voted&&o.push([(0,t.h)("div",(0,i.i18n)("topic_voting.reached_limit")),(0,t.h)("p",(0,t.h)("a",{href:this.currentUser.get("path")+"/activity/votes"},(0,i.i18n)("topic_voting.list_votes")))]),o}})}))
//# sourceMappingURL=discourse-voting-78d2818e976b4872fa173f3c0f7b2f8e0a2ab62cda89a3db569517e505f19406.map
//!
;
Flash Sale Popup