Automatically swap style sheets to hide background colours when publishing to TR/.
authorCameron McCormack <cam@mcc.id.au>
Sat, 18 Aug 2012 17:40:05 +1000
changeset 47 ca9311658567
parent 46 45101ee54e7a
child 48 ebd1897ec1af
Automatically swap style sheets to hide background colours when publishing to TR/.
publish/processing.js
publish/publish.js
--- a/publish/processing.js	Sat Aug 18 16:57:36 2012 +1000
+++ b/publish/processing.js	Sat Aug 18 17:40:05 2012 +1000
@@ -32,19 +32,31 @@
   doc.getElementsByTagName('title')[0].textContent += ' — ' + conf.shortTitle;
 };
 
-// -- Link to the W3C style sheet for the document's maturity -----------------
+// -- Link to the document and W3C style sheet for the document's maturity ---
 
-exports.insertW3CStyleSheet = function(conf, page, doc) {
+exports.insertStyleSheets = function(conf, page, doc) {
   // Remove existing links to W3C style sheets.
   for (var next, n = doc.head.firstChild; n; n = next) {
     next = n.nextSibling;
     if (n.nodeName == 'link' &&
-        n.getAttribute('media') != 'print' &&
-        n.getAttribute('href').indexOf('StyleSheets/TR') != -1) {
+        n.getAttribute('media') != 'print') {
       n.parentNode.removeChild(n);
     }
   }
 
+  // Add a link to the default style sheet.
+  doc.head.appendChild(utils.parse('<link rel="stylesheet" title="Default" href="{{href}}" type="text/css" media="screen"/>',
+                                   { href: conf.maturity == 'ED' ? 'style/default_svg.css' : 'style/default_no_maturity.css' }));
+
+  // Add a link to alternate style sheet to hide background colors
+  // if this is an Editor's Draft, or to show them otherwise.
+  doc.head.appendChild(utils.parse('<link rel="alternate stylesheet" title="{{title}}" href="{{href}}" type="text/css" media="screen"/>',
+                                   { href: conf.maturity == 'ED' ? 'style/default_no_maturity.css' : 'style/default_svg.css',
+                                     title: conf.maturity == 'ED' ? 'Only annotations for publication' : 'All annotations' }));
+
+  // Add a link to the "no issues/annotations" style sheet.
+  doc.head.appendChild(utils.parse('<link rel="alternate stylesheet" title="No issues/annotations" href="style/default_no_issues.css" type="text/css" media="screen"/>'));
+
   // Add a link to a local or remote W3C TR style sheet for this document's maturity.
   var href = 'W3C-' + conf.shortMaturity;
   if (conf.localStyleSheets) {
@@ -57,7 +69,7 @@
 
   // Add <script> to fix up protocol-relative style sheet links when viewed over file:.
   doc.head.appendChild(utils.parse('<script src="style/link-fixup.js"></script>'));
-}
+};
 
 
 // -- Insert link to MathJax script on pages that have math -------------------
--- a/publish/publish.js	Sat Aug 18 16:57:36 2012 +1000
+++ b/publish/publish.js	Sat Aug 18 17:40:05 2012 +1000
@@ -75,7 +75,7 @@
 
   [processing.insertPageComment,
    processing.insertSpecNameInTitle,
-   processing.insertW3CStyleSheet,
+   processing.insertStyleSheets,
    processing.insertMathJaxScript,
    processing.addBodyClass,
    processing.addHeaderFooter,