ui_bibz 1.1.0 → 1.1.1
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 +8 -8
- data/.yardoc/checksums +49 -46
- data/.yardoc/object_types +0 -0
- data/.yardoc/objects/root.dat +0 -0
- data/Gemfile.lock +69 -56
- data/README.md +156 -61
- data/doc/UiBibz/Concerns/Models/Searchable/ClassMethods.html +6 -6
- data/doc/UiBibz/Concerns/Models/Searchable.html +2 -2
- data/doc/UiBibz/Concerns/Models.html +115 -0
- data/doc/UiBibz/Concerns.html +115 -0
- data/doc/UiBibz/Helpers/MetaHelper.html +75 -9
- data/doc/UiBibz/Helpers/UiCoreHelper.html +120 -68
- data/doc/UiBibz/Helpers/UiUxHelper.html +2 -2
- data/doc/UiBibz/Helpers/UtilsHelper.html +2 -2
- data/doc/UiBibz/Helpers.html +115 -0
- data/doc/UiBibz/Rails/Engine.html +1 -1
- data/doc/UiBibz/Rails.html +1 -1
- data/doc/UiBibz/Ui/Base.html +2 -2
- data/doc/UiBibz/Ui/Core/Alert.html +26 -13
- data/doc/UiBibz/Ui/Core/Bar.html +26 -13
- data/doc/UiBibz/Ui/Core/Breadcrumb.html +32 -19
- data/doc/UiBibz/Ui/Core/BreadcrumbLink.html +26 -13
- data/doc/UiBibz/Ui/Core/Button.html +26 -13
- data/doc/UiBibz/Ui/Core/ButtonDropdown.html +31 -18
- data/doc/UiBibz/Ui/Core/ButtonGroup.html +26 -13
- data/doc/UiBibz/Ui/Core/ButtonLink.html +26 -13
- data/doc/UiBibz/Ui/Core/ButtonSplitDropdown.html +27 -14
- data/doc/UiBibz/Ui/Core/Col.html +26 -13
- data/doc/UiBibz/Ui/Core/Component.html +166 -225
- data/doc/UiBibz/Ui/Core/Dropdown.html +61 -410
- data/doc/UiBibz/Ui/Core/DropdownLink.html +373 -0
- data/doc/UiBibz/Ui/Core/DropdownList.html +26 -13
- data/doc/UiBibz/Ui/Core/Glyph.html +26 -386
- data/doc/UiBibz/Ui/Core/Jumbotron.html +26 -13
- data/doc/UiBibz/Ui/Core/Label.html +29 -15
- data/doc/UiBibz/Ui/Core/List.html +64 -25
- data/doc/UiBibz/Ui/Core/ListGroup.html +47 -21
- data/doc/UiBibz/Ui/Core/Nav.html +64 -25
- data/doc/UiBibz/Ui/Core/NavDropdown.html +29 -16
- data/doc/UiBibz/Ui/Core/NavLink.html +30 -15
- data/doc/UiBibz/Ui/Core/Navbar.html +154 -45
- data/doc/UiBibz/Ui/Core/NavbarForm.html +58 -38
- data/doc/UiBibz/Ui/Core/NavbarNav.html +7 -7
- data/doc/UiBibz/Ui/Core/NavbarText.html +26 -13
- data/doc/UiBibz/Ui/Core/Panel.html +38 -237
- data/doc/UiBibz/Ui/Core/ProgressBar.html +45 -19
- data/doc/UiBibz/Ui/Core/Row.html +26 -13
- data/doc/UiBibz/Ui/Core/Stars.html +367 -0
- data/doc/UiBibz/Ui/Core.html +16 -5
- data/doc/UiBibz/Ui/Ux/Actionable.html +1 -1
- data/doc/UiBibz/Ui/Ux/Actions.html +198 -14
- data/doc/UiBibz/Ui/Ux/Column.html +4 -4
- data/doc/UiBibz/Ui/Ux/Columns.html +42 -16
- data/doc/UiBibz/Ui/Ux/Grid.html +31 -371
- data/doc/UiBibz/Ui/Ux/Paginable.html +22 -9
- data/doc/UiBibz/Ui/Ux/Searchable.html +22 -9
- data/doc/UiBibz/Ui/Ux/Sortable.html +18 -7
- data/doc/UiBibz/Ui/Ux/Store.html +160 -56
- data/doc/UiBibz/Ui/Ux/Table.html +109 -374
- data/doc/UiBibz/Ui/Ux/TableAction.html +2 -2
- data/doc/UiBibz/Ui/Ux/TablePagination.html +33 -14
- data/doc/UiBibz/Ui/Ux/TablePaginationPerPage.html +30 -15
- data/doc/UiBibz/Ui/Ux/TablePanel.html +139 -43
- data/doc/UiBibz/Ui/Ux/TableSearchField.html +26 -13
- data/doc/UiBibz/Ui/Ux.html +15 -4
- data/doc/UiBibz/Ui.html +4 -2
- data/doc/UiBibz/Utils/Internationalization.html +1 -1
- data/doc/UiBibz/Utils.html +1 -1
- data/doc/UiBibz.html +5 -5
- data/doc/_index.html +50 -7
- data/doc/class_list.html +1 -1
- data/doc/file.README.html +155 -63
- data/doc/images/stars.png +0 -0
- data/doc/index.html +155 -63
- data/doc/method_list.html +278 -398
- data/doc/top-level-namespace.html +1 -1
- data/lib/ui_bibz/concerns/models/searchable.rb +36 -13
- data/lib/ui_bibz/helpers/meta_helper.rb +22 -3
- data/lib/ui_bibz/helpers/ui_core_helper.rb +4 -0
- data/lib/ui_bibz/ui/core/alert.rb +2 -0
- data/lib/ui_bibz/ui/core/breadcrumb/breadcrumb.rb +3 -0
- data/lib/ui_bibz/ui/core/breadcrumb/components/breadcrumb_link.rb +2 -0
- data/lib/ui_bibz/ui/core/button/button.rb +2 -0
- data/lib/ui_bibz/ui/core/button/button_dropdown.rb +6 -4
- data/lib/ui_bibz/ui/core/button/button_group.rb +2 -0
- data/lib/ui_bibz/ui/core/button/button_link.rb +2 -0
- data/lib/ui_bibz/ui/core/button/button_split_dropdown.rb +2 -0
- data/lib/ui_bibz/ui/core/col.rb +2 -0
- data/lib/ui_bibz/ui/core/component.rb +23 -25
- data/lib/ui_bibz/ui/core/dropdown/components/dropdown_link.rb +57 -0
- data/lib/ui_bibz/ui/core/dropdown/components/dropdown_list.rb +2 -0
- data/lib/ui_bibz/ui/core/dropdown/dropdown.rb +22 -9
- data/lib/ui_bibz/ui/core/glyph.rb +10 -0
- data/lib/ui_bibz/ui/core/jumbotron.rb +2 -0
- data/lib/ui_bibz/ui/core/label.rb +3 -0
- data/lib/ui_bibz/ui/core/list/components/list.rb +4 -0
- data/lib/ui_bibz/ui/core/list/list_group.rb +4 -0
- data/lib/ui_bibz/ui/core/nav/components/nav_dropdown.rb +4 -2
- data/lib/ui_bibz/ui/core/nav/components/nav_link.rb +4 -1
- data/lib/ui_bibz/ui/core/nav/components/navbar_form.rb +39 -3
- data/lib/ui_bibz/ui/core/nav/components/navbar_nav.rb +1 -0
- data/lib/ui_bibz/ui/core/nav/components/navbar_text.rb +8 -0
- data/lib/ui_bibz/ui/core/nav/nav.rb +6 -0
- data/lib/ui_bibz/ui/core/nav/navbar.rb +31 -4
- data/lib/ui_bibz/ui/core/panel.rb +7 -5
- data/lib/ui_bibz/ui/core/progress_bar/components/bar.rb +2 -0
- data/lib/ui_bibz/ui/core/progress_bar/progress_bar.rb +4 -0
- data/lib/ui_bibz/ui/core/row.rb +2 -0
- data/lib/ui_bibz/ui/core/stars.rb +88 -0
- data/lib/ui_bibz/ui/ux/grid.rb +4 -0
- data/lib/ui_bibz/ui/ux/table/components/actions.rb +17 -2
- data/lib/ui_bibz/ui/ux/table/components/column.rb +2 -2
- data/lib/ui_bibz/ui/ux/table/components/columns.rb +4 -2
- data/lib/ui_bibz/ui/ux/table/components/store.rb +10 -1
- data/lib/ui_bibz/ui/ux/table/extensions/actionable.rb +3 -1
- data/lib/ui_bibz/ui/ux/table/extensions/paginable.rb +1 -0
- data/lib/ui_bibz/ui/ux/table/extensions/searchable.rb +1 -0
- data/lib/ui_bibz/ui/ux/table/extensions/sortable.rb +8 -2
- data/lib/ui_bibz/ui/ux/table/table.rb +19 -8
- data/lib/ui_bibz/ui/ux/table/table_pagination.rb +8 -1
- data/lib/ui_bibz/ui/ux/table/table_pagination_per_page.rb +10 -2
- data/lib/ui_bibz/ui/ux/table/table_panel.rb +28 -13
- data/lib/ui_bibz/ui/ux/table/table_search_field.rb +9 -1
- data/lib/ui_bibz/version.rb +1 -1
- data/lib/ui_bibz.rb +1 -0
- data/test/test_helper.rb +5 -0
- data/test/ui/dropdown_test.rb +4 -4
- data/test/ui/stars_test.rb +42 -0
- data/test/ui/table_test.rb +25 -6
- data/ui_bibz.gemspec +4 -1
- data/vendor/assets/fonts/FontAwesome.otf +0 -0
- data/vendor/assets/fonts/fontawesome-webfont.eot +0 -0
- data/vendor/assets/fonts/fontawesome-webfont.svg +640 -0
- data/vendor/assets/fonts/fontawesome-webfont.ttf +0 -0
- data/vendor/assets/fonts/fontawesome-webfont.woff +0 -0
- data/vendor/assets/fonts/fontawesome-webfont.woff2 +0 -0
- data/vendor/assets/javascripts/bootstrap-datepicker.min.js +8 -0
- data/vendor/assets/javascripts/bootstrap-select.min.js +8 -0
- data/vendor/assets/javascripts/bootstrap-switch.min.js +22 -0
- data/vendor/assets/javascripts/bootstrap.min.js +7 -0
- data/vendor/assets/javascripts/jquery-2.1.4.min.js +4 -0
- data/vendor/assets/javascripts/ui_bibz.js.coffee +8 -0
- data/vendor/assets/stylesheets/bootstrap-datepicker3.min.css +8 -0
- data/vendor/assets/stylesheets/bootstrap-select.min.css +6 -0
- data/vendor/assets/stylesheets/bootstrap-switch.min.css +22 -0
- data/vendor/assets/stylesheets/bootstrap-theme.min.css +5 -0
- data/vendor/assets/stylesheets/bootstrap.min.css +5 -0
- data/vendor/assets/stylesheets/font-awesome.min.css +4 -0
- data/vendor/assets/stylesheets/ui_bibz.sass +23 -0
- metadata +71 -2
@@ -103,7 +103,7 @@
|
|
103
103
|
</div>
|
104
104
|
|
105
105
|
<div id="footer">
|
106
|
-
Generated on
|
106
|
+
Generated on Mon Aug 31 14:08:52 2015 by
|
107
107
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
108
108
|
0.8.7.6 (ruby-1.9.3).
|
109
109
|
</div>
|
@@ -4,22 +4,40 @@ module UiBibz::Concerns::Models::Searchable
|
|
4
4
|
included do
|
5
5
|
# Maybe create a class to put all methods of table_search_pagination
|
6
6
|
def self.table_search_pagination params, session, args = {}
|
7
|
-
@params
|
8
|
-
@session
|
9
|
-
@arguments
|
10
|
-
OpenStruct.new(records: search_sort_paginate,
|
11
|
-
model: self,
|
12
|
-
controller: params[:controller],
|
13
|
-
direction: params[:direction],
|
14
|
-
search: params[:search],
|
15
|
-
sort: params[:sort],
|
16
|
-
searchable_attributes: @searchable_attributes,
|
17
|
-
action: params[:action])
|
18
|
-
end
|
7
|
+
@params = params.clone
|
8
|
+
@session = session
|
9
|
+
@arguments = args
|
19
10
|
|
11
|
+
initialize_params unless @arguments[:store_id].nil?
|
12
|
+
OpenStruct.new(generate_parameters)
|
13
|
+
end
|
20
14
|
|
21
15
|
private
|
22
16
|
|
17
|
+
def self.generate_parameters
|
18
|
+
{
|
19
|
+
controller: @params[:controller],
|
20
|
+
param_id: @params[:id],
|
21
|
+
direction: @params[:direction],
|
22
|
+
search: @params[:search],
|
23
|
+
sort: @params[:sort],
|
24
|
+
action: @params[:action],
|
25
|
+
id: @arguments[:store_id],
|
26
|
+
records: search_sort_paginate,
|
27
|
+
searchable_attributes: @searchable_attributes,
|
28
|
+
model: self
|
29
|
+
}
|
30
|
+
end
|
31
|
+
|
32
|
+
# If there is more one table in html page
|
33
|
+
def self.initialize_params
|
34
|
+
unless self.is_good_store_id?
|
35
|
+
@params[:search] = nil
|
36
|
+
@params[:per_page] = nil
|
37
|
+
@params[:page] = nil
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
23
41
|
def self.search
|
24
42
|
sql = all
|
25
43
|
column_args = get_column_args
|
@@ -42,7 +60,7 @@ module UiBibz::Concerns::Models::Searchable
|
|
42
60
|
self.paginate_by_sql(sq, :page => @params[:page], per_page: @session[:per_page])
|
43
61
|
else
|
44
62
|
sql.order(order_sql).paginate(:page => @params[:page], per_page: @session[:per_page])
|
45
|
-
|
63
|
+
end
|
46
64
|
|
47
65
|
end
|
48
66
|
|
@@ -82,6 +100,11 @@ module UiBibz::Concerns::Models::Searchable
|
|
82
100
|
@session[:per_page] = @params[:per_page] unless @params[:per_page].nil?
|
83
101
|
self.search
|
84
102
|
end
|
103
|
+
|
104
|
+
# If there's several table in the same page
|
105
|
+
def self.is_good_store_id?
|
106
|
+
@arguments[:store_id] == @params[:store_id]
|
107
|
+
end
|
85
108
|
end
|
86
109
|
|
87
110
|
module ClassMethods
|
@@ -12,11 +12,9 @@ module UiBibz::Helpers::MetaHelper
|
|
12
12
|
def ui_bibz_meta_links
|
13
13
|
capture do
|
14
14
|
# Latest compiled and minified CSS
|
15
|
-
concat stylesheet_link_tag "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css"
|
15
|
+
concat stylesheet_link_tag "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css", title: 'Default'
|
16
16
|
# font awesome icons
|
17
17
|
concat stylesheet_link_tag "https://maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css"
|
18
|
-
# Optional theme
|
19
|
-
concat stylesheet_link_tag "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap-theme.min.css"
|
20
18
|
# Jquery is required for boostrap
|
21
19
|
concat javascript_include_tag 'https://code.jquery.com/jquery-2.1.1.min.js'
|
22
20
|
# Latest compiled and minified JavaScript
|
@@ -24,4 +22,25 @@ module UiBibz::Helpers::MetaHelper
|
|
24
22
|
end
|
25
23
|
end
|
26
24
|
|
25
|
+
def ui_bibz_local_meta_links
|
26
|
+
capture do
|
27
|
+
# Latest compiled and minified CSS
|
28
|
+
concat stylesheet_link_tag "bootstrap.min"
|
29
|
+
# font awesome icons
|
30
|
+
concat stylesheet_link_tag "font-awesome.min"
|
31
|
+
# Jquery is required for boostrap
|
32
|
+
concat javascript_include_tag 'jquery-2.1.4.min'
|
33
|
+
# Latest compiled and minified JavaScript
|
34
|
+
concat javascript_include_tag "bootstrap.min"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
|
39
|
+
#def ui_bibz_meta_links_ext
|
40
|
+
#capture do
|
41
|
+
##concat javascript_include_tag '/vendor/assets/javascripts/moment.js'
|
42
|
+
##concat javascript_include_tag 'boostrap-datetimepicker.js'
|
43
|
+
#end
|
44
|
+
#end
|
45
|
+
|
27
46
|
end
|
@@ -13,6 +13,10 @@ module UiBibz::Helpers::UiCoreHelper
|
|
13
13
|
UiBibz::Ui::Core::Alert.new(content, options, html_options, &block).render
|
14
14
|
end
|
15
15
|
|
16
|
+
def stars content = nil, options = nil, html_options = nil, &block
|
17
|
+
UiBibz::Ui::Core::Stars.new(content, options, html_options, &block).render
|
18
|
+
end
|
19
|
+
|
16
20
|
# Use "etiquette" instead of "label" : due to "actionview (4.2.0) lib/action_view/helpers/form_helper.rb" conflict
|
17
21
|
def etiquette content = nil, options = nil, html_options = nil, &block
|
18
22
|
UiBibz::Ui::Core::Label.new(content, options, html_options, &block).render
|
@@ -47,10 +47,12 @@ module UiBibz::Ui::Core
|
|
47
47
|
#
|
48
48
|
class Alert < Component
|
49
49
|
|
50
|
+
# See UiBibz::Ui::Core::Component.initialize
|
50
51
|
def initialize content = nil, options = nil, html_options = nil, &block
|
51
52
|
super
|
52
53
|
end
|
53
54
|
|
55
|
+
# Render html tag
|
54
56
|
def render
|
55
57
|
content_tag :div, class_and_html_options('alert').merge({ role: 'alert'}) do
|
56
58
|
concat glyph_and_content_html
|
@@ -53,15 +53,18 @@ module UiBibz::Ui::Core
|
|
53
53
|
#
|
54
54
|
class Breadcrumb < Component
|
55
55
|
|
56
|
+
# See UiBibz::Ui::Core::Component.initialize
|
56
57
|
def initialize content = nil, options = nil, html_options = nil, &block
|
57
58
|
super
|
58
59
|
@links = []
|
59
60
|
end
|
60
61
|
|
62
|
+
# Render html tag
|
61
63
|
def render
|
62
64
|
content_tag :ol, @links.join.html_safe, class_and_html_options("breadcrumb")
|
63
65
|
end
|
64
66
|
|
67
|
+
# Add breadcrumb link items
|
65
68
|
# See UiBibz::Ui::Core::BreadcrumbLink
|
66
69
|
def link content = nil, options = nil, html_options = nil, &block
|
67
70
|
@links << BreadcrumbLink.new(content, options, html_options, &block).render
|
@@ -40,10 +40,12 @@ module UiBibz::Ui::Core
|
|
40
40
|
#
|
41
41
|
class BreadcrumbLink < Component
|
42
42
|
|
43
|
+
# See UiBibz::Ui::Core::Component.initialize
|
43
44
|
def initialize content = nil, options = nil, html_options = nil, &block
|
44
45
|
super
|
45
46
|
end
|
46
47
|
|
48
|
+
# Render html tag
|
47
49
|
def render
|
48
50
|
content_tag :li, link_html, class_and_html_options
|
49
51
|
end
|
@@ -48,10 +48,12 @@ module UiBibz::Ui::Core
|
|
48
48
|
# end
|
49
49
|
class Button < Component
|
50
50
|
|
51
|
+
# See UiBibz::Ui::Core::Component.initialize
|
51
52
|
def initialize content = nil, options = nil, html_options = nil, &block
|
52
53
|
super
|
53
54
|
end
|
54
55
|
|
56
|
+
# Render html tag
|
55
57
|
def render
|
56
58
|
content_tag :button, glyph_and_content_html, class_and_html_options(['btn', size])
|
57
59
|
end
|
@@ -26,19 +26,19 @@ module UiBibz::Ui::Core
|
|
26
26
|
# ==== Signatures
|
27
27
|
#
|
28
28
|
# UiBibz::Ui::Core::ButtonDropdown.new(options = nil, html_options = nil).tap do |d|
|
29
|
+
# ...
|
29
30
|
# d.list content = nil, options = nil, html_options = nil, &block
|
30
|
-
# d.
|
31
|
-
# d.list content = nil, options = nil, html_options = nil, &block
|
31
|
+
# d.link content = nil, options = nil, html_options = nil, &block
|
32
32
|
# ...
|
33
33
|
# end
|
34
34
|
#
|
35
35
|
# ==== Examples
|
36
36
|
#
|
37
37
|
# UiBibz::Ui::Core::ButtonDropdown.new(name, state: :success).tap do |d|
|
38
|
-
# d.
|
38
|
+
# d.link 'test', { url: '#Test1' }
|
39
39
|
# d.list('---')
|
40
40
|
# d.list('Header 1', { type: :header })
|
41
|
-
# d.
|
41
|
+
# d.link 'test2', { url: '#Test2' }
|
42
42
|
# end.render
|
43
43
|
#
|
44
44
|
# ==== Helper
|
@@ -52,10 +52,12 @@ module UiBibz::Ui::Core
|
|
52
52
|
#
|
53
53
|
class ButtonDropdown < Dropdown
|
54
54
|
|
55
|
+
# See UiBibz::Ui::Core::Component.initialize
|
55
56
|
def initialize name, options = nil, html_options = nil, &block
|
56
57
|
super
|
57
58
|
end
|
58
59
|
|
60
|
+
# Render html tag
|
59
61
|
def render
|
60
62
|
content_tag :div, class_and_html_options(['btn-group', type]).merge({ role: 'group' }) do
|
61
63
|
concat button_html
|
@@ -44,10 +44,12 @@ module UiBibz::Ui::Core
|
|
44
44
|
#
|
45
45
|
class ButtonGroup < Component
|
46
46
|
|
47
|
+
# See UiBibz::Ui::Core::Component.initialize
|
47
48
|
def initialize content = nil, options = nil, html_options = nil, &block
|
48
49
|
super
|
49
50
|
end
|
50
51
|
|
52
|
+
# Render html tag
|
51
53
|
def render
|
52
54
|
content_tag :div, @content, class_and_html_options(["btn-#{ type }", size, position]).merge({ role: type })
|
53
55
|
end
|
@@ -50,10 +50,12 @@ module UiBibz::Ui::Core
|
|
50
50
|
#
|
51
51
|
class ButtonLink < Component
|
52
52
|
|
53
|
+
# See UiBibz::Ui::Core::Component.initialize
|
53
54
|
def initialize content = nil, options = nil, html_options = nil, &block
|
54
55
|
super
|
55
56
|
end
|
56
57
|
|
58
|
+
# Render html tag
|
57
59
|
def render
|
58
60
|
link_to glyph_and_content_html, @options[:url], class_and_html_options("btn")
|
59
61
|
end
|
@@ -52,10 +52,12 @@ module UiBibz::Ui::Core
|
|
52
52
|
#
|
53
53
|
class ButtonSplitDropdown < Dropdown
|
54
54
|
|
55
|
+
# See UiBibz::Ui::Core::Component.initialize
|
55
56
|
def initialize name, options = nil, html_options = nil, &block
|
56
57
|
super
|
57
58
|
end
|
58
59
|
|
60
|
+
# Render html tag
|
59
61
|
def render
|
60
62
|
content_tag :div, class_and_html_options(['btn-group', type]).merge({ role: 'group' }) do
|
61
63
|
concat button_html
|
data/lib/ui_bibz/ui/core/col.rb
CHANGED
@@ -44,11 +44,13 @@ module UiBibz::Ui::Core
|
|
44
44
|
#
|
45
45
|
class Col < Component
|
46
46
|
|
47
|
+
# See UiBibz::Ui::Core::Component.initialize
|
47
48
|
def initialize content = nil, options = nil, html_options = nil, &block
|
48
49
|
super
|
49
50
|
@cols = []
|
50
51
|
end
|
51
52
|
|
53
|
+
# Render html tag
|
52
54
|
def render
|
53
55
|
content_tag :div, @content, class_and_html_options(col_classes)
|
54
56
|
end
|
@@ -40,6 +40,11 @@ module UiBibz::Ui::Core
|
|
40
40
|
|
41
41
|
attr_accessor :content, :html_options, :options
|
42
42
|
|
43
|
+
# Use link_to system in rails
|
44
|
+
# * Content can be send by content variable or by block
|
45
|
+
# if a block is sent, variable 'content' does not exit.
|
46
|
+
# * Options of component is defined in hash options
|
47
|
+
# * Html options is defined in hash html_options
|
43
48
|
def initialize content = nil, options = nil, html_options = nil, &block
|
44
49
|
if !block.nil?
|
45
50
|
@html_options, @options = options, content
|
@@ -56,45 +61,40 @@ module UiBibz::Ui::Core
|
|
56
61
|
@options = @options || {}
|
57
62
|
end
|
58
63
|
|
64
|
+
# Render html tag
|
59
65
|
def render
|
60
66
|
glyph_and_content_html
|
61
67
|
end
|
62
68
|
|
69
|
+
# Render glyph and content html
|
63
70
|
def glyph_and_content_html
|
64
71
|
[glyph_with_space, @content].compact.join.html_safe
|
65
72
|
end
|
66
73
|
|
67
|
-
|
68
|
-
glyph_info = options[:glyph] if options.kind_of?(Hash)
|
69
|
-
Glyph.new(glyph_info).render unless glyph_info.nil?
|
70
|
-
end
|
71
|
-
|
74
|
+
# Render glyph with space html
|
72
75
|
def glyph_with_space
|
73
76
|
"#{ glyph } " unless glyph.nil?
|
74
77
|
end
|
75
78
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
def html_options
|
81
|
-
@html_options
|
79
|
+
# Render glyph html
|
80
|
+
def glyph
|
81
|
+
glyph_info = options[:glyph] if options.kind_of?(Hash)
|
82
|
+
Glyph.new(glyph_info).render unless glyph_info.nil?
|
82
83
|
end
|
83
84
|
|
84
|
-
|
85
|
-
|
85
|
+
# Render badge html tag
|
86
|
+
def badge_html
|
87
|
+
content_tag :span, @options[:badge], class: 'badge'
|
86
88
|
end
|
87
89
|
|
90
|
+
# Set :default state symbol
|
88
91
|
def state
|
89
92
|
sym = options.delete(:state) if options[:state]
|
90
93
|
sym = sym || :default
|
91
94
|
states[:sym]
|
92
95
|
end
|
93
96
|
|
94
|
-
|
95
|
-
content_tag :span, @options[:badge], class: 'badge'
|
96
|
-
end
|
97
|
-
|
97
|
+
# Add classes in html_options
|
98
98
|
def class_and_html_options classes = nil
|
99
99
|
options_class = options[:class] if options.kind_of?(Hash)
|
100
100
|
cls = [
|
@@ -109,13 +109,15 @@ module UiBibz::Ui::Core
|
|
109
109
|
html_options
|
110
110
|
end
|
111
111
|
|
112
|
-
|
113
|
-
|
114
|
-
|
112
|
+
# Add classes in html_options
|
113
|
+
def add_classes *classes
|
114
|
+
classes.compact.join(' ')
|
115
115
|
end
|
116
116
|
|
117
|
+
private
|
118
|
+
|
117
119
|
def status
|
118
|
-
options[:status]
|
120
|
+
options[:status] unless options[:status].nil?
|
119
121
|
end
|
120
122
|
|
121
123
|
def states
|
@@ -129,9 +131,5 @@ module UiBibz::Ui::Core
|
|
129
131
|
@states
|
130
132
|
end
|
131
133
|
|
132
|
-
def add_classes *classes
|
133
|
-
classes.compact.join(' ')
|
134
|
-
end
|
135
|
-
|
136
134
|
end
|
137
135
|
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
module UiBibz::Ui::Core
|
2
|
+
|
3
|
+
# Create DropdownLink
|
4
|
+
#
|
5
|
+
# This element is an extend of UiBibz::Ui::Core::Component.
|
6
|
+
#
|
7
|
+
# ==== Attributes
|
8
|
+
#
|
9
|
+
# * +content+ - Content of element
|
10
|
+
# * +options+ - Options of element
|
11
|
+
# * +html_options+ - Html Options of element
|
12
|
+
#
|
13
|
+
# ==== Options
|
14
|
+
#
|
15
|
+
# You can add HTML attributes using the +html_options+.
|
16
|
+
# You can pass arguments in options attribute:
|
17
|
+
# * +status+ - State of élement with symbol value:
|
18
|
+
# (+:active+)
|
19
|
+
# * +url+ - String
|
20
|
+
# * +glyph+ - Add glyph with name or hash options
|
21
|
+
# * +name+ - String
|
22
|
+
# * +size+ - Integer
|
23
|
+
# * +type+ - Symbol
|
24
|
+
# * +link_html_options+ - Hash
|
25
|
+
#
|
26
|
+
# ==== Signatures
|
27
|
+
#
|
28
|
+
# UiBibz::Ui::Core::DropdownLink.new(content, options = nil, html_options = nil)
|
29
|
+
#
|
30
|
+
# UiBibz::Ui::Core::DropdownLink.new(options = nil, html_options = nil) do
|
31
|
+
# content
|
32
|
+
# end
|
33
|
+
#
|
34
|
+
# ==== Examples
|
35
|
+
#
|
36
|
+
# UiBibz::Ui::Core::DropdownLink.new('Home', { glyph: 'home', status: :active, url: '#home', link_html_options: { class: 'link1' }},{ class: 'test' }).render
|
37
|
+
#
|
38
|
+
# UiBibz::Ui::Core::DropdownLink.new({ glyph: { name: 'eye', size: 3 }, url: '#home' }, { class: 'test' }) do
|
39
|
+
# 'Home'
|
40
|
+
# end.render
|
41
|
+
#
|
42
|
+
class DropdownLink < Component
|
43
|
+
|
44
|
+
# See UiBibz::Ui::Core::Component.initialize
|
45
|
+
def initialize content = nil, options = nil, html_options = nil, &block
|
46
|
+
super
|
47
|
+
end
|
48
|
+
|
49
|
+
# Render html tag
|
50
|
+
def render
|
51
|
+
content_tag :li, @html_options.merge({ role: 'presentation' }) do
|
52
|
+
link_to glyph_and_content_html, @options[:url], @options[:link_html_options]
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
end
|
@@ -45,10 +45,12 @@ module UiBibz::Ui::Core
|
|
45
45
|
|
46
46
|
DIVIDER = '---'
|
47
47
|
|
48
|
+
# See UiBibz::Ui::Core::Component.initialize
|
48
49
|
def initialize content = nil, options = nil, html_options = nil, &block
|
49
50
|
super
|
50
51
|
end
|
51
52
|
|
53
|
+
# Render html tag
|
52
54
|
def render
|
53
55
|
@content == DIVIDER ? divider_html : link_html
|
54
56
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'ui_bibz/ui/core/dropdown/components/dropdown_list'
|
2
|
+
require 'ui_bibz/ui/core/dropdown/components/dropdown_link'
|
2
3
|
module UiBibz::Ui::Core
|
3
4
|
|
4
5
|
# Create a dropdown
|
@@ -28,19 +29,19 @@ module UiBibz::Ui::Core
|
|
28
29
|
# ==== Signatures
|
29
30
|
#
|
30
31
|
# UiBibz::Ui::Core::Dropdown.new(options = nil, html_options = nil).tap do |d|
|
32
|
+
# ...
|
31
33
|
# d.list content = nil, options = nil, html_options = nil, &block
|
32
|
-
# d.
|
33
|
-
# d.list content = nil, options = nil, html_options = nil, &block
|
34
|
+
# d.link content = nil, options = nil, html_options = nil, &block
|
34
35
|
# ...
|
35
36
|
# end
|
36
37
|
#
|
37
38
|
# ==== Examples
|
38
39
|
#
|
39
40
|
# UiBibz::Ui::Core::Dropdown.new(name, state: :success).tap do |d|
|
40
|
-
# d.
|
41
|
-
# d.list
|
42
|
-
# d.list
|
43
|
-
# d.
|
41
|
+
# d.link 'test', { url: '#' }
|
42
|
+
# d.list '---'
|
43
|
+
# d.list 'Header 1', { type: :header }
|
44
|
+
# d.link 'test2', { url: '#' }
|
44
45
|
# end.render
|
45
46
|
#
|
46
47
|
# ==== Helper
|
@@ -50,16 +51,21 @@ module UiBibz::Ui::Core
|
|
50
51
|
# d.list(options = {}, html_options = {}) do
|
51
52
|
# content
|
52
53
|
# end
|
54
|
+
# d.link(content, options = {}, html_options = {})
|
55
|
+
# d.link(options = {}, html_options = {}) do
|
56
|
+
# content
|
57
|
+
# end
|
53
58
|
# end
|
54
59
|
#
|
55
60
|
class Dropdown < Component
|
56
61
|
|
57
62
|
def initialize content, options = nil, html_options = nil, &block
|
58
63
|
super
|
59
|
-
@
|
64
|
+
@items = []
|
60
65
|
@state = @options.delete(:state)
|
61
66
|
end
|
62
67
|
|
68
|
+
# Render html tag
|
63
69
|
def render
|
64
70
|
content_tag :div, class_and_html_options(type) do
|
65
71
|
concat button_html
|
@@ -67,9 +73,16 @@ module UiBibz::Ui::Core
|
|
67
73
|
end
|
68
74
|
end
|
69
75
|
|
76
|
+
# Add dropdown list
|
70
77
|
# See UiBibz::Ui::Core::DropdownList
|
71
78
|
def list content = nil, options = nil, html_options = nil, &block
|
72
|
-
@
|
79
|
+
@items << DropdownList.new(content, options, html_options, &block).render
|
80
|
+
end
|
81
|
+
|
82
|
+
# Add dropdown link in list
|
83
|
+
# See UiBibz::Ui::Core::DropdownLink
|
84
|
+
def link content = nil, options = nil, html_options = nil, &block
|
85
|
+
@items << DropdownLink.new(content, options, html_options, &block).render
|
73
86
|
end
|
74
87
|
|
75
88
|
protected
|
@@ -83,7 +96,7 @@ module UiBibz::Ui::Core
|
|
83
96
|
end
|
84
97
|
|
85
98
|
def ul_html
|
86
|
-
content_tag :ul, @
|
99
|
+
content_tag :ul, @items.join.html_safe, class: "dropdown-menu dropdown-menu-#{ position }", role: 'menu'
|
87
100
|
end
|
88
101
|
|
89
102
|
def caret
|
@@ -17,6 +17,8 @@ module UiBibz::Ui::Core
|
|
17
17
|
# * +name+ - String
|
18
18
|
# * +size+ - Integer
|
19
19
|
# * +type+ - Symbol
|
20
|
+
# * +state+ - Symbol
|
21
|
+
# (+:default+, +:primary+, +:info+, +:warning+, +:danger+)
|
20
22
|
#
|
21
23
|
# ==== Signatures
|
22
24
|
#
|
@@ -54,14 +56,18 @@ module UiBibz::Ui::Core
|
|
54
56
|
# end
|
55
57
|
class Glyph < Component
|
56
58
|
|
59
|
+
# See UiBibz::Ui::Core::Component.initialize
|
57
60
|
def initialize content, options = nil, html_options = nil, &block
|
58
61
|
super
|
59
62
|
end
|
60
63
|
|
64
|
+
# Render html tag
|
61
65
|
def render
|
62
66
|
content_tag :i, '', class_and_html_options(classes)
|
63
67
|
end
|
64
68
|
|
69
|
+
private
|
70
|
+
|
65
71
|
def classes
|
66
72
|
cls = ["glyph", "fa", "fa-#{ content }"]
|
67
73
|
cls << "fa-#{ size }x" unless size.nil?
|
@@ -96,5 +102,9 @@ module UiBibz::Ui::Core
|
|
96
102
|
@options[:name] || @content
|
97
103
|
end
|
98
104
|
|
105
|
+
def state
|
106
|
+
"glyph-#{ @options[:state] }" unless @options[:state].nil?
|
107
|
+
end
|
108
|
+
|
99
109
|
end
|
100
110
|
end
|
@@ -42,10 +42,12 @@ module UiBibz::Ui::Core
|
|
42
42
|
#
|
43
43
|
class Jumbotron < Component
|
44
44
|
|
45
|
+
# See UiBibz::Ui::Core::Component.initialize
|
45
46
|
def initialize content = nil, options = nil, html_options = nil, &block
|
46
47
|
super
|
47
48
|
end
|
48
49
|
|
50
|
+
# Render html tag
|
49
51
|
def render
|
50
52
|
content_tag :div, class_and_html_options('jumbotron') do
|
51
53
|
if full_width
|
@@ -3,6 +3,7 @@ module UiBibz::Ui::Core
|
|
3
3
|
# Create a label
|
4
4
|
#
|
5
5
|
# This element is an extend of UiBibz::Ui::Core::Component.
|
6
|
+
# The helper use 'etiquette' method to avoid conflict with Rails.
|
6
7
|
#
|
7
8
|
# ==== Attributes
|
8
9
|
#
|
@@ -47,10 +48,12 @@ module UiBibz::Ui::Core
|
|
47
48
|
#
|
48
49
|
class Label < Component
|
49
50
|
|
51
|
+
# See UiBibz::Ui::Core::Component.initialize
|
50
52
|
def initialize content = nil, options = nil, html_options = nil, &block
|
51
53
|
super
|
52
54
|
end
|
53
55
|
|
56
|
+
# Render html tag
|
54
57
|
def render
|
55
58
|
content_tag :span, glyph_and_content_html, class_and_html_options('label')
|
56
59
|
end
|
@@ -55,10 +55,12 @@ module UiBibz::Ui::Core
|
|
55
55
|
#
|
56
56
|
class List < Component
|
57
57
|
|
58
|
+
# See UiBibz::Ui::Core::Component.initialize
|
58
59
|
def initialize content = nil, options = nil, html_options = nil, &block
|
59
60
|
super
|
60
61
|
end
|
61
62
|
|
63
|
+
# Render html tag
|
62
64
|
def render
|
63
65
|
content_tag tag, class_and_html_options('list-group-item') do
|
64
66
|
concat glyph_and_content_html if @content
|
@@ -68,10 +70,12 @@ module UiBibz::Ui::Core
|
|
68
70
|
end
|
69
71
|
end
|
70
72
|
|
73
|
+
# Add header which is a component
|
71
74
|
def header content = nil, options = nil, html_options = nil, &block
|
72
75
|
@header = Component.new content, options, html_options, &block
|
73
76
|
end
|
74
77
|
|
78
|
+
# Add body which is a component
|
75
79
|
def body content = nil, options = nil, html_options = nil, &block
|
76
80
|
@body = Component.new content, options, html_options, &block
|
77
81
|
end
|
@@ -70,15 +70,19 @@ module UiBibz::Ui::Core
|
|
70
70
|
#
|
71
71
|
class ListGroup < Component
|
72
72
|
|
73
|
+
# See UiBibz::Ui::Core::Component.initialize
|
73
74
|
def initialize content = nil, options = nil, html_options = nil, &block
|
74
75
|
super
|
75
76
|
@lists = []
|
76
77
|
end
|
77
78
|
|
79
|
+
# Render html tag
|
78
80
|
def render
|
79
81
|
content_tag type, @lists.join().html_safe, class_and_html_options("list-group")
|
80
82
|
end
|
81
83
|
|
84
|
+
# Add group list
|
85
|
+
# See UiBibz::Ui::Core::List
|
82
86
|
def list content = nil, options = {} , html_options = nil, &block
|
83
87
|
is_tap = (content[:tap] if content.kind_of?(Hash)) || (options[:tap] unless options.nil?)
|
84
88
|
options = options.merge({ type: :link }) if @options[:type] == :link
|