jsmenubuilder 0.3.0 → 0.3.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0eba4d6420ecbc1a40bc3340c9b65dce19df5b09ed27d13ad93bfa0381b66ac9
4
- data.tar.gz: f5b93fc21a025c39b9bb194a3e54c1525fd57295635986642be16f96046c215c
3
+ metadata.gz: 390f2055daa29b9c5b8af617ef19102a9d06e5b2a688bc5cf5c17df27a5c7cf7
4
+ data.tar.gz: 83f06038310c93648c578c4635d31da97b515d1e3dca1f3625f739257b7111ac
5
5
  SHA512:
6
- metadata.gz: a597c62a7d66619d306b3ab0266b81c4b8edfd4ba991e88aa6bbc6d0a7d183078dbf7948f9245a8fc0b90775c20d9324322873d6ed41811e4a04008765bffe27
7
- data.tar.gz: 1b5ba4cf5e40745d0fdb5b2a4c17a6dcde6028a36d740a7b6c3a0d72f87086299090b5e31e0fb1dc3f8ecc02ac7dbabc962ee74969e81cd6f6263dc8ea23376e
6
+ metadata.gz: 49c3173c496d39ac8f5be2652892bba3ed418f9bf1ddc85df27cafe9283a51efa690828343f7679aad1febea03ee261d85733a0cc2d0400f164583e978698767
7
+ data.tar.gz: 2a0ac728386fc75241f7776cf044bb521255c731b8e9f834347a34c154fa20d0b93733423d9f81b806da5d4c22bd626f2b62607b640ec4962dbe107ccbf72b53
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -6,6 +6,7 @@ require 'rexle'
6
6
  require 'rxfhelper'
7
7
  require 'rexle-builder'
8
8
 
9
+
9
10
  class JsMenuBuilder
10
11
  using ColouredText
11
12
 
@@ -189,7 +190,109 @@ STICKY_NAVBAR_CSS =<<EOF
189
190
  .sticky + .content {
190
191
  padding-top: 60px;
191
192
  }
193
+ /* see https://stackoverflow.com/questions/10732690/offsetting-an-html-anchor-to-adjust-for-fixed-header */
194
+ .anchor {
195
+ background-color: transparent;
196
+ padding-top: 70px;
197
+ margin-top: -70px;
198
+ display: block;
199
+ }
200
+
201
+ h2.anchor {
202
+ background-color: transparent;
203
+ padding-top: 60px;
204
+ margin-top: 0px;
205
+ }
206
+
207
+ EOF
208
+
209
+ VERTICAL_MENU_CSS =<<EOF
210
+ .vertical-menu {
211
+ width: 200px; /* Set a width if you like */
212
+ }
213
+
214
+ .vertical-menu a {
215
+ background-color: #eee; /* Grey background color */
216
+ color: black; /* Black text color */
217
+ display: block; /* Make the links appear below each other */
218
+ padding: 12px; /* Add some padding */
219
+ text-decoration: none; /* Remove underline from links */
220
+ }
221
+
222
+ .vertical-menu a:hover {
223
+ background-color: #ccc; /* Dark grey background on mouse-over */
224
+ }
225
+
226
+ .vertical-menu a.active {
227
+ background-color: #4CAF50; /* Add a green color to the "active/current" link */
228
+ color: white;
229
+ }
230
+ EOF
231
+
232
+ FIXED_MENU_CSS =<<EOF
233
+ /* The navigation bar */
234
+ .navbar {
235
+ overflow: hidden;
236
+ background-color: #333;
237
+ position: fixed; /* Set the navbar to fixed position */
238
+ top: 0; /* Position the navbar at the top of the page */
239
+ width: 100%; /* Full width */
240
+ }
241
+
242
+ /* Links inside the navbar */
243
+ .navbar a {
244
+ float: left;
245
+ display: block;
246
+ color: #f2f2f2;
247
+ text-align: center;
248
+ padding: 14px 16px;
249
+ text-decoration: none;
250
+ }
251
+
252
+ /* Change background on mouse-over */
253
+ .navbar a:hover {
254
+ background: #ddd;
255
+ color: black;
256
+ }
192
257
 
258
+ /* Main content */
259
+ .main {
260
+ margin-top: 30px; /* Add a top margin to avoid content overlay */
261
+ }
262
+ EOF
263
+
264
+ BREADCRUMB_CSS =<<EOF
265
+ /* Style the list */
266
+ ul.breadcrumb {
267
+ padding: 10px 16px;
268
+ list-style: none;
269
+ background-color: #eee;
270
+ }
271
+
272
+ /* Display list items side by side */
273
+ ul.breadcrumb li {
274
+ display: inline;
275
+ font-size: 18px;
276
+ }
277
+
278
+ /* Add a slash symbol (/) before/behind each list item */
279
+ ul.breadcrumb li+li:before {
280
+ padding: 8px;
281
+ color: black;
282
+ content: "/\\00a0";
283
+ }
284
+
285
+ /* Add a color to all links inside the list */
286
+ ul.breadcrumb li a {
287
+ color: #0275d8;
288
+ text-decoration: none;
289
+ }
290
+
291
+ /* Add a color on mouse-over */
292
+ ul.breadcrumb li a:hover {
293
+ color: #01447e;
294
+ text-decoration: underline;
295
+ }
193
296
  EOF
194
297
 
195
298
  FULL_PAGE_TABS_JS =<<EOF
@@ -266,6 +369,11 @@ function myFunction() {
266
369
  }
267
370
  EOF
268
371
 
372
+ VERTICAL_MENU_JS = ''
373
+ FIXED_MENU_JS = ''
374
+ BREADCRUMB_JS = ''
375
+
376
+
269
377
  attr_reader :html, :css, :js
270
378
 
271
379
  def initialize(unknown=nil, options={})
@@ -290,7 +398,8 @@ EOF
290
398
  options = unknown
291
399
  end
292
400
 
293
- @types = %i(tabs full_page_tabs accordion sticky_navbar)
401
+ @types = %i(tabs full_page_tabs accordion sticky_navbar
402
+ vertical_menu fixed_menu breadcrumb)
294
403
 
295
404
  build(type, options) if type
296
405
 
@@ -409,7 +518,7 @@ EOF
409
518
  puts 'inside build_h'.info if @debug
410
519
 
411
520
  h = doc.root.xpath('tag').inject({}) do |r,e|
412
- r.merge(e.attributes[:title] => e.children.join.strip)
521
+ r.merge(e.attributes[:title] => [e.children.join.strip, e.attributes[:class].join(' ')])
413
522
  end
414
523
 
415
524
  puts ('build_h: ' + h.inspect).debug if @debug
@@ -441,8 +550,9 @@ EOF
441
550
 
442
551
  a = RexleBuilder.build do |xml|
443
552
  xml.tags({mode: type}) do
444
- entries.each do |heading, content|
445
- xml.tag({title: heading}, content )
553
+ entries.each do |heading, value|
554
+ content, klass = value
555
+ xml.tag({title: heading, class: klass}, content )
446
556
  end
447
557
  end
448
558
  end
@@ -545,7 +655,7 @@ EOF
545
655
 
546
656
  panels = opt[:accordion]
547
657
 
548
- @h = h = panels.group_by {|key, value| key.upcase[0]}
658
+ @h = h = panels.group_by {|key, value| key.upcase[0]}
549
659
 
550
660
  debug = @debug
551
661
 
@@ -555,16 +665,23 @@ EOF
555
665
 
556
666
  xml.html do
557
667
 
558
- h.each do |char, rows|
668
+ h.sort.each do |char, rows|
559
669
 
560
- xml.h2({id: char.downcase}, char)
670
+ xml.h2({class: 'anchor', id: char.downcase}, char)
561
671
 
562
- rows.each do |heading, inner_html|
672
+ rows.each do |heading, value|
673
+
674
+ puts 'value: ' + value.inspect if @debug
675
+ inner_html, attrclass = value
676
+
563
677
  puts 'inner_html: ' + inner_html.inspect if debug
564
- xml.a({name: heading.downcase.gsub(/\W/,'-').gsub(/-{2,}/,'-')\
565
- .gsub(/^-|-$/,'')})
678
+ xml.a({class: 'anchor', name: heading.downcase.gsub(/\W/,'-')\
679
+ .gsub(/-{2,}/,'-').gsub(/^-|-$/,'')})
566
680
  xml.button({class:'accordion'}, heading.to_s)
567
- xml.div({class:'panel'}, inner_html)
681
+
682
+ s = 'panel'
683
+ s += ' ' + attrclass if attrclass
684
+ xml.div({class: s}, inner_html)
568
685
 
569
686
  end
570
687
  end
@@ -586,7 +703,7 @@ EOF
586
703
 
587
704
  opt[:html]
588
705
 
589
- elsif opt[:sticky_navbar]
706
+ elsif opt[:items]
590
707
 
591
708
  RexleBuilder.build do |xml|
592
709
 
@@ -594,7 +711,7 @@ EOF
594
711
 
595
712
  xml.div(id: 'navbar') do
596
713
 
597
- opt[:sticky_navbar].each do |title, href|
714
+ opt[:items].each do |title, href|
598
715
  xml.a({href: href}, title)
599
716
  end
600
717
 
@@ -610,6 +727,119 @@ EOF
610
727
  return doc
611
728
 
612
729
 
730
+ end
731
+
732
+ def vertical_menu(opt={})
733
+
734
+ puts 'inside vertical_navbar' if @debug
735
+
736
+ navhtml = if opt[:html] then
737
+
738
+ opt[:html]
739
+
740
+ elsif opt[:items]
741
+
742
+ RexleBuilder.build do |xml|
743
+
744
+ xml.html do
745
+
746
+ xml.div(class: 'vertical-menu') do
747
+
748
+ opt[:items].each do |title, href|
749
+ xml.a({href: href}, title)
750
+ end
751
+
752
+ end
753
+
754
+ end
755
+ end
756
+ end
757
+
758
+ doc = Rexle.new(navhtml)
759
+ puts 'doc: ' + doc.xml.inspect if @debug
760
+
761
+ return doc
762
+
763
+
764
+ end
765
+
766
+ def fixed_menu(opt={})
767
+
768
+ puts 'inside fixed_menu' if @debug
769
+
770
+ navhtml = if opt[:html] then
771
+
772
+ opt[:html]
773
+
774
+ elsif opt[:items]
775
+
776
+ RexleBuilder.build do |xml|
777
+
778
+ xml.html do
779
+
780
+ xml.div(class: 'navbar') do
781
+
782
+ opt[:items].each do |title, href|
783
+ xml.a({href: href}, title)
784
+ end
785
+
786
+ end
787
+
788
+ xml.div(class: 'main') do
789
+
790
+ end
791
+
792
+ end
793
+ end
794
+ end
795
+
796
+ doc = Rexle.new(navhtml)
797
+ puts 'doc: ' + doc.xml.inspect if @debug
798
+
799
+ return doc
800
+
801
+
613
802
  end
803
+
804
+ def breadcrumb(opt={})
805
+
806
+ puts 'inside breadcrumb' if @debug
807
+
808
+ navhtml = if opt[:html] then
809
+
810
+ opt[:html]
811
+
812
+ elsif opt[:items]
813
+
814
+ RexleBuilder.build do |xml|
815
+
816
+ xml.html do
817
+
818
+ xml.ul(class: 'breadcrumb') do
819
+
820
+ opt[:items][0..-2].each do |title, href|
821
+ xml.li do
822
+ xml.a({href: href}, title)
823
+ end
824
+ end
825
+
826
+ title = opt[:items][-1].first
827
+ xml.li title
828
+
829
+ end
830
+
831
+
832
+
833
+ end
834
+ end
835
+ end
836
+
837
+ doc = Rexle.new(navhtml)
838
+ puts 'doc: ' + doc.xml.inspect if @debug
839
+
840
+ return doc
841
+
842
+
843
+ end
614
844
 
615
845
  end
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.3.0
4
+ version: 0.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -11,31 +11,31 @@ cert_chain:
11
11
  - |
12
12
  -----B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apVyi8IiiPeJ
31
- Nv948ScbwvKxuS/Kse91M9iT5Enf+VvD7IbHwyc37Yj32f4bAj/eM3n8BT434cuB
32
- J87qb8cHPcBKBJlzAjqmv7B8TTdUMiUwbf0Yzaa145GXYjIZU8DYAXZqJqvDOity
33
- HqT8Qpv1d/qgsBRSZuzR5/9+GaGsig7+nHjdhG8pW/YZsQGbGGVG+lLUJBsZjO4B
34
- XF6C/51+tUiA0WG6T2/20uNe8aN+CEMxBoTBuzQgO55w6d3utEk4X2+yKuktQ/GR
35
- haYJPATx3zs+9jtQoiFg+keM0CPYk/5LgCv9jxxzQcSS20C8O9MWRVvYfIr47ak7
36
- yXrDPmRvbJLTNjDv6Tkg3vU6
28
+ BgkqhkiG9w0BAQsFAAOCAYEAB3veD2cecAEwrICnXn9pYFc+eC9fIMwyyboP1jgf
29
+ uoxV7buwI6jKolHBuGanDQdqFMUib2JrX0mKZ/9KZw4cCen8grmFRIRRGSooZZEt
30
+ F5wMy0Mte8+nVnhi8tBU5+0bwqR2USL9LKVoeDCyd6sxOlkffVqYZFRGQB3/K3o9
31
+ XaAfiwiXOcq1hYBPh76N/rcNUvjlON4WpoJbwGiREKsLgFXpExXloeUUo8EhCVs5
32
+ g5n20V75pNW/1y8jOxbrKq/M4uaJkyvFMc96ms/NO5Av1OO/GfFJmecuupUvi80E
33
+ yD+/vvvKT8C6A+7Luv70eCEqNC2kmI5k2FKlfkkfaHacRtDz4Ntzw+W216u2ewBB
34
+ 4DzeVtqMQq2g7T4xVjQRRwdBJkdERbyx4TD/2HNa6VNC/V8R5aVlKNyjjglPSC3P
35
+ stR9WM2Qrn9oxHHjgt05mQb9lgp7uGqcCvQoP82U8lJawp7oLLsO25kTe4Hj28T1
36
+ +BcAGJd5hR/dFCHvJ6rtQss3
37
37
  -----END CERTIFICATE-----
38
- date: 2020-02-24 00:00:00.000000000 Z
38
+ date: 2021-01-20 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: rexle
@@ -46,7 +46,7 @@ dependencies:
46
46
  version: '1.5'
47
47
  - - ">="
48
48
  - !ruby/object:Gem::Version
49
- version: 1.5.3
49
+ version: 1.5.9
50
50
  type: :runtime
51
51
  prerelease: false
52
52
  version_requirements: !ruby/object:Gem::Requirement
@@ -56,7 +56,7 @@ dependencies:
56
56
  version: '1.5'
57
57
  - - ">="
58
58
  - !ruby/object:Gem::Version
59
- version: 1.5.3
59
+ version: 1.5.9
60
60
  description:
61
61
  email: james@jamesrobertson.eu
62
62
  executables: []
@@ -83,7 +83,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
83
83
  - !ruby/object:Gem::Version
84
84
  version: '0'
85
85
  requirements: []
86
- rubygems_version: 3.0.3
86
+ rubyforge_project:
87
+ rubygems_version: 2.7.10
87
88
  signing_key:
88
89
  specification_version: 4
89
90
  summary: Generates HTML based tabs using HTML, CSS, and JavaScript.
metadata.gz.sig CHANGED
Binary file