From 7433c5e72a2e7b7609dd68e405e73a23d816aae8 Mon Sep 17 00:00:00 2001 From: Marti Martz Date: Thu, 26 Oct 2017 18:28:07 -0600 Subject: [PATCH] Embed the comment editor (#1204) * Few minor HTML fixes * Rewrote client side script to not be in jQuery. Polyfill for older browsers.. applies to #904 * Reference FAQ and GFM Closes #1197 Auto-merge --- views/includes/commentEditor.html | 10 ++- views/includes/commentForm.html | 42 ++++++++-- .../includes/scripts/commentReplyScript.html | 79 ++++++------------- .../scripts/polyfillElementClosest.js | 18 +++++ views/pages/discussionPage.html | 17 ++-- views/pages/newDiscussionPage.html | 2 +- views/pages/scriptIssuePage.html | 20 ++--- views/pages/scriptNewIssuePage.html | 2 +- views/pages/scriptViewSourcePage.html | 2 +- 9 files changed, 97 insertions(+), 95 deletions(-) create mode 100644 views/includes/scripts/polyfillElementClosest.js diff --git a/views/includes/commentEditor.html b/views/includes/commentEditor.html index 32be28cd5..11f4f1e65 100644 --- a/views/includes/commentEditor.html +++ b/views/includes/commentEditor.html @@ -21,14 +21,16 @@
- +
- +
diff --git a/views/includes/commentForm.html b/views/includes/commentForm.html index 1756a92c6..111d949fc 100644 --- a/views/includes/commentForm.html +++ b/views/includes/commentForm.html @@ -1,11 +1,37 @@ -
-
-
-
- - +
+
diff --git a/views/includes/scripts/commentReplyScript.html b/views/includes/scripts/commentReplyScript.html index f9d440545..e2f8ca594 100644 --- a/views/includes/scripts/commentReplyScript.html +++ b/views/includes/scripts/commentReplyScript.html @@ -1,80 +1,47 @@ diff --git a/views/includes/scripts/polyfillElementClosest.js b/views/includes/scripts/polyfillElementClosest.js new file mode 100644 index 000000000..a7a8544b1 --- /dev/null +++ b/views/includes/scripts/polyfillElementClosest.js @@ -0,0 +1,18 @@ +// IE8+, Opera Presto, and older browser Element.Polyfill + +if (window.Element && !Element.prototype.closest) { + Element.prototype.closest = + function(aSelector) { + var matches = (this.document || this.ownerDocument).querySelectorAll(aSelector); + var i; + var el = this; + + do { + i = matches.length; + while (--i >= 0 && matches.item(i) !== el) { + }; + } while ((i < 0) && (el = el.parentElement)); + + return el; + }; +} diff --git a/views/pages/discussionPage.html b/views/pages/discussionPage.html index 996293aa2..47837a268 100644 --- a/views/pages/discussionPage.html +++ b/views/pages/discussionPage.html @@ -4,15 +4,6 @@ {{title}} {{> includes/head.html }} - {{> includes/header.html }} @@ -45,6 +36,11 @@
{{/paginationRendered}} + {{#authedUser}} +
+ {{> includes/commentForm.html }} +
+ {{/authedUser}}
@@ -54,8 +50,7 @@ -
- {{> includes/commentForm.html }} + {{> includes/footer.html }} {{#paginationRendered}} {{> includes/scripts/showTopPagination.html }} diff --git a/views/pages/newDiscussionPage.html b/views/pages/newDiscussionPage.html index 9692c43c0..8601ef6d3 100644 --- a/views/pages/newDiscussionPage.html +++ b/views/pages/newDiscussionPage.html @@ -17,7 +17,7 @@
diff --git a/views/pages/scriptIssuePage.html b/views/pages/scriptIssuePage.html index 144c00441..3019f4bc5 100644 --- a/views/pages/scriptIssuePage.html +++ b/views/pages/scriptIssuePage.html @@ -5,15 +5,6 @@ {{> includes/head.html }} - {{> includes/header.html }} @@ -53,6 +44,11 @@
{{/paginationRendered}} + {{#authedUser}} +
+ {{> includes/commentForm.html }} +
+ {{/authedUser}} @@ -63,16 +59,14 @@ -
- {{> includes/commentForm.html }} {{> includes/footer.html }} {{#paginationRendered}} {{> includes/scripts/showTopPagination.html }} {{/paginationRendered}} {{> includes/scripts/lazyIconScript.html }} {{#authedUser}} - {{> includes/scripts/markdownEditor.html }} - {{> includes/scripts/commentReplyScript.html }} + {{> includes/scripts/markdownEditor.html }} + {{> includes/scripts/commentReplyScript.html }} {{/authedUser}} {{^authedUser}} {{> includes/scripts/commentReplyTooltip.html }} diff --git a/views/pages/scriptNewIssuePage.html b/views/pages/scriptNewIssuePage.html index 19a66821d..69a37e896 100644 --- a/views/pages/scriptNewIssuePage.html +++ b/views/pages/scriptNewIssuePage.html @@ -18,7 +18,7 @@
  • {{script.name}}
  • {{category.name}}
  • - +
  • diff --git a/views/pages/scriptViewSourcePage.html b/views/pages/scriptViewSourcePage.html index f1d416af2..79134568f 100644 --- a/views/pages/scriptViewSourcePage.html +++ b/views/pages/scriptViewSourcePage.html @@ -34,7 +34,7 @@
    {{#isLib}} {{#newScript}} - Library Name: + Library Name: {{/newScript}} {{^newScript}}