Initial Commit

This commit is contained in:
David Stone
2024-11-30 18:24:12 -07:00
commit e8f7955c1c
5432 changed files with 1397750 additions and 0 deletions

150
assets/js/addons.js Normal file
View File

@ -0,0 +1,150 @@
/* global Vue, wu_addons, ajaxurl, _ */
(function($) {
const search_addon = new Vue({
el: '#search-addons',
data: {
search: wu_addons.search,
},
});
const wu_main_addon_app = new Vue({
el: '#wu-addon',
data() {
return {
loading: true,
category: wu_addons.category,
addons: [],
};
},
mounted() {
this.fetch_addons_list();
},
computed: {
search() {
return search_addon.search;
},
i18n() {
return window.wu_addons.i18n;
},
categories() {
let categories = [];
_.each(this.addons, function(addon) {
categories = categories.concat(addon.categories);
});
return _.unique(categories);
},
addons_list() {
const app = this;
return _.filter(app.addons, function(addon, slug) {
addon.slug = slug;
if (app.category !== 'all' && ! _.contains(addon.categories.map((item) => item.toLowerCase()), app.category.toLowerCase())) {
return false;
} // end if;
if (! app.search) {
return true;
} // end if;
const search = [
addon.slug,
addon.name,
addon.categories,
addon.description,
];
return search.join('').toLowerCase().indexOf(app.search.toLowerCase()) > -1;
});
},
},
methods: {
fetch_addons_list() {
const app = this;
$.ajax({
method: 'GET',
url: ajaxurl,
data: {
action: 'serve_addons_list',
},
success(data) {
app.addons = data.data;
app.loading = false;
},
});
},
},
});
new Vue({
el: '.wp-heading-inline',
data: {},
computed: {
count() {
return wu_main_addon_app.addons_list.length;
},
},
});
new Vue({
el: '#addons-menu',
data: {},
methods: {
set_category(category) {
this.main_app.category = category;
const url = new URL(window.location.href);
url.searchParams.set('tab', category); // setting your param
history.pushState({}, null, url);
},
},
computed: {
main_app() {
return wu_main_addon_app;
},
category() {
return wu_main_addon_app.category;
},
},
});
}(jQuery));

1
assets/js/addons.min.js vendored Normal file
View File

@ -0,0 +1 @@
!function(e){const a=new Vue({el:"#search-addons",data:{search:wu_addons.search}}),t=new Vue({el:"#wu-addon",data:()=>({loading:!0,category:wu_addons.category,addons:[]}),mounted(){this.fetch_addons_list()},computed:{search:()=>a.search,i18n:()=>window.wu_addons.i18n,categories(){let e=[];return _.each(this.addons,(function(a){e=e.concat(a.categories)})),_.unique(e)},addons_list(){const e=this;return _.filter(e.addons,(function(a,t){if(a.slug=t,"all"!==e.category&&!_.contains(a.categories.map((e=>e.toLowerCase())),e.category.toLowerCase()))return!1;if(!e.search)return!0;return[a.slug,a.name,a.categories,a.description].join("").toLowerCase().indexOf(e.search.toLowerCase())>-1}))}},methods:{fetch_addons_list(){const a=this;e.ajax({method:"GET",url:ajaxurl,data:{action:"serve_addons_list"},success(e){a.addons=e.data,a.loading=!1}})}}});new Vue({el:".wp-heading-inline",data:{},computed:{count:()=>t.addons_list.length}}),new Vue({el:"#addons-menu",data:{},methods:{set_category(e){this.main_app.category=e;const a=new URL(window.location.href);a.searchParams.set("tab",e),history.pushState({},null,a)}},computed:{main_app:()=>t,category:()=>t.category}})}(jQuery);

View File

@ -0,0 +1,43 @@
(function($) {
$(document).ready(function() {
/**
* Prevent notices from jumping around.
*/
$('.notice.wu-hidden').removeClass('wu-hidden');
/**
* Dismisses a WP Ultimo notice
*
* When a notice is dismissable, we save the key of that notice after the dismiss
* button is clicked to avoid showing that notice again for that customer in the future.
*/
$('.notice.wu-admin-notice').on('click', '.notice-dismiss', function(e) {
e.preventDefault();
const $this = $(this);
const $notice = $this.parents('.notice');
if ($notice.find('[name="notice_id"]').val()) {
$.ajax({
method: 'post',
// eslint-disable-next-line no-undef
url: ajaxurl,
data: {
action: 'wu_dismiss_admin_notice',
nonce: $notice.find('[name="nonce"]').val(),
notice_id: $notice.find('[name="notice_id"]').val(),
},
});
} // end if;
});
});
}(jQuery));

1
assets/js/admin-notices.min.js vendored Normal file
View File

@ -0,0 +1 @@
!function(n){n(document).ready((function(){n(".notice.wu-hidden").removeClass("wu-hidden"),n(".notice.wu-admin-notice").on("click",".notice-dismiss",(function(i){i.preventDefault();const e=n(this).parents(".notice");e.find('[name="notice_id"]').val()&&n.ajax({method:"post",url:ajaxurl,data:{action:"wu_dismiss_admin_notice",nonce:e.find('[name="nonce"]').val(),notice_id:e.find('[name="notice_id"]').val()}})}))}))}(jQuery);

33
assets/js/admin-screen.js Normal file
View File

@ -0,0 +1,33 @@
/* eslint-disable max-len */
/* global wu_admin_screen, wu_block_ui */
(function($) {
$(document).ready(function() {
$('body').on('click', '#wu-admin-screen-customize', function() {
wu_block_ui('#wpcontent');
});
const is_edit_mode = $('body').hasClass('wu-customize-admin-screen');
let $elem = `<a id="wu-admin-screen-customize" href="${ wu_admin_screen.customize_link }" class="button show-settings">${ wu_admin_screen.i18n.customize_label }</button>`;
const $page_elem = `<a title="${ wu_admin_screen.i18n.page_customize_label }" id="wu-admin-screen-page-customize" href="${ wu_admin_screen.page_customize_link }" class="wubox button show-settings">${ wu_admin_screen.i18n.page_customize_label }</button>`;
if (is_edit_mode) {
$elem = `<a id="wu-admin-screen-customize" href="${ wu_admin_screen.close_link }" class="button show-settings wu-font-medium"><span class="wu-text-sm wu-align-text-bottom wu-text-red-500 wu-mr-2 wu--ml-1 dashicons-wu-circle-with-cross"></span>${ wu_admin_screen.i18n.close_label }</button>`;
} else {
$($page_elem).prependTo('#screen-options-link-wrap');
} // end if;
$($elem).appendTo('#screen-options-link-wrap');
});
}(jQuery));

1
assets/js/admin-screen.min.js vendored Normal file
View File

@ -0,0 +1 @@
!function(e){e(document).ready((function(){e("body").on("click","#wu-admin-screen-customize",(function(){wu_block_ui("#wpcontent")}));const n=e("body").hasClass("wu-customize-admin-screen");let s=`<a id="wu-admin-screen-customize" href="${wu_admin_screen.customize_link}" class="button show-settings">${wu_admin_screen.i18n.customize_label}</button>`;const t=`<a title="${wu_admin_screen.i18n.page_customize_label}" id="wu-admin-screen-page-customize" href="${wu_admin_screen.page_customize_link}" class="wubox button show-settings">${wu_admin_screen.i18n.page_customize_label}</button>`;n?s=`<a id="wu-admin-screen-customize" href="${wu_admin_screen.close_link}" class="button show-settings wu-font-medium"><span class="wu-text-sm wu-align-text-bottom wu-text-red-500 wu-mr-2 wu--ml-1 dashicons-wu-circle-with-cross"></span>${wu_admin_screen.i18n.close_label}</button>`:e(t).prependTo("#screen-options-link-wrap"),e(s).appendTo("#screen-options-link-wrap")}))}(jQuery);

16
assets/js/admin.js Normal file
View File

@ -0,0 +1,16 @@
/* global wu_on_load */
(function($) {
// eslint-disable-next-line no-undef
wu = {
tables: {},
configs: {},
};
$(document).ready(function() {
wu_on_load();
});
}(jQuery));

1
assets/js/admin.min.js vendored Normal file
View File

@ -0,0 +1 @@
!function(n){wu={tables:{},configs:{}},n(document).ready((function(){wu_on_load()}))}(jQuery);

3
assets/js/app.js Normal file
View File

@ -0,0 +1,3 @@
(() => {
"use strict";
})()

3
assets/js/app.min.js vendored Normal file
View File

@ -0,0 +1,3 @@
(() => {
"use strict";
})()

View File

@ -0,0 +1,24 @@
/* global wubox */
wp.hooks.addAction('wu_add_checkout_form_field_mounted', 'nextpress/wp-ultimo', function(data) {
if (data.type === '') {
wubox.width(600);
} // end if;
});
wp.hooks.addAction('wu_add_checkout_form_field_changed', 'nextpress/wp-ultimo', function(val, data) {
if (data.type === '') {
wubox.width(600);
} else {
wubox.width(400);
}// end if;
});

View File

@ -0,0 +1 @@
wp.hooks.addAction("wu_add_checkout_form_field_mounted","nextpress/wp-ultimo",(function(o){""===o.type&&wubox.width(600)})),wp.hooks.addAction("wu_add_checkout_form_field_changed","nextpress/wp-ultimo",(function(o,t){""===t.type?wubox.width(600):wubox.width(400)}));

View File

@ -0,0 +1,281 @@
/* global vuedraggable, Vue, wu_checkout_forms_editor_app, wu_checkout_form, _, ajaxurl, wu_initialize_tooltip */
(function($) {
$(document).ready(function() {
const draggable_table = {
components: {
vuedraggable,
},
template: '#wu-table',
props: ['list', 'headers', 'step_name'],
name: 'wu-draggable-table',
data() {
return {
delete_field_id: '',
};
},
methods: {
remove_field(field) {
wu_checkout_forms_editor_app.remove_field(this.step_name, field);
this.delete_field_id = '';
},
},
};
wu_checkout_forms_editor_app = new Vue({
el: '#wu-checkout-editor-app',
name: 'CheckoutEditor',
data() {
return Object.assign({}, {
dragging: false,
search: '',
delete_step_id: '',
preview_error: false,
preview: false,
loading_preview: false,
preview_content: '',
iframe_preview_url: '',
}, wu_checkout_form);
},
components: {
vuedraggable,
'wu-draggable-table': draggable_table,
},
computed: {
field_count() {
return _.reduce(this.steps, function(memo, step) {
return memo + step.fields.length;
}, 0);
},
},
watch: {
steps: {
handler() {
this.update_session();
},
deep: true,
},
},
mounted() {
this.update_session();
},
methods: {
get_preview(type = null) {
if (type === null) {
this.preview = ! this.preview;
} // end if;
if (this.preview) {
this.loading_preview = true;
const that = this;
// eslint-disable-next-line max-len
that.iframe_preview_url = that.register_page + '?action=wu_generate_checkout_form_preview' + '&form_id=' + that.form_id + '&type=' + type + '&uniq=' + (Math.random() * 1000);
$('#wp-ultimo-checkout-preview').on('load', function() {
that.loading_preview = false;
setTimeout(() => {
const height = document.getElementById('wp-ultimo-checkout-preview').contentWindow.document.body.scrollHeight;
$('#wp-ultimo-checkout-preview').animate({
height,
});
}, 1000);
});
}
// eslint-disable-next-line no-console
console.log('no preview');
// end if;
},
add_step(data, cb = null) {
const existing_step = data.original_id ? this.find_step(data.original_id) : this.find_step(data.id) ;
delete data.original_id;
if (typeof existing_step !== 'undefined') {
const index = _.indexOf(this.steps, existing_step);
data = Object.assign({}, existing_step, data);
data.fields = existing_step.fields;
Vue.set(this.steps, index, data);
} else {
this.steps.push(data);
} // end if;
this.$nextTick(function() {
if (typeof cb === 'function') {
cb();
this.scroll_to(`wp-ultimo-list-table-${ data.id }`);
} // end if;
});
},
add_field(data, cb = null) {
const step = _.findWhere(this.steps, {
id: data.step,
});
let existing_field = this.find_field(data.step, data.id);
if (typeof existing_field === 'undefined') {
existing_field = this.find_field(data.step, data.original_id);
delete data.original_id;
} // end if;
if (typeof existing_field !== 'undefined') {
const index = _.indexOf(step.fields, existing_field);
Vue.set(step.fields, index, data);
} else {
step.fields.push(data);
} // end if;
this.$nextTick(function() {
if (typeof cb === 'function') {
cb();
this.scroll_to(`wp-ultimo-field-${ data.id }`);
} // end if;
});
},
scroll_to(element_id) {
this.$nextTick(function() {
setTimeout(() => {
const element = document.getElementById(element_id);
element.scrollIntoView({ behavior: 'smooth', block: 'center', inline: 'nearest' });
}, 500);
});
},
find_step(step_name) {
return _.findWhere(this.steps, {
id: step_name,
});
},
find_field(step_name, field_name) {
const step = _.findWhere(this.steps, {
id: step_name,
});
const field = _.findWhere(step.fields, {
id: field_name,
});
return field;
},
remove_step(step_name) {
this.steps = _.reject(this.steps, function(item) {
return item.id === step_name;
});
this.delete_step_id = '';
},
remove_field(step_name, field_name) {
const step = _.findWhere(this.steps, {
id: step_name,
});
step.fields = _.reject(step.fields, function(item) {
return item.id === field_name;
});
},
update_session() {
wu_initialize_tooltip();
const that = this;
$.ajax({
method: 'post',
url: ajaxurl,
data: {
action: 'wu_save_editor_session',
settings: that.steps,
form_id: that.form_id,
},
success() { },
});
},
},
});
});
}(jQuery));

View File

@ -0,0 +1 @@
!function(e){e(document).ready((function(){const t={components:{vuedraggable:vuedraggable},template:"#wu-table",props:["list","headers","step_name"],name:"wu-draggable-table",data:()=>({delete_field_id:""}),methods:{remove_field(e){wu_checkout_forms_editor_app.remove_field(this.step_name,e),this.delete_field_id=""}}};wu_checkout_forms_editor_app=new Vue({el:"#wu-checkout-editor-app",name:"CheckoutEditor",data:()=>Object.assign({},{dragging:!1,search:"",delete_step_id:"",preview_error:!1,preview:!1,loading_preview:!1,preview_content:"",iframe_preview_url:""},wu_checkout_form),components:{vuedraggable:vuedraggable,"wu-draggable-table":t},computed:{field_count(){return _.reduce(this.steps,(function(e,t){return e+t.fields.length}),0)}},watch:{steps:{handler(){this.update_session()},deep:!0}},mounted(){this.update_session()},methods:{get_preview(t=null){if(null===t&&(this.preview=!this.preview),this.preview){this.loading_preview=!0;const i=this;i.iframe_preview_url=i.register_page+"?action=wu_generate_checkout_form_preview&form_id="+i.form_id+"&type="+t+"&uniq="+1e3*Math.random(),e("#wp-ultimo-checkout-preview").on("load",(function(){i.loading_preview=!1,setTimeout((()=>{const t=document.getElementById("wp-ultimo-checkout-preview").contentWindow.document.body.scrollHeight;e("#wp-ultimo-checkout-preview").animate({height:t})}),1e3)}))}console.log("no preview")},add_step(e,t=null){const i=e.original_id?this.find_step(e.original_id):this.find_step(e.id);if(delete e.original_id,void 0!==i){const t=_.indexOf(this.steps,i);(e=Object.assign({},i,e)).fields=i.fields,Vue.set(this.steps,t,e)}else this.steps.push(e);this.$nextTick((function(){"function"==typeof t&&(t(),this.scroll_to(`wp-ultimo-list-table-${e.id}`))}))},add_field(e,t=null){const i=_.findWhere(this.steps,{id:e.step});let s=this.find_field(e.step,e.id);if(void 0===s&&(s=this.find_field(e.step,e.original_id),delete e.original_id),void 0!==s){const t=_.indexOf(i.fields,s);Vue.set(i.fields,t,e)}else i.fields.push(e);this.$nextTick((function(){"function"==typeof t&&(t(),this.scroll_to(`wp-ultimo-field-${e.id}`))}))},scroll_to(e){this.$nextTick((function(){setTimeout((()=>{document.getElementById(e).scrollIntoView({behavior:"smooth",block:"center",inline:"nearest"})}),500)}))},find_step(e){return _.findWhere(this.steps,{id:e})},find_field(e,t){const i=_.findWhere(this.steps,{id:e});return _.findWhere(i.fields,{id:t})},remove_step(e){this.steps=_.reject(this.steps,(function(t){return t.id===e})),this.delete_step_id=""},remove_field(e,t){const i=_.findWhere(this.steps,{id:e});i.fields=_.reject(i.fields,(function(e){return e.id===t}))},update_session(){wu_initialize_tooltip();e.ajax({method:"post",url:ajaxurl,data:{action:"wu_save_editor_session",settings:this.steps,form_id:this.form_id},success(){}})}}})}))}(jQuery);

966
assets/js/checkout.js Normal file
View File

@ -0,0 +1,966 @@
/* global Vue, moment, _, wu_checkout, pwsL10n, wu_checkout_form, wu_create_cookie, wu_listen_to_cookie_change */
(function ($, hooks, _) {
/*
* Remove the pre-flight parameter.
*/
if (window.history.replaceState) {
window.history.replaceState(null, null, wu_checkout.baseurl);
} // end if;
/*
* Sets default template.
*/
hooks.addAction('wu_on_create_order', 'nextpress/wp-ultimo', function (checkout, data) {
if (typeof data.order.extra.template_id !== 'undefined') {
checkout.template_id = data.order.extra.template_id;
} // end if;
});
/*
* Handle auto-submittable fields.
*
* Some fields are auto-submittable if they are the one relevant
* field on a checkout step.
*/
hooks.addAction('wu_checkout_loaded', 'nextpress/wp-ultimo', function (checkout) {
/*
* The checkout sets the auto submittable field as a global variable
*/
if (typeof window.wu_auto_submittable_field !== 'undefined' && window.wu_auto_submittable_field) {
const options = {
deep: true,
};
checkout.$watch(window.wu_auto_submittable_field, function () {
jQuery(this.$el).submit();
}, options);
} // end if;
});
/*
* Sets up the cookie listener for template selection.
*/
hooks.addAction('wu_checkout_loaded', 'nextpress/wp-ultimo', function (checkout) {
/*
* Resets the template selection cookie.
*/
wu_create_cookie('wu_template', '');
/*
* Resets the selected products cookie.
*/
wu_create_cookie('wu_selected_products', '');
/*
* Listens for changes and set the template if one is detected.
*/
wu_listen_to_cookie_change('wu_template', function (value) {
checkout.template_id = value;
});
});
/**
* Allows for cross-sells
*/
$(document).on('click', '[href|="#wu-checkout-add"]', function (event) {
event.preventDefault();
const el = $(this);
const product_slug = el.attr('href').split('#').pop().replace('wu-checkout-add-', '');
if (typeof wu_checkout_form !== 'undefined') {
if (wu_checkout_form.products.indexOf(product_slug) === -1) {
wu_checkout_form.add_product(product_slug);
el.html(wu_checkout.i18n.added_to_order);
} // end if;
} // end if;
});
/**
* Reload page when history back button was pressed
*/
window.addEventListener('pageshow', function (event) {
if (event.persisted && this.window.wu_checkout_form) {
this.window.wu_checkout_form.unblock();
} // end if;
});
/**
* Setup
*/
$(document).ready(function () {
/*
* Prevent app creation when vue is not available.
*/
if (typeof window.Vue === 'undefined') {
return;
} // end if;
Object.defineProperty(Vue.prototype, '$moment', { value: moment });
const maybe_cast_to_int = function (value) {
return isNaN(value) ? value : parseInt(value, 10);
};
const initial_data = {
plan: maybe_cast_to_int(wu_checkout.plan),
errors: [],
order: wu_checkout.order,
products: _.map(wu_checkout.products, maybe_cast_to_int),
template_id: wu_checkout.template_id,
template_category: '',
gateway: wu_checkout.gateway,
request_billing_address: wu_checkout.request_billing_address,
country: wu_checkout.country,
state: '',
city: '',
site_url: wu_checkout.site_url,
site_domain: wu_checkout.site_domain,
is_subdomain: wu_checkout.is_subdomain,
discount_code: '',
toggle_discount_code: 0,
payment_method: '',
username: '',
payment_id: wu_checkout.payment_id,
membership_id: wu_checkout.membership_id,
cart_type: 'new',
auto_renew: 1,
duration: wu_checkout.duration,
duration_unit: wu_checkout.duration_unit,
prevent_submission: false,
valid_password: true,
stored_templates: {},
state_list: [],
city_list: [],
labels: {},
};
hooks.applyFilters('wu_before_form_init', initial_data);
if (!jQuery('#wu_form').length) {
return;
} // end if;
/**
* ColorPicker Component
*/
Vue.component('colorPicker', {
props: ['value'],
template: '<input type="text">',
mounted() {
const vm = this;
$(this.$el)
.val(this.value)
// WordPress color picker
.wpColorPicker({
width: 200,
defaultColor: this.value,
change(event, ui) {
// emit change event on color change using mouse
vm.$emit('input', ui.color.toString());
},
});
},
watch: {
value(value) {
// update value
$(this.$el).wpColorPicker('color', value);
},
},
destroyed() {
$(this.$el).off().wpColorPicker('destroy'); // (!) Not tested
},
});
/**
* Declare the dynamic content for Vue.
*/
const dynamic = {
functional: true,
template: '#dynamic',
props: ['template'],
render(h, context) {
const template = context.props.template;
const component = template ? { template } : '<div>nbsp;</div>';
return h(component);
},
};
// eslint-disable-next-line no-unused-vars
window.wu_checkout_form = new Vue({
el: '#wu_form',
data: initial_data,
directives: {
init: {
bind(el, binding, vnode) {
vnode.context[binding.arg] = binding.value;
},
},
},
components: {
dynamic,
},
computed: {
hooks() {
return wp.hooks;
},
unique_products() {
return _.uniq(this.products, false, (item) => parseInt(item, 10));
},
},
methods: {
debounce(fn) {
return _.debounce(fn, 200, true);
},
open_url(url, target = '_blank') {
window.open(url, target);
},
get_template(template, data) {
if (typeof data.id === 'undefined') {
data.id = 'default';
} // end if;
const template_name = template + '/' + data.id;
if (typeof this.stored_templates[template_name] !== 'undefined') {
return this.stored_templates[template_name];
} // end if;
const template_data = this.hooks.applyFilters('wu_before_template_fetch', {
duration: this.duration,
duration_unit: this.duration_unit,
products: this.products,
...data,
}, this);
this.fetch_template(template, template_data);
return '<div class="wu-p-4 wu-bg-gray-100 wu-text-center wu-my-2 wu-rounded">' + wu_checkout.i18n.loading + '</div>';
},
reset_templates(to_clear) {
if (typeof to_clear === 'undefined') {
this.stored_templates = {};
return;
}
const new_list = {};
_.forEach(this.stored_templates, function (item, key) {
const type = key.toString().substr(0, key.toString().indexOf('/'));
if (_.contains(to_clear, type) === false) {
new_list[key] = item;
} // end if;
});
this.stored_templates = new_list;
},
fetch_template(template, data) {
const that = this;
if (typeof data.id === 'undefined') {
data.id = 'default';
} // end if;
this.request('wu_render_field_template', {
template,
attributes: data,
}, function (results) {
const template_name = template + '/' + data.id;
if (results.success) {
Vue.set(that.stored_templates, template_name, results.data.html);
} else {
Vue.set(that.stored_templates, template_name, '<div>' + results.data[0].message + '</div>');
} // end if;
});
},
go_back() {
// eslint-disable-next-line no-console
console.log('Going back...');
this.block();
window.history.back();
},
set_prevent_submission(value) {
this.$nextTick(function () {
this.prevent_submission = value;
});
},
remove_product(product_id, product_slug) {
this.products = _.filter(this.products, function (item) {
// eslint-disable-next-line eqeqeq
return item != product_id && item != product_slug;
});
},
add_plan(product_id) {
if (this.plan) {
this.remove_product(this.plan);
} // end if;
this.plan = product_id;
this.add_product(product_id);
},
add_product(product_id) {
this.products.push(product_id);
},
has_product(product_id) {
return this.products.indexOf(product_id) > -1 || this.products.indexOf(parseInt(product_id, 10)) > -1;
},
wu_format_money(value) {
return window.wu_format_money(value);
},
filter_for_request(data, request_type = '') {
const filter_list = this.hooks.doAction('wu_filter_for_request', [
'stored_templates',
], data, request_type);
const filtered_list = _.omit(data, filter_list);
return filtered_list;
},
create_order() {
/*
* Bail if there is no order summary to update.
*/
if (!jQuery('#wu-order-summary-content').length) {
return;
} // end if;
this.block();
this.order = false;
const that = this;
const _request = this.debounce(this.request);
const data = { ...this.$data };
delete data.stored_templates;
delete data.state_list;
delete data.city_list;
delete data.labels;
_request('wu_create_order', this.filter_for_request(data, 'wu_create_order'), function (results) {
that.order = results.data.order;
that.state_list = results.data.states;
that.city_list = results.data.cities;
that.labels = results.data.labels;
that.cart_type = results.data.order.type;
that.errors = results.data.order.errors;
that.hooks.doAction('wu_on_create_order', that, results.data);
if (results.data.order.url) {
try {
// history.pushState({}, null, wu_checkout.baseurl + results.data.order.url);
} catch (err) {
// eslint-disable-next-line no-console
console.warn('Browser does not support pushState.', err);
} // end try;
} // ed if;
that.unblock();
}, this.handle_errors);
},
get_errors() {
const result = this.errors.map(function (e) {
return e.message;
});
return result.length > 0 ? result : false;
},
get_error(field) {
const result = this.errors.filter(function (e) {
return e.code === field;
});
return result.length > 0 ? result[0] : false;
},
form_success(results) {
if (!_.isEmpty(results.data)) {
this.hooks.doAction('wu_on_form_success', this, results.data);
const fields = results.data.gateway.data;
fields.payment_id = results.data.payment_id;
fields.membership_id = results.data.membership_id;
fields.cart_type = results.data.cart_type;
// Append the hidden fields
jQuery.each(Object.assign({}, fields), function (index, value) {
const hidden = document.createElement('input');
hidden.type = 'hidden';
hidden.name = index;
hidden.value = value;
jQuery('#wu_form').append(hidden);
});
} // end if;
},
validate_form() {
this.errors = [];
const form_data_obj = jQuery('#wu_form').serializeArray().reduce(function (json, { name, value }) {
// Get products from this
if (name !== 'products[]') {
json[name] = value;
}
return json;
}, {});
const form_data = jQuery.param({
...form_data_obj,
products: this.products,
membership_id: this.membership_id,
payment_id: this.payment_id,
auto_renew: this.auto_renew,
cart_type: this.type,
valid_password: this.valid_password,
duration: this.duration,
duration_unit: this.duration_unit,
});
const that = this;
this.request('wu_validate_form', form_data, function (results) {
if (!that.valid_password) {
that.errors.push({
code: 'password',
message: wu_checkout.i18n.weak_password,
});
} // end if;
if (results.success === false) {
that.errors = [].concat(that.errors, results.data);
that.unblock();
return;
} // end if;
if (!that.errors.length) {
that.form_success(results);
if (that.prevent_submission === false) {
that.resubmit();
} // end if;
} else {
that.unblock();
} // end if;
}, this.handle_errors);
},
resubmit() {
jQuery('#wu_form').get(0).submit();
},
handle_errors(errors) {
this.unblock();
// eslint-disable-next-line no-console
console.error(errors);
},
on_submit(event) {
event.preventDefault();
},
on_change_product(new_value, old_value) {
window.wu_create_cookie('wu_selected_products', new_value.join(','), 0.5) // Save it for 12 hours max.
this.reset_templates(['template-selection']);
hooks.doAction('wu_on_change_product', new_value, old_value, this);
this.create_order();
},
on_change_gateway(new_value, old_value) {
hooks.doAction('wu_on_change_gateway', new_value, old_value, this);
},
on_change_country(new_value, old_value) {
hooks.doAction('wu_on_change_country', new_value, old_value, this);
this.create_order();
},
on_change_state(new_value, old_value) {
hooks.doAction('wu_on_change_state', new_value, old_value, this);
this.create_order();
},
on_change_city(new_value, old_value) {
hooks.doAction('wu_on_change_city', new_value, old_value, this);
this.create_order();
},
on_change_duration(new_value, old_value) {
this.reset_templates();
hooks.doAction('wu_on_change_duration', new_value, old_value, this);
this.create_order();
},
on_change_duration_unit(new_value, old_value) {
this.reset_templates();
hooks.doAction('wu_on_change_duration_unit', new_value, old_value, this);
this.create_order();
},
on_change_discount_code(new_value, old_value) {
hooks.doAction('wu_on_change_discount_code', new_value, old_value, this);
this.create_order();
},
block() {
/*
* Get the first bg color from a parent.
*/
const bg_color = jQuery(this.$el).parents().filter(function () {
return $(this).css('backgroundColor') !== 'rgba(0, 0, 0, 0)';
}).first().css('backgroundColor');
jQuery(this.$el).wu_block({
message: '<div class="spinner is-active wu-float-none" style="float: none !important;"></div>',
overlayCSS: {
backgroundColor: bg_color ? bg_color : '#ffffff',
opacity: 0.6,
},
css: {
padding: 0,
margin: 0,
width: '50%',
fontSize: '14px !important',
top: '40%',
left: '35%',
textAlign: 'center',
color: '#000',
border: 'none',
backgroundColor: 'none',
cursor: 'wait',
},
});
},
unblock() {
jQuery(this.$el).wu_unblock();
},
request(action, data, success_handler, error_handler) {
const actual_ajax_url = action === 'wu_validate_form' ? wu_checkout.late_ajaxurl : wu_checkout.ajaxurl;
jQuery.ajax({
method: 'POST',
url: actual_ajax_url + '&action=' + action,
data,
success: success_handler,
error: error_handler,
});
},
check_pass_strength() {
const pass1_el = '#field-password';
if (!jQuery('#pass-strength-result').length) {
return;
} // end if;
jQuery('#pass-strength-result')
.attr('class', 'wu-py-2 wu-px-4 wu-bg-gray-100 wu-block wu-text-sm wu-border-solid wu-border wu-border-gray-200');
const pass1 = jQuery(pass1_el).val();
if (!pass1) {
jQuery('#pass-strength-result').addClass('empty').html('Enter Password');
return;
} // end if;
this.valid_password = false;
const disallowed_list = typeof wp.passwordStrength.userInputDisallowedList === 'undefined'
? wp.passwordStrength.userInputBlacklist()
: wp.passwordStrength.userInputDisallowedList();
const strength = wp.passwordStrength.meter(pass1, disallowed_list, pass1);
switch (strength) {
case -1:
jQuery('#pass-strength-result').addClass('wu-bg-red-200 wu-border-red-300').html(pwsL10n.unknown);
break;
case 2:
jQuery('#pass-strength-result').addClass('wu-bg-red-200 wu-border-red-300').html(pwsL10n.bad);
break;
case 3:
jQuery('#pass-strength-result').addClass('wu-bg-green-200 wu-border-green-300').html(pwsL10n.good);
this.valid_password = true;
break;
case 4:
jQuery('#pass-strength-result').addClass('wu-bg-green-200 wu-border-green-300').html(pwsL10n.strong);
this.valid_password = true;
break;
case 5:
jQuery('#pass-strength-result').addClass('wu-bg-yellow-200 wu-border-yellow-300').html(pwsL10n.mismatch);
break;
default:
jQuery('#pass-strength-result').addClass('wu-bg-yellow-200 wu-border-yellow-300').html(pwsL10n.short);
} // end switch;
},
},
updated() {
this.$nextTick(function () {
hooks.doAction('wu_on_form_updated', this);
wu_initialize_tooltip();
});
},
mounted() {
const that = this;
jQuery(this.$el).on('click', function (e) {
$(this).data('submited_via', $(e.target));
});
jQuery(this.$el).on('submit', async function (e) {
e.preventDefault();
/**
* Handle button submission.
*/
const submit_el = jQuery(this).data('submited_via');
if (submit_el) {
const new_input = jQuery('<input>');
new_input.attr('type', 'hidden');
new_input.attr('name', submit_el.attr('name'));
new_input.attr('value', submit_el.val());
jQuery(this).append(new_input);
} // end if;
that.block();
try {
const promises = [];
// Here we use filter to return possible promises to await
await Promise.all(hooks.applyFilters("wu_before_form_submitted", promises, that, that.gateway));
} catch (error) {
that.errors = [];
that.errors.push({
code: 'before-submit-error',
message: error.message,
});
that.unblock();
that.handle_errors(error);
return;
} // end try;
that.validate_form();
hooks.doAction('wu_on_form_submitted', that, that.gateway);
});
this.create_order();
hooks.doAction('wu_checkout_loaded', this);
hooks.doAction('wu_on_change_gateway', this.gateway, this.gateway);
jQuery('#field-password').on('input pwupdate', function () {
that.check_pass_strength();
});
wu_initialize_tooltip();
},
watch: {
products(new_value, old_value) {
this.on_change_product(new_value, old_value);
},
toggle_discount_code(new_value) {
if (!new_value) {
this.discount_code = '';
} // end if;
},
discount_code(new_value, old_value) {
this.on_change_discount_code(new_value, old_value);
},
gateway(new_value, old_value) {
this.on_change_gateway(new_value, old_value);
},
country(new_value, old_value) {
this.state = '';
this.on_change_country(new_value, old_value);
},
state(new_value, old_value) {
this.city = '';
this.on_change_state(new_value, old_value);
},
city(new_value, old_value) {
this.on_change_city(new_value, old_value);
},
duration(new_value, old_value) {
this.on_change_duration(new_value, old_value);
},
duration_unit(new_value, old_value) {
this.on_change_duration_unit(new_value, old_value);
},
},
});
});
}(jQuery, wp.hooks, _));

1
assets/js/checkout.min.js vendored Normal file

File diff suppressed because one or more lines are too long

101
assets/js/cookie-helpers.js Normal file
View File

@ -0,0 +1,101 @@
/**
* Create a new cookie.
*
* @param {string} name The cookie name.
* @param {*} value The cookie value.
* @param {number} days The expiration, in days.
* @return {void}
*/
window.wu_create_cookie = function(name, value, days) {
let expires;
if (days) {
const date = new Date();
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
expires = '; expires=' + date.toGMTString();
} else {
expires = '';
} // end if;
document.cookie = name + '=' + value + expires + '; path=/';
};
/**
* Reads from a cookie.
*
* @param {string} name The cookie name
* @return {*} The cookie value
*/
window.wu_read_cookie = function(name) {
const nameEQ = name + '=';
const ca = document.cookie.split(';');
for (let i = 0; i < ca.length; i++) {
let c = ca[i];
while (c.charAt(0) === ' ') {
c = c.substring(1, c.length);
} // end while;
if (c.indexOf(nameEQ) === 0) {
return c.substring(nameEQ.length, c.length);
} // end if;
} // end for;
return null;
};
/**
* Erase a cookie.
*
* @param {string} name The cookie name.
*/
window.wu_erase_cookie = function(name) {
window.wu_create_cookie(name, '', -1);
};
/**
* Listens to a particular cookie to catch a change in value.
*
* @param {string} name The cookie name.
* @param {Function} callback The callback to call when a change is detected.
*/
window.wu_listen_to_cookie_change = function(name, callback) {
let cookie_value = window.wu_read_cookie(name);
setInterval(function() {
const new_cookie_value = window.wu_read_cookie(name);
if (new_cookie_value !== cookie_value) {
// update registry so we dont get triggered again
cookie_value = new_cookie_value;
callback(cookie_value);
} // end if;
}, 100);
};

1
assets/js/cookie-helpers.min.js vendored Normal file
View File

@ -0,0 +1 @@
window.wu_create_cookie=function(e,o,n){let t;if(n){const e=new Date;e.setTime(e.getTime()+24*n*60*60*1e3),t="; expires="+e.toGMTString()}else t="";document.cookie=e+"="+o+t+"; path=/"},window.wu_read_cookie=function(e){const o=e+"=",n=document.cookie.split(";");for(let e=0;e<n.length;e++){let t=n[e];for(;" "===t.charAt(0);)t=t.substring(1,t.length);if(0===t.indexOf(o))return t.substring(o.length,t.length)}return null},window.wu_erase_cookie=function(e){window.wu_create_cookie(e,"",-1)},window.wu_listen_to_cookie_change=function(e,o){let n=window.wu_read_cookie(e);setInterval((function(){const t=window.wu_read_cookie(e);t!==n&&(n=t,o(n))}),100)};

74
assets/js/customizer.js Normal file
View File

@ -0,0 +1,74 @@
/* global Vue, wu_block_ui */
(function($) {
/**
* If we detect the preview changed, we add a loader.
*/
window.addEventListener('message', function(message) {
let block;
if (message.data === 'wu_preview_changed') {
block = wu_block_ui('#preview_content');
} // end if;
/**
* Unblocks when the loading is finished.
*/
$('#preview-stage-iframe').on('load', function() {
if (block) {
block.unblock();
} // end if;
});
}, false);
$(document).ready(function() {
// eslint-disable-next-line no-unused-vars
const wu_preview_stage = new Vue({
el: '#preview-stage',
data() {
return {
preview: false,
};
},
});
$('[data-wu-customizer-panel]').each(function() {
const app = $(this);
const app_name = 'wu_' + app.data('wu-app');
wp.hooks.addAction(app_name + '_changed', 'nextpress/wp-ultimo', function(prop) {
if (prop === 'tab') {
return;
} // end if;
const param = jQuery.param(window[app_name].$data);
const param2 = app.find('input').serialize();
const url = $('#preview-stage-iframe').attr('data-src');
$('#preview-stage-iframe').attr('src', url + '&' + param + '&' + param2);
});
});
});
}(jQuery));

1
assets/js/customizer.min.js vendored Normal file
View File

@ -0,0 +1 @@
!function(e){window.addEventListener("message",(function(t){let a;"wu_preview_changed"===t.data&&(a=wu_block_ui("#preview_content")),e("#preview-stage-iframe").on("load",(function(){a&&a.unblock()}))}),!1),e(document).ready((function(){new Vue({el:"#preview-stage",data:()=>({preview:!1})});e("[data-wu-customizer-panel]").each((function(){const t=e(this),a="wu_"+t.data("wu-app");wp.hooks.addAction(a+"_changed","nextpress/wp-ultimo",(function(n){if("tab"===n)return;const i=jQuery.param(window[a].$data),r=t.find("input").serialize(),o=e("#preview-stage-iframe").attr("data-src");e("#preview-stage-iframe").attr("src",o+"&"+i+"&"+r)}))}))}))}(jQuery);

View File

@ -0,0 +1,232 @@
/* global wu_dashboard_statistics_vars, wu_format_money, Vue, wu_block_ui, moment, ajaxurl */
(function() {
const graph = document.getElementById('wp-ultimo-mrr-growth');
if (! graph) {
return;
} // end if;
// eslint-disable-next-line no-undef
mrr_graph = new Vue({
el: '#wp-ultimo-mrr-growth',
components: {
apexchart: window.VueApexCharts,
},
data: {
start_date: wu_dashboard_statistics_vars.start_date,
end_date: wu_dashboard_statistics_vars.end_date,
chart_options: {
mrr_growth: {
series: [
{
name: wu_dashboard_statistics_vars.i18n.new_mrr,
data: [
wu_dashboard_statistics_vars.mrr_array.january.total,
wu_dashboard_statistics_vars.mrr_array.february.total,
wu_dashboard_statistics_vars.mrr_array.march.total,
wu_dashboard_statistics_vars.mrr_array.april.total,
wu_dashboard_statistics_vars.mrr_array.may.total,
wu_dashboard_statistics_vars.mrr_array.june.total,
wu_dashboard_statistics_vars.mrr_array.july.total,
wu_dashboard_statistics_vars.mrr_array.august.total,
wu_dashboard_statistics_vars.mrr_array.september.total,
wu_dashboard_statistics_vars.mrr_array.october.total,
wu_dashboard_statistics_vars.mrr_array.november.total,
wu_dashboard_statistics_vars.mrr_array.december.total,
],
},
{
name: wu_dashboard_statistics_vars.i18n.cancellations,
data: [
-wu_dashboard_statistics_vars.mrr_array.january.cancelled,
-wu_dashboard_statistics_vars.mrr_array.february.cancelled,
-wu_dashboard_statistics_vars.mrr_array.march.cancelled,
-wu_dashboard_statistics_vars.mrr_array.april.cancelled,
-wu_dashboard_statistics_vars.mrr_array.may.cancelled,
-wu_dashboard_statistics_vars.mrr_array.june.cancelled,
-wu_dashboard_statistics_vars.mrr_array.july.cancelled,
-wu_dashboard_statistics_vars.mrr_array.august.cancelled,
-wu_dashboard_statistics_vars.mrr_array.september.cancelled,
-wu_dashboard_statistics_vars.mrr_array.october.cancelled,
-wu_dashboard_statistics_vars.mrr_array.november.cancelled,
-wu_dashboard_statistics_vars.mrr_array.december.cancelled,
],
},
],
chartOptions: {
chart: {
type: 'bar',
height: 300,
stacked: true,
toolbar: {
show: false,
},
zoom: {
enabled: true,
},
},
dataLabels: {
enabled: false,
maxItems: 0,
},
responsive: [{
breakpoint: 480,
options: {
legend: {
position: 'bottom',
offsetX: -10,
offsetY: 0,
},
},
}],
colors: ['#3498db', '#e74c3c'],
plotOptions: {
bar: {
horizontal: false,
columnWidth: '40%',
endingShape: 'rounded',
startingShape: 'rounded',
},
},
xaxis: {
categories: wu_dashboard_statistics_vars.month_list,
position: 'bottom',
axisBorder: {
show: true,
},
axisTicks: {
show: true,
},
crosshairs: {
fill: {
type: 'gradient',
gradient: {
colorFrom: '#D8E3F0',
colorTo: '#BED1E6',
stops: [0, 100],
opacityFrom: 0.4,
opacityTo: 0.5,
},
},
},
tooltip: {
enabled: true,
},
},
yaxis: {
labels: {
formatter(y) {
return y >= 0 ? wu_format_money(y) : '-' + wu_format_money(y);
},
},
},
legend: {
position: 'top',
offsetY: 0,
},
fill: {
opacity: 1,
},
},
},
},
},
});
}());
(function($) {
$(document).ready(function() {
$('.wu-loader').on('click', function() {
wu_block_ui('#wpcontent');
});
$('#wu-date-range').flatpickr({
mode: 'range',
dateFormat: 'Y-m-d',
maxDate: wu_dashboard_statistics_vars.today,
defaultDate: [
wu_dashboard_statistics_vars.start_date,
wu_dashboard_statistics_vars.end_date,
],
onClose(selectedDates) {
const redirect = new URL(window.location.href);
redirect.searchParams.set('start_date', moment(selectedDates[0]).format('YYYY-MM-DD'));
redirect.searchParams.set('end_date', moment(selectedDates[1]).format('YYYY-MM-DD'));
window.location.href = redirect.toString();
wu_block_ui('#wpcontent');
},
});
});
}(jQuery));
(function($) {
$(document).ready(function() {
$('.wu-export-button').on('click', function(e) {
e.preventDefault();
const slug = e.target.getAttribute('attr-slug-csv');
const headers = $('#csv_headers_' + slug).val();
const data = $('#csv_data_' + slug).val();
const action = $('#csv_action_' + slug).val();
const date_range = wu_dashboard_statistics_vars.start_date + '_to_' + wu_dashboard_statistics_vars.end_date;
const block = wu_block_ui('#wpcontent');
setTimeout(() => {
block.unblock();
}, 2000);
// eslint-disable-next-line max-len
$('body').append('<form id="export_csv" method="post" action="' + ajaxurl + '" style="display:none;"><input name="action" value="' + action + '" type="hidden"><input name="slug" value="' + slug + '" type="hidden"></form>');
$('<input />').attr('type', 'hidden')
.attr('name', 'headers')
.attr('value', headers)
.appendTo('#export_csv');
$('<input />').attr('type', 'hidden')
.attr('name', 'data')
.attr('value', data)
.appendTo('#export_csv');
$('<input />').attr('type', 'hidden')
.attr('name', 'date_range')
.attr('value', date_range)
.appendTo('#export_csv');
$('#export_csv').submit();
$('#export_csv').remove();
});
});
}(jQuery));

1
assets/js/dashboard-statistics.min.js vendored Normal file
View File

@ -0,0 +1 @@
document.getElementById("wp-ultimo-mrr-growth")&&(mrr_graph=new Vue({el:"#wp-ultimo-mrr-growth",components:{apexchart:window.VueApexCharts},data:{start_date:wu_dashboard_statistics_vars.start_date,end_date:wu_dashboard_statistics_vars.end_date,chart_options:{mrr_growth:{series:[{name:wu_dashboard_statistics_vars.i18n.new_mrr,data:[wu_dashboard_statistics_vars.mrr_array.january.total,wu_dashboard_statistics_vars.mrr_array.february.total,wu_dashboard_statistics_vars.mrr_array.march.total,wu_dashboard_statistics_vars.mrr_array.april.total,wu_dashboard_statistics_vars.mrr_array.may.total,wu_dashboard_statistics_vars.mrr_array.june.total,wu_dashboard_statistics_vars.mrr_array.july.total,wu_dashboard_statistics_vars.mrr_array.august.total,wu_dashboard_statistics_vars.mrr_array.september.total,wu_dashboard_statistics_vars.mrr_array.october.total,wu_dashboard_statistics_vars.mrr_array.november.total,wu_dashboard_statistics_vars.mrr_array.december.total]},{name:wu_dashboard_statistics_vars.i18n.cancellations,data:[-wu_dashboard_statistics_vars.mrr_array.january.cancelled,-wu_dashboard_statistics_vars.mrr_array.february.cancelled,-wu_dashboard_statistics_vars.mrr_array.march.cancelled,-wu_dashboard_statistics_vars.mrr_array.april.cancelled,-wu_dashboard_statistics_vars.mrr_array.may.cancelled,-wu_dashboard_statistics_vars.mrr_array.june.cancelled,-wu_dashboard_statistics_vars.mrr_array.july.cancelled,-wu_dashboard_statistics_vars.mrr_array.august.cancelled,-wu_dashboard_statistics_vars.mrr_array.september.cancelled,-wu_dashboard_statistics_vars.mrr_array.october.cancelled,-wu_dashboard_statistics_vars.mrr_array.november.cancelled,-wu_dashboard_statistics_vars.mrr_array.december.cancelled]}],chartOptions:{chart:{type:"bar",height:300,stacked:!0,toolbar:{show:!1},zoom:{enabled:!0}},dataLabels:{enabled:!1,maxItems:0},responsive:[{breakpoint:480,options:{legend:{position:"bottom",offsetX:-10,offsetY:0}}}],colors:["#3498db","#e74c3c"],plotOptions:{bar:{horizontal:!1,columnWidth:"40%",endingShape:"rounded",startingShape:"rounded"}},xaxis:{categories:wu_dashboard_statistics_vars.month_list,position:"bottom",axisBorder:{show:!0},axisTicks:{show:!0},crosshairs:{fill:{type:"gradient",gradient:{colorFrom:"#D8E3F0",colorTo:"#BED1E6",stops:[0,100],opacityFrom:.4,opacityTo:.5}}},tooltip:{enabled:!0}},yaxis:{labels:{formatter:a=>a>=0?wu_format_money(a):"-"+wu_format_money(a)}},legend:{position:"top",offsetY:0},fill:{opacity:1}}}}}})),function(a){a(document).ready((function(){a(".wu-loader").on("click",(function(){wu_block_ui("#wpcontent")})),a("#wu-date-range").flatpickr({mode:"range",dateFormat:"Y-m-d",maxDate:wu_dashboard_statistics_vars.today,defaultDate:[wu_dashboard_statistics_vars.start_date,wu_dashboard_statistics_vars.end_date],onClose(a){const t=new URL(window.location.href);t.searchParams.set("start_date",moment(a[0]).format("YYYY-MM-DD")),t.searchParams.set("end_date",moment(a[1]).format("YYYY-MM-DD")),window.location.href=t.toString(),wu_block_ui("#wpcontent")}})}))}(jQuery),function(a){a(document).ready((function(){a(".wu-export-button").on("click",(function(t){t.preventDefault();const r=t.target.getAttribute("attr-slug-csv"),s=a("#csv_headers_"+r).val(),e=a("#csv_data_"+r).val(),o=a("#csv_action_"+r).val(),_=wu_dashboard_statistics_vars.start_date+"_to_"+wu_dashboard_statistics_vars.end_date,d=wu_block_ui("#wpcontent");setTimeout(()=>{d.unblock()},2e3),a("body").append('<form id="export_csv" method="post" action="'+ajaxurl+'" style="display:none;"><input name="action" value="'+o+'" type="hidden"><input name="slug" value="'+r+'" type="hidden"></form>'),a("<input />").attr("type","hidden").attr("name","headers").attr("value",s).appendTo("#export_csv"),a("<input />").attr("type","hidden").attr("name","data").attr("value",e).appendTo("#export_csv"),a("<input />").attr("type","hidden").attr("name","date_range").attr("value",_).appendTo("#export_csv"),a("#export_csv").submit(),a("#export_csv").remove()}))}))}(jQuery);

View File

@ -0,0 +1,231 @@
/* eslint-disable no-lonely-if */
/* global Vue, wu_block_ui, ajaxurl, wu_placeholdersl10n */
(function($) {
$(document).ready(function() {
/**
* Vue
*/
if ($('#wu-template-placeholders').length) {
window.wu_placeholders = new Vue({
el: '#wu-template-placeholders',
data: {
tax_category: 'default',
switching: false,
creating: false,
create_name: '',
toggle: false,
loading: true,
saving: false,
initialLoading: true,
error: false,
changed: false,
data: {
placeholders: [],
},
delete: [],
saveMessage: '',
errorMessage: '',
rate_type: 'standard_rate',
},
watch: {
data: {
deep: true,
handler() {
if (this.initialLoading) {
this.initialLoading = false;
return;
}
this.changed = true;
},
},
loading(new_value) {
if (new_value === true) {
window.wu_blocked_table = wu_block_ui('table.wp-list-table');
} else {
if (typeof window.wu_blocked_table !== 'undefined') {
window.wu_blocked_table.unblock();
} // end if;
} // end if;
},
},
mounted() {
this.loading = true;
this.pull_data(true);
$('.wu-tooltip-vue').tipTip();
},
created() {
// Create the event.
const event = document.createEvent('Event');
// Define that the event name is 'build'.
event.initEvent('vue_loaded', true, true);
event.vue = this;
// target can be any Element or other EventTarget.
window.dispatchEvent(event);
},
computed: {
selected() {
return $(this.data.placeholders).filter(function(index, item) {
return item.selected;
});
},
},
methods: {
refresh(e) {
e.preventDefault();
this.loading = true;
this.pull_data();
},
select_all(event) {
const toggle = $(event.target).is(':checked');
this.data.placeholders = $.map(this.data.placeholders, function(item) {
item.selected = toggle;
return item;
});
},
pull_data() {
const that = this;
jQuery.getJSON(ajaxurl + '?action=wu_get_placeholders').done(function(response) {
that.loading = false;
that.data = response.data;
})
.fail(function(error) {
that.loading = false;
that.error = true;
that.errorMessage = error.statusText;
});
},
add_row() {
Vue.set(this.data, 'placeholders', this.data.placeholders.concat([
{
placeholder: '',
content: '',
selected: false,
},
]));
this.$forceUpdate();
},
delete_rows() {
this.delete = this.delete.concat(this.selected.get());
// eslint-disable-next-line no-alert
const are_you_sure = confirm(wu_placeholdersl10n.confirm_message);
if (are_you_sure) {
const cleaned_list = $(this.data.placeholders).filter(function(index, item) {
return ! item.selected;
});
Vue.set(this.data, 'placeholders', cleaned_list.get());
this.$forceUpdate();
} // end if
},
save() {
const that = this;
that.saving = true;
$.post({
url: ajaxurl + '?action=wu_save_placeholders&' + $('#nonce_form').serialize(),
data: JSON.stringify({
placeholders: that.data.placeholders,
}),
dataType: 'json',
contentType: 'application/json; charset=utf-8',
}).success(function(data) {
that.saving = false;
that.changed = false;
that.delete = [];
that.saveMessage = data.message;
if (data.code === 'success') {
that.loading = true;
that.initialLoading = true;
that.pull_data();
}
setInterval(function() {
that.saveMessage = '';
}, 6000);
});
},
},
});
} // end if;
});
}(jQuery));

1
assets/js/edit-placeholders.min.js vendored Normal file
View File

@ -0,0 +1 @@
!function(e){e(document).ready((function(){e("#wu-template-placeholders").length&&(window.wu_placeholders=new Vue({el:"#wu-template-placeholders",data:{tax_category:"default",switching:!1,creating:!1,create_name:"",toggle:!1,loading:!0,saving:!1,initialLoading:!0,error:!1,changed:!1,data:{placeholders:[]},delete:[],saveMessage:"",errorMessage:"",rate_type:"standard_rate"},watch:{data:{deep:!0,handler(){this.initialLoading?this.initialLoading=!1:this.changed=!0}},loading(e){!0===e?window.wu_blocked_table=wu_block_ui("table.wp-list-table"):void 0!==window.wu_blocked_table&&window.wu_blocked_table.unblock()}},mounted(){this.loading=!0,this.pull_data(!0),e(".wu-tooltip-vue").tipTip()},created(){const e=document.createEvent("Event");e.initEvent("vue_loaded",!0,!0),e.vue=this,window.dispatchEvent(e)},computed:{selected(){return e(this.data.placeholders).filter((function(e,t){return t.selected}))}},methods:{refresh(e){e.preventDefault(),this.loading=!0,this.pull_data()},select_all(t){const a=e(t.target).is(":checked");this.data.placeholders=e.map(this.data.placeholders,(function(e){return e.selected=a,e}))},pull_data(){const e=this;jQuery.getJSON(ajaxurl+"?action=wu_get_placeholders").done((function(t){e.loading=!1,e.data=t.data})).fail((function(t){e.loading=!1,e.error=!0,e.errorMessage=t.statusText}))},add_row(){Vue.set(this.data,"placeholders",this.data.placeholders.concat([{placeholder:"",content:"",selected:!1}])),this.$forceUpdate()},delete_rows(){this.delete=this.delete.concat(this.selected.get());if(confirm(wu_placeholdersl10n.confirm_message)){const t=e(this.data.placeholders).filter((function(e,t){return!t.selected}));Vue.set(this.data,"placeholders",t.get()),this.$forceUpdate()}},save(){const t=this;t.saving=!0,e.post({url:ajaxurl+"?action=wu_save_placeholders&"+e("#nonce_form").serialize(),data:JSON.stringify({placeholders:t.data.placeholders}),dataType:"json",contentType:"application/json; charset=utf-8"}).success((function(e){t.saving=!1,t.changed=!1,t.delete=[],t.saveMessage=e.message,"success"===e.code&&(t.loading=!0,t.initialLoading=!0,t.pull_data()),setInterval((function(){t.saveMessage=""}),6e3)}))}}}))}))}(jQuery);

View File

@ -0,0 +1,81 @@
/* global ajaxurl, Vue, wu_event_payload_placeholders, _ */
(function($) {
$(document).ready(function() {
wu_event_payload_placeholders = new Vue({
el: '#wu_event_payload_placeholders',
data() {
return {
placeholders: [],
event: $("select[name='event']").val(),
search: '',
loading: true,
};
},
computed: {
filtered_placeholders() {
const search = this.search.toLowerCase();
return _.filter(this.placeholders, function(item) {
return item.name.toLowerCase().indexOf(search) > -1 || item.placeholder.toLowerCase().indexOf(search) > -1;
});
},
},
watch: {
event() {
this.get_event_payload();
},
},
methods: {
get_event_payload() {
const app = this;
app.loading = true;
$.ajax({
method: 'post',
url: ajaxurl,
data: {
action: 'wu_get_event_payload_placeholders',
email_event: app.event,
},
success(response) {
app.placeholders = response;
app.loading = false;
},
});
},
},
mounted() {
this.get_event_payload();
},
});
$(document).on('change', 'select[name="event"]', function() {
wu_event_payload_placeholders.event = $("select[name='event']").val();
});
});
}(jQuery));

1
assets/js/email-edit-page.min.js vendored Normal file
View File

@ -0,0 +1 @@
!function(e){e(document).ready((function(){wu_event_payload_placeholders=new Vue({el:"#wu_event_payload_placeholders",data:()=>({placeholders:[],event:e("select[name='event']").val(),search:"",loading:!0}),computed:{filtered_placeholders(){const e=this.search.toLowerCase();return _.filter(this.placeholders,(function(t){return t.name.toLowerCase().indexOf(e)>-1||t.placeholder.toLowerCase().indexOf(e)>-1}))}},watch:{event(){this.get_event_payload()}},methods:{get_event_payload(){const t=this;t.loading=!0,e.ajax({method:"post",url:ajaxurl,data:{action:"wu_get_event_payload_placeholders",email_event:t.event},success(e){t.placeholders=e,t.loading=!1}})}},mounted(){this.get_event_payload()}}),e(document).on("change",'select[name="event"]',(function(){wu_event_payload_placeholders.event=e("select[name='event']").val()}))}))}(jQuery);

View File

@ -0,0 +1,46 @@
/* eslint-disable no-unused-vars */
/* global Vue, wu_event_view_payload, ClipboardJS */
(function ($) {
$(function () {
if (($('#wu_payload').length)) {
wu_event_view_payload = new Vue({
el: '#wu_payload',
data() {
return {
loading: false,
payload: $('#hidden_textarea').val(),
};
},
methods: {},
});
}
// eslint-disable-next-line no-unused-vars
const clipboard = new ClipboardJS('.btn-clipboard');
clipboard.on('success', function (e) {
const target = $(e.trigger);
const default_text = target.text();
target.attr('disabled', 'disabled').text('Copied!');
setTimeout(function () {
target.text(default_text).removeAttr('disabled');
}, 3000);
});
});
}(jQuery));

1
assets/js/event-view-page.min.js vendored Normal file
View File

@ -0,0 +1 @@
!function(e){e((function(){e("#wu_payload").length&&(wu_event_view_payload=new Vue({el:"#wu_payload",data:()=>({loading:!1,payload:e("#hidden_textarea").val()}),methods:{}}));new ClipboardJS(".btn-clipboard").on("success",(function(t){const a=e(t.trigger),d=a.text();a.attr("disabled","disabled").text("Copied!"),setTimeout((function(){a.text(d).removeAttr("disabled")}),3e3)}))}))}(jQuery);

46
assets/js/fields.js Normal file
View File

@ -0,0 +1,46 @@
/* global Vue */
if (typeof window.Vue !== 'undefined') {
/**
* Registers the ColorPicker component.
*
* @since 2.0.0
*/
Vue.component('colorPicker', {
props: ['value'],
template: '<input type="text">',
mounted() {
const vm = this;
$(this.$el)
.val(this.value)
.wpColorPicker({
width: 200,
defaultColor: this.value,
change(event, ui) {
// emit change event on color change using mouse
vm.$emit('input', ui.color.toString());
},
});
},
watch: {
value(value) {
// update value
$(this.$el).wpColorPicker('color', value);
},
},
destroyed() {
$(this.$el).off().wpColorPicker('destroy'); // (!) Not tested
},
});
} // end if;

1
assets/js/fields.min.js vendored Normal file
View File

@ -0,0 +1 @@
void 0!==window.Vue&&Vue.component("colorPicker",{props:["value"],template:'<input type="text">',mounted(){const e=this;$(this.$el).val(this.value).wpColorPicker({width:200,defaultColor:this.value,change(o,t){e.$emit("input",t.color.toString())}})},watch:{value(e){$(this.$el).wpColorPicker("color",e)}},destroyed(){$(this.$el).off().wpColorPicker("destroy")}});

460
assets/js/functions.js Normal file
View File

@ -0,0 +1,460 @@
/* eslint-disable no-undef */
/* eslint-disable no-unused-vars */
/* global wu_settings, wu_input_masks, wu_money_input_masks, Cleave, ClipboardJS, wu_fields, tinymce, wu_media_frame, fontIconPicker */
window.wu_initialize_tooltip = function() {
jQuery('[role="tooltip"]').tipTip({
attribute: 'aria-label',
});
}; // end wu_initialize_tooltip;
window.wu_initialize_editors = function() {
jQuery('textarea[data-editor]').each(function() {
tinymce.remove('#' + jQuery(this).attr('id'));
tinymce.init({
selector: '#' + jQuery(this).attr('id'), // change this value according to your HTML
menubar: '',
theme: 'modern',
...wp.editor.getDefaultSettings().tinymce,
});
});
}; // end wu_initialize_editors
window.wu_initialize_imagepicker = function() {
jQuery('.wu-wrapper-image-field').each(function() {
const that = jQuery(this);
that.find('img').css({
maxWidth: '100%',
});
const value = that.find('img').attr('src');
if (value) {
that.find('.wu-wrapper-image-field-upload-actions').show();
} else {
that.find('.wu-add-image-wrapper').show();
} // end if;
that.on('click', 'a.wu-add-image', function() {
if (typeof wu_media_frame !== 'undefined') {
wu_media_frame.open();
return;
} // end if;
wu_media_frame = wp.media({
title: wu_fields.l10n.image_picker_title,
multiple: false,
button: {
text: wu_fields.l10n.image_picker_button_text,
},
});
wu_media_frame.on('select', function() {
const mediaObject = wu_media_frame.state().get('selection').first().toJSON();
const img_el = that.find('img');
that.find('img').removeClass('wu-absolute').attr('src', mediaObject.url);
that.find('.wubox').attr('href', mediaObject.url);
that.find('input').val(mediaObject.id);
that.find('.wu-add-image-wrapper').hide();
img_el.on('load', function() {
that.find('.wu-wrapper-image-field-upload-actions').show();
});
});
wu_media_frame.open();
});
that.find('.wu-remove-image').on('click', function(e) {
e.preventDefault();
that.find('img').removeAttr('src').addClass('wu-absolute');
that.find('input').val('');
that.find('.wu-wrapper-image-field-upload-actions').hide();
that.find('.wu-add-image-wrapper').show();
});
});
}; // end wu_initialize_imagepicker
window.wu_initialize_colorpicker = function() {
jQuery(document).ready(function() {
jQuery('.wu_color_field').each(function() {
jQuery(this).wpColorPicker();
});
});
}; // end wu_initialize_colorpicker;
window.wu_initialize_iconfontpicker = function() {
jQuery(document).ready(function() {
if (jQuery('.wu_select_icon').length) {
jQuery('.wu_select_icon').fontIconPicker({
theme: 'wu-theme',
});
}
});
}; // end wu_initialize_iconfontpicker;
window.wu_initialize_clipboardjs = function() {
new ClipboardJS('.wu-copy');
}; // end wu_initialize_clipboardjs;
// DatePicker;
window.wu_initialize_datepickers = function() {
jQuery('.wu-datepicker, [wu-datepicker]').each(function() {
const $this = jQuery(this);
const format = $this.data('format'),
allow_time = $this.data('allow-time');
$this.flatpickr({
animate: false,
// locale: wpu.datepicker_locale,
time_24hr: true,
enableTime: typeof allow_time === 'undefined' ? true : allow_time,
dateFormat: format,
allowInput: true,
defaultDate: $this.val(),
});
});
}; // end wu_initialize_datepickers;
window.wu_update_clock = function() {
// eslint-disable-next-line no-undef
const yourTimeZoneFrom = wu_ticker.server_clock_offset; // time zone value where you are at
const d = new Date();
//get the timezone offset from local time in minutes
// eslint-disable-next-line no-mixed-operators
const tzDifference = yourTimeZoneFrom * 60 + d.getTimezoneOffset();
//convert the offset to milliseconds, add to targetTime, and make a new Date
const offset = tzDifference * 60 * 1000;
function callback_update_clock() {
const tDate = new Date(new Date().getTime() + offset);
const in_years = tDate.getFullYear();
let in_months = tDate.getMonth() + 1;
let in_days = tDate.getDate();
let in_hours = tDate.getHours();
let in_minutes = tDate.getMinutes();
let in_seconds = tDate.getSeconds();
if (in_months < 10) {
in_months = '0' + in_months;
}
if (in_days < 10) {
in_days = '0' + in_days;
}
if (in_minutes < 10) {
in_minutes = '0' + in_minutes;
}
if (in_seconds < 10) {
in_seconds = '0' + in_seconds;
}
if (in_hours < 10) {
in_hours = '0' + in_hours;
}
jQuery('#wu-ticker').text(in_years + '-' + in_months + '-' + in_days + ' ' + in_hours + ':' + in_minutes + ':' + in_seconds);
}
function start_clock() {
setInterval(callback_update_clock, 500);
}
start_clock();
};
// eslint-disable-next-line no-unused-vars
function wu_on_load() {
wu_initialize_tooltip();
wu_initialize_datepickers();
wu_initialize_colorpicker();
wu_initialize_iconfontpicker();
wu_initialize_editors();
wu_update_clock();
wu_initialize_clipboardjs();
wu_initialize_imagepicker();
wu_image_preview();
} // end wu_on_load;
window.wu_on_load = wu_on_load;
// eslint-disable-next-line no-unused-vars
window.wu_block_ui = function(el) {
jQuery(el).wu_block({
message: '<div class="spinner is-active wu-float-none" style="float: none !important;"></div>',
overlayCSS: {
backgroundColor: '#FFF',
opacity: 0.6,
},
css: {
padding: 0,
margin: 0,
width: '50%',
fontSize: '14px !important',
top: '40%',
left: '35%',
textAlign: 'center',
color: '#000',
border: 'none',
backgroundColor: 'none',
cursor: 'wait',
},
});
const el_instance = jQuery(el);
el_instance.unblock = jQuery(el).wu_unblock;
return el_instance;
};
function wu_format_money(value) {
value = parseFloat(value.toString().replace(/[^0-9\.]/g, ''));
const settings = wp.hooks.applyFilters('wu_format_money', {
currency: {
symbol: wu_settings.currency_symbol, // default currency symbol is '$'
format: wu_settings.currency_position, // controls output: %s = symbol, %v = value/number (can be object: see below)
decimal: wu_settings.decimal_separator, // decimal point separator
thousand: wu_settings.thousand_separator, // thousands separator
precision: wu_settings.precision, // decimal places
},
number: {
precision: 0, // default precision on numbers is 0
thousand: ',',
decimal: ',',
},
});
accounting.settings = settings;
return accounting.formatMoney(value);
} // end wu_format_money;
window.wu_image_preview = function() {
const xOffset = 10;
const yOffset = 30;
const preview_el = '#wu-image-preview';
// eslint-disable-next-line eqeqeq
const selector = wu_settings.disable_image_zoom == true ? '.wu-image-preview:not(img)' : '.wu-image-preview';
const el_id = preview_el.replace('#', '');
if (jQuery(preview_el).length === 0) {
jQuery('body').append(
"<div id='" + el_id + "' class='wu-rounded wu-p-1 wp-ui-primary' style='max-width: 600px; display: none; z-index: 9999999;'>" +
"<img class='wu-rounded wu-block wu-m-0 wu-p-0 wu-bg-gray-100' style='max-width: 100%;' src='' alt=''>" +
'</div>'
);
} // end if;
/* END CONFIG */
jQuery(selector).hover(function(e) {
this.t = this.title;
this.title = '';
const img = jQuery(this).data('image');
jQuery(preview_el)
.find('img')
.attr('src', img)
.attr('alt', this.t)
.end()
.css({
position: 'absolute',
display: 'none',
})
.css('top', (e.pageY - xOffset) + 'px')
.css('left', (e.pageX + yOffset) + 'px')
.fadeIn('fast');
},
function() {
this.title = this.t;
jQuery(preview_el).fadeOut('fast');
});
jQuery(selector).mousemove(function(e) {
jQuery(preview_el)
.css('top', (e.pageY - xOffset) + 'px')
.css('left', (e.pageX + yOffset) + 'px');
});
};
// eslint-disable-next-line no-undef
window.wu_initialize_code_editors = function() {
if (jQuery('[data-code-editor]').length) {
if (typeof window.wu_editor_instances === 'undefined') {
window.wu_editor_instances = {};
} // end if;
jQuery('[data-code-editor]').each(function() {
const code_editor = jQuery(this);
const editor_id = code_editor.attr('id');
if (typeof window.wu_editor_instances[editor_id] === 'undefined') {
if (! code_editor.is(':visible')) {
return;
} // end if;
window.wu_editor_instances[editor_id] = wp.codeEditor.initialize(editor_id, {
codemirror: {
mode: code_editor.data('code-editor'),
lint: true,
autoCloseBrackets: true,
matchBrackets: true,
indentUnit: 2,
indentWithTabs: true,
lineNumbers: true,
lineWrapping: true,
styleActiveLine: true,
continueComments: true,
inputStyle: 'contenteditable',
direction: 'ltr', // Code is shown in LTR even in RTL languages.
gutters: [],
extraKeys: {
'Ctrl-Space': 'autocomplete',
'Ctrl-/': 'toggleComment',
'Cmd-/': 'toggleComment',
'Alt-F': 'findPersistent',
},
},
});
} // end if;
});
} // end if;
}; // end wu_initialize_code_editors;
/**
* Get a timezone-d moment instance.
*
* @param {*} a The date.
* @return moment instance
*/
window.wu_moment = function(a) {
return moment.tz(a, 'Etc/UTC');
}; // end wu_moment;

1
assets/js/functions.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,45 @@
/* eslint-disable */
/* global wu_stripe_checkout, Stripe */
const stripeCheckout = function(publicKey) {
wp.hooks.addAction('wu_on_form_success', 'nextpress/wp-ultimo', async function(checkout, results) {
if (checkout.gateway === 'stripe-checkout' && results.gateway.slug !== 'free' && results.gateway.data && results.gateway.data.stripe_session_id) {
// Prevent redirect to thank you page
// set_prevent_submission not work in this case
checkout.prevent_submission = true;
// When the customer clicks on the button, redirect
// them to Checkout.
const stripe = await Stripe(publicKey);
stripe.redirectToCheckout({
sessionId: results.gateway.data.stripe_session_id,
}).then(function(result) {
if (result.error) {
console.log(result.error.message);
var displayError = document.getElementById('error-message');
displayError.textContent = result.error.message;
}
});
} // end if;
});
};
/**
* Initializes the Stripe checkout onto the checkout form on load.
*/
wp.hooks.addAction('wu_checkout_loaded', 'nextpress/wp-ultimo', function() {
stripeCheckout(wu_stripe_checkout.pk_key);
});

View File

@ -0,0 +1 @@
const stripeCheckout=function(e){wp.hooks.addAction("wu_on_form_success","nextpress/wp-ultimo",(async function(t,s){if("stripe-checkout"===t.gateway&&"free"!==s.gateway.slug&&s.gateway.data&&s.gateway.data.stripe_session_id){t.prevent_submission=!0;(await Stripe(e)).redirectToCheckout({sessionId:s.gateway.data.stripe_session_id}).then((function(e){e.error&&(console.log(e.error.message),document.getElementById("error-message").textContent=e.error.message)}))}}))};wp.hooks.addAction("wu_checkout_loaded","nextpress/wp-ultimo",(function(){var e;e=wu_stripe_checkout.pk_key,wp.hooks.addAction("wu_on_form_success","nextpress/wp-ultimo",(async function(t,s){"stripe-checkout"===t.gateway&&"free"!==s.gateway.slug&&s.gateway.data&&s.gateway.data.stripe_session_id&&(t.prevent_submission=!0,(await Stripe(e)).redirectToCheckout({sessionId:s.gateway.data.stripe_session_id}).then((function(e){e.error&&(console.log(e.error.message),document.getElementById("error-message").textContent=e.error.message)})))}))}));

View File

@ -0,0 +1,290 @@
/* eslint-disable */
/* global wu_stripe, Stripe */
let _stripe;
let stripeElement;
let card;
const stripeElements = function(publicKey) {
_stripe = Stripe(publicKey);
const elements = _stripe.elements();
card = elements.create('card', {
hidePostalCode: true,
});
wp.hooks.addFilter('wu_before_form_submitted', 'nextpress/wp-ultimo', function(promises, checkout, gateway) {
const cardEl = document.getElementById('card-element');
if (gateway === 'stripe' && checkout.order.totals.total > 0 && cardEl && cardEl.offsetParent) {
promises.push(new Promise( async (resolve, reject) => {
try {
const paymentMethod = await _stripe.createPaymentMethod({type: 'card', card});
if (paymentMethod.error) {
reject(paymentMethod.error);
} // end if;
} catch(err) {
} // end try;
resolve();
}));
} // end if;
return promises;
});
wp.hooks.addAction('wu_on_form_success', 'nextpress/wp-ultimo', function(checkout, results) {
if (checkout.gateway === 'stripe' && (checkout.order.totals.total > 0 || checkout.order.totals.recurring.total > 0)) {
checkout.set_prevent_submission(false);
handlePayment(checkout, results, card);
} // end if;
});
wp.hooks.addAction('wu_on_form_updated', 'nextpress/wp-ultimo', function(form) {
if (form.gateway === 'stripe') {
try {
card.mount('#card-element');
wu_stripe_update_styles(card, '#field-payment_template');
/*
* Prevents the from from submitting while Stripe is
* creating a payment source.
*/
form.set_prevent_submission(form.order && form.order.should_collect_payment && form.payment_method === 'add-new');
} catch (error) {
// Silence
} // end try;
} else {
form.set_prevent_submission(false);
try {
card.unmount('#card-element');
} catch (error) {
// Silence is golden
} // end try;
} // end if;
});
// Element focus ring
card.on('focus', function() {
const el = document.getElementById('card-element');
el.classList.add('focused');
});
card.on('blur', function() {
const el = document.getElementById('card-element');
el.classList.remove('focused');
});
};
wp.hooks.addFilter('wu_before_form_init', 'nextpress/wp-ultimo', function(data) {
data.add_new_card = wu_stripe.add_new_card;
data.payment_method = wu_stripe.payment_method;
return data;
});
wp.hooks.addAction('wu_checkout_loaded', 'nextpress/wp-ultimo', function() {
stripeElement = stripeElements(wu_stripe.pk_key);
});
/**
* Copy styles from an existing element to the Stripe Card Element.
*
* @param {Object} cardElement Stripe card element.
* @param {string} selector Selector to copy styles from.
*
* @since 3.3
*/
function wu_stripe_update_styles(cardElement, selector) {
if (undefined === typeof selector) {
selector = '#field-payment_template';
}
const inputField = document.querySelector(selector);
if (null === inputField) {
return;
}
if (document.getElementById('wu-stripe-styles')) {
return;
}
const inputStyles = window.getComputedStyle(inputField);
const styleTag = document.createElement('style');
styleTag.innerHTML = '.StripeElement {' +
'background-color:' + inputStyles.getPropertyValue('background-color') + ';' +
'border-top-color:' + inputStyles.getPropertyValue('border-top-color') + ';' +
'border-right-color:' + inputStyles.getPropertyValue('border-right-color') + ';' +
'border-bottom-color:' + inputStyles.getPropertyValue('border-bottom-color') + ';' +
'border-left-color:' + inputStyles.getPropertyValue('border-left-color') + ';' +
'border-top-width:' + inputStyles.getPropertyValue('border-top-width') + ';' +
'border-right-width:' + inputStyles.getPropertyValue('border-right-width') + ';' +
'border-bottom-width:' + inputStyles.getPropertyValue('border-bottom-width') + ';' +
'border-left-width:' + inputStyles.getPropertyValue('border-left-width') + ';' +
'border-top-style:' + inputStyles.getPropertyValue('border-top-style') + ';' +
'border-right-style:' + inputStyles.getPropertyValue('border-right-style') + ';' +
'border-bottom-style:' + inputStyles.getPropertyValue('border-bottom-style') + ';' +
'border-left-style:' + inputStyles.getPropertyValue('border-left-style') + ';' +
'border-top-left-radius:' + inputStyles.getPropertyValue('border-top-left-radius') + ';' +
'border-top-right-radius:' + inputStyles.getPropertyValue('border-top-right-radius') + ';' +
'border-bottom-left-radius:' + inputStyles.getPropertyValue('border-bottom-left-radius') + ';' +
'border-bottom-right-radius:' + inputStyles.getPropertyValue('border-bottom-right-radius') + ';' +
'padding-top:' + inputStyles.getPropertyValue('padding-top') + ';' +
'padding-right:' + inputStyles.getPropertyValue('padding-right') + ';' +
'padding-bottom:' + inputStyles.getPropertyValue('padding-bottom') + ';' +
'padding-left:' + inputStyles.getPropertyValue('padding-left') + ';' +
'line-height:' + inputStyles.getPropertyValue('height') + ';' +
'height:' + inputStyles.getPropertyValue('height') + ';' +
`display: flex;
flex-direction: column;
justify-content: center;` +
'}';
styleTag.id = 'wu-stripe-styles';
document.body.appendChild(styleTag);
cardElement.update({
style: {
base: {
color: inputStyles.getPropertyValue('color'),
fontFamily: inputStyles.getPropertyValue('font-family'),
fontSize: inputStyles.getPropertyValue('font-size'),
fontWeight: inputStyles.getPropertyValue('font-weight'),
fontSmoothing: inputStyles.getPropertyValue('-webkit-font-smoothing'),
},
},
});
}
function wu_stripe_handle_intent(handler, client_secret, args) {
const _handle_error = function (e) {
wu_checkout_form.unblock();
if (e.error) {
wu_checkout_form.errors.push(e.error);
} // end if;
} // end _handle_error;
try {
_stripe[handler](client_secret, args).then(function(results) {
if (results.error) {
_handle_error(results);
return;
} // end if;
wu_checkout_form.resubmit();
}, _handle_error);
} catch(e) {} // end if;
} // end if;
/**
* After registration has been processed, handle card payments.
*
* @param form
* @param response
* @param card
*/
function handlePayment(form, response, card) {
// Trigger error if we don't have a client secret.
if (! response.gateway.data.stripe_client_secret) {
return;
} // end if;
const handler = 'payment_intent' === response.gateway.data.stripe_intent_type ? 'confirmCardPayment' : 'confirmCardSetup';
const args = {
payment_method: form.payment_method !== 'add-new' ? form.payment_method : {
card,
billing_details: {
name: response.customer.display_name,
email: response.customer.user_email,
address: {
country: response.customer.billing_address_data.billing_country,
postal_code: response.customer.billing_address_data.billing_zip_code,
},
},
},
};
/**
* Handle payment intent / setup intent.
*/
wu_stripe_handle_intent(
handler, response.gateway.data.stripe_client_secret, args
);
}

1
assets/js/gateways/stripe.min.js vendored Normal file
View File

@ -0,0 +1 @@
let _stripe,stripeElement,card;const stripeElements=function(e){_stripe=Stripe(e);const t=_stripe.elements();card=t.create("card",{hidePostalCode:!0}),wp.hooks.addFilter("wu_before_form_submitted","nextpress/wp-ultimo",(function(e,t,r){const o=document.getElementById("card-element");return"stripe"===r&&t.order.totals.total>0&&o&&o.offsetParent&&e.push(new Promise(async(e,t)=>{try{const e=await _stripe.createPaymentMethod({type:"card",card:card});e.error&&t(e.error)}catch(e){}e()})),e})),wp.hooks.addAction("wu_on_form_success","nextpress/wp-ultimo",(function(e,t){"stripe"===e.gateway&&(e.order.totals.total>0||e.order.totals.recurring.total>0)&&(e.set_prevent_submission(!1),handlePayment(e,t,card))})),wp.hooks.addAction("wu_on_form_updated","nextpress/wp-ultimo",(function(e){if("stripe"===e.gateway)try{card.mount("#card-element"),wu_stripe_update_styles(card,"#field-payment_template"),e.set_prevent_submission(e.order&&e.order.should_collect_payment&&"add-new"===e.payment_method)}catch(e){}else{e.set_prevent_submission(!1);try{card.unmount("#card-element")}catch(e){}}})),card.on("focus",(function(){document.getElementById("card-element").classList.add("focused")})),card.on("blur",(function(){document.getElementById("card-element").classList.remove("focused")}))};function wu_stripe_update_styles(e,t){void 0===typeof t&&(t="#field-payment_template");const r=document.querySelector(t);if(null===r)return;if(document.getElementById("wu-stripe-styles"))return;const o=window.getComputedStyle(r),d=document.createElement("style");d.innerHTML=".StripeElement {background-color:"+o.getPropertyValue("background-color")+";border-top-color:"+o.getPropertyValue("border-top-color")+";border-right-color:"+o.getPropertyValue("border-right-color")+";border-bottom-color:"+o.getPropertyValue("border-bottom-color")+";border-left-color:"+o.getPropertyValue("border-left-color")+";border-top-width:"+o.getPropertyValue("border-top-width")+";border-right-width:"+o.getPropertyValue("border-right-width")+";border-bottom-width:"+o.getPropertyValue("border-bottom-width")+";border-left-width:"+o.getPropertyValue("border-left-width")+";border-top-style:"+o.getPropertyValue("border-top-style")+";border-right-style:"+o.getPropertyValue("border-right-style")+";border-bottom-style:"+o.getPropertyValue("border-bottom-style")+";border-left-style:"+o.getPropertyValue("border-left-style")+";border-top-left-radius:"+o.getPropertyValue("border-top-left-radius")+";border-top-right-radius:"+o.getPropertyValue("border-top-right-radius")+";border-bottom-left-radius:"+o.getPropertyValue("border-bottom-left-radius")+";border-bottom-right-radius:"+o.getPropertyValue("border-bottom-right-radius")+";padding-top:"+o.getPropertyValue("padding-top")+";padding-right:"+o.getPropertyValue("padding-right")+";padding-bottom:"+o.getPropertyValue("padding-bottom")+";padding-left:"+o.getPropertyValue("padding-left")+";line-height:"+o.getPropertyValue("height")+";height:"+o.getPropertyValue("height")+";display: flex;\n flex-direction: column;\n justify-content: center;}",d.id="wu-stripe-styles",document.body.appendChild(d),e.update({style:{base:{color:o.getPropertyValue("color"),fontFamily:o.getPropertyValue("font-family"),fontSize:o.getPropertyValue("font-size"),fontWeight:o.getPropertyValue("font-weight"),fontSmoothing:o.getPropertyValue("-webkit-font-smoothing")}}})}function wu_stripe_handle_intent(e,t,r){const o=function(e){wu_checkout_form.unblock(),e.error&&wu_checkout_form.errors.push(e.error)};try{_stripe[e](t,r).then((function(e){e.error?o(e):wu_checkout_form.resubmit()}),o)}catch(e){}}function handlePayment(e,t,r){if(!t.gateway.data.stripe_client_secret)return;const o="payment_intent"===t.gateway.data.stripe_intent_type?"confirmCardPayment":"confirmCardSetup",d={payment_method:"add-new"!==e.payment_method?e.payment_method:{card:r,billing_details:{name:t.customer.display_name,email:t.customer.user_email,address:{country:t.customer.billing_address_data.billing_country,postal_code:t.customer.billing_address_data.billing_zip_code}}}};wu_stripe_handle_intent(o,t.gateway.data.stripe_client_secret,d)}wp.hooks.addFilter("wu_before_form_init","nextpress/wp-ultimo",(function(e){return e.add_new_card=wu_stripe.add_new_card,e.payment_method=wu_stripe.payment_method,e})),wp.hooks.addAction("wu_checkout_loaded","nextpress/wp-ultimo",(function(){stripeElement=stripeElements(wu_stripe.pk_key)}));

View File

@ -0,0 +1,61 @@
/* eslint-disable no-multi-str */
/* global wu_gutenberg */
(function($) {
$(document).ready(function() {
/**
* Filter that receives the content from the preview markup and make modifications to it.
*
* @param {*} content
*/
const custom_gutenberg_preview_message = function(content) {
content = content.replace(wp.i18n.__('Generating preview…'), wu_gutenberg.replacement_message);
const img = '<img class="wu-logo" src="' + wu_gutenberg.logo + '"><p>';
content = content.replace('<p>', img);
content += '<style> \
svg { \
display: none !important; \
} \
img.wu-logo { \
opacity: 0; \
animation: fade-in-right ease 1s forwards; \
max-width: 100px; \
height: auto; \
padding: 20px; \
} \
@keyframes fade-in-right { \
from { \
opacity: 0; \
transform: translateY(-15px); \
} \
to { \
opacity: 1; \
transform: translateY(0); \
} \
} \
</style>';
return content;
};
/**
* Check if the hooks are set to avoid bugs and breaking other scripts.
*/
if (typeof wp === 'object' && typeof wp.hooks === 'object') {
/**
* Pass as a wp hook
*/
wp.hooks.addFilter('editor.PostPreview.interstitialMarkup', 'wp-ultimo/custom-preview-message', custom_gutenberg_preview_message);
} // end if;
});
}(jQuery));

1
assets/js/gutenberg-support.min.js vendored Normal file
View File

@ -0,0 +1 @@
jQuery(document).ready((function(){const e=function(e){e=e.replace(wp.i18n.__("Generating preview…"),wu_gutenberg.replacement_message);const t='<img class="wu-logo" src="'+wu_gutenberg.logo+'"><p>';return e=e.replace("<p>",t),e+="<style> svg { display: none !important; } img.wu-logo { opacity: 0; animation: fade-in-right ease 1s forwards; max-width: 100px; height: auto; padding: 20px; } @keyframes fade-in-right { from { opacity: 0; transform: translateY(-15px); } to { opacity: 1; transform: translateY(0); } } </style>"};"object"==typeof wp&&"object"==typeof wp.hooks&&wp.hooks.addFilter("editor.PostPreview.interstitialMarkup","wp-ultimo/custom-preview-message",e)}));

165
assets/js/jumper.js Normal file
View File

@ -0,0 +1,165 @@
/* eslint-disable no-undef */
(function($) {
$(document).ready(function() {
// Adds WUChosen.js to our custom select input
const $jumper = $('#wu-jumper-select').selectize({
create: false,
maxItems: 1,
optgroupField: 'group',
optgroupValueField: 'value',
searchField: ['text', 'name', 'display_name', 'domain', 'title', 'desc', 'code'],
render: {
option(option) {
if (typeof option.model === 'undefined') {
option.model = 'jumper-link';
} // end if;
if (typeof option.text === 'undefined') {
option.text = option.reference_code || option.name || option.title || option.display_name || option.code;
} // end if;
if (typeof option.group === 'undefined') {
option.group = option.model;
} // end if;
const template_html = jQuery('#wu-template-' + option.model).length ?
jQuery('#wu-template-' + option.model).html() :
jQuery('#wu-template-default').html();
const template = _.template(template_html, {
interpolate: /\{\{(.+?)\}\}/g,
});
return template(option);
},
},
load(query, callback) {
if (! query.length) {
return callback();
} // end if;
$('#wu-jumper .wu-jumper-loading').show();
jQuery.ajax({
// eslint-disable-next-line no-undef
url: wu_jumper_vars.ajaxurl,
type: 'POST',
data: {
action: 'wu_search',
model: 'all',
number: 99,
query: {
search: '*' + query + '*',
},
},
error() {
callback();
},
success(res) {
$('#wu-jumper .wu-jumper-loading').hide();
callback(res);
},
});
},
});
const is_local_url = function(url) {
return url.toLowerCase().indexOf(wu_jumper_vars.base_url) >= 0 || url.toLowerCase().indexOf(wu_jumper_vars.network_base_url) >= 0;
}; // end is_local_url
// Every time the value changes, we need to redirect the user
$jumper.on('change', function() {
// Check if we need to open this in a new tab
if (is_local_url($(this).val())) {
window.location.href = $(this).val();
$(this).parent().parent().find('.wu-jumper-redirecting').show();
} else {
window.open($(this).val(), '_blank');
$($jumper.parent()).hide();
} // end if;
});
// Closes on clicking other elements
$(document).on('click', ':not(#wu-jumper-button-trigger)', function(e) {
const target = e.target;
if ($(target).attr('id') === 'wu-jumper-button-trigger' || $(target).parent().attr('id') === 'wu-jumper-button-trigger') {
return;
} // end if;
if (! $(target).is($jumper.parent()) && ! $(target).parents().is($jumper.parent())) {
$($jumper.parent().parent()).hide();
} // end if;
});
const trigger_key = wu_jumper_vars.trigger_key.charAt(0);
// Our bar is hidden by default, we need to display it when a certain shortcut is pressed
Mousetrap.bind(['command+option+' + trigger_key, 'ctrl+alt+' + trigger_key], function(e) {
e.preventDefault();
open_jumper();
}); // end mousetrap;
$(document).on('click', '#wu-jumper-button-trigger', function(e) {
e.preventDefault();
open_jumper();
});
/**
* Actually opens the jumper.
*/
function open_jumper() {
$('#wu-jumper').show();
$('#wu-jumper').find('input').focus();
return false;
} // end open_jumper;
});
}(jQuery));

1
assets/js/jumper.min.js vendored Normal file
View File

@ -0,0 +1 @@
!function(e){e(document).ready((function(){const t=e("#wu-jumper-select").selectize({create:!1,maxItems:1,optgroupField:"group",optgroupValueField:"value",searchField:["text","name","display_name","domain","title","desc","code"],render:{option(e){void 0===e.model&&(e.model="jumper-link"),void 0===e.text&&(e.text=e.reference_code||e.name||e.title||e.display_name||e.code),void 0===e.group&&(e.group=e.model);const t=jQuery("#wu-template-"+e.model).length?jQuery("#wu-template-"+e.model).html():jQuery("#wu-template-default").html();return _.template(t,{interpolate:/\{\{(.+?)\}\}/g})(e)}},load(t,r){if(!t.length)return r();e("#wu-jumper .wu-jumper-loading").show(),jQuery.ajax({url:wu_jumper_vars.ajaxurl,type:"POST",data:{action:"wu_search",model:"all",number:99,query:{search:"*"+t+"*"}},error(){r()},success(t){e("#wu-jumper .wu-jumper-loading").hide(),r(t)}})}});t.on("change",(function(){var r;(r=e(this).val()).toLowerCase().indexOf(wu_jumper_vars.base_url)>=0||r.toLowerCase().indexOf(wu_jumper_vars.network_base_url)>=0?(window.location.href=e(this).val(),e(this).parent().parent().find(".wu-jumper-redirecting").show()):(window.open(e(this).val(),"_blank"),e(t.parent()).hide())})),e(document).on("click",":not(#wu-jumper-button-trigger)",(function(r){const u=r.target;"wu-jumper-button-trigger"!==e(u).attr("id")&&"wu-jumper-button-trigger"!==e(u).parent().attr("id")&&(e(u).is(t.parent())||e(u).parents().is(t.parent())||e(t.parent().parent()).hide())}));const r=wu_jumper_vars.trigger_key.charAt(0);function u(){return e("#wu-jumper").show(),e("#wu-jumper").find("input").focus(),!1}Mousetrap.bind(["command+option+"+r,"ctrl+alt+"+r],(function(e){e.preventDefault(),u()})),e(document).on("click","#wu-jumper-button-trigger",(function(e){e.preventDefault(),u()}))}))}(jQuery);

View File

@ -0,0 +1,13 @@
(() => {
"use strict";
const { addFilter } = window.wp.hooks;
document.addEventListener("DOMContentLoaded", () => {
addFilter("wu_before_form_init", "nextpress/wp-ultimo", (data) => {
if (typeof data !== "undefined") {
data.billing_option = 1;
data.default_billing_option = 12;
}
return data;
});
});
})()

1
assets/js/legacy-signup.min.js vendored Normal file
View File

@ -0,0 +1 @@
(()=>{"use strict";const{addFilter:o}=window.wp.hooks;document.addEventListener("DOMContentLoaded",(()=>{o("wu_before_form_init","nextpress/wp-ultimo",(o=>(void 0!==o&&(o.billing_option=1,o.default_billing_option=12),o)))}))})();

413
assets/js/lib/accounting.js Normal file
View File

@ -0,0 +1,413 @@
/*!
* accounting.js v0.4.2
* Copyright 2014 Open Exchange Rates
*
* Freely distributable under the MIT license.
* Portions of accounting.js are inspired or borrowed from underscore.js
*
* Full details and documentation:
* http://openexchangerates.github.io/accounting.js/
*/
(function(root, undefined) {
/* --- Setup --- */
// Create the local library object, to be exported or referenced globally later
var lib = {};
// Current version
lib.version = '0.4.1';
/* --- Exposed settings --- */
// The library's settings configuration object. Contains default parameters for
// currency and number formatting
lib.settings = {
currency: {
symbol : "$", // default currency symbol is '$'
format : "%s%v", // controls output: %s = symbol, %v = value (can be object, see docs)
decimal : ".", // decimal point separator
thousand : ",", // thousands separator
precision : 2, // decimal places
grouping : 3 // digit grouping (not implemented yet)
},
number: {
precision : 0, // default precision on numbers is 0
grouping : 3, // digit grouping (not implemented yet)
thousand : ",",
decimal : "."
}
};
/* --- Internal Helper Methods --- */
// Store reference to possibly-available ECMAScript 5 methods for later
var nativeMap = Array.prototype.map,
nativeIsArray = Array.isArray,
toString = Object.prototype.toString;
/**
* Tests whether supplied parameter is a string
* from underscore.js
*/
function isString(obj) {
return !!(obj === '' || (obj && obj.charCodeAt && obj.substr));
}
/**
* Tests whether supplied parameter is a string
* from underscore.js, delegates to ECMA5's native Array.isArray
*/
function isArray(obj) {
return nativeIsArray ? nativeIsArray(obj) : toString.call(obj) === '[object Array]';
}
/**
* Tests whether supplied parameter is a true object
*/
function isObject(obj) {
return obj && toString.call(obj) === '[object Object]';
}
/**
* Extends an object with a defaults object, similar to underscore's _.defaults
*
* Used for abstracting parameter handling from API methods
*/
function defaults(object, defs) {
var key;
object = object || {};
defs = defs || {};
// Iterate over object non-prototype properties:
for (key in defs) {
if (defs.hasOwnProperty(key)) {
// Replace values with defaults only if undefined (allow empty/zero values):
if (object[key] == null) object[key] = defs[key];
}
}
return object;
}
/**
* Implementation of `Array.map()` for iteration loops
*
* Returns a new Array as a result of calling `iterator` on each array value.
* Defers to native Array.map if available
*/
function map(obj, iterator, context) {
var results = [], i, j;
if (!obj) return results;
// Use native .map method if it exists:
if (nativeMap && obj.map === nativeMap) return obj.map(iterator, context);
// Fallback for native .map:
for (i = 0, j = obj.length; i < j; i++ ) {
results[i] = iterator.call(context, obj[i], i, obj);
}
return results;
}
/**
* Check and normalise the value of precision (must be positive integer)
*/
function checkPrecision(val, base) {
val = Math.round(Math.abs(val));
return isNaN(val)? base : val;
}
/**
* Parses a format string or object and returns format obj for use in rendering
*
* `format` is either a string with the default (positive) format, or object
* containing `pos` (required), `neg` and `zero` values (or a function returning
* either a string or object)
*
* Either string or format.pos must contain "%v" (value) to be valid
*/
function checkCurrencyFormat(format) {
var defaults = lib.settings.currency.format;
// Allow function as format parameter (should return string or object):
if ( typeof format === "function" ) format = format();
// Format can be a string, in which case `value` ("%v") must be present:
if ( isString( format ) && format.match("%v") ) {
// Create and return positive, negative and zero formats:
return {
pos : format,
neg : format.replace("-", "").replace("%v", "-%v"),
zero : format
};
// If no format, or object is missing valid positive value, use defaults:
} else if ( !format || !format.pos || !format.pos.match("%v") ) {
// If defaults is a string, casts it to an object for faster checking next time:
return ( !isString( defaults ) ) ? defaults : lib.settings.currency.format = {
pos : defaults,
neg : defaults.replace("%v", "-%v"),
zero : defaults
};
}
// Otherwise, assume format was fine:
return format;
}
/* --- API Methods --- */
/**
* Takes a string/array of strings, removes all formatting/cruft and returns the raw float value
* Alias: `accounting.parse(string)`
*
* Decimal must be included in the regular expression to match floats (defaults to
* accounting.settings.number.decimal), so if the number uses a non-standard decimal
* separator, provide it as the second argument.
*
* Also matches bracketed negatives (eg. "$ (1.99)" => -1.99)
*
* Doesn't throw any errors (`NaN`s become 0) but this may change in future
*/
var unformat = lib.unformat = lib.parse = function(value, decimal) {
// Recursively unformat arrays:
if (isArray(value)) {
return map(value, function(val) {
return unformat(val, decimal);
});
}
// Fails silently (need decent errors):
value = value || 0;
// Return the value as-is if it's already a number:
if (typeof value === "number") return value;
// Default decimal point comes from settings, but could be set to eg. "," in opts:
decimal = decimal || lib.settings.number.decimal;
// Build regex to strip out everything except digits, decimal point and minus sign:
var regex = new RegExp("[^0-9-" + decimal + "]", ["g"]),
unformatted = parseFloat(
("" + value)
.replace(/\((.*)\)/, "-$1") // replace bracketed values with negatives
.replace(regex, '') // strip out any cruft
.replace(decimal, '.') // make sure decimal point is standard
);
// This will fail silently which may cause trouble, let's wait and see:
return !isNaN(unformatted) ? unformatted : 0;
};
/**
* Implementation of toFixed() that treats floats more like decimals
*
* Fixes binary rounding issues (eg. (0.615).toFixed(2) === "0.61") that present
* problems for accounting- and finance-related software.
*/
var toFixed = lib.toFixed = function(value, precision) {
precision = checkPrecision(precision, lib.settings.number.precision);
var power = Math.pow(10, precision);
// Multiply up by precision, round accurately, then divide and use native toFixed():
return (Math.round(lib.unformat(value) * power) / power).toFixed(precision);
};
/**
* Format a number, with comma-separated thousands and custom precision/decimal places
* Alias: `accounting.format()`
*
* Localise by overriding the precision and thousand / decimal separators
* 2nd parameter `precision` can be an object matching `settings.number`
*/
var formatNumber = lib.formatNumber = lib.format = function(number, precision, thousand, decimal) {
// Resursively format arrays:
if (isArray(number)) {
return map(number, function(val) {
return formatNumber(val, precision, thousand, decimal);
});
}
// Clean up number:
number = unformat(number);
// Build options object from second param (if object) or all params, extending defaults:
var opts = defaults(
(isObject(precision) ? precision : {
precision : precision,
thousand : thousand,
decimal : decimal
}),
lib.settings.number
),
// Clean up precision
usePrecision = checkPrecision(opts.precision),
// Do some calc:
negative = number < 0 ? "-" : "",
base = parseInt(toFixed(Math.abs(number || 0), usePrecision), 10) + "",
mod = base.length > 3 ? base.length % 3 : 0;
// Format the number:
return negative + (mod ? base.substr(0, mod) + opts.thousand : "") + base.substr(mod).replace(/(\d{3})(?=\d)/g, "$1" + opts.thousand) + (usePrecision ? opts.decimal + toFixed(Math.abs(number), usePrecision).split('.')[1] : "");
};
/**
* Format a number into currency
*
* Usage: accounting.formatMoney(number, symbol, precision, thousandsSep, decimalSep, format)
* defaults: (0, "$", 2, ",", ".", "%s%v")
*
* Localise by overriding the symbol, precision, thousand / decimal separators and format
* Second param can be an object matching `settings.currency` which is the easiest way.
*
* To do: tidy up the parameters
*/
var formatMoney = lib.formatMoney = function(number, symbol, precision, thousand, decimal, format) {
// Resursively format arrays:
if (isArray(number)) {
return map(number, function(val){
return formatMoney(val, symbol, precision, thousand, decimal, format);
});
}
// Clean up number:
number = unformat(number);
// Build options object from second param (if object) or all params, extending defaults:
var opts = defaults(
(isObject(symbol) ? symbol : {
symbol : symbol,
precision : precision,
thousand : thousand,
decimal : decimal,
format : format
}),
lib.settings.currency
),
// Check format (returns object with pos, neg and zero):
formats = checkCurrencyFormat(opts.format),
// Choose which format to use for this value:
useFormat = number > 0 ? formats.pos : number < 0 ? formats.neg : formats.zero;
// Return with currency symbol added:
return useFormat.replace('%s', opts.symbol).replace('%v', formatNumber(Math.abs(number), checkPrecision(opts.precision), opts.thousand, opts.decimal));
};
/**
* Format a list of numbers into an accounting column, padding with whitespace
* to line up currency symbols, thousand separators and decimals places
*
* List should be an array of numbers
* Second parameter can be an object containing keys that match the params
*
* Returns array of accouting-formatted number strings of same length
*
* NB: `white-space:pre` CSS rule is required on the list container to prevent
* browsers from collapsing the whitespace in the output strings.
*/
lib.formatColumn = function(list, symbol, precision, thousand, decimal, format) {
if (!list) return [];
// Build options object from second param (if object) or all params, extending defaults:
var opts = defaults(
(isObject(symbol) ? symbol : {
symbol : symbol,
precision : precision,
thousand : thousand,
decimal : decimal,
format : format
}),
lib.settings.currency
),
// Check format (returns object with pos, neg and zero), only need pos for now:
formats = checkCurrencyFormat(opts.format),
// Whether to pad at start of string or after currency symbol:
padAfterSymbol = formats.pos.indexOf("%s") < formats.pos.indexOf("%v") ? true : false,
// Store value for the length of the longest string in the column:
maxLength = 0,
// Format the list according to options, store the length of the longest string:
formatted = map(list, function(val, i) {
if (isArray(val)) {
// Recursively format columns if list is a multi-dimensional array:
return lib.formatColumn(val, opts);
} else {
// Clean up the value
val = unformat(val);
// Choose which format to use for this value (pos, neg or zero):
var useFormat = val > 0 ? formats.pos : val < 0 ? formats.neg : formats.zero,
// Format this value, push into formatted list and save the length:
fVal = useFormat.replace('%s', opts.symbol).replace('%v', formatNumber(Math.abs(val), checkPrecision(opts.precision), opts.thousand, opts.decimal));
if (fVal.length > maxLength) maxLength = fVal.length;
return fVal;
}
});
// Pad each number in the list and send back the column of numbers:
return map(formatted, function(val, i) {
// Only if this is a string (not a nested array, which would have already been padded):
if (isString(val) && val.length < maxLength) {
// Depending on symbol position, pad after symbol or at index 0:
return padAfterSymbol ? val.replace(opts.symbol, opts.symbol+(new Array(maxLength - val.length + 1).join(" "))) : (new Array(maxLength - val.length + 1).join(" ")) + val;
}
return val;
});
};
/* --- Module Definition --- */
// Export accounting for CommonJS. If being loaded as an AMD module, define it as such.
// Otherwise, just add `accounting` to the global object
if (typeof exports !== 'undefined') {
if (typeof module !== 'undefined' && module.exports) {
exports = module.exports = lib;
}
exports.accounting = lib;
} else if (typeof define === 'function' && define.amd) {
// Return the library as an AMD module:
define([], function() {
return lib;
});
} else {
// Use accounting.noConflict to restore `accounting` back to its original value.
// Returns a reference to the library's `accounting` object;
// e.g. `var numbers = accounting.noConflict();`
lib.noConflict = (function(oldAccounting) {
return function() {
// Reset the value of the root's `accounting` variable:
root.accounting = oldAccounting;
// Delete the noConflict method:
lib.noConflict = undefined;
// Return reference to the library to re-assign it:
return lib;
};
})(root.accounting);
// Declare `fx` on the root (global/window) object:
root['accounting'] = lib;
}
// Root will be `window` in browser or `global` on the server:
}(this));

11
assets/js/lib/accounting.min.js vendored Normal file
View File

@ -0,0 +1,11 @@
/*!
* accounting.js v0.4.2
* Copyright 2014 Open Exchange Rates
*
* Freely distributable under the MIT license.
* Portions of accounting.js are inspired or borrowed from underscore.js
*
* Full details and documentation:
* http://openexchangerates.github.io/accounting.js/
*/
!function(n,r){var e={version:"0.4.1",settings:{currency:{symbol:"$",format:"%s%v",decimal:".",thousand:",",precision:2,grouping:3},number:{precision:0,grouping:3,thousand:",",decimal:"."}}},t=Array.prototype.map,o=Array.isArray,a=Object.prototype.toString;function i(n){return!!(""===n||n&&n.charCodeAt&&n.substr)}function u(n){return o?o(n):"[object Array]"===a.call(n)}function c(n){return n&&"[object Object]"===a.call(n)}function s(n,r){var e;for(e in n=n||{},r=r||{})r.hasOwnProperty(e)&&null==n[e]&&(n[e]=r[e]);return n}function f(n,r,e){var o,a,i=[];if(!n)return i;if(t&&n.map===t)return n.map(r,e);for(o=0,a=n.length;o<a;o++)i[o]=r.call(e,n[o],o,n);return i}function p(n,r){return n=Math.round(Math.abs(n)),isNaN(n)?r:n}function l(n){var r=e.settings.currency.format;return"function"==typeof n&&(n=n()),i(n)&&n.match("%v")?{pos:n,neg:n.replace("-","").replace("%v","-%v"),zero:n}:n&&n.pos&&n.pos.match("%v")?n:i(r)?e.settings.currency.format={pos:r,neg:r.replace("%v","-%v"),zero:r}:r}var m,d=e.unformat=e.parse=function(n,r){if(u(n))return f(n,(function(n){return d(n,r)}));if("number"==typeof(n=n||0))return n;r=r||e.settings.number.decimal;var t=new RegExp("[^0-9-"+r+"]",["g"]),o=parseFloat((""+n).replace(/\((.*)\)/,"-$1").replace(t,"").replace(r,"."));return isNaN(o)?0:o},g=e.toFixed=function(n,r){r=p(r,e.settings.number.precision);var t=Math.pow(10,r);return(Math.round(e.unformat(n)*t)/t).toFixed(r)},h=e.formatNumber=e.format=function(n,r,t,o){if(u(n))return f(n,(function(n){return h(n,r,t,o)}));n=d(n);var a=s(c(r)?r:{precision:r,thousand:t,decimal:o},e.settings.number),i=p(a.precision),l=n<0?"-":"",m=parseInt(g(Math.abs(n||0),i),10)+"",y=m.length>3?m.length%3:0;return l+(y?m.substr(0,y)+a.thousand:"")+m.substr(y).replace(/(\d{3})(?=\d)/g,"$1"+a.thousand)+(i?a.decimal+g(Math.abs(n),i).split(".")[1]:"")},y=e.formatMoney=function(n,r,t,o,a,i){if(u(n))return f(n,(function(n){return y(n,r,t,o,a,i)}));n=d(n);var m=s(c(r)?r:{symbol:r,precision:t,thousand:o,decimal:a,format:i},e.settings.currency),g=l(m.format);return(n>0?g.pos:n<0?g.neg:g.zero).replace("%s",m.symbol).replace("%v",h(Math.abs(n),p(m.precision),m.thousand,m.decimal))};e.formatColumn=function(n,r,t,o,a,m){if(!n)return[];var g=s(c(r)?r:{symbol:r,precision:t,thousand:o,decimal:a,format:m},e.settings.currency),y=l(g.format),b=y.pos.indexOf("%s")<y.pos.indexOf("%v"),v=0,x=f(n,(function(n,r){if(u(n))return e.formatColumn(n,g);var t=((n=d(n))>0?y.pos:n<0?y.neg:y.zero).replace("%s",g.symbol).replace("%v",h(Math.abs(n),p(g.precision),g.thousand,g.decimal));return t.length>v&&(v=t.length),t}));return f(x,(function(n,r){return i(n)&&n.length<v?b?n.replace(g.symbol,g.symbol+new Array(v-n.length+1).join(" ")):new Array(v-n.length+1).join(" ")+n:n}))},"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=e),exports.accounting=e):"function"==typeof define&&define.amd?define([],(function(){return e})):(e.noConflict=(m=n.accounting,function(){return n.accounting=m,e.noConflict=void 0,e}),n.accounting=e)}(this);

File diff suppressed because one or more lines are too long

6
assets/js/lib/apexcharts.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,206 @@
/**
*
* detectIncognito v22.01.x - (c) 2022 Joe Rutkowski <Joe@dreggle.com> (https://github.com/Joe12387/detectIncognito)
*
* Incognito & Private Browsing detection
*
* Support: Safari for iOS -- 8 to 15
* Safari for macOS <= 15
* Chrome/Chromium -- 50 to 96
* Edge -- 15 - 18; 79 to 96
* Firefox -- 44 to 95
* MSIE >= 10
*
**/
var detectIncognito = function (callback) {
var browserName = "Unknown";
function __callback(isPrivate) {
callback({
isPrivate: isPrivate,
browserName: browserName
});
}
function identifyChromium() {
var ua = navigator.userAgent;
if (ua.match(/Chrome/)) {
if (ua.match(/Edg/)) {
return "Edge"
} else if (navigator.brave !== undefined) {
return "Brave";
} else if (navigator.opr !== undefined) {
return "Opera";
}
return "Chrome";
} else {
return "Chromium";
}
}
function assertEvalToString(value) {
return value === eval.toString().length;
}
function isSafari() {
var v = navigator.vendor;
return v !== undefined && v.indexOf("Apple") === 0 && assertEvalToString(37);
}
function isChrome() {
var v = navigator.vendor;
return v !== undefined && v.indexOf("Google") === 0 && assertEvalToString(33);
}
function isFirefox() {
return document.documentElement !== undefined && document.documentElement.style.MozAppearance !== undefined && assertEvalToString(37);
}
function isMSIE() {
return navigator.msSaveBlob !== undefined && assertEvalToString(39);
}
/**
* Safari (Safari for iOS & macOS)
**/
function macOS_safari14() {
try {
window.safari.pushNotification.requestPermission("https://example.com", "private", {}, (function () { }));
} catch (e) {
return __callback(!new RegExp("gesture").test(e));
}
return __callback(false);
}
function iOS_safari14() {
var tripped = false;
var iframe = document.createElement("iframe");
iframe.style.display = "none";
document.body.appendChild(iframe);
iframe.contentWindow.applicationCache.addEventListener("error", function () {
tripped = true;
return __callback(true);
});
setTimeout(function () {
if (!tripped) {
__callback(false);
}
}, 100);
}
function oldSafariTest() {
var openDB = window.openDatabase;
var storage = window.localStorage;
try {
openDB(null, null, null, null);
} catch (e) {
return __callback(true);
}
try {
storage.setItem("test", "1");
storage.removeItem("test");
} catch (e) {
return __callback(true);
}
return __callback(false);
}
function safariPrivateTest() {
var w = window;
if (navigator.maxTouchPoints !== undefined) {
if (w.safari !== undefined && w.DeviceMotionEvent === undefined) {
browserName = "Safari for macOS";
macOS_safari14();
} else if (w.DeviceMotionEvent !== undefined) {
browserName = "Safari for iOS";
iOS_safari14();
} else {
throw new Error("detectIncognito Could not identify this version of Safari");
}
} else {
oldSafariTest();
}
}
/**
* Chrome
**/
function getQuotaLimit() {
var w = window;
if (w.performance !== undefined && w.performance.memory !== undefined && w.performance.memory.jsHeapSizeLimit !== undefined) {
return performance.memory.jsHeapSizeLimit;
}
return 1073741824;
}
// >= 76
function storageQuotaChromePrivateTest() {
navigator.webkitTemporaryStorage.queryUsageAndQuota(
function (usage, quota) {
__callback(quota < getQuotaLimit());
},
function (e) {
throw new Error("detectIncognito somehow failed to query storage quota: " + e.message);
}
);
}
// 50 to 75
function oldChromePrivateTest() {
var fs = window.webkitRequestFileSystem;
var success = function () {
__callback(false);
};
var error = function () {
__callback(true);
};
fs(0, 1, success, error);
}
function chromePrivateTest() {
if (Promise !== undefined && Promise.allSettled !== undefined) {
storageQuotaChromePrivateTest();
} else {
oldChromePrivateTest();
}
}
/**
* Firefox
**/
function firefoxPrivateTest() {
__callback(navigator.serviceWorker === undefined);
}
/**
* MSIE
**/
function msiePrivateTest() {
__callback(window.indexedDB === undefined);
}
function main() {
if (isSafari()) {
safariPrivateTest();
} else if (isChrome()) {
browserName = identifyChromium();
chromePrivateTest();
} else if (isFirefox()) {
browserName = "Firefox";
firefoxPrivateTest();
} else if (isMSIE()) {
browserName = "Internet Explorer";
msiePrivateTest();
} else {
throw new Error("detectIncognito cannot determine the browser");
}
}
main();
};

1
assets/js/lib/detectincognito.min.js vendored Normal file
View File

@ -0,0 +1 @@
var detectIncognito=function(e){var o="Unknown";function n(n){e({isPrivate:n,browserName:o})}function t(e){return e===eval.toString().length}function i(){var e,t,i=window;if(void 0!==navigator.maxTouchPoints)if(void 0!==i.safari&&void 0===i.DeviceMotionEvent)o="Safari for macOS",function(){try{window.safari.pushNotification.requestPermission("https://example.com","private",{},(function(){}))}catch(e){return n(!new RegExp("gesture").test(e))}n(!1)}();else{if(void 0===i.DeviceMotionEvent)throw new Error("detectIncognito Could not identify this version of Safari");o="Safari for iOS",e=!1,(t=document.createElement("iframe")).style.display="none",document.body.appendChild(t),t.contentWindow.applicationCache.addEventListener("error",(function(){return e=!0,n(!0)})),setTimeout((function(){e||n(!1)}),100)}else!function(){var e=window.openDatabase,o=window.localStorage;try{e(null,null,null,null)}catch(e){return n(!0)}try{o.setItem("test","1"),o.removeItem("test")}catch(e){return n(!0)}n(!1)}()}function r(){navigator.webkitTemporaryStorage.queryUsageAndQuota((function(e,o){var t;n(o<(void 0!==(t=window).performance&&void 0!==t.performance.memory&&void 0!==t.performance.memory.jsHeapSizeLimit?performance.memory.jsHeapSizeLimit:1073741824))}),(function(e){throw new Error("detectIncognito somehow failed to query storage quota: "+e.message)}))}function a(){void 0!==Promise&&void 0!==Promise.allSettled?r():(0,window.webkitRequestFileSystem)(0,1,(function(){n(!1)}),(function(){n(!0)}))}!function(){if(void 0!==(r=navigator.vendor)&&0===r.indexOf("Apple")&&t(37))i();else if(function(){var e=navigator.vendor;return void 0!==e&&0===e.indexOf("Google")&&t(33)}())e=navigator.userAgent,o=e.match(/Chrome/)?e.match(/Edg/)?"Edge":void 0!==navigator.brave?"Brave":void 0!==navigator.opr?"Opera":"Chrome":"Chromium",a();else if(void 0!==document.documentElement&&void 0!==document.documentElement.style.MozAppearance&&t(37))o="Firefox",n(void 0===navigator.serviceWorker);else{if(void 0===navigator.msSaveBlob||!t(39))throw new Error("detectIncognito cannot determine the browser");o="Internet Explorer",n(void 0===window.indexedDB)}var e,r}()};

10
assets/js/lib/es6-promise.auto.min.js vendored Normal file

File diff suppressed because one or more lines are too long

2610
assets/js/lib/flatpicker.js Normal file

File diff suppressed because it is too large Load Diff

16
assets/js/lib/flatpicker.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,622 @@
/*!
* jQuery blockUI plugin
* Version 2.70.0-2014.11.23
* Requires jQuery v1.7 or later
*
* This was heavily modified to make use of the new jQuery apis and remove deprecated code.
*
* Examples at: http://malsup.com/jquery/block/
* Copyright (c) 2007-2013 M. Alsup
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*
* Thanks to Amir-Hossein Sobhi for some excellent contributions!
*/
;(function() {
/*jshint eqeqeq:false curly:false latedef:false */
"use strict";
function setup($) {
$.fn._fadeIn = $.fn.fadeIn;
var noOp = $.noop || function() {};
// this bit is to ensure we don't call setExpression when we shouldn't (with extra muscle to handle
// confusing userAgent strings on Vista)
var msie = /MSIE/.test(navigator.userAgent);
var ie6 = /MSIE 6.0/.test(navigator.userAgent) && ! /MSIE 8.0/.test(navigator.userAgent);
var mode = document.documentMode || 0;
var setExpr = typeof document.createElement('div').style.setExpression === "function";
// global $ methods for blocking/unblocking the entire page
$.blockUI = function(opts) { install(window, opts); };
$.unblockUI = function(opts) { remove(window, opts); };
// convenience method for quick growl-like notifications (http://www.google.com/search?q=growl)
$.growlUI = function(title, message, timeout, onClose) {
var $m = $('<div class="growlUI"></div>');
if (title) $m.append('<h1>'+title+'</h1>');
if (message) $m.append('<h2>'+message+'</h2>');
if (timeout === undefined) timeout = 3000;
// Added by konapun: Set timeout to 30 seconds if this growl is moused over, like normal toast notifications
var callBlock = function(opts) {
opts = opts || {};
$.blockUI({
message: $m,
fadeIn : typeof opts.fadeIn !== 'undefined' ? opts.fadeIn : 700,
fadeOut: typeof opts.fadeOut !== 'undefined' ? opts.fadeOut : 1000,
timeout: typeof opts.timeout !== 'undefined' ? opts.timeout : timeout,
centerY: false,
showOverlay: false,
onUnblock: onClose,
css: $.blockUI.defaults.growlCSS
});
};
callBlock();
var nonmousedOpacity = $m.css('opacity');
$m.mouseover(function() {
callBlock({
fadeIn: 0,
timeout: 30000
});
var displayBlock = $('.blockMsg');
displayBlock.stop(); // cancel fadeout if it has started
displayBlock.fadeTo(300, 1); // make it easier to read the message by removing transparency
}).mouseout(function() {
$('.blockMsg').fadeOut(1000);
});
// End konapun additions
};
// plugin method for blocking element content
$.fn.wu_block = function(opts) {
if ( this[0] === window ) {
$.blockUI( opts );
return this;
}
var fullOpts = $.extend({}, $.blockUI.defaults, opts || {});
this.each(function() {
var $el = $(this);
if (fullOpts.ignoreIfBlocked && $el.data('blockUI.isBlocked'))
return;
$el.wu_unblock({ fadeOut: 0 });
});
return this.each(function() {
if ($.css(this,'position') == 'static') {
this.style.position = 'relative';
$(this).data('blockUI.static', true);
}
this.style.zoom = 1; // force 'hasLayout' in ie
install(this, opts);
});
};
// plugin method for unblocking element content
$.fn.wu_unblock = function(opts) {
if ( this[0] === window ) {
$.unblockUI( opts );
return this;
}
return this.each(function() {
remove(this, opts);
});
};
$.blockUI.version = 2.70; // 2nd generation blocking at no extra cost!
// override these in your code to change the default behavior and style
$.blockUI.defaults = {
// message displayed when blocking (use null for no message)
message: '<h1>Please wait...</h1>',
title: null, // title string; only used when theme == true
draggable: true, // only used when theme == true (requires jquery-ui.js to be loaded)
theme: false, // set to true to use with jQuery UI themes
// styles for the message when blocking; if you wish to disable
// these and use an external stylesheet then do this in your code:
// $.blockUI.defaults.css = {};
css: {
padding: 0,
margin: 0,
width: '30%',
top: '40%',
left: '35%',
textAlign: 'center',
color: '#000',
border: '3px solid #aaa',
backgroundColor:'#fff',
cursor: 'wait'
},
// minimal style set used when themes are used
themedCSS: {
width: '30%',
top: '40%',
left: '35%'
},
// styles for the overlay
overlayCSS: {
backgroundColor: '#000',
opacity: 0.6,
cursor: 'wait'
},
// style to replace wait cursor before unblocking to correct issue
// of lingering wait cursor
cursorReset: 'default',
// styles applied when using $.growlUI
growlCSS: {
width: '350px',
top: '10px',
left: '',
right: '10px',
border: 'none',
padding: '5px',
opacity: 0.6,
cursor: 'default',
color: '#fff',
backgroundColor: '#000',
'-webkit-border-radius':'10px',
'-moz-border-radius': '10px',
'border-radius': '10px'
},
// IE issues: 'about:blank' fails on HTTPS and javascript:false is s-l-o-w
// (hat tip to Jorge H. N. de Vasconcelos)
/*jshint scripturl:true */
iframeSrc: /^https/i.test(window.location.href || '') ? 'javascript:false' : 'about:blank',
// force usage of iframe in non-IE browsers (handy for blocking applets)
forceIframe: false,
// z-index for the blocking overlay
baseZ: 1000,
// set these to true to have the message automatically centered
centerX: true, // <-- only effects element blocking (page block controlled via css above)
centerY: true,
// allow body element to be stetched in ie6; this makes blocking look better
// on "short" pages. disable if you wish to prevent changes to the body height
allowBodyStretch: true,
// enable if you want key and mouse events to be disabled for content that is blocked
bindEvents: true,
// be default blockUI will supress tab navigation from leaving blocking content
// (if bindEvents is true)
constrainTabKey: true,
// fadeIn time in millis; set to 0 to disable fadeIn on block
fadeIn: 200,
// fadeOut time in millis; set to 0 to disable fadeOut on unblock
fadeOut: 400,
// time in millis to wait before auto-unblocking; set to 0 to disable auto-unblock
timeout: 0,
// disable if you don't want to show the overlay
showOverlay: true,
// if true, focus will be placed in the first available input field when
// page blocking
focusInput: true,
// elements that can receive focus
focusableElements: ':input:enabled:visible',
// suppresses the use of overlay styles on FF/Linux (due to performance issues with opacity)
// no longer needed in 2012
// applyPlatformOpacityRules: true,
// callback method invoked when fadeIn has completed and blocking message is visible
onBlock: null,
// callback method invoked when unblocking has completed; the callback is
// passed the element that has been unblocked (which is the window object for page
// blocks) and the options that were passed to the unblock call:
// onUnblock(element, options)
onUnblock: null,
// callback method invoked when the overlay area is clicked.
// setting this will turn the cursor to a pointer, otherwise cursor defined in overlayCss will be used.
onOverlayClick: null,
// don't ask; if you really must know: http://groups.google.com/group/jquery-en/browse_thread/thread/36640a8730503595/2f6a79a77a78e493#2f6a79a77a78e493
quirksmodeOffsetHack: 4,
// class name of the message block
blockMsgClass: 'blockMsg',
// if it is already blocked, then ignore it (don't unblock and reblock)
ignoreIfBlocked: false
};
// private data and functions follow...
var pageBlock = null;
var pageBlockEls = [];
function install(el, opts) {
var css, themedCSS;
var full = (el == window);
var msg = (opts && opts.message !== undefined ? opts.message : undefined);
opts = $.extend({}, $.blockUI.defaults, opts || {});
if (opts.ignoreIfBlocked && $(el).data('blockUI.isBlocked'))
return;
opts.overlayCSS = $.extend({}, $.blockUI.defaults.overlayCSS, opts.overlayCSS || {});
css = $.extend({}, $.blockUI.defaults.css, opts.css || {});
if (opts.onOverlayClick)
opts.overlayCSS.cursor = 'pointer';
themedCSS = $.extend({}, $.blockUI.defaults.themedCSS, opts.themedCSS || {});
msg = msg === undefined ? opts.message : msg;
// remove the current block (if there is one)
if (full && pageBlock)
remove(window, {fadeOut:0});
// if an existing element is being used as the blocking content then we capture
// its current place in the DOM (and current display style) so we can restore
// it when we unblock
if (msg && typeof msg != 'string' && (msg.parentNode || msg.jquery)) {
var node = msg.jquery ? msg[0] : msg;
var data = {};
$(el).data('blockUI.history', data);
data.el = node;
data.parent = node.parentNode;
data.display = node.style.display;
data.position = node.style.position;
if (data.parent)
data.parent.removeChild(node);
}
$(el).data('blockUI.onUnblock', opts.onUnblock);
var z = opts.baseZ;
// blockUI uses 3 layers for blocking, for simplicity they are all used on every platform;
// layer1 is the iframe layer which is used to supress bleed through of underlying content
// layer2 is the overlay layer which has opacity and a wait cursor (by default)
// layer3 is the message content that is displayed while blocking
var lyr1, lyr2, lyr3, s;
if (msie || opts.forceIframe)
lyr1 = $('<iframe class="wu_blockUI" style="z-index:'+ (z++) +';display:none;border:none;margin:0;padding:0;position:absolute;width:100%;height:100%;top:0;left:0" src="'+opts.iframeSrc+'"></iframe>');
else
lyr1 = $('<div class="wu_blockUI" style="display:none"></div>');
if (opts.theme)
lyr2 = $('<div class="wu_blockUI blockOverlay ui-widget-overlay" style="z-index:'+ (z++) +';display:none"></div>');
else
lyr2 = $('<div class="wu_blockUI blockOverlay" style="z-index:'+ (z++) +';display:none;border:none;margin:0;padding:0;width:100%;height:100%;top:0;left:0"></div>');
if (opts.theme && full) {
s = '<div class="wu_blockUI ' + opts.blockMsgClass + ' blockPage ui-dialog ui-widget ui-corner-all" style="z-index:'+(z+10)+';display:none;position:fixed">';
if ( opts.title ) {
s += '<div class="ui-widget-header ui-dialog-titlebar ui-corner-all blockTitle">'+(opts.title || '&nbsp;')+'</div>';
}
s += '<div class="ui-widget-content ui-dialog-content"></div>';
s += '</div>';
}
else if (opts.theme) {
s = '<div class="wu_blockUI ' + opts.blockMsgClass + ' blockElement ui-dialog ui-widget ui-corner-all" style="z-index:'+(z+10)+';display:none;position:absolute">';
if ( opts.title ) {
s += '<div class="ui-widget-header ui-dialog-titlebar ui-corner-all blockTitle">'+(opts.title || '&nbsp;')+'</div>';
}
s += '<div class="ui-widget-content ui-dialog-content"></div>';
s += '</div>';
}
else if (full) {
s = '<div class="wu_blockUI ' + opts.blockMsgClass + ' blockPage" style="z-index:'+(z+10)+';display:none;position:fixed"></div>';
}
else {
s = '<div class="wu_blockUI ' + opts.blockMsgClass + ' blockElement" style="z-index:'+(z+10)+';display:none;position:absolute"></div>';
}
lyr3 = $(s);
// if we have a message, style it
if (msg) {
if (opts.theme) {
lyr3.css(themedCSS);
lyr3.addClass('ui-widget-content');
}
else
lyr3.css(css);
}
// style the overlay
if (!opts.theme /*&& (!opts.applyPlatformOpacityRules)*/)
lyr2.css(opts.overlayCSS);
lyr2.css('position', full ? 'fixed' : 'absolute');
// make iframe layer transparent in IE
if (msie || opts.forceIframe)
lyr1.css('opacity',0.0);
//$([lyr1[0],lyr2[0],lyr3[0]]).appendTo(full ? 'body' : el);
var layers = [lyr1,lyr2,lyr3], $par = full ? $('body') : $(el);
$.each(layers, function() {
this.appendTo($par);
});
if (opts.theme && opts.draggable && $.fn.draggable) {
lyr3.draggable({
handle: '.ui-dialog-titlebar',
cancel: 'li'
});
}
// ie7 must use absolute positioning in quirks mode and to account for activex issues (when scrolling)
var expr = setExpr && (!$.support.boxModel || $('object,embed', full ? null : el).length > 0);
if (ie6 || expr) {
// give body 100% height
if (full && opts.allowBodyStretch && $.support.boxModel)
$('html,body').css('height','100%');
// fix ie6 issue when blocked element has a border width
if ((ie6 || !$.support.boxModel) && !full) {
var t = sz(el,'borderTopWidth'), l = sz(el,'borderLeftWidth');
var fixT = t ? '(0 - '+t+')' : 0;
var fixL = l ? '(0 - '+l+')' : 0;
}
// simulate fixed position
$.each(layers, function(i,o) {
var s = o[0].style;
s.position = 'absolute';
if (i < 2) {
if (full)
s.setExpression('height','Math.max(document.body.scrollHeight, document.body.offsetHeight) - (jQuery.support.boxModel?0:'+opts.quirksmodeOffsetHack+') + "px"');
else
s.setExpression('height','this.parentNode.offsetHeight + "px"');
if (full)
s.setExpression('width','jQuery.support.boxModel && document.documentElement.clientWidth || document.body.clientWidth + "px"');
else
s.setExpression('width','this.parentNode.offsetWidth + "px"');
if (fixL) s.setExpression('left', fixL);
if (fixT) s.setExpression('top', fixT);
}
else if (opts.centerY) {
if (full) s.setExpression('top','(document.documentElement.clientHeight || document.body.clientHeight) / 2 - (this.offsetHeight / 2) + (blah = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + "px"');
s.marginTop = 0;
}
else if (!opts.centerY && full) {
var top = (opts.css && opts.css.top) ? parseInt(opts.css.top, 10) : 0;
var expression = '((document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + '+top+') + "px"';
s.setExpression('top',expression);
}
});
}
// show the message
if (msg) {
if (opts.theme)
lyr3.find('.ui-widget-content').append(msg);
else
lyr3.append(msg);
if (msg.jquery || msg.nodeType)
$(msg).show();
}
if ((msie || opts.forceIframe) && opts.showOverlay)
lyr1.show(); // opacity is zero
if (opts.fadeIn) {
var cb = opts.onBlock ? opts.onBlock : noOp;
var cb1 = (opts.showOverlay && !msg) ? cb : noOp;
var cb2 = msg ? cb : noOp;
if (opts.showOverlay)
lyr2._fadeIn(opts.fadeIn, cb1);
if (msg)
lyr3._fadeIn(opts.fadeIn, cb2);
}
else {
if (opts.showOverlay)
lyr2.show();
if (msg)
lyr3.show();
if (opts.onBlock)
opts.onBlock.bind(lyr3)();
}
// bind key and mouse events
bind(1, el, opts);
if (full) {
pageBlock = lyr3[0];
pageBlockEls = $(opts.focusableElements,pageBlock);
if (opts.focusInput)
setTimeout(focus, 20);
}
else
center(lyr3[0], opts.centerX, opts.centerY);
if (opts.timeout) {
// auto-unblock
var to = setTimeout(function() {
if (full)
$.unblockUI(opts);
else
$(el).wu_unblock(opts);
}, opts.timeout);
$(el).data('blockUI.timeout', to);
}
}
// remove the block
function remove(el, opts) {
var count;
var full = (el == window);
var $el = $(el);
var data = $el.data('blockUI.history');
var to = $el.data('blockUI.timeout');
if (to) {
clearTimeout(to);
$el.removeData('blockUI.timeout');
}
opts = $.extend({}, $.blockUI.defaults, opts || {});
bind(0, el, opts); // unbind events
if (opts.onUnblock === null) {
opts.onUnblock = $el.data('blockUI.onUnblock');
$el.removeData('blockUI.onUnblock');
}
var els;
if (full) // crazy selector to handle odd field errors in ie6/7
els = $('body').children().filter('.wu_blockUI').add('body > .wu_blockUI');
else
els = $el.find('> .wu_blockUI');
// fix cursor issue
if ( opts.cursorReset ) {
if ( els.length > 1 )
els[1].style.cursor = opts.cursorReset;
if ( els.length > 2 )
els[2].style.cursor = opts.cursorReset;
}
if (full)
pageBlock = pageBlockEls = null;
if (opts.fadeOut) {
count = els.length;
els.stop().fadeOut(opts.fadeOut, function() {
if ( --count === 0)
reset(els,data,opts,el);
});
}
else
reset(els, data, opts, el);
}
// move blocking element back into the DOM where it started
function reset(els,data,opts,el) {
var $el = $(el);
if ( $el.data('blockUI.isBlocked') )
return;
els.each(function(i,o) {
// remove via DOM calls so we don't lose event handlers
if (this.parentNode)
this.parentNode.removeChild(this);
});
if (data && data.el) {
data.el.style.display = data.display;
data.el.style.position = data.position;
data.el.style.cursor = 'default'; // #59
if (data.parent)
data.parent.appendChild(data.el);
$el.removeData('blockUI.history');
}
if ($el.data('blockUI.static')) {
$el.css('position', 'static'); // #22
}
if (typeof opts.onUnblock == 'function')
opts.onUnblock(el,opts);
// fix issue in Safari 6 where block artifacts remain until reflow
var body = $(document.body), w = body.width(), cssW = body[0].style.width;
body.width(w-1).width(w);
body[0].style.width = cssW;
}
// bind/unbind the handler
function bind(b, el, opts) {
var full = el == window, $el = $(el);
// don't bother unbinding if there is nothing to unbind
if (!b && (full && !pageBlock || !full && !$el.data('blockUI.isBlocked')))
return;
$el.data('blockUI.isBlocked', b);
// don't bind events when overlay is not in use or if bindEvents is false
if (!full || !opts.bindEvents || (b && !opts.showOverlay))
return;
// bind anchors and inputs for mouse and key events
var events = 'mousedown mouseup keydown keypress keyup touchstart touchend touchmove';
if (b)
$(document).bind(events, opts, handler);
else
$(document).unbind(events, handler);
// former impl...
// var $e = $('a,:input');
// b ? $e.bind(events, opts, handler) : $e.unbind(events, handler);
}
// event handler to suppress keyboard/mouse events when blocking
function handler(e) {
// allow tab navigation (conditionally)
if (e.type === 'keydown' && e.keyCode && e.keyCode == 9) {
if (pageBlock && e.data.constrainTabKey) {
var els = pageBlockEls;
var fwd = !e.shiftKey && e.target === els[els.length-1];
var back = e.shiftKey && e.target === els[0];
if (fwd || back) {
setTimeout(function(){focus(back);},10);
return false;
}
}
}
var opts = e.data;
var target = $(e.target);
if (target.hasClass('blockOverlay') && opts.onOverlayClick)
opts.onOverlayClick(e);
// allow events within the message content
if (target.parents('div.' + opts.blockMsgClass).length > 0)
return true;
// allow events for content that is not being blocked
return target.parents().children().filter('div.wu_blockUI').length === 0;
}
function focus(back) {
if (!pageBlockEls)
return;
var e = pageBlockEls[back===true ? pageBlockEls.length-1 : 0];
if (e)
e.focus();
}
function center(el, x, y) {
var p = el.parentNode, s = el.style;
var l = ((p.offsetWidth - el.offsetWidth)/2) - sz(p,'borderLeftWidth');
var t = ((p.offsetHeight - el.offsetHeight)/2) - sz(p,'borderTopWidth');
if (x) s.left = l > 0 ? (l+'px') : '0';
if (y) s.top = t > 0 ? (t+'px') : '0';
}
function sz(el, p) {
return parseInt($.css(el,p),10)||0;
}
}
/*global define:true */
if (typeof define === 'function' && define.amd && define.amd.jQuery) {
define(['jquery'], setup);
} else {
setup(jQuery);
}
})();

16
assets/js/lib/jquery.blockUI.min.js vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

1058
assets/js/lib/mousetrap.js Normal file

File diff suppressed because it is too large Load Diff

1
assets/js/lib/mousetrap.min.js vendored Normal file

File diff suppressed because one or more lines are too long

3891
assets/js/lib/selectize.js Normal file

File diff suppressed because it is too large Load Diff

1
assets/js/lib/selectize.min.js vendored Normal file

File diff suppressed because one or more lines are too long

9406
assets/js/lib/shepherd.js Normal file

File diff suppressed because it is too large Load Diff

55
assets/js/lib/shepherd.min.js vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

5
assets/js/lib/sweetalert2.all.min.js vendored Normal file

File diff suppressed because one or more lines are too long

194
assets/js/lib/tiptip.js Normal file
View File

@ -0,0 +1,194 @@
/*
* TipTip
* Copyright 2010 Drew Wilson
* www.drewwilson.com
* code.drewwilson.com/entry/tiptip-jquery-plugin
*
* Version 1.3 - Updated: Mar. 23, 2010
*
* This Plug-In will create a custom tooltip to replace the default
* browser tooltip. It is extremely lightweight and very smart in
* that it detects the edges of the browser window and will make sure
* the tooltip stays within the current window size. As a result the
* tooltip will adjust itself to be displayed above, below, to the left
* or to the right depending on what is necessary to stay within the
* browser window. It is completely customizable as well via CSS.
*
* This TipTip jQuery plug-in is dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*/
(function($){
$.fn.tipTip = function(options) {
var defaults = {
activation: "hover",
keepAlive: false,
maxWidth: "200px",
edgeOffset: 10,
defaultPosition: "bottom",
delay: 400,
fadeIn: 200,
fadeOut: 200,
attribute: "title",
content: false, // HTML or String to fill TipTIp with
enter: function(){},
exit: function(){}
};
var opts = $.extend(defaults, options);
// Setup tip tip elements and render them to the DOM
if($("#tiptip_holder").length <= 0){
var tiptip_holder = $('<div id="tiptip_holder" style="max-width:'+ opts.maxWidth +';"></div>');
var tiptip_content = $('<div id="tiptip_content"></div>');
var tiptip_arrow = $('<div id="tiptip_arrow"></div>');
$("body").append(tiptip_holder.html(tiptip_content).prepend(tiptip_arrow.html('<div id="tiptip_arrow_inner"></div>')));
} else {
var tiptip_holder = $("#tiptip_holder");
var tiptip_content = $("#tiptip_content");
var tiptip_arrow = $("#tiptip_arrow");
}
return this.each(function(){
var org_elem = $(this);
if(opts.content){
var org_title = opts.content;
} else {
var org_title = org_elem.attr(opts.attribute);
}
if(org_title != ""){
if(!opts.content){
// org_elem.removeAttr(opts.attribute); //remove original Attribute
org_elem.attr('data-' + opts.attribute, org_title); //saves a backup
}
var timeout = false;
if(opts.activation == "hover"){
org_elem.hover(function(){
active_tiptip();
}, function(){
if(!opts.keepAlive){
deactive_tiptip();
}
});
if(opts.keepAlive){
tiptip_holder.hover(function(){}, function(){
deactive_tiptip();
});
}
} else if(opts.activation == "focus"){
org_elem.focus(function(){
active_tiptip();
}).blur(function(){
deactive_tiptip();
});
} else if(opts.activation == "click"){
org_elem.click(function(){
active_tiptip();
return false;
}).hover(function(){},function(){
if(!opts.keepAlive){
deactive_tiptip();
}
});
if(opts.keepAlive){
tiptip_holder.hover(function(){}, function(){
deactive_tiptip();
});
}
}
function active_tiptip(){
opts.enter.call(this);
tiptip_content.html(org_title);
tiptip_holder.hide().removeAttr("class").css("margin","0");
tiptip_arrow.removeAttr("style");
var top = parseInt(org_elem.offset()['top']);
var left = parseInt(org_elem.offset()['left']);
var org_width = parseInt(org_elem.outerWidth());
var org_height = parseInt(org_elem.outerHeight());
var tip_w = tiptip_holder.outerWidth();
var tip_h = tiptip_holder.outerHeight();
var w_compare = Math.round((org_width - tip_w) / 2);
var h_compare = Math.round((org_height - tip_h) / 2);
var marg_left = Math.round(left + w_compare);
var marg_top = Math.round(top + org_height + opts.edgeOffset);
var t_class = "";
var arrow_top = "";
var arrow_left = Math.round(tip_w - 12) / 2;
if(opts.defaultPosition == "bottom"){
t_class = "_bottom";
} else if(opts.defaultPosition == "top"){
t_class = "_top";
} else if(opts.defaultPosition == "left"){
t_class = "_left";
} else if(opts.defaultPosition == "right"){
t_class = "_right";
}
var right_compare = (w_compare + left) < parseInt($(window).scrollLeft());
var left_compare = (tip_w + left) > parseInt($(window).width());
if((right_compare && w_compare < 0) || (t_class == "_right" && !left_compare) || (t_class == "_left" && left < (tip_w + opts.edgeOffset + 5))){
t_class = "_right";
arrow_top = Math.round(tip_h - 13) / 2;
arrow_left = -12;
marg_left = Math.round(left + org_width + opts.edgeOffset);
marg_top = Math.round(top + h_compare);
} else if((left_compare && w_compare < 0) || (t_class == "_left" && !right_compare)){
t_class = "_left";
arrow_top = Math.round(tip_h - 13) / 2;
arrow_left = Math.round(tip_w);
marg_left = Math.round(left - (tip_w + opts.edgeOffset + 5));
marg_top = Math.round(top + h_compare);
}
var top_compare = (top + org_height + opts.edgeOffset + tip_h + 8) > parseInt($(window).height() + $(window).scrollTop());
var bottom_compare = ((top + org_height) - (opts.edgeOffset + tip_h + 8)) < 0;
if(top_compare || (t_class == "_bottom" && top_compare) || (t_class == "_top" && !bottom_compare)){
if(t_class == "_top" || t_class == "_bottom"){
t_class = "_top";
} else {
t_class = t_class+"_top";
}
arrow_top = tip_h;
marg_top = Math.round(top - (tip_h + 5 + opts.edgeOffset));
} else if(bottom_compare | (t_class == "_top" && bottom_compare) || (t_class == "_bottom" && !top_compare)){
if(t_class == "_top" || t_class == "_bottom"){
t_class = "_bottom";
} else {
t_class = t_class+"_bottom";
}
arrow_top = -12;
marg_top = Math.round(top + org_height + opts.edgeOffset);
}
if(t_class == "_right_top" || t_class == "_left_top"){
marg_top = marg_top + 5;
} else if(t_class == "_right_bottom" || t_class == "_left_bottom"){
marg_top = marg_top - 5;
}
if(t_class == "_left_top" || t_class == "_left_bottom"){
marg_left = marg_left + 5;
}
tiptip_arrow.css({"margin-left": arrow_left+"px", "margin-top": arrow_top+"px"});
tiptip_holder.css({"margin-left": marg_left+"px", "margin-top": marg_top+"px"}).attr("class","tip"+t_class);
if (timeout){ clearTimeout(timeout); }
timeout = setTimeout(function(){ tiptip_holder.stop(true,true).fadeIn(opts.fadeIn); }, opts.delay);
}
function deactive_tiptip(){
opts.exit.call(this);
if (timeout){ clearTimeout(timeout); }
tiptip_holder.fadeOut(opts.fadeOut);
}
}
});
}
})(jQuery);

1
assets/js/lib/tiptip.min.js vendored Normal file
View File

@ -0,0 +1 @@
!function(t){t.fn.tipTip=function(e){var o=t.extend({activation:"hover",keepAlive:!1,maxWidth:"200px",edgeOffset:10,defaultPosition:"bottom",delay:400,fadeIn:200,fadeOut:200,attribute:"title",content:!1,enter:function(){},exit:function(){}},e);if(t("#tiptip_holder").length<=0){var i=t('<div id="tiptip_holder" style="max-width:'+o.maxWidth+';"></div>'),n=t('<div id="tiptip_content"></div>'),r=t('<div id="tiptip_arrow"></div>');t("body").append(i.html(n).prepend(r.html('<div id="tiptip_arrow_inner"></div>')))}else i=t("#tiptip_holder"),n=t("#tiptip_content"),r=t("#tiptip_arrow");return this.each((function(){var e=t(this);if(o.content)var a=o.content;else a=e.attr(o.attribute);if(""!=a){o.content||e.attr("data-"+o.attribute,a);var f=!1;function d(){o.enter.call(this),n.html(a),i.hide().removeAttr("class").css("margin","0"),r.removeAttr("style");var d=parseInt(e.offset().top),u=parseInt(e.offset().left),p=parseInt(e.outerWidth()),l=parseInt(e.outerHeight()),h=i.outerWidth(),c=i.outerHeight(),s=Math.round((p-h)/2),_=Math.round((l-c)/2),v=Math.round(u+s),m=Math.round(d+l+o.edgeOffset),g="",b="",M=Math.round(h-12)/2;"bottom"==o.defaultPosition?g="_bottom":"top"==o.defaultPosition?g="_top":"left"==o.defaultPosition?g="_left":"right"==o.defaultPosition&&(g="_right");var w=s+u<parseInt(t(window).scrollLeft()),O=h+u>parseInt(t(window).width());w&&s<0||"_right"==g&&!O||"_left"==g&&u<h+o.edgeOffset+5?(g="_right",b=Math.round(c-13)/2,M=-12,v=Math.round(u+p+o.edgeOffset),m=Math.round(d+_)):(O&&s<0||"_left"==g&&!w)&&(g="_left",b=Math.round(c-13)/2,M=Math.round(h),v=Math.round(u-(h+o.edgeOffset+5)),m=Math.round(d+_));var x=d+l+o.edgeOffset+c+8>parseInt(t(window).height()+t(window).scrollTop()),I=d+l-(o.edgeOffset+c+8)<0;x||"_bottom"==g&&x||"_top"==g&&!I?("_top"==g||"_bottom"==g?g="_top":g+="_top",b=c,m=Math.round(d-(c+5+o.edgeOffset))):(I|("_top"==g&&I)||"_bottom"==g&&!x)&&("_top"==g||"_bottom"==g?g="_bottom":g+="_bottom",b=-12,m=Math.round(d+l+o.edgeOffset)),"_right_top"==g||"_left_top"==g?m+=5:"_right_bottom"!=g&&"_left_bottom"!=g||(m-=5),"_left_top"!=g&&"_left_bottom"!=g||(v+=5),r.css({"margin-left":M+"px","margin-top":b+"px"}),i.css({"margin-left":v+"px","margin-top":m+"px"}).attr("class","tip"+g),f&&clearTimeout(f),f=setTimeout((function(){i.stop(!0,!0).fadeIn(o.fadeIn)}),o.delay)}function u(){o.exit.call(this),f&&clearTimeout(f),i.fadeOut(o.fadeOut)}"hover"==o.activation?(e.hover((function(){d()}),(function(){o.keepAlive||u()})),o.keepAlive&&i.hover((function(){}),(function(){u()}))):"focus"==o.activation?e.focus((function(){d()})).blur((function(){u()})):"click"==o.activation&&(e.click((function(){return d(),!1})).hover((function(){}),(function(){o.keepAlive||u()})),o.keepAlive&&i.hover((function(){}),(function(){u()})))}}))}}(jQuery);

1
assets/js/lib/v-money.js Normal file
View File

@ -0,0 +1 @@
(function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.VMoney=t():e.VMoney=t()})(this,function(){return function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var n={};return t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p=".",t(t.s=9)}([function(e,t,n){"use strict";t.a={prefix:"",suffix:"",thousands:",",decimal:".",precision:2}},function(e,t,n){"use strict";var r=n(2),i=n(5),u=n(0);t.a=function(e,t){if(t.value){var o=n.i(i.a)(u.a,t.value);if("INPUT"!==e.tagName.toLocaleUpperCase()){var a=e.getElementsByTagName("input");1!==a.length||(e=a[0])}e.oninput=function(){var t=e.value.length-e.selectionEnd;e.value=n.i(r.a)(e.value,o),t=Math.max(t,o.suffix.length),t=e.value.length-t,t=Math.max(t,o.prefix.length+1),n.i(r.b)(e,t),e.dispatchEvent(n.i(r.c)("change"))},e.onfocus=function(){n.i(r.b)(e,e.value.length-o.suffix.length)},e.oninput(),e.dispatchEvent(n.i(r.c)("input"))}}},function(e,t,n){"use strict";function r(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:m.a;"number"==typeof e&&(e=e.toFixed(o(t.precision)));var n=e.indexOf("-")>=0?"-":"",r=u(e),i=c(r,t.precision),a=d(i).split("."),p=a[0],l=a[1];return p=f(p,t.thousands),t.prefix+n+s(p,l,t.decimal)+t.suffix}function i(e,t){var n=e.indexOf("-")>=0?-1:1,r=u(e),i=c(r,t);return parseFloat(i)*n}function u(e){return d(e).replace(/\D+/g,"")||"0"}function o(e){return a(0,e,20)}function a(e,t,n){return Math.max(e,Math.min(t,n))}function c(e,t){var n=Math.pow(10,t);return(parseFloat(e)/n).toFixed(o(t))}function f(e,t){return e.replace(/(\d)(?=(?:\d{3})+\b)/gm,"$1"+t)}function s(e,t,n){return t?e+n+t:e}function d(e){return e?e.toString():""}function p(e,t){var n=function(){e.setSelectionRange(t,t)};e===document.activeElement&&(n(),setTimeout(n,1))}function l(e){var t=document.createEvent("Event");return t.initEvent(e,!0,!0),t}var m=n(0);n.d(t,"a",function(){return r}),n.d(t,"d",function(){return i}),n.d(t,"b",function(){return p}),n.d(t,"c",function(){return l})},function(e,t,n){"use strict";function r(e,t){t&&Object.keys(t).map(function(e){a.a[e]=t[e]}),e.directive("money",o.a),e.component("money",u.a)}Object.defineProperty(t,"__esModule",{value:!0});var i=n(6),u=n.n(i),o=n(1),a=n(0);n.d(t,"Money",function(){return u.a}),n.d(t,"VMoney",function(){return o.a}),n.d(t,"options",function(){return a.a}),n.d(t,"VERSION",function(){return c});var c="0.8.1";t.default=r,"undefined"!=typeof window&&window.Vue&&window.Vue.use(r)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(1),i=n(0),u=n(2);t.default={name:"Money",props:{value:{required:!0,type:[Number,String],default:0},masked:{type:Boolean,default:!1},precision:{type:Number,default:function(){return i.a.precision}},decimal:{type:String,default:function(){return i.a.decimal}},thousands:{type:String,default:function(){return i.a.thousands}},prefix:{type:String,default:function(){return i.a.prefix}},suffix:{type:String,default:function(){return i.a.suffix}}},directives:{money:r.a},data:function(){return{formattedValue:""}},watch:{value:{immediate:!0,handler:function(e,t){var r=n.i(u.a)(e,this.$props);r!==this.formattedValue&&(this.formattedValue=r)}}},methods:{change:function(e){this.$emit("input",this.masked?e.target.value:n.i(u.d)(e.target.value,this.precision))}}}},function(e,t,n){"use strict";t.a=function(e,t){return e=e||{},t=t||{},Object.keys(e).concat(Object.keys(t)).reduce(function(n,r){return n[r]=void 0===t[r]?e[r]:t[r],n},{})}},function(e,t,n){var r=n(7)(n(4),n(8),null,null);e.exports=r.exports},function(e,t){e.exports=function(e,t,n,r){var i,u=e=e||{},o=typeof e.default;"object"!==o&&"function"!==o||(i=e,u=e.default);var a="function"==typeof u?u.options:u;if(t&&(a.render=t.render,a.staticRenderFns=t.staticRenderFns),n&&(a._scopeId=n),r){var c=a.computed||(a.computed={});Object.keys(r).forEach(function(e){var t=r[e];c[e]=function(){return t}})}return{esModule:i,exports:u,options:a}}},function(e,t){e.exports={render:function(){var e=this,t=e.$createElement;return(e._self._c||t)("input",{directives:[{name:"money",rawName:"v-money",value:{precision:e.precision,decimal:e.decimal,thousands:e.thousands,prefix:e.prefix,suffix:e.suffix},expression:"{precision, decimal, thousands, prefix, suffix}"}],staticClass:"v-money",attrs:{type:"tel"},domProps:{value:e.formattedValue},on:{change:e.change}})},staticRenderFns:[]}},function(e,t,n){e.exports=n(3)}])});

1
assets/js/lib/v-money.min.js vendored Normal file
View File

@ -0,0 +1 @@
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.VMoney=t():e.VMoney=t()}(this,(function(){return function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var n={};return t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p=".",t(t.s=9)}([function(e,t,n){"use strict";t.a={prefix:"",suffix:"",thousands:",",decimal:".",precision:2}},function(e,t,n){"use strict";var r=n(2),i=n(5),u=n(0);t.a=function(e,t){if(t.value){var o=n.i(i.a)(u.a,t.value);if("INPUT"!==e.tagName.toLocaleUpperCase()){var a=e.getElementsByTagName("input");1!==a.length||(e=a[0])}e.oninput=function(){var t=e.value.length-e.selectionEnd;e.value=n.i(r.a)(e.value,o),t=Math.max(t,o.suffix.length),t=e.value.length-t,t=Math.max(t,o.prefix.length+1),n.i(r.b)(e,t),e.dispatchEvent(n.i(r.c)("change"))},e.onfocus=function(){n.i(r.b)(e,e.value.length-o.suffix.length)},e.oninput(),e.dispatchEvent(n.i(r.c)("input"))}}},function(e,t,n){"use strict";function r(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:l.a;"number"==typeof e&&(e=e.toFixed(o(t.precision)));var n=e.indexOf("-")>=0?"-":"",r=u(e),i=a(r,t.precision),d=s(i).split("."),p=d[0],m=d[1];return p=c(p,t.thousands),t.prefix+n+f(p,m,t.decimal)+t.suffix}function i(e,t){var n=e.indexOf("-")>=0?-1:1,r=a(u(e),t);return parseFloat(r)*n}function u(e){return s(e).replace(/\D+/g,"")||"0"}function o(e){return function(e,t,n){return Math.max(e,Math.min(t,n))}(0,e,20)}function a(e,t){var n=Math.pow(10,t);return(parseFloat(e)/n).toFixed(o(t))}function c(e,t){return e.replace(/(\d)(?=(?:\d{3})+\b)/gm,"$1"+t)}function f(e,t,n){return t?e+n+t:e}function s(e){return e?e.toString():""}function d(e,t){var n=function(){e.setSelectionRange(t,t)};e===document.activeElement&&(n(),setTimeout(n,1))}function p(e){var t=document.createEvent("Event");return t.initEvent(e,!0,!0),t}var l=n(0);n.d(t,"a",(function(){return r})),n.d(t,"d",(function(){return i})),n.d(t,"b",(function(){return d})),n.d(t,"c",(function(){return p}))},function(e,t,n){"use strict";function r(e,t){t&&Object.keys(t).map((function(e){a.a[e]=t[e]})),e.directive("money",o.a),e.component("money",u.a)}Object.defineProperty(t,"__esModule",{value:!0});var i=n(6),u=n.n(i),o=n(1),a=n(0);n.d(t,"Money",(function(){return u.a})),n.d(t,"VMoney",(function(){return o.a})),n.d(t,"options",(function(){return a.a})),n.d(t,"VERSION",(function(){return c}));var c="0.8.1";t.default=r,"undefined"!=typeof window&&window.Vue&&window.Vue.use(r)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(1),i=n(0),u=n(2);t.default={name:"Money",props:{value:{required:!0,type:[Number,String],default:0},masked:{type:Boolean,default:!1},precision:{type:Number,default:function(){return i.a.precision}},decimal:{type:String,default:function(){return i.a.decimal}},thousands:{type:String,default:function(){return i.a.thousands}},prefix:{type:String,default:function(){return i.a.prefix}},suffix:{type:String,default:function(){return i.a.suffix}}},directives:{money:r.a},data:function(){return{formattedValue:""}},watch:{value:{immediate:!0,handler:function(e,t){var r=n.i(u.a)(e,this.$props);r!==this.formattedValue&&(this.formattedValue=r)}}},methods:{change:function(e){this.$emit("input",this.masked?e.target.value:n.i(u.d)(e.target.value,this.precision))}}}},function(e,t,n){"use strict";t.a=function(e,t){return e=e||{},t=t||{},Object.keys(e).concat(Object.keys(t)).reduce((function(n,r){return n[r]=void 0===t[r]?e[r]:t[r],n}),{})}},function(e,t,n){var r=n(7)(n(4),n(8),null,null);e.exports=r.exports},function(e,t){e.exports=function(e,t,n,r){var i,u=e=e||{},o=typeof e.default;"object"!==o&&"function"!==o||(i=e,u=e.default);var a="function"==typeof u?u.options:u;if(t&&(a.render=t.render,a.staticRenderFns=t.staticRenderFns),n&&(a._scopeId=n),r){var c=a.computed||(a.computed={});Object.keys(r).forEach((function(e){var t=r[e];c[e]=function(){return t}}))}return{esModule:i,exports:u,options:a}}},function(e,t){e.exports={render:function(){var e=this,t=e.$createElement;return(e._self._c||t)("input",{directives:[{name:"money",rawName:"v-money",value:{precision:e.precision,decimal:e.decimal,thousands:e.thousands,prefix:e.prefix,suffix:e.suffix},expression:"{precision, decimal, thousands, prefix, suffix}"}],staticClass:"v-money",attrs:{type:"tel"},domProps:{value:e.formattedValue},on:{change:e.change}})},staticRenderFns:[]}},function(e,t,n){e.exports=n(3)}])}));

View File

@ -0,0 +1,263 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('apexcharts')) :
typeof define === 'function' && define.amd ? define(['apexcharts'], factory) :
(global.VueApexCharts = factory(global.ApexCharts));
}(this, (function (ApexCharts) { 'use strict';
ApexCharts = ApexCharts && ApexCharts.hasOwnProperty('default') ? ApexCharts['default'] : ApexCharts;
function _typeof(obj) {
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
_typeof = function (obj) {
return typeof obj;
};
} else {
_typeof = function (obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
};
}
return _typeof(obj);
}
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
var ApexChartsComponent = {
props: {
options: {
type: Object
},
type: {
type: String
},
series: {
type: Array,
required: true,
default: function _default() {
return [];
}
},
width: {
default: "100%"
},
height: {
default: "auto"
}
},
data: function data() {
return {
chart: null
};
},
beforeMount: function beforeMount() {
window.ApexCharts = ApexCharts;
},
mounted: function mounted() {
this.init();
},
created: function created() {
var _this = this;
this.$watch("options", function (options) {
if (!_this.chart && options) {
_this.init();
} else {
_this.chart.updateOptions(_this.options);
}
});
this.$watch("series", function (series) {
if (!_this.chart && series) {
_this.init();
} else {
_this.chart.updateSeries(_this.series);
}
});
var watched = ["type", "width", "height"];
watched.forEach(function (prop) {
_this.$watch(prop, function () {
_this.refresh();
});
});
},
beforeDestroy: function beforeDestroy() {
if (!this.chart) {
return;
}
this.destroy();
},
render: function render(createElement) {
return createElement("div");
},
methods: {
init: function init() {
var _this2 = this;
var newOptions = {
chart: {
type: this.type || this.options.chart.type || "line",
height: this.height,
width: this.width,
events: {}
},
series: this.series
};
Object.keys(this.$listeners).forEach(function (evt) {
newOptions.chart.events[evt] = _this2.$listeners[evt];
});
var config = this.extend(this.options, newOptions);
this.chart = new ApexCharts(this.$el, config);
return this.chart.render();
},
isObject: function isObject(item) {
return item && _typeof(item) === "object" && !Array.isArray(item) && item != null;
},
extend: function extend(target, source) {
var _this3 = this;
if (typeof Object.assign !== "function") {
(function () {
Object.assign = function (target) {
// We must check against these specific cases.
if (target === undefined || target === null) {
throw new TypeError("Cannot convert undefined or null to object");
}
var output = Object(target);
for (var index = 1; index < arguments.length; index++) {
var _source = arguments[index];
if (_source !== undefined && _source !== null) {
for (var nextKey in _source) {
if (_source.hasOwnProperty(nextKey)) {
output[nextKey] = _source[nextKey];
}
}
}
}
return output;
};
})();
}
var output = Object.assign({}, target);
if (this.isObject(target) && this.isObject(source)) {
Object.keys(source).forEach(function (key) {
if (_this3.isObject(source[key])) {
if (!(key in target)) {
Object.assign(output, _defineProperty({}, key, source[key]));
} else {
output[key] = _this3.extend(target[key], source[key]);
}
} else {
Object.assign(output, _defineProperty({}, key, source[key]));
}
});
}
return output;
},
refresh: function refresh() {
this.destroy();
return this.init();
},
destroy: function destroy() {
this.chart.destroy();
},
updateSeries: function updateSeries(newSeries, animate) {
return this.chart.updateSeries(newSeries, animate);
},
updateOptions: function updateOptions(newOptions, redrawPaths, animate, updateSyncedCharts) {
return this.chart.updateOptions(newOptions, redrawPaths, animate, updateSyncedCharts);
},
toggleSeries: function toggleSeries(seriesName) {
return this.chart.toggleSeries(seriesName);
},
showSeries: function showSeries(seriesName) {
this.chart.showSeries(seriesName);
},
hideSeries: function hideSeries(seriesName) {
this.chart.hideSeries(seriesName);
},
appendSeries: function appendSeries(newSeries, animate) {
return this.chart.appendSeries(newSeries, animate);
},
resetSeries: function resetSeries() {
this.chart.resetSeries();
},
zoomX: function zoomX(min, max) {
this.chart.zoomX(min, max);
},
toggleDataPointSelection: function toggleDataPointSelection(seriesIndex, dataPointIndex) {
this.chart.toggleDataPointSelection(seriesIndex, dataPointIndex);
},
appendData: function appendData(newData) {
return this.chart.appendData(newData);
},
addText: function addText(options) {
this.chart.addText(options);
},
addImage: function addImage(options) {
this.chart.addImage(options);
},
addShape: function addShape(options) {
this.chart.addShape(options);
},
dataURI: function dataURI() {
return this.chart.dataURI();
},
setLocale: function setLocale(localeName) {
return this.chart.setLocale(localeName);
},
addXaxisAnnotation: function addXaxisAnnotation(options, pushToMemory) {
this.chart.addXaxisAnnotation(options, pushToMemory);
},
addYaxisAnnotation: function addYaxisAnnotation(options, pushToMemory) {
this.chart.addYaxisAnnotation(options, pushToMemory);
},
addPointAnnotation: function addPointAnnotation(options, pushToMemory) {
this.chart.addPointAnnotation(options, pushToMemory);
},
removeAnnotation: function removeAnnotation(id, options) {
this.chart.removeAnnotation(id, options);
},
clearAnnotations: function clearAnnotations() {
this.chart.clearAnnotations();
}
}
};
var VueApexCharts = ApexChartsComponent;
window.ApexCharts = ApexCharts;
VueApexCharts.install = function (Vue) {
//adding a global method or property
Vue.ApexCharts = ApexCharts;
window.ApexCharts = ApexCharts; // add the instance method
Object.defineProperty(Vue.prototype, '$apexcharts', {
get: function get() {
return ApexCharts;
}
});
};
return VueApexCharts;
})));

1
assets/js/lib/vue-apexcharts.min.js vendored Normal file
View File

@ -0,0 +1 @@
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("apexcharts")):"function"==typeof define&&define.amd?define(["apexcharts"],e):t.VueApexCharts=e(t.ApexCharts)}(this,(function(t){"use strict";function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function n(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}t=t&&t.hasOwnProperty("default")?t.default:t;var i={props:{options:{type:Object},type:{type:String},series:{type:Array,required:!0,default:function(){return[]}},width:{default:"100%"},height:{default:"auto"}},data:function(){return{chart:null}},beforeMount:function(){window.ApexCharts=t},mounted:function(){this.init()},created:function(){var t=this;this.$watch("options",(function(e){!t.chart&&e?t.init():t.chart.updateOptions(t.options)})),this.$watch("series",(function(e){!t.chart&&e?t.init():t.chart.updateSeries(t.series)}));["type","width","height"].forEach((function(e){t.$watch(e,(function(){t.refresh()}))}))},beforeDestroy:function(){this.chart&&this.destroy()},render:function(t){return t("div")},methods:{init:function(){var e=this,n={chart:{type:this.type||this.options.chart.type||"line",height:this.height,width:this.width,events:{}},series:this.series};Object.keys(this.$listeners).forEach((function(t){n.chart.events[t]=e.$listeners[t]}));var i=this.extend(this.options,n);return this.chart=new t(this.$el,i),this.chart.render()},isObject:function(t){return t&&"object"===e(t)&&!Array.isArray(t)&&null!=t},extend:function(t,e){var i=this;"function"!=typeof Object.assign&&(Object.assign=function(t){if(null==t)throw new TypeError("Cannot convert undefined or null to object");for(var e=Object(t),n=1;n<arguments.length;n++){var i=arguments[n];if(null!=i)for(var r in i)i.hasOwnProperty(r)&&(e[r]=i[r])}return e});var r=Object.assign({},t);return this.isObject(t)&&this.isObject(e)&&Object.keys(e).forEach((function(o){i.isObject(e[o])&&o in t?r[o]=i.extend(t[o],e[o]):Object.assign(r,n({},o,e[o]))})),r},refresh:function(){return this.destroy(),this.init()},destroy:function(){this.chart.destroy()},updateSeries:function(t,e){return this.chart.updateSeries(t,e)},updateOptions:function(t,e,n,i){return this.chart.updateOptions(t,e,n,i)},toggleSeries:function(t){return this.chart.toggleSeries(t)},showSeries:function(t){this.chart.showSeries(t)},hideSeries:function(t){this.chart.hideSeries(t)},appendSeries:function(t,e){return this.chart.appendSeries(t,e)},resetSeries:function(){this.chart.resetSeries()},zoomX:function(t,e){this.chart.zoomX(t,e)},toggleDataPointSelection:function(t,e){this.chart.toggleDataPointSelection(t,e)},appendData:function(t){return this.chart.appendData(t)},addText:function(t){this.chart.addText(t)},addImage:function(t){this.chart.addImage(t)},addShape:function(t){this.chart.addShape(t)},dataURI:function(){return this.chart.dataURI()},setLocale:function(t){return this.chart.setLocale(t)},addXaxisAnnotation:function(t,e){this.chart.addXaxisAnnotation(t,e)},addYaxisAnnotation:function(t,e){this.chart.addYaxisAnnotation(t,e)},addPointAnnotation:function(t,e){this.chart.addPointAnnotation(t,e)},removeAnnotation:function(t,e){this.chart.removeAnnotation(t,e)},clearAnnotations:function(){this.chart.clearAnnotations()}}};return window.ApexCharts=t,i.install=function(e){e.ApexCharts=t,window.ApexCharts=t,Object.defineProperty(e.prototype,"$apexcharts",{get:function(){return t}})},i}));

View File

@ -0,0 +1 @@
(function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.VueTheMask=t():e.VueTheMask=t()})(this,function(){return function(e){function t(r){if(n[r])return n[r].exports;var a=n[r]={i:r,l:!1,exports:{}};return e[r].call(a.exports,a,a.exports,t),a.l=!0,a.exports}var n={};return t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p=".",t(t.s=10)}([function(e,t){e.exports={"#":{pattern:/\d/},X:{pattern:/[0-9a-zA-Z]/},S:{pattern:/[a-zA-Z]/},A:{pattern:/[a-zA-Z]/,transform:function(e){return e.toLocaleUpperCase()}},a:{pattern:/[a-zA-Z]/,transform:function(e){return e.toLocaleLowerCase()}},"!":{escape:!0}}},function(e,t,n){"use strict";function r(e){var t=document.createEvent("Event");return t.initEvent(e,!0,!0),t}var a=n(2),o=n(0),i=n.n(o);t.a=function(e,t){var o=t.value;if((Array.isArray(o)||"string"==typeof o)&&(o={mask:o,tokens:i.a}),"INPUT"!==e.tagName.toLocaleUpperCase()){var u=e.getElementsByTagName("input");if(1!==u.length)throw new Error("v-mask directive requires 1 input, found "+u.length);e=u[0]}e.oninput=function(t){if(t.isTrusted){var i=e.selectionEnd,u=e.value[i-1];for(e.value=n.i(a.a)(e.value,o.mask,!0,o.tokens);i<e.value.length&&e.value.charAt(i-1)!==u;)i++;e===document.activeElement&&(e.setSelectionRange(i,i),setTimeout(function(){e.setSelectionRange(i,i)},0)),e.dispatchEvent(r("input"))}};var s=n.i(a.a)(e.value,o.mask,!0,o.tokens);s!==e.value&&(e.value=s,e.dispatchEvent(r("input")))}},function(e,t,n){"use strict";var r=n(6),a=n(5);t.a=function(e,t){var o=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],i=arguments[3];return Array.isArray(t)?n.i(a.a)(r.a,t,i)(e,t,o,i):n.i(r.a)(e,t,o,i)}},function(e,t,n){"use strict";function r(e){e.component(s.a.name,s.a),e.directive("mask",i.a)}Object.defineProperty(t,"__esModule",{value:!0});var a=n(0),o=n.n(a),i=n(1),u=n(7),s=n.n(u);n.d(t,"TheMask",function(){return s.a}),n.d(t,"mask",function(){return i.a}),n.d(t,"tokens",function(){return o.a}),n.d(t,"version",function(){return c});var c="0.11.1";t.default=r,"undefined"!=typeof window&&window.Vue&&window.Vue.use(r)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(1),a=n(0),o=n.n(a),i=n(2);t.default={name:"TheMask",props:{value:[String,Number],mask:{type:[String,Array],required:!0},masked:{type:Boolean,default:!1},tokens:{type:Object,default:function(){return o.a}}},directives:{mask:r.a},data:function(){return{lastValue:null,display:this.value}},watch:{value:function(e){e!==this.lastValue&&(this.display=e)},masked:function(){this.refresh(this.display)}},computed:{config:function(){return{mask:this.mask,tokens:this.tokens,masked:this.masked}}},methods:{onInput:function(e){e.isTrusted||this.refresh(e.target.value)},refresh:function(e){this.display=e;var e=n.i(i.a)(e,this.mask,this.masked,this.tokens);e!==this.lastValue&&(this.lastValue=e,this.$emit("input",e))}}}},function(e,t,n){"use strict";function r(e,t,n){return t=t.sort(function(e,t){return e.length-t.length}),function(r,a){for(var o=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],i=0;i<t.length;){var u=t[i];i++;var s=t[i];if(!(s&&e(r,s,!0,n).length>u.length))return e(r,u,o,n)}return""}}t.a=r},function(e,t,n){"use strict";function r(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],r=arguments[3];e=e||"",t=t||"";for(var a=0,o=0,i="";a<t.length&&o<e.length;){var u=t[a],s=r[u],c=e[o];s&&!s.escape?(s.pattern.test(c)&&(i+=s.transform?s.transform(c):c,a++),o++):(s&&s.escape&&(a++,u=t[a]),n&&(i+=u),c===u&&o++,a++)}for(var f="";a<t.length&&n;){var u=t[a];if(r[u]){f="";break}f+=u,a++}return i+f}t.a=r},function(e,t,n){var r=n(8)(n(4),n(9),null,null);e.exports=r.exports},function(e,t){e.exports=function(e,t,n,r){var a,o=e=e||{},i=typeof e.default;"object"!==i&&"function"!==i||(a=e,o=e.default);var u="function"==typeof o?o.options:o;if(t&&(u.render=t.render,u.staticRenderFns=t.staticRenderFns),n&&(u._scopeId=n),r){var s=u.computed||(u.computed={});Object.keys(r).forEach(function(e){var t=r[e];s[e]=function(){return t}})}return{esModule:a,exports:o,options:u}}},function(e,t){e.exports={render:function(){var e=this,t=e.$createElement;return(e._self._c||t)("input",{directives:[{name:"mask",rawName:"v-mask",value:e.config,expression:"config"}],attrs:{type:"text"},domProps:{value:e.display},on:{input:e.onInput}})},staticRenderFns:[]}},function(e,t,n){e.exports=n(3)}])});

1
assets/js/lib/vue-the-mask.min.js vendored Normal file
View File

@ -0,0 +1 @@
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.VueTheMask=t():e.VueTheMask=t()}(this,(function(){return function(e){function t(r){if(n[r])return n[r].exports;var a=n[r]={i:r,l:!1,exports:{}};return e[r].call(a.exports,a,a.exports,t),a.l=!0,a.exports}var n={};return t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p=".",t(t.s=10)}([function(e,t){e.exports={"#":{pattern:/\d/},X:{pattern:/[0-9a-zA-Z]/},S:{pattern:/[a-zA-Z]/},A:{pattern:/[a-zA-Z]/,transform:function(e){return e.toLocaleUpperCase()}},a:{pattern:/[a-zA-Z]/,transform:function(e){return e.toLocaleLowerCase()}},"!":{escape:!0}}},function(e,t,n){"use strict";function r(e){var t=document.createEvent("Event");return t.initEvent(e,!0,!0),t}var a=n(2),o=n(0),i=n.n(o);t.a=function(e,t){var o=t.value;if((Array.isArray(o)||"string"==typeof o)&&(o={mask:o,tokens:i.a}),"INPUT"!==e.tagName.toLocaleUpperCase()){var u=e.getElementsByTagName("input");if(1!==u.length)throw new Error("v-mask directive requires 1 input, found "+u.length);e=u[0]}e.oninput=function(t){if(t.isTrusted){var i=e.selectionEnd,u=e.value[i-1];for(e.value=n.i(a.a)(e.value,o.mask,!0,o.tokens);i<e.value.length&&e.value.charAt(i-1)!==u;)i++;e===document.activeElement&&(e.setSelectionRange(i,i),setTimeout((function(){e.setSelectionRange(i,i)}),0)),e.dispatchEvent(r("input"))}};var s=n.i(a.a)(e.value,o.mask,!0,o.tokens);s!==e.value&&(e.value=s,e.dispatchEvent(r("input")))}},function(e,t,n){"use strict";var r=n(6),a=n(5);t.a=function(e,t){var o=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],i=arguments[3];return Array.isArray(t)?n.i(a.a)(r.a,t,i)(e,t,o,i):n.i(r.a)(e,t,o,i)}},function(e,t,n){"use strict";function r(e){e.component(s.a.name,s.a),e.directive("mask",i.a)}Object.defineProperty(t,"__esModule",{value:!0});var a=n(0),o=n.n(a),i=n(1),u=n(7),s=n.n(u);n.d(t,"TheMask",(function(){return s.a})),n.d(t,"mask",(function(){return i.a})),n.d(t,"tokens",(function(){return o.a})),n.d(t,"version",(function(){return c}));var c="0.11.1";t.default=r,"undefined"!=typeof window&&window.Vue&&window.Vue.use(r)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(1),a=n(0),o=n.n(a),i=n(2);t.default={name:"TheMask",props:{value:[String,Number],mask:{type:[String,Array],required:!0},masked:{type:Boolean,default:!1},tokens:{type:Object,default:function(){return o.a}}},directives:{mask:r.a},data:function(){return{lastValue:null,display:this.value}},watch:{value:function(e){e!==this.lastValue&&(this.display=e)},masked:function(){this.refresh(this.display)}},computed:{config:function(){return{mask:this.mask,tokens:this.tokens,masked:this.masked}}},methods:{onInput:function(e){e.isTrusted||this.refresh(e.target.value)},refresh:function(e){this.display=e,(e=n.i(i.a)(e,this.mask,this.masked,this.tokens))!==this.lastValue&&(this.lastValue=e,this.$emit("input",e))}}}},function(e,t,n){"use strict";t.a=function(e,t,n){return t=t.sort((function(e,t){return e.length-t.length})),function(r,a){for(var o=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],i=0;i<t.length;){var u=t[i];i++;var s=t[i];if(!(s&&e(r,s,!0,n).length>u.length))return e(r,u,o,n)}return""}}},function(e,t,n){"use strict";t.a=function(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],r=arguments[3];e=e||"",t=t||"";for(var a=0,o=0,i="";a<t.length&&o<e.length;){var u=r[f=t[a]],s=e[o];u&&!u.escape?(u.pattern.test(s)&&(i+=u.transform?u.transform(s):s,a++),o++):(u&&u.escape&&(f=t[++a]),n&&(i+=f),s===f&&o++,a++)}for(var c="";a<t.length&&n;){var f;if(r[f=t[a]]){c="";break}c+=f,a++}return i+c}},function(e,t,n){var r=n(8)(n(4),n(9),null,null);e.exports=r.exports},function(e,t){e.exports=function(e,t,n,r){var a,o=e=e||{},i=typeof e.default;"object"!==i&&"function"!==i||(a=e,o=e.default);var u="function"==typeof o?o.options:o;if(t&&(u.render=t.render,u.staticRenderFns=t.staticRenderFns),n&&(u._scopeId=n),r){var s=u.computed||(u.computed={});Object.keys(r).forEach((function(e){var t=r[e];s[e]=function(){return t}}))}return{esModule:a,exports:o,options:u}}},function(e,t){e.exports={render:function(){var e=this,t=e.$createElement;return(e._self._c||t)("input",{directives:[{name:"mask",rawName:"v-mask",value:e.config,expression:"config"}],attrs:{type:"text"},domProps:{value:e.display},on:{input:e.onInput}})},staticRenderFns:[]}},function(e,t,n){e.exports=n(3)}])}));

8949
assets/js/lib/vue.js Normal file

File diff suppressed because it is too large Load Diff

6
assets/js/lib/vue.min.js vendored Normal file

File diff suppressed because one or more lines are too long

549
assets/js/list-tables.js Normal file
View File

@ -0,0 +1,549 @@
/* eslint-disable no-undef */
(function($, hooks) {
/**
* Fixes the value of the action for deleting pending sites.
*/
hooks.addAction('wu_list_table_update', 'nextpress/wp-ultimo', function(results, data, $parent) {
if (results.type === 'pending' && data.table_id === 'site_list_table') {
$parent.find('select[name^=action] > option[value=delete]').attr('value', 'delete-pending');
} else {
$parent.find('select[name^=action] > option[value=delete-pending]').attr('value', 'delete');
} // end if;
});
/**
* Select All
*/
$(document).on('click', '#cb-select-all-grid', function(e) {
e.preventDefault();
const checkboxes = jQuery(this)
.parents('form')
.find('#the-list')
.find('input[type=checkbox]');
const checked = checkboxes.prop('checked');
checkboxes.parents('.wu-grid-item')
.toggleClass('wu-grid-item-selected', ! checked);
checkboxes.prop('checked', ! checked);
});
$(document).on('change', '.wu-grid-item input[type=checkbox]', function() {
const checked = $(this).prop('checked');
$(this).parents('.wu-grid-item')
.toggleClass('wu-grid-item-selected', checked);
});
/**
* Function that creates the code to handle the AJAX functionality of the WU List Tables.
*
* @param id
* @param count
* @param filters
* @param date_filters
*/
// eslint-disable-next-line no-undef
wu_create_list = function(id) {
return {
/**
* Table element ID
*/
el: '#' + id,
/**
* Filters ID
*/
filters_el: '#' + id + '-filters',
/**
* Wether or not the table was initialized.
*/
initialized: false,
/**
* Register our triggers
*
* We want to capture clicks on specific links, but also value change in
* the pagination input field. The links contain all the information we
* need concerning the wanted page number or ordering, so we'll just
* parse the URL to extract these variables.
*
* The page number input is trickier: it has no URL so we have to find a
* way around. We'll use the hidden inputs added in TT_Example_List_Table::display()
* to recover the ordering variables, and the default paged input added
* automatically by WordPress.
*/
init() {
const table = this;
const $table_parent = $('#wu-' + id);
// This will have its utility when dealing with the page number input
let timer;
const delay = 500;
/*
* Handles bulk-delete.
*/
jQuery('body').on('click', '#doaction, #doaction2', function(event) {
const form = jQuery(event.target).parents('form');
const form_data = form.serialize();
const params = new URL('https://example.com?' + form_data);
const action = params.searchParams.get('action') || params.searchParams.get('action2');
const ids = params.searchParams.getAll('bulk-delete[]');
if (action !== '-1' && ids.length) {
event.preventDefault();
} else {
return;
}// end if;
params.searchParams.set('bulk_action', action);
params.searchParams.forEach((value, key) => {
if (key !== 'bulk_action' && key !== 'bulk-delete[]') {
params.searchParams.delete(key);
} // end if;
});
params.searchParams.set('model', wu_list_table.model);
wubox.show(wu_list_table.i18n.confirm, wu_list_table.base_url + '&' + params.searchParams.toString());
});
// Pagination links, sortable link
$table_parent.on('click', '.tablenav-pages a, .manage-column.sortable a, .manage-column.sorted a', function(e) {
// We don't want to actually follow these links
e.preventDefault();
// Simple way: use the URL to extract our needed variables
const query = this.search.substring(1);
const data = $.extend({}, table.__get_query(query), {
order: table.__query(query, 'order') || 'DESC',
paged: table.__query(query, 'paged') || '1',
s: table.__query(query, 's') || '',
});
table.update(data);
});
// Page number input
$table_parent.on('keyup', 'input[name=paged]', function(e) {
// If user hit enter, we don't want to submit the form
// We don't preventDefault() for all keys because it would
// also prevent to get the page number!
if (13 === e.which) {
e.preventDefault();
} // end if;
// This time we fetch the variables in inputs
const data = {
paged: parseInt($('input[name=paged]').val()) || '1',
s: $('input[name=s]').val() || '',
};
// Now the timer comes to use: we wait half a second after
// the user stopped typing to actually send the call. If
// we don't, the keyup event will trigger instantly and
// thus may cause duplicate calls before sending the intended
// value
window.clearTimeout(timer);
timer = window.setTimeout(function() {
table.update(data);
}, delay);
});
/**
* Initializes filters
*/
if (table.initialized === false && $(table.filters_el).get(0)) {
table.filters = table.init_filters();
} // end if;
table.initialized = true;
return table;
},
/**
* Copy a object
*
* @param {Object} obj
*/
copy: function copy(obj) {
return JSON.parse(JSON.stringify(obj));
},
/**
* Setup up the filters
*/
init_filters() {
if (typeof window.Vue === 'undefined') {
return;
} // end if;
const table = this;
const available_filters = table.copy(window[id + '_config'].filters);
// eslint-disable-next-line no-undef
return new Vue({
el: table.filters_el,
data() {
return {
open: true,
view: false,
// relation: 'and',
available_filters: [], // table.copy(available_filters),
filters: [], //[_.first(table.copy(available_filters))],
};
},
computed: {
},
mounted() {
let timer;
const delay = 500;
wu_on_load();
$(table.filters_el + ' form.search-form').on('submit', function(e) {
e.preventDefault();
});
// Page number input
$(table.filters_el + ' input[name=s]').on('input keyup', function(e) {
// If user hit enter, we don't want to submit the form
// We don't preventDefault() for all keys because it would
// also prevent to get the page number!
if (13 === e.which) {
e.preventDefault();
} // end if;
// This time we fetch the variables in inputs
const data = {
paged: parseInt($('input[name=paged]').val()) || '1',
s: $('input[name=s]').val() || '',
};
// Fix paged
if ($('input[name=s]').val() !== '') {
data.paged = '1';
} // end if;
// Now the timer comes to use: we wait half a second after
// the user stopped typing to actually send the call. If
// we don't, the keyup event will trigger instantly and
// thus may cause duplicate calls before sending the intended
// value
window.clearTimeout(timer);
timer = window.setTimeout(function() {
table.update(data);
}, delay);
});
},
methods: {
set_view(type, value) {
const query = window.location.href.split('?')[1];
const data = $.extend({}, table.__get_query(query), {
paged: table.__query(query, 'paged') || '1',
s: table.__query(query, 's') || '',
});
this.view = value;
data[type] = value;
jQuery('.wu-filter .current').removeClass('current');
table.update(data);
},
get_filter_type(field) {
const available_filter = _.findWhere(available_filters, {
field,
});
return available_filter.type;
},
get_filter_rule(field) {
const available_filter = _.findWhere(available_filters, {
field,
});
return available_filter.rule;
},
remove_filter(index) {
this.filters.splice(index, 1);
},
add_new_filter() {
this.filters.push(_.first(table.copy(this.available_filters)));
},
open_filters() {
this.open = true;
},
close_filters() {
this.open = false;
},
},
});
},
set_history(data) {
if (window[id + '_config'].context !== 'page') {
return;
}
/** Update History */
try {
const history_vars = _.omit(data, function(value, key) {
return key === 'action' ||
key === 'table_id' ||
! value ||
key.indexOf('_') === 0;
});
history.pushState({}, null, '?' + $.param(history_vars));
} catch (err) {
// eslint-disable-next-line no-console
console.warn('Browser does not support pushState.', err);
} // end try;
},
/**
* AJAX call
*
* Send the call and replace table parts with updated version!
*
* @param {Object} data The data to pass through AJAX
*/
update(data) {
const table = this;
const $table_parent = $('#wu-' + id);
const default_data = {
action: 'wu_list_table_fetch_ajax_results',
table_id: id,
id: $('input#id').val(),
};
default_data['_ajax_' + id + '_nonce'] = $('#_ajax_' + id + '_nonce').val();
const form_data = $.extend(
{},
default_data,
// $($table_parent).find('input').serializeObject(),
// $(table.filters_el).find('input').serializeObject(),
data,
);
const $content = $table_parent.find('tbody, .wu-grid-content');
$content.animate({ opacity: 0.4 }, 300);
$.ajax({
// eslint-disable-next-line no-undef
url: ajaxurl,
// Add action and nonce to our collected data
data: form_data,
// Handle the successful result
statusCode: {
403() {
$content.animate({ opacity: 1 }, 300);
},
},
success(response) {
table.set_history(form_data, default_data);
$content.animate({ opacity: 1 }, 300);
// Add the requested rows
if (typeof response.rows !== 'undefined') {
$content.html(response.rows);
} // end if;
// Add the requested rows
if (typeof response.count !== 'undefined') {
// table.filters.count = response.count;
} // end if;
// Update column headers for sorting
if (response.column_headers.length) {
$table_parent.find('thead tr, tfoot tr').html(response.column_headers);
} // end if;
// Update pagination for navigation
if (response.pagination.top.length) {
$table_parent.find('.tablenav.top .tablenav-pages').html($(response.pagination.top).html());
} // end if;
if (response.pagination.bottom.length) {
$table_parent.find('.tablenav.bottom .tablenav-pages').html($(response.pagination.bottom).html());
} // end if;
hooks.doAction('wu_list_table_update', response, form_data, $table_parent);
// Init back our event handlers
// table.init();
},
});
},
/**
* Filter the URL Query to extract variables
*
* @see http://css-tricks.com/snippets/javascript/get-url-variables/
* @param {string} query The URL query part containing the variables
* @param {string} variable The URL query part containing the variables
* @return {string|boolean} The variable value if available, false else.
*/
__query(query, variable) {
const vars = query.split('&');
for (let i = 0; i < vars.length; i++) {
const pair = vars[i].split('=');
if (pair[0] === variable) {
return pair[1];
} // end if;
} // end for;
return false;
},
__get_query(query) {
const vars = query.split('&');
const _query = {};
for (let i = 0; i < vars.length; i++) {
const pair = vars[i].split('=');
_query[pair[0]] = pair[1];
} // end for;
return _query;
},
};
}; // end wu_create_list;
}(jQuery, wp.hooks));

1
assets/js/list-tables.min.js vendored Normal file
View File

@ -0,0 +1 @@
!function(e,t){t.addAction("wu_list_table_update","nextpress/wp-ultimo",(function(e,t,n){"pending"===e.type&&"site_list_table"===t.table_id?n.find("select[name^=action] > option[value=delete]").attr("value","delete-pending"):n.find("select[name^=action] > option[value=delete-pending]").attr("value","delete")})),e(document).on("click","#cb-select-all-grid",(function(e){e.preventDefault();const t=jQuery(this).parents("form").find("#the-list").find("input[type=checkbox]"),n=t.prop("checked");t.parents(".wu-grid-item").toggleClass("wu-grid-item-selected",!n),t.prop("checked",!n)})),e(document).on("change",".wu-grid-item input[type=checkbox]",(function(){const t=e(this).prop("checked");e(this).parents(".wu-grid-item").toggleClass("wu-grid-item-selected",t)})),wu_create_list=function(n){return{el:"#"+n,filters_el:"#"+n+"-filters",initialized:!1,init(){const t=this,i=e("#wu-"+n);let a;return jQuery("body").on("click","#doaction, #doaction2",(function(e){const t=jQuery(e.target).parents("form").serialize(),n=new URL("https://example.com?"+t),i=n.searchParams.get("action")||n.searchParams.get("action2"),a=n.searchParams.getAll("bulk-delete[]");"-1"!==i&&a.length&&(e.preventDefault(),n.searchParams.set("bulk_action",i),n.searchParams.forEach(((e,t)=>{"bulk_action"!==t&&"bulk-delete[]"!==t&&n.searchParams.delete(t)})),n.searchParams.set("model",wu_list_table.model),wubox.show(wu_list_table.i18n.confirm,wu_list_table.base_url+"&"+n.searchParams.toString()))})),i.on("click",".tablenav-pages a, .manage-column.sortable a, .manage-column.sorted a",(function(n){n.preventDefault();const i=this.search.substring(1),a=e.extend({},t.__get_query(i),{order:t.__query(i,"order")||"DESC",paged:t.__query(i,"paged")||"1",s:t.__query(i,"s")||""});t.update(a)})),i.on("keyup","input[name=paged]",(function(n){13===n.which&&n.preventDefault();const i={paged:parseInt(e("input[name=paged]").val())||"1",s:e("input[name=s]").val()||""};window.clearTimeout(a),a=window.setTimeout((function(){t.update(i)}),500)})),!1===t.initialized&&e(t.filters_el).get(0)&&(t.filters=t.init_filters()),t.initialized=!0,t},copy:function(e){return JSON.parse(JSON.stringify(e))},init_filters(){if(void 0===window.Vue)return;const t=this,i=t.copy(window[n+"_config"].filters);return new Vue({el:t.filters_el,data:()=>({open:!0,view:!1,available_filters:[],filters:[]}),computed:{},mounted(){let n;wu_on_load(),e(t.filters_el+" form.search-form").on("submit",(function(e){e.preventDefault()})),e(t.filters_el+" input[name=s]").on("input keyup",(function(i){13===i.which&&i.preventDefault();const a={paged:parseInt(e("input[name=paged]").val())||"1",s:e("input[name=s]").val()||""};""!==e("input[name=s]").val()&&(a.paged="1"),window.clearTimeout(n),n=window.setTimeout((function(){t.update(a)}),500)}))},methods:{set_view(n,i){const a=window.location.href.split("?")[1],o=e.extend({},t.__get_query(a),{paged:t.__query(a,"paged")||"1",s:t.__query(a,"s")||""});this.view=i,o[n]=i,jQuery(".wu-filter .current").removeClass("current"),t.update(o)},get_filter_type:e=>_.findWhere(i,{field:e}).type,get_filter_rule:e=>_.findWhere(i,{field:e}).rule,remove_filter(e){this.filters.splice(e,1)},add_new_filter(){this.filters.push(_.first(t.copy(this.available_filters)))},open_filters(){this.open=!0},close_filters(){this.open=!1}}})},set_history(t){if("page"===window[n+"_config"].context)try{const n=_.omit(t,(function(e,t){return"action"===t||"table_id"===t||!e||0===t.indexOf("_")}));history.pushState({},null,"?"+e.param(n))}catch(e){console.warn("Browser does not support pushState.",e)}},update(i){const a=this,o=e("#wu-"+n),s={action:"wu_list_table_fetch_ajax_results",table_id:n,id:e("input#id").val()};s["_ajax_"+n+"_nonce"]=e("#_ajax_"+n+"_nonce").val();const l=e.extend({},s,i),r=o.find("tbody, .wu-grid-content");r.animate({opacity:.4},300),e.ajax({url:ajaxurl,data:l,statusCode:{403(){r.animate({opacity:1},300)}},success(n){a.set_history(l,s),r.animate({opacity:1},300),void 0!==n.rows&&r.html(n.rows),n.count,n.column_headers.length&&o.find("thead tr, tfoot tr").html(n.column_headers),n.pagination.top.length&&o.find(".tablenav.top .tablenav-pages").html(e(n.pagination.top).html()),n.pagination.bottom.length&&o.find(".tablenav.bottom .tablenav-pages").html(e(n.pagination.bottom).html()),t.doAction("wu_list_table_update",n,l,o)}})},__query(e,t){const n=e.split("&");for(let e=0;e<n.length;e++){const i=n[e].split("=");if(i[0]===t)return i[1]}return!1},__get_query(e){const t=e.split("&"),n={};for(let e=0;e<t.length;e++){const i=t[e].split("=");n[i[0]]=i[1]}return n}}}}(jQuery,wp.hooks);

View File

@ -0,0 +1,54 @@
/* global wu_block_ui */
(function($) {
$(document).ready(function() {
$('#scraper').on('click', function(e) {
e.preventDefault();
const block = wu_block_ui('#wp-ultimo-image-widget');
$('.wu-scraper-note, .wu-scraper-error').hide();
jQuery.ajax({
// eslint-disable-next-line no-undef
url: ajaxurl,
type: 'POST',
data: {
action: 'wu_get_screenshot',
site_id: $('#id').val(),
},
error() {
block.unblock();
},
success(res) {
block.unblock();
if (res.success) {
$('#wp-ultimo-image-widget img').attr('src', res.data.attachment_url);
$('#wp-ultimo-image-widget input').val(res.data.attachment_id);
$('.wu-scraper-note').show();
} else {
$('.wu-scraper-error').show();
$('.wu-scraper-error-message').text(res.data.pop().message);
} // end if;
},
});
});
});
}(jQuery));

1
assets/js/screenshot-scraper.min.js vendored Normal file
View File

@ -0,0 +1 @@
!function(e){e(document).ready((function(){e("#scraper").on("click",(function(t){t.preventDefault();const r=wu_block_ui("#wp-ultimo-image-widget");e(".wu-scraper-note, .wu-scraper-error").hide(),jQuery.ajax({url:ajaxurl,type:"POST",data:{action:"wu_get_screenshot",site_id:e("#id").val()},error(){r.unblock()},success(t){r.unblock(),t.success?(e("#wp-ultimo-image-widget img").attr("src",t.data.attachment_url),e("#wp-ultimo-image-widget input").val(t.data.attachment_id),e(".wu-scraper-note").show()):(e(".wu-scraper-error").show(),e(".wu-scraper-error-message").text(t.data.pop().message))}})}))}))}(jQuery);

202
assets/js/selectizer.js Normal file
View File

@ -0,0 +1,202 @@
/* global _, wu_initialize_selectizer, wu_selector */
(function($) {
$(document).ready(function() {
window.wu_initialize_selectizer = function() {
jQuery('[data-selectize]').selectize();
$.each($('[data-selectize-categories]'), function(index, item) {
jQuery($(item)).selectize({
maxItems: $(item).data('max-items') || 10,
create(input) {
return {
value: input,
text: input,
};
},
});
});
$.each($('[data-model]'), function(index, item) {
wu_selector({
el: item,
valueField: $(item).data('value-field'),
labelField: $(item).data('label-field'),
searchField: $(item).data('search-field'),
maxItems: $(item).data('max-items'),
selected: $(item).data('selected'),
options: [],
data: {
action: 'wu_search',
model: $(item).data('model'),
number: 10,
exclude: $(item).data('exclude'),
include: $(item).data('include'),
},
});
});
};
wu_initialize_selectizer();
jQuery('body').on('wubox:load', function() {
wu_initialize_selectizer();
});
});
window.wu_selector = function wu_selector(options) {
options = _.defaults(options, {
options: [],
maxItems: 1,
templateName: false,
create: false,
});
if (jQuery(options.el).data('init')) {
return;
} // end if;
jQuery(options.el).data('__options', options);
const select = jQuery(options.el).selectize({
valueField: options.valueField,
labelField: options.labelField,
searchField: ['text', 'name', 'display_name', 'domain', 'path', 'title', 'desc', 'code', 'post_title', 'reference_code'],
options: options.options,
maxItems: options.maxItems,
create: options.create,
render: {
option(option) {
const templateName = options.templateName ? options.templateName : options.data.model;
const template_html = jQuery('#wu-template-' + templateName).length
? jQuery('#wu-template-' + templateName).html()
: jQuery('#wu-template-default').html();
const template = _.template(template_html, {
interpolate: /\{\{(.+?)\}\}/g,
});
const render = template(option);
return render;
},
},
load(query, callback) {
if (! query.length) {
return callback();
} // end if;
const __options = jQuery(options.el).data('__options');
jQuery.ajax({
// eslint-disable-next-line no-undef
url: wu_selectizer.ajaxurl,
type: 'POST',
data: {
...__options.data,
query: {
search: '*' + query + '*',
},
},
error() {
callback();
},
success(res) {
selectize.savedItems = res;
callback(res);
},
});
},
});
jQuery(options.el).attr('data-init', 1);
const selectize = select[0].selectize;
/*
* Makes sure this is reactive for vue
*/
selectize.on('change', function(value) {
const input = jQuery(select[0]);
const vue_app = input.parents('[data-wu-app]').data('wu-app');
if (vue_app && typeof window['wu_' + vue_app] !== 'undefined') {
window['wu_' + vue_app][input.attr('name')] = value;
} // end if;
});
selectize.on('item_add', function(value) {
let active_item = {
url: null,
};
jQuery.each(selectize.savedItems, function(index, item) {
if (item.setting_id === value) {
active_item = item;
} // end if;
});
if (active_item.url) {
window.location.href = active_item.url;
} // end if;
});
if (options.selected) {
selectize.options = [];
selectize.clearOptions();
const selected_values = _.isArray(options.selected) ? options.selected : [options.selected];
selectize.addOption(selected_values);
const selected = _.isArray(options.selected) ? _.pluck(options.selected, options.valueField) : options.selected[options.valueField];
selectize.setValue(selected, false);
} // end if;
};
}(jQuery));

1
assets/js/selectizer.min.js vendored Normal file
View File

@ -0,0 +1 @@
!function(e){e(document).ready((function(){window.wu_initialize_selectizer=function(){jQuery("[data-selectize]").selectize(),e.each(e("[data-selectize-categories]"),(function(t,a){jQuery(e(a)).selectize({maxItems:e(a).data("max-items")||10,create:e=>({value:e,text:e})})})),e.each(e("[data-model]"),(function(t,a){wu_selector({el:a,valueField:e(a).data("value-field"),labelField:e(a).data("label-field"),searchField:e(a).data("search-field"),maxItems:e(a).data("max-items"),selected:e(a).data("selected"),options:[],data:{action:"wu_search",model:e(a).data("model"),number:10,exclude:e(a).data("exclude"),include:e(a).data("include")}})}))},wu_initialize_selectizer(),jQuery("body").on("wubox:load",(function(){wu_initialize_selectizer()}))})),window.wu_selector=function(e){if(e=_.defaults(e,{options:[],maxItems:1,templateName:!1,create:!1}),jQuery(e.el).data("init"))return;jQuery(e.el).data("__options",e);const t=jQuery(e.el).selectize({valueField:e.valueField,labelField:e.labelField,searchField:["text","name","display_name","domain","path","title","desc","code","post_title","reference_code"],options:e.options,maxItems:e.maxItems,create:e.create,render:{option(t){const a=e.templateName?e.templateName:e.data.model,l=jQuery("#wu-template-"+a).length?jQuery("#wu-template-"+a).html():jQuery("#wu-template-default").html();return _.template(l,{interpolate:/\{\{(.+?)\}\}/g})(t)}},load(t,l){if(!t.length)return l();const i=jQuery(e.el).data("__options");jQuery.ajax({url:wu_selectizer.ajaxurl,type:"POST",data:{...i.data,query:{search:"*"+t+"*"}},error(){l()},success(e){a.savedItems=e,l(e)}})}});jQuery(e.el).attr("data-init",1);const a=t[0].selectize;if(a.on("change",(function(e){const a=jQuery(t[0]),l=a.parents("[data-wu-app]").data("wu-app");l&&void 0!==window["wu_"+l]&&(window["wu_"+l][a.attr("name")]=e)})),a.on("item_add",(function(e){let t={url:null};jQuery.each(a.savedItems,(function(a,l){l.setting_id===e&&(t=l)})),t.url&&(window.location.href=t.url)})),e.selected){a.options=[],a.clearOptions();const t=_.isArray(e.selected)?e.selected:[e.selected];a.addOption(t);const l=_.isArray(e.selected)?_.pluck(e.selected,e.valueField):e.selected[e.valueField];a.setValue(l,!1)}}}(jQuery);

View File

@ -0,0 +1,50 @@
// eslint-disable-next-line no-unused-vars
// eslint-disable-next-line prefer-const
let wu_block_ui_polyfill = function(el) {
jQuery(el).wu_block({
message: '<span style="float: none;" class="spinner is-active wu-float-none"></span>',
overlayCSS: {
backgroundColor: '#FFF',
opacity: 0.6,
},
css: {
padding: 0,
margin: 0,
width: '50%',
fontSize: '14px !important',
top: '40%',
left: '35%',
textAlign: 'center',
color: '#000',
border: 'none',
backgroundColor: 'none',
cursor: 'wait',
},
});
const el_instance = jQuery(el);
el_instance.unblock = jQuery(el).wu_unblock;
return el_instance;
};
(function($) {
$(document).ready(function() {
jQuery('[role="tooltip"]').tipTip({
attribute: 'aria-label',
});
$('#poststuff').on('submit', 'form', function() {
wu_block_ui_polyfill($(this));
});
});
}(jQuery));

View File

@ -0,0 +1 @@
let wu_block_ui_polyfill=function(o){jQuery(o).wu_block({message:'<span style="float: none;" class="spinner is-active wu-float-none"></span>',overlayCSS:{backgroundColor:"#FFF",opacity:.6},css:{padding:0,margin:0,width:"50%",fontSize:"14px !important",top:"40%",left:"35%",textAlign:"center",color:"#000",border:"none",backgroundColor:"none",cursor:"wait"}});const n=jQuery(o);return n.unblock=jQuery(o).wu_unblock,n};!function(o){o(document).ready((function(){jQuery('[role="tooltip"]').tipTip({attribute:"aria-label"}),o("#poststuff").on("submit","form",(function(){wu_block_ui_polyfill(o(this))}))}))}(jQuery);

210
assets/js/setup-wizard.js Normal file
View File

@ -0,0 +1,210 @@
/* global wu_setup, wu_setup_settings, ajaxurl, wu_block_ui_polyfill, _wu_block_ui_polyfill */
(function($) {
window._wu_block_ui_polyfill = wu_block_ui_polyfill;
wu_block_ui_polyfill = function() { };
$(document).ready(function() {
// Click button
// Generates queue
// Start to process queue items one by one
// Changes the status
// Move to the next item
// When all is done, redirect to the next page via a form submission
$('#poststuff').on('submit', 'form', function(e) {
e.preventDefault();
const $form = $(this);
const install_id = $form.find('table[data-id]').data('id');
$form.find('[name=next]').attr('disabled', 'disabled');
let queue = $form.find('tr[data-content]');
/*
* Only keep items selected on the queue.
*/
queue = queue.filter(function() {
const checkbox = $(this).find('input[type=checkbox]');
if (checkbox.length) {
return checkbox.is(':checked');
} // end if;
return true;
});
let successes = 0;
let index = 0;
process_queue_item(queue.eq(index));
/**
* Process the queue items one by one recursively.
*
* @param {string} item The item to process.
*/
function process_queue_item(item) {
window.onbeforeunload = function() {
return '';
};
if (item.length === 0) {
if (queue.length === successes || install_id === 'migration') {
window.onbeforeunload = null;
_wu_block_ui_polyfill($('#poststuff .inside'));
setTimeout(() => {
$form.get(0).submit();
}, 100);
} // end if;
$form.find('[name=next]').removeAttr('disabled');
return false;
} // end if;
const $item = $(item);
const content = $item.data('content');
$item.get(0).scrollIntoView({ behavior: 'smooth', block: 'center', inline: 'nearest' });
$item.find('td.status')
.attr('class', '')
.addClass('status')
.find('> span').html(wu_setup[content].installing).end()
.find('.spinner').addClass('is-active').end()
.find('a.help').slideUp();
// Ajax request
$.ajax({
url: ajaxurl,
method: 'post',
data: {
action: 'wu_setup_install',
installer: content,
'dry-run': wu_setup_settings.dry_run,
},
success(data) {
if (data.success === true) {
$item.find('td.status')
.attr('class', '')
.addClass('status wu-text-green-600')
.find('> span').html(wu_setup[content].success).end()
.find('.spinner').removeClass('is-active');
$item.removeAttr('data-content');
successes++;
} else {
$item.find('td.status')
.attr('class', '')
.addClass('status wu-text-red-400')
.find('> span').html(data.data[0].message).end()
.find('.spinner').removeClass('is-active').end()
.find('a.help').slideDown();
} // end if;
index++;
process_queue_item(queue.eq(index));
},
error() {
$item.find('td.status')
.attr('class', '')
.addClass('status wu-text-red-400')
.find('span').html('').end()
.find('.spinner').removeClass('is-active').end()
.find('a.help').slideDown();
index++;
process_queue_item(queue.eq(index));
},
});
} // end process_queue_item;
});
});
}(jQuery));
if (typeof wu_initialize_tooltip !== 'function') {
const wu_initialize_tooltip = function() {
jQuery('[role="tooltip"]').tipTip({
attribute: 'aria-label',
});
}; // end wu_initialize_tooltip;
// eslint-disable-next-line no-unused-vars
const wu_block_ui = function(el) {
jQuery(el).wu_block({
message: '<span>Please wait...</span>',
overlayCSS: {
backgroundColor: '#FFF',
opacity: 0.6,
},
css: {
padding: 0,
margin: 0,
width: '50%',
fontSize: '14px !important',
top: '40%',
left: '35%',
textAlign: 'center',
color: '#000',
border: 'none',
backgroundColor: 'none',
cursor: 'wait',
},
});
return jQuery(el);
};
(function($) {
$(document).ready(function() {
wu_initialize_tooltip();
});
}(jQuery));
} // end if;

1
assets/js/setup-wizard.min.js vendored Normal file
View File

@ -0,0 +1 @@
if(function(t){window._wu_block_ui_polyfill=wu_block_ui_polyfill,wu_block_ui_polyfill=function(){},t(document).ready((function(){t("#poststuff").on("submit","form",(function(n){n.preventDefault();const e=t(this),s=e.find("table[data-id]").data("id");e.find("[name=next]").attr("disabled","disabled");let i=e.find("tr[data-content]");i=i.filter((function(){const n=t(this).find("input[type=checkbox]");return!n.length||n.is(":checked")}));let a=0,d=0;!function n(l){if(window.onbeforeunload=function(){return""},0===l.length)return i.length!==a&&"migration"!==s||(window.onbeforeunload=null,_wu_block_ui_polyfill(t("#poststuff .inside")),setTimeout(()=>{e.get(0).submit()},100)),e.find("[name=next]").removeAttr("disabled"),!1;const o=t(l),u=o.data("content");o.get(0).scrollIntoView({behavior:"smooth",block:"center",inline:"nearest"}),o.find("td.status").attr("class","").addClass("status").find("> span").html(wu_setup[u].installing).end().find(".spinner").addClass("is-active").end().find("a.help").slideUp(),t.ajax({url:ajaxurl,method:"post",data:{action:"wu_setup_install",installer:u,"dry-run":wu_setup_settings.dry_run},success(t){!0===t.success?(o.find("td.status").attr("class","").addClass("status wu-text-green-600").find("> span").html(wu_setup[u].success).end().find(".spinner").removeClass("is-active"),o.removeAttr("data-content"),a++):o.find("td.status").attr("class","").addClass("status wu-text-red-400").find("> span").html(t.data[0].message).end().find(".spinner").removeClass("is-active").end().find("a.help").slideDown(),d++,n(i.eq(d))},error(){o.find("td.status").attr("class","").addClass("status wu-text-red-400").find("span").html("").end().find(".spinner").removeClass("is-active").end().find("a.help").slideDown(),d++,n(i.eq(d))}})}(i.eq(d))}))}))}(jQuery),"function"!=typeof wu_initialize_tooltip){const t=function(){jQuery('[role="tooltip"]').tipTip({attribute:"aria-label"})};jQuery(document).ready((function(){t()}))}

View File

@ -0,0 +1,52 @@
/* global wu_site_maintenance, wu_block_ui */
(function($) {
$(document).ready(function() {
$('#wu-tg-maintenance_mode').change(function() {
const blocked = wu_block_ui('#wp-ultimo-site-maintenance-element .inside');
jQuery.ajax({
url: wu_site_maintenance.ajaxurl,
type: 'post',
data: {
action: 'toggle_maintenance_mode',
maintenance_status: $('#wu-tg-maintenance_mode').is(':checked'),
site_hash: $('[name=site_hash]').val(),
_wpnonce: wu_site_maintenance.nonce,
},
success(response) {
blocked.unblock();
if (response.success) {
if (response.data.value) {
$('#wp-admin-bar-wu-maintenance-mode').show();
} else {
$('#wp-admin-bar-wu-maintenance-mode').hide();
} // end if;
}
}, // end success;
error(error) {
// eslint-disable-next-line no-console
console.error(error);
}, // end error;
}); // end ajax;
}); //end checked
});
}(jQuery));

1
assets/js/site-maintenance.min.js vendored Normal file
View File

@ -0,0 +1 @@
!function(e){e(document).ready((function(){e("#wu-tg-maintenance_mode").change((function(){const n=wu_block_ui("#wp-ultimo-site-maintenance-element .inside");jQuery.ajax({url:wu_site_maintenance.ajaxurl,type:"post",data:{action:"toggle_maintenance_mode",maintenance_status:e("#wu-tg-maintenance_mode").is(":checked"),site_hash:e("[name=site_hash]").val(),_wpnonce:wu_site_maintenance.nonce},success(a){n.unblock(),a.success&&(a.data.value?e("#wp-admin-bar-wu-maintenance-mode").show():e("#wp-admin-bar-wu-maintenance-mode").hide())},error(e){console.error(e)}})}))}))}(jQuery);

155
assets/js/sso.js Normal file
View File

@ -0,0 +1,155 @@
/* global wu_create_cookie, wu_sso_config, wu_read_cookie, detectIncognito */
(function(o) {
window.wu = window.wu || {};
window.is_incognito = false;
window.wu.sso_denied = function() {
wu_create_cookie('wu_sso_denied', 1, o.expiration_in_minutes);
}; // end if;
window.wu.check_for_incognito_window = function() {
detectIncognito(results => window.is_incognito = results.isPrivate);
} // end is_incognito_window;
window.wu.check_for_incognito_window();
window.addEventListener('error', wu.sso_denied, true);
const w = document.createElement('script');
w.type = 'text/javascript';
w.async = true;
w.defer = true;
w.src = o.server_url + '?_jsonp=1';
const denied = wu_read_cookie('wu_sso_denied');
document.head.insertAdjacentHTML('beforeend', `
<style>
@keyframes fade_in {
from { opacity: 0; }
to { opacity: 1; }
}
body.sso-loading {
overflow: hidden;
}
body.sso-loading .sso-overlay {
background: rgba(0, 0, 0, 0.7);
width: 100vw;
height: 100vh;
position: absolute;
top: 0;
-webkit-animation: fade_in 300ms;
-moz-animation: fade_in 300ms;
-ms-animation: fade_in 300ms;
-o-animation: fade_in 300ms;
animation: fade_in 300ms;
}
body.sso-loading .sso-overlay::before {
content: "";
display: block;
width: 20px;
height: 20px;
position: absolute;
left: 50%;
top: 50%;
margin: -10px 0 0 -10px;
transform: translateZ(0);
background: transparent url(${ o.img_folder }/spinner.gif) no-repeat center center;
background-image: url(${ o.img_folder }/loader.svg);
background-size: 20px 20px;
}
</style>
`);
if (! o.is_user_logged_in && ! denied) {
const s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(w, s);
document.body.insertAdjacentHTML('beforeend', '<div class="sso-overlay">&nbsp;</div>');
} // end if;
window.wu.sso = function(payload) {
const encodedLocation = encodeURIComponent(window.location.href);
if (payload.code === 200) {
if (o.use_overlay) {
document.body.classList.add('sso-loading');
} // end if;
/**
* In case we're dealing with http (without ssl),
* we force a redirect to bypass browser cookie
* limitations.
*
* Otherwise, on the else block,
* we redirect with the verification code attached,
* to perform a regular SSO flow.
*/
if (payload.verify === 'must-redirect') {
window.location.replace(`${ o.server_url }?return_url=${ encodedLocation }`);
} else {
window.location.replace(`${ o.server_url }?sso_verify=${ payload.verify }&return_url=${ encodedLocation }`);
} // end if;
} else {
/**
* If we are in a incognito window,
* we give it another try with a full redirect,
* as chrome settings might be blocking
* cookies from being sent anyways.
*/
if (window.is_incognito) {
if (o.use_overlay) {
document.body.classList.add('sso-loading');
} // end if;
window.location.replace(`${o.server_url}?return_url=${ encodedLocation }`);
return;
} // end if;
window.wu.sso_denied();
document.body.classList.remove('sso-loading');
} // end if;
}; // end sso;
(function clean_up_query_args() {
if (window.history.replaceState) {
window.history.replaceState(null, null, o.filtered_url + window.location.hash);
} // end if;
}());
}(wu_sso_config));

1
assets/js/sso.min.js vendored Normal file
View File

@ -0,0 +1 @@
!function(n){window.wu=window.wu||{},window.is_incognito=!1,window.wu.sso_denied=function(){wu_create_cookie("wu_sso_denied",1,n.expiration_in_minutes)},window.wu.check_for_incognito_window=function(){detectIncognito(n=>window.is_incognito=n.isPrivate)},window.wu.check_for_incognito_window(),window.addEventListener("error",wu.sso_denied,!0);const o=document.createElement("script");o.type="text/javascript",o.async=!0,o.defer=!0,o.src=n.server_url+"?_jsonp=1";const e=wu_read_cookie("wu_sso_denied");if(document.head.insertAdjacentHTML("beforeend",`\n <style>\n @keyframes fade_in {\n from { opacity: 0; }\n to { opacity: 1; }\n }\n body.sso-loading {\n overflow: hidden;\n }\n body.sso-loading .sso-overlay {\n background: rgba(0, 0, 0, 0.7);\n width: 100vw;\n height: 100vh;\n position: absolute;\n top: 0;\n -webkit-animation: fade_in 300ms;\n -moz-animation: fade_in 300ms;\n -ms-animation: fade_in 300ms;\n -o-animation: fade_in 300ms;\n animation: fade_in 300ms;\n }\n body.sso-loading .sso-overlay::before {\n content: "";\n display: block;\n width: 20px;\n height: 20px;\n position: absolute;\n left: 50%;\n top: 50%;\n margin: -10px 0 0 -10px;\n transform: translateZ(0);\n background: transparent url(${n.img_folder}/spinner.gif) no-repeat center center;\n background-image: url(${n.img_folder}/loader.svg);\n background-size: 20px 20px;\n }\n </style>\n `),!n.is_user_logged_in&&!e){const n=document.getElementsByTagName("script")[0];n.parentNode.insertBefore(o,n),document.body.insertAdjacentHTML("beforeend",'<div class="sso-overlay">&nbsp;</div>')}window.wu.sso=function(o){const e=encodeURIComponent(window.location.href);if(200===o.code)n.use_overlay&&document.body.classList.add("sso-loading"),"must-redirect"===o.verify?window.location.replace(`${n.server_url}?return_url=${e}`):window.location.replace(`${n.server_url}?sso_verify=${o.verify}&return_url=${e}`);else{if(window.is_incognito)return n.use_overlay&&document.body.classList.add("sso-loading"),void window.location.replace(`${n.server_url}?return_url=${e}`);window.wu.sso_denied(),document.body.classList.remove("sso-loading")}},window.history.replaceState&&window.history.replaceState(null,null,n.filtered_url+window.location.hash)}(wu_sso_config);

71
assets/js/support.js Normal file
View File

@ -0,0 +1,71 @@
/* global wu_support_vars, Beacon, wu_block_ui, _wu_block_ui_polyfill */
let wu_install_support_widget_done = false;
const wu_install_support_widget = function() {
if (wu_install_support_widget_done === true) {
return;
} // end if;
/* eslint-disable */
!function (e, t, n) { function a() { var e = t.getElementsByTagName("script")[0], n = t.createElement("script"); n.type = "text/javascript", n.async = !0, n.src = "https://beacon-v2.helpscout.net", e.parentNode.insertBefore(n, e) } if (e.Beacon = n = function (t, n, a) { e.Beacon.readyQueue.push({ method: t, options: n, data: a }) }, n.readyQueue = [], "complete" === t.readyState) return a(); e.attachEvent ? e.attachEvent("onload", a) : e.addEventListener("load", a, !1) }(window, document, window.Beacon || function () { });
window.Beacon('init', '687a385f-df79-4b37-b6a9-7114a7d3d586');
/* eslint-enable */
wu_install_support_widget_done = true;
};
const hs_beacon = document.getElementsByClassName('wu-trigger-support');
if (hs_beacon.length) {
hs_beacon[0].addEventListener('click', function(a) {
wu_install_support_widget();
const blocked_ui = wu_support_vars.should_use_polyfills ? _wu_block_ui_polyfill('#wpcontent') : wu_block_ui('#wpcontent');
a.preventDefault();
setTimeout(function() {
Beacon('identify', {
avatar: wu_support_vars.avatar, // Avatar
name: wu_support_vars.display_name, // Full name
email: wu_support_vars.email, // Email address
licenseKey: wu_support_vars.license_key, // License key
signature: wu_support_vars.signature,
});
if (wu_support_vars.subject || wu_support_vars.message) {
Beacon('prefill', {
subject: wu_support_vars.subject,
text: wu_support_vars.message,
});
} // end if;
Beacon('on', 'open', function() {
if (blocked_ui) {
blocked_ui.unblock();
} // end if;
});
Beacon('open');
}, 5E3);
}, false);
} // end if;

1
assets/js/support.min.js vendored Normal file
View File

@ -0,0 +1 @@
let wu_install_support_widget_done=!1;const wu_install_support_widget=function(){!0!==wu_install_support_widget_done&&(!function(e,t,n){function a(){var e=t.getElementsByTagName("script")[0],n=t.createElement("script");n.type="text/javascript",n.async=!0,n.src="https://beacon-v2.helpscout.net",e.parentNode.insertBefore(n,e)}if(e.Beacon=n=function(t,n,a){e.Beacon.readyQueue.push({method:t,options:n,data:a})},n.readyQueue=[],"complete"===t.readyState)return a();e.attachEvent?e.attachEvent("onload",a):e.addEventListener("load",a,!1)}(window,document,window.Beacon||function(){}),window.Beacon("init","687a385f-df79-4b37-b6a9-7114a7d3d586"),wu_install_support_widget_done=!0)},hs_beacon=document.getElementsByClassName("wu-trigger-support");hs_beacon.length&&hs_beacon[0].addEventListener("click",(function(e){!0!==wu_install_support_widget_done&&(function(e,t,n){function a(){var e=t.getElementsByTagName("script")[0],n=t.createElement("script");n.type="text/javascript",n.async=!0,n.src="https://beacon-v2.helpscout.net",e.parentNode.insertBefore(n,e)}if(e.Beacon=n=function(t,n,a){e.Beacon.readyQueue.push({method:t,options:n,data:a})},n.readyQueue=[],"complete"===t.readyState)return a();e.attachEvent?e.attachEvent("onload",a):e.addEventListener("load",a,!1)}(window,document,window.Beacon||function(){}),window.Beacon("init","687a385f-df79-4b37-b6a9-7114a7d3d586"),wu_install_support_widget_done=!0);const t=wu_support_vars.should_use_polyfills?_wu_block_ui_polyfill("#wpcontent"):wu_block_ui("#wpcontent");e.preventDefault(),setTimeout((function(){Beacon("identify",{avatar:wu_support_vars.avatar,name:wu_support_vars.display_name,email:wu_support_vars.email,licenseKey:wu_support_vars.license_key,signature:wu_support_vars.signature}),(wu_support_vars.subject||wu_support_vars.message)&&Beacon("prefill",{subject:wu_support_vars.subject,text:wu_support_vars.message}),Beacon("on","open",(function(){t&&t.unblock()})),Beacon("open")}),5e3)}),!1);

385
assets/js/tax-rates.js Normal file
View File

@ -0,0 +1,385 @@
/* eslint-disable no-lonely-if */
/* global _, vuedraggable, Vue, wu_block_ui, ajaxurl, wu_tax_ratesl10n */
(function($) {
$(document).ready(function() {
/**
* Vue
*/
if ($('#wu-tax-rates').length) {
Vue.component('selectizer', {
props: [
'value',
'id',
'name',
'model',
'country',
'state',
'selected',
'options',
'placeholder',
],
template: '<input v-bind="$props">',
updated() {
this.$nextTick(function() {
const options = jQuery(this.$el).data('__options');
if (options.data.country !== this.country) {
options.data.country = this.country;
jQuery(this.$el).data('__options', options);
this.$el.selectize.clear();
this.$el.selectize.clearOptions();
} // end if;
if (options.data.state !== this.state) {
options.data.state = this.state;
jQuery(this.$el).data('__options', options);
} // end if;
});
},
mounted() {
const that = this;
const item = this.$el;
window.wu_selector({
el: item,
maxItems: 1000,
options: this.options,
valueField: 'slug',
labelField: 'name',
searchField: ['slug', 'name'],
create: true,
templateName: 'checkout_form',
data: {
action: 'wu_search',
model: this.model,
country: this.country,
state: this.state,
number: 10,
},
});
this.$el.selectize.on('change', function(value) {
that.$emit('input', value);
});
},
});
window.wu_tax_rates = new Vue({
el: '#wu-tax-rates',
components: {
vuedraggable,
},
data() {
return {
dragging: false,
tax_category: 'default',
switching: false,
creating: false,
create_name: '',
toggle: false,
loading: true,
saving: false,
initialLoading: true,
error: false,
changed: false,
data: {
default: {
name: 'Default',
rates: [],
},
},
delete: [],
saveMessage: '',
errorMessage: '',
rate_type: 'standard_rate',
editing: 0,
item: {
title: wu_tax_ratesl10n.name,
country: '',
state: '',
tax_rate: '',
type: 'regular',
compound: false,
},
};
},
watch: {
loading(new_value) {
if (new_value === true) {
window.wu_blocked_table = wu_block_ui('table.wp-list-table');
} else {
if (typeof window.wu_blocked_table !== 'undefined') {
window.wu_blocked_table.unblock();
} // end if;
} // end if;
},
},
mounted() {
this.loading = true;
this.pull_data(true);
$('.wu-tooltip-vue').tipTip();
const vm = this;
this.$watch('data', function() {
if (vm.initialLoading) {
vm.initialLoading = false;
return;
}
vm.changed = true;
}, {
deep: true,
});
},
created() {
// Create the event.
const event = document.createEvent('Event');
// Define that the event name is 'build'.
event.initEvent('vue_loaded', true, true);
event.vue = this;
// target can be any Element or other EventTarget.
window.dispatchEvent(event);
},
computed: {
selected() {
return $(this.data[this.tax_category].rates).filter(function(index, item) {
return item.selected;
});
},
},
methods: {
refresh(e) {
e.preventDefault();
this.loading = true;
this.pull_data();
},
select_all(event) {
const toggle = $(event.target).is(':checked');
this.data[this.tax_category].rates = $.map(this.data[this.tax_category].rates, function(item) {
item.selected = toggle;
return item;
});
},
pull_data() {
const that = this;
jQuery.getJSON(ajaxurl + '?action=wu_get_tax_rates').done(function(response) {
that.loading = false;
that.data = response.data;
})
.fail(function(error) {
that.loading = false;
that.error = true;
that.errorMessage = error.statusText;
});
},
add_tax_category() {
this.data[this.create_name] = {
name: this.create_name,
rates: [],
};
this.creating = false;
this.tax_category = this.create_name;
},
add_row() {
Vue.set(this.data[this.tax_category], 'rates', this.data[this.tax_category].rates.concat([
{
title: wu_tax_ratesl10n.name,
country: '',
state: '',
tax_rate: '',
type: 'regular',
compound: false,
},
]));
this.$forceUpdate();
},
delete_tax_category() {
// eslint-disable-next-line no-alert
const are_you_sure = confirm(wu_tax_ratesl10n.confirm_delete_tax_category_message);
const that = this;
if (are_you_sure) {
const cleaned_list = _.filter(this.data, function(item, index) {
return index !== that.tax_category;
});
that.data = cleaned_list.length ? cleaned_list : {
default: {
name: 'Default',
rates: [],
},
};
that.tax_category = Object.keys(that.data).shift();
} // end if
},
delete_rows() {
this.delete = this.delete.concat(this.selected.get());
// eslint-disable-next-line no-alert
const are_you_sure = confirm(wu_tax_ratesl10n.confirm_message);
if (are_you_sure) {
const cleaned_list = $(this.data[this.tax_category].rates).filter(function(index, item) {
return ! item.selected;
});
Vue.set(this.data[this.tax_category], 'rates', cleaned_list.get());
this.$forceUpdate();
} // end if
},
save() {
const that = this;
that.saving = true;
if (typeof that.data[that.tax_category].rates !== 'undefined') {
_.map(that.data[that.tax_category].rates, (item, index) => {
item.priority = index * 10;
return item;
});
}
$.post({
url: ajaxurl + '?action=wu_save_tax_rates&' + $('#nonce_form').serialize(),
data: JSON.stringify({
tax_rates: that.data,
tax_category: that.tax_category,
}),
dataType: 'json',
contentType: 'application/json; charset=utf-8',
}).success(function(data) {
that.saving = false;
that.changed = false;
that.delete = [];
that.saveMessage = data.message;
if (data.code === 'success') {
that.loading = true;
that.initialLoading = true;
that.pull_data();
that.tax_category = data.tax_category;
}
setInterval(function() {
that.saveMessage = '';
}, 6000);
});
},
},
});
} // end if;
});
}(jQuery));

1
assets/js/tax-rates.min.js vendored Normal file
View File

@ -0,0 +1 @@
!function(t){t(document).ready((function(){t("#wu-tax-rates").length&&(Vue.component("selectizer",{props:["value","id","name","model","country","state","selected","options","placeholder"],template:'<input v-bind="$props">',updated(){this.$nextTick((function(){const t=jQuery(this.$el).data("__options");t.data.country!==this.country&&(t.data.country=this.country,jQuery(this.$el).data("__options",t),this.$el.selectize.clear(),this.$el.selectize.clearOptions()),t.data.state!==this.state&&(t.data.state=this.state,jQuery(this.$el).data("__options",t))}))},mounted(){const t=this,e=this.$el;window.wu_selector({el:e,maxItems:1e3,options:this.options,valueField:"slug",labelField:"name",searchField:["slug","name"],create:!0,templateName:"checkout_form",data:{action:"wu_search",model:this.model,country:this.country,state:this.state,number:10}}),this.$el.selectize.on("change",(function(e){t.$emit("input",e)}))}}),window.wu_tax_rates=new Vue({el:"#wu-tax-rates",components:{vuedraggable:vuedraggable},data:()=>({dragging:!1,tax_category:"default",switching:!1,creating:!1,create_name:"",toggle:!1,loading:!0,saving:!1,initialLoading:!0,error:!1,changed:!1,data:{default:{name:"Default",rates:[]}},delete:[],saveMessage:"",errorMessage:"",rate_type:"standard_rate",editing:0,item:{title:wu_tax_ratesl10n.name,country:"",state:"",tax_rate:"",type:"regular",compound:!1}}),watch:{loading(t){!0===t?window.wu_blocked_table=wu_block_ui("table.wp-list-table"):void 0!==window.wu_blocked_table&&window.wu_blocked_table.unblock()}},mounted(){this.loading=!0,this.pull_data(!0),t(".wu-tooltip-vue").tipTip();const e=this;this.$watch("data",(function(){e.initialLoading?e.initialLoading=!1:e.changed=!0}),{deep:!0})},created(){const t=document.createEvent("Event");t.initEvent("vue_loaded",!0,!0),t.vue=this,window.dispatchEvent(t)},computed:{selected(){return t(this.data[this.tax_category].rates).filter((function(t,e){return e.selected}))}},methods:{refresh(t){t.preventDefault(),this.loading=!0,this.pull_data()},select_all(e){const a=t(e.target).is(":checked");this.data[this.tax_category].rates=t.map(this.data[this.tax_category].rates,(function(t){return t.selected=a,t}))},pull_data(){const t=this;jQuery.getJSON(ajaxurl+"?action=wu_get_tax_rates").done((function(e){t.loading=!1,t.data=e.data})).fail((function(e){t.loading=!1,t.error=!0,t.errorMessage=e.statusText}))},add_tax_category(){this.data[this.create_name]={name:this.create_name,rates:[]},this.creating=!1,this.tax_category=this.create_name},add_row(){Vue.set(this.data[this.tax_category],"rates",this.data[this.tax_category].rates.concat([{title:wu_tax_ratesl10n.name,country:"",state:"",tax_rate:"",type:"regular",compound:!1}])),this.$forceUpdate()},delete_tax_category(){const t=confirm(wu_tax_ratesl10n.confirm_delete_tax_category_message),e=this;if(t){const t=_.filter(this.data,(function(t,a){return a!==e.tax_category}));e.data=t.length?t:{default:{name:"Default",rates:[]}},e.tax_category=Object.keys(e.data).shift()}},delete_rows(){this.delete=this.delete.concat(this.selected.get());if(confirm(wu_tax_ratesl10n.confirm_message)){const e=t(this.data[this.tax_category].rates).filter((function(t,e){return!e.selected}));Vue.set(this.data[this.tax_category],"rates",e.get()),this.$forceUpdate()}},save(){const e=this;e.saving=!0,void 0!==e.data[e.tax_category].rates&&_.map(e.data[e.tax_category].rates,(t,e)=>(t.priority=10*e,t)),t.post({url:ajaxurl+"?action=wu_save_tax_rates&"+t("#nonce_form").serialize(),data:JSON.stringify({tax_rates:e.data,tax_category:e.tax_category}),dataType:"json",contentType:"application/json; charset=utf-8"}).success((function(t){e.saving=!1,e.changed=!1,e.delete=[],e.saveMessage=t.message,"success"===t.code&&(e.loading=!0,e.initialLoading=!0,e.pull_data(),e.tax_category=t.tax_category),setInterval((function(){e.saveMessage=""}),6e3)}))}}}))}))}(jQuery);

136
assets/js/tax-statistics.js Normal file
View File

@ -0,0 +1,136 @@
/* eslint-disable */
(function() {
let graph = document.getElementById('wp-ultimo-taxes');
if (!graph) {
return;
} // end if;
const tax_graph = new Vue({
el: '#wp-ultimo-taxes',
components: {
apexchart: window.VueApexCharts,
},
data: {
chart_options: {
mrr_growth: {
series: [
{
name: wu_tax_statistics_vars.i18n.net_profit_label,
data: [
wu_tax_statistics_vars.data.january.net_profit,
wu_tax_statistics_vars.data.february.net_profit,
wu_tax_statistics_vars.data.march.net_profit,
wu_tax_statistics_vars.data.april.net_profit,
wu_tax_statistics_vars.data.may.net_profit,
wu_tax_statistics_vars.data.june.net_profit,
wu_tax_statistics_vars.data.july.net_profit,
wu_tax_statistics_vars.data.august.net_profit,
wu_tax_statistics_vars.data.september.net_profit,
wu_tax_statistics_vars.data.october.net_profit,
wu_tax_statistics_vars.data.november.net_profit,
wu_tax_statistics_vars.data.december.net_profit
]
},
{
name: wu_tax_statistics_vars.i18n.taxes_label,
data: [
wu_tax_statistics_vars.data.january.tax_total,
wu_tax_statistics_vars.data.february.tax_total,
wu_tax_statistics_vars.data.march.tax_total,
wu_tax_statistics_vars.data.april.tax_total,
wu_tax_statistics_vars.data.may.tax_total,
wu_tax_statistics_vars.data.june.tax_total,
wu_tax_statistics_vars.data.july.tax_total,
wu_tax_statistics_vars.data.august.tax_total,
wu_tax_statistics_vars.data.september.tax_total,
wu_tax_statistics_vars.data.october.tax_total,
wu_tax_statistics_vars.data.november.tax_total,
wu_tax_statistics_vars.data.december.tax_total
]
},
],
chartOptions: {
chart: {
type: 'bar',
height: 300,
stacked: true,
toolbar: {
show: false
},
zoom: {
enabled: true
}
},
dataLabels: {
enabled: false,
maxItems: 0,
},
responsive: [{
breakpoint: 480,
options: {
legend: {
position: 'bottom',
offsetX: -10,
offsetY: 0
}
}
}],
colors: ['#2c3e50', '#95a5a6'],
plotOptions: {
bar: {
horizontal: false,
columnWidth: '40%',
endingShape: 'rounded',
startingShape: 'rounded',
},
},
xaxis: {
categories: wu_tax_statistics_vars.month_list,
position: 'bottom',
axisBorder: {
show: true
},
axisTicks: {
show: true
},
crosshairs: {
fill: {
type: 'gradient',
gradient: {
colorFrom: '#D8E3F0',
colorTo: '#BED1E6',
stops: [0, 100],
opacityFrom: 0.4,
opacityTo: 0.5,
}
}
},
tooltip: {
enabled: true,
}
},
yaxis: {
labels: {
formatter: function (y) {
return y >= 0 ? wu_format_money(y) : '-' + wu_format_money(y);
}
}
},
legend: {
position: 'top',
offsetY: 0
},
fill: {
opacity: 1
}
},
},
},
},
});
}());

1
assets/js/tax-statistics.min.js vendored Normal file
View File

@ -0,0 +1 @@
!function(){if(!document.getElementById("wp-ultimo-taxes"))return;new Vue({el:"#wp-ultimo-taxes",components:{apexchart:window.VueApexCharts},data:{chart_options:{mrr_growth:{series:[{name:wu_tax_statistics_vars.i18n.net_profit_label,data:[wu_tax_statistics_vars.data.january.net_profit,wu_tax_statistics_vars.data.february.net_profit,wu_tax_statistics_vars.data.march.net_profit,wu_tax_statistics_vars.data.april.net_profit,wu_tax_statistics_vars.data.may.net_profit,wu_tax_statistics_vars.data.june.net_profit,wu_tax_statistics_vars.data.july.net_profit,wu_tax_statistics_vars.data.august.net_profit,wu_tax_statistics_vars.data.september.net_profit,wu_tax_statistics_vars.data.october.net_profit,wu_tax_statistics_vars.data.november.net_profit,wu_tax_statistics_vars.data.december.net_profit]},{name:wu_tax_statistics_vars.i18n.taxes_label,data:[wu_tax_statistics_vars.data.january.tax_total,wu_tax_statistics_vars.data.february.tax_total,wu_tax_statistics_vars.data.march.tax_total,wu_tax_statistics_vars.data.april.tax_total,wu_tax_statistics_vars.data.may.tax_total,wu_tax_statistics_vars.data.june.tax_total,wu_tax_statistics_vars.data.july.tax_total,wu_tax_statistics_vars.data.august.tax_total,wu_tax_statistics_vars.data.september.tax_total,wu_tax_statistics_vars.data.october.tax_total,wu_tax_statistics_vars.data.november.tax_total,wu_tax_statistics_vars.data.december.tax_total]}],chartOptions:{chart:{type:"bar",height:300,stacked:!0,toolbar:{show:!1},zoom:{enabled:!0}},dataLabels:{enabled:!1,maxItems:0},responsive:[{breakpoint:480,options:{legend:{position:"bottom",offsetX:-10,offsetY:0}}}],colors:["#2c3e50","#95a5a6"],plotOptions:{bar:{horizontal:!1,columnWidth:"40%",endingShape:"rounded",startingShape:"rounded"}},xaxis:{categories:wu_tax_statistics_vars.month_list,position:"bottom",axisBorder:{show:!0},axisTicks:{show:!0},crosshairs:{fill:{type:"gradient",gradient:{colorFrom:"#D8E3F0",colorTo:"#BED1E6",stops:[0,100],opacityFrom:.4,opacityTo:.5}}},tooltip:{enabled:!0}},yaxis:{labels:{formatter:function(t){return t>=0?wu_format_money(t):"-"+wu_format_money(t)}}},legend:{position:"top",offsetY:0},fill:{opacity:1}}}}}})}();

View File

@ -0,0 +1,143 @@
(() => {
"use strict";
const CreateCookie = (name, value, days) => {
let expires;
if (days) {
const date = /* @__PURE__ */ new Date();
date.setTime(date.getTime() + days * 24 * 60 * 60 * 1e3);
expires = "; expires=" + date.toUTCString();
} else {
expires = "";
}
document.cookie = name + "=" + value + expires + "; path=/";
};
const ReadCookie = (name) => {
const nameEQ = name + "=";
const ca = document.cookie.split(";");
for (let i = 0; i < ca.length; i++) {
let c = ca[i];
while (c.charAt(0) === " ") {
c = c.substring(1, c.length);
}
if (c.indexOf(nameEQ) === 0) {
return c.substring(nameEQ.length, c.length);
}
}
return null;
};
const ListenToCookieChange = (name, callback) => {
let cookie_value = ReadCookie(name);
setInterval(function() {
const new_cookie_value = ReadCookie(name);
if (new_cookie_value !== cookie_value) {
cookie_value = new_cookie_value;
callback(cookie_value);
}
}, 100);
};
window.addEventListener("beforeunload", () => {
var _a;
return (_a = window.top) == null ? void 0 : _a.postMessage("wu_preview_changed", "*");
});
CreateCookie("wu_template", "");
const isIOS = () => {
var _a;
window.addEventListener("touchstart", () => {
});
const iDevices = [
"iPad Simulator",
"iPhone Simulator",
"iPod Simulator",
"iPad",
"iPhone",
"iPod"
];
const platform = ((_a = navigator == null ? void 0 : navigator.userAgentData) == null ? void 0 : _a.platform) || (navigator == null ? void 0 : navigator.platform) || "";
return iDevices.includes(platform);
};
document.addEventListener("DOMContentLoaded", () => {
var _a;
ListenToCookieChange("wu_selected_products", () => document.location.reload());
const iframe = document.getElementById("iframe");
const wn = iframe == null ? void 0 : iframe.contentWindow;
wn == null ? void 0 : wn.postMessage("Hello to iframe from parent!", "https://" + location.hostname);
const elements = document.querySelectorAll("#action-select, #action-select2");
elements.forEach((element) => element.addEventListener("click", (event) => {
event.preventDefault();
const value = document.getElementById("template-selector").value;
CreateCookie("wu_template", value);
window.close();
}));
iframe == null ? void 0 : iframe.addEventListener("load", () => {
var _a2;
if (isIOS()) {
const body = (_a2 = document.getElementById("iframe")) == null ? void 0 : _a2.getElementsByTagName("body")[0];
body == null ? void 0 : body.classList.add("wu-fix-safari-preview");
(body == null ? void 0 : body.style) && Object.assign(body.style, {
position: "fixed",
top: 0,
right: 0,
bottom: 0,
left: 0,
"overflow-y": "scroll",
"-webkit-overflow-scrolling": "touch"
});
}
});
const adjustIframeHeight = () => {
var _a2;
const ee = ((_a2 = document.getElementById("switcher")) == null ? void 0 : _a2.offsetHeight) || 0;
iframe.style.height = document.body.offsetHeight - ee + "px";
};
window.addEventListener("resize", adjustIframeHeight);
adjustIframeHeight();
const toggleList = () => {
const list = document.querySelectorAll("#theme_list ul");
list.forEach((element) => element.style.display = element.style.display === "none" ? "block" : "none");
};
toggleList();
(_a = document.getElementById("template_selector")) == null ? void 0 : _a.addEventListener("click", (event) => {
event.preventDefault();
toggleList();
});
document.querySelectorAll("#theme_list ul li a").forEach((element) => element.addEventListener("click", (event) => {
event.preventDefault();
toggleList();
const target = event.currentTarget;
const href = target.getAttribute("href") || "";
iframe.src = target.getAttribute("data-frame") || "";
const selector = document.getElementById("template_selector");
const selectorText = selector.firstChild;
selectorText.nodeValue = target.getAttribute("data-title") || "";
window.history.pushState({}, "", href);
}));
const headerBar = document.getElementById("header-bar");
if (headerBar) {
headerBar.style.display = "none";
}
const screenSizes = {
desktop: "100%",
tabletlandscape: "1040px",
tabletportrait: "788px",
mobilelandscape: "500px",
mobileportrait: "340px",
placebo: "0px"
};
document.querySelectorAll(".responsive a").forEach((element) => element.addEventListener("click", (event) => {
const target = event.currentTarget;
const width = Array.from(target.classList).reduce((acc, cur) => {
if (screenSizes[cur]) {
acc = screenSizes[cur];
}
return acc;
}, "");
iframe.style.width = width;
iframe.style.transition = "200ms";
document.querySelectorAll(".responsive a").forEach((element2) => element2.classList.remove("active"));
target.classList.add("active");
}));
if (navigator.userAgent.match(/iPad/i) !== null) {
iframe.style.height = "100%";
}
});
})()

1
assets/js/template-previewer.min.js vendored Normal file
View File

@ -0,0 +1 @@
(()=>{"use strict";const e=(e,t,n)=>{let o;if(n){const e=new Date;e.setTime(e.getTime()+24*n*60*60*1e3),o="; expires="+e.toUTCString()}else o="";document.cookie=e+"="+t+o+"; path=/"},t=e=>{const t=e+"=",n=document.cookie.split(";");for(let e=0;e<n.length;e++){let o=n[e];for(;" "===o.charAt(0);)o=o.substring(1,o.length);if(0===o.indexOf(t))return o.substring(t.length,o.length)}return null};window.addEventListener("beforeunload",(()=>{var e;return null==(e=window.top)?void 0:e.postMessage("wu_preview_changed","*")})),e("wu_template","");document.addEventListener("DOMContentLoaded",(()=>{var n;((e,n)=>{let o=t(e);setInterval((function(){const l=t(e);l!==o&&(o=l,n(o))}),100)})("wu_selected_products",(()=>document.location.reload()));const o=document.getElementById("iframe"),l=null==o?void 0:o.contentWindow;null==l||l.postMessage("Hello to iframe from parent!","https://"+location.hostname);document.querySelectorAll("#action-select, #action-select2").forEach((t=>t.addEventListener("click",(t=>{t.preventDefault();const n=document.getElementById("template-selector").value;e("wu_template",n),window.close()})))),null==o||o.addEventListener("load",(()=>{var e;if((()=>{var e;window.addEventListener("touchstart",(()=>{}));const t=(null==(e=null==navigator?void 0:navigator.userAgentData)?void 0:e.platform)||(null==navigator?void 0:navigator.platform)||"";return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(t)})()){const t=null==(e=document.getElementById("iframe"))?void 0:e.getElementsByTagName("body")[0];null==t||t.classList.add("wu-fix-safari-preview"),(null==t?void 0:t.style)&&Object.assign(t.style,{position:"fixed",top:0,right:0,bottom:0,left:0,"overflow-y":"scroll","-webkit-overflow-scrolling":"touch"})}}));const i=()=>{var e;const t=(null==(e=document.getElementById("switcher"))?void 0:e.offsetHeight)||0;o.style.height=document.body.offsetHeight-t+"px"};window.addEventListener("resize",i),i();const a=()=>{document.querySelectorAll("#theme_list ul").forEach((e=>e.style.display="none"===e.style.display?"block":"none"))};a(),null==(n=document.getElementById("template_selector"))||n.addEventListener("click",(e=>{e.preventDefault(),a()})),document.querySelectorAll("#theme_list ul li a").forEach((e=>e.addEventListener("click",(e=>{e.preventDefault(),a();const t=e.currentTarget,n=t.getAttribute("href")||"";o.src=t.getAttribute("data-frame")||"";document.getElementById("template_selector").firstChild.nodeValue=t.getAttribute("data-title")||"",window.history.pushState({},"",n)}))));const r=document.getElementById("header-bar");r&&(r.style.display="none");const s={desktop:"100%",tabletlandscape:"1040px",tabletportrait:"788px",mobilelandscape:"500px",mobileportrait:"340px",placebo:"0px"};document.querySelectorAll(".responsive a").forEach((e=>e.addEventListener("click",(e=>{const t=e.currentTarget,n=Array.from(t.classList).reduce(((e,t)=>(s[t]&&(e=s[t]),e)),"");o.style.width=n,o.style.transition="200ms",document.querySelectorAll(".responsive a").forEach((e=>e.classList.remove("active"))),t.classList.add("active")})))),null!==navigator.userAgent.match(/iPad/i)&&(o.style.height="100%")}))})();

View File

@ -0,0 +1,219 @@
/* global wu_template_switching_params, Vue, wu_create_cookie, wu_listen_to_cookie_change */
(function($, hooks) {
/*
* Sets up the cookie listener for template selection.
*/
hooks.addAction('wu_checkout_loaded', 'nextpress/wp-ultimo', function() {
/*
* Resets the template selection cookie.
*/
wu_create_cookie('wu_template', false);
/*
* Listens for changes and set the template if one is detected.
*/
wu_listen_to_cookie_change('wu_template', function(value) {
window.wu_template_switching.template_id = value;
});
});
$(document).ready(function() {
const dynamic = {
functional: true,
template: '#dynamic',
props: ['template'],
render(h, context) {
const template = context.props.template;
const component = template ? { template } : '<div>nbsp;</div>';
return h(component);
},
};
hooks.doAction('wu_checkout_loaded');
// eslint-disable-next-line no-unused-vars
window.wu_template_switching = new Vue({
el: '#wp-ultimo-form-wu-template-switching-form',
data() {
return {
template_id: 0,
original_template_id: -1,
template_category: '',
stored_templates: {},
confirm_switch: 0,
ready: false,
};
},
directives: {
init: {
bind(el, binding, vnode) {
vnode.context[binding.arg] = binding.value;
},
},
},
components: {
dynamic,
},
watch: {
ready() {
const that = this;
if (that.ready !== false) {
that.switch_template();
} // end if;
},
},
methods: {
get_template(template, data) {
if (typeof data.id === 'undefined') {
data.id = 'default';
} // end if;
const template_name = template + '/' + data.id;
if (typeof this.stored_templates[template_name] !== 'undefined') {
return this.stored_templates[template_name];
} // end if;
const template_data = {
duration: this.duration,
duration_unit: this.duration_unit,
products: this.products,
...data,
};
this.fetch_template(template, template_data);
return '<div class="wu-p-4 wu-bg-gray-100 wu-text-center wu-rounded">Loading</div>';
},
fetch_template(template, data) {
const that = this;
if (typeof data.id === 'undefined') {
data.id = 'default';
} // end if;
this.request('wu_render_field_template', {
template,
attributes: data,
}, function(results) {
const template_name = template + '/' + data.id;
if (results.success) {
Vue.set(that.stored_templates, template_name, results.data.html);
} else {
Vue.set(that.stored_templates, template_name, '<div>' + results.data[0].message + '</div>');
} // end if;
});
},
switch_template() {
const that = this;
that.block();
this.request('wu_switch_template', {
template_id: that.template_id,
}, function(results) {
/*
* Redirect of we get a redirect URL back.
*/
if (typeof results.data.redirect_url === 'string') {
window.location.href = results.data.redirect_url;
} // end if;
});
},
block() {
/*
* Get the first bg color from a parent.
*/
const bg_color = jQuery(this.$el).parents().filter(function() {
return $(this).css('backgroundColor') !== 'rgba(0, 0, 0, 0)';
}).first().css('backgroundColor');
jQuery(this.$el).wu_block({
message: '<div class="spinner is-active wu-float-none" style="float: none !important;"></div>',
overlayCSS: {
backgroundColor: bg_color ? bg_color : '#ffffff',
opacity: 0.6,
},
css: {
padding: 0,
margin: 0,
width: '50%',
fontSize: '14px !important',
top: '40%',
left: '35%',
textAlign: 'center',
color: '#000',
border: 'none',
backgroundColor: 'none',
cursor: 'wait',
},
});
},
unblock() {
jQuery(this.$el).wu_unblock();
},
request(action, data, success_handler, error_handler) {
jQuery.ajax({
method: 'POST',
url: wu_template_switching_params.ajaxurl + '&action=' + action,
data,
success: success_handler,
error: error_handler,
});
},
},
});
});
}(jQuery, wp.hooks));

1
assets/js/template-switching.min.js vendored Normal file
View File

@ -0,0 +1 @@
!function(t,e){e.addAction("wu_checkout_loaded","nextpress/wp-ultimo",(function(){wu_create_cookie("wu_template",!1),wu_listen_to_cookie_change("wu_template",(function(t){window.wu_template_switching.template_id=t}))})),t(document).ready((function(){const i={functional:!0,template:"#dynamic",props:["template"],render(t,e){const i=e.props.template;return t(i?{template:i}:"<div>nbsp;</div>")}};e.doAction("wu_checkout_loaded"),window.wu_template_switching=new Vue({el:"#wp-ultimo-form-wu-template-switching-form",data:()=>({template_id:0,original_template_id:-1,template_category:"",stored_templates:{},confirm_switch:0,ready:!1}),directives:{init:{bind(t,e,i){i.context[e.arg]=e.value}}},components:{dynamic:i},watch:{ready(){const t=this;!1!==t.ready&&t.switch_template()}},methods:{get_template(t,e){void 0===e.id&&(e.id="default");const i=t+"/"+e.id;if(void 0!==this.stored_templates[i])return this.stored_templates[i];const o={duration:this.duration,duration_unit:this.duration_unit,products:this.products,...e};return this.fetch_template(t,o),'<div class="wu-p-4 wu-bg-gray-100 wu-text-center wu-rounded">Loading</div>'},fetch_template(t,e){const i=this;void 0===e.id&&(e.id="default"),this.request("wu_render_field_template",{template:t,attributes:e},(function(o){const a=t+"/"+e.id;o.success?Vue.set(i.stored_templates,a,o.data.html):Vue.set(i.stored_templates,a,"<div>"+o.data[0].message+"</div>")}))},switch_template(){this.block(),this.request("wu_switch_template",{template_id:this.template_id},(function(t){"string"==typeof t.data.redirect_url&&(window.location.href=t.data.redirect_url)}))},block(){const e=jQuery(this.$el).parents().filter((function(){return"rgba(0, 0, 0, 0)"!==t(this).css("backgroundColor")})).first().css("backgroundColor");jQuery(this.$el).wu_block({message:'<div class="spinner is-active wu-float-none" style="float: none !important;"></div>',overlayCSS:{backgroundColor:e||"#ffffff",opacity:.6},css:{padding:0,margin:0,width:"50%",fontSize:"14px !important",top:"40%",left:"35%",textAlign:"center",color:"#000",border:"none",backgroundColor:"none",cursor:"wait"}})},unblock(){jQuery(this.$el).wu_unblock()},request(t,e,i,o){jQuery.ajax({method:"POST",url:wu_template_switching_params.ajaxurl+"&action="+t,data:e,success:i,error:o})}}})}))}(jQuery,wp.hooks);

139
assets/js/thank-you.js Normal file
View File

@ -0,0 +1,139 @@
(() => {
"use strict";
const TransitionText = (element, has_icon = false) => {
return {
classes: [],
has_icon: false,
original_value: element.innerHTML,
get_icon() {
return this.has_icon ? '<span class="wu-spin wu-inline-block wu-mr-2"><span class="dashicons-wu-loader"></span></span>' : "";
},
clear_classes() {
element.classList.remove(...this.classes);
},
add_classes(classes) {
this.classes = classes;
element.classList.add(...classes);
},
text(text, classes, toggle_icon = false) {
this.clear_classes();
if (toggle_icon) {
this.has_icon = !this.has_icon;
}
element.animate([
{
opacity: "1"
},
{
opacity: "0.75"
}
], {
duration: 300,
iterations: 1
});
setTimeout(() => {
this.add_classes(classes ?? []);
element.innerHTML = this.get_icon() + text;
element.style.opacity = "0.75";
}, 300);
return this;
},
done(timeout = 5e3) {
setTimeout(() => {
element.animate([
{
opacity: "0.75"
},
{
opacity: "1"
}
], {
duration: 300,
iterations: 1
});
setTimeout(() => {
this.clear_classes();
element.innerHTML = this.original_value;
element.style.opacity = "1";
}, 300);
}, timeout);
return this;
}
};
};
document.addEventListener("DOMContentLoaded", () => {
document.querySelectorAll(".wu-resend-verification-email").forEach((element) => element.addEventListener("click", async (event) => {
event.preventDefault();
const transitional_text = TransitionText(element, true).text(wu_thank_you.i18n.resending_verification_email, ["wu-text-gray-400"]);
const request = await fetch(
wu_thank_you.ajaxurl,
{
method: "POST",
body: JSON.stringify({
action: "wu_resend_verification_email",
_ajax_nonce: wu_thank_you.resend_verification_email_nonce
})
}
);
const response = await request.json();
if (response.success) {
transitional_text.text(wu_thank_you.i18n.email_sent, ["wu-text-green-700"], true).done();
} else {
transitional_text.text(response.data[0].message, ["wu-text-red-600"], true).done();
}
}));
if (!document.getElementById("wu-sites")) {
return;
}
const { Vue, defineComponent } = window.wu_vue;
window.wu_sites = new Vue(defineComponent({
el: "#wu-sites",
data() {
return {
creating: wu_thank_you.creating,
next_queue: parseInt(wu_thank_you.next_queue, 10) + 5,
random: 0,
progress_in_seconds: 0
};
},
computed: {
progress() {
return Math.round(this.progress_in_seconds / this.next_queue * 100);
}
},
mounted() {
if (wu_thank_you.has_pending_site) {
this.check_site_created();
return;
}
if (this.next_queue <= 0 || wu_thank_you.creating) {
return;
}
const interval_seconds = setInterval(() => {
this.progress_in_seconds++;
if (this.progress_in_seconds >= this.next_queue) {
clearInterval(interval_seconds);
window.location.reload();
}
if (this.progress_in_seconds % 5 === 0) {
fetch("/wp-cron.php?doing_wp_cron");
}
}, 1e3);
},
methods: {
async check_site_created() {
const url = new URL(wu_thank_you.ajaxurl);
url.searchParams.set("action", "wu_check_pending_site_created");
url.searchParams.set("membership_hash", wu_thank_you.membership_hash);
const response = await fetch(url).then((request) => request.json());
if (response.publish_status === "completed") {
window.location.reload();
} else {
this.creating = response.publish_status === "running";
setTimeout(this.check_site_created, 3e3);
}
}
}
}));
});
})()

1
assets/js/thank-you.min.js vendored Normal file
View File

@ -0,0 +1 @@
(()=>{"use strict";const e=(e,t=!1)=>({classes:[],has_icon:!1,original_value:e.innerHTML,get_icon(){return this.has_icon?'<span class="wu-spin wu-inline-block wu-mr-2"><span class="dashicons-wu-loader"></span></span>':""},clear_classes(){e.classList.remove(...this.classes)},add_classes(t){this.classes=t,e.classList.add(...t)},text(t,s,n=!1){return this.clear_classes(),n&&(this.has_icon=!this.has_icon),e.animate([{opacity:"1"},{opacity:"0.75"}],{duration:300,iterations:1}),setTimeout((()=>{this.add_classes(s??[]),e.innerHTML=this.get_icon()+t,e.style.opacity="0.75"}),300),this},done(t=5e3){return setTimeout((()=>{e.animate([{opacity:"0.75"},{opacity:"1"}],{duration:300,iterations:1}),setTimeout((()=>{this.clear_classes(),e.innerHTML=this.original_value,e.style.opacity="1"}),300)}),t),this}});document.addEventListener("DOMContentLoaded",(()=>{if(document.querySelectorAll(".wu-resend-verification-email").forEach((t=>t.addEventListener("click",(async s=>{s.preventDefault();const n=e(t,!0).text(wu_thank_you.i18n.resending_verification_email,["wu-text-gray-400"]),i=await fetch(wu_thank_you.ajaxurl,{method:"POST",body:JSON.stringify({action:"wu_resend_verification_email",_ajax_nonce:wu_thank_you.resend_verification_email_nonce})}),a=await i.json();a.success?n.text(wu_thank_you.i18n.email_sent,["wu-text-green-700"],!0).done():n.text(a.data[0].message,["wu-text-red-600"],!0).done()})))),!document.getElementById("wu-sites"))return;const{Vue:t,defineComponent:s}=window.wu_vue;window.wu_sites=new t(s({el:"#wu-sites",data:()=>({creating:wu_thank_you.creating,next_queue:parseInt(wu_thank_you.next_queue,10)+5,random:0,progress_in_seconds:0}),computed:{progress(){return Math.round(this.progress_in_seconds/this.next_queue*100)}},mounted(){if(wu_thank_you.has_pending_site)return void this.check_site_created();if(this.next_queue<=0||wu_thank_you.creating)return;const e=setInterval((()=>{this.progress_in_seconds++,this.progress_in_seconds>=this.next_queue&&(clearInterval(e),window.location.reload()),this.progress_in_seconds%5==0&&fetch("/wp-cron.php?doing_wp_cron")}),1e3)},methods:{async check_site_created(){const e=new URL(wu_thank_you.ajaxurl);e.searchParams.set("action","wu_check_pending_site_created"),e.searchParams.set("membership_hash",wu_thank_you.membership_hash);const t=await fetch(e).then((e=>e.json()));"completed"===t.publish_status?window.location.reload():(this.creating="running"===t.publish_status,setTimeout(this.check_site_created,3e3))}}}))}))})();

100
assets/js/tours.js Normal file
View File

@ -0,0 +1,100 @@
/* global Shepherd, _, wu_tours, ajaxurl, wu_tours_vars */
(function($) {
$(document).ready(function() {
_.each(wu_tours, function(tour, tour_id) {
window[tour_id] = new Shepherd.Tour({
useModalOverlay: true,
includeStyles: false,
styleVariables: {
arrowSize: 1.1,
},
defaultStepOptions: {
classes: 'wu-p-2 wu-bg-white wu-shadow-sm wu-rounded wu-text-left wu-text-gray-700',
scrollTo: {
block: 'center',
behavior: 'smooth',
},
tippyOptions: {
zIndex: 999999,
onCreate(instance) {
instance.popper.classList.add('wu-styling');
const elements = instance.popperChildren.content.children[0].children[0].children;
if (elements[0].children[0]) {
elements[0].children[0].classList.add('wu-p-2', 'wu-pb-0', 'wu-m-0', 'wu--mb-1', 'wu-text-gray-800');
} // end if;
elements[1].classList.add('wu-p-2');
elements[2].classList.add('wu--mt-1', 'wu-p-2', 'wu-bg-gray-200', 'wu-rounded', 'wu-text-right');
},
},
},
});
window[tour_id].on('complete', function() {
$.ajax({
url: ajaxurl,
data: {
action: 'wu_mark_tour_as_finished',
tour_id,
nonce: wu_tours_vars.nonce,
},
});
});
_.each(tour, function(step, step_index) {
const last_step = (step_index + 1) === tour.length;
const action_url = function(url, target = '_blank') {
return () => {
window.open(url, target);
};
};
step.buttons = _.isArray(step.buttons) ? step.buttons : [];
step.buttons = _.map(step.buttons, function(item) {
item.action = action_url(item.url, item.target);
return item;
});
window[tour_id].addStep({
...step,
buttons: [
...step.buttons,
{
classes: 'button button-primary wu-text-xs sm:wu-normal-case',
text: last_step ? wu_tours_vars.i18n.finish : wu_tours_vars.i18n.next,
action: window[tour_id].next,
},
],
});
});
window[tour_id].start();
});
});
}(jQuery));

Some files were not shown because too many files have changed in this diff Show More