Skip to content

Commit

Permalink
Clone free files changes
Browse files Browse the repository at this point in the history
  • Loading branch information
olatechpro committed Sep 2, 2024
1 parent ecf1237 commit ca8e311
Show file tree
Hide file tree
Showing 13 changed files with 223 additions and 47 deletions.
32 changes: 32 additions & 0 deletions common/css/publishpress-admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,38 @@
font-style: normal;
}

.pp-title-tooltip {
cursor: help;
position: relative;
}

.pp-title-tooltip-text {
display: none;
position: absolute;
background-color: #3c434a;
color: #fff;
padding: 5px;
border-radius: 5px;
font-size: 12px;
white-space: nowrap;
z-index: 1000;
pointer-events: none;
box-shadow: 0px 4px 8px rgb(255, 255, 255);
}

.pp-title-tooltip-text::after {
content: "";
position: absolute;
top: 100%;
left: 50%;
transform: translateX(-50%);
border-width: 5px;
border-style: solid;
border-color: #333 transparent transparent transparent;
box-shadow: -1px -1px 3px rgba(0, 0, 0, 0.1);
}


[class^="pp-icon-"]:before,
[class*=" pp-icon-"]:before {
font-family: "publishpress" !important;
Expand Down
44 changes: 44 additions & 0 deletions common/js/publishpress-admin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
(function ($) {
'use strict';

/**
* All of the code for admin-facing JavaScript source
* should reside in this file.
*/

$(document).ready(function () {

initToolTips();
function initToolTips() {
$('.pp-title-tooltip').each(function() {
var $this = $(this);
var titleText = $this.attr('title');

if (titleText && titleText !== '') {
$this.removeAttr('title');

var $tooltip = $('<div class="pp-title-tooltip-text"></div>').text(titleText);
$('body').append($tooltip);

$this.hover(function() {
$tooltip.show();

// Adjust the tooltip position to account for the arrow
var tooltipTop = $this.offset().top - $tooltip.outerHeight() - 10; // Position 10px above the element
var tooltipLeft = $this.offset().left + ($this.outerWidth() / 2) - ($tooltip.outerWidth() / 2);

$tooltip.css({
top: tooltipTop + 'px',
left: tooltipLeft + 'px',
position: 'absolute'
});
}, function() {
$tooltip.hide();
});
}
});
}

});

})(jQuery);
1 change: 1 addition & 0 deletions common/php/class-module.php
Original file line number Diff line number Diff line change
Expand Up @@ -1050,6 +1050,7 @@ public function localize_post_data($localized_post_data, $post, $can_edit_post)
'post_id' => $post->ID,
'post_title' => $post_title,
'raw_title' => $post->post_title,
'filtered_title' => isset($post->filtered_title) ? $post->filtered_title : $post->post_title,
'post_status' => $post->post_status,
'status_label' => $this->get_post_status_friendly_name($post->post_status),
'can_edit_post' => $can_edit_post ? 1 : 0,
Expand Down
22 changes: 19 additions & 3 deletions modules/calendar/calendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,14 @@ public function enqueue_admin_scripts()
PUBLISHPRESS_VERSION,
true
);

wp_enqueue_script(
'publishpress-admin',
PUBLISHPRESS_URL . 'common/js/publishpress-admin.js',
['jquery'],
PUBLISHPRESS_VERSION
);

wp_enqueue_script(
'publishpress-calendar-js',
$this->module_url . 'lib/calendar.js',
Expand Down Expand Up @@ -1215,6 +1223,7 @@ public function update_user_filters($request_filter = [])
'weeks' => '',
'start_date' => '',
'me_mode' => '',
'show_revision' => '',
's' => '',
'post_status' => '',
];
Expand Down Expand Up @@ -1247,6 +1256,7 @@ public function update_user_filters($request_filter = [])
'weeks' => __('Weeks', 'publishpress'),
'start_date' => __('Start Date', 'publishpress'),
'me_mode' => __('Me Mode', 'publishpress'),
'show_revision' => __('Show Revision', 'publishpress'),
's' => __('Search', 'publishpress'),
], $this->filters);

Expand Down Expand Up @@ -1804,6 +1814,7 @@ public function get_calendar_filters() {
data-label="<?php esc_html_e('Me Mode', 'publishpress'); ?>">
<span class="dashicons dashicons-admin-users"></span> <?php esc_html_e('Me Mode', 'publishpress'); ?>
</div>
<?php do_action('pp_content_calendar_filter_after_me_mode', $this->user_filters); ?>
<?php $modal_id++; ?>
<div class="item action co-filter" data-target="#content_calendar_modal_<?php echo esc_attr($modal_id); ?>">
<span class="dashicons dashicons-filter"></span> <?php esc_html_e('Customize Filters', 'publishpress'); ?>
Expand All @@ -1828,6 +1839,7 @@ public function get_calendar_filters() {
<form method="GET" id="pp-content-filters" class="pp-content-filters">
<input type="hidden" name="page" value="pp-content-calendar"/>
<input type="hidden" name="me_mode" id="content_calendar_me_mode" value="<?php echo esc_attr($me_mode); ?>" />
<?php do_action('pp_content_calendar_filter_hidden_fields', $this->user_filters); ?>
<div class="pp-content-calendar-filters">
<?php
$filter_weeks = isset($this->user_filters['weeks']) ? (int)$this->user_filters['weeks'] : self::DEFAULT_NUM_WEEKS;
Expand Down Expand Up @@ -3337,12 +3349,11 @@ public function getCalendarDataForMultipleWeeks($args = [], $context = 'dashboar
}

// Filter for an end user to implement any of their own query args
$args = apply_filters('pp_calendar_posts_query_args', $args, $context);
$args = apply_filters('pp_calendar_posts_query_args', $args, $context, $enabled_filters, $this->user_filters);

if (isset($this->module->options->sort_by)) {
add_filter('posts_orderby', [$this, 'filterPostsOrderBy'], 10);
}

$post_results = new WP_Query($args);

$posts = [];
Expand Down Expand Up @@ -4341,12 +4352,17 @@ private function getPostTypeObject($postType)

private function extractPostDataForTheCalendar($post)
{


$filtered_title = apply_filters('pp_calendar_post_title_html', $post->post_title, $post);
$post->filtered_title = $filtered_title;

$postTypeOptions = $this->get_post_status_options($post->post_status);
$postTypeObject = $this->getPostTypeObject($post->post_type);
$canEdit = current_user_can($postTypeObject->cap->edit_post, $post->ID);

$data = [
'label' => esc_html($post->post_title),
'label' => $filtered_title,
'id' => (int)$post->ID,
'timestamp' => esc_attr($post->post_date),
'icon' => esc_attr($postTypeOptions['icon']),
Expand Down
21 changes: 20 additions & 1 deletion modules/calendar/lib/async-calendar/js/AsyncCalendar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import NavigationBar from "./NavigationBar";
import WeekDays from "./WeekDays";
import MessageBar from "./MessageBar";
import DayCell from "./DayCell";
import {calculateWeeksInMilliseconds, getBeginDateOfWeekByDate, getDateAsStringInWpFormat, getDateInstanceFromString, addCalendarPosts, openPostModal, adjustTextareaHeight, updateModalPost} from "./Functions";
import {calculateWeeksInMilliseconds, getBeginDateOfWeekByDate, getDateAsStringInWpFormat, getDateInstanceFromString, addCalendarPosts, openPostModal, adjustTextareaHeight, updateModalPost, initToolTips} from "./Functions";
import FilterBar from "./FilterBar";
import ItemFormPopup from "./ItemFormPopup";

Expand Down Expand Up @@ -81,6 +81,23 @@ export default function AsyncCalendar(props) {
document.querySelector('#filter_author').value = '';
document.querySelector('#pp-content-filters #content_calendar_me_mode').value = new_value;
};

const onShowRevisionClick = (event) => {
event.preventDefault();
let new_value = '';

if (event.target.classList.contains('active-filter')) {
new_value = 0;
event.target.classList.remove('active-filter');
} else {
new_value = 1;
event.target.classList.add('active-filter');
}

onFilterEventCallback('show_revision', new_value);

document.querySelector('#pp-content-filters #pp_show_revision_input').value = new_value;
};

const onSearchClick = (event) => {
let selectElement = event.target;
Expand Down Expand Up @@ -133,6 +150,7 @@ export default function AsyncCalendar(props) {
$(document).on('click', '.metadata-item-filter .filter-apply input[type=submit]', onFilterApplyClick);
$(document).on('click', '.pp-content-calendar-manage .search-bar input[type=submit]', onSearchClick);
$(document).on('click', '.pp-content-calendar-manage .me-mode-action', onMeModeClick);
$(document).on('click', '.pp-content-calendar-manage .pp-show-revision-btn', onShowRevisionClick);
$(document).on('click', '.pp-popup-modal-header .modal-nav-prev, .pp-popup-modal-header .modal-nav-next', onModalNavClick);
$(document).on('input', '.pp-content-calendar-general-modal-container .modal-post-title .title-area', adjustTextareaHeight);
$(document).on('click', '.pp-content-calendar-general-modal-container .modal-content-right .save-post-changes:not(.disabled)', function(e) {
Expand Down Expand Up @@ -193,6 +211,7 @@ export default function AsyncCalendar(props) {
setMessage(null);

resetCSSClasses();
initToolTips();
});
};

Expand Down
35 changes: 33 additions & 2 deletions modules/calendar/lib/async-calendar/js/Functions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -320,13 +320,13 @@ export function openPostModal(post_id) {

if (previous_post.post_id != post.post_id) {
popup_header += '<div class="pp-modal-navigation-prev">';
popup_header += '<a title="' + publishpressCalendarParams.strings.prev_label + '" href="#" class="modal-nav-prev" data-post_id="' + previous_post.post_id + '"><span class="dashicons dashicons-arrow-left-alt"></span> ' + previous_post.post_title + '</a>';
popup_header += '<a title="' + publishpressCalendarParams.strings.prev_label + '" href="#" class="modal-nav-prev" data-post_id="' + previous_post.post_id + '"><span class="dashicons dashicons-arrow-left-alt"></span> ' + previous_post.filtered_title + '</a>';
popup_header += '</div>';
}

if (next_post.post_id != post.post_id) {
popup_header += '<div class="pp-modal-navigation-next">';
popup_header += '<a title="' + publishpressCalendarParams.strings.next_label + '" href="#" class="modal-nav-next" data-post_id="' + next_post.post_id + '">' + next_post.post_title + ' <span class="dashicons dashicons-arrow-right-alt"></span></a>';
popup_header += '<a title="' + publishpressCalendarParams.strings.next_label + '" href="#" class="modal-nav-next" data-post_id="' + next_post.post_id + '">' + next_post.filtered_title + ' <span class="dashicons dashicons-arrow-right-alt"></span></a>';
popup_header += '</div>';
}

Expand Down Expand Up @@ -536,6 +536,37 @@ export function init_date_time_picker() {
self.datetimepicker(options);
});
}

export function initToolTips() {
jQuery('.pp-title-tooltip').each(function() {
var $this = jQuery(this);
var titleText = $this.attr('title');

if (titleText && titleText !== '') {
$this.removeAttr('title');

var $tooltip = jQuery('<div class="pp-title-tooltip-text"></div>').text(titleText);
jQuery('body').append($tooltip);

$this.hover(function() {
$tooltip.show();

// Adjust the tooltip position to account for the arrow
var tooltipTop = $this.offset().top - $tooltip.outerHeight() - 10; // Position 10px above the element
var tooltipLeft = $this.offset().left + ($this.outerWidth() / 2) - ($tooltip.outerWidth() / 2);

$tooltip.css({
top: tooltipTop + 'px',
left: tooltipLeft + 'px',
position: 'absolute'
});
}, function() {
$tooltip.hide();
});
}
});
}


export function getOptions (self, custom_options) {
var default_options = {
Expand Down
2 changes: 1 addition & 1 deletion modules/calendar/lib/async-calendar/js/index.min.js

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion modules/calendar/lib/calendar.css
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@
text-overflow: ellipsis;
text-overflow: ellipsis;
max-width: 150px;
display: inline-block;
vertical-align: middle;
max-height: 1.5rem;
border: 1px solid rgb(204, 201, 250);
Expand Down
24 changes: 18 additions & 6 deletions modules/content-board/content-board.php
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,13 @@ public function enqueue_admin_scripts()

wp_enqueue_script('jquery-ui-sortable');

wp_enqueue_script(
'publishpress-admin',
PUBLISHPRESS_URL . 'common/js/publishpress-admin.js',
['jquery'],
PUBLISHPRESS_VERSION
);

wp_enqueue_script(
'publishpress-content_board',
$this->module_url . 'lib/content-board.js',
Expand Down Expand Up @@ -625,6 +632,7 @@ public function update_user_filters()
'start_date' => $this->filter_get_param('start_date'),
'end_date' => $this->filter_get_param('end_date'),
'me_mode' => $this->filter_get_param('me_mode'),
'show_revision' => $this->filter_get_param('show_revision'),
];

$editorial_metadata = $this->terms_options;
Expand Down Expand Up @@ -1887,6 +1895,7 @@ public function table_navigation()
<div class="item action me-mode-action <?php echo esc_attr($active_me_mode); ?>">
<span class="dashicons dashicons-admin-users"></span> <?php esc_html_e('Me Mode', 'publishpress'); ?>
</div>
<?php do_action('pp_content_board_filter_after_me_mode', $this->user_filters); ?>
<div class="item action co-filter" data-target="#content_board_modal_<?php echo esc_attr($modal_id); ?>">
<span class="dashicons dashicons-editor-table"></span> <?php esc_html_e('Customize Card Data', 'publishpress'); ?>
</div>
Expand Down Expand Up @@ -1937,6 +1946,7 @@ public function table_navigation()
<div class="clear"></div>
<form method="GET" id="pp-content-filters">
<input type="hidden" name="page" value="pp-content-board"/>
<?php do_action('pp_content_board_filter_hidden_fields', $this->user_filters); ?>
<input type="hidden" name="me_mode" id="content_board_me_mode" value="<?php echo esc_attr($me_mode); ?>" />
<div class="pp-content-board-filters">
<?php
Expand Down Expand Up @@ -1992,6 +2002,7 @@ class="co-filter <?php echo esc_attr($active_class); ?> <?php echo esc_attr($sel
<input type="hidden" name="cat" value=""/>
<input type="hidden" name="author" value=""/>
<input type="hidden" name="me_mode" value=""/>
<?php do_action('pp_content_board_filter_reset_hidden_fields', $this->user_filters); ?>
<input type="hidden" name="orderby" value="<?php
echo (isset($_GET['orderby']) && ! empty($_GET['orderby'])) ?
esc_attr(sanitize_key($_GET['orderby'])) : 'post_date'; ?>"/>
Expand Down Expand Up @@ -2612,7 +2623,9 @@ public function printPostForPostType($postType)
$can_edit_post = current_user_can($post_type_object->cap->edit_post, $status_post->ID);
$post_date = get_the_time(get_option("date_format"), $status_post->ID) . " " . get_the_time(get_option("time_format"), $status_post->ID);

$post_title = _draft_or_post_title($status_post->ID);
$post_title = _draft_or_post_title($status_post->ID);
$filtered_title = apply_filters('pp_content_board_post_title_html', $post_title, $status_post);
$status_post->filtered_title = $filtered_title;

if (Util::isPlannersProActive()) {
$localized_post_data = $this->localize_post_data($localized_post_data, $status_post, $can_edit_post);
Expand All @@ -2628,11 +2641,9 @@ public function printPostForPostType($postType)
<div class="post-title post-'. esc_attr($status_post->ID) .'">';

if ($can_edit_post) {
$title_output = '<strong class="post-title-text"><a href="'. esc_url(get_edit_post_link($status_post->ID)) . '" title="'. esc_attr($post_title) .'">'. esc_html(
$post_title
) . '</a></strong>';
$title_output = '<strong class="post-title-text"><a href="'. esc_url(get_edit_post_link($status_post->ID)) . '" title="'. esc_attr($post_title) .'">'. $filtered_title . '</a></strong>';
} else {
$title_output = '<strong class="post-title-text" title="'. esc_attr($post_title) .'">'. esc_html($post_title) . '</strong>';
$title_output = '<strong class="post-title-text" title="'. esc_attr($post_title) .'">'. $filtered_title . '</strong>';
}
$statuses_content_markup .= $title_output;
$statuses_content_markup .= '</div>';
Expand Down Expand Up @@ -2998,7 +3009,8 @@ public function getPostsForPostType($postType, $args = null)
}

// Filter for an end user to implement any of their own query args
$args = apply_filters('PP_Content_Board_posts_query_args', $args);
$context = 'default';
$args = apply_filters('PP_Content_Board_posts_query_args', $args, $context, $enabled_filters, $this->user_filters);

add_filter('posts_where', [$this, 'posts_where_range']);
$term_posts_query_results = new WP_Query($args);
Expand Down
5 changes: 4 additions & 1 deletion modules/content-board/lib/content-board.css
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,10 @@
-webkit-line-clamp: 1;
}

.content-board-table-wrap .board-content .content-item .content-item-post .post-title .post-title-text .pp-title-tooltip {
color: #b95c00;
}

.content-board-table-wrap .board-content .content-item .content-item-post .post-meta {
display: flex;
justify-content: space-between;
Expand Down Expand Up @@ -393,7 +397,6 @@
text-overflow: ellipsis;
text-overflow: ellipsis;
max-width: 150px;
display: inline-block;
vertical-align: middle;
max-height: 1.5rem;
border: 1px solid rgb(204, 201, 250);
Expand Down
Loading

0 comments on commit ca8e311

Please sign in to comment.