This commit is contained in:
2026-09-15 10:35:56 +08:00
commit 782f8ea7aa
4086 changed files with 631288 additions and 0 deletions
@@ -0,0 +1,58 @@
/**
* Mageplaza
*
* NOTICE OF LICENSE
*
* This source file is subject to the Mageplaza.com license that is
* available through the world-wide-web at this URL:
* https://www.mageplaza.com/LICENSE.txt
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this extension to newer
* version in the future.
*
* @category Mageplaza
* @package Mageplaza_Blog
* @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/)
* @license https://www.mageplaza.com/LICENSE.txt
*/
define([
'jquery'
], function ($) {
"use strict";
var parentCategory = $(".mp-blog-expand-tree-2");
var childCategory = $(".mp-blog-expand-tree-3");
parentCategory.click(function () {
if ($(this).hasClass("mp-blog-expand-tree-2")) {
$(this).parent().find(".category-level3").slideDown("fast");
$(this).removeClass("mp-blog-expand-tree-2 fa fa-plus-square-o")
.addClass("mp-blog-narrow-tree-2 fa fa-minus-square-o");
} else {
$(this).parent().find(".category-level4").slideUp("fast");
$(this).parent().find(".category-level3").slideUp("fast");
$(this).removeClass("mp-blog-narrow-tree-2 fa fa-minus-square-o")
.addClass("mp-blog-expand-tree-2 fa fa-plus-square-o");
$(this).parent().find(".mp-blog-narrow-tree-3")
.removeClass("mp-blog-narrow-tree-3 fa fa-minus-square-o")
.addClass("mp-blog-expand-tree-3 fa fa-plus-square-o");
}
});
childCategory.click(function () {
if ($(this).hasClass("mp-blog-expand-tree-3")) {
$(this).parent().find(".category-level4").slideDown("fast");
$(this).removeClass("mp-blog-expand-tree-3 fa fa-plus-square-o")
.addClass("mp-blog-narrow-tree-3 fa fa-minus-square-o");
} else {
$(this).parent().find(".category-level4").slideUp("fast");
$(this).removeClass("mp-blog-narrow-tree-3 fa fa-minus-square-o")
.addClass("mp-blog-expand-tree-3 fa fa-plus-square-o");
}
});
}
);
File diff suppressed because one or more lines are too long
+304
View File
@@ -0,0 +1,304 @@
/**
* Mageplaza
*
* NOTICE OF LICENSE
*
* This source file is subject to the Mageplaza.com license that is
* available through the world-wide-web at this URL:
* https://www.mageplaza.com/LICENSE.txt
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this extension to newer
* version in the future.
*
* @category Mageplaza
* @package Mageplaza_Blog
* @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/)
* @license https://www.mageplaza.com/LICENSE.txt
*/
require([
'jquery'
], function ($) {
'use strict';
var cmtBox = $('.default-cmt__content__cmt-block__cmt-box__cmt-input'),
submitCmt = $('.default-cmt__content__cmt-block__cmt-box__cmt-btn__btn-submit'),
defaultCmt = $('ul.default-cmt__content__cmt-content:first'),
likeBtn = defaultCmt.find('.btn-like'),
replyBtn = defaultCmt.find('.btn-reply');
submitComment();
likeComment(likeBtn);
showReply(replyBtn);
$('li.default-cmt__content__cmt-content__cmt-row:first').css({'border-top': 'none'});
$('.default-cmt__cmt-login__btn-login').click(function () {
var socialPopup = $("[href$='social-login-popup']");
if (socialPopup.length) {
socialPopup.first().trigger("click");
} else {
window.location.href = loginUrl;
}
});
/**
* Check the guest name and email input is valid
*
* @returns {boolean}
*/
function checkGuestFormValidate() {
if (isLogged == 'No') {
return $("#default-cmt__content__cmt-block__guest-form").valid();
}
return true;
}
/**
* The comment submit button action
*/
function submitComment() {
submitCmt.click(function () {
$(".default-cmt__content__cmt-block__cmt-box").find('.messages').hide();
if (checkGuestFormValidate()) {
var cmtText = cmtBox.val();
if (cmtText.trim().length) {
$('.default-cmt_loading').show();
$(this).prop('disabled', true);
var ajaxRequest = ajaxCommentActions(cmtText, submitCmt);
ajaxRequest.done(function () {
cmtBox.val('');
$('.default-cmt_loading').hide();
$(this).prop('disabled', false);
}.bind(this));
} else {
$('.default-cmt__content__cmt-block__cmt-box__cmt-input').parent().append(messengerBox.cmt_warning);
}
}
});
}
//like action
function likeComment(btn) {
btn.each(function () {
var likeEl = $(this);
likeEl.click(function () {
var cmtId = $(this).attr('data-cmt-id'),
cmtRowContainer = $(this).closest('.default-cmt__content__cmt-content__cmt-row');
if (isLogged === 'Yes') {
var likeCount = $(this).find('span').text();
if ($(this).attr('click') === '1') {
if ($(this).hasClass('mpblog-liked')) {
$(this).css('color', '#333333');
likeCount--;
$(this).find('span').text((likeCount === 0) ? "" : likeCount);
$(this).removeClass('mpblog-liked')
} else {
likeCount++;
$(this).find('span').text(likeCount);
$(this).css('color', likedColor);
$(this).addClass('mpblog-liked')
}
$.ajax({
type: "POST",
url: window.location.href,
data: {cmtId: cmtId},
success: function (response) {
if (response.status === 'ok') {
$(likeEl).attr('click', '1');
} else if (response.status === 'error' && response.hasOwnProperty(error)) {
defaultCmt.append(response.error);
}
}
});
}
$(this).attr('click', '0');
} else {
cmtRowContainer.append(messengerBox.login_warning);
jQuery.fn.fadeOutAndRemove = function (speed) {
$(this).fadeOut(speed, function () {
$(this).remove();
})
};
var removeNotification = function () {
$('.message.error.message-error').fadeOutAndRemove('normal');
};
setTimeout(removeNotification, 3000);
}
});
});
}
//show reply
function showReply(btn) {
btn.each(function () {
$(this).click(function () {
var cmtId = (typeof $(this).closest('.default-cmt__content__cmt-content__cmt-row').parent().parent().parent().parent().attr('data-cmt-id') !== 'undefined') ? $(this).closest('.default-cmt__content__cmt-content__cmt-row').parent().parent().attr('data-cmt-id') : $(this).attr('data-cmt-id'),
inputCmtID = $(this).attr('data-cmt-id'),
cmtRowCmt = $("div").find('#cmt-row');
var cmtRowContainer = $(this).closest('.default-cmt__content__cmt-content__cmt-row');
if ($("li.cmt-row-" + cmtId).find("ul").length) {
var cmtRowContainer = $("#cmt-id-" + cmtId + " ul:last-child");
}
var cmtRow = cmtRowContainer.find('.row__' + inputCmtID);
var cmtName = $(".username__" + inputCmtID).text();
if (isLogged === 'Yes') {
if (cmtRowCmt.length) {
cmtRowCmt.toggle();
$("#cmt-row").remove();
}
if (cmtRow.length) {
cmtRow.toggle();
$("#cmt-row").remove();
} else {
cmtRowContainer.append('<div id="cmt-row" class="cmt-row__reply-row row row__' + inputCmtID + ' col-md-12">' +
'<div class="reply-form__form-input form-group col-xs-8 col-md-6">' +
'<label for="reply_cmt' + inputCmtID + '"></label>' +
'<input type="text" id="reply_cmt' + inputCmtID + '" class="form-group__input form-control" placeholder="Press enter to submit reply" value="' + cmtName + ' " autofocus onfocus="this.setSelectionRange(1000,1001);"/>' +
'</div>' +
'</div>');
var input = $('#reply_cmt' + inputCmtID);
input.closest('.form-group').append(
$('.default-cmt__content__cmt-block__cmt-box__cmt-btn .default-cmt_loading').clone()
);
input.focus();
submitReply(input, cmtId, cmtRowContainer);
}
} else {
cmtRowContainer.append(messengerBox.login_warning);
jQuery.fn.fadeOutAndRemove = function (speed) {
$(this).fadeOut(speed, function () {
$(this).remove();
})
};
var removeNotification = function () {
$('.message.error.message-error').fadeOutAndRemove('normal');
};
setTimeout(removeNotification, 3000);
}
});
});
}
//submit reply
function submitReply(input, replyId, parentComment) {
input.keypress(function (e) {
var text = input.val();
if (text !== '') {
if (e.keyCode === 13) {
input.siblings('.default-cmt_loading').show();
input.prop('disabled', true);
var ajaxRequest = ajaxCommentActions(text, input, true, replyId, parentComment);
ajaxRequest.done(function () {
input.closest('.cmt-row__reply-row').hide();
input.siblings('.default-cmt_loading').hide();
input.prop('disabled', false);
$("#cmt-row").remove();
});
}
}
});
}
//submit comment actions
function ajaxCommentActions(cmtText, inputEl, checkReply, cmtId, parentComment) {
var isReply = (typeof checkReply !== 'undefined') ? 1 : 0,
replyId = (typeof cmtId !== 'undefined') ? cmtId : 0,
displayReply = (typeof checkReply !== 'undefined');
var guestName = $('#default-cmt__content__cmt-block__guest-box__name-input').val();
var guestEmail = $('#default-cmt__content__cmt-block__guest-box__email-input').val();
return $.ajax({
type: 'POST',
url: window.location.href,
// async: false,
data: {cmt_text: cmtText, isReply: isReply, replyId: replyId, guestName: guestName, guestEmail: guestEmail},
success: function (response) {
switch (response.status) {
case 'duplicated':
$('.default-cmt__content__cmt-block__cmt-box__cmt-input').parent().append(messengerBox.exist_email_warning);
break;
case 3:
$('.default-cmt__content__cmt-block').prepend(messengerBox.comment_approve);
break;
case 1:
displayComment(response, displayReply);
var cmtCount = defaultCmt.find('li').length;
$('.mp-cmt-count').text(cmtCount);
inputEl.val('');
break;
case 'error':
if (checkReply !== 'undefined') {
parentComment.append(response.error);
} else {
defaultCmt.append(response.error);
}
break;
}
}
});
}
// display comment
function displayComment(cmt, isReply) {
function htmlComment(text) {
var html = '';
var sub = text.split("\n");
for (var i = 0; i < sub.length; i++) {
html += '<p>' + sub[i] + '</p>';
}
return html;
}
var cmtRow = '<li style="width: 100%" id="cmt-id-' + cmt.cmt_id + '" class="default-cmt__content__cmt-content__cmt-row cmt-row-' + cmt.cmt_id + ' cmt-row col-m-12 '
+ (isReply ? ('reply-row') : '') + '" data-cmt-id="' + cmt.cmt_id + '"' + (isReply ? ('data-reply-id="' + cmt.reply_cmt + '"') : '')
+ '> <div class="cmt-row__cmt-username"> <span class="cmt-row__cmt-username username username__' + cmt.cmt_id + '">' + cmt.user_cmt
+ '</span> </div> <div class="cmt-row__cmt-content"> <p>' + htmlComment(cmt.cmt_text)
+ '</p> </div> <div class="cmt-row__cmt-interactions interactions"> <div class="interactions__btn-actions"> <a class="interactions__btn-actions action btn-like mpblog-like" data-cmt-id="'
+ cmt.cmt_id + '" click="1"><i class="fa fa-thumbs-up" aria-hidden="true" style="margin-right: 3px"></i><span class="count-like__like-text"></span></a> <a class="interactions__btn-actions action btn-reply" data-cmt-id="'
+ cmt.cmt_id + '">' + reply + '</a> </div> <div class="interactions__cmt-createdat"> <span>' + cmt.created_at + '</span> </div> </div> </li>';
if (isReply) {
var replyCmtId = cmt.reply_cmt;
var replyCmt = defaultCmt.find('.default-cmt__content__cmt-content__cmt-row');
replyCmt.each(function () {
var cmtEl = $(this);
if (cmtEl.attr('data-cmt-id') === replyCmtId) {
var replyList = cmtEl.find('ul.default-cmt__content__cmt-content:first');
if (!replyList.length) {
cmtRow = $('<ul class="default-cmt__content__cmt-content row">' + cmtRow + '</ul>');
cmtEl.append(cmtRow);
likeComment(cmtRow.find('.btn-like'));
showReply(cmtRow.find('.btn-reply'));
} else {
cmtRow = $(cmtRow);
replyList.append(cmtRow);
likeComment(cmtRow.find('.btn-like'));
showReply(cmtRow.find('.btn-reply'));
}
return false;
}
});
} else {
cmtRow = $(cmtRow);
defaultCmt.append(cmtRow);
likeComment(cmtRow.find('.btn-like'));
showReply(cmtRow.find('.btn-reply'));
}
}
});
+90
View File
@@ -0,0 +1,90 @@
/**
* Mageplaza
*
* NOTICE OF LICENSE
*
* This source file is subject to the Mageplaza.com license that is
* available through the world-wide-web at this URL:
* https://www.mageplaza.com/LICENSE.txt
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this extension to newer
* version in the future.
*
* @category Mageplaza
* @package Mageplaza_Blog
* @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/)
* @license https://www.mageplaza.com/LICENSE.txt
*/
define([
'jquery',
"mage/adminhtml/events",
"mage/adminhtml/wysiwyg/tiny_mce/setup"
], function ($) {
'use strict';
return {
config: function (nameEL, versionEditor, versionMagento, width) {
var wysiwygcompany_description,
config = {},
editor;
if (typeof width === 'undefined') {
width = '99%';
}
if (versionMagento === "2") {
$.extend(config, {
settings: {
theme_advanced_buttons1: 'bold,italic,|,justifyleft,justifycenter,justifyright,|,' +
'fontselect,fontsizeselect,|,forecolor,backcolor,|,link,unlink,image,|,' +
'bullist,numlist,|,code',
theme_advanced_buttons2: null,
theme_advanced_buttons3: null,
theme_advanced_buttons4: null
}
});
editor = new tinyMceWysiwygSetup(
nameEL,
config
);
editor.turnOn();
$('#' + nameEL).addClass('wysiwyg-editor').data('wysiwygEditor', editor);
} else if (versionEditor === "4") {
wysiwygcompany_description = new wysiwygSetup(nameEL, {
"width": width,
"height": "200px",
"plugins": [{"name": "image"}],
"tinymce4": {
"toolbar": "formatselect | bold italic underline | alignleft aligncenter alignright |" +
" bullist numlist | link table charmap",
"plugins": "advlist autolink lists link charmap media noneditable" +
" table contextmenu paste code help table"
}
});
wysiwygcompany_description.setup("exact");
} else {
$.extend(config, {
settings: {
theme_advanced_buttons1: 'bold,italic,|,justifyleft,justifycenter,justifyright,|,' +
'fontselect,fontsizeselect,|,forecolor,backcolor,|,link,unlink,image,|,' +
'bullist,numlist,|,code',
theme_advanced_buttons2: null,
theme_advanced_buttons3: null,
theme_advanced_buttons4: null
},
tinymce : {
content_css : null
}
});
editor = new wysiwygSetup(
nameEL,
config
);
editor.setup("exact");
$('#' + nameEL).addClass('wysiwyg-editor').data('wysiwygEditor', editor);
}
}
};
});
@@ -0,0 +1,193 @@
/**
* Mageplaza
*
* NOTICE OF LICENSE
*
* This source file is subject to the Mageplaza.com license that is
* available through the world-wide-web at this URL:
* https://www.mageplaza.com/LICENSE.txt
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this extension to newer
* version in the future.
*
* @category Mageplaza
* @package Mageplaza_Blog
* @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/)
* @license https://www.mageplaza.com/LICENSE.txt
*/
define([
'jquery'
], function ($) {
'use strict';
$.widget('mageplaza.mpBlogHelpfulRate', {
options: {
url: '',
post_id: '',
mode: ''
},
_create: function () {
var post_id = this.options.post_id,
url = this.options.url,
self = this,
subPostId = {};
if (self.options.mode === 1) {
$.ajax({
url: url,
type: "post",
data: {
post_id: post_id,
action: '3',
mode: self.options.mode
},
showLoader: false,
success: function (response) {
if (response.status === 0) {
self.disableReview(response.action);
}
}
});
} else if (JSON.parse(self.getCookie('mpblog_post_data'))) {
subPostId = JSON.parse(self.getCookie('mpblog_post_data'));
if (typeof subPostId[post_id] !== "undefined") {
self.disableReview(subPostId[post_id].type);
}
}
$('#mp-blog-review div').each(function () {
var el = this;
$(el).on('click', function () {
var action = 0,
currentPostIds = {},
likeId = 0;
if (JSON.parse(self.getCookie('mpblog_post_data'))) {
currentPostIds = JSON.parse(self.getCookie('mpblog_post_data'));
}
if ($(this).hasClass('mp-blog-like')) {
action = 1;
}
if (typeof currentPostIds[post_id] !== "undefined" && self.options.mode === 0) {
likeId = currentPostIds[post_id].likeId;
self.enableReview(currentPostIds[post_id].type);
if (action === currentPostIds[post_id].type) {
delete currentPostIds[post_id];
document.cookie = 'mpblog_post_data = ' + JSON.stringify(currentPostIds);
} else {
currentPostIds[post_id].type = action;
self.disableReview(action);
}
}
$.ajax({
url: url,
type: "post",
data: {
post_id: post_id,
action: action,
mode: self.options.mode,
likeId: likeId
},
showLoader: true,
success: function (response) {
var storedPostIds,
jsonStringIds;
if (response['postLike']
&& self.options.mode === 0 && typeof currentPostIds[post_id] === "undefined") {
storedPostIds =
self.receiveCookiePostIds(post_id, action, response['postLike'], self);
jsonStringIds = JSON.stringify(storedPostIds);
document.cookie = 'mpblog_post_data = ' + jsonStringIds;
}
if (response['status']) {
if (response["sumLike"]) {
$('#mp-blog-review .mp-blog-like .mp-blog-view')
.text('(' + response["sumLike"] + ')');
} else {
$('#mp-blog-review .mp-blog-like .mp-blog-view')
.text('');
}
if (response["sumDislike"]) {
$('#mp-blog-review .mp-blog-dislike .mp-blog-view')
.text('(' + response["sumDislike"] + ')');
} else {
$('#mp-blog-review .mp-blog-dislike .mp-blog-view')
.text('');
}
}
if (response['status']) {
self.enableAllReview();
if (response['postLike']) {
self.disableReview(action);
}
}
$('html, body').animate({
scrollTop: $('body').offset().top
}, 500);
}
});
});
});
},
disableReview: function (action) {
if ('' + action === '1') {
$('.mp-blog-like').css('background-color', '#658259');
} else {
$('.mp-blog-dislike').css('background-color', '#9a6464');
}
},
enableReview: function (action) {
if ('' + action === '1') {
$('.mp-blog-like').css('background-color', '#6AA84F');
} else {
$('.mp-blog-dislike').css('background-color', '#EC3A3C');
}
},
enableAllReview: function () {
$('.mp-blog-like').css('background-color', '#6AA84F');
$('.mp-blog-dislike').css('background-color', '#EC3A3C');
},
getCookie: function (name) {
var v = document.cookie.match('(^|;) ?' + name + '=([^;]*)(;|$)');
return v ? v[2] : null;
},
receiveCookiePostIds: function (postId, action, likeId, self) {
var postData = {
id: postId,
type: action,
likeId: likeId
},
receivedJsonStr = self.getCookie('mpblog_post_data'),
postIds = JSON.parse(receivedJsonStr);
if (postIds == null) {
postIds = {};
}
if (typeof postIds[postId] !== "undefined") {
return postIds;
}
postIds[postId] = postData;
return postIds;
}
}
);
return $.mageplaza.mpBlogHelpfulRate;
});
+204
View File
@@ -0,0 +1,204 @@
/**
* Mageplaza
*
* NOTICE OF LICENSE
*
* This source file is subject to the Mageplaza.com license that is
* available through the world-wide-web at this URL:
* https://www.mageplaza.com/LICENSE.txt
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this extension to newer
* version in the future.
*
* @category Mageplaza
* @package Mageplaza_Blog
* @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/)
* @license https://www.mageplaza.com/LICENSE.txt
*/
define([
'jquery',
'mage/translate',
'underscore',
'Magento_Ui/js/modal/modal',
'uiRegistry',
'moment',
"Mageplaza_Blog/js/get-editor"
], function ($, $t, _, modal, registry, moment, editor) {
'use strict';
$.widget('mageplaza.mpBlogManagePost', {
options: {
deleteUrl: '',
basePubUrl: '',
postDatas: {},
editorVersion: '',
magentoVersion: ''
},
_create: function () {
var self = this,
htmlPopup = $('#mp-blog-new-post-popup');
$('.mp-blog-new-post button').on('click', function () {
self._AddNewPost(self, htmlPopup);
});
$('.mpblog-post-edit').on('click', function () {
self._EditPost(self, this, htmlPopup);
});
$('.mpblog-post-duplicate').on('click', function () {
self._DuplicatePost(self, this, htmlPopup);
});
$('.mpblog-post-delete').on('click', function () {
self._DeletePost(self, this);
});
},
_AddNewPost: function (self, htmlPopup) {
var options = {
'type': 'popup',
'title': $t('Add New Post'),
'responsive': true,
'innerScroll': true,
'buttons': []
};
self._resetForm('');
self._openPopup(options, htmlPopup, self);
},
_resetForm: function (postContent) {
var iframe = document.getElementById('post_content_ifr');
$('#mp_blog_post_form').trigger("reset");
$('#short_description').empty();
$('#post_content').empty();
$('#post_id').removeAttr('value');
if (iframe){
iframe.contentWindow.document.open();
iframe.contentWindow.document.write(postContent);
iframe.contentWindow.document.close();
}
$('.mp-field .mp-image-link').remove();
registry.get('customCategory').value('');
registry.get('customTag').value('');
registry.get('customTopic').value('');
},
_EditPost: function (self, click, htmlPopup) {
var postId = $(click).parent().data('postid'),
postData = self.options.postDatas[postId],
pubUrl = self.options.basePubUrl,
options = {
'type': 'popup',
'title': $t('Edit Post'),
'responsive': true,
'innerScroll': true,
'buttons': []
};
if (htmlPopup.find('#mp_blog_post_form [name="name"]').length > 0) {
self._resetForm(postData['post_content']);
}
self._openPopup(options, htmlPopup, self);
self._setPopupFormData(postData, pubUrl, htmlPopup);
},
_setPopupFormData: function(postData, pubUrl, htmlPopup){
_.each(postData, function (value, name) {
var field = htmlPopup.find('#mp_blog_post_form [name="' + name + '"]'),
imageEL,
deleteEL,
date;
if (field.is('[type="file"]') && value) {
imageEL = '<a class="mp-image-link" href="' + pubUrl + 'mageplaza/blog/post/' + value
+ '" onclick="imagePreview(\'post_image_image\'); return false;" >' +
'<img src="' + pubUrl + 'mageplaza/blog/post/' + value + '" id="post_image_image"' +
' title="' + value + '" alt="' + value + '" height="22" width="22"' +
' class="small-image-preview v-middle">' +
'</a>';
field.parent().prepend(imageEL);
deleteEL = '<span class="delete-image">'
+ '<input style="width: 8%" type="checkbox" name="image[delete]"'
+ ' value="1" class="checkbox" id="post_image_delete">'
+ '<label for="post_image_delete"> Delete Image</label>'
+ '</span>';
if (!field.parent().find('.delete-image').lenth) {
field.parent().append(deleteEL);
}
} else if (field.is('[type="datetime-local"]')) {
date = moment(value).format("YYYY-MM-DDTkk:mm");
field.val(date);
} else if (field.is('input') || field.is('select')) {
field.val(value);
} else if (field.is('textarea')) {
field.html(value);
}
if (name === 'category_ids') {
registry.get('customCategory').value(value);
}
if (name === 'tag_ids') {
registry.get('customTag').value(value);
}
if (name === 'topic_ids') {
registry.get('customTopic').value(value);
}
});
},
_DuplicatePost: function (self, click, htmlPopup) {
var postId = $(click).parent().data('postid'),
postData = self.options.postDatas[postId],
pubUrl = self.options.basePubUrl,
options = {
'type': 'popup',
'title': $t('Duplicate Post'),
'responsive': true,
'innerScroll': true,
'buttons': []
};
if (htmlPopup.find('#mp_blog_post_form [name="name"]').length > 0) {
self._resetForm(postData['post_content']);
}
self._openPopup(options, htmlPopup, self);
self._setPopupFormData(postData, pubUrl, htmlPopup);
$('#post_id').removeAttr('value');
$('#image').parent().append('<input type="hidden" name="image" value="'+postData["image"]+'" />');
},
_DeletePost: function (self, widget) {
var url = self.options.deleteUrl,
id = $(widget).parent().data('postid');
$.ajax({
url: url,
type: "post",
data: {
post_id: id
},
showLoader: true,
success: function (result) {
if (result['status'] === 1){
$('.post-list-item[data-post-id="'+result['post_id']+'"]').remove();
}
},
complete: function () {
}
});
},
_openPopup: function (options, htmlPopup, self) {
var popupModal,
editorVersion = self.options.editorVersion,
magentoVersion = self.options.magentoVersion;
popupModal = modal(options, htmlPopup);
popupModal.openModal();
$('#mp_blog_post_form').trigger('contentUpdated');
editor.config('post_content', editorVersion, magentoVersion);
}
}
);
return $.mageplaza.mpBlogManagePost;
});
+63
View File
@@ -0,0 +1,63 @@
/**
* Mageplaza
*
* NOTICE OF LICENSE
*
* This source file is subject to the Mageplaza.com license that is
* available through the world-wide-web at this URL:
* https://www.mageplaza.com/LICENSE.txt
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this extension to newer
* version in the future.
*
* @category Mageplaza
* @package Mageplaza_Blog
* @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/)
* @license https://www.mageplaza.com/LICENSE.txt
*/
define([
'jquery',
"mage/adminhtml/events",
"mage/adminhtml/wysiwyg/tiny_mce/setup"
], function ($) {
'use strict';
$.widget('mageplaza.mpBlogPostAction', {
options: {},
_create: function () {
var self = this;
$('button.mpblog-action-new').on('click', function () {
self._AddNew();
});
},
_AddNew: function () {
var form = $('#mp_blog_post_form'),
formData = new FormData(form[0]),
htmlPopup = $('#mp-blog-new-post-popup'),
url = form.attr('action');
$.ajax({
url: url,
type: "post",
data: formData,
cache: false,
contentType: false,
processData: false,
showLoader: true,
success: function (result) {
htmlPopup.data('mageModal').closeModal();
if (result.status === 1) {
setTimeout(function () {
location.reload();
}, 500);
}
}
});
}
}
);
return $.mageplaza.mpBlogPostAction;
});
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long