Learn more  » Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Bower components Debian packages RPM packages NuGet packages

jsarnowski / jsarnowski/jet-popup   php

Repository URL to install this package:

Version: 1.5.2 

/ js / jet-popup-admin.min.js

!function(e){"use strict";var t={init:function(){t.importInit(),e("#jet-popup-library-page")[0]&&t.presetLibraryInit(),e("#jet-popup-settings-page")[0]&&t.settingPageInit()},importInit:function(){var t=e('.page-title-action[href*="post-new.php?post_type=jet-popup"]'),a=e("#jet-popup-import-trigger");if(!e("#wpbody-content .page-title-action")[0])return!1;e("#wpbody-content").find(".page-title-action:last").after(a),t.on("click",function(e){e.preventDefault()});tippy([t[0]],{html:document.querySelector("#jet-popup-create-form"),arrow:!0,placement:"bottom-start",flipBehavior:"clockwise",trigger:"click",interactive:!0,hideOnClick:!0,theme:"jet-popup-light"}),tippy([a[0]],{html:document.querySelector("#jet-popup-import-form"),arrow:!0,placement:"bottom-start",flipBehavior:"clockwise",trigger:"click",interactive:!0,hideOnClick:!0,theme:"jet-popup-light"})},presetLibraryInit:function(){Vue.config.devtools=!0,Vue.component("preset-list",{template:"#preset-list-template",props:{presets:Array},methods:{changePage:function(e){console.log(changePage)}}}),Vue.component("preset-item",{template:"#preset-item-template",props:{presetId:Number,title:String,thumbUrl:String,category:Array,categoryNames:Array,install:Number,required:Array,excerpt:String,details:Array,permalink:String},data:function(){return{modalShow:!1,requiredPluginData:window.jetPopupData.requiredPluginData}},computed:{categoryName:function(){var e="None";return 0!==this.categoryNames.length&&(e="",this.categoryNames.forEach(function(t,a){e+=t}),e=this.categoryNames.join(", ")),e},requiredPlugins:function(){var e=[],t=this.requiredPluginData;return this.required.forEach(function(a,i){t.hasOwnProperty(a)&&e.push(t[a])}),e}},methods:{openModal:function(){this.modalShow=!0,e.$emit("openIntallPopup",this.presetId)}}}),Vue.component("presetlibrary",{template:"#preset-library-template",data:function(){return{spinnerShow:!0,presetsLoaded:!1,presetsLoadedError:!1,categoriesLoaded:!1,presetsData:[],categoryData:[],activeCategories:[],presetsLength:!1,installPopupVisible:!1,inactiveLicenseVisible:!1,page:1,perPage:6,preset:!1,filterBy:"date",filterByOptions:[{label:"Date",value:"date"},{label:"Name",value:"name"},{label:"Popular",value:"popular"}]}},mounted:function(){var t=window.jetPopupData.libraryPresetsUrl,a=window.jetPopupData.libraryPresetsCategoryUrl,i=[],r=[],s=this;axios.get(t).then(function(e){var t=e.data;if(t.success){for(var a in t.presets){var i=t.presets[a];r.push({id:i.id,title:i.title,thumb:i.thumb,category:i.category,categoryNames:i.category_names,order:i.order,install:+i.install,required:i.required,excerpt:i.excerpt,details:i.details,permalink:i.permalink})}s.presetsData=r,s.spinnerShow=!1,s.presetsLoaded=!0}else s.spinnerShow=!1,s.presetsLoadedError=!0}).catch(function(e){s.spinnerShow=!1,s.presetsLoadedError=!0,s.presetsData=[]}),axios.get(a).then(function(e){var t=e.data;if(t.success){for(var a in t.categories)i.push({id:a,label:t.categories[a],state:!1});s.categoryData=i}s.categoriesLoaded=!0}).catch(function(e){s.categoryData=[]}),e.$on("openIntallPopup",function(e){s.preset=e,"true"===window.jetPopupData.pluginActivated?s.installPopupVisible=!0:s.inactiveLicenseVisible=!0})},computed:{presetList:function(){var e=this.page,t=this.perPage,a=[];return a=this.presetsData.filter((e,t)=>{var a=!1;for(var i in a=this.categoryData.every(e=>"false"===e.state||!1===e.state),this.categoryData)if("true"===this.categoryData[i].state&&e.category.includes(this.categoryData[i].id)){a=!0;break}return a}),this.presetsLength=a.length,a=a.filter((a,i)=>{var r=!1,s=(e-1)*t;return i>=s&&i<s+t&&(r=!0),r})},isShowPagination:function(){return this.presetsLength>this.perPage}},methods:{filterByCategory:function(){this.page=1},filterByHandler:function(){switch(this.page=1,this.filterBy){case"date":this.presetsData.sort(function(e,t){return e.order-t.order});break;case"name":this.presetsData.sort(function(e,t){var a=e.title.toLowerCase(),i=t.title.toLowerCase();return a>i?1:a<i?-1:0});break;case"popular":this.presetsData.sort(function(e,t){return t.install-e.install})}},changePage:function(e){this.page=e},createPopup:function(){window.location.href=window.jetPopupData.createPopupLink+"&preset="+this.preset},activateLicense:function(){window.location.href=window.jetPopupData.licenseActivationLink}}});var e=new Vue;new Vue({el:"#jet-popup-library-page"})},settingPageInit:function(){Vue.config.devtools=!0,Vue.component("mailchimp-list-item",{template:"#mailchimp-list-item-template",props:{list:Object,apikey:String},data:function(){return{mergeFieldsStatusLoading:!1}},computed:{isMergeFields:function(){return!(!this.list.hasOwnProperty("mergeFields")||jQuery.isEmptyObject(this.list.mergeFields))}},methods:{getMergeFields:function(){var t=this;jQuery.ajax({type:"POST",url:ajaxurl,data:{action:"get_mailchimp_list_merge_fields",apikey:this.apikey,listid:this.list.id},beforeSend:function(e,a){t.mergeFieldsStatusLoading=!0},error:function(e,t,a){},success:function(a,i,r){switch(t.mergeFieldsStatusLoading=!1,a.type){case"success":t.$CXNotice.add({message:a.desc,type:"success",duration:3e3}),e.$emit("updateListMergeFields",a.request);break;case"error":t.$CXNotice.add({message:a.desc,type:"error",duration:3e3})}}})}}}),Vue.component("settingsform",{template:"#settings-form-template",data:function(){return{saveStatusLoading:!1,syncStatusLoading:!1,mergeFieldsStatusLoading:!1,collapse:"mailChimpPanel",settingsData:{apikey:""},mailchimpAccountData:{},mailchimpListsData:{}}},computed:{isMailchimpAccountData:function(){return!jQuery.isEmptyObject(this.mailchimpAccountData)},isMailchimpListsData:function(){return!jQuery.isEmptyObject(this.mailchimpListsData)}},created:function(){var t=this,a=window.jetPopupAdminData.settings,i=window.jetPopupAdminData.mailchimpApiData;if(this.settingsData=a,i.hasOwnProperty(a.apikey)){var r=i[a.apikey];if(r.hasOwnProperty("account")){var s=r.account;this.mailchimpAccountData={account_id:s.account_id,username:s.username||"-",first_name:s.first_name||"-",last_name:s.last_name||"-",avatar_url:s.avatar_url}}if(r.hasOwnProperty("lists")){var n=r.lists,o={};if(!jQuery.isEmptyObject(n))for(var c in n){var p=n[c].info,u=n[c].merge_fields||[],l={};u.forEach(function(e,t,a){l[e.tag]=e.name}),o[c]={id:p.id,name:p.name,memberCount:p.stats.member_count,doubleOptin:p.double_optin,dateCreated:p.date_created,mergeFields:l}}this.mailchimpListsData=o}}e.$on("updateListMergeFields",function(e){var a=e.list_id,i=e.merge_fields,r={};for(c in i){var s=i[c];r[s.tag]=s.name}Vue.set(t.mailchimpListsData[a],"mergeFields",r)})},methods:{mailchimpSync:function(){var e=this;jQuery.ajax({type:"POST",url:ajaxurl,data:{action:"get_mailchimp_user_data",apikey:this.settingsData.apikey},beforeSend:function(t,a){e.syncStatusLoading=!0},error:function(e,t){},success:function(t,a,i){switch(t.type){case"success":var r=t.request;e.$CXNotice.add({message:t.desc,type:"success",duration:3e3}),e.mailchimpAccountData={account_id:r.account_id,username:r.username||"-",first_name:r.first_name||"-",last_name:r.last_name||"-",avatar_url:r.avatar_url},e.mailchimpSyncLists();break;case"error":e.syncStatusLoading=!1,e.$CXNotice.add({message:t.desc,type:"error",duration:3e3})}}})},mailchimpSyncLists:function(){var e=this;jQuery.ajax({type:"POST",url:ajaxurl,data:{action:"get_mailchimp_lists",apikey:this.settingsData.apikey},beforeSend:function(t,a){e.syncStatusLoading=!0},error:function(e,t){},success:function(t,a,i){switch(e.syncStatusLoading=!1,t.type){case"success":e.$CXNotice.add({message:t.desc,type:"success",duration:3e3});var r=t.request;if(r.hasOwnProperty("lists")){var s=r.lists,n={};for(var o in s){var c=s[o];n[c.id]={id:c.id,name:c.name,memberCount:c.stats.member_count,doubleOptin:c.double_optin,dateCreated:c.date_created}}e.mailchimpListsData=n}break;case"error":e.$CXNotice.add({message:t.desc,type:"error",duration:3e3})}}})},saveSettings:function(){var e=this,t={action:"jet_popup_save_settings",data:this.settingsData};jQuery.ajax({type:"POST",url:ajaxurl,data:t,beforeSend:function(t,a){e.saveStatusLoading=!0},error:function(e,t,a){},success:function(t,a,i){switch(e.saveStatusLoading=!1,t.type){case"success":e.$CXNotice.add({message:t.desc,type:"success",duration:3e3});break;case"error":e.$CXNotice.add({message:t.desc,type:"error",duration:3e3})}}})}}});var e=new Vue;new Vue({el:"#jet-popup-settings-page"})}};t.init()}(jQuery);