4,656
edits
No edit summary Tag: Reverted |
No edit summary Tag: Manual revert |
||
| Line 51: | Line 51: | ||
var numberA = parseInt( | var numberA = parseInt( | ||
$(a).find(".entry-number").text().replace(/\[|\]/g, ""), | $(a).find(".entry-number").text().replace(/\[|\]/g, ""), | ||
10 | 10 | ||
); | ); | ||
var numberB = parseInt( | var numberB = parseInt( | ||
$(b).find(".entry-number").text().replace(/\[|\]/g, ""), | $(b).find(".entry-number").text().replace(/\[|\]/g, ""), | ||
10 | 10 | ||
); | ); | ||
return numberB - numberA; // Descending order | return numberB - numberA; // Descending order | ||
| Line 109: | Line 109: | ||
var titleImagesContainer = $( | var titleImagesContainer = $( | ||
'<div class="title-images"></div>' | '<div class="title-images"></div>' | ||
).append(images, title); | ).append(images, title); | ||
$(this).find(".people").after(titleImagesContainer); | $(this).find(".people").after(titleImagesContainer); | ||
} | } | ||
} | } | ||
); | ); | ||
| Line 133: | Line 133: | ||
$(this).find(".type").after(images); | $(this).find(".type").after(images); | ||
} | } | ||
} | } | ||
); | ); | ||
} | } | ||
| Line 179: | Line 179: | ||
$(".home-block-view").show(); | $(".home-block-view").show(); | ||
$(".home-chronicle-block-button, .home-block-view-button").addClass( | $(".home-chronicle-block-button, .home-block-view-button").addClass( | ||
"active-view-button" | "active-view-button" | ||
); | ); | ||
// Initially hide list view sorting buttons and set the default sorted view for block | // Initially hide list view sorting buttons and set the default sorted view for block | ||
$( | $( | ||
".home-chronicle-list-button, .home-random-list-button, .home-alphabetical-list-button" | ".home-chronicle-list-button, .home-random-list-button, .home-alphabetical-list-button" | ||
).hide(); | ).hide(); | ||
sortChronologically(); // Sort the block view chronologically by default | sortChronologically(); // Sort the block view chronologically by default | ||
| Line 205: | Line 205: | ||
// Toggling visibility of buttons | // Toggling visibility of buttons | ||
$( | $( | ||
".home-chronicle-block-button, .home-random-block-button, .home-alphabetical-block-button" | ".home-chronicle-block-button, .home-random-block-button, .home-alphabetical-block-button" | ||
).hide(); | ).hide(); | ||
$( | $( | ||
".home-chronicle-list-button, .home-random-list-button, .home-alphabetical-list-button" | ".home-chronicle-list-button, .home-random-list-button, .home-alphabetical-list-button" | ||
).show(); | ).show(); | ||
updateLastVisibleCard(); | updateLastVisibleCard(); | ||
| Line 246: | Line 246: | ||
.addClass("home-chronicle-block"); | .addClass("home-chronicle-block"); | ||
$( | $( | ||
".home-chronicle-block-button, .home-random-block-button, .home-alphabetical-block-button" | ".home-chronicle-block-button, .home-random-block-button, .home-alphabetical-block-button" | ||
).show(); | ).show(); | ||
$( | $( | ||
".home-chronicle-list-button, .home-random-list-button, .home-alphabetical-list-button" | ".home-chronicle-list-button, .home-random-list-button, .home-alphabetical-list-button" | ||
).hide(); | ).hide(); | ||
updateLastVisibleCard(); | updateLastVisibleCard(); | ||
| Line 350: | Line 350: | ||
$(".home-list-view").show(); | $(".home-list-view").show(); | ||
$(".chronicle-list-button, .list-view-button").addClass( | $(".chronicle-list-button, .list-view-button").addClass( | ||
"active-view-button" | "active-view-button" | ||
); | ); | ||
| Line 356: | Line 356: | ||
// Initially hide block view sorting buttons and set the default sorted view for list | // Initially hide block view sorting buttons and set the default sorted view for list | ||
$( | $( | ||
".chronicle-block-button, .random-block-button, .alphabetical-block-button" | ".chronicle-block-button, .random-block-button, .alphabetical-block-button" | ||
).hide(); | ).hide(); | ||
sortChronologically(); // Sort the block view chronologically by default | sortChronologically(); // Sort the block view chronologically by default | ||
| Line 378: | Line 378: | ||
// Toggling visibility of buttons | // Toggling visibility of buttons | ||
$( | $( | ||
".chronicle-block-button, .random-block-button, .alphabetical-block-button" | ".chronicle-block-button, .random-block-button, .alphabetical-block-button" | ||
).hide(); | ).hide(); | ||
$( | $( | ||
".chronicle-list-button, .random-list-button, .alphabetical-list-button" | ".chronicle-list-button, .random-list-button, .alphabetical-list-button" | ||
).show(); | ).show(); | ||
updateLastVisibleCard(); | updateLastVisibleCard(); | ||
| Line 418: | Line 418: | ||
.addClass("home-chronicle-block"); | .addClass("home-chronicle-block"); | ||
$( | $( | ||
".chronicle-block-button, .random-block-button, .alphabetical-block-button" | ".chronicle-block-button, .random-block-button, .alphabetical-block-button" | ||
).show(); | ).show(); | ||
$( | $( | ||
".chronicle-list-button, .random-list-button, .alphabetical-list-button" | ".chronicle-list-button, .random-list-button, .alphabetical-list-button" | ||
).hide(); | ).hide(); | ||
updateLastVisibleCard(); | updateLastVisibleCard(); | ||
| Line 673: | Line 673: | ||
// Target only the list view container for updating the last visible card | // Target only the list view container for updating the last visible card | ||
$(".home-chronicle-list div.list-container div.card").removeClass( | $(".home-chronicle-list div.list-container div.card").removeClass( | ||
"last-visible" | "last-visible" | ||
); | ); | ||
// Find the last visible card within the list view and add the class | // Find the last visible card within the list view and add the class | ||
var lastVisibleCard = $( | var lastVisibleCard = $( | ||
".home-chronicle-list div.list-container div.card:visible:last" | ".home-chronicle-list div.list-container div.card:visible:last" | ||
); | ); | ||
lastVisibleCard.addClass("last-visible"); | lastVisibleCard.addClass("last-visible"); | ||
| Line 688: | Line 688: | ||
$(".home-chronicle-block div.list-container div.card").css( | $(".home-chronicle-block div.list-container div.card").css( | ||
"width", | "width", | ||
"calc(20% - 0px)" | "calc(20% - 0px)" | ||
); | ); | ||
$( | $( | ||
".home-chronicle-block div.list-container div.card:nth-child(5n + 1)" | ".home-chronicle-block div.list-container div.card:nth-child(5n + 1)" | ||
).css("width", "calc(20% + 4px)"); | ).css("width", "calc(20% + 4px)"); | ||
} | } | ||
| Line 768: | Line 768: | ||
.find(".article-images") | .find(".article-images") | ||
.html( | .html( | ||
getImageHtml(image, currentIndex, images.length, enableNavigation) | getImageHtml(image, currentIndex, images.length, enableNavigation) | ||
); | ); | ||
} | } | ||
| Line 936: | Line 936: | ||
'</p><p class="article-people">' + | '</p><p class="article-people">' + | ||
peopleHtml + | peopleHtml + | ||
"</p>" | "</p>" | ||
); | ); | ||
var articleContentHtml = '<div class="article-title-link">'; | var articleContentHtml = '<div class="article-title-link">'; | ||
| Line 1,071: | Line 1,071: | ||
'</p><p class="article-people">' + | '</p><p class="article-people">' + | ||
peopleHtml + | peopleHtml + | ||
"</p>" | "</p>" | ||
); | ); | ||
| Line 1,168: | Line 1,168: | ||
'<div class="related-articles-label">Related Articles</div><div class="related-articles-container">' + | '<div class="related-articles-label">Related Articles</div><div class="related-articles-container">' + | ||
relatedArticlesHtml + | relatedArticlesHtml + | ||
"</div>" | "</div>" | ||
) | ) | ||
.show(); | .show(); | ||
| Line 1,211: | Line 1,211: | ||
$(".home-chronicle-list div.list-container div.card div.type").css( | $(".home-chronicle-list div.list-container div.card div.type").css( | ||
"left", | "left", | ||
"90%" | "90%" | ||
); | ); | ||
} else if ($(".home-chronicle-block").is(":visible")) { | } else if ($(".home-chronicle-block").is(":visible")) { | ||
| Line 1,269: | Line 1,269: | ||
'<a href="#" id="print-with-border" class="print-choice">show border</a> ' + | '<a href="#" id="print-with-border" class="print-choice">show border</a> ' + | ||
'<a href="#" id="print-no-border" class="print-choice">hide border</a>' + | '<a href="#" id="print-no-border" class="print-choice">hide border</a>' + | ||
"</div>" | "</div>" | ||
); | ); | ||
jQuery("#print-button").after($chooser); | jQuery("#print-button").after($chooser); | ||
| Line 1,304: | Line 1,304: | ||
function updatePrintSelectionUI() { | function updatePrintSelectionUI() { | ||
requestAnimationFrame(function () { | requestAnimationFrame(function () { | ||
var activeCount = jQuery("#filters .values button.active").length; | |||
if (activeCount > 0) { | |||
jQuery("#print-selection-wrapper").show(); | jQuery("#print-selection-wrapper").show(); | ||
} else { | |||
jQuery("#print-selection-wrapper").hide(); | jQuery("#print-selection-wrapper").hide(); | ||
jQuery("#print-selection-options").hide(); | jQuery("#print-selection-options").hide(); | ||
} | |||
}); | }); | ||
} | } | ||
function hidePrintSelectionOptions() { | function hidePrintSelectionOptions() { | ||
jQuery("#print-selection-options").hide(); | |||
} | |||
function swHandleBatchPrint(borderPref) { | function swHandleBatchPrint(borderPref) { | ||
| Line 1,325: | Line 1,325: | ||
if (!$cards.length) { | if (!$cards.length) { | ||
alert("No entries to print."); | |||
return; | |||
} | } | ||
| Line 1,332: | Line 1,332: | ||
$cards.each(function () { | $cards.each(function () { | ||
var $card = jQuery(this); | |||
var title = $card.data("page"); | |||
if (!title) return; | |||
var url = | |||
window.mw && mw.util && mw.util.getUrl | window.mw && mw.util && mw.util.getUrl | ||
? swPrintCacheBust(mw.util.getUrl(title)) | |||
: swPrintCacheBust("/wiki/" + String(title)); | |||
requests.push( | |||
jQuery.get(url).then(function (html) { | jQuery.get(url).then(function (html) { | ||
var $tmp = jQuery("<div>").html(html); | |||
var $print = $tmp.find(".print-only").first(); | |||
return $print.length ? $print.prop("outerHTML") : ""; | |||
}) | }) | ||
); | |||
}); | }); | ||
Promise.all(requests) | Promise.all(requests) | ||
.then(function (results) { | |||
var combinedHtml = results.join(""); | var combinedHtml = results.join(""); | ||
if (!combinedHtml.trim()) { | if (!combinedHtml.trim()) { | ||
alert("Could not generate print content."); | |||
return; | |||
} | } | ||
swBuildIframeAndPrint( | swBuildIframeAndPrint(combinedHtml, borderPref); | ||
}) | |||
.catch(function () { | |||
alert("There was a problem preparing the print selection."); | alert("There was a problem preparing the print selection."); | ||
}); | |||
} | } | ||
| Line 1,385: | Line 1,380: | ||
/* core: build iframe and print */ | /* core: build iframe and print */ | ||
function swBuildIframeAndPrint(printHtml, borderPref, $btn | function swBuildIframeAndPrint(printHtml, borderPref, $btn) { | ||
// iframe | // iframe | ||
var iframe = document.createElement("iframe"); | var iframe = document.createElement("iframe"); | ||
| Line 1,399: | Line 1,394: | ||
doc.open(); | doc.open(); | ||
doc.write( | doc.write( | ||
'<!doctype html><html><head><meta charset="utf-8"><title>Print</title></head><body></body></html>' | '<!doctype html><html><head><meta charset="utf-8"><title>Print</title></head><body></body></html>' | ||
); | ); | ||
doc.close(); | doc.close(); | ||
| Line 1,412: | Line 1,407: | ||
linkCss.rel = "stylesheet"; | linkCss.rel = "stylesheet"; | ||
linkCss.href = swPrintCacheBust( | linkCss.href = swPrintCacheBust( | ||
"/index.php?title=MediaWiki:Print.css&action=raw&ctype=text/css" | "/index.php?title=MediaWiki:Print.css&action=raw&ctype=text/css" | ||
); | ); | ||
| Line 1,435: | Line 1,430: | ||
(function () { | (function () { | ||
var pres = doc.querySelectorAll(".link-pdf pre"); | |||
Array.prototype.forEach.call(pres, function (pre) { | |||
// move its children out | |||
while (pre.firstChild) { | |||
pre.parentNode.insertBefore(pre.firstChild, pre); | |||
} | |||
// remove the <pre> | |||
pre.parentNode.removeChild(pre); | |||
}); | |||
})(); | })(); | ||
| Line 1,474: | Line 1,469: | ||
htmlEl.className = (htmlEl.className || "").replace( | htmlEl.className = (htmlEl.className || "").replace( | ||
/\bprint-no-border\b/g, | /\bprint-no-border\b/g, | ||
"" | "" | ||
); | ); | ||
} | } | ||
| Line 1,610: | Line 1,605: | ||
}; | }; | ||
}); | }); | ||
}) | }) | ||
); | ); | ||
} | } | ||
| Line 1,647: | Line 1,642: | ||
.then(function () { | .then(function () { | ||
// filename via document.title | // filename via document.title | ||
var entryNum = ""; | |||
var numEl = doc.querySelector(".article-entry-number"); | |||
if (numEl) { | |||
var m = (numEl.textContent || "").match(/\d+/); | |||
entryNum = m ? m[0] : ""; | |||
} | } | ||
var desiredTitle = | |||
(entryNum ? entryNum + "." : "") + "softwear.directory"; | |||
var oldIframeTitle = doc.title; | var oldIframeTitle = doc.title; | ||
var oldParentTitle = document.title; | var oldParentTitle = document.title; | ||
| Line 1,791: | Line 1,780: | ||
if (k === "Enter" || k === 13 || k === " " || k === 32) fire(e); | if (k === "Enter" || k === 13 || k === " " || k === 32) fire(e); | ||
}, | }, | ||
true | true | ||
); | ); | ||
})(els[i]); | })(els[i]); | ||
| Line 1,841: | Line 1,830: | ||
// click directly on a choice link (fallback path) | // click directly on a choice link (fallback path) | ||
var $choice = jQuery(e.target).closest( | var $choice = jQuery(e.target).closest( | ||
"a#print-with-border, a#print-no-border" | "a#print-with-border, a#print-no-border" | ||
); | ); | ||
if (!$choice.length) return; | if (!$choice.length) return; | ||
e.preventDefault(); | e.preventDefault(); | ||
swHandlePrintChoice($choice.attr("id"), $choice); | swHandlePrintChoice($choice.attr("id"), $choice); | ||
} | } | ||
); | ); | ||
| Line 1,855: | Line 1,844: | ||
function (e) { | function (e) { | ||
var host = this.closest( | var host = this.closest( | ||
'[id="print-with-border"], [id="print-no-border"]' | '[id="print-with-border"], [id="print-no-border"]' | ||
); | ); | ||
if (!host) return; | if (!host) return; | ||
e.preventDefault(); | e.preventDefault(); | ||
swHandlePrintChoice(host.id, (window.jQuery && jQuery(host)) || null); | swHandlePrintChoice(host.id, (window.jQuery && jQuery(host)) || null); | ||
} | } | ||
); | ); | ||
| Line 1,866: | Line 1,855: | ||
jQuery(document).on("keydown.swprint", function (e) { | jQuery(document).on("keydown.swprint", function (e) { | ||
if (e && e.keyCode === 27) { | if (e && e.keyCode === 27) { | ||
swHidePrintUI(); | |||
hidePrintSelectionOptions(); | |||
} | } | ||
}); | }); | ||
| Line 1,873: | Line 1,862: | ||
// toggle filtered print options | // toggle filtered print options | ||
jQuery(document).on("click", ".print-selection-toggle", function (e) { | jQuery(document).on("click", ".print-selection-toggle", function (e) { | ||
e.preventDefault(); | |||
jQuery("#print-selection-options").toggle(); | |||
}); | |||
// run filtered batch print | // run filtered batch print | ||
| Line 1,882: | Line 1,871: | ||
".print-selection-border, .print-selection-no-border", | ".print-selection-border, .print-selection-no-border", | ||
function (e) { | function (e) { | ||
e.preventDefault(); | |||
var $btn = jQuery(this); | |||
var borderPref = $btn.hasClass("print-selection-no-border") | |||
? "without" | ? "without" | ||
: "with"; | : "with"; | ||
// disable all related buttons | |||
jQuery(".print-selection-border, .print-selection-no-border, .print-selection-toggle") | |||
.prop("disabled", true) | .prop("disabled", true) | ||
.css("opacity", "0.5"); | .css("opacity", "0.5"); | ||
// change ONLY clicked button text (native feeling) | |||
var originalText = $btn.text(); | |||
$btn.text("working…"); | |||
swHandleBatchPrint(borderPref); | |||
// optional reset (if user comes back) | |||
setTimeout(function () { | |||
$btn.text(originalText); | $btn.text(originalText); | ||
jQuery( | jQuery(".print-selection-border, .print-selection-no-border, .print-selection-toggle") | ||
.prop("disabled", false) | |||
.css("opacity", ""); | |||
}, 2000); | |||
} | |||
} | |||
); | ); | ||
| Line 1,952: | Line 1,937: | ||
$(this).css("overflow-y", "hidden"); | $(this).css("overflow-y", "hidden"); | ||
$(this).css("overflow-x", "hidden"); | $(this).css("overflow-x", "hidden"); | ||
} | } | ||
); | ); | ||
| Line 1,993: | Line 1,978: | ||
jQuery( | jQuery( | ||
"#show-article .article-description, #show-article .article-reflection" | "#show-article .article-description, #show-article .article-reflection" | ||
).each(function () { | ).each(function () { | ||
var $el = jQuery(this); | var $el = jQuery(this); | ||
| Line 2,097: | Line 2,082: | ||
// Tooltip for "wander elsewhere..." on .card.event | // Tooltip for "wander elsewhere..." on .card.event | ||
var tooltip = $( | var tooltip = $( | ||
'<div class="tooltip-popup">wander elsewhere...</div>' | '<div class="tooltip-popup">wander elsewhere...</div>' | ||
).appendTo("body"); | ).appendTo("body"); | ||