pixelfed/public/js/profile.js

1 wiersz
28 KiB
JavaScript
Czysty Zwykły widok Historia

2019-03-07 20:28:37 +00:00
!function(t){var e={};function n(o){if(e[o])return e[o].exports;var s=e[o]={i:o,l:!1,exports:{}};return t[o].call(s.exports,s,s.exports,n),s.l=!0,s.exports}n.m=t,n.c=e,n.d=function(t,e,o){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:o})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var s in t)n.d(o,s,function(e){return t[e]}.bind(null,s));return o},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="/",n(n.s=4)}({"2wtg":function(t,e,n){Vue.component("profile",n("EHjT").default)},4:function(t,e,n){t.exports=n("2wtg")},"9tPo":function(t,e){t.exports=function(t){var e="undefined"!=typeof window&&window.location;if(!e)throw new Error("fixUrls requires window.location");if(!t||"string"!=typeof t)return t;var n=e.protocol+"//"+e.host,o=n+e.pathname.replace(/\/[^\/]*$/,"/");return t.replace(/url\s*\(((?:[^)(]|\((?:[^)(]+|\([^)(]*\))*\))*)\)/gi,function(t,e){var s,a=e.trim().replace(/^"(.*)"$/,function(t,e){return e}).replace(/^'(.*)'$/,function(t,e){return e});return/^(#|data:|http:\/\/|https:\/\/|file:\/\/\/|\s*$)/i.test(a)?t:(s=0===a.indexOf("//")?a:0===a.indexOf("/")?n+a:o+a.replace(/^\.\//,""),"url("+JSON.stringify(s)+")")})}},EHjT:function(t,e,n){"use strict";n.r(e);function o(t){return function(t){if(Array.isArray(t)){for(var e=0,n=new Array(t.length);e<t.length;e++)n[e]=t[e];return n}}(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")}()}var s={props:["profile-id","profile-settings"],data:function(){return{profile:{},user:{},timeline:[],timelinePage:2,min_id:0,max_id:0,loading:!0,owner:!1,mode:"grid",modes:["grid","list","masonry"],modalStatus:!1,relationship:{},followers:[],followerCursor:1,followerMore:!0,following:[],followingCursor:1,followingMore:!0}},beforeMount:function(){this.fetchProfile()},mounted:function(){},updated:function(){},methods:{fetchProfile:function(){var t=this;axios.get("/api/v1/accounts/"+this.profileId).then(function(e){t.profile=e.data}),axios.get("/api/v1/accounts/verify_credentials").then(function(e){t.user=e.data}),axios.get("/api/v1/accounts/relationships",{params:{"id[]":this.profileId}}).then(function(e){t.relationship=e.data[0]});var e="/api/v1/accounts/"+this.profileId+"/statuses";axios.get(e,{params:{only_media:!0,min_id:1}}).then(function(e){var n=e.data;t.timeline=n;var s=n.map(function(t){return t.id});t.min_id=Math.max.apply(Math,o(s)),t.max_id=Math.min.apply(Math,o(s)),t.modalStatus=_.first(e.data),t.loading=!1,t.ownerCheck()}).catch(function(t){swal("Oops, something went wrong","Please release the page.","error")})},ownerCheck:function(){this.owner=this.profile.id===this.user.id},infiniteTimeline:function(t){var e=this,n="/api/v1/accounts/"+this.profileId+"/statuses";axios.get(n,{params:{only_media:!0,max_id:this.max_id}}).then(function(n){if(n.data.length&&0==e.loading){var s,a=n.data;(s=e.timeline).push.apply(s,o(a));var i=a.map(function(t){return t.id});e.max_id=Math.min.apply(Math,o(i)),e.loading=!1,t.loaded()}else t.complete()})},previewUrl:function(t){return t.media_attachments[0].preview_url},previewBackground:function(t){return"background-image: url("+this.previewUrl(t)+");"},switchMode:function(t){this.mode=_.indexOf(this.modes,t)?t:"grid","masonry"==this.mode&&$(".masonry").masonry({columnWidth:200,itemSelector:".masonry-item"})},reportUrl:function(t){return"/i/report?type="+(t.in_reply_to?"comment":"post")+"&id="+t.id},commentFocus:function(t,e){var n=event.target.parentElement.parentElement.parentElement,o=n.getElements