in static/src/javascripts/projects/common/modules/discussion/loader.js [173:265]
initToolbar() {
const $orderLabel = $('.js-comment-order');
const $threadingLabel = $('.js-comment-threading');
$threadingLabel.text(this.comments && this.comments.options.threading);
$orderLabel.text(this.comments && this.comments.options.order);
this.on('click', '.js-comment-order-dropdown .popup__action', (e) => {
bean.fire(
qwery('.js-comment-order-dropdown [data-toggle]')[0],
'click',
);
if (this.comments) {
this.comments.options.order = bonzo(e.currentTarget).data(
'order',
);
}
$orderLabel.text(this.comments && this.comments.options.order);
userPrefs.set(
'discussion.order',
this.comments && this.comments.options.order,
);
this.loadComments({ page: 1 });
document.dispatchEvent(new CustomEvent('comments-state-change'));
});
this.on(
'click',
'.js-comment-threading-dropdown .popup__action',
(e) => {
bean.fire(
qwery('.js-comment-threading-dropdown [data-toggle]')[0],
'click',
);
if (this.comments) {
this.comments.options.threading = bonzo(
e.currentTarget,
).data('threading');
}
$threadingLabel.text(
this.comments && this.comments.options.threading,
);
userPrefs.set(
'discussion.threading',
this.comments && this.comments.options.threading,
);
this.loadComments();
},
);
if (config.get('page.section') === 'crosswords') {
const $timestampsLabel = $('.js-timestamps');
const updateLabelText = (prefValue) => {
$timestampsLabel.text(prefValue ? 'Relative' : 'Absolute');
};
updateLabelText();
const PREF_RELATIVE_TIMESTAMPS =
'discussion.enableRelativeTimestamps';
// Default to true
const prefValue =
userPrefs.get(PREF_RELATIVE_TIMESTAMPS) !== null
? userPrefs.get(PREF_RELATIVE_TIMESTAMPS)
: true;
updateLabelText(prefValue);
this.on('click', '.js-timestamps-dropdown .popup__action', (e) => {
const format = bonzo(e.currentTarget).data('timestamp');
bean.fire(
qwery('.js-timestamps-dropdown [data-toggle]')[0],
'click',
);
updateLabelText(format === 'relative');
userPrefs.set(PREF_RELATIVE_TIMESTAMPS, format === 'relative');
this.loadComments();
});
}
}