1
0
Fork 1
mirror of https://github.com/pixelfed/pixelfed.git synced 2024-12-30 19:55:10 +00:00
pixelfed/public/js/status.js

1 line
29 KiB
JavaScript
Raw Normal View History

2019-02-22 04:09:25 +00:00
!function(t){var e={};function s(a){if(e[a])return e[a].exports;var n=e[a]={i:a,l:!1,exports:{}};return t[a].call(n.exports,n,n.exports,s),n.l=!0,n.exports}s.m=t,s.c=e,s.d=function(t,e,a){s.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:a})},s.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},s.t=function(t,e){if(1&e&&(t=s(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var a=Object.create(null);if(s.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)s.d(a,n,function(e){return t[e]}.bind(null,n));return a},s.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return s.d(e,"a",e),e},s.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},s.p="/",s(s.s=5)}({"/sM+":function(t,e,s){"use strict";var a=s("v7ba");s.n(a).a},5:function(t,e,s){t.exports=s("CJs/")},"6ZA0":function(t,e,s){"use strict";s.r(e);function a(t){return function(t){if(Array.isArray(t)){for(var e=0,s=new Array(t.length);e<t.length;e++)s[e]=t[e];return s}}(t)||function(t){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t))return Array.from(t)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}pixelfed.postComponent={};var n={props:["status-id","status-username","status-template","status-url","status-profile-url","status-avatar"],data:function(){return{status:!1,media:{},user:!1,reactions:{liked:!1,shared:!1},likes:[],likesPage:1,shares:[],sharesPage:1}},mounted:function(){this.fetchData(),this.authCheck();var t=$('meta[name="csrf-token"]').attr("content");$('input[name="_token"]').each(function(e,s){$(s).val(t)})},updated:function(){if($(".carousel").carousel(),this.reactions&&(1==this.reactions.bookmarked&&$(".postComponent .far.fa-bookmark").removeClass("far").addClass("fas text-warning"),1==this.reactions.shared&&$(".postComponent .far.fa-share-square").addClass("text-primary"),1==this.reactions.liked&&$(".postComponent .far.fa-heart").removeClass("far text-dark").addClass("fas text-danger")),this.status){var t=this.status.account.username+" posted a photo: "+this.status.favourites_count+" likes";$("head title").text(t)}},methods:{authCheck:function(){1==$("body").hasClass("loggedIn")&&($(".comment-form-guest").addClass("d-none"),$(".comment-form").removeClass("d-none"))},showMuteBlock:function(){this.status.account.id==this.user.id?$(".post-actions .menu-author").removeClass("d-none"):$(".post-actions .menu-user").removeClass("d-none")},reportUrl:function(){return"/i/report?type=post&id="+this.status.id},editUrl:function(){return this.status.url+"/edit"},timestampFormat:function(){var t=new Date(this.status.created_at);return t.toDateString()+" "+t.toLocaleTimeString()},fetchData:function(){var t=this,e=this.$loading.show({opacity:0,"background-color":"#f5f8fa"});axios.get("/api/v2/profile/"+this.statusUsername+"/status/"+this.statusId).then(function(s){var a=t;a.status=s.data.status,a.user=s.data.user,a.media=a.status.media_attachments,a.reactions=s.data.reactions,a.likes=s.data.likes,a.shares=s.data.shares,a.likesPage=2,a.sharesPage=2,t.showMuteBlock(),e.hide(),pixelfed.readmore(),$(".postComponent").removeClass("d-none"),$(".postPresenterLoader").addClass("d-none"),$(".postPresenterContainer").removeClass("d-none")}).catch(function(t){if(t.response)switch(t.response.status){case 401:$(".postPresenterLoader .lds-ring").attr("style","width:100%").addClass("pt-4 font-weight-bold text-muted").text("Please login to view.");break;default:$(".postPresenterLoader .lds-ring").attr("style","width:100%").addClass("pt-4 font-weight-bold text-muted").text("An error occurred, cannot fetch media. Please try again later.")}else $(".postPresenterLoader .lds-ring").attr("style","width:100%").addClass("pt-4 font-weight-bold text-muted").text("An error occurred, cannot fetch media. Please try again later.")})},commentFocus:function(){$('.comment-form