weaver 0.3.7 → 0.3.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/weaver/version.rb +1 -1
  3. data/lib/weaver.rb +110 -83
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b5f4d34b80117b37e934c9c5bd9391339ca04d7b
4
- data.tar.gz: f3d7460153ce3ecddceb3ec69faf1955edaf26b5
3
+ metadata.gz: 3d760bc2c46a59fb5f6ba9d9dc245931cdc69f7f
4
+ data.tar.gz: 42e33c49557e737e13bef75e71bb9200bd32b295
5
5
  SHA512:
6
- metadata.gz: 135aad79ce90cfc8abe3f957e077e590ec9f214d707f116baf8061b3e43e10915fcb18a10de4f165d7def4b20ce530144f945ac7ce4d53995caf3ac14c90a8f2
7
- data.tar.gz: 70d011dbbba5c182c66c4d70eb4e4bbeb90fa6bc2768fceecdf1344921e433e3a706fb89ffedb2e4d929321b81c011a1a43e96e22f2fb132deb319b2147d76cc
6
+ metadata.gz: a6cbcba84b42e7058bb9d7241ce340daa4dcaf86a0f32dd0cac3c457c37eaeda12a7eb2b7d9217f8e92d84dc38802d8d1b351127cae82599345bf3e706a761fd
7
+ data.tar.gz: ec4f8cb2e33273ffe9444d05faa823e946906ad8c8e7443852849d162f7a3494bb71512ff349eb4e540b758de264eb195465740a2bafa3890b83f71bf3a4746d
@@ -1,3 +1,3 @@
1
1
  module Weaver
2
- VERSION = "0.3.7"
2
+ VERSION = "0.3.8"
3
3
  end
data/lib/weaver.rb CHANGED
@@ -21,7 +21,7 @@ module Weaver
21
21
  inner = args.shift
22
22
  end
23
23
  if block
24
- elem = Elements.new(@page, @anchors)
24
+ elem = self.class.new(@page, @anchors)
25
25
  elem.instance_eval(&block)
26
26
  inner = elem.generate
27
27
  end
@@ -85,8 +85,7 @@ module Weaver
85
85
  end
86
86
 
87
87
  def wform(options={}, &block)
88
- theform = Form.new(@page, @anchors, options)
89
- theform.instance_eval(&block)
88
+ theform = Form.new(@page, @anchors, options, &block)
90
89
  @inner_content << theform.generate
91
90
  @page.scripts << theform.generate_script
92
91
  end
@@ -271,16 +270,81 @@ module Weaver
271
270
  end
272
271
 
273
272
  def row(options={}, &block)
274
- r = Row.new(@page, @anchors, options)
275
- r.instance_eval(&block)
273
+ options[:class] = "row"
274
+ div options do
275
+ instance_eval(&block)
276
+ end
277
+ end
276
278
 
277
- @inner_content << <<-ENDROW
278
- <div class="row">
279
- #{r.generate}
280
- </div>
281
- ENDROW
279
+ def twothirds(&block)
280
+ opts =
281
+ {
282
+ xs: 12,
283
+ sm: 12,
284
+ md: 8,
285
+ lg: 8
286
+ }
287
+ col(4, opts, &block)
288
+ end
289
+
290
+ def half(&block)
291
+ opts =
292
+ {
293
+ xs: 12,
294
+ sm: 12,
295
+ md: 12,
296
+ lg: 6
297
+ }
298
+ col(4, opts, &block)
299
+ end
300
+
301
+ def third(&block)
302
+ opts =
303
+ {
304
+ xs: 12,
305
+ sm: 12,
306
+ md: 4,
307
+ lg: 4
308
+ }
309
+ col(4, opts, &block)
282
310
  end
283
311
 
312
+ def quarter(&block)
313
+ opts =
314
+ {
315
+ xs: 12,
316
+ sm: 12,
317
+ md: 6,
318
+ lg: 3
319
+ }
320
+ col(3, opts, &block)
321
+ end
322
+
323
+ def col(occupies, options={}, &block)
324
+
325
+ xs = options[:xs] || occupies
326
+ sm = options[:sm] || occupies
327
+ md = options[:md] || occupies
328
+ lg = options[:lg] || occupies
329
+
330
+ hidden = ""
331
+
332
+ xs_style = "col-xs-#{xs}" unless options[:xs] == 0
333
+ sm_style = "col-sm-#{sm}" unless options[:sm] == 0
334
+ md_style = "col-md-#{md}" unless options[:md] == 0
335
+ lg_style = "col-lg-#{lg}" unless options[:lg] == 0
336
+
337
+ hidden += "hidden-xs " if options[:xs] == 0
338
+ hidden += "hidden-sm " if options[:sm] == 0
339
+ hidden += "hidden-md " if options[:md] == 0
340
+ hidden += "hidden-lg " if options[:lg] == 0
341
+
342
+ div class: "#{xs_style} #{sm_style} #{md_style} #{lg_style} #{hidden}" do
343
+ instance_eval(&block)
344
+ end
345
+ end
346
+
347
+
284
348
  def jumbotron(options={}, &block)
285
349
 
286
350
  additional_style = ""
@@ -1031,22 +1095,19 @@ $("##{@id}").keyup(function()
1031
1095
  object.attr("aria-invalid", "true");
1032
1096
  }
1033
1097
  })
1034
-
1035
-
1036
1098
  SCRIPT
1037
1099
  end
1038
-
1039
1100
  end
1040
-
1041
1101
  end
1042
1102
 
1043
- class Form < Elements
1044
- def initialize(page, anchors, options)
1103
+ class FormElements < Elements
1104
+
1105
+ attr_accessor :options, :scripts
1106
+
1107
+ def initialize(page, anchors, options={})
1045
1108
  super(page, anchors)
1046
1109
  @options = options
1047
1110
  @scripts = []
1048
-
1049
- @formName = options[:id] || @page.create_anchor("form")
1050
1111
  end
1051
1112
 
1052
1113
  def passwordfield(name, textfield_label=nil, options={}, &block)
@@ -1130,8 +1191,7 @@ $("##{@id}").keyup(function()
1130
1191
  end
1131
1192
 
1132
1193
  def dropdown(name, dropdown_label, choice_array, options={})
1133
- select_name = @page.create_anchor "select"
1134
-
1194
+ select_name = options[:id] || @page.create_anchor("select")
1135
1195
 
1136
1196
  options[:class] = "form-control"
1137
1197
  options[:name] = name
@@ -1186,8 +1246,8 @@ $("##{@id}").keyup(function()
1186
1246
  method_missing :select, form_options do
1187
1247
 
1188
1248
  choice_array.each do |choice|
1189
- if options[:value] == choice
1190
- option choice, selected: selected
1249
+ if "#{options[:value]}" == "#{choice}"
1250
+ option choice, selected: true
1191
1251
  else
1192
1252
  option choice
1193
1253
  end
@@ -1283,11 +1343,10 @@ $("##{@id}").keyup(function()
1283
1343
  @scripts << <<-SCRIPT
1284
1344
  object["#{name}"] = $('input[name=#{name}]:checked', '##{@formName}').val()
1285
1345
  SCRIPT
1286
-
1287
1346
  end
1288
1347
 
1289
1348
  def checkbox(name, checkbox_label, options={})
1290
- checkbox_name = @page.create_anchor "checkbox"
1349
+ checkbox_name = options[:id] || @page.create_anchor("checkbox")
1291
1350
  options[:type] = "checkbox"
1292
1351
  options[:name] = name
1293
1352
  options[:id] = checkbox_name
@@ -1307,17 +1366,6 @@ $("##{@id}").keyup(function()
1307
1366
  _button(options, &block)
1308
1367
  end
1309
1368
 
1310
- def generate_script
1311
- <<-SCRIPT
1312
- function get_#{@formName}_object()
1313
- {
1314
- var object = {}
1315
- #{@scripts.join "\n"}
1316
- return object;
1317
- }
1318
- SCRIPT
1319
- end
1320
-
1321
1369
  def boolean_element(checkbox_label, options={})
1322
1370
 
1323
1371
  @page.request_css "css/plugins/iCheck/custom.css"
@@ -1358,11 +1406,33 @@ $(document).ready(function () {
1358
1406
 
1359
1407
  elem.generate
1360
1408
  end
1409
+ end
1410
+
1411
+ class Form
1412
+ def initialize(page, anchors, options={}, &block)
1413
+
1414
+ @formName = options[:id] || page.create_anchor("form")
1415
+
1416
+ @form_element = FormElements.new(page, anchors, options)
1417
+
1418
+ @form_element.instance_eval(&block)
1419
+ end
1420
+
1421
+ def generate_script
1422
+ <<-SCRIPT
1423
+ function get_#{@formName}_object()
1424
+ {
1425
+ var object = {}
1426
+ #{@form_element.scripts.join "\n"}
1427
+ return object;
1428
+ }
1429
+ SCRIPT
1430
+ end
1361
1431
 
1362
1432
  def generate
1363
- inner = super
1433
+ inner = @form_element.generate
1364
1434
  formName = @formName
1365
- options = @options
1435
+ options = @form_element.options
1366
1436
 
1367
1437
  elem = Elements.new(@page, @anchors)
1368
1438
  elem.instance_eval do
@@ -1900,7 +1970,7 @@ $( document ).ready(function() {
1900
1970
  end
1901
1971
  end
1902
1972
 
1903
- class Row
1973
+ class Row < Elements
1904
1974
  attr_accessor :extra_classes, :style
1905
1975
 
1906
1976
  def initialize(page, anchors, options)
@@ -1912,51 +1982,6 @@ $( document ).ready(function() {
1912
1982
  @page = page
1913
1983
  end
1914
1984
 
1915
- def twothirds(&block)
1916
- opts =
1917
- {
1918
- xs: 12,
1919
- sm: 12,
1920
- md: 8,
1921
- lg: 8
1922
- }
1923
- col(4, opts, &block)
1924
- end
1925
-
1926
- def half(&block)
1927
- opts =
1928
- {
1929
- xs: 12,
1930
- sm: 12,
1931
- md: 12,
1932
- lg: 6
1933
- }
1934
- col(4, opts, &block)
1935
- end
1936
-
1937
- def third(&block)
1938
- opts =
1939
- {
1940
- xs: 12,
1941
- sm: 12,
1942
- md: 4,
1943
- lg: 4
1944
- }
1945
- col(4, opts, &block)
1946
- end
1947
-
1948
- def quarter(&block)
1949
- opts =
1950
- {
1951
- xs: 12,
1952
- sm: 12,
1953
- md: 6,
1954
- lg: 3
1955
- }
1956
- col(3, opts, &block)
1957
- end
1958
-
1959
-
1960
1985
  def col(occupies, options={}, &block)
1961
1986
  raise "Not enough columns!" if @free < occupies
1962
1987
  elem = Elements.new(@page, @anchors)
@@ -1967,6 +1992,7 @@ $( document ).ready(function() {
1967
1992
  end
1968
1993
 
1969
1994
  def generate
1995
+
1970
1996
  @columns.map { |col|
1971
1997
 
1972
1998
  xs = col[:options][:xs] || col[:occupy]
@@ -2031,6 +2057,7 @@ $( document ).ready(function() {
2031
2057
  @rows << r
2032
2058
  end
2033
2059
 
2060
+
2034
2061
  end
2035
2062
 
2036
2063
  class NavPage < StructuredPage
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: weaver
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.7
4
+ version: 0.3.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Siaw
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-07-25 00:00:00.000000000 Z
11
+ date: 2016-07-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport