middleman-hashicorp 0.3.30 → 0.3.31
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/assets/javascripts/hashicorp/analytics.js +37 -0
- data/lib/middleman-hashicorp/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b89d166a23b94b6b828588e86f2ce55a83cf4d02b427f723f43056be31d6d487
|
4
|
+
data.tar.gz: 3978068b8d6130bab1c140a9e25fa9a3fc426216560a42849453814ec3b71907
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d8dd053be52f4e46c1427ec8491955b9d3dbfd94611de4f47e13307829cd245cbf306378e77c11e5d22deb2ccd42be039419c9b19c87dadc40ac4617233e8ee
|
7
|
+
data.tar.gz: 2eaa402d56f7a485e0dc1079155ed9e223668220953a926f4db582e453daa97bba95fc17a5b9f74c6324de32133a163139df8119c34da7f29555bfc6aed486b7
|
@@ -0,0 +1,37 @@
|
|
1
|
+
/**
|
2
|
+
* Wrapper for segment's track function that will track multiple elements,
|
3
|
+
* normalize parameters, and easily switch between tracking links or events.
|
4
|
+
* @param {String} selector - query selector, multi element compatible
|
5
|
+
* @param {Function} cb - optional function that should return params, and will receive the element as a parameter
|
6
|
+
* @param {Boolean} [link=false] - if true, tracks a link click
|
7
|
+
*/
|
8
|
+
function track(selector, cb, link = false) {
|
9
|
+
each(document.querySelectorAll(selector), el => {
|
10
|
+
var params = cb
|
11
|
+
if (typeof cb === 'function') params = cb(el)
|
12
|
+
var event = params.event
|
13
|
+
delete params.event
|
14
|
+
if (link) {
|
15
|
+
analytics.trackLink(el, event, params)
|
16
|
+
} else {
|
17
|
+
el.addEventListener('click', function() {
|
18
|
+
analytics.track(event, params)
|
19
|
+
})
|
20
|
+
}
|
21
|
+
})
|
22
|
+
}
|
23
|
+
|
24
|
+
/**
|
25
|
+
* Iterates through a NodeList, not built-in for all browsers.
|
26
|
+
* (https://developer.mozilla.org/en-US/docs/Web/API/NodeList)
|
27
|
+
* @param {NodeList} list a NodeList instance
|
28
|
+
* @param {Function} cb a function to execute for each node
|
29
|
+
*/
|
30
|
+
function each(list, cb) {
|
31
|
+
for (let i = 0; i < list.length; i++) cb(list[i], i)
|
32
|
+
}
|
33
|
+
|
34
|
+
// Expose as commonjs for module bundlers if needed
|
35
|
+
if (module && module.exports) {
|
36
|
+
module.exports = { track }
|
37
|
+
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: middleman-hashicorp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.31
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Seth Vargo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-03-
|
11
|
+
date: 2018-03-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: middleman
|
@@ -191,6 +191,7 @@ files:
|
|
191
191
|
- assets/images/mega-nav/logo-vagrant.svg
|
192
192
|
- assets/images/mega-nav/logo-vault.svg
|
193
193
|
- assets/javascripts/bootstrap.js
|
194
|
+
- assets/javascripts/hashicorp/analytics.js
|
194
195
|
- assets/javascripts/hashicorp/mega-nav.js
|
195
196
|
- assets/javascripts/hashicorp/sidebar.js
|
196
197
|
- assets/javascripts/ie-compat.js
|