jsmenubuilder 0.2.11 → 0.2.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/jsmenubuilder.rb +124 -10
- data.tar.gz.sig +0 -0
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1fdc2c1787fb134b36c6d883e8809b822cbff1642542d103c8e6b965464fd227
|
4
|
+
data.tar.gz: 33dd4cec053d48d5a47f2239d1d97f9428853c18ca79012a41c798c5fa239beb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 89fc1f800e9781ed67d488b65d78b1de8fac89c3bf9181200725e35295fcdceffe71ec1abb99800ad4ba64a708d1f4dec5c1536442b4e8d9cc0dd01c8ccbe784
|
7
|
+
data.tar.gz: 3c058822cbe2013afc605610b3c22f4f65745c8418e077de4523820cc0dd87f86068e04c9aa77b857abcecdfa4c53fe2112d7e0aa93f243cfd83785759b9731c
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/jsmenubuilder.rb
CHANGED
@@ -115,6 +115,9 @@ button.active {
|
|
115
115
|
EOF
|
116
116
|
|
117
117
|
ACCORDION_CSS = %q(
|
118
|
+
|
119
|
+
|
120
|
+
|
118
121
|
.accordion {
|
119
122
|
background-color: #eee;
|
120
123
|
color: #444;
|
@@ -153,6 +156,42 @@ ACCORDION_CSS = %q(
|
|
153
156
|
}
|
154
157
|
)
|
155
158
|
|
159
|
+
STICKY_NAVBAR_CSS =<<EOF
|
160
|
+
/* Style the navbar */
|
161
|
+
#navbar {
|
162
|
+
overflow: hidden;
|
163
|
+
background-color: #333;
|
164
|
+
}
|
165
|
+
|
166
|
+
/* Navbar links */
|
167
|
+
#navbar a {
|
168
|
+
float: left;
|
169
|
+
display: block;
|
170
|
+
color: #f2f2f2;
|
171
|
+
text-align: center;
|
172
|
+
padding: 14px;
|
173
|
+
text-decoration: none;
|
174
|
+
}
|
175
|
+
|
176
|
+
/* Page content */
|
177
|
+
.content {
|
178
|
+
padding: 16px;
|
179
|
+
}
|
180
|
+
|
181
|
+
/* The sticky class is added to the navbar with JS when it reaches its scroll position */
|
182
|
+
.sticky {
|
183
|
+
position: fixed;
|
184
|
+
top: 0;
|
185
|
+
width: 100%;
|
186
|
+
}
|
187
|
+
|
188
|
+
/* Add some top padding to the page content to prevent sudden quick movement (as the navigation bar gets a new position at the top of the page (position:fixed and top:0) */
|
189
|
+
.sticky + .content {
|
190
|
+
padding-top: 60px;
|
191
|
+
}
|
192
|
+
|
193
|
+
EOF
|
194
|
+
|
156
195
|
FULL_PAGE_TABS_JS =<<EOF
|
157
196
|
function openPage(pageName,elmnt) {
|
158
197
|
var i, tabcontent;
|
@@ -206,6 +245,26 @@ for (i = 0; i < acc.length; i++) {
|
|
206
245
|
|
207
246
|
EOF
|
208
247
|
|
248
|
+
STICKY_NAVBAR_JS =<<EOF
|
249
|
+
|
250
|
+
// When the user scrolls the page, execute myFunction
|
251
|
+
window.onscroll = function() {myFunction()};
|
252
|
+
|
253
|
+
// Get the navbar
|
254
|
+
var navbar = document.getElementById("navbar");
|
255
|
+
|
256
|
+
// Get the offset position of the navbar
|
257
|
+
var sticky = navbar.offsetTop;
|
258
|
+
|
259
|
+
// Add the sticky class to the navbar when you reach its scroll position. Remove "sticky" when you leave the scroll position
|
260
|
+
function myFunction() {
|
261
|
+
if (window.pageYOffset >= sticky) {
|
262
|
+
navbar.classList.add("sticky")
|
263
|
+
} else {
|
264
|
+
navbar.classList.remove("sticky");
|
265
|
+
}
|
266
|
+
}
|
267
|
+
EOF
|
209
268
|
|
210
269
|
attr_reader :html, :css, :js
|
211
270
|
|
@@ -231,7 +290,7 @@ EOF
|
|
231
290
|
options = unknown
|
232
291
|
end
|
233
292
|
|
234
|
-
@types = %i(tabs full_page_tabs accordion)
|
293
|
+
@types = %i(tabs full_page_tabs accordion sticky_navbar)
|
235
294
|
|
236
295
|
build(type, options) if type
|
237
296
|
|
@@ -366,6 +425,7 @@ EOF
|
|
366
425
|
headings = options[:headings]
|
367
426
|
headings.zip(headings.map {|heading| ['h3', {}, heading]}).to_h
|
368
427
|
else
|
428
|
+
return unless options.has_key?(type.to_sym)
|
369
429
|
options[type.to_sym]
|
370
430
|
end
|
371
431
|
|
@@ -473,18 +533,40 @@ EOF
|
|
473
533
|
|
474
534
|
def accordion(opt={})
|
475
535
|
|
476
|
-
|
536
|
+
puts ('opt: ' + opt.inspect).debug if @debug
|
537
|
+
|
538
|
+
panels = opt[:accordion]
|
539
|
+
|
540
|
+
h = panels.group_by {|key, value| key.upcase[0]}
|
541
|
+
|
477
542
|
debug = @debug
|
543
|
+
|
544
|
+
puts ('panels: ' + panels.inspect).debug if @debug
|
478
545
|
|
479
546
|
a = RexleBuilder.build do |xml|
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
547
|
+
|
548
|
+
xml.html do
|
549
|
+
|
550
|
+
xml.div(id: 'navbar') do
|
551
|
+
|
552
|
+
h.each do |char, _|
|
553
|
+
xml.a({href: '#' + char.downcase}, char)
|
554
|
+
end
|
555
|
+
|
556
|
+
end
|
557
|
+
|
558
|
+
h.each do |char, rows|
|
559
|
+
|
560
|
+
xml.h2({id: char.downcase}, char)
|
561
|
+
|
562
|
+
rows.each do |heading, inner_html|
|
563
|
+
puts 'inner_html: ' + inner_html.inspect if debug
|
564
|
+
xml.a({name: heading.downcase.gsub(/\W/,'-').gsub(/-{2,}/,'-')\
|
565
|
+
.gsub(/^-|-$/,'')})
|
566
|
+
xml.button({class:'accordion'}, heading.to_s)
|
567
|
+
xml.div({class:'panel'}, inner_html)
|
568
|
+
|
569
|
+
end
|
488
570
|
end
|
489
571
|
|
490
572
|
end
|
@@ -496,5 +578,37 @@ EOF
|
|
496
578
|
|
497
579
|
end
|
498
580
|
|
581
|
+
def sticky_navbar(opt={})
|
582
|
+
|
583
|
+
|
584
|
+
navhtml = if opt[:html] then
|
585
|
+
|
586
|
+
opt[:html]
|
587
|
+
|
588
|
+
elsif opt[:sticky_navbar]
|
589
|
+
|
590
|
+
RexleBuilder.build do |xml|
|
591
|
+
|
592
|
+
xml.html do
|
593
|
+
|
594
|
+
xml.div(id: 'navbar') do
|
595
|
+
|
596
|
+
h.each do |char, _|
|
597
|
+
xml.a({href: '#' + char.downcase}, char)
|
598
|
+
end
|
599
|
+
|
600
|
+
end
|
601
|
+
|
602
|
+
end
|
603
|
+
end
|
604
|
+
end
|
605
|
+
|
606
|
+
doc = Rexle.new(navhtml)
|
607
|
+
puts 'doc: ' + doc.xml.inspect if @debug
|
608
|
+
|
609
|
+
return doc
|
610
|
+
|
611
|
+
|
612
|
+
end
|
499
613
|
|
500
614
|
end
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jsmenubuilder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -35,7 +35,7 @@ cert_chain:
|
|
35
35
|
haYJPATx3zs+9jtQoiFg+keM0CPYk/5LgCv9jxxzQcSS20C8O9MWRVvYfIr47ak7
|
36
36
|
yXrDPmRvbJLTNjDv6Tkg3vU6
|
37
37
|
-----END CERTIFICATE-----
|
38
|
-
date: 2020-02-
|
38
|
+
date: 2020-02-23 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: rexle
|
metadata.gz.sig
CHANGED
Binary file
|