mediacms/static/js/profile-about.js

1 line
14 KiB
JavaScript
Raw Normal View History

!function(){"use strict";var t={6705:function(t,e,n){var o=n(2667),r=(n(2004),n(8407),n(4458),n(5101),n(6394),n(2322),n(4669),n(9268),n(3233),n(5466)),i=n(3074),a=n.n(i),u=n(1346),s=n(2880),l=n(365),c=n(137),f=n.n(c),h=n(4426),p=n(2259),m=n(612),d=n(5464),b=n(8170),y=n(8349),v=n(3085),g=(n(9174),n(9688)),_=n(8420);function S(t){return(S="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function w(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function k(t,e){for(var n=0;n<e.length;n++){var o=e[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}function E(t,e,n){return e&&k(t.prototype,e),n&&k(t,n),t}function P(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&j(t,e)}function j(t,e){return(j=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function D(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,o=O(t);if(e){var r=O(this).constructor;n=Reflect.construct(o,arguments,r)}else n=o.apply(this,arguments);return C(this,n)}}function C(t,e){return!e||"object"!==S(e)&&"function"!=typeof e?x(t):e}function x(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function O(t){return(O=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var F=function(t){P(n,t);var e=D(n);function n(t){var o;return w(this,n),(o=e.call(this,t)).state={subject:"",body:"",isSending:!1},o.onUpdateSubject=o.onUpdateSubject.bind(x(o)),o.onUpdateBody=o.onUpdateBody.bind(x(o)),o.onSubmit=o.onSubmit.bind(x(o)),o.onSubmitSuccess=o.onSubmitSuccess.bind(x(o)),o.onSubmitFail=o.onSubmitFail.bind(x(o)),o}return E(n,[{key:"onUpdateSubject",value:function(){this.setState({subject:this.refs.msgSubject.value.trim()})}},{key:"onUpdateBody",value:function(){this.setState({body:this.refs.msgBody.value.trim()})}},{key:"onSubmitSuccess",value:function(t){this.setState({subject:"",body:"",isSending:!1},(function(){setTimeout(function(){y.wN("Your message was successfully submitted to "+this.props.author.name,"messageSubmitSucceed")}.bind(this),100)}))}},{key:"onSubmitFail",value:function(t){this.setState({isSending:!1},(function(){console.log(t),setTimeout(function(){y.wN("Your message failed to submit. Please try again","messageSubmitFailed")}.bind(this),100)}))}},{key:"onSubmit",value:function(t){this.state.isSending||""===this.state.subject||""===this.state.body||(t.preventDefault(),t.stopPropagation(),this.setState({isSending:!0},(function(){var t=u.Z._currentValue.users+"/"+this.props.author.username+"/contact";(0,_.j0)(t,{subject:this.state.subject,body:this.state.body},{headers:{"X-CSRFToken":(0,_.m5)()}},!1,this.onSubmitSuccess,this.onSubmitFail)})))}},{key:"render",value:function(){return r.createElement("div",{className:"media-list-row profile-contact"},r.createElement("div",{className:"media-list-header"},r.createElement("h2",null,"Contact")),r.createElement("form",{method:"post",className:"user-contact-form"+(this.state.isSending?" pending-response":"")},r.createElement("span",null,r.createElement("label",null,"Subject"),r.createElement("input",{ref:"msgSubject",type:"text",required:!0,onChange:this.onUpdateSubject,value:this.state.subject})),r.createElement("span",null,r.createElement("label",null,"Message"),r.createElement("textarea",{ref:"msgBody",required:!0,cols:"40",rows:"10",onChange:this.onUpdateBody,value:this.state.body})),r.createElement("button",{onClick:this.onSubmit},"SUBMIT")))}}])