bootstrap_builders 0.0.59 → 0.0.60

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
  SHA1:
3
- metadata.gz: 86eff598e9fcaf0e0d255d91c0d567fe7e04fb6e
4
- data.tar.gz: 525e87bc8c7591baecc3aae24c8109f9d7a857a7
3
+ metadata.gz: b931613adf3a0e431b305e7c36dc97fc218a5388
4
+ data.tar.gz: 50990ef9f9be4ee5a8e0fdcfcbbea8289554caea
5
5
  SHA512:
6
- metadata.gz: 1fb4958acd108f740dc045745b231641bbf0427010ea06ae9011412c7459eb155cd3715bf4a90d960303063683c610052f81faec7728468a97405ca4d55b007a
7
- data.tar.gz: a062b52e8e6b6da121bf40d0c3ef2801d9ee1d823a5a286d7d6d594346c6b0da09a67781f01745b30de14696e8c3164746d4b6fdc0ed13333403d8e356cf1520
6
+ metadata.gz: db32506f27788225a1df4c51578d2e6736c67aab7c1ff4e7b338f37e26652bbfcda84e68447cc308e6c872ff188da4c4b2dd24f12a0375ed500f155cc0fc95f3
7
+ data.tar.gz: cf2a7beff524b9cf7b1026b0323b2f8ffcaeb22bd25259802d275543c4fe568f6885f57d76da2bcd4c1b33b59d5aa1404b18735c3cb37d9c14782102b6cc11d7
@@ -4,7 +4,7 @@ class BootstrapBuilders::ButtonDropDown
4
4
  def initialize(*args)
5
5
  args_parser = BootstrapBuilders::ArgumentsParser.new(
6
6
  arguments: args,
7
- short_true_arguments: [:block, :danger, :link, :info, :primary, :sm, :warning]
7
+ short_true_arguments: [:block, :danger, :link, :info, :primary, :sm, :warning, :xs]
8
8
  )
9
9
 
10
10
  args_parser.arguments_hash[:label] ||= args.shift if args.first.is_a?(String)
@@ -43,28 +43,29 @@ class BootstrapBuilders::ButtonDropDown
43
43
  toggle: "dropdown"
44
44
  }
45
45
  )
46
- main_button.add_str(@args.fetch(:label))
47
- main_button.add_ele(:span, classes: ["caret"])
46
+ main_button.add_ele(:i, classes: ["fa", "fa-fw", "fa-#{@args.fetch(:icon)}"]) if @args[:icon].present?
47
+ main_button.add_str(@args.fetch(:label)) if @args[:label].present?
48
+ main_button.add_ele(:span, classes: ["caret"]) if !@args.key?(:caret) || @args[:cart]
48
49
 
49
50
  ul = btn_group.add_ele(:ul, classes: ["dropdown-menu"])
50
51
 
51
52
  @buttons.each do |button|
52
53
  li = ul.add_ele(:li)
53
54
 
54
- url = button.fetch(:url)
55
- url = view_context.polymorphic_url(url) if url.is_a?(Array)
56
-
57
- a_href = li.add_ele(:a, attr: {href: url}, classes: BootstrapBuilders::ClassAttributeHandler.short(button[:class]))
58
-
59
- a_href.data[:confirm] = I18n.t("are_you_sure") if button[:confirm]
60
- a_href.data[:method] = button[:method] if button[:method].present?
61
- a_href.data.merge!(button[:data]) if button[:data]
62
-
63
- if button[:icon]
64
- a_href.add_ele(:i, classes: ["fa", "fa-fw", "fa-#{button.fetch(:icon)}"])
55
+ link_args = {class: BootstrapBuilders::ClassAttributeHandler.short(button[:class])}
56
+ link_args.deep_merge!(data: {confirm: I18n.t("are_you_sure")}) if button[:confirm]
57
+ link_args.deep_merge!(data: {method: button[:method]}) if button[:method].present?
58
+ link_args.deep_merge!(data: button[:data]) if button[:data]
59
+
60
+ link = view_context.link_to(button.fetch(:url), link_args) do
61
+ if button[:icon]
62
+ view_context.safe_join [view_context.content_tag(:i, nil, class: ["fa", "fa-fw", "fa-#{button.fetch(:icon)}"]), " ", button.fetch(:label)]
63
+ else
64
+ button.fetch(:label)
65
+ end
65
66
  end
66
67
 
67
- a_href.add_str(button.fetch(:label))
68
+ li.add_html(link)
68
69
  end
69
70
 
70
71
  btn_group.html
@@ -1,3 +1,3 @@
1
1
  module BootstrapBuilders
2
- VERSION = "0.0.59".freeze
2
+ VERSION = "0.0.60".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bootstrap_builders
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.59
4
+ version: 0.0.60
5
5
  platform: ruby
6
6
  authors:
7
7
  - kaspernj
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-22 00:00:00.000000000 Z
11
+ date: 2017-10-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -52,8 +52,6 @@ files:
52
52
  - app/assets/javascripts/bootstrap_builders/bb-btn-responsive.js
53
53
  - app/assets/javascripts/bootstrap_builders/date-picker-input.es6
54
54
  - app/assets/javascripts/bootstrap_builders/tabs.js
55
- - app/assets/javascripts/bootstrap_builders/url-builder/README.md
56
- - app/assets/javascripts/bootstrap_builders/url-builder/lib/url-builder.es6
57
55
  - app/assets/javascripts/bootstrap_builders/view-port-detection.js
58
56
  - app/assets/stylesheets/bootstrap_builders.scss
59
57
  - app/assets/stylesheets/bootstrap_builders/bb-btn-responsive.scss
@@ -1,27 +0,0 @@
1
- # UrlBuilder
2
-
3
- ## Usage
4
-
5
- Start by making a new object with any given URL
6
-
7
- ```js
8
- var urlb = new UrlBuilder.new(window.location.href)
9
- ```
10
-
11
- ### Manipulate a query parameter
12
-
13
- ```js
14
- urlb.queryParameters["someParameter"] = "newValue"
15
- ```
16
-
17
- ### Generate a new URL
18
-
19
- ```js
20
- urlb.generateFullUrl() #=> "http://localhost:3000/?someParameter=newValue"
21
- ```
22
-
23
- ### Generate the path with query parameters
24
-
25
- ```js
26
- urlb.pathWithQueryParameters #=> "/?someParameter=newValue"
27
- ```
@@ -1,140 +0,0 @@
1
- class UrlBuilder {
2
- constructor(url) {
3
- if (url) {
4
- this.parseUrlFromString(url)
5
- }
6
- }
7
-
8
- parseHostAndPortFromUrl() {
9
- var match = this.matchAndRemove(/^([A-z\d-\.]+)(|:(\d+))($|\/)/)
10
-
11
- if (match) {
12
- this.host = match[1]
13
-
14
- if (match[3]) {
15
- this.port = parseInt(match[3])
16
- this.portSpecified = true
17
- } else {
18
- if (this.protocol == "https") {
19
- this.port = 443
20
- } else {
21
- this.port = 80
22
- }
23
- }
24
- }
25
- }
26
-
27
- parsePathFromUrl() {
28
- var match = this.matchAndRemove(/^([^\?]+)/)
29
-
30
- if (match) {
31
- this.path = "/" + match[1]
32
- } else {
33
- this.path = ""
34
- }
35
- }
36
-
37
- parseProtocolFromUrl() {
38
- var match = this.matchAndRemove(/^(.+?):\/\//)
39
-
40
- if (match) {
41
- this.protocol = match[1]
42
- }
43
- }
44
-
45
- parseQueryParametersFromUrl() {
46
- this.queryParameters = {}
47
-
48
- if (this.matchAndRemove(/^\?/)) {
49
- var pairs = this.url.split("&")
50
-
51
- for(var pair in pairs) {
52
- var match = pair.match(/^(.+?)=(.+)$/)
53
- if (match) {
54
- this.queryParameters[match[1]] = match[2]
55
- }
56
- }
57
- }
58
- }
59
-
60
- parseUrlFromString(url) {
61
- this.url = url
62
-
63
- this.parseProtocolFromUrl()
64
- this.parseHostAndPortFromUrl()
65
- this.parsePathFromUrl()
66
- this.parseQueryParametersFromUrl()
67
- }
68
-
69
- generateFullUrl() {
70
- var url = this.protocol + "://" + this.host
71
-
72
- if (this.portSpecified) {
73
- url += ":" + this.port
74
- }
75
-
76
- url += this.path
77
-
78
- if (this.hasQueryParameters()) {
79
- url += "?"
80
- url += this.queryParametersAsString()
81
- }
82
-
83
- return url
84
- }
85
-
86
- pathWithQueryParameters() {
87
- var generatedPath = this.path
88
-
89
- if (this.hasQueryParameters()) {
90
- generatedPath += "?"
91
- generatedPath += this.queryParametersAsString()
92
- }
93
-
94
- return generatedPath
95
- }
96
-
97
- matchAndRemove(regex) {
98
- var match = this.url.match(regex)
99
-
100
- if (match) {
101
- this.url = this.url.replace(regex, "")
102
- return match
103
- } else {
104
- return false
105
- }
106
- }
107
-
108
- // Returns true if any query parameters has been saved
109
- hasQueryParameters() {
110
- if (this.queryParameters && Object.keys(this.queryParameters).length > 0) {
111
- return true
112
- } else {
113
- return false
114
- }
115
- }
116
-
117
- // Returns a hash containing the query parameters
118
- queryParameters() {
119
- this.queryParameters
120
- }
121
-
122
- queryParametersAsString() {
123
- var queryParametersString = ""
124
- var first = true
125
-
126
- for(var key in this.queryParameters) {
127
- var value = this.queryParameters[key]
128
-
129
- if (first) {
130
- first = false
131
- } else {
132
- queryParametersString += "&"
133
- }
134
-
135
- queryParametersString += key + "=" + value
136
- }
137
-
138
- return queryParametersString
139
- }
140
- }