effective_bootstrap 0.8.3 → 0.9.2

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: 6d33c3af90acc774a7ae2426c06085e9d0395a168d59532586d17788f0fc4cb2
4
- data.tar.gz: a9723f01115d8c7025b0a02aab7a79ca69174050cc5f839fd2ec98d7e401e6ff
3
+ metadata.gz: a09d2f8d91357f5486377ae6a31483533bf214f4c8f1ba536bc9061828529370
4
+ data.tar.gz: e6a42b55fc5b377d7ccebf1b7418c41df907ed4b66de6ee58407690e46e82767
5
5
  SHA512:
6
- metadata.gz: 8776c093e66d79f264b1b1cb907b7716547b554ebc266f652255f98b3d22a47090fbd074508d4dc00fb11e480208072fd5cc1d9d55427e2e400bf1e2289efa19
7
- data.tar.gz: daa01ad649fd5e49b9108b124ed7c4556264442c029c03eafaa39ed5d31c48ad0334d50106a65c3c9f221d0f00fe7e68cf0dcf064fb876e977a344b63828049e
6
+ metadata.gz: 95b1495a52b26a3970754866ef7d35735be448daa675c3f21745ec8ff6298d893d8ecc912d37b28d1dd03ffad3fed29fa3adbcc26e6a278a050a6565bb052dbb
7
+ data.tar.gz: 174be86ba9a4064b21a3dcdbe4c13787165a574a31f93773ac12de60d20212e37edea12793197afa360502f95f6f2fd8941281696f114f881c2aa61da6fea470
data/README.md CHANGED
@@ -323,7 +323,7 @@ The end date selector will have its date <= start_date disabled.
323
323
  To disable this behaviour, call with `date_linked: false`.
324
324
 
325
325
  ```ruby
326
- = f.input :end_at, date_linked: false
326
+ = f.date_field :end_at, date_linked: false
327
327
  ```
328
328
 
329
329
  ### Events
@@ -334,6 +334,34 @@ More info is available here:
334
334
 
335
335
  http://eonasdan.github.io/bootstrap-datetimepicker/Events/
336
336
 
337
+ ## Custom editor
338
+
339
+ A drop in ready rich text editor based on
340
+
341
+ https://quilljs.com/
342
+
343
+ To use the editor, you must make additional javascript and stylesheet includes:
344
+
345
+ In your application.js
346
+
347
+ ```
348
+ //= require effective_bootstrap
349
+ //= require effective_bootstrap_editor
350
+ ```
351
+
352
+ In your application.scss
353
+
354
+ ```
355
+ @import 'effective_bootstrap';
356
+ @import 'effective_bootstrap_editor';
357
+ ```
358
+
359
+ And then in any form, instead of a text area:
360
+
361
+ ```
362
+ = f.editor :body
363
+ ```
364
+
337
365
  ## Custom percent_field
338
366
 
339
367
  This custom form input uses no 3rd party jQuery plugins.
@@ -622,6 +650,8 @@ The `f.save` is purely a input submit button.
622
650
  ```
623
651
 
624
652
 
653
+
654
+
625
655
  ## License
626
656
 
627
657
  MIT License. Copyright [Code and Effect Inc.](http://www.codeandeffect.com/)
@@ -0,0 +1 @@
1
+ <svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>Microsoft Azure icon</title><path d="M5.483 21.3H24L14.025 4.013l-3.038 8.347 5.836 6.938L5.483 21.3zM13.23 2.7L6.105 8.677 0 19.253h5.505v.014L13.23 2.7z"/></svg>
@@ -13,7 +13,7 @@
13
13
  //= require ./effective_clear/input
14
14
  //= require ./effective_checks/input
15
15
  //= require ./effective_ck_editor/input
16
- //= require ./effective_editor/input
16
+
17
17
  //= require ./effective_file/input
18
18
  //= require ./effective_integer/input
19
19
  //= require ./effective_number_text/input
@@ -0,0 +1 @@
1
+ //= require ./effective_editor/input
@@ -1,4 +1,3 @@
1
- # http://eonasdan.github.io/bootstrap-datetimepicker/Options/
2
1
  (this.EffectiveBootstrap || {}).effective_ck_editor = ($element, options) ->
3
2
  setupCkeditor($element)
4
3
  initCkeditor($element, $element.data('input-js-options'))
@@ -69,4 +68,4 @@ initCkeditor = ($element, input_options) ->
69
68
  ckeditor.on 'insertElement', (event) ->
70
69
  element = $(event.data.$)
71
70
  if element.is('table')
72
- element.removeAttr('style').addClass('table')
71
+ element.removeAttr('style').addClass('table')
@@ -5,8 +5,8 @@
5
5
  @import 'effective_date/input';
6
6
  @import 'effective_time/input';
7
7
 
8
- @import 'effective_editor/input';
9
8
  @import 'effective_file/input';
9
+ @import 'effective_rich_text_area/input';
10
10
  @import 'effective_select/input';
11
11
  @import 'effective_select_or_text/input';
12
12
  @import 'effective_radio/input';
@@ -0,0 +1 @@
1
+ @import 'effective_editor/input';
@@ -0,0 +1,25 @@
1
+ .effective_rich_text_area {
2
+ height: 100%;
3
+ border-color: #ccc;
4
+
5
+ &:hover,
6
+ &:active,
7
+ &:focus, {
8
+ border-color: #ccc;
9
+ outline: 0px !important;
10
+ -webkit-appearance: none;
11
+ box-shadow: none !important;
12
+ }
13
+ }
14
+
15
+ // Bootstrap 4 Feedback client side
16
+ .was-validated .form-control:invalid ~ .trix-content, { border-color: #dc3545 !important; }
17
+ .was-validated .form-control:valid ~ .trix-content { border-color: #28a745 !important; }
18
+ .was-validated .form-control:invalid ~ trix-toolbar, { border-color: #dc3545 !important; }
19
+ .was-validated .form-control:valid ~ trix-toolbar { border-color: #28a745 !important; }
20
+
21
+ // Bootstrap 4 Server side feedback
22
+ .form-control.is-invalid ~ .trix-content { border-color: #dc3545 !important; }
23
+ .form-control.is-invalid ~ trix-toolbar { border-color: #dc3545 !important; }
24
+ .form-control.is-valid ~ .trix-content { border-color: #28a745 !important; }
25
+ .form-control.is-valid ~ trix-toolbar { border-color: #28a745 !important; }
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Boostrap4 Helpers
2
4
 
3
5
  module EffectiveBootstrapHelper
@@ -72,15 +74,27 @@ module EffectiveBootstrapHelper
72
74
  # variations can be :dropup, :dropleft, :dropright
73
75
  # split can be true, false
74
76
  # right is to right align things
77
+ DROPDOWN_SPLIT_OPTS = {class: "btn dropdown-toggle dropdown-toggle-split btn-sm btn-outline-primary", type: 'button', 'data-toggle': 'dropdown', 'aria-haspopup': true, 'aria-expanded': false}
78
+ DROPDOWN_UNSPLIT_OPTS= {class: "btn dropdown-toggle btn-sm btn-outline-primary", type: 'button', 'data-toggle': 'dropdown', 'aria-haspopup': true, 'aria-expanded': false}
79
+
80
+ DROPDOWN_DROPLEFT_GROUP_OPTS = {class: 'btn-group'}
81
+ DROPDOWN_DROPLEFT_OPTS = {class: 'btn-group dropleft', role: 'group'}
82
+
83
+ DROPDOWN_MENU_OPTS = {class: 'dropdown-menu'}
84
+ DROPDOWN_MENU_RIGHT_OPTS = {class: 'dropdown-menu dropdown-menu-right'}
85
+
86
+ DROPDOWN_BTN_CLASS = 'btn-sm btn-outline-primary'
87
+ DROPDOWN_TOGGLE_DROPDOWN = "<span class='sr-only'>Toggle Dropdown</span>".html_safe
88
+
75
89
  def dropdown(variation: nil, split: true, btn_class: nil, btn_content: nil, right: false, &block)
76
90
  raise 'expected a block' unless block_given?
77
91
 
78
- btn_class = btn_class.presence || 'btn-outline-primary'
92
+ btn_class ||= DROPDOWN_BTN_CLASS
79
93
 
94
+ # Process all dropdown_link_tos
80
95
  @_dropdown_link_tos = []
81
96
  @_dropdown_split = split
82
-
83
- # process dropdown_link_tos
97
+ @_dropdown_button_class = btn_class
84
98
  yield
85
99
 
86
100
  return @_dropdown_link_tos.first if @_dropdown_link_tos.length <= 1
@@ -88,31 +102,37 @@ module EffectiveBootstrapHelper
88
102
  # Build tags
89
103
  first = @_dropdown_link_tos.first
90
104
 
91
- button = content_tag(:button, class: "btn #{btn_class} dropdown-toggle" + (split ? " dropdown-toggle-split" : ''), type: 'button', 'data-toggle': 'dropdown', 'aria-haspopup': true, 'aria-expanded': false) do
92
- btn_content || content_tag(:span, 'Toggle Dropdown', class: 'sr-only')
105
+ button_opts = (split ? DROPDOWN_SPLIT_OPTS : DROPDOWN_UNSPLIT_OPTS)
106
+
107
+ if btn_class != DROPDOWN_BTN_CLASS
108
+ button_opts[:class] = button_opts[:class].sub(DROPDOWN_BTN_CLASS, btn_class)
109
+ end
110
+
111
+ button = content_tag(:button, button_opts) do
112
+ btn_content || DROPDOWN_TOGGLE_DROPDOWN
93
113
  end
94
114
 
115
+ menu_opts = (right ? DROPDOWN_MENU_RIGHT_OPTS : DROPDOWN_MENU_OPTS)
116
+
95
117
  menu = if split
96
- content_tag(:div, @_dropdown_link_tos[1..-1].join.html_safe, class: ['dropdown-menu', ('dropdown-menu-right' if right)].compact.join(' '))
118
+ content_tag(:div, @_dropdown_link_tos[1..-1].join.html_safe, menu_opts)
97
119
  else
98
- content_tag(:div, @_dropdown_link_tos.join.html_safe, class: ['dropdown-menu', ('dropdown-menu-right' if right)].compact.join(' '))
120
+ content_tag(:div, @_dropdown_link_tos.join.html_safe, menu_opts)
99
121
  end
100
122
 
101
- retval = if split
123
+ @_dropdown_link_tos = nil
124
+
125
+ if split && variation == :dropleft
126
+ content_tag(:div, DROPDOWN_DROPLEFT_GROUP_OPTS) do
127
+ content_tag(:div, (button + menu), DROPDOWN_DROPLEFT_OPTS) + first.html_safe
128
+ end
129
+ elsif split
102
130
  content_tag(:div, class: 'btn-group') do
103
- content_tag(:div, class: ['btn-group', variation.to_s.presence].compact.join(' '), role: 'group') do
104
- [:dropleft].include?(variation) ? (button + menu) : (first + button + menu)
105
- end + ([:dropleft].include?(variation) ? first : '').html_safe
131
+ content_tag(:div, (first + button + menu), class: "btn-group #{variation}", role: 'group')
106
132
  end
107
133
  else
108
- content_tag(:div, class: 'dropdown') do
109
- button + menu
110
- end
134
+ content_tag(:div, (button + menu), class: 'dropdown')
111
135
  end
112
-
113
- @_dropdown_link_tos = nil
114
-
115
- retval
116
136
  end
117
137
 
118
138
  # This is a special variant of dropdown
@@ -135,17 +155,17 @@ module EffectiveBootstrapHelper
135
155
 
136
156
  # Works with dots do and dropdown do
137
157
  def dropdown_link_to(label, path, options = {})
138
- btn_class = options.delete(:btn_class).presence || 'btn-outline-primary'
158
+ btn_class = options.delete(:btn_class).presence || @_dropdown_button_class || 'btn-outline-primary'
139
159
 
140
160
  unless @_dropdown_link_tos
141
- options[:class] = [options[:class], 'dropdown-item'].compact.join(' ')
161
+ options[:class] = (options[:class] ? "dropdown-item #{options[:class]}" : 'dropdown-item')
142
162
  return link_to(label, path, options)
143
163
  end
144
164
 
145
165
  if @_dropdown_link_tos.length == 0 && @_dropdown_split
146
- options[:class] = [options[:class], 'btn', btn_class].compact.join(' ')
166
+ options[:class] = (options[:class] ? "btn #{btn_class} #{options[:class]}" : "btn #{btn_class}")
147
167
  else
148
- options[:class] = [options[:class], 'dropdown-item'].compact.join(' ')
168
+ options[:class] = (options[:class] ? "dropdown-item #{options[:class]}" : 'dropdown-item')
149
169
  end
150
170
 
151
171
  @_dropdown_link_tos << link_to(label, path, options)
@@ -100,6 +100,10 @@ module Effective
100
100
  Effective::FormInputs::RemoteLinkTo.new(name, options, builder: self).to_html(&block)
101
101
  end
102
102
 
103
+ def rich_text_area(name, options = {})
104
+ Effective::FormInputs::RichTextArea.new(name, options, builder: self).to_html { super(name, options) }
105
+ end
106
+
103
107
  def search_field(name, options = {})
104
108
  Effective::FormInputs::SearchField.new(name, options, builder: self).to_html { super(name, options) }
105
109
  end
@@ -0,0 +1,11 @@
1
+ module Effective
2
+ module FormInputs
3
+ class RichTextArea < Effective::FormInput
4
+
5
+ def input_html_options
6
+ { class: 'form-control effective_rich_text_area trix-content', id: tag_id }
7
+ end
8
+
9
+ end
10
+ end
11
+ end
@@ -1,3 +1,3 @@
1
1
  module EffectiveBootstrap
2
- VERSION = '0.8.3'.freeze
2
+ VERSION = '0.9.2'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_bootstrap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.3
4
+ version: 0.9.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-08 00:00:00.000000000 Z
11
+ date: 2020-09-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -262,6 +262,7 @@ files:
262
262
  - app/assets/images/icons/message-square.svg
263
263
  - app/assets/images/icons/mic-off.svg
264
264
  - app/assets/images/icons/mic.svg
265
+ - app/assets/images/icons/microsoft.svg
265
266
  - app/assets/images/icons/minimize-2.svg
266
267
  - app/assets/images/icons/minimize.svg
267
268
  - app/assets/images/icons/minus-circle.svg
@@ -395,6 +396,7 @@ files:
395
396
  - app/assets/javascripts/effective_bootstrap/logic.js.coffee
396
397
  - app/assets/javascripts/effective_bootstrap/other.js.coffee
397
398
  - app/assets/javascripts/effective_bootstrap/tabs.js
399
+ - app/assets/javascripts/effective_bootstrap_editor.js
398
400
  - app/assets/javascripts/effective_checks/initialize.js.coffee
399
401
  - app/assets/javascripts/effective_checks/input.js
400
402
  - app/assets/javascripts/effective_ck_editor/initialize.js.coffee
@@ -571,6 +573,7 @@ files:
571
573
  - app/assets/stylesheets/effective_bootstrap/forms.scss
572
574
  - app/assets/stylesheets/effective_bootstrap/icons.scss
573
575
  - app/assets/stylesheets/effective_bootstrap/overrides.scss
576
+ - app/assets/stylesheets/effective_bootstrap_editor.scss
574
577
  - app/assets/stylesheets/effective_checks/input.scss
575
578
  - app/assets/stylesheets/effective_date/input.scss
576
579
  - app/assets/stylesheets/effective_datetime/bootstrap-datetimepicker.scss
@@ -581,6 +584,7 @@ files:
581
584
  - app/assets/stylesheets/effective_editor/quill.scss
582
585
  - app/assets/stylesheets/effective_file/input.scss
583
586
  - app/assets/stylesheets/effective_radio/input.scss
587
+ - app/assets/stylesheets/effective_rich_text_area/input.scss
584
588
  - app/assets/stylesheets/effective_select/bootstrap-theme.css
585
589
  - app/assets/stylesheets/effective_select/input.scss
586
590
  - app/assets/stylesheets/effective_select/overrides.scss
@@ -620,6 +624,7 @@ files:
620
624
  - app/models/effective/form_inputs/radios.rb
621
625
  - app/models/effective/form_inputs/remote_link_to.rb
622
626
  - app/models/effective/form_inputs/reset.rb
627
+ - app/models/effective/form_inputs/rich_text_area.rb
623
628
  - app/models/effective/form_inputs/save.rb
624
629
  - app/models/effective/form_inputs/search_field.rb
625
630
  - app/models/effective/form_inputs/select.rb
@@ -663,7 +668,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
663
668
  - !ruby/object:Gem::Version
664
669
  version: '0'
665
670
  requirements: []
666
- rubygems_version: 3.1.2
671
+ rubygems_version: 3.1.4
667
672
  signing_key:
668
673
  specification_version: 4
669
674
  summary: Everything you need to get set up with bootstrap 4.