jsmenubuilder 0.1.0 → 0.1.1

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: c2d779db609c99fd6d02286ce9a4d3219b31abd8354695942ed0b08940d76f76
4
- data.tar.gz: 906184a64d92b74b605271b8092e95d89c59caf749be5d617ec3704d10bb7bc9
3
+ metadata.gz: 2232d7d7c417abc9c6b13cb8b5c6f1b8e8f4ce26e2c8faa00bcd73408807aa68
4
+ data.tar.gz: e24a782b2157968a45fe1c22074aac659df5b0fd5358713a6a4b7813b99adfb8
5
5
  SHA512:
6
- metadata.gz: c0d55d91b7d8b2c3cb7d63545f02cd92e37d3b23c0eca25b48b2f66a4707c8d644eed58cd9022fdd2f1455a9c613154844878d1da0401718550fb524f67206d2
7
- data.tar.gz: 6a676ecfca13e8839498ccbb75a45d2f531dd69f98616db45a40bd1c78b8c6e9990904249443d01d0924c071cca36c816aad9e974482a6239f3a0bd7055299eb
6
+ metadata.gz: 2e5cc9d72d5ee7489ce2ebc621259bced5dd4e7ca4b315331e24820aeb999e6133fd89e7a31fd3956435af47d1f850e99d275bab7124aee3e830655cbb5d093e
7
+ data.tar.gz: 375c158de22cb84b24c96b80e8bc0407016d38b0bafe7131577273899998700930dcb1621ffdcd266f76593f2feeaa0c69fa9466150ba1cf6d21e8fd842dc0e5
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/lib/jsmenubuilder.rb CHANGED
@@ -67,6 +67,8 @@ function openTab(evt, tabName) {
67
67
  evt.currentTarget.className += " active";
68
68
  }
69
69
 
70
+ // Get the element with id="defaultOpen" and click on it
71
+ document.getElementById("defaultOpen").click();
70
72
  EOF
71
73
 
72
74
 
@@ -122,8 +124,18 @@ EOF
122
124
 
123
125
  private
124
126
 
125
- def tabs(options={})
127
+ def tabs(opt={})
126
128
 
129
+ options = {active: '1'}.merge(opt)
130
+
131
+ tabs = if options[:headings] then
132
+ headings = options[:headings]
133
+ headings.zip(headings.map {|heading| ['h3', {}, heading]}).to_h
134
+ else
135
+ options[:tabs]
136
+ end
137
+
138
+
127
139
  ## build the HTML
128
140
 
129
141
  a = RexleBuilder.build do |xml|
@@ -131,7 +143,7 @@ EOF
131
143
 
132
144
  xml.comment!(' Tab links ')
133
145
  xml.div(class: 'tab' ) do
134
- options[:headings].each do |heading|
146
+ tabs.keys.each do |heading|
135
147
  xml.button({class:'tablinks',
136
148
  onclick: %Q(openTab(event, "#{heading}"))}, heading)
137
149
  end
@@ -139,15 +151,19 @@ EOF
139
151
 
140
152
  xml.comment!(' Tab content ')
141
153
 
142
- options[:headings].each do |heading|
143
- xml.div(id: heading, class: 'tabcontent' ) do
144
- xml.h3 heading
145
- end
154
+ tabs.each do |heading, content|
155
+ puts 'content: ' + content.inspect
156
+ xml.div({id: heading, class: 'tabcontent'}, content )
146
157
  end
147
158
  end
148
159
  end
149
160
 
150
- @html = Rexle.new(a).xml(pretty: true, declaration: false)\
161
+ doc = Rexle.new(a)
162
+
163
+ e = doc.root.element("div/button[#{options[:active]}]")
164
+ e.attributes[:id] = 'defaultOpen' if e
165
+
166
+ @html = doc.xml(pretty: true, declaration: false)\
151
167
  .gsub(/<\/div>/,'\0' + "\n").strip.lines[1..-2]\
152
168
  .map {|x| x.sub(/^ /,'') }.join
153
169
 
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.1.0
4
+ version: 0.1.1
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: 2019-07-10 00:00:00.000000000 Z
38
+ date: 2019-07-12 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: rexle
metadata.gz.sig CHANGED
Binary file