fleetio_spark 0.2.28 → 0.2.29
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/spark/_stack.js +1 -0
- data/app/assets/javascripts/spark/components/nav/_tree.js +56 -30
- data/app/assets/stylesheets/spark/components/nav/tree/_group.scss +2 -2
- data/app/helpers/spark/menu_helper.rb +0 -1
- data/app/helpers/spark/nav_menu_helper.rb +1 -1
- data/lib/fleetio_spark/version.rb +1 -1
- data/public/{code-0.2.28.js → code-0.2.29.js} +1 -1
- data/public/{code-0.2.28.js.gz → code-0.2.29.js.gz} +0 -0
- data/public/{code-0.2.28.js.map → code-0.2.29.js.map} +1 -1
- data/public/{spark-0.2.28.css → spark-0.2.29.css} +1 -1
- data/public/{spark-0.2.28.css.gz → spark-0.2.29.css.gz} +0 -0
- data/public/{spark-0.2.28.js → spark-0.2.29.js} +2 -2
- data/public/spark-0.2.29.js.gz +0 -0
- data/public/spark-0.2.29.js.map +1 -0
- metadata +10 -12
- data/public/code-0.2.27.js +0 -17648
- data/public/spark-0.2.27.js +0 -4591
- data/public/spark-0.2.28.js.gz +0 -0
- data/public/spark-0.2.28.js.map +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3640eeaf1e8c576f9ba70590de9dd65808b37b9222915ef949d3681cfc2df49b
|
4
|
+
data.tar.gz: b3845797d1b2a9dea6bebc9392a96e820cdb9d97473e49f428fa00c689f866ca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0dd3669666d16c9c9fd90c60c7ccd486ac6793645107d29d83ca8594aee1e8d687951fcf3b38348ea78ced5fd33b30d54fb8398c79cd49b68bc044f36f28ab6f
|
7
|
+
data.tar.gz: 1047c7d294fbe1b0e9c234cdef2bf6f6f3ef86111102eac9ef463de2cd1d00250578a9600374e5eb2d5beab22cd12316703c70a488b00de00df47b66deeecebe
|
@@ -246,6 +246,7 @@ function navClick(event) {
|
|
246
246
|
}
|
247
247
|
|
248
248
|
function navKey(event) {
|
249
|
+
// Find the active panel in the stack where the navigation event should be triggered.
|
249
250
|
var panel = event.currentTarget.closest('[data-stack="root"]').querySelector('[data-stack-index][aria-hidden="false"]')
|
250
251
|
if (!panel) { return }
|
251
252
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
// Purpose: Toggles expansion of tree nav and stores cookies to retain state
|
2
2
|
//
|
3
|
-
//
|
3
|
+
// For Cookies to be set:
|
4
4
|
// - Trees must have a [data-tree='tree-key']
|
5
5
|
// - Nodes are named by [data-node='node-name']
|
6
6
|
//
|
@@ -12,7 +12,7 @@ var toolbox = require('@spark-engine/toolbox'),
|
|
12
12
|
cookie = require('../../_cookie'),
|
13
13
|
Event = require('@spark-engine/event')
|
14
14
|
|
15
|
-
function setCookie
|
15
|
+
function setCookie(node) {
|
16
16
|
if (node.dataset.node) {
|
17
17
|
var tree = node.closest('[data-tree]')
|
18
18
|
if (tree) {
|
@@ -23,30 +23,31 @@ function setCookie (node) {
|
|
23
23
|
}
|
24
24
|
}
|
25
25
|
|
26
|
-
function click
|
26
|
+
function click(event) {
|
27
27
|
toggleNode(event.currentTarget)
|
28
28
|
}
|
29
29
|
|
30
|
+
// Expand or collapse the current tree node
|
30
31
|
function toggleNode(target) {
|
31
|
-
parent = target.
|
32
|
-
|
32
|
+
var parent = target.closest('[aria-expanded]'),
|
33
|
+
expanded = parent.getAttribute('aria-expanded') == 'true'
|
33
34
|
|
34
35
|
// Add a classname to indicate that it was manually triggered
|
35
36
|
// This allows for animating interactions, but not other attribute changes
|
36
37
|
parent.classList.add('triggered')
|
37
|
-
toggleExpansion(parent, expanded
|
38
|
-
select(target)
|
38
|
+
toggleExpansion(parent, !expanded)
|
39
39
|
|
40
40
|
setCookie(parent)
|
41
41
|
}
|
42
42
|
|
43
|
+
// Set aria-expanded and toggle tabindex values based on expansion
|
43
44
|
function toggleExpansion(el, expanded) {
|
44
45
|
el.setAttribute('aria-expanded', expanded)
|
45
46
|
setupItemTabIndex(el)
|
46
47
|
}
|
47
48
|
|
48
49
|
// Sets tree nav state based off of cookies
|
49
|
-
function restoreNav
|
50
|
+
function restoreNav() {
|
50
51
|
toolbox.each(document.querySelectorAll('[data-tree]'), function(tree) {
|
51
52
|
var key = tree.dataset.tree
|
52
53
|
if (key) {
|
@@ -65,90 +66,115 @@ function restoreNav () {
|
|
65
66
|
})
|
66
67
|
}
|
67
68
|
|
69
|
+
// Enables keyboard navigation of a nav tree
|
70
|
+
//
|
71
|
+
// `space` - toggles tree node triggers
|
72
|
+
// `right arrow` - opens nodes and navigates inward
|
73
|
+
// `left arrow` - closes nodes and navigates outward
|
74
|
+
// `up arrow` - moves to previous visible element
|
75
|
+
// `down arrow` - moves to next visible element
|
76
|
+
//
|
68
77
|
function navigateTree(event) {
|
69
78
|
var item = document.activeElement
|
70
79
|
if (!item) return
|
71
80
|
|
81
|
+
// Find the parent tree item
|
72
82
|
var tree = item.closest('[role="tree"]')
|
73
83
|
if (!tree) return
|
74
84
|
|
75
|
-
|
76
|
-
|
77
|
-
if (trigger) {
|
85
|
+
// Is the item a trigger which opens nodes?
|
86
|
+
if (item.matches('.tree-trigger')) {
|
78
87
|
var expanded = item.parentElement.getAttribute('aria-expanded') != 'false'
|
79
88
|
|
89
|
+
// Space toggles node which trigger points to
|
80
90
|
if (Event.key.isPressed('space')) {
|
81
|
-
toggleNode(item)
|
82
91
|
event.preventDefault()
|
92
|
+
return toggleNode(item)
|
83
93
|
}
|
84
94
|
|
95
|
+
// Expand or move to the first item in the node
|
85
96
|
if (Event.key.isPressed('right')) {
|
86
97
|
event.preventDefault()
|
87
|
-
if (expanded) return
|
98
|
+
if (expanded) return focus(getNextItem(tree, item))
|
88
99
|
else return toggleNode(item)
|
89
100
|
}
|
90
101
|
|
102
|
+
// Collapse or move up the parent node
|
91
103
|
if (Event.key.isPressed('left')) {
|
92
104
|
event.preventDefault()
|
93
105
|
if (expanded) return toggleNode(item)
|
94
|
-
else return
|
106
|
+
else return focus(getUpwardItem(tree, item))
|
95
107
|
}
|
96
108
|
}
|
97
109
|
|
110
|
+
// Move to next visible item in the tree
|
98
111
|
if (Event.key.isPressed('down')) {
|
99
112
|
event.preventDefault()
|
100
|
-
|
113
|
+
focus(getNextItem(tree, item))
|
101
114
|
}
|
102
115
|
|
103
|
-
|
116
|
+
// Move to previous visible item in the tree
|
117
|
+
else if (Event.key.isPressed('up')) {
|
104
118
|
event.preventDefault()
|
105
|
-
|
119
|
+
focus(getPreviousItem(tree, item))
|
106
120
|
}
|
107
121
|
|
108
|
-
|
122
|
+
// Move outward in tree
|
123
|
+
else if (Event.key.isPressed('left')) {
|
109
124
|
event.preventDefault()
|
110
|
-
|
125
|
+
focus(getUpwardItem(tree, item))
|
111
126
|
}
|
112
127
|
}
|
113
128
|
|
114
|
-
|
115
|
-
|
116
|
-
el.focus()
|
129
|
+
// Focus on element (if able)
|
130
|
+
function focus(el) {
|
131
|
+
if (el) el.focus()
|
117
132
|
}
|
118
133
|
|
134
|
+
// Find next focusable item
|
119
135
|
function getNextItem(tree, item) {
|
120
|
-
items =
|
136
|
+
items = getFocusableItems(tree)
|
121
137
|
return items[ items.indexOf(item) + 1]
|
122
138
|
}
|
123
139
|
|
140
|
+
// Find previous focusable item
|
124
141
|
function getPreviousItem(tree, item) {
|
125
|
-
items =
|
142
|
+
items = getFocusableItems(tree)
|
126
143
|
return items[ items.indexOf(item) - 1]
|
127
144
|
}
|
128
145
|
|
146
|
+
// Walk up the tree to the tree trigger
|
129
147
|
function getUpwardItem(tree, item) {
|
130
148
|
var upward = item.parentElement.closest('[aria-expanded]')
|
131
149
|
if (upward) return upward.querySelector('.tree-trigger')
|
132
150
|
}
|
133
151
|
|
134
|
-
|
135
|
-
|
152
|
+
// Find all focusable items in a nav tree
|
153
|
+
function getFocusableItems(tree) {
|
154
|
+
// Filter out items in collapsed nodes
|
155
|
+
return Array.prototype.filter.call(tree.querySelectorAll('a, [tabindex]'), function(el) {
|
136
156
|
return !el.closest('[aria-expanded="false"] [role="group"]')
|
137
157
|
})
|
138
158
|
}
|
139
159
|
|
140
|
-
//
|
160
|
+
// Ensure hidden items are not focasable
|
141
161
|
function setupItemTabIndex(tree) {
|
142
|
-
toolbox.each(tree.querySelectorAll('a'), function(el) {
|
162
|
+
toolbox.each(tree.querySelectorAll('a, [tabindex]'), function(el) {
|
143
163
|
if (el.closest('[aria-expanded="false"] [role="group"]')) {
|
144
164
|
el.setAttribute('tabindex', -1)
|
145
165
|
} else {
|
146
|
-
|
166
|
+
// Don't set a tabindex for anchor elements
|
167
|
+
// They already participate in tabindex and tabindex=0
|
168
|
+
// will change their click behavior
|
169
|
+
if (el.matches('a')) {
|
170
|
+
el.removeAttribute('tabindex')
|
171
|
+
} else {
|
172
|
+
el.setAttribute('tabindex', 0)
|
173
|
+
}
|
147
174
|
}
|
148
175
|
})
|
149
176
|
}
|
150
177
|
|
151
|
-
|
152
178
|
function setup() {
|
153
179
|
Event.ready(function() {
|
154
180
|
|
@@ -65,7 +65,7 @@ module Spark
|
|
65
65
|
options = add_class( options, classes )
|
66
66
|
|
67
67
|
content_tag( config[:item_tag], options ) do
|
68
|
-
concat link_to(
|
68
|
+
concat link_to("#", class: config[:base_class] + '-item'){
|
69
69
|
concat name.call
|
70
70
|
concat use_svg( 'chevron-down', class: 'expand-icon' )
|
71
71
|
}
|