| Server IP : 68.178.247.200 / Your IP : 216.73.216.110 Web Server : Apache System : Linux p3plzcpnl489463.prod.phx3.secureserver.net 4.18.0-553.126.2.lve.el8.x86_64 #1 SMP Thu May 28 14:12:30 UTC 2026 x86_64 User : x9dppmxs4rgd ( 8559391) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /proc/self/cwd/wp-content/plugins/publishpress/modules/calendar/lib/async-calendar/js/ |
Upload File : |
import {getHourStringOnFormat, getDateInstanceFromString} from './Functions';
import ItemPopup from './ItemPopup';
const {__} = wp.i18n;
const $ = jQuery;
export default function Item(props) {
const DEFAULT_TIME_FORMAT = 'g:i a';
const DEFAULT_LABEL = __('Untitled', 'publishpress');
const calendarItem = React.useRef(null);
const getHourString = () => {
let timestampDate = getDateInstanceFromString(props.timestamp);
return getHourStringOnFormat(timestampDate, props.timeFormat || DEFAULT_TIME_FORMAT);
}
const getClassName = () => {
let className = 'publishpress-calendar-item';
if (props.isPopupOpened) {
className += ' publishpress-calendar-item-opened-popup';
}
if (props.canMove) {
className += ' publishpress-calendar-item-movable';
}
return className;
}
const isPopupElementOrChildrenOfPopup = (element) => {
return $(element).hasClass('publishpress-calendar-popup')
|| $(element).parents('.publishpress-calendar-popup').length > 0;
}
const dispatchClickEvent = (e) => {
if (isPopupElementOrChildrenOfPopup(e.target)) {
return;
}
props.onClickItemCallback(props.id);
}
const iconElement = props.showIcon && props.icon ?
<span className={'dashicons ' + props.icon}> </span> : null;
const timeElement = props.showTime ?
<time className="publishpress-calendar-item-time"
dateTime={props.timestamp}
title={props.timestamp}>{getHourString()}</time> : null;
const label = props.label || DEFAULT_LABEL;
return (
<li
ref={calendarItem}
className={getClassName()}
style={{backgroundColor: props.color}}
data-index={props.index}
data-id={props.id}
data-datetime={props.timestamp}
onClick={dispatchClickEvent}>
{iconElement}{timeElement}
{label}
{props.isPopupOpened &&
<ItemPopup target={calendarItem}
id={props.id}
title={label}
icon={props.icon}
timestamp={props.timestamp}
color={props.color}
data={props.isPopupOpened ? props.getPopupItemDataCallback() : null}
onItemActionClickCallback={props.onItemActionClickCallback}
ajaxUrl={props.ajaxUrl}/>
}
</li>
)
}