Skip to content

Commit

Permalink
Update V4.8
Browse files Browse the repository at this point in the history
  • Loading branch information
poojabhimani12 committed Dec 4, 2024
1 parent 5cb5346 commit cd8a3da
Show file tree
Hide file tree
Showing 8 changed files with 142 additions and 94 deletions.
113 changes: 46 additions & 67 deletions admin/assets/js/commenting-block-admin-functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -529,11 +529,7 @@ function showNoticeBoardonNewComments() {
}
setTimeout(function () {
if (noticeboard !== null) {
// if( noticeboard.innerHTML === "" ){
// noticeboard.setAttribute('style','display:none');
// } else {
// noticeboard.setAttribute('style','display:block');
// }

}

}, 300);
Expand Down Expand Up @@ -1041,6 +1037,7 @@ function cfgetCustomAttributeId(selectedText) {
const wrapper = document.querySelector('#cf-comment-board-wrapper');
const focusBoard = wrapper.querySelector('.cls-board-outer.focus');
const elid = focusBoard ? focusBoard.getAttribute('id') : null;
const commentEditFocus = focusBoard?.querySelector('.js-cf-edit-comment.comment-focus');

setTimeout(function () {

Expand Down Expand Up @@ -1138,18 +1135,16 @@ function cfgetCustomAttributeId(selectedText) {
}
}
});

scrollBoardToPosition(topOfTextSingleBoardSuggestion);
if(commentEditFocus){
scrollBoardToPosition(topOfTextSingleBoardSuggestion);
}
}
} else if (focusBoard) {
let topOfText;
if (elid && elid.match(/^el/m) !== null) {
//topOfText = document.querySelector('[datatext="' + elid + '"]').offsetTop;
topOfText = jQuery('[datatext="' + elid + '"]').offset()?.top;
} else {
// const sid = document.getElementById(elid)?.getAttribute('data-sid');
// //topOfText = document.querySelector('[id="' + sid + '"]')?.offsetTop;
// topOfText = document.getElementById( elid )?.offsetTop;
const sid = jQuery('#' + elid).attr('data-sid');
topOfText = jQuery('[id="' + sid + '"]').offset()?.top;

Expand All @@ -1162,7 +1157,10 @@ function cfgetCustomAttributeId(selectedText) {
// const focusBoardElement = document.querySelector('#cf-comment-board-wrapper').querySelector('.cls-board-outer.focus');
// focusBoardElement.style.top = topOfText + 'px';
jQuery('#cf-span__comments').find('.cls-board-outer.focus').offset({ top: topOfText });
scrollBoardToPosition(topOfText);

if(commentEditFocus){
scrollBoardToPosition(topOfText);
}
}
}, 800);
}
Expand All @@ -1180,22 +1178,26 @@ function cfgetCustomAttributeId(selectedText) {
}

// Function to handle layout changes
function handleEditorLayoutChange() {
function handleEditorLayoutChange( fromIconClick = false ) {

var $ = jQuery;

const notCommentOncls = document.querySelector(".multicollab_body_class");
var checkCommntAval = !notCommentOncls?.classList?.contains('commentOn');
const ediLayot = document.querySelector(".editor-styles-wrapper");
const cmntLayout = document.querySelector("#cf-comments-suggestions-parent");
const ediLayotWidth = ediLayot?.offsetWidth;
const cmntLyotWidth = cmntLayout?.offsetWidth;
const calcLyotWidth = ediLayotWidth - cmntLyotWidth;
let calcLyotWidth = ediLayotWidth - cmntLyotWidth;
const editSidebarchck = document.querySelector(".edit-post-layout");
const blockinsertchck = document.querySelector(".interface-interface-skeleton__body");
const firstChild = blockinsertchck?.firstElementChild;

const checkVisualedit = wp.data.select("core/edit-post").getEditorMode();
const $boardOuter = document.querySelector( '#cf-comment-board-wrapper .cls-board-outer' );
const calcAuto = "auto";

const prevSidebarOpen = document.querySelector('.editor-sidebar');

if (!checkCommntAval) {
if (editSidebarchck?.classList?.contains('is-sidebar-opened') || firstChild) {
mdboardOffset();
Expand All @@ -1204,60 +1206,37 @@ function cfgetCustomAttributeId(selectedText) {
} else {
setContainerDimensions("auto", `${calcLyotWidth}px`);
}

setTimeout(() => {
var editorSidebar = document.querySelector('.editor-sidebar');
const wrapper = document.querySelector('#cf-comment-board-wrapper');
const focusBoard = wrapper.querySelector('.cls-board-outer.focus');
if( null !== editorSidebar && null !== focusBoard ) {
calcLyotWidth = calcLyotWidth - editorSidebar?.offsetWidth;
}

const editSidebar = wp.data.select("core/edit-post").isEditorSidebarOpened();
if (checkVisualedit === "visual") {
if (editSidebar === false) {
setContainerDimensions(`${calcLyotWidth}px`, "unset");
} else {
jQuery(".is-root-container").width(calcAuto);
if( fromIconClick ) {

setTimeout(function () {
const notCommentOncls = document.querySelector(".multicollab_body_class");
const $boardOuter = $("#cf-comment-board-wrapper .cls-board-outer");
const $hideCheckBox = $(".comment-toggle .is-checked");
const $SuggestionCheckBox = $(".suggestion-toggle .is-checked");
const ediLayot = document.querySelector(".editor-styles-wrapper");
const cmntLayout = document.querySelector("#cf-comments-suggestions-parent");
const ediLayotWidth = ediLayot?.offsetWidth;
const cmntLyotWidth = cmntLayout?.offsetWidth;
const calcLyotWidth = ediLayotWidth - cmntLyotWidth;
const calcAuto = "auto";
const editSidebarchck = wp.data.select("core/edit-post").isEditorSidebarOpened();
const checkVisualedit = wp.data.select("core/edit-post").getEditorMode();

if (checkVisualedit === "visual") {
if ($boardOuter.length >= 1 && ($hideCheckBox.length !== 1 || $SuggestionCheckBox.length !== 1) && editSidebarchck === true) {
setContainerDimensions(`${calcLyotWidth}px`, "unset");
} else if (!notCommentOncls?.classList?.contains('commentOn') && ($hideCheckBox.length == 0 || $SuggestionCheckBox.length == 0)) {
setTimeout(function () {
setContainerDimensions("auto", `${calcLyotWidth}px`);
}, 100);
} else if (editSidebarchck === false || ($hideCheckBox.length == 0 || $SuggestionCheckBox.length == 0)) {
setContainerDimensions(`${calcLyotWidth}px`, "unset");
} else {
jQuery(".is-root-container").width(calcAuto);
}
}
}
}, 200);

}, 500);
}

}

// Function to load more users
// function loadMoreUsers( loadingUser, post_id, selectedUsers ) {
// var $ = jQuery;
// let page = 1; // Starting page
// const ulElement = $('#select2-guest-email-results');
// console.log('loading more users', page);

// if( ! loadingUser ) {
// return;
// }

// $.ajax({
// url: '/wp-admin/admin-ajax.php', // Adjust as necessary for your setup
// type: 'POST',
// data: {
// action: 'cf_load_more_users', // Your AJAX action
// page: page,
// post_id: post_id,
// selectedUsers: selectedUsers
// },
// success: function(response) {
// if (response) {
// ulElement.append(response); // Append the new user entries
// page++; // Increment the page number for next request
// loadingUser = false;
// }

// // else {
// // // No more users to load
// // $(window).off('scroll', onScroll);
// // }
// }
// });
// }

102 changes: 80 additions & 22 deletions admin/assets/js/commenting-block-admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,60 @@ window.process = {
}

setTimeout(function () {
scrollBoardToPosition(topOfText);
_this.offset({ top: topOfText });
if (!target.is(".btn-delete")){
scrollBoardToPosition(topOfText);
}
_this.offset({ top: topOfText });
}, 800);

$('[data-rich-text-format-boundary="true"]').removeAttr('data-rich-text-format-boundary');
$('[datatext="' + selectedText + '"]').attr('data-rich-text-format-boundary', true);

if ($(`#${selectedText}`).hasClass('sg-board')) {
let sid = $(`#${selectedText}`).attr('data-sid');
$(`#${sid}`).attr('data-rich-text-format-boundary', 'true');
}
$('[datatext="' + selectedText + '"]').attr('data-rich-text-format-boundary', true);

});

//Set board top offset from activity center @author: Minal Diwan @since-3.4
$(document).on('click', '.user-commented-on,.cf-activity-centre .user-action a', function (e) {
var elID = e.target.dataset.elid;
if (elID) {
elID = elID.replace('cf-', '');
$(`#${elID}`).trigger('click');
setTimeout(function () {
let topOfText;
if (elID.match(/^el/m) !== null) {
topOfText = $('[datatext="' + elID + '"]').offset().top;
} else {
let sid = $('#' + elID).attr('data-sid');
topOfText = $('[id="' + sid + '"]').offset()?.top;
if (!topOfText) {
topOfText = $('[suggestion_id="' + sid + '"]').offset()?.top;
}
$('#' + sid).addClass('sg-format-class');

}
$('#cf-span__comments .cls-board-outer').removeAttr('style');
$('#cf-span__comments .cls-board-outer').removeClass('focus');
$('#cf-span__comments .cls-board-outer').removeClass('is-open');
$('#cf-span__comments .cls-board-outer').css('opacity', '0.4');

const currentUser = wp.data.select('core').getCurrentUser()?.id;

$('#' + elID + '.cls-board-outer').addClass('focus');
$('#' + elID + '.cls-board-outer').addClass('is-open');
$('#' + elID + '.cls-board-outer').css('opacity', '1');


scrollBoardToPosition(topOfText);

$('#' + elID + '.cls-board-outer').offset({ top: topOfText });

}, 800);
}
});
});
})(jQuery);

Expand All @@ -95,6 +136,7 @@ window.addEventListener("click", function (e) {

if (visualEditor && visualEditor.contains(e.target)) {
sidebar.classList.add("cf-sidebar-closed");
setTimeout(handleEditorLayoutChange( true ), 100);
closeMulticollabSidebar();
}
});
Expand Down Expand Up @@ -546,11 +588,15 @@ window.addEventListener("click", function (e) {
// Editor layout width changes sidebar multicollab btn click
if (
event.target.closest(
".interface-pinned-items .components-button, .edit-post-header-toolbar__inserter-toggle, .editor-document-tools__inserter-toggle"
)
) {
setTimeout(handleEditorLayoutChange, 100);
}
".interface-pinned-items .components-button, .edit-post-header-toolbar__inserter-toggle, .editor-document-tools__inserter-toggle"
) ||
event.target.closest(
".editor-document-tools .editor-document-tools__document-overview-toggle"
) ||
( event.target?.parentElement?.getAttribute("aria-label") === "Close" || event.target?.parentElement?.getAttribute("aria-label") === "Close Settings" || event.target?.parentElement?.getAttribute("aria-label") === "Close plugin" )
) {
setTimeout(handleEditorLayoutChange( true ), 100);
}

// If thread focused via an activity center
if (event.target.closest(".block-editor-block-list__layout .wp-block")) {
Expand Down Expand Up @@ -1019,16 +1065,24 @@ window.addEventListener("click", function (e) {
}
}
if (event.target.matches(".js-cf-edit-comment")) {
// Disable reply box when we focus on edit input box
document.querySelectorAll(".cls-board-outer").forEach((element) => {
element.classList.remove("cf-removeReply");
});

const boardOuter = event.target.closest(".cls-board-outer");
if (boardOuter) {
boardOuter.classList.add("cf-removeReply");
}
}
// Disable reply box when we focus on edit input box
document.querySelectorAll(".cls-board-outer").forEach((element) => {
element.classList.remove("cf-removeReply");
element.style.opacity = "0.4";
});

const boardOuter = event.target.closest(".cls-board-outer");
if (boardOuter) {
boardOuter.classList.add("cf-removeReply");
boardOuter.style.opacity = "1.0";
const shareCommentContainer = boardOuter.querySelector(
".shareCommentContainer"
);
if(shareCommentContainer){
shareCommentContainer.style.display = "none";
}
}
}
});

document.addEventListener("focusout", function (event) {
Expand Down Expand Up @@ -2471,8 +2525,10 @@ function showAssignableEmailList() {
document.getElementById(getCurrentTextAreaID);
currentTextAreaNode.innerHTML = "";
currentTextAreaNode.appendChild(fragments);
document.querySelector(appendIn)?.remove();
document.querySelector(assignablePopup)?.remove();
//document.querySelector(appendIn)?.remove();
//document.querySelector(assignablePopup)?.remove();
jQuery(appendIn).remove(); // Remove previous DOM.
jQuery(assignablePopup).remove(); // Remove previous DOM.
trackedStr = "";

// Setup the caret position after appending the Display Name.
Expand Down Expand Up @@ -2549,8 +2605,10 @@ function showAssignableEmailList() {
document.getElementById(getCurrentTextAreaID);
currentTextAreaNode.innerHTML = "";
currentTextAreaNode.appendChild(fragments);
document.querySelector(appendIn)?.remove();
document.querySelector(assignablePopup)?.remove();
//document.querySelector(appendIn)?.remove();
//document.querySelector(assignablePopup)?.remove();
jQuery(appendIn).remove(); // Remove previous DOM.
jQuery(assignablePopup).remove(); // Remove previous DOM.
trackedStr = "";

// Setup the caret position after appending the Display Name.
Expand Down
2 changes: 1 addition & 1 deletion admin/assets/js/dist/activityCentre.build.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion admin/assets/js/dist/block.build.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion admin/assets/js/dist/dashboard.build.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion admin/assets/js/dist/styles/editorStyle.build.min.css

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions commenting-block.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,17 @@ function cf_custom_plugin_row_meta( $plugin_meta, $plugin_file ) {
* @author: Rishi Shah
* @version 3.4
*/
// $remote_arrd = filter_input( INPUT_SERVER, 'REMOTE_ADDR', FILTER_SANITIZE_SPECIAL_CHARS );
// if ( '127.' === substr( $remote_arrd, 0, 4 ) || '::1' === $remote_arrd ) {
// define( 'CF_PROMOTIONAL_BANNER_API_URL', 'https://multicollabstg.wpengine.com/' );
// define( 'CF_STORE_URL', 'https://multicollabstg.wpengine.com/' );
// define( 'EDD_PLAN_PRO', 2817 );
// } else {
// define( 'CF_PROMOTIONAL_BANNER_API_URL', 'https://www.multicollab.com/' );
// define( 'CF_STORE_URL', 'https://www.multicollab.com/' );
// define( 'EDD_PLAN_PRO', 3793 );
// }

define( 'CF_PROMOTIONAL_BANNER_API_URL', 'https://www.multicollab.com/' );
define( 'CF_STORE_URL', 'https://www.multicollab.com/' );
define( 'EDD_PLAN_PRO', 3793 );
Expand Down
2 changes: 1 addition & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ If you’d still like help, simply <a href="https://bit.ly/3KPzx2I" target="_bla

== Changelog ==

= 4.8 - 21.10.2024 =
= 4.8 - 04.12.2024 =
* [Enhancements] Significantly improved the performance for faster loading and smoother interaction.
* [Enhancements] Streamlined script and style loading for better performance.
* [Enhancements] Enhanced compatibility with the latest WordPress.
Expand Down

0 comments on commit cd8a3da

Please sign in to comment.