mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-11 00:54:50 +00:00
1 line
13 KiB
JavaScript
Vendored
1 line
13 KiB
JavaScript
Vendored
(self.webpackChunkpixelfed=self.webpackChunkpixelfed||[]).push([[4822],{13574:(t,e,a)=>{"use strict";a.r(e),a.d(e,{default:()=>o});var i=a(24786),s=a(91584),r=(a(77333),a(74692));const o={components:{VueCropper:s.default,VueTimeago:i.default},props:["profile-id"],data:function(){return{loaded:!1,config:window.App.config,mimes:["image/jpeg","image/png"],page:"landing",pages:["landing","crop","edit","confirm","error","uploading"],uploading:!1,uploadProgress:0,cropper:{aspectRatio:9/16,viewMode:2,zoomable:!0,zoom:null},mediaUrl:null,mediaId:null,stories:[],lightboxMedia:!1,duration:3}},mounted:function(){var t=this;r("body").addClass("bg-black"),this.mediaWatcher(),axios.get("/api/stories/v0/fetch/"+this.profileId).then((function(e){t.stories=e.data.map((function(t){return t.showViewers=!1,t.viewers=[],t})),t.loaded=!0}))},methods:{upload:function(){r('.file-input[name="media"]').trigger("click")},mediaWatcher:function(){var t=this;r(document).on("change","#pf-dz",(function(e){t.triggerUpload()}))},triggerUpload:function(){var t=this;t.uploading=!0;var e=document.querySelector("#pf-dz");t.page="uploading",Array.prototype.forEach.call(e.files,(function(e,a){if(t.media&&t.media.length+a>=t.config.uploader.album_limit)return swal("Error","You can only upload "+t.config.uploader.album_limit+" photos per album","error"),t.uploading=!1,void(t.page=2);var i=e.type;if(-1==r.inArray(i,t.mimes))return swal("Invalid File Type","The file you are trying to add is not a valid mime type. Please upload a "+t.mimes+" only.","error"),t.uploading=!1,void(t.page="error");var s=new FormData;s.append("file",e);var o={onUploadProgress:function(e){var a=Math.floor(100*e.loaded/e.total);t.uploadProgress=a}};e.value=null,axios.post("/api/stories/v0/add",s,o).then((function(e){t.uploadProgress=100,t.uploading=!1,t.mediaUrl=e.data.media_url,t.mediaId=e.data.media_id,t.page="video"===e.data.media_type?"preview":"crop"})).catch((function(a){t.uploading=!1,e.value=null;var i=a.response.data.message?a.response.data.message:"Something went wrong.";swal("Oops!",i,"warning"),t.page="error"})),t.uploadProgress=0}))},expiresTimestamp:function(t){return(t=new Date(1e3*t)).toDateString()+" "+t.toLocaleTimeString()},edit:function(){this.page="edit"},showLightbox:function(t){this.lightboxMedia={url:t.src},this.$refs.lightboxModal.show()},deleteStory:function(t,e){var a=this;1==window.confirm("Are you sure you want to delete this Story?")&&axios.delete("/api/stories/v0/delete/"+t.id).then((function(t){a.stories.splice(e,1),0==a.stories.length&&(window.location.href="/i/stories/new")}))},navigateTo:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"/";window.location.href=t},goBack:function(){this.page="landing"},performCrop:function(){var t=this;this.page="cropping";var e=this.$refs.croppa.getData();axios.post("/api/stories/v0/crop",{media_id:this.mediaId,width:e.width,height:e.height,x:e.x,y:e.y}).then((function(e){t.page="preview"}))},deleteCurrentStory:function(){var t={id:this.mediaId};this.deleteStory(t),this.page="landing"},shareStoryToFollowers:function(){var t=this;axios.post("/api/stories/v0/publish",{media_id:this.mediaId,duration:this.duration}).then((function(e){window.location.href="/i/my/story?id="+t.mediaId}))},viewMyStory:function(){window.location.href="/i/my/story"},toggleShowViewers:function(t){this.stories[t].showViewers=!this.stories[t].showViewers}}}},74414:(t,e,a)=>{"use strict";a.r(e),a.d(e,{render:()=>i,staticRenderFns:()=>s});var i=function(){var t=this,e=t._self._c;return e("div",{staticClass:"container mt-2 mt-md-5 bg-black"},[e("input",{staticClass:"d-none file-input",attrs:{type:"file",id:"pf-dz",name:"media",accept:t.config.mimes}}),t._v(" "),e("span",{staticClass:"fixed-top text-right m-3 cursor-pointer",on:{click:function(e){return t.navigateTo()}}},[e("i",{staticClass:"fas fa-times fa-lg text-white"})]),t._v(" "),t.loaded?e("div",{staticClass:"row"},[e("div",{staticClass:"col-12 col-md-6 offset-md-3 bg-dark rounded-lg"},["landing"==t.page?e("div",{staticClass:"card card-body bg-transparent border-0 shadow-none d-flex justify-content-center",staticStyle:{height:"90vh"}},[t._m(0),t._v(" "),e("div",{staticClass:"flex-fill py-4"},[e("div",{staticClass:"card w-100 shadow-none bg-transparent"},[e("div",{staticClass:"list-group bg-transparent"},[e("a",{staticClass:"list-group-item bg-transparent lead text-decoration-none text-light font-weight-bold border-light",attrs:{href:"#"},on:{click:function(e){return e.preventDefault(),t.upload()}}},[e("i",{staticClass:"fas fa-plus-square mr-2"}),t._v("\n\t\t\t\t\t\t\t\tAdd to Story\n\t\t\t\t\t\t\t")]),t._v(" "),t.stories.length?e("a",{staticClass:"list-group-item bg-transparent lead text-decoration-none text-lighter font-weight-bold border-muted",attrs:{href:"#"},on:{click:function(e){return e.preventDefault(),t.edit()}}},[e("i",{staticClass:"far fa-clone mr-2"}),t._v("\n\t\t\t\t\t\t\t\tMy Story\n\t\t\t\t\t\t\t")]):t._e(),t._v(" "),t.stories.length?e("a",{staticClass:"list-group-item bg-transparent lead text-decoration-none text-lighter font-weight-bold border-muted",attrs:{href:"#"},on:{click:function(e){return e.preventDefault(),t.viewMyStory()}}},[e("i",{staticClass:"fas fa-history mr-2"}),t._v("\n\t\t\t\t\t\t\t\tView My Story\n\t\t\t\t\t\t\t")]):t._e(),t._v(" "),t._m(1)])])]),t._v(" "),e("div",{staticClass:"text-center flex-fill"})]):t._e(),t._v(" "),"crop"==t.page?e("div",{staticClass:"card card-body bg-transparent border-0 shadow-none d-flex justify-content-center",staticStyle:{height:"90vh"}},[e("div",{staticClass:"text-center py-3 d-flex justify-content-between align-items-center"},[e("div",[e("button",{staticClass:"btn btn-outline-lighter btn-sm py-1 px-md-3",on:{click:function(e){return t.deleteCurrentStory()}}},[e("i",{staticClass:"pr-2 fas fa-chevron-left fa-sm"}),t._v(" Delete")])]),t._v(" "),t._m(2),t._v(" "),e("div",[e("button",{staticClass:"btn btn-primary btn-sm py-1 px-md-3",on:{click:function(e){return t.performCrop()}}},[t._v("Crop "),e("i",{staticClass:"pl-2 fas fa-chevron-right fa-sm"})])])]),t._v(" "),e("div",{staticClass:"flex-fill"},[e("div",{staticClass:"card w-100 mt-3"},[e("div",{staticClass:"card-body p-0"},[e("vue-cropper",{ref:"croppa",attrs:{relativeZoom:t.cropper.zoom,aspectRatio:t.cropper.aspectRatio,viewMode:t.cropper.viewMode,zoomable:t.cropper.zoomable,rotatable:!0,src:t.mediaUrl}})],1)])])]):t._e(),t._v(" "),"error"==t.page?e("div",{staticClass:"card card-body bg-transparent border-0 shadow-none d-flex justify-content-center align-items-center",staticStyle:{height:"90vh"}},[e("p",{staticClass:"h3 mb-0 text-light"},[t._v("Oops!")]),t._v(" "),e("p",{staticClass:"text-muted lead"},[t._v("An error occurred, please try again later.")]),t._v(" "),t._m(3)]):t._e(),t._v(" "),"uploading"==t.page?e("div",{staticClass:"card card-body bg-transparent border-0 shadow-none d-flex justify-content-center align-items-center",staticStyle:{height:"90vh"}},[100!=t.uploadProgress?e("p",{staticClass:"display-4 mb-0 text-muted"},[t._v("Uploading "+t._s(t.uploadProgress)+"%")]):e("p",{staticClass:"display-4 mb-0 text-muted"},[t._v("Processing ...")])]):t._e(),t._v(" "),"cropping"==t.page?e("div",{staticClass:"card card-body bg-transparent border-0 shadow-none d-flex justify-content-center align-items-center",staticStyle:{height:"90vh"}},[e("p",{staticClass:"display-4 mb-0 text-muted"},[t._v("Cropping ...")])]):t._e(),t._v(" "),"preview"==t.page?e("div",{staticClass:"card card-body bg-transparent border-0 shadow-none d-flex justify-content-center align-items-center",staticStyle:{height:"90vh"}},[e("div",[e("div",{staticClass:"form-group"},[e("label",{staticClass:"text-light lead font-weight-bold",attrs:{for:"durationSlider"}},[t._v("Story Duration")]),t._v(" "),e("input",{directives:[{name:"model",rawName:"v-model",value:t.duration,expression:"duration"}],staticClass:"custom-range",attrs:{type:"range",min:"3",max:"10",id:"durationSlider"},domProps:{value:t.duration},on:{__r:function(e){t.duration=e.target.value}}}),t._v(" "),e("p",{staticClass:"help-text text-center"},[e("span",{staticClass:"text-light"},[t._v(t._s(t.duration)+" seconds")])])]),t._v(" "),e("hr",{staticClass:"my-3"}),t._v(" "),e("a",{staticClass:"btn btn-primary btn-block px-5 font-weight-bold my-3",attrs:{href:"#"},on:{click:function(e){return e.preventDefault(),t.shareStoryToFollowers()}}},[t._v("\n\t\t\t\t\t\tShare Story with followers\n\t\t\t\t\t")]),t._v(" "),e("a",{staticClass:"btn btn-outline-muted btn-block px-5 font-weight-bold",attrs:{href:"/"},on:{click:function(e){return e.preventDefault(),t.deleteCurrentStory()}}},[t._v("\n\t\t\t\t\t\tCancel\n\t\t\t\t\t")])])]):t._e(),t._v(" "),"edit"==t.page?e("div",{staticClass:"card card-body bg-transparent border-0 shadow-none d-flex justify-content-center",staticStyle:{height:"90vh"}},[t._m(4),t._v(" "),e("div",{staticClass:"flex-fill py-4"},[e("p",{staticClass:"lead font-weight-bold text-lighter"},[t._v("My Stories")]),t._v(" "),e("div",{staticClass:"card w-100 shadow-none bg-transparent",staticStyle:{"max-height":"50vh","overflow-y":"scroll"}},[e("div",{staticClass:"list-group"},t._l(t.stories,(function(a,i){return e("div",{staticClass:"list-group-item bg-transparent text-center border-muted text-lighter",attrs:{href:"#"}},[e("div",{staticClass:"media align-items-center"},[e("div",{staticClass:"mr-3 cursor-pointer",on:{click:function(e){return t.showLightbox(a)}}},[e("img",{staticClass:"rounded-circle border",staticStyle:{"object-fit":"cover"},attrs:{src:a.src,width:"40px",height:"40px"}})]),t._v(" "),e("div",{staticClass:"media-body text-left"},[e("p",{staticClass:"mb-0 text-muted font-weight-bold"},[e("span",[t._v(t._s(a.created_ago)+" ago")])])]),t._v(" "),e("div",{staticClass:"flex-grow-1 text-right"},[a.viewers.length?e("button",{staticClass:"btn btn-link btn-sm mr-1",on:{click:function(e){return t.toggleShowViewers(i)}}},[e("i",{staticClass:"fas fa-eye fa-lg text-muted"})]):t._e(),t._v(" "),e("button",{staticClass:"btn btn-link btn-sm",on:{click:function(e){return t.deleteStory(a,i)}}},[e("i",{staticClass:"fas fa-trash-alt fa-lg text-muted"})])])]),t._v(" "),a.showViewers&&a.viewers.length?e("div",{staticClass:"m-2 text-left"},[e("p",{staticClass:"font-weight-bold mb-2"},[t._v("Viewed By")]),t._v(" "),t._l(a.viewers,(function(a){return e("div",{staticClass:"d-flex"},[e("img",{staticClass:"rounded-circle mr-2",attrs:{src:"/storage/avatars/default.png",width:"24",height:"24"}}),t._v(" "),e("p",{staticClass:"mb-0 font-weight-bold"},[t._v("viewer.username")])])}))],2):t._e()])})),0)])]),t._v(" "),e("div",{staticClass:"flex-fill text-center"},[e("a",{staticClass:"btn btn-outline-secondary btn-block px-5 font-weight-bold",attrs:{href:"/i/stories/new"},on:{click:function(e){return e.preventDefault(),t.goBack()}}},[t._v("Go back")])])]):t._e()])]):t._e(),t._v(" "),e("b-modal",{ref:"lightboxModal",staticClass:"bg-transparent",attrs:{id:"lightbox","hide-header":"","hide-footer":"",centered:"",size:"md","body-class":"p-0 bg-transparent"}},[t.lightboxMedia?e("div",{staticClass:"w-100 h-100 bg-transparent"},[e("img",{staticStyle:{"max-height":"90vh",width:"100%","object-fit":"contain"},attrs:{src:t.lightboxMedia.url}})]):t._e()])],1)},s=[function(){var t=this,e=t._self._c;return e("div",{staticClass:"text-center flex-fill pt-3"},[e("p",{staticClass:"text-muted font-weight-light mb-1"},[e("i",{staticClass:"fas fa-history fa-5x"})]),t._v(" "),e("p",{staticClass:"text-muted font-weight-bold mb-0"},[t._v("STORIES")])])},function(){var t=this._self._c;return t("a",{staticClass:"list-group-item bg-transparent lead text-decoration-none text-lighter font-weight-bold border-muted",attrs:{href:"/"}},[t("i",{staticClass:"fas fa-arrow-left mr-2"}),this._v("\n\t\t\t\t\t\t\t\tGo back\n\t\t\t\t\t\t\t")])},function(){var t=this,e=t._self._c;return e("div",{},[e("p",{staticClass:"text-muted font-weight-light mb-1"},[e("i",{staticClass:"fas fa-history fa-5x"})]),t._v(" "),e("p",{staticClass:"text-muted font-weight-bold mb-0"},[t._v("STORIES")])])},function(){var t=this._self._c;return t("p",{staticClass:"text-muted mb-0"},[t("a",{staticClass:"btn btn-outline-secondary py-0 px-5 font-weight-bold",attrs:{href:"/"}},[this._v("Go back")])])},function(){var t=this,e=t._self._c;return e("div",{staticClass:"text-center flex-fill mt-5"},[e("p",{staticClass:"text-muted font-weight-light mb-1"},[e("i",{staticClass:"fas fa-history fa-5x"})]),t._v(" "),e("p",{staticClass:"text-muted font-weight-bold mb-0"},[t._v("STORIES")])])}]},63620:(t,e,a)=>{Vue.component("story-compose",a(75750).default)},31760:(t,e,a)=>{"use strict";a.r(e),a.d(e,{default:()=>r});var i=a(76798),s=a.n(i)()((function(t){return t[1]}));s.push([t.id,".bg-black{background-color:#262626}#lightbox .modal-content{background:transparent}",""]);const r=s},28035:(t,e,a)=>{"use strict";a.r(e),a.d(e,{default:()=>n});var i=a(85072),s=a.n(i),r=a(31760),o={insert:"head",singleton:!1};s()(r.default,o);const n=r.default.locals||{}},75750:(t,e,a)=>{"use strict";a.r(e),a.d(e,{default:()=>o});var i=a(50683),s=a(51737),r={};for(const t in s)"default"!==t&&(r[t]=()=>s[t]);a.d(e,r);a(45312);const o=(0,a(14486).default)(s.default,i.render,i.staticRenderFns,!1,null,null,null).exports},51737:(t,e,a)=>{"use strict";a.r(e),a.d(e,{default:()=>r});var i=a(13574),s={};for(const t in i)"default"!==t&&(s[t]=()=>i[t]);a.d(e,s);const r=i.default},50683:(t,e,a)=>{"use strict";a.r(e);var i=a(74414),s={};for(const t in i)"default"!==t&&(s[t]=()=>i[t]);a.d(e,s)},45312:(t,e,a)=>{"use strict";a.r(e);var i=a(28035),s={};for(const t in i)"default"!==t&&(s[t]=()=>i[t]);a.d(e,s)}},t=>{t.O(0,[3660],(()=>{return e=63620,t(t.s=e);var e}));t.O()}]); |