| 1 |
jQuery(function(i){if(i("#acym__plugin__available__application").length>0){new Vue({directives:{infiniteScroll:infiniteScroll},el:"#acym__plugin__available__application",data:{allPlugins:[],displayedPlugins:[],search:acym_helper.getCookie("acym_available_plugins_search"),type:acym_helper.getCookie("acym_available_plugins_type"),level:acym_helper.getCookie("acym_available_plugins_level"),loading:!0,noPluginTodisplay:!1,typingTimer:"",doneTypingInterval:1e3,currentLevel:"",downloading:{},allPluginsInstalled:{},pageDisplay:1,busy:!1,installed:{}},mounted:function(){this.getAllPlugins().then(e=>{if(void 0!==(e=acym_helper.parseJson(e)).error)return acym_helperNotification.addNotification(e.error,"error"),!1;this.getAllPluginsInstalled().then(l=>{this.allPluginsInstalled=l.data,this.currentLevel=("undefined"==typeof ACYM_LEVEL?"":ACYM_LEVEL).toLowerCase(),this.allPlugins=e,e=e.map(i=>{i.description=i.description.replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g,"$1<br />")}),this.setStatus(),this.resetDisplay(),i('[name="acym__plugins__level"], [name="acym__plugins__type"]').select2({theme:"foundation",width:"100%"}),0===this.displayedPlugins.length&&(this.noPluginTodisplay=!0),this.loading=!1,setTimeout(()=>{this.$forceUpdate(),acym_helperTooltip.setTooltip()},400)})}),this.$el.addEventListener("touchend",this.loadMorePlugins)},methods:{getAllPlugins:()=>"joomla"===ACYM_CMS?i.get(ACYM_UPDATEME_API_URL+"public/addons"):"wordpress"===ACYM_CMS?Promise.resolve(JSON.stringify(window.acymailingAvailableAddons)):void 0,getAllPluginsInstalled:()=>acym_helper.post(ACYM_AJAX_URL,{ctrl:"plugins",task:"getAllPluginsAjax"}),download(i){if(this.downloading[i.file_name])return!0;this.downloading[i.file_name]=!0,this.downloading={...this.downloading};const e={ctrl:"plugins",task:"download",plugin:i};acym_helper.post(ACYM_AJAX_URL,e).then(e=>{if(e.error)return acym_helperNotification.addNotification(e.message,"error"),this.downloading[i.file_name]=!1,this.downloading={...this.downloading},!1;acym_helperNotification.addNotification(e.message,"info"),this.downloading[i.file_name]=!1,this.installed[i.file_name]=!0})},resetDisplay(){this.pageDisplay=1,this.fillDisplayPlugins()},fillDisplayPlugins(){this.displayedPlugins=this.filter().slice(0,18*this.pageDisplay),this.displayedPlugins=[...this.displayedPlugins]},rightLevel(i){return"starter"===i||("essential"===i&&-1!==["essential","enterprise"].indexOf(this.currentLevel)||"enterprise"===i&&"enterprise"===this.currentLevel)},ucfirst:i=>void 0===i?"":i.charAt(0).toUpperCase()+i.slice(1),setStatus(){for(let i in this.allPlugins)this.downloading[this.allPlugins[i].file_name]=!1,this.installed[this.allPlugins[i].file_name]=this.isInstalled(this.allPlugins[i])},isInstalled(i){return void 0!==this.allPluginsInstalled.find(e=>e.title===i.name)||void 0!==this.allPluginsInstalled.find(e=>e.folder_name===i.file_name)},filter(){return this.allPlugins.filter(i=>-1!==i.level.toLowerCase().indexOf(this.level.toLowerCase())&&-1!==i.category.toLowerCase().indexOf(this.type.toLowerCase())&&-1!==i.name.toLowerCase().indexOf(this.search.toLowerCase()))},loadMorePlugins(){this.pageDisplay++,this.fillDisplayPlugins()},imageUrl:i=>void 0===i?"":"joomla"===ACYM_CMS?ACYM_UPDATEME_API_URL+"public/addons/banner?file_name="+i:"wordpress"===ACYM_CMS?ACYM_MEDIA_URL+"images/plugins/"+i+".png":void 0,isOverflown(i){return void 0===this.$refs.plugins||void 0===this.$refs.plugins[i]?"":this.$refs.plugins[i].scrollHeight>this.$refs.plugins[i].clientHeight?"acym__plugins__card__params_desc__overflown":""}},watch:{displayedPlugins(i,e){this.noPluginTodisplay=0===this.displayedPlugins.length&&1!==e[0]},search(i){clearTimeout(this.typingTimer),document.cookie="acym_available_plugins_search="+i+";",""===i?this.resetDisplay():this.typingTimer=setTimeout(()=>{this.resetDisplay()},this.doneTypingInterval)},type(){document.cookie="acym_available_plugins_type="+this.type+";",this.resetDisplay()},level(){document.cookie="acym_available_plugins_level="+this.level+";",this.resetDisplay()}}})}}); |