framework/extensions/subscriptions/js/dist/forum.js
flarum-bot 3757bde4fc Bundled output for commit f67ca5782a
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2023-06-07 10:45:14 +00:00

2 lines
7.8 KiB
JavaScript
Generated

(()=>{var o={n:t=>{var s=t&&t.__esModule?()=>t.default:()=>t;return o.d(s,{a:s}),s},d:(t,s)=>{for(var n in s)o.o(s,n)&&!o.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:s[n]})},o:(o,t)=>Object.prototype.hasOwnProperty.call(o,t),r:o=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(o,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(o,"__esModule",{value:!0})}},t={};(()=>{"use strict";o.r(t),o.d(t,{extend:()=>V});const s=flarum.core.compat["common/extend"],n=flarum.core.compat["forum/app"];var r=o.n(n);flarum.core.compat["common/Model"];const a=flarum.core.compat["common/models/Discussion"];var e=o.n(a);const i=flarum.core.compat["forum/components/NotificationGrid"];var l=o.n(i);const c=flarum.core.compat["common/components/Badge"];var u=o.n(c);const f=flarum.core.compat["common/components/Button"];var p=o.n(f);const b=flarum.core.compat["forum/components/DiscussionPage"];var d=o.n(b);const _=flarum.core.compat["forum/utils/DiscussionControls"];var g=o.n(_);const w=flarum.core.compat["common/components/Dropdown"];var h=o.n(w);const v=flarum.core.compat["common/components/Tooltip"];var y=o.n(v);const x=flarum.core.compat["common/helpers/icon"];var S=o.n(x);const P=flarum.core.compat["common/utils/extractText"];var N=o.n(P);const M=flarum.core.compat["common/utils/classList"];var k=o.n(M);const B=flarum.core.compat["common/Component"];var D=o.n(B);class I extends(D()){view(){return m("button",{className:"SubscriptionMenuItem hasIcon",onclick:this.attrs.onclick},this.attrs.active&&S()("fas fa-check",{className:"Button-icon"}),m("span",{className:"SubscriptionMenuItem-label"},S()(this.attrs.icon,{className:"Button-icon"}),m("strong",null,this.attrs.label),m("span",{className:"SubscriptionMenuItem-description"},this.attrs.description)))}}class A extends(h()){oninit(o){super.oninit(o),this.options=[{subscription:null,icon:"far fa-star",label:r().translator.trans("flarum-subscriptions.forum.sub_controls.not_following_button"),description:r().translator.trans("flarum-subscriptions.forum.sub_controls.not_following_text")},{subscription:"follow",icon:"fas fa-star",label:r().translator.trans("flarum-subscriptions.forum.sub_controls.following_button"),description:r().translator.trans("flarum-subscriptions.forum.sub_controls.following_text")},{subscription:"ignore",icon:"far fa-eye-slash",label:r().translator.trans("flarum-subscriptions.forum.sub_controls.ignoring_button"),description:r().translator.trans("flarum-subscriptions.forum.sub_controls.ignoring_text")}]}view(){const o=this.attrs.discussion,t=o.subscription();let s=r().translator.trans("flarum-subscriptions.forum.sub_controls.follow_button"),n="far fa-star";const a="SubscriptionMenu-button--"+t;switch(t){case"follow":s=r().translator.trans("flarum-subscriptions.forum.sub_controls.following_button"),n="fas fa-star";break;case"ignore":s=r().translator.trans("flarum-subscriptions.forum.sub_controls.ignoring_button"),n="far fa-eye-slash"}const e=r().session.user.preferences(),i=e.notify_newPost_email,l=e.notify_newPost_alert,c=N()(r().translator.trans(i?"flarum-subscriptions.forum.sub_controls.notify_email_tooltip":"flarum-subscriptions.forum.sub_controls.notify_alert_tooltip")),u=(i||l)&&null===t,f=m(p(),{className:k()("Button","SubscriptionMenu-button",a),icon:n,onclick:this.saveSubscription.bind(this,o,-1!==["follow","ignore"].indexOf(t)?null:"follow")},s);return m("div",{className:"Dropdown ButtonGroup SubscriptionMenu"},u?m(y(),{text:c,position:"bottom"},f):f,m("button",{className:k()("Dropdown-toggle Button Button--icon",a),"data-toggle":"dropdown"},S()("fas fa-caret-down",{className:"Button-icon"})),m("ul",{className:"Dropdown-menu dropdown-menu Dropdown-menu--right"},this.options.map((s=>m("li",null,m(I,Object.assign({},s,{onclick:this.saveSubscription.bind(this,o,s.subscription),active:t===s.subscription})))))))}saveSubscription(o,t){o.save({subscription:t}),this.$(".SubscriptionMenu-button").tooltip("hide")}}const O=flarum.core.compat["common/components/LinkButton"];var R=o.n(O);const T=flarum.core.compat["forum/components/IndexPage"];var j=o.n(T);const L=flarum.core.compat["forum/states/DiscussionListState"];var C=o.n(L);const q=flarum.core.compat["forum/states/GlobalSearchState"];var F=o.n(q);const G=flarum.core.compat["forum/components/SettingsPage"];var z=o.n(G);const U=flarum.core.compat["common/components/Switch"];var $=o.n(U);const E=flarum.core.compat["forum/components/Notification"];var H=o.n(E);class J extends(H()){icon(){return"fas fa-star"}href(){const o=this.attrs.notification,t=o.subject(),s=o.content()||{};return r().route.discussion(t,s.postNumber)}content(){return r().translator.trans("flarum-subscriptions.forum.notifications.new_post_text",{user:this.attrs.notification.fromUser()})}}const K=flarum.core.compat["common/extenders"];var Q=o.n(K);const V=[(new(Q().Routes)).add("following","/following",j()),new(Q().Model)(e()).attribute("subscription")];r().initializers.add("subscriptions",(function(){r().notificationComponents.newPost=J,(0,s.extend)(e().prototype,"badges",(function(o){let t;switch(this.subscription()){case"follow":t=m(u(),{label:r().translator.trans("flarum-subscriptions.forum.badge.following_tooltip"),icon:"fas fa-star",type:"following"});break;case"ignore":t=m(u(),{label:r().translator.trans("flarum-subscriptions.forum.badge.ignoring_tooltip"),icon:"far fa-eye-slash",type:"ignoring"})}t&&o.add("subscription",t)})),(0,s.extend)(g(),"userControls",(function(o,t,s){if(r().session.user&&!(s instanceof d())){const s={none:{label:r().translator.trans("flarum-subscriptions.forum.discussion_controls.follow_button"),icon:"fas fa-star",save:"follow"},follow:{label:r().translator.trans("flarum-subscriptions.forum.discussion_controls.unfollow_button"),icon:"far fa-star",save:null},ignore:{label:r().translator.trans("flarum-subscriptions.forum.discussion_controls.unignore_button"),icon:"fas fa-eye",save:null}},n=t.subscription()||"none";o.add("subscription",m(p(),{icon:s[n].icon,onclick:t.save.bind(t,{subscription:s[n].save})},s[n].label))}})),(0,s.extend)(d().prototype,"sidebarItems",(function(o){if(r().session.user){const t=this.discussion;o.add("subscription",m(A,{discussion:t}),80)}})),(0,s.extend)(j().prototype,"navItems",(function(o){if(r().session.user){const t=r().search.stickyParams();o.add("following",m(R(),{href:r().route("following",t),icon:"fas fa-star"},r().translator.trans("flarum-subscriptions.forum.index.following_link")),50)}})),(0,s.extend)(j().prototype,"setTitle",(function(){"following"===r().current.get("routeName")&&r().setTitle(r().translator.trans("flarum-subscriptions.forum.following.meta_title_text"))})),(0,s.extend)(F().prototype,"params",(function(o){o.onFollowing="following"===r().current.get("routeName")})),(0,s.extend)(C().prototype,"requestParams",(function(o){this.params.onFollowing&&(o.filter||(o.filter={}),o.filter.q?o.filter.q+=" is:following":o.filter.subscription="following")})),(0,s.extend)(z().prototype,"notificationsItems",(function(o){var t;o.add("followAfterReply",m($(),{state:this.user.preferences().followAfterReply,onchange:o=>{this.followAfterReplyLoading=!0,this.user.savePreferences({followAfterReply:o}).then((()=>{this.followAfterReplyLoading=!1,m.redraw()}))},loading:this.followAfterReplyLoading},r().translator.trans("flarum-subscriptions.forum.settings.follow_after_reply_label"))),o.add("notifyForAllPosts",m($(),{id:"flarum_subscriptions__notify_for_all_posts",state:!(null==(t=this.user.preferences())||!t["flarum-subscriptions.notify_for_all_posts"]),onchange:o=>{this.user.savePreferences({"flarum-subscriptions.notify_for_all_posts":o})}},r().translator.trans("flarum-subscriptions.forum.settings.notify_for_all_posts_label")))})),(0,s.extend)(l().prototype,"notificationTypes",(function(o){o.add("newPost",{name:"newPost",icon:"fas fa-star",label:r().translator.trans("flarum-subscriptions.forum.settings.notify_new_post_label")})}))}))})(),module.exports=t})();
//# sourceMappingURL=forum.js.map