<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[6893] sites/trunk/wordpress.org/public_html/style/trac/common/js/trac.js: Trac: Add Trac 1.2.2's trac.js to the CDN.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="http://meta.trac.wordpress.org/changeset/6893">6893</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"http://meta.trac.wordpress.org/changeset/6893","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>dd32</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2018-03-21 03:09:34 +0000 (Wed, 21 Mar 2018)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Trac: Add Trac 1.2.2's trac.js to the CDN. This JS appears to work with existing older Trac versions too.
Trac 1.2.2 has a bunch of other updated JS/CSS resources too, but they don't appear to be needed immediately.
See https://wordpress.slack.com/archives/C02QB8GMM/p1521425868000026</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#sitestrunkwordpressorgpublic_htmlstyletraccommonjstracjs">sites/trunk/wordpress.org/public_html/style/trac/common/js/trac.js</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="sitestrunkwordpressorgpublic_htmlstyletraccommonjstracjs"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/wordpress.org/public_html/style/trac/common/js/trac.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordpress.org/public_html/style/trac/common/js/trac.js 2018-03-21 01:36:46 UTC (rev 6892)
+++ sites/trunk/wordpress.org/public_html/style/trac/common/js/trac.js 2018-03-21 03:09:34 UTC (rev 6893)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -9,8 +9,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $("<a class='anchor'> \u00B6</a>").attr("href", "#" + this.id)
</span><span class="cx" style="display: block; padding: 0 10px"> .attr("title", title).appendTo(this);
</span><span class="cx" style="display: block; padding: 0 10px"> });
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- }
-
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ };
+
</ins><span class="cx" style="display: block; padding: 0 10px"> $.fn.checked = function(checked) {
</span><span class="cx" style="display: block; padding: 0 10px"> if (checked == undefined) { // getter
</span><span class="cx" style="display: block; padding: 0 10px"> if (!this.length) return false;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -20,8 +20,89 @@
</span><span class="cx" style="display: block; padding: 0 10px"> this.checked = checked;
</span><span class="cx" style="display: block; padding: 0 10px"> });
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- }
-
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ };
+
+ // Add a Select All checkbox to each thead in the table.
+ $.fn.addSelectAllCheckboxes = function() {
+ var $table = this;
+ if ($("tr td.sel", $table).length > 0) {
+ $("tr th.sel", $table).append(
+ $('<input type="checkbox" name="toggle_group" />').attr({
+ title: _("Toggle group")
+ }).click(function() {
+ $("tr td.sel input",
+ $(this).closest("thead, tbody").next())
+ .prop("checked", this.checked).change();
+ })
+ );
+ $("tr td.sel", $table).click(function() {
+ var $tbody = $(this).closest("tbody");
+ var $checkboxes = $("tr td.sel input", $tbody);
+ var num_selected = $checkboxes.filter(":checked").length;
+ var none_selected = num_selected === 0;
+ var all_selected = num_selected === $checkboxes.length;
+ $("tr th.sel input", $tbody.prev())
+ .prop({"checked": all_selected,
+ "indeterminate": !(none_selected || all_selected)});
+ });
+ }
+ };
+
+ $.fn.exclusiveOnClick = function(selector) {
+ var $container = $(this);
+ $container.on("click", selector,
+ function(event) {
+ if (!event.metaKey && !event.altKey)
+ return;
+ var clicked;
+ if (this.tagName === "LABEL") {
+ if (this.htmlFor) {
+ clicked = document.getElementById(this.htmlFor);
+ } else {
+ clicked = this.children[0];
+ }
+ } else {
+ clicked = this;
+ }
+ var $clicked = $(clicked);
+ $container.find(":checkbox").not(clicked).prop("checked", false);
+ $clicked.prop("checked", true);
+ }).mousedown(function(event) {
+ if (event.metaKey || event.altKey) {
+ event.preventDefault(); // Prevent border on Firefox.
+ }
+ });
+ };
+
+ // Conditionally disable the submit button. Returns a jQuery object.
+ $.fn.disableSubmit = function(determinant) {
+ determinant = $(determinant);
+ var subject = $(this);
+ var isDisabled;
+ if (determinant.is("input:checkbox")) {
+ isDisabled = function () {
+ return determinant.filter(":checked").length === 0;
+ }
+ } else if (determinant.is("input:file")) {
+ isDisabled = function () {
+ return !determinant.val();
+ }
+ } else {
+ return subject;
+ }
+ function toggleDisabled() {
+ subject.prop("disabled", isDisabled);
+ if (subject.prop("disabled")) {
+ subject.attr("title", _("At least one item must be selected"))
+ } else {
+ subject.removeAttr("title");
+ }
+ }
+ determinant.change(toggleDisabled);
+ toggleDisabled();
+ return subject;
+ };
+
</ins><span class="cx" style="display: block; padding: 0 10px"> $.fn.enable = function(enabled) {
</span><span class="cx" style="display: block; padding: 0 10px"> if (enabled == undefined) enabled = true;
</span><span class="cx" style="display: block; padding: 0 10px"> return this.each(function() {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -36,8 +117,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> label.removeClass("disabled");
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> });
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- }
-
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ };
+
</ins><span class="cx" style="display: block; padding: 0 10px"> $.fn.getAbsolutePos = function() {
</span><span class="cx" style="display: block; padding: 0 10px"> return this.map(function() {
</span><span class="cx" style="display: block; padding: 0 10px"> var left = this.offsetLeft;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -50,18 +131,52 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> return {left: left, top: top};
</span><span class="cx" style="display: block; padding: 0 10px"> });
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- }
-
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ };
+
</ins><span class="cx" style="display: block; padding: 0 10px"> $.fn.scrollToTop = function() {
</span><span class="cx" style="display: block; padding: 0 10px"> return this.each(function() {
</span><span class="cx" style="display: block; padding: 0 10px"> scrollTo(0, $(this).getAbsolutePos()[0].top);
</span><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><span class="cx" style="display: block; padding: 0 10px"> });
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- }
-
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ };
+
+ // Disable the form's submit action after the submit button is pressed by
+ // replacing it with a handler that cancels the action. The handler is
+ // removed when navigating away from the page so that the action will
+ // be enabled when using the back button to return to the page.
+ $.fn.disableOnSubmit = function() {
+ this.click(function() {
+ var form = $(this).closest("form");
+ if (form.hasClass("trac-submit-is-disabled")) {
+ form.on("submit.prevent-submit", function() {
+ return false;
+ });
+ $(window).on("unload", function() {
+ form.off("submit.prevent-submit");
+ });
+ } else {
+ form.addClass("trac-submit-is-disabled");
+ $(window).on("unload", function() {
+ form.removeClass("trac-submit-is-disabled");
+ })
+ }
+ });
+ };
+
</ins><span class="cx" style="display: block; padding: 0 10px"> $.loadStyleSheet = function(href, type) {
</span><span class="cx" style="display: block; padding: 0 10px"> type = type || "text/css";
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $(document).ready(function() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $(function() {
+ var link;
+ $("link[rel=stylesheet]").each(function() {
+ if (this.getAttribute("href") === href) {
+ if (this.disabled)
+ this.disabled = false;
+ link = this;
+ return false;
+ }
+ });
+ if (link !== undefined)
+ return;
</ins><span class="cx" style="display: block; padding: 0 10px"> if (document.createStyleSheet) { // MSIE
</span><span class="cx" style="display: block; padding: 0 10px"> document.createStyleSheet(href);
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -69,8 +184,71 @@
</span><span class="cx" style="display: block; padding: 0 10px"> .appendTo("head");
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> });
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- }
-
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ };
+
+ // {script.src: [listener1, listener2, ...]}
+ var readyListeners = {};
+
+ $.documentReady = function(listener) {
+ var script = document.currentScript;
+ if (script === undefined) {
+ script = $("head script");
+ script = script[script.length - 1];
+ }
+ if (script) {
+ var href = script.getAttribute("src");
+ if (!(href in readyListeners))
+ readyListeners[href] = [];
+ var listeners = readyListeners[href];
+ listeners.push(listener);
+ }
+ $(listener);
+ };
+
+ $.loadScript = function(href, type, charset) {
+ var script;
+ $("head script").each(function() {
+ if (this.getAttribute("src") === href) {
+ script = this;
+ return false;
+ }
+ });
+ if (script !== undefined) {
+ // Call registered ready listeners
+ $.each(readyListeners[href] || [], function(idx, listener) {
+ listener.call(document, $);
+ });
+ } else {
+ // Don't use $("<script>").appendTo("head") to avoid adding
+ // "_=<timestamp>" parameter to url.
+ script = document.createElement("script");
+ script.src = href;
+ script.async = false;
+ script.type = type || "text/javascript";
+ script.charset = charset || "utf-8";
+ $("head")[0].appendChild(script);
+ }
+ };
+
+ var warn_unsaved_changes;
+
+ // Prompt a warning if leaving the page with unsaved changes
+ $.setWarningUnsavedChanges = function(enabled, message) {
+ if (enabled) {
+ if (!warn_unsaved_changes) {
+ $(window).on("beforeunload", function() {
+ return warn_unsaved_changes;
+ });
+ }
+ warn_unsaved_changes = message || _("You have unsaved changes. Your " +
+ "changes will be lost if you leave this page before saving your " +
+ "changes.");
+ } else {
+ $(window).off("beforeunload");
+ warn_unsaved_changes = null;
+ }
+ };
+
</ins><span class="cx" style="display: block; padding: 0 10px"> // Escape special HTML characters (&<>")
</span><span class="cx" style="display: block; padding: 0 10px"> var quote = {"&": "&", "<": "<", ">": ">", '"': """};
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -78,8 +256,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if (typeof value != "string")
</span><span class="cx" style="display: block; padding: 0 10px"> return value;
</span><span class="cx" style="display: block; padding: 0 10px"> return value.replace(/[&<>"]/g, function(c) { return quote[c]; });
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- }
-
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ };
+
</ins><span class="cx" style="display: block; padding: 0 10px"> function format(str, args, escape) {
</span><span class="cx" style="display: block; padding: 0 10px"> var kwargs = args[args.length - 1];
</span><span class="cx" style="display: block; padding: 0 10px"> return str.replace(/\${?(\w+)}?/g, function(_, k) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -89,18 +267,18 @@
</span><span class="cx" style="display: block; padding: 0 10px"> else
</span><span class="cx" style="display: block; padding: 0 10px"> result = kwargs[k];
</span><span class="cx" style="display: block; padding: 0 10px"> return escape ? escape(result) : result;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- });
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ });
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Expand positional ($1 .. $9) and keyword ($name) arguments in a string.
</span><span class="cx" style="display: block; padding: 0 10px"> // The htmlFormat() version HTML-escapes arguments prior to substitution.
</span><span class="cx" style="display: block; padding: 0 10px"> $.format = function(str) {
</span><span class="cx" style="display: block; padding: 0 10px"> return format(str, arguments);
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ };
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $.htmlFormat = function(str) {
</span><span class="cx" style="display: block; padding: 0 10px"> return format(str, arguments, $.htmlEscape);
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ };
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $.template = $.format; // For backward compatibility
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -112,22 +290,4 @@
</span><span class="cx" style="display: block; padding: 0 10px"> textarea.rows = rows;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // The following are defined for backwards compatibility with releases prior
- // to Trac 0.11
-
- window.addEvent = function(elem, type, func) {
- $(elem).bind(type, func);
- }
- window.addHeadingLinks = function(container, title) {
- $.each(["h1", "h2", "h3", "h4", "h5", "h6"], function() {
- $(this, container).addAnchor(title);
- });
- }
- window.enableControl = function(id, enabled) {
- $("#" + id).enable(enabled);
- }
- window.getAncestorByTagName = function(elem, tagName) {
- return $(elem).parents(tagName).get(0);
- }
-
</del><span class="cx" style="display: block; padding: 0 10px"> })(jQuery);
</span></span></pre>
</div>
</div>
</body>
</html>