pixelfed/public/js/search.js

1 line
7.6 KiB
JavaScript
Raw Normal View History

2019-06-16 23:08:04 +00:00
(window.webpackJsonp=window.webpackJsonp||[]).push([[10],{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 a={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}).catch(function(t){t.response.data.message&&swal("Error",t.response.data.message,"error")})}}},r=e("KHd+"),i=Object(r.a)(a,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,a=s.target,r=!!a.checked;if(Array.isArray(e)){var i=t._i(e,null);a.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",r)}}}),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,a=s.target,r=!!a.checked;if(Array.isArray(e)){var i=t._i(e,null);a.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",r)}}}),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,a=s.target,r=!!a.checked;if(Array.isArray(e)){var i=t._i(e,null);a.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",r)}}}),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