card-mod-bootstrap 0.11.5 → 0.13.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. checksums.yaml +4 -4
  2. data/db/migrate_core_cards/20180423160231_migrate_customized_bootstrap_skin.rb +1 -1
  3. data/db/migrate_core_cards/20200809112346_add_mod_card.rb +7 -0
  4. data/db/migrate_core_cards/20201129140917_remove_script_cards.rb +9 -0
  5. data/file/mod_bootstrap_script_bootstrap_machine_output/file.js +25 -0
  6. data/file/mod_bootstrap_script_pointer_machine_output/file.js +223 -0
  7. data/lib/card/bootstrap.rb +17 -0
  8. data/lib/card/bootstrap/basic_tags.rb +26 -0
  9. data/lib/card/bootstrap/component.rb +110 -0
  10. data/lib/card/bootstrap/component/carousel.rb +78 -0
  11. data/lib/card/bootstrap/component/form.rb +67 -0
  12. data/lib/card/bootstrap/component/horizontal_form.rb +65 -0
  13. data/lib/card/bootstrap/component/layout.rb +107 -0
  14. data/lib/card/bootstrap/component/panel.rb +11 -0
  15. data/lib/{bootstrap/component/component_class.rb → card/bootstrap/component_klass.rb} +5 -4
  16. data/lib/card/bootstrap/component_loader.rb +30 -0
  17. data/lib/card/bootstrap/content.rb +42 -0
  18. data/lib/card/bootstrap/delegate.rb +18 -0
  19. data/lib/card/bootstrap/old_component.rb +108 -0
  20. data/lib/card/bootstrap/tag_method.rb +56 -0
  21. data/lib/card/bootstrapper.rb +17 -0
  22. data/lib/card/tab.rb +8 -1
  23. data/lib/stylesheets/font_awesome.css +6 -6
  24. data/lib/stylesheets/material_icons.css +4 -4
  25. data/public/{assets/fonts → fonts}/MaterialIcons-Regular.eot +0 -0
  26. data/public/{assets/fonts → fonts}/MaterialIcons-Regular.ijmap +0 -0
  27. data/public/{assets/fonts → fonts}/MaterialIcons-Regular.svg +0 -0
  28. data/public/{assets/fonts → fonts}/MaterialIcons-Regular.ttf +0 -0
  29. data/public/{assets/fonts → fonts}/MaterialIcons-Regular.woff +0 -0
  30. data/public/{assets/fonts → fonts}/MaterialIcons-Regular.woff2 +0 -0
  31. data/public/{assets/fonts → fonts}/fa-brands-400.eot +0 -0
  32. data/public/{assets/fonts → fonts}/fa-brands-400.svg +0 -0
  33. data/public/{assets/fonts → fonts}/fa-brands-400.ttf +0 -0
  34. data/public/{assets/fonts → fonts}/fa-brands-400.woff +0 -0
  35. data/public/{assets/fonts → fonts}/fa-brands-400.woff2 +0 -0
  36. data/public/{assets/fonts → fonts}/fa-regular-400.eot +0 -0
  37. data/public/{assets/fonts → fonts}/fa-regular-400.svg +0 -0
  38. data/public/{assets/fonts → fonts}/fa-regular-400.ttf +0 -0
  39. data/public/{assets/fonts → fonts}/fa-regular-400.woff +0 -0
  40. data/public/{assets/fonts → fonts}/fa-regular-400.woff2 +0 -0
  41. data/public/{assets/fonts → fonts}/fa-solid-900.eot +0 -0
  42. data/public/{assets/fonts → fonts}/fa-solid-900.svg +0 -0
  43. data/public/{assets/fonts → fonts}/fa-solid-900.ttf +0 -0
  44. data/public/{assets/fonts → fonts}/fa-solid-900.woff +0 -0
  45. data/public/{assets/fonts → fonts}/fa-solid-900.woff2 +0 -0
  46. data/public/{assets/fonts → fonts}/glyphicons-halflings-regular.eot +0 -0
  47. data/public/{assets/fonts → fonts}/glyphicons-halflings-regular.svg +0 -0
  48. data/public/{assets/fonts → fonts}/glyphicons-halflings-regular.ttf +0 -0
  49. data/public/{assets/fonts → fonts}/glyphicons-halflings-regular.woff +0 -0
  50. data/public/{assets/fonts → fonts}/glyphicons-halflings-regular.woff2 +0 -0
  51. data/set/abstract/bootswatch_theme.rb +2 -2
  52. data/set/all/bootstrap/icon.rb +3 -1
  53. metadata +72 -58
  54. data/lib/bootstrap.rb +0 -18
  55. data/lib/bootstrap/basic_tags.rb +0 -26
  56. data/lib/bootstrap/component.rb +0 -108
  57. data/lib/bootstrap/component/carousel.rb +0 -76
  58. data/lib/bootstrap/component/form.rb +0 -65
  59. data/lib/bootstrap/component/horizontal_form.rb +0 -63
  60. data/lib/bootstrap/component/layout.rb +0 -105
  61. data/lib/bootstrap/component/panel.rb +0 -9
  62. data/lib/bootstrap/component_loader.rb +0 -28
  63. data/lib/bootstrap/content.rb +0 -40
  64. data/lib/bootstrap/delegate.rb +0 -16
  65. data/lib/bootstrap/old_component.rb +0 -103
  66. data/lib/bootstrap/tag_method.rb +0 -54
  67. data/lib/bootstrapper.rb +0 -16
  68. data/lib/javascript/bootstrap_modal_decko.js +0 -27
  69. data/lib/javascript/script_load_select2.js.coffee +0 -55
  70. data/set/self/script_bootstrap.rb +0 -12
  71. data/set/self/script_select2.rb +0 -12
@@ -0,0 +1,78 @@
1
+ class Card
2
+ class Bootstrap
3
+ class Component
4
+ class Carousel < Component
5
+ def render_content
6
+ carousel(*@args, &@build_block)
7
+ end
8
+
9
+ def carousel id, active_index, &block
10
+ @id = id
11
+ @active_item_index = active_index
12
+ @items = []
13
+ instance_exec(&block)
14
+
15
+ @html.div class: "carousel slide", id: id, "data-ride" => "carousel" do
16
+ indicators
17
+ items
18
+ control_prev
19
+ control_next
20
+ end
21
+ end
22
+
23
+ def item content=nil, &block
24
+ @items << (content || block)
25
+ end
26
+
27
+ def items
28
+ @html.div class: "carousel-inner", role: "listbox" do
29
+ @items.each_with_index do |item, index|
30
+ carousel_item item, carousel_item_opts(index)
31
+ end
32
+ end
33
+ end
34
+
35
+ def carousel_item_opts index
36
+ { class: "carousel-item" }.tap do |opts|
37
+ add_class opts, "active" if index == @active_item_index
38
+ end
39
+ end
40
+
41
+ def carousel_item item, html_opts
42
+ @html.div html_opts do
43
+ item = item.call if item.respond_to?(:call)
44
+ @html << item if item.is_a?(String)
45
+ end
46
+ end
47
+
48
+ def control_prev
49
+ @html.a class: "carousel-control-prev", href: "##{@id}", role: "button",
50
+ "data-slide" => "prev" do
51
+ @html.span class: "carousel-control-prev-icon", "aria-hidden" => "true"
52
+ @html.span "Previous", class: "sr-only"
53
+ end
54
+ end
55
+
56
+ def control_next
57
+ @html.a class: "carousel-control-next", href: "##{@id}", role: "button",
58
+ "data-slide": "next" do
59
+ @html.span class: "carousel-control-next-icon", "aria-hidden" => "true"
60
+ @html.span "Next", class: "sr-only"
61
+ end
62
+ end
63
+
64
+ def indicators
65
+ @html.ol class: "carousel-indicators" do
66
+ @items.size.times { |i| indicator i }
67
+ end
68
+ end
69
+
70
+ def indicator index
71
+ html_opts = { "data-slide-to" => index, "data-target": "##{@id}" }
72
+ add_class html_opts, "active" if index == @active_item_index
73
+ @html.li html_opts
74
+ end
75
+ end
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,67 @@
1
+ class Card
2
+ class Bootstrap
3
+ class Component
4
+ class Form < Component
5
+ def render_content *args
6
+ form(*args, &@build_block)
7
+ end
8
+
9
+ #
10
+ # def_tag_method :form, nil, optional_classes: {
11
+ # horizontal: "form-horizontal",
12
+ # inline: "form-inline"
13
+ # }
14
+ # def_div_method :group, "form-group"
15
+ # def_tag_method :label, nil
16
+ # def_tag_method :input, "form-control" do |opts, extra_args|
17
+ # type, label = extra_args
18
+ # prepend { label label, for: opts[:id] } if label
19
+ # opts[:type] = type
20
+ # opts
21
+ # end
22
+
23
+ def form opts={}, &block
24
+ add_class opts, "form-horizontal" if opts.delete(:horizontal)
25
+ add_class opts, "form-inline" if opts.delete(:inline)
26
+ @html.form opts do
27
+ instance_exec(&block)
28
+ end
29
+ end
30
+
31
+ def group text=nil, &block
32
+ @html.div text, class: "form-group" do
33
+ instance_exec(&block)
34
+ end
35
+ end
36
+
37
+ def label text=nil, &block
38
+ @html.label text, &block
39
+ end
40
+
41
+ def input type, text: nil, label: nil, id: nil
42
+ @html.input id: id, class: "form-control", type: type do
43
+ @html.label label, for: id if label
44
+ @html << text if text
45
+ end
46
+ end
47
+
48
+ %i[text password datetime datetime-local date month time
49
+ week number email url search tel color].each do |tag|
50
+ # def_tag_method tag, "form-control", attributes: { type: tag },
51
+ # tag: :input do |opts, extra_args|
52
+ # label, = extra_args
53
+ # prepend { label label, for: opts[:id] } if label
54
+ # opts
55
+ # end
56
+
57
+ define_method tag do |id:, label:, text: nil|
58
+ @html.input id: id, class: "form-control", type: tag do
59
+ @html.label label, for: id if label
60
+ @html << text
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,65 @@
1
+ class Card
2
+ class Bootstrap
3
+ class Component
4
+ class HorizontalForm < Form
5
+ def left_col_width
6
+ @child_args.last && @child_args.last[0] || 2
7
+ end
8
+
9
+ def right_col_width
10
+ @child_args.last && @child_args.last[1] || 10
11
+ end
12
+
13
+ def_tag_method :form, "form-horizontal"
14
+
15
+ def_tag_method :label, "control-label" do |opts, _extra_args|
16
+ prepend_class opts, "col-sm-#{left_col_width}"
17
+ opts
18
+ end
19
+
20
+ # def_div_method :input, nil do |opts, extra_args, &block|
21
+ # type, label = extra_args
22
+ # prepend { tag(:label, nil, for: opts[:id]) { label } } if label
23
+ # insert { inner_input opts.merge(type: type) }
24
+ # { class: "col-sm-#{right_col_width}" }
25
+ # end
26
+
27
+ def label_col label, id:
28
+ @html.label label, for: id, class: "col-sm-#{left_col_width} control-label"
29
+ end
30
+
31
+ def input type, label:, id:
32
+ label_col label, id: id
33
+ @html.div class: "col-sm-#{right_col_width}" do
34
+ @html.input type: type, id: id, class: "form-control"
35
+ end
36
+ # block.call class: "col-sm-#{right_col_width}" do
37
+ # inner_input opts.merge(type: type)
38
+ # end
39
+ end
40
+
41
+ def_tag_method :inner_input, "form-control", tag: :input
42
+ def_div_method :inner_checkbox, "checkbox"
43
+
44
+ def_div_method :checkbox, nil do |opts, extra_args|
45
+ inner_checkbox do
46
+ label do
47
+ inner_input "checkbox", extra_args.first, opts
48
+ end
49
+ end
50
+ { class: "col-sm-offset-#{left_col_width} col-sm-#{right_col_width}" }
51
+ end
52
+
53
+ def checkbox _text, _extra_args
54
+ @html.div class: "col-sm-offset-#{left_col_width} col-sm-#{right_col_width}" do
55
+ @html.div class: "checkbox" do
56
+ label_cllabel do
57
+ inner_input "checkbox"
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,107 @@
1
+ class Card
2
+ class Bootstrap
3
+ class Component
4
+ # generate bootstrap column layout
5
+ # @example
6
+ # layout container: true, fluid: true, class: "hidden" do
7
+ # row 6, 6, class: "unicorn" do
8
+ # column "horn",
9
+ # column "rainbow", class: "colorful"
10
+ # end
11
+ # end
12
+ # @example
13
+ # layout do
14
+ # row 3, 3, 4, 2, class: "unicorn" do
15
+ # [ "horn", "body", "tail", "rainbow"]
16
+ # end
17
+ # add_html "<span> some extra html</span>"
18
+ # row 6, 6, ["unicorn", "rainbow"], class: "horn"
19
+ # end
20
+ class Layout < OldComponent
21
+ def render
22
+ @rendered = begin
23
+ render_content
24
+ @content[-1]
25
+ end
26
+ end
27
+
28
+ def render_content
29
+ content = instance_exec(*@args, &@build_block)
30
+ add_content content
31
+ opts = @args.first
32
+ return unless opts&.delete(:container)
33
+
34
+ content = @content.pop
35
+ @content = ["".html_safe]
36
+ container content, opts
37
+ end
38
+
39
+ add_div_method :container, nil do |opts, _extra_args|
40
+ prepend_class opts, opts.delete(:fluid) ? "container-fluid" : "container"
41
+ opts
42
+ end
43
+
44
+ # @param args column widths, column content and html attributes
45
+ # @example
46
+ # row 6, 6, ["col one", "col two"], class: "count", id: "count"
47
+ # @example
48
+ # row md: 12, xs: 8, "single column content"
49
+ # @example
50
+ # row md: [1, 11], xs: [2, 10] do
51
+ # col "A"
52
+ # col "B"
53
+ # end
54
+ add_div_method :row, "row", content_processor: :column do |opts, extra_args|
55
+ cols_content = extra_args.pop if extra_args.last.is_a? Array
56
+ [opts, col_widths(extra_args, opts), cols_content].compact
57
+ end
58
+
59
+ # default column width type is for medium devices (col-md-)
60
+ add_div_method :column, nil do |opts, _extra_args|
61
+ @child_args.last.each do |medium, size|
62
+ if medium == :xs
63
+ prepend_class opts, "col-#{size.shift}"
64
+ else
65
+ prepend_class opts, "col-#{medium}-#{size.shift}"
66
+ end
67
+ end
68
+ opts
69
+ end
70
+
71
+ alias_method :col, :column
72
+
73
+ private
74
+
75
+ def standardize_row_args args
76
+ opts = args.last.is_a?(Hash) ? args.pop : {}
77
+ cols = (args.last.is_a?(Array) || args.last.is_a?(String)) &&
78
+ Array.wrap(args.pop)
79
+ [cols, opts, col_widths(args, opts)]
80
+ end
81
+
82
+ def col_widths args, opts
83
+ opts = args.pop if args.one? && args.last.is_a?(Hash)
84
+ if args.present?
85
+ col_widths_from_args args
86
+ else
87
+ col_widths_from_opts opts
88
+ end
89
+ end
90
+
91
+ def col_widths_from_args args
92
+ raise Error, "bad argument" unless args.all? { |a| a.is_a? Integer }
93
+
94
+ { md: Array.wrap(args) }
95
+ end
96
+
97
+ def col_widths_from_opts opts
98
+ %i[lg xs sm md].each_with_object({}) do |k, cols_w|
99
+ next unless (widths = opts.delete(k))
100
+
101
+ cols_w[k] = Array.wrap widths
102
+ end
103
+ end
104
+ end
105
+ end
106
+ end
107
+ end
@@ -0,0 +1,11 @@
1
+ class Card
2
+ class Bootstrap
3
+ class Component
4
+ class Panel < OldComponent
5
+ def_div_method :panel, "card"
6
+ def_div_method :heading, "card-header"
7
+ def_div_method :body, "card-body"
8
+ end
9
+ end
10
+ end
11
+ end
@@ -1,7 +1,7 @@
1
- class Bootstrap
2
- class Component
1
+ class Card
2
+ class Bootstrap
3
3
  # class methods for Bootstrap::Component
4
- module ComponentClass
4
+ module ComponentKlass
5
5
  def render format, *args, &block
6
6
  new(format, *args, &block).render
7
7
  end
@@ -26,7 +26,8 @@ class Bootstrap
26
26
  def def_tag_method method_name, html_class, tag_opts={}, &tag_opts_block
27
27
  tag = tag_opts.delete(:tag) || method_name
28
28
  define_method method_name do |*args, &content_block|
29
- @html.tag! tag, tag_method_opts(args, html_class, tag_opts, &tag_opts_block) do
29
+ @html.tag! tag,
30
+ tag_method_opts(args, html_class, tag_opts, &tag_opts_block) do
30
31
  instance_exec(&content_block)
31
32
  end
32
33
  end
@@ -0,0 +1,30 @@
1
+ class Card
2
+ class Bootstrap
3
+ module ComponentLoader
4
+ def load_components
5
+ components.each do |component|
6
+ require_relative "component/#{component}"
7
+ include_component component
8
+ end
9
+ end
10
+
11
+ def include_component component
12
+ component_class = to_const component.camelcase
13
+ define_method component do |*args, &block|
14
+ component_class.render self, *args, &block
15
+ end
16
+ end
17
+
18
+ def components
19
+ path = File.expand_path "component/*.rb", __dir__
20
+ Dir.glob(path).map do |file|
21
+ File.basename file, ".rb"
22
+ end
23
+ end
24
+
25
+ def to_const name
26
+ self.class.const_get "::Card::Bootstrap::Component::#{name.camelcase}"
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,42 @@
1
+ class Card
2
+ class Bootstrap
3
+ # shared methods for OldComponent and TagMethod
4
+ module Content
5
+ private
6
+
7
+ def process_collected_content tag_name, opts
8
+ collected_content = @content.pop
9
+ tag_name = opts.delete(:tag) if tag_name == :yield
10
+ add_content content_tag(tag_name, collected_content, opts, false)
11
+ end
12
+
13
+ def process_content &content_block
14
+ content, opts = yield
15
+ wrappers = @wrap.pop
16
+ if wrappers.present?
17
+ process_wrappers wrappers, content, &content_block
18
+ else
19
+ add_content content
20
+ end
21
+ opts
22
+ end
23
+
24
+ def process_append
25
+ @append.pop.each do |block|
26
+ add_content instance_exec(&block)
27
+ end
28
+ end
29
+
30
+ def process_wrappers wrappers, content, &content_block
31
+ while wrappers.present?
32
+ wrapper = wrappers.shift
33
+ if wrapper.is_a? Symbol
34
+ send wrapper, &content_block
35
+ else
36
+ instance_exec content, &wrappers.shift
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,18 @@
1
+ class Card
2
+ class Bootstrap
3
+ module Delegate
4
+ def method_missing method_name, *args, &block
5
+ # return super unless @context.respond_to? method_name
6
+ if block_given?
7
+ @context.send(method_name, *args, &block)
8
+ else
9
+ @context.send(method_name, *args)
10
+ end
11
+ end
12
+
13
+ def respond_to_missing? method_name, _include_private=false
14
+ @context.respond_to? method_name
15
+ end
16
+ end
17
+ end
18
+ end