Skip to content

Commit

Permalink
Merge branch 'asif-dev' into priyo-dev
Browse files Browse the repository at this point in the history
  • Loading branch information
priyomukul committed Aug 29, 2021
2 parents 24047df + b9da40b commit a5848c7
Show file tree
Hide file tree
Showing 6 changed files with 482 additions and 9 deletions.
Binary file added assets/images/wpsp-el-editor-modal-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
91 changes: 91 additions & 0 deletions assets/js/elementor-editor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
(function ($) {
var wpsp_menu = $('#elementor-panel-footer-sub-menu-item-wpsp'),
modal = $('#schedulepress-elementor-modal'),
wpsp_quick_button = $('#elementor-panel-footer-wpsp-modal'),
wpsp_submit_button = $('.wpsp-el-form-submit'),
wpsp_submit_button_text = $('span:nth-child(2)', wpsp_submit_button),
label_schedule = wpsp_submit_button.data('label-schedule'),
label_publish = wpsp_submit_button.data('label-publish'),
label_update = wpsp_submit_button.data('label-update'),
wpsp_date;

$(window).on('load', function () {
$('.elementor-panel-footer-sub-menu-wrapper .elementor-panel-footer-sub-menu').append(wpsp_menu);
wpsp_quick_button.insertAfter('#elementor-panel-footer-saver-preview');
wpsp_date = flatpickr("#wpsp-schedule-datetime", {
enableTime: true,
dateFormat: "Y-m-d H:i:S",
altInput: true,
altFormat: "F j, Y h:i K",
appendTo: window.document.querySelector('.wpsp-el-modal-date-picker'),
onChange: function(selectedDates, dateStr, instance) {
var current_time = new Date(),
selected_time = new Date(dateStr);

if (current_time.getTime() < selected_time.getTime()) {
wpsp_submit_button_text.text(label_schedule)
} else {
wpsp_submit_button_text.text(label_publish)
}
}
});

if ($('.wpsp-pro-fields.wpsp-pro-activated label input').length) {
flatpickr(".wpsp-pro-fields.wpsp-pro-activated label input", {
enableTime: true,
dateFormat: "Y/m/d H:i",
altInput: true,
altFormat: "F j, Y h:i K",
appendTo: window.document.querySelector('.wpsp-el-modal-date-picker'),
});
}
});

$(document).on('click', '#elementor-panel-footer-sub-menu-item-wpsp, #elementor-panel-footer-wpsp-modal', function (e) {
e.preventDefault();
modal.fadeIn();
}).on('click', '.elementor-templates-modal__header__close > svg, .elementor-templates-modal__header__close > svg *, #schedulepress-elementor-modal', function (e) {
e.preventDefault();
if (e.target === this) {
modal.fadeOut();
}
}).on('click', '.wpsp-immediately-publish', function (e) {
e.preventDefault();
wpsp_date.clear();
wpsp_submit_button_text.text(label_publish);
$(this).addClass('active');
wpsp_submit_button_text.trigger('click');
}).on('click', 'button.wpsp-el-form-submit', function (e) {
e.preventDefault();
var $form = modal.find('form'),
url = $form.attr('action'),
data = $form.serialize(),
wpsp_el_result = $(".wpsp-el-result");

$('#elementor-panel-saver-button-publish').trigger('click');

wpsp_submit_button.addClass('elementor-button-state');
$.post(url, data, function (data) {
wpsp_el_result.html(data.data.msg).slideDown();

if (data.success) {
var immediately_btn = $('.wpsp-immediately-publish');
wpsp_submit_button.removeClass('elementor-button-state');
wpsp_el_result.addClass('wpsp-msg-success');
wpsp_date.setDate(data.data.post_time);

if (data.data.status === 'future') {
immediately_btn.show();
wpsp_submit_button_text.text(label_schedule);
} else {
immediately_btn.hide().removeClass('active');
wpsp_submit_button_text.text(label_update);
}
}

setTimeout(function () {
wpsp_el_result.slideUp().html('').removeClass('wpsp-msg-success');
}, 3000);
});
});
})(jQuery);
Loading

0 comments on commit a5848c7

Please sign in to comment.