jsmenubuilder 0.1.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2232d7d7c417abc9c6b13cb8b5c6f1b8e8f4ce26e2c8faa00bcd73408807aa68
4
- data.tar.gz: e24a782b2157968a45fe1c22074aac659df5b0fd5358713a6a4b7813b99adfb8
3
+ metadata.gz: 90c199cc14c95c758c56e60926884e0728750da3dfe2c75ba1a35fd8ac001d64
4
+ data.tar.gz: a4f64e2a769dd9a159011394a420404d746897621fd274f69b689fa6ba6f815e
5
5
  SHA512:
6
- metadata.gz: 2e5cc9d72d5ee7489ce2ebc621259bced5dd4e7ca4b315331e24820aeb999e6133fd89e7a31fd3956435af47d1f850e99d275bab7124aee3e830655cbb5d093e
7
- data.tar.gz: 375c158de22cb84b24c96b80e8bc0407016d38b0bafe7131577273899998700930dcb1621ffdcd266f76593f2feeaa0c69fa9466150ba1cf6d21e8fd842dc0e5
6
+ metadata.gz: d2df2af5486c48a9c21df9b3211f0a763bb2f2c893c2ba770c3e296a705e009690e8233852b136ba65903ff8471adcfca4576b22c2fb22680a8cf5d4ccccf9a2
7
+ data.tar.gz: 349510de80b99681503a3f476f4a2c45e2fccf706d484771f5cd41cd0eb9877f10069aa2015dd4f9772418f46523050ae3779ed6647fc603a68ca64d6ca13d83
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/jsmenubuilder.rb CHANGED
@@ -67,6 +67,70 @@ 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();
72
+ EOF
73
+
74
+ FULL_PAGE_TABS_CSS =<<EOF
75
+ /* Set height of body and the document to 100% to enable "full page tabs" */
76
+ body, html {
77
+ height: 100%;
78
+ margin: 0;
79
+ font-family: Arial;
80
+ }
81
+
82
+ /* Style tab links */
83
+ .tablink {
84
+ background-color: #555;
85
+ color: white;
86
+ float: left;
87
+ border: none;
88
+ outline: none;
89
+ cursor: pointer;
90
+ padding: 14px 16px;
91
+ font-size: 17px;
92
+ width: 25%;
93
+ }
94
+
95
+ button.active {
96
+ background-color: #c55;
97
+ }
98
+
99
+ .tablink:hover {
100
+ background-color: #777;
101
+ }
102
+
103
+
104
+
105
+ /* Style the tab content (and add height:100% for full page content) */
106
+ .tabcontent {
107
+ color: #000;
108
+ display: none;
109
+ padding: 100px 20px;
110
+ height: 100%;
111
+ }
112
+
113
+ EOF
114
+
115
+ FULL_PAGE_TABS_JS =<<EOF
116
+ function openPage(pageName,elmnt) {
117
+ var i, tabcontent;
118
+ tabcontent = document.getElementsByClassName("tabcontent");
119
+ for (i = 0; i < tabcontent.length; i++) {
120
+ tabcontent[i].style.display = "none";
121
+ }
122
+
123
+ // Get all elements with class="tablink" and remove the class "active"
124
+ tablink = document.getElementsByClassName("tablink");
125
+ for (i = 0; i < tablink.length; i++) {
126
+ tablink[i].className = tablink[i].className.replace(" active", "");
127
+ }
128
+
129
+
130
+ document.getElementById(pageName).style.display = "block";
131
+ elmnt.className += " active";
132
+ }
133
+
70
134
  // Get the element with id="defaultOpen" and click on it
71
135
  document.getElementById("defaultOpen").click();
72
136
  EOF
@@ -78,8 +142,14 @@ EOF
78
142
  def initialize(type, options={})
79
143
 
80
144
  @type = type
81
- types = %i(tabs)
82
- method(type.to_sym).call(options) if types.include? type
145
+ types = %i(tabs full_page_tabs)
146
+ doc = method(type.to_sym).call(options) if types.include? type
147
+ @html = doc.xml(pretty: true, declaration: false)\
148
+ .gsub(/<\/div>/,'\0' + "\n").strip.lines[1..-2]\
149
+ .map {|x| x.sub(/^ /,'') }.join
150
+
151
+ @css = Object.const_get 'JsMenuBuilder::' + @type.to_s.upcase + '_CSS'
152
+ @js = Object.const_get 'JsMenuBuilder::' + @type.to_s.upcase + '_JS'
83
153
 
84
154
  end
85
155
 
@@ -163,13 +233,47 @@ EOF
163
233
  e = doc.root.element("div/button[#{options[:active]}]")
164
234
  e.attributes[:id] = 'defaultOpen' if e
165
235
 
166
- @html = doc.xml(pretty: true, declaration: false)\
167
- .gsub(/<\/div>/,'\0' + "\n").strip.lines[1..-2]\
168
- .map {|x| x.sub(/^ /,'') }.join
169
-
170
- @css = Object.const_get 'JsMenuBuilder::' + @type.to_s.upcase + '_CSS'
171
- @js = Object.const_get 'JsMenuBuilder::' + @type.to_s.upcase + '_JS'
172
-
236
+ return doc
237
+
173
238
  end
239
+
240
+ def full_page_tabs(opt={})
241
+
242
+ options = {active: '1'}.merge(opt)
243
+
244
+ tabs = if options[:headings] then
245
+ headings = options[:headings]
246
+ headings.zip(headings.map {|heading| ['h3', {}, heading]}).to_h
247
+ else
248
+ options[:tabs]
249
+ end
250
+
251
+
252
+ ## build the HTML
174
253
 
254
+ a = RexleBuilder.build do |xml|
255
+ xml.html do
256
+
257
+ tabs.keys.each do |heading|
258
+ xml.button({class:'tablink',
259
+ onclick: %Q(openPage("#{heading}", this))}, heading)
260
+ end
261
+
262
+ tabs.each do |heading, content|
263
+ puts 'content: ' + content.inspect
264
+ xml.div({id: heading, class: 'tabcontent'}, content )
265
+ end
266
+ end
267
+ end
268
+
269
+ doc = Rexle.new(a)
270
+
271
+ e = doc.root.element("button[#{options[:active]}]")
272
+ e.attributes[:id] = 'defaultOpen' if e
273
+
274
+ return doc
275
+
276
+
277
+ end
278
+
175
279
  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.1.1
4
+ version: 0.2.0
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-12 00:00:00.000000000 Z
38
+ date: 2019-07-13 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: rexle
metadata.gz.sig CHANGED
Binary file