From f215eeedac66e08cbee9f79c0573a566f4480f40 Mon Sep 17 00:00:00 2001
From: Daryl Tan <3646725+openorclose@users.noreply.github.com>
Date: Tue, 3 Mar 2020 21:48:07 +0800
Subject: [PATCH] Migrate to bootstrap-vue popovers (#1033)
---
asset/css/markbind.css | 29 ++++
asset/js/setup.js | 33 ++++
docs/userGuide/syntax/extra/triggers.mbdf | 2 +-
docs/userGuide/syntax/modals.mbdf | 4 +-
docs/userGuide/syntax/popovers.mbdf | 6 +-
docs/userGuide/syntax/tooltips.mbdf | 5 +-
.../markbind/src/parsers/componentParser.js | 152 ++++++++++++++++--
.../test_site/expected/bugs/index.html | 35 ++--
test/functional/test_site/expected/index.html | 26 ++-
.../expected/markbind/css/markbind.css | 29 ++++
.../test_site/expected/markbind/js/setup.js | 33 ++++
.../test_site/expected/siteData.json | 1 +
.../expected/testTooltipSpacing.html | 6 +-
.../expected/index.html | 16 +-
.../expected/markbind/css/markbind.css | 29 ++++
.../expected/markbind/js/setup.js | 33 ++++
.../expected/markbind/css/markbind.css | 29 ++++
.../expected/markbind/js/setup.js | 33 ++++
.../expected/markbind/css/markbind.css | 29 ++++
.../expected/markbind/js/setup.js | 33 ++++
.../test_default/expected/index.html | 12 +-
.../expected/markbind/css/markbind.css | 29 ++++
.../expected/markbind/js/setup.js | 33 ++++
.../expected/markbind/css/markbind.css | 29 ++++
.../expected/markbind/js/setup.js | 33 ++++
test/unit/parsers/componentParser.test.js | 2 +-
test/unit/utils/componentParserData.js | 52 +++---
27 files changed, 640 insertions(+), 113 deletions(-)
diff --git a/asset/css/markbind.css b/asset/css/markbind.css
index b38ecfa195..d38eb2b900 100644
--- a/asset/css/markbind.css
+++ b/asset/css/markbind.css
@@ -340,3 +340,32 @@ li.footnote-item:target {
top: 0;
width: 3em;
}
+
+/* hide popover, modal, tooltip content */
+[data-mb-html-for] {
+ display: none;
+}
+
+/* styles for triggers */
+.trigger {
+ text-decoration: underline dotted;
+}
+
+.modal.mb-zoom {
+ -webkit-transform: scale(0.1);
+ -moz-transform: scale(0.1);
+ -ms-transform: scale(0.1);
+ transform: scale(0.1);
+ opacity: 0;
+ -webkit-transition: all 0.3s;
+ -moz-transition: all 0.3s;
+ transition: all 0.3s;
+}
+
+.modal.mb-zoom.show {
+ -webkit-transform: scale(1);
+ -moz-transform: scale(1);
+ -ms-transform: scale(1);
+ transform: scale(1);
+ opacity: 1;
+}
diff --git a/asset/js/setup.js b/asset/js/setup.js
index 114e5a70e8..c6b54ef24f 100644
--- a/asset/js/setup.js
+++ b/asset/js/setup.js
@@ -171,6 +171,39 @@ function setupWithSearch() {
setupSiteNav();
}
+function makeInnerGetterFor(attribute) {
+ return (element) => {
+ const innerElement = element.querySelector(`[data-mb-html-for="${attribute}"]`);
+ return innerElement === null ? '' : innerElement.innerHTML;
+ };
+}
+
+function makeHtmlGetterFor(componentType, attribute) {
+ return (element) => {
+ const contentWrapper = document.getElementById(element.attributes.for.value);
+ return contentWrapper.dataset.mbComponentType === componentType
+ ? makeInnerGetterFor(attribute)(contentWrapper) : '';
+ };
+}
+
+/* eslint-disable no-unused-vars */
+/*
+ These getters are used by triggers to get their popover/tooltip content.
+ We need to create a completely new popover/tooltip for each trigger due to bootstrap-vue's implementation,
+ so this is how we retrieve our contents.
+*/
+const popoverContentGetter = makeHtmlGetterFor('popover', 'content');
+const popoverHeaderGetter = makeHtmlGetterFor('popover', 'header');
+const popoverInnerContentGetter = makeInnerGetterFor('content');
+const popoverInnerHeaderGetter = makeInnerGetterFor('header');
+
+const popoverGenerator = { title: popoverHeaderGetter, content: popoverContentGetter };
+const popoverInnerGenerator = { title: popoverInnerHeaderGetter, content: popoverInnerContentGetter };
+
+const tooltipContentGetter = makeHtmlGetterFor('tooltip', '_content');
+const tooltipInnerContentGetter = makeInnerGetterFor('_content');
+/* eslint-enable no-unused-vars */
+
if (enableSearch) {
setupWithSearch();
} else {
diff --git a/docs/userGuide/syntax/extra/triggers.mbdf b/docs/userGuide/syntax/extra/triggers.mbdf
index 56d70d2b91..ff6d7d0edd 100644
--- a/docs/userGuide/syntax/extra/triggers.mbdf
+++ b/docs/userGuide/syntax/extra/triggers.mbdf
@@ -14,5 +14,5 @@ Additionally, multiple Triggers could share the same overlay by providing them w
Name | Type | Default | Description
---- | ---- | ------- | ------
-trigger | `String` | `hover` | How the overlay view is triggered.
Supports: `click`, `focus`, `hover`, `contextmenu`.
+trigger | `String` | `hover` | How the overlay view is triggered.
Supports: `click`, `focus`, `hover`.
for | `String` | `null` | The id for the overlay view to be shown.
\ No newline at end of file
diff --git a/docs/userGuide/syntax/modals.mbdf b/docs/userGuide/syntax/modals.mbdf
index cdfbe0abea..1f46638ffd 100644
--- a/docs/userGuide/syntax/modals.mbdf
+++ b/docs/userGuide/syntax/modals.mbdf
@@ -54,9 +54,7 @@ Name | type | Default | Description
header
@@ -146,8 +143,7 @@ This is the same
Supports: `click`, `focus`, `hover`, `contextmenu`.
-effect | `String` | `fade` | Transition effect for Popover.
Supports: `scale`, `fade`.
+trigger | `String` | `hover` | How the Popover is triggered.
Supports: `click`, `focus`, `hover`.
header
popover initiated by trigger: honor trigger attribute
Repro:
-
-
Requirements gathering, requirements elicitation, requirements analysis, requirements capture are some of the terms commonly and interchangeably used to represent the activity of understanding what a software product should - do. -
-Establishing Requirements
+ +Requirements gathering, requirements elicitation, requirements analysis, +requirements capture are some of the terms commonly and interchangeably used to represent the activity +of understanding what a software product should do.
Support multiple inclusions of a modal
Repro:
This is to reproduce
-
This is to reproduce multiple inclusions of a modal bug
+Requirements gathering, requirements elicitation, requirements analysis, requirements capture are some of the terms commonly and interchangeably used to represent the activity of understanding what a software product should do.
This is to reproduce
-
This is to reproduce multiple inclusions of a modal bug
+Requirements gathering, requirements elicitation, requirements analysis, requirements capture are some of the terms commonly and interchangeably used to represent the activity of understanding what a software product should do.
Remove extra space in links
diff --git a/test/functional/test_site/expected/index.html b/test/functional/test_site/expected/index.html index aa9b11cc31..dcf2201aa4 100644 --- a/test/functional/test_site/expected/index.html +++ b/test/functional/test_site/expected/index.html @@ -146,16 +146,9 @@Test footnotes
Normal footnotes: Here is a footnote reference,
-
Here is a repeated footnote to
-
Inline footnotes: Here is an inline note.
-
Normal footnotes: Here is a footnote reference,[1] and another.[2]
+Here is a repeated footnote to [1]
+Inline footnotes: Here is an inline note.[3]
Variables that reference another variable
This variable can be referenced.
@@ -285,8 +278,8 @@Carefully designed questionnaires can be used to solicit responses and opinions from a large number of users regarding any current system or a new innovation.
Focus groups are a kind of informal interview within an interactive group setting. A
-
Focus groups are a kind of informal interview within an interactive group setting. A e.g. potential users, beta testersgroup + of people are asked about their understanding of a specific issue or a process. Focus groups can bring out undiscovered conflicts and misunderstandings among stakeholder interests which can then be resolved or clarified as necessary.
Include segment
@@ -448,14 +441,12 @@Modal with panel inside
-
-
trigger
+Panel content inside modal
Unexpanded panel
Panel content of unexpanded panel should not appear in search data
@@ -570,6 +561,7 @@