User:Chlod/Scripts/Deputy.js: Difference between revisions

Content deleted Content added
v0.2.1; https://github.com/ChlodAlejandro/deputy/releases/tag/v0.2.1
v0.2.2; https://github.com/ChlodAlejandro/deputy/releases/tag/v0.2.2
Line 2,494:
* (g) closing comments
*/
class DeputyContributionSurveyRow extends EventTarget {
/**
* Creates a new DeputyContributionSurveyRow object.
Line 2,504:
*/
constructor(row, originalElement, originalWikitext, section) {
super();
/**
* The state of this element.
Line 2,750 ⟶ 2,751:
this.commentsField.setNotices([]);
}
// Emit "update" event
this.dispatchEvent(new CustomEvent('update'));
}
/**
Line 3,331 ⟶ 3,334:
* modifying it manually.
*/
var deputyVersion = /* v */ '0.2.12' /* v */;
 
/**
Line 3,856 ⟶ 3,859:
});
closingWarning.toggle(false);
const updateClosingWarning = (() => {
closingWarning.toggle(v && this.rows.some((row) => !row.completed));
});
const closingCommentsField = new OO.ui.FieldLayout(this.closingComments, {
align: 'top',
Line 3,873 ⟶ 3,879:
this.closed = v;
closingCommentsField.toggle(v);
closingWarning.toggle(v && this.rows.some((row) => !row.completed));
this.toggleClosingComments(v);
if (v) {
updateClosingWarning();
this.rows.forEach((row) => {
row.addEventListener('update', updateClosingWarning);
});
}
else {
closingWarning.toggle(false);
this.rows.forEach((row) => {
row.removeEventListener('update', updateClosingWarning);
});
}
});
this.closingComments.on('change', (v) => {
Line 12,267 ⟶ 12,284:
</div>
<!-- {{int:deputy.ia.content.copyvio.content}} -->
<div class="copyvio" style="display: none" data-copyvio>`;
/**
* `{{subst:copyvio/bottom}}` equivalent.
Line 13,115 ⟶ 13,132:
"deputy.ia.report.success.report": "Page reported",
"deputy.ia.report.error.report": "An error occurred while trying to save the entry to today's noticeboard listings. Please visit the noticeboard page and select \"Add listing\" or file the listing manually.",
"deputy.ia.report.error.shadow": "An error occurred while trying to append the {{copyvio}} template on the page. Please manually insert the template.",
"deputy.ia.hiddenVio": "A user has marked content on this page as a suspected copyright violation. It is currently hidden from normal viewers of this page while awaiting further action.",
"deputy.ia.hiddenVio.show": "Show hidden copyright violation",
"deputy.ia.hiddenVio.hide": "Hide hidden copyright violation"
};
 
Line 14,797 ⟶ 14,817:
}
 
var iaStyles = ".ia-listing-action {display: inline-block;}body.ltr .ia-listing-action {margin-left: 0.5em;}body.ltr .ia-listing-action--bracket:first-child,body.rtl .ia-listing-action--bracket:first-child {margin-right: 0.2em;}body.rtl .ia-listing-action {margin-right: 0.5em;}body.ltr .ia-listing-action--bracket:last-child,body.rtl .ia-listing-action--bracket:last-child {margin-left: 0.2em;}.ia-listing-action--link[disabled] {color: gray;pointer-events: none;}@keyframes ia-newResponse {from { background-color: #ffe29e }to { background-color: rgba( 0, 0, 0, 0 ); }}.ia-newResponse {animation: ia-newResponse 2s ease-out;}.ia-listing-response, .ia-listing-new {max-width: 50em;}.ia-listing-response {margin-top: 0.4em;margin-bottom: 0.4em;}.mw-content-ltr .ia-listing-response, .mw-content-rtl .mw-content-ltr .ia-listing-response {margin-left: 1.6em;margin-right: 0;}.mw-content-rtl .ia-listing-response, .mw-content-ltr .mw-content-rtl .ia-listing-response {margin-left: 0;margin-right: 1.6em;}.ia-listing-response > div {margin-bottom: 8px;}.ia-listing--preview {box-sizing: border-box;background: #f6f6f6;padding: 0.5em 1em;overflow: hidden;}/** \"Preview\" */.ia-listing--preview::before {content: attr(data-label);color: #808080;display: block;margin-bottom: 0.2em;}.ia-listing-response--submit {text-align: right;}/** * NEW LISTINGS */.ia-listing-newPanel {margin-top: 0.5em;}.ia-listing-new {display: flex;align-items: end;margin-top: 0.5em;padding: 1em;}.ia-listing-new--field {flex: 1;}.ia-listing-new--cancel {margin-left: 0.5em;}.ia-batchListing-new {padding: 1em;max-width: 50em;}.ia-batchListing-new--buttons {display: flex;justify-content: end;margin-top: 12px;}.ia-batchListing-new .ia-listing--preview {margin-top: 12px;}/** * REPORTING DIALOG */.ia-report-intro {font-size: 0.8rem;padding-bottom: 12px;border-bottom: 1px solid gray;margin-bottom: 12px;}.ia-report-intro b {display: block;font-size: 1rem;}.ia-report-submit {padding-top: 12px;display: flex;justify-content: flex-end;}/** * COPYVIO PREVIEWS */.copyvio.deputy-show {display: inherit !important;border: 0.2em solid #f88;padding: 1em;}.dp-hiddenVio {display: flex;flex-direction: row;margin: 1em 0;}.dp-hiddenVio-actions {flex: 0;margin-left: 1em;display: flex;flex-direction: column;justify-content: center;}";
 
/**
*
*/
class HiddenViolationUI {
/**
*
* @param el
*/
constructor(el) {
if (!el.classList.contains('copyvio') && !el.hasAttribute('data-copyvio')) {
throw new Error('Attempted to create HiddenViolationUI on non-copyvio element.');
}
this.vioElement = el;
}
/**
*
*/
attach() {
this.vioElement.insertAdjacentElement('beforebegin', h_1("div", { class: "deputy dp-hiddenVio" },
h_1("div", null, this.renderMessage()),
h_1("div", { class: "dp-hiddenVio-actions" }, this.renderButton())));
this.vioElement.classList.add('deputy-upgraded');
}
/**
* @return A message widget.
*/
renderMessage() {
return unwrapWidget(DeputyMessageWidget({
type: 'warning',
label: mw.msg('deputy.ia.hiddenVio')
}));
}
/**
* @return A button.
*/
renderButton() {
const button = new OO.ui.ToggleButtonWidget({
icon: 'eye',
label: mw.msg('deputy.ia.hiddenVio.show')
});
button.on('change', (shown) => {
button.setLabel(shown ? mw.msg('deputy.ia.hiddenVio.hide') : mw.msg('deputy.ia.hiddenVio.show'));
button.setIcon(shown ? 'eyeClosed' : 'eye');
this.vioElement.classList.toggle('deputy-show', shown);
});
return unwrapWidget(button);
}
}
 
/**
Line 14,889 ⟶ 14,958:
});
}
mw.hook('wikipage.content').add(() => {
mw.loader.using([
'oojs-ui-core',
'oojs-ui-widgets',
'oojs-ui.styles.icons-alerts',
'oojs-ui.styles.icons-accessibility'
], () => {
document.querySelectorAll('.copyvio:not(.deputy-upgraded), [data-copyvio]:not(.deputy-upgraded)').forEach((el) => {
new HiddenViolationUI(el).attach();
});
});
});
});
}