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

[skip ci]
2022-08-31 09:20:08 +00:00

2 lines
8.5 KiB
JavaScript
Generated

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