vertx-howtos-jekyll-theme 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE.txt +21 -0
- data/README.md +52 -0
- data/_layouts/page.html +61 -0
- data/_sass/bootstrap/js/dist/alert.js +199 -0
- data/_sass/bootstrap/js/dist/alert.js.map +1 -0
- data/_sass/bootstrap/js/dist/button.js +187 -0
- data/_sass/bootstrap/js/dist/button.js.map +1 -0
- data/_sass/bootstrap/js/dist/carousel.js +666 -0
- data/_sass/bootstrap/js/dist/carousel.js.map +1 -0
- data/_sass/bootstrap/js/dist/collapse.js +428 -0
- data/_sass/bootstrap/js/dist/collapse.js.map +1 -0
- data/_sass/bootstrap/js/dist/dropdown.js +591 -0
- data/_sass/bootstrap/js/dist/dropdown.js.map +1 -0
- data/_sass/bootstrap/js/dist/index.js +23 -0
- data/_sass/bootstrap/js/dist/index.js.map +1 -0
- data/_sass/bootstrap/js/dist/modal.js +644 -0
- data/_sass/bootstrap/js/dist/modal.js.map +1 -0
- data/_sass/bootstrap/js/dist/popover.js +261 -0
- data/_sass/bootstrap/js/dist/popover.js.map +1 -0
- data/_sass/bootstrap/js/dist/scrollspy.js +375 -0
- data/_sass/bootstrap/js/dist/scrollspy.js.map +1 -0
- data/_sass/bootstrap/js/dist/tab.js +266 -0
- data/_sass/bootstrap/js/dist/tab.js.map +1 -0
- data/_sass/bootstrap/js/dist/toast.js +278 -0
- data/_sass/bootstrap/js/dist/toast.js.map +1 -0
- data/_sass/bootstrap/js/dist/tooltip.js +745 -0
- data/_sass/bootstrap/js/dist/tooltip.js.map +1 -0
- data/_sass/bootstrap/js/dist/util.js +168 -0
- data/_sass/bootstrap/js/dist/util.js.map +1 -0
- data/_sass/bootstrap/js/src/alert.js +179 -0
- data/_sass/bootstrap/js/src/button.js +171 -0
- data/_sass/bootstrap/js/src/carousel.js +604 -0
- data/_sass/bootstrap/js/src/collapse.js +402 -0
- data/_sass/bootstrap/js/src/dropdown.js +538 -0
- data/_sass/bootstrap/js/src/index.js +52 -0
- data/_sass/bootstrap/js/src/modal.js +587 -0
- data/_sass/bootstrap/js/src/popover.js +184 -0
- data/_sass/bootstrap/js/src/scrollspy.js +326 -0
- data/_sass/bootstrap/js/src/tab.js +257 -0
- data/_sass/bootstrap/js/src/toast.js +223 -0
- data/_sass/bootstrap/js/src/tooltip.js +735 -0
- data/_sass/bootstrap/js/src/util.js +173 -0
- data/_sass/bootstrap/js/tests/README.md +69 -0
- data/_sass/bootstrap/js/tests/browsers.js +82 -0
- data/_sass/bootstrap/js/tests/index.html +145 -0
- data/_sass/bootstrap/js/tests/integration/bundle.js +8 -0
- data/_sass/bootstrap/js/tests/integration/index.html +66 -0
- data/_sass/bootstrap/js/tests/integration/rollup.bundle.js +20 -0
- data/_sass/bootstrap/js/tests/karma.conf.js +145 -0
- data/_sass/bootstrap/js/tests/unit/.eslintrc.json +40 -0
- data/_sass/bootstrap/js/tests/unit/alert.js +123 -0
- data/_sass/bootstrap/js/tests/unit/button.js +222 -0
- data/_sass/bootstrap/js/tests/unit/carousel.js +1273 -0
- data/_sass/bootstrap/js/tests/unit/collapse.js +892 -0
- data/_sass/bootstrap/js/tests/unit/dropdown.js +1364 -0
- data/_sass/bootstrap/js/tests/unit/modal.js +796 -0
- data/_sass/bootstrap/js/tests/unit/popover.js +471 -0
- data/_sass/bootstrap/js/tests/unit/scrollspy.js +728 -0
- data/_sass/bootstrap/js/tests/unit/tab.js +462 -0
- data/_sass/bootstrap/js/tests/unit/toast.js +239 -0
- data/_sass/bootstrap/js/tests/unit/tooltip.js +1072 -0
- data/_sass/bootstrap/js/tests/unit/util.js +164 -0
- data/_sass/bootstrap/js/tests/visual/alert.html +58 -0
- data/_sass/bootstrap/js/tests/visual/button.html +51 -0
- data/_sass/bootstrap/js/tests/visual/carousel.html +66 -0
- data/_sass/bootstrap/js/tests/visual/collapse.html +78 -0
- data/_sass/bootstrap/js/tests/visual/dropdown.html +212 -0
- data/_sass/bootstrap/js/tests/visual/modal.html +268 -0
- data/_sass/bootstrap/js/tests/visual/popover.html +46 -0
- data/_sass/bootstrap/js/tests/visual/scrollspy.html +95 -0
- data/_sass/bootstrap/js/tests/visual/tab.html +234 -0
- data/_sass/bootstrap/js/tests/visual/toast.html +72 -0
- data/_sass/bootstrap/js/tests/visual/tooltip.html +106 -0
- data/_sass/bootstrap/scss/_alert.scss +51 -0
- data/_sass/bootstrap/scss/_badge.scss +53 -0
- data/_sass/bootstrap/scss/_breadcrumb.scss +41 -0
- data/_sass/bootstrap/scss/_button-group.scss +163 -0
- data/_sass/bootstrap/scss/_buttons.scss +140 -0
- data/_sass/bootstrap/scss/_card.scss +310 -0
- data/_sass/bootstrap/scss/_carousel.scss +198 -0
- data/_sass/bootstrap/scss/_close.scss +44 -0
- data/_sass/bootstrap/scss/_code.scss +48 -0
- data/_sass/bootstrap/scss/_custom-forms.scss +507 -0
- data/_sass/bootstrap/scss/_dropdown.scss +191 -0
- data/_sass/bootstrap/scss/_forms.scss +334 -0
- data/_sass/bootstrap/scss/_functions.scss +86 -0
- data/_sass/bootstrap/scss/_grid.scss +52 -0
- data/_sass/bootstrap/scss/_images.scss +42 -0
- data/_sass/bootstrap/scss/_input-group.scss +193 -0
- data/_sass/bootstrap/scss/_jumbotron.scss +16 -0
- data/_sass/bootstrap/scss/_list-group.scss +121 -0
- data/_sass/bootstrap/scss/_media.scss +8 -0
- data/_sass/bootstrap/scss/_mixins.scss +41 -0
- data/_sass/bootstrap/scss/_modal.scss +186 -0
- data/_sass/bootstrap/scss/_nav.scss +120 -0
- data/_sass/bootstrap/scss/_navbar.scss +299 -0
- data/_sass/bootstrap/scss/_pagination.scss +78 -0
- data/_sass/bootstrap/scss/_popover.scss +183 -0
- data/_sass/bootstrap/scss/_print.scss +141 -0
- data/_sass/bootstrap/scss/_progress.scss +34 -0
- data/_sass/bootstrap/scss/_reboot.scss +462 -0
- data/_sass/bootstrap/scss/_root.scss +19 -0
- data/_sass/bootstrap/scss/_spinners.scss +53 -0
- data/_sass/bootstrap/scss/_tables.scss +187 -0
- data/_sass/bootstrap/scss/_toasts.scss +43 -0
- data/_sass/bootstrap/scss/_tooltip.scss +115 -0
- data/_sass/bootstrap/scss/_transitions.scss +22 -0
- data/_sass/bootstrap/scss/_type.scss +125 -0
- data/_sass/bootstrap/scss/_utilities.scss +16 -0
- data/_sass/bootstrap/scss/_variables.scss +1091 -0
- data/_sass/bootstrap/scss/bootstrap-grid.scss +29 -0
- data/_sass/bootstrap/scss/bootstrap-reboot.scss +12 -0
- data/_sass/bootstrap/scss/bootstrap.scss +44 -0
- data/_sass/bootstrap/scss/mixins/_alert.scss +13 -0
- data/_sass/bootstrap/scss/mixins/_background-variant.scss +21 -0
- data/_sass/bootstrap/scss/mixins/_badge.scss +11 -0
- data/_sass/bootstrap/scss/mixins/_border-radius.scss +35 -0
- data/_sass/bootstrap/scss/mixins/_box-shadow.scss +5 -0
- data/_sass/bootstrap/scss/mixins/_breakpoints.scss +123 -0
- data/_sass/bootstrap/scss/mixins/_buttons.scss +111 -0
- data/_sass/bootstrap/scss/mixins/_caret.scss +62 -0
- data/_sass/bootstrap/scss/mixins/_clearfix.scss +7 -0
- data/_sass/bootstrap/scss/mixins/_float.scss +11 -0
- data/_sass/bootstrap/scss/mixins/_forms.scss +198 -0
- data/_sass/bootstrap/scss/mixins/_gradients.scss +45 -0
- data/_sass/bootstrap/scss/mixins/_grid-framework.scss +66 -0
- data/_sass/bootstrap/scss/mixins/_grid.scss +51 -0
- data/_sass/bootstrap/scss/mixins/_hover.scss +37 -0
- data/_sass/bootstrap/scss/mixins/_image.scss +36 -0
- data/_sass/bootstrap/scss/mixins/_list-group.scss +21 -0
- data/_sass/bootstrap/scss/mixins/_lists.scss +7 -0
- data/_sass/bootstrap/scss/mixins/_nav-divider.scss +10 -0
- data/_sass/bootstrap/scss/mixins/_pagination.scss +22 -0
- data/_sass/bootstrap/scss/mixins/_reset-text.scss +17 -0
- data/_sass/bootstrap/scss/mixins/_resize.scss +6 -0
- data/_sass/bootstrap/scss/mixins/_screen-reader.scss +33 -0
- data/_sass/bootstrap/scss/mixins/_size.scss +6 -0
- data/_sass/bootstrap/scss/mixins/_table-row.scss +39 -0
- data/_sass/bootstrap/scss/mixins/_text-emphasis.scss +14 -0
- data/_sass/bootstrap/scss/mixins/_text-hide.scss +13 -0
- data/_sass/bootstrap/scss/mixins/_text-truncate.scss +8 -0
- data/_sass/bootstrap/scss/mixins/_transition.scss +16 -0
- data/_sass/bootstrap/scss/mixins/_visibility.scss +7 -0
- data/_sass/bootstrap/scss/utilities/_align.scss +8 -0
- data/_sass/bootstrap/scss/utilities/_background.scss +19 -0
- data/_sass/bootstrap/scss/utilities/_borders.scss +63 -0
- data/_sass/bootstrap/scss/utilities/_clearfix.scss +3 -0
- data/_sass/bootstrap/scss/utilities/_display.scss +38 -0
- data/_sass/bootstrap/scss/utilities/_embed.scss +39 -0
- data/_sass/bootstrap/scss/utilities/_flex.scss +51 -0
- data/_sass/bootstrap/scss/utilities/_float.scss +9 -0
- data/_sass/bootstrap/scss/utilities/_overflow.scss +5 -0
- data/_sass/bootstrap/scss/utilities/_position.scss +32 -0
- data/_sass/bootstrap/scss/utilities/_screenreaders.scss +11 -0
- data/_sass/bootstrap/scss/utilities/_shadows.scss +6 -0
- data/_sass/bootstrap/scss/utilities/_sizing.scss +20 -0
- data/_sass/bootstrap/scss/utilities/_spacing.scss +73 -0
- data/_sass/bootstrap/scss/utilities/_text.scss +67 -0
- data/_sass/bootstrap/scss/utilities/_visibility.scss +11 -0
- data/_sass/custom.scss +1 -0
- data/assets/css/style.scss +65 -0
- data/assets/images/vertx-square.svg +1 -0
- metadata +248 -0
@@ -0,0 +1,184 @@
|
|
1
|
+
/**
|
2
|
+
* --------------------------------------------------------------------------
|
3
|
+
* Bootstrap (v4.2.1): popover.js
|
4
|
+
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
|
5
|
+
* --------------------------------------------------------------------------
|
6
|
+
*/
|
7
|
+
|
8
|
+
import $ from 'jquery'
|
9
|
+
import Tooltip from './tooltip'
|
10
|
+
|
11
|
+
/**
|
12
|
+
* ------------------------------------------------------------------------
|
13
|
+
* Constants
|
14
|
+
* ------------------------------------------------------------------------
|
15
|
+
*/
|
16
|
+
|
17
|
+
const NAME = 'popover'
|
18
|
+
const VERSION = '4.2.1'
|
19
|
+
const DATA_KEY = 'bs.popover'
|
20
|
+
const EVENT_KEY = `.${DATA_KEY}`
|
21
|
+
const JQUERY_NO_CONFLICT = $.fn[NAME]
|
22
|
+
const CLASS_PREFIX = 'bs-popover'
|
23
|
+
const BSCLS_PREFIX_REGEX = new RegExp(`(^|\\s)${CLASS_PREFIX}\\S+`, 'g')
|
24
|
+
|
25
|
+
const Default = {
|
26
|
+
...Tooltip.Default,
|
27
|
+
placement : 'right',
|
28
|
+
trigger : 'click',
|
29
|
+
content : '',
|
30
|
+
template : '<div class="popover" role="tooltip">' +
|
31
|
+
'<div class="arrow"></div>' +
|
32
|
+
'<h3 class="popover-header"></h3>' +
|
33
|
+
'<div class="popover-body"></div></div>'
|
34
|
+
}
|
35
|
+
|
36
|
+
const DefaultType = {
|
37
|
+
...Tooltip.DefaultType,
|
38
|
+
content : '(string|element|function)'
|
39
|
+
}
|
40
|
+
|
41
|
+
const ClassName = {
|
42
|
+
FADE : 'fade',
|
43
|
+
SHOW : 'show'
|
44
|
+
}
|
45
|
+
|
46
|
+
const Selector = {
|
47
|
+
TITLE : '.popover-header',
|
48
|
+
CONTENT : '.popover-body'
|
49
|
+
}
|
50
|
+
|
51
|
+
const Event = {
|
52
|
+
HIDE : `hide${EVENT_KEY}`,
|
53
|
+
HIDDEN : `hidden${EVENT_KEY}`,
|
54
|
+
SHOW : `show${EVENT_KEY}`,
|
55
|
+
SHOWN : `shown${EVENT_KEY}`,
|
56
|
+
INSERTED : `inserted${EVENT_KEY}`,
|
57
|
+
CLICK : `click${EVENT_KEY}`,
|
58
|
+
FOCUSIN : `focusin${EVENT_KEY}`,
|
59
|
+
FOCUSOUT : `focusout${EVENT_KEY}`,
|
60
|
+
MOUSEENTER : `mouseenter${EVENT_KEY}`,
|
61
|
+
MOUSELEAVE : `mouseleave${EVENT_KEY}`
|
62
|
+
}
|
63
|
+
|
64
|
+
/**
|
65
|
+
* ------------------------------------------------------------------------
|
66
|
+
* Class Definition
|
67
|
+
* ------------------------------------------------------------------------
|
68
|
+
*/
|
69
|
+
|
70
|
+
class Popover extends Tooltip {
|
71
|
+
// Getters
|
72
|
+
|
73
|
+
static get VERSION() {
|
74
|
+
return VERSION
|
75
|
+
}
|
76
|
+
|
77
|
+
static get Default() {
|
78
|
+
return Default
|
79
|
+
}
|
80
|
+
|
81
|
+
static get NAME() {
|
82
|
+
return NAME
|
83
|
+
}
|
84
|
+
|
85
|
+
static get DATA_KEY() {
|
86
|
+
return DATA_KEY
|
87
|
+
}
|
88
|
+
|
89
|
+
static get Event() {
|
90
|
+
return Event
|
91
|
+
}
|
92
|
+
|
93
|
+
static get EVENT_KEY() {
|
94
|
+
return EVENT_KEY
|
95
|
+
}
|
96
|
+
|
97
|
+
static get DefaultType() {
|
98
|
+
return DefaultType
|
99
|
+
}
|
100
|
+
|
101
|
+
// Overrides
|
102
|
+
|
103
|
+
isWithContent() {
|
104
|
+
return this.getTitle() || this._getContent()
|
105
|
+
}
|
106
|
+
|
107
|
+
addAttachmentClass(attachment) {
|
108
|
+
$(this.getTipElement()).addClass(`${CLASS_PREFIX}-${attachment}`)
|
109
|
+
}
|
110
|
+
|
111
|
+
getTipElement() {
|
112
|
+
this.tip = this.tip || $(this.config.template)[0]
|
113
|
+
return this.tip
|
114
|
+
}
|
115
|
+
|
116
|
+
setContent() {
|
117
|
+
const $tip = $(this.getTipElement())
|
118
|
+
|
119
|
+
// We use append for html objects to maintain js events
|
120
|
+
this.setElementContent($tip.find(Selector.TITLE), this.getTitle())
|
121
|
+
let content = this._getContent()
|
122
|
+
if (typeof content === 'function') {
|
123
|
+
content = content.call(this.element)
|
124
|
+
}
|
125
|
+
this.setElementContent($tip.find(Selector.CONTENT), content)
|
126
|
+
|
127
|
+
$tip.removeClass(`${ClassName.FADE} ${ClassName.SHOW}`)
|
128
|
+
}
|
129
|
+
|
130
|
+
// Private
|
131
|
+
|
132
|
+
_getContent() {
|
133
|
+
return this.element.getAttribute('data-content') ||
|
134
|
+
this.config.content
|
135
|
+
}
|
136
|
+
|
137
|
+
_cleanTipClass() {
|
138
|
+
const $tip = $(this.getTipElement())
|
139
|
+
const tabClass = $tip.attr('class').match(BSCLS_PREFIX_REGEX)
|
140
|
+
if (tabClass !== null && tabClass.length > 0) {
|
141
|
+
$tip.removeClass(tabClass.join(''))
|
142
|
+
}
|
143
|
+
}
|
144
|
+
|
145
|
+
// Static
|
146
|
+
|
147
|
+
static _jQueryInterface(config) {
|
148
|
+
return this.each(function () {
|
149
|
+
let data = $(this).data(DATA_KEY)
|
150
|
+
const _config = typeof config === 'object' ? config : null
|
151
|
+
|
152
|
+
if (!data && /dispose|hide/.test(config)) {
|
153
|
+
return
|
154
|
+
}
|
155
|
+
|
156
|
+
if (!data) {
|
157
|
+
data = new Popover(this, _config)
|
158
|
+
$(this).data(DATA_KEY, data)
|
159
|
+
}
|
160
|
+
|
161
|
+
if (typeof config === 'string') {
|
162
|
+
if (typeof data[config] === 'undefined') {
|
163
|
+
throw new TypeError(`No method named "${config}"`)
|
164
|
+
}
|
165
|
+
data[config]()
|
166
|
+
}
|
167
|
+
})
|
168
|
+
}
|
169
|
+
}
|
170
|
+
|
171
|
+
/**
|
172
|
+
* ------------------------------------------------------------------------
|
173
|
+
* jQuery
|
174
|
+
* ------------------------------------------------------------------------
|
175
|
+
*/
|
176
|
+
|
177
|
+
$.fn[NAME] = Popover._jQueryInterface
|
178
|
+
$.fn[NAME].Constructor = Popover
|
179
|
+
$.fn[NAME].noConflict = () => {
|
180
|
+
$.fn[NAME] = JQUERY_NO_CONFLICT
|
181
|
+
return Popover._jQueryInterface
|
182
|
+
}
|
183
|
+
|
184
|
+
export default Popover
|
@@ -0,0 +1,326 @@
|
|
1
|
+
/**
|
2
|
+
* --------------------------------------------------------------------------
|
3
|
+
* Bootstrap (v4.2.1): scrollspy.js
|
4
|
+
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
|
5
|
+
* --------------------------------------------------------------------------
|
6
|
+
*/
|
7
|
+
|
8
|
+
import $ from 'jquery'
|
9
|
+
import Util from './util'
|
10
|
+
|
11
|
+
/**
|
12
|
+
* ------------------------------------------------------------------------
|
13
|
+
* Constants
|
14
|
+
* ------------------------------------------------------------------------
|
15
|
+
*/
|
16
|
+
|
17
|
+
const NAME = 'scrollspy'
|
18
|
+
const VERSION = '4.2.1'
|
19
|
+
const DATA_KEY = 'bs.scrollspy'
|
20
|
+
const EVENT_KEY = `.${DATA_KEY}`
|
21
|
+
const DATA_API_KEY = '.data-api'
|
22
|
+
const JQUERY_NO_CONFLICT = $.fn[NAME]
|
23
|
+
|
24
|
+
const Default = {
|
25
|
+
offset : 10,
|
26
|
+
method : 'auto',
|
27
|
+
target : ''
|
28
|
+
}
|
29
|
+
|
30
|
+
const DefaultType = {
|
31
|
+
offset : 'number',
|
32
|
+
method : 'string',
|
33
|
+
target : '(string|element)'
|
34
|
+
}
|
35
|
+
|
36
|
+
const Event = {
|
37
|
+
ACTIVATE : `activate${EVENT_KEY}`,
|
38
|
+
SCROLL : `scroll${EVENT_KEY}`,
|
39
|
+
LOAD_DATA_API : `load${EVENT_KEY}${DATA_API_KEY}`
|
40
|
+
}
|
41
|
+
|
42
|
+
const ClassName = {
|
43
|
+
DROPDOWN_ITEM : 'dropdown-item',
|
44
|
+
DROPDOWN_MENU : 'dropdown-menu',
|
45
|
+
ACTIVE : 'active'
|
46
|
+
}
|
47
|
+
|
48
|
+
const Selector = {
|
49
|
+
DATA_SPY : '[data-spy="scroll"]',
|
50
|
+
ACTIVE : '.active',
|
51
|
+
NAV_LIST_GROUP : '.nav, .list-group',
|
52
|
+
NAV_LINKS : '.nav-link',
|
53
|
+
NAV_ITEMS : '.nav-item',
|
54
|
+
LIST_ITEMS : '.list-group-item',
|
55
|
+
DROPDOWN : '.dropdown',
|
56
|
+
DROPDOWN_ITEMS : '.dropdown-item',
|
57
|
+
DROPDOWN_TOGGLE : '.dropdown-toggle'
|
58
|
+
}
|
59
|
+
|
60
|
+
const OffsetMethod = {
|
61
|
+
OFFSET : 'offset',
|
62
|
+
POSITION : 'position'
|
63
|
+
}
|
64
|
+
|
65
|
+
/**
|
66
|
+
* ------------------------------------------------------------------------
|
67
|
+
* Class Definition
|
68
|
+
* ------------------------------------------------------------------------
|
69
|
+
*/
|
70
|
+
|
71
|
+
class ScrollSpy {
|
72
|
+
constructor(element, config) {
|
73
|
+
this._element = element
|
74
|
+
this._scrollElement = element.tagName === 'BODY' ? window : element
|
75
|
+
this._config = this._getConfig(config)
|
76
|
+
this._selector = `${this._config.target} ${Selector.NAV_LINKS},` +
|
77
|
+
`${this._config.target} ${Selector.LIST_ITEMS},` +
|
78
|
+
`${this._config.target} ${Selector.DROPDOWN_ITEMS}`
|
79
|
+
this._offsets = []
|
80
|
+
this._targets = []
|
81
|
+
this._activeTarget = null
|
82
|
+
this._scrollHeight = 0
|
83
|
+
|
84
|
+
$(this._scrollElement).on(Event.SCROLL, (event) => this._process(event))
|
85
|
+
|
86
|
+
this.refresh()
|
87
|
+
this._process()
|
88
|
+
}
|
89
|
+
|
90
|
+
// Getters
|
91
|
+
|
92
|
+
static get VERSION() {
|
93
|
+
return VERSION
|
94
|
+
}
|
95
|
+
|
96
|
+
static get Default() {
|
97
|
+
return Default
|
98
|
+
}
|
99
|
+
|
100
|
+
// Public
|
101
|
+
|
102
|
+
refresh() {
|
103
|
+
const autoMethod = this._scrollElement === this._scrollElement.window
|
104
|
+
? OffsetMethod.OFFSET : OffsetMethod.POSITION
|
105
|
+
|
106
|
+
const offsetMethod = this._config.method === 'auto'
|
107
|
+
? autoMethod : this._config.method
|
108
|
+
|
109
|
+
const offsetBase = offsetMethod === OffsetMethod.POSITION
|
110
|
+
? this._getScrollTop() : 0
|
111
|
+
|
112
|
+
this._offsets = []
|
113
|
+
this._targets = []
|
114
|
+
|
115
|
+
this._scrollHeight = this._getScrollHeight()
|
116
|
+
|
117
|
+
const targets = [].slice.call(document.querySelectorAll(this._selector))
|
118
|
+
|
119
|
+
targets
|
120
|
+
.map((element) => {
|
121
|
+
let target
|
122
|
+
const targetSelector = Util.getSelectorFromElement(element)
|
123
|
+
|
124
|
+
if (targetSelector) {
|
125
|
+
target = document.querySelector(targetSelector)
|
126
|
+
}
|
127
|
+
|
128
|
+
if (target) {
|
129
|
+
const targetBCR = target.getBoundingClientRect()
|
130
|
+
if (targetBCR.width || targetBCR.height) {
|
131
|
+
// TODO (fat): remove sketch reliance on jQuery position/offset
|
132
|
+
return [
|
133
|
+
$(target)[offsetMethod]().top + offsetBase,
|
134
|
+
targetSelector
|
135
|
+
]
|
136
|
+
}
|
137
|
+
}
|
138
|
+
return null
|
139
|
+
})
|
140
|
+
.filter((item) => item)
|
141
|
+
.sort((a, b) => a[0] - b[0])
|
142
|
+
.forEach((item) => {
|
143
|
+
this._offsets.push(item[0])
|
144
|
+
this._targets.push(item[1])
|
145
|
+
})
|
146
|
+
}
|
147
|
+
|
148
|
+
dispose() {
|
149
|
+
$.removeData(this._element, DATA_KEY)
|
150
|
+
$(this._scrollElement).off(EVENT_KEY)
|
151
|
+
|
152
|
+
this._element = null
|
153
|
+
this._scrollElement = null
|
154
|
+
this._config = null
|
155
|
+
this._selector = null
|
156
|
+
this._offsets = null
|
157
|
+
this._targets = null
|
158
|
+
this._activeTarget = null
|
159
|
+
this._scrollHeight = null
|
160
|
+
}
|
161
|
+
|
162
|
+
// Private
|
163
|
+
|
164
|
+
_getConfig(config) {
|
165
|
+
config = {
|
166
|
+
...Default,
|
167
|
+
...typeof config === 'object' && config ? config : {}
|
168
|
+
}
|
169
|
+
|
170
|
+
if (typeof config.target !== 'string') {
|
171
|
+
let id = $(config.target).attr('id')
|
172
|
+
if (!id) {
|
173
|
+
id = Util.getUID(NAME)
|
174
|
+
$(config.target).attr('id', id)
|
175
|
+
}
|
176
|
+
config.target = `#${id}`
|
177
|
+
}
|
178
|
+
|
179
|
+
Util.typeCheckConfig(NAME, config, DefaultType)
|
180
|
+
|
181
|
+
return config
|
182
|
+
}
|
183
|
+
|
184
|
+
_getScrollTop() {
|
185
|
+
return this._scrollElement === window
|
186
|
+
? this._scrollElement.pageYOffset : this._scrollElement.scrollTop
|
187
|
+
}
|
188
|
+
|
189
|
+
_getScrollHeight() {
|
190
|
+
return this._scrollElement.scrollHeight || Math.max(
|
191
|
+
document.body.scrollHeight,
|
192
|
+
document.documentElement.scrollHeight
|
193
|
+
)
|
194
|
+
}
|
195
|
+
|
196
|
+
_getOffsetHeight() {
|
197
|
+
return this._scrollElement === window
|
198
|
+
? window.innerHeight : this._scrollElement.getBoundingClientRect().height
|
199
|
+
}
|
200
|
+
|
201
|
+
_process() {
|
202
|
+
const scrollTop = this._getScrollTop() + this._config.offset
|
203
|
+
const scrollHeight = this._getScrollHeight()
|
204
|
+
const maxScroll = this._config.offset +
|
205
|
+
scrollHeight -
|
206
|
+
this._getOffsetHeight()
|
207
|
+
|
208
|
+
if (this._scrollHeight !== scrollHeight) {
|
209
|
+
this.refresh()
|
210
|
+
}
|
211
|
+
|
212
|
+
if (scrollTop >= maxScroll) {
|
213
|
+
const target = this._targets[this._targets.length - 1]
|
214
|
+
|
215
|
+
if (this._activeTarget !== target) {
|
216
|
+
this._activate(target)
|
217
|
+
}
|
218
|
+
return
|
219
|
+
}
|
220
|
+
|
221
|
+
if (this._activeTarget && scrollTop < this._offsets[0] && this._offsets[0] > 0) {
|
222
|
+
this._activeTarget = null
|
223
|
+
this._clear()
|
224
|
+
return
|
225
|
+
}
|
226
|
+
|
227
|
+
const offsetLength = this._offsets.length
|
228
|
+
for (let i = offsetLength; i--;) {
|
229
|
+
const isActiveTarget = this._activeTarget !== this._targets[i] &&
|
230
|
+
scrollTop >= this._offsets[i] &&
|
231
|
+
(typeof this._offsets[i + 1] === 'undefined' ||
|
232
|
+
scrollTop < this._offsets[i + 1])
|
233
|
+
|
234
|
+
if (isActiveTarget) {
|
235
|
+
this._activate(this._targets[i])
|
236
|
+
}
|
237
|
+
}
|
238
|
+
}
|
239
|
+
|
240
|
+
_activate(target) {
|
241
|
+
this._activeTarget = target
|
242
|
+
|
243
|
+
this._clear()
|
244
|
+
|
245
|
+
const queries = this._selector
|
246
|
+
.split(',')
|
247
|
+
.map((selector) => `${selector}[data-target="${target}"],${selector}[href="${target}"]`)
|
248
|
+
|
249
|
+
const $link = $([].slice.call(document.querySelectorAll(queries.join(','))))
|
250
|
+
|
251
|
+
if ($link.hasClass(ClassName.DROPDOWN_ITEM)) {
|
252
|
+
$link.closest(Selector.DROPDOWN).find(Selector.DROPDOWN_TOGGLE).addClass(ClassName.ACTIVE)
|
253
|
+
$link.addClass(ClassName.ACTIVE)
|
254
|
+
} else {
|
255
|
+
// Set triggered link as active
|
256
|
+
$link.addClass(ClassName.ACTIVE)
|
257
|
+
// Set triggered links parents as active
|
258
|
+
// With both <ul> and <nav> markup a parent is the previous sibling of any nav ancestor
|
259
|
+
$link.parents(Selector.NAV_LIST_GROUP).prev(`${Selector.NAV_LINKS}, ${Selector.LIST_ITEMS}`).addClass(ClassName.ACTIVE)
|
260
|
+
// Handle special case when .nav-link is inside .nav-item
|
261
|
+
$link.parents(Selector.NAV_LIST_GROUP).prev(Selector.NAV_ITEMS).children(Selector.NAV_LINKS).addClass(ClassName.ACTIVE)
|
262
|
+
}
|
263
|
+
|
264
|
+
$(this._scrollElement).trigger(Event.ACTIVATE, {
|
265
|
+
relatedTarget: target
|
266
|
+
})
|
267
|
+
}
|
268
|
+
|
269
|
+
_clear() {
|
270
|
+
[].slice.call(document.querySelectorAll(this._selector))
|
271
|
+
.filter((node) => node.classList.contains(ClassName.ACTIVE))
|
272
|
+
.forEach((node) => node.classList.remove(ClassName.ACTIVE))
|
273
|
+
}
|
274
|
+
|
275
|
+
// Static
|
276
|
+
|
277
|
+
static _jQueryInterface(config) {
|
278
|
+
return this.each(function () {
|
279
|
+
let data = $(this).data(DATA_KEY)
|
280
|
+
const _config = typeof config === 'object' && config
|
281
|
+
|
282
|
+
if (!data) {
|
283
|
+
data = new ScrollSpy(this, _config)
|
284
|
+
$(this).data(DATA_KEY, data)
|
285
|
+
}
|
286
|
+
|
287
|
+
if (typeof config === 'string') {
|
288
|
+
if (typeof data[config] === 'undefined') {
|
289
|
+
throw new TypeError(`No method named "${config}"`)
|
290
|
+
}
|
291
|
+
data[config]()
|
292
|
+
}
|
293
|
+
})
|
294
|
+
}
|
295
|
+
}
|
296
|
+
|
297
|
+
/**
|
298
|
+
* ------------------------------------------------------------------------
|
299
|
+
* Data Api implementation
|
300
|
+
* ------------------------------------------------------------------------
|
301
|
+
*/
|
302
|
+
|
303
|
+
$(window).on(Event.LOAD_DATA_API, () => {
|
304
|
+
const scrollSpys = [].slice.call(document.querySelectorAll(Selector.DATA_SPY))
|
305
|
+
const scrollSpysLength = scrollSpys.length
|
306
|
+
|
307
|
+
for (let i = scrollSpysLength; i--;) {
|
308
|
+
const $spy = $(scrollSpys[i])
|
309
|
+
ScrollSpy._jQueryInterface.call($spy, $spy.data())
|
310
|
+
}
|
311
|
+
})
|
312
|
+
|
313
|
+
/**
|
314
|
+
* ------------------------------------------------------------------------
|
315
|
+
* jQuery
|
316
|
+
* ------------------------------------------------------------------------
|
317
|
+
*/
|
318
|
+
|
319
|
+
$.fn[NAME] = ScrollSpy._jQueryInterface
|
320
|
+
$.fn[NAME].Constructor = ScrollSpy
|
321
|
+
$.fn[NAME].noConflict = () => {
|
322
|
+
$.fn[NAME] = JQUERY_NO_CONFLICT
|
323
|
+
return ScrollSpy._jQueryInterface
|
324
|
+
}
|
325
|
+
|
326
|
+
export default ScrollSpy
|