From faa4809559541433eeb53374045d3e9ad956b888 Mon Sep 17 00:00:00 2001 From: Jeffrey Yasskin Date: Sat, 6 Jun 2015 18:07:19 -0700 Subject: [PATCH 01/13] Upgrade to Polymer 1.0. --- bower.json | 6 +- clause.html | 76 ++++++++------- codeblock.html | 25 ++--- definition-section.html | 27 +++--- definition-section.js | 41 +++++--- figure.html | 14 +-- footnote.html | 22 ++--- foreign-index.html | 14 +-- foreign-index.js | 13 ++- foreword.html | 5 +- framework.html | 7 +- function.html | 184 ++++++++++++++---------------------- include.js | 31 +++--- promise-0.1.1.min.js | 1 - publish.html | 16 ++-- publish.js | 20 +++- ref.html | 27 +++--- ref.js | 62 ++++++++++-- section.html | 28 +++--- section.js | 56 ++++++++--- table.html | 67 ++++++------- titlepage.html | 142 +++++++++++++--------------- titlepage.js | 128 +++++++++++++++---------- toc.html | 67 +++++++------ toc.js | 52 +++++++--- util/get-element-by-id.html | 29 ++++-- 26 files changed, 662 insertions(+), 498 deletions(-) delete mode 100644 promise-0.1.1.min.js diff --git a/bower.json b/bower.json index 084edd0..17e45c9 100644 --- a/bower.json +++ b/bower.json @@ -10,7 +10,9 @@ "tests" ], "dependencies": { - "polymer": "Polymer/polymer#0.5.2", - "core-ajax": "Polymer/core-ajax#0.5.2" + "polymer": "Polymer/polymer#^1.0.0", + "iron-ajax": "PolymerElements/iron-ajax#^1.0.0", + "promise-polyfill": "PolymerLabs/promise-polyfill#^1.0.0", + "fetch": "github/fetch#^0.9.0" } } diff --git a/clause.html b/clause.html index 3fa7e8d..6880ff4 100644 --- a/clause.html +++ b/clause.html @@ -13,38 +13,46 @@ limitations under the License. --> - - - + } + Polymer({ + is: 'cxx-clause', + + behaviors: [CxxSectionBehavior], + + // Convenience function at the clause level, which gets called + // from . If the clause is explicitly numbered, then + // this sets the clause_num to that value. Otherwise, the clause + // number is set to the argument clause_num. This returns + // 1 + the value set. + // + // Note that this will recursively set the section numbers for + // this clause. + set_clause_num: function(clause_num) { + // If the author explicitly specified the clause number, don't + // use a different number. + if (this.number) + clause_num = Number(this.number) + this.update_sec_nums(clause_num); + return clause_num + 1; + }, + + attached: updateTocClauses, + detached: updateTocClauses, + }); + })(); + diff --git a/codeblock.html b/codeblock.html index d07533b..25a55ff 100644 --- a/codeblock.html +++ b/codeblock.html @@ -25,22 +25,25 @@ TODO: This could call into a syntax highlighter that styles comments correctly. --> - + + - - + diff --git a/definition-section.html b/definition-section.html index a08dfcc..0b4ccfc 100644 --- a/definition-section.html +++ b/definition-section.html @@ -18,22 +18,19 @@ and definitions" section that gets numbered as if each term is a section, but doesn't make them show up in the table of contents. --> - + + + + + - - - + + diff --git a/definition-section.js b/definition-section.js index e56dc3f..0fe4eb1 100644 --- a/definition-section.js +++ b/definition-section.js @@ -17,16 +17,33 @@ limitations under the License. // Record the document that this element is declared in, so we can // pull the
template out of it. // The condition handles the HTML Imports polyfill: - // http://www.polymer-project.org/platform/html-imports.html#other-notes + // http://webcomponents.org/polyfills/html-imports/#other-notes var importDocument = document._currentScript ? document._currentScript.ownerDocument : document.currentScript.ownerDocument; - Polymer('cxx-definition-section', { + var CxxDefinitionSectionTerm = Polymer({ + is: 'cxx-definition-section-term', + extends: 'dt', + + joinWithDots: function() { + return Array.prototype.join.call(arguments, '.'); + }, + prependHash: function(value) { + return '#' + value; + }, + surroundWithBrackets: function(value) { + return '[' + value + ']'; + }, + }); + Polymer({ + is: 'cxx-definition-section', + extends: 'dl', + ready: function() { - var parent_section = this.parentElement; + var parent_section = Polymer.dom(this).parentNode; while (parent_section && parent_section.tagName != 'CXX-SECTION') - parent_section = parent_section.parentElement; + parent_section = Polymer.dom(parent_section).parentNode; if (!parent_section) { console.error('cxx-definition-section', this, 'must be a descendent of a element.'); @@ -34,20 +51,20 @@ limitations under the License. } var next_term_number = 1; - for (var dt = this.firstElementChild; dt; - dt = dt.nextElementSibling) { + for (var dt = Polymer.dom(this).firstElementChild; dt; + dt = Polymer.dom(dt).nextSibling) { if (dt.tagName != 'DT') continue; + var oldDt = dt; + dt = new CxxDefinitionSectionTerm(); + dt.id = oldDt.id; dt.parent_section = parent_section; dt.term_number = next_term_number++; + Polymer.dom(dt).innerHTML = Polymer.dom(oldDt).innerHTML; - var template = importDocument.getElementById( - 'cxx-definition-section-term').cloneNode(true); - template.removeAttribute('id'); - template.model = dt; - - dt.createShadowRoot().appendChild(template); + Polymer.dom(this).insertBefore(dt, oldDt); + Polymer.dom(this).removeChild(oldDt); } } }); diff --git a/figure.html b/figure.html index 3d2dafb..ec58e7b 100644 --- a/figure.html +++ b/figure.html @@ -17,13 +17,12 @@ Uses the HTML
content model, but automatically adds a number to the
. --> - +