1
0
Fork 0
pixelfed/public/js/search.js

1 line
8.3 KiB
JavaScript

!function(t){var s={};function e(r){if(s[r])return s[r].exports;var a=s[r]={i:r,l:!1,exports:{}};return t[r].call(a.exports,a,a.exports,e),a.l=!0,a.exports}e.m=t,e.c=s,e.d=function(t,s,r){e.o(t,s)||Object.defineProperty(t,s,{enumerable:!0,get:r})},e.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},e.t=function(t,s){if(1&s&&(t=e(t)),8&s)return t;if(4&s&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(e.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&s&&"string"!=typeof t)for(var a in t)e.d(r,a,function(s){return t[s]}.bind(null,a));return r},e.n=function(t){var s=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(s,"a",s),s},e.o=function(t,s){return Object.prototype.hasOwnProperty.call(t,s)},e.p="/",e(e.s=8)}({8:function(t,s,e){t.exports=e("EnJJ")},EnJJ:function(t,s,e){Vue.component("search-results",e("IpYn").default)},IpYn:function(t,s,e){"use strict";e.r(s);var r={props:["query","profileId"],data:function(){return{loading:!0,networkError:!1,results:{hashtags:[],profiles:[],statuses:[]},filters:{hashtags:!0,profiles:!0,statuses:!0}}},beforeMount:function(){this.fetchSearchResults()},mounted:function(){$(".search-bar input").val(this.query)},updated:function(){},methods:{fetchSearchResults:function(){var t=this;axios.get("/api/search",{params:{q:this.query,src:"metro",v:1}}).then(function(s){var e=s.data;t.results.hashtags=e.hashtags,t.results.profiles=e.profiles,t.results.statuses=e.posts,t.loading=!1}).catch(function(s){t.loading=!1})},followProfile:function(t){axios.post("/i/follow",{item:t}).then(function(t){window.location.href=window.location.href})}}},a=e("KHd+"),i=Object(a.a)(r,function(){var t=this,s=t.$createElement,e=t._self._c||s;return e("div",{staticClass:"container"},[t.loading?e("div",{staticClass:"pt-5 text-center"},[t._m(0)]):t._e(),t._v(" "),t.networkError?e("div",{staticClass:"pt-5 text-center"},[t._m(1)]):t._e(),t._v(" "),t.loading||t.networkError?t._e():e("div",{staticClass:"mt-5 row"},[e("div",{staticClass:"col-12 col-md-3 mb-4"},[t.results.hashtags||t.results.profiles||t.results.statuses?e("div",[e("p",{staticClass:"font-weight-bold"},[t._v("Filters")]),t._v(" "),e("div",{staticClass:"custom-control custom-checkbox"},[e("input",{directives:[{name:"model",rawName:"v-model",value:t.filters.hashtags,expression:"filters.hashtags"}],staticClass:"custom-control-input",attrs:{type:"checkbox",id:"filter1"},domProps:{checked:Array.isArray(t.filters.hashtags)?t._i(t.filters.hashtags,null)>-1:t.filters.hashtags},on:{change:function(s){var e=t.filters.hashtags,r=s.target,a=!!r.checked;if(Array.isArray(e)){var i=t._i(e,null);r.checked?i<0&&t.$set(t.filters,"hashtags",e.concat([null])):i>-1&&t.$set(t.filters,"hashtags",e.slice(0,i).concat(e.slice(i+1)))}else t.$set(t.filters,"hashtags",a)}}}),t._v(" "),e("label",{staticClass:"custom-control-label text-muted font-weight-light",attrs:{for:"filter1"}},[t._v("Show Hashtags")])]),t._v(" "),e("div",{staticClass:"custom-control custom-checkbox"},[e("input",{directives:[{name:"model",rawName:"v-model",value:t.filters.profiles,expression:"filters.profiles"}],staticClass:"custom-control-input",attrs:{type:"checkbox",id:"filter2"},domProps:{checked:Array.isArray(t.filters.profiles)?t._i(t.filters.profiles,null)>-1:t.filters.profiles},on:{change:function(s){var e=t.filters.profiles,r=s.target,a=!!r.checked;if(Array.isArray(e)){var i=t._i(e,null);r.checked?i<0&&t.$set(t.filters,"profiles",e.concat([null])):i>-1&&t.$set(t.filters,"profiles",e.slice(0,i).concat(e.slice(i+1)))}else t.$set(t.filters,"profiles",a)}}}),t._v(" "),e("label",{staticClass:"custom-control-label text-muted font-weight-light",attrs:{for:"filter2"}},[t._v("Show Profiles")])]),t._v(" "),e("div",{staticClass:"custom-control custom-checkbox"},[e("input",{directives:[{name:"model",rawName:"v-model",value:t.filters.statuses,expression:"filters.statuses"}],staticClass:"custom-control-input",attrs:{type:"checkbox",id:"filter3"},domProps:{checked:Array.isArray(t.filters.statuses)?t._i(t.filters.statuses,null)>-1:t.filters.statuses},on:{change:function(s){var e=t.filters.statuses,r=s.target,a=!!r.checked;if(Array.isArray(e)){var i=t._i(e,null);r.checked?i<0&&t.$set(t.filters,"statuses",e.concat([null])):i>-1&&t.$set(t.filters,"statuses",e.slice(0,i).concat(e.slice(i+1)))}else t.$set(t.filters,"statuses",a)}}}),t._v(" "),e("label",{staticClass:"custom-control-label text-muted font-weight-light",attrs:{for:"filter3"}},[t._v("Show Statuses")])])]):t._e()]),t._v(" "),e("div",{staticClass:"col-12 col-md-9"},[e("p",{staticClass:"h5 font-weight-bold"},[t._v("Showing results for "),e("i",[t._v(t._s(t.query))])]),t._v(" "),e("hr"),t._v(" "),t.filters.hashtags&&t.results.hashtags?e("div",{staticClass:"row mb-4"},[e("p",{staticClass:"col-12 font-weight-bold text-muted"},[t._v("Hashtags")]),t._v(" "),t._l(t.results.hashtags,function(s,r){return e("a",{staticClass:"col-12 col-md-3 mb-3",staticStyle:{"text-decoration":"none"},attrs:{href:s.url}},[e("div",{staticClass:"card card-body text-center"},[e("p",{staticClass:"lead mb-0 text-truncate text-dark",attrs:{"data-toggle":"tooltip",title:s.value}},[t._v("\n\t\t\t\t\t\t\t#"+t._s(s.value)+"\n\t\t\t\t\t\t")]),t._v(" "),e("p",{staticClass:"lead mb-0 small font-weight-bold text-dark"},[t._v("\n\t\t\t\t\t\t\t"+t._s(s.count)+" posts\n\t\t\t\t\t\t")])])])})],2):t._e(),t._v(" "),t.filters.profiles&&t.results.profiles?e("div",{staticClass:"row mb-4"},[e("p",{staticClass:"col-12 font-weight-bold text-muted"},[t._v("Profiles")]),t._v(" "),t._l(t.results.profiles,function(s,r){return e("a",{staticClass:"col-12 col-md-4 mb-3",staticStyle:{"text-decoration":"none"},attrs:{href:s.url}},[e("div",{staticClass:"card card-body text-center"},[e("p",{staticClass:"text-center"},[e("img",{staticClass:"rounded-circle box-shadow",attrs:{src:s.entity.thumb,width:"32px",height:"32px"}})]),t._v(" "),e("p",{staticClass:"font-weight-bold text-truncate text-dark"},[t._v("\n\t\t\t\t\t\t\t"+t._s(s.value)+"\n\t\t\t\t\t\t")]),t._v(" "),e("p",{staticClass:"mb-0 text-center"},[e("button",{class:[s.entity.following?"btn btn-secondary btn-sm py-1 font-weight-bold":"btn btn-primary btn-sm py-1 font-weight-bold"],on:{click:function(e){return t.followProfile(s.entity.id)}}},[t._v("\n\t\t\t\t\t\t\t \t"+t._s(s.entity.following?"Unfollow":"Follow")+"\n\t\t\t\t\t\t\t ")])])])])})],2):t._e(),t._v(" "),t.filters.statuses&&t.results.statuses?e("div",{staticClass:"row mb-4"},[e("p",{staticClass:"col-12 font-weight-bold text-muted"},[t._v("Statuses")]),t._v(" "),t._l(t.results.statuses,function(s,r){return e("a",{staticClass:"col-12 col-md-4 mb-3",staticStyle:{"text-decoration":"none"},attrs:{href:s.url}},[e("div",{staticClass:"card"},[e("img",{staticClass:"card-img-top img-fluid",staticStyle:{height:"180px"},attrs:{src:s.thumb}}),t._v(" "),e("div",{staticClass:"card-body text-center "},[e("p",{staticClass:"mb-0 small text-truncate font-weight-bold text-muted",domProps:{innerHTML:t._s(s.value)}})])])])})],2):t._e(),t._v(" "),t.results.hashtags||t.results.profiles||t.results.statuses?t._e():e("div",[e("p",{staticClass:"text-center lead"},[t._v("No results found!")])])])])])},[function(){var t=this.$createElement,s=this._self._c||t;return s("div",{staticClass:"spinner-border",attrs:{role:"status"}},[s("span",{staticClass:"sr-only"},[this._v("Loading…")])])},function(){var t=this.$createElement,s=this._self._c||t;return s("p",{staticClass:"lead font-weight-lighter"},[this._v("An error occured, results could not be loaded."),s("br"),this._v(" Please try again later.")])}],!1,null,"22d4526c",null);s.default=i.exports},"KHd+":function(t,s,e){"use strict";function r(t,s,e,r,a,i,l,o){var n,c="function"==typeof t?t.options:t;if(s&&(c.render=s,c.staticRenderFns=e,c._compiled=!0),r&&(c.functional=!0),i&&(c._scopeId="data-v-"+i),l?(n=function(t){(t=t||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(t=__VUE_SSR_CONTEXT__),a&&a.call(this,t),t&&t._registeredComponents&&t._registeredComponents.add(l)},c._ssrRegister=n):a&&(n=o?function(){a.call(this,this.$root.$options.shadowRoot)}:a),n)if(c.functional){c._injectStyles=n;var u=c.render;c.render=function(t,s){return n.call(s),u(t,s)}}else{var f=c.beforeCreate;c.beforeCreate=f?[].concat(f,n):[n]}return{exports:t,options:c}}e.d(s,"a",function(){return r})}});