effective_bootstrap 0.9.39 → 0.9.43

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: ac9e0d6013b991db010ef717fe181ea041d2d9e756e0bb477d9ff7544248b718
4
- data.tar.gz: f212aea0848dd0d7d50b0186b798ce9cb52d8c5e17bba7f4cfd63b69cc716861
3
+ metadata.gz: 8f0ef370fca1da439ea16cd2708d95e49a7783097817ba724c54a4da175188fe
4
+ data.tar.gz: 33471717cd69b0cba4eff2122ad7fb7c638393df3114fbccb3c0c1f60b9f7849
5
5
  SHA512:
6
- metadata.gz: a87134d9311b1837d06e9e37857c03930a52cb0c211a2bd1dd05276ecd7eca76d57615e71cea80b271b9f11a7469647ff4915f790330f19ddd8a2c185a0604c6
7
- data.tar.gz: 35fca4a527a44b58237cc6e71ab8846aa4da76d0f1c7e82078d272323bfb90be12ca16c4f27574603b118a90f5831753fb0e010bc7e5586626c982cf8be33901
6
+ metadata.gz: 49ac133d45de49472654194c63aaf7b1ecf29b38745572f3f5567eeb3ea221b4066b84b0e00c7d21cf979657ab7b93b9f4698f6d0b0b31d3921e85089aa77f4a
7
+ data.tar.gz: 87d0cdb39ab2317f53dbfdee5944e8bef922c5122e8e6542e2257f1a8b27edc635dba42a618af02113b175807d852d8f6efce373b0b3c68bd91bdd79ab399404
@@ -6,7 +6,25 @@ uploadActiveStorage = (editor, data) ->
6
6
 
7
7
  upload.create (error, blob) =>
8
8
  url = '/rails/active_storage/blobs/redirect/' + blob.signed_id + '/' + blob.filename
9
- editor.complete({ file: { url: url }}, data.e)
9
+ editor.complete({ file: { url: url, name: blob.filename, content_type: blob.content_type }}, data.e)
10
+
11
+ insertUploadByDrop = (response, e) ->
12
+ if @app.block.is()
13
+ instance = @app.block.get()
14
+ target = e.target
15
+ type = instance.getType()
16
+
17
+ if ((type == 'card' && target && target.tagName == 'IMG' && instance.hasImage()) || type == 'image')
18
+ return @change(response)
19
+ else if (e && type != 'card' && instance.isEditable())
20
+ @app.insertion.insertPoint(e)
21
+
22
+ content_type = (response.file.content_type || '')
23
+
24
+ unless content_type.startsWith('image') && @app.filelink
25
+ @app.filelink._insert(response)
26
+ else
27
+ @insert(response)
10
28
 
11
29
  (this.EffectiveBootstrap || {}).effective_article_editor = ($element, options) ->
12
30
 
@@ -15,4 +33,9 @@ uploadActiveStorage = (editor, data) ->
15
33
  upload: (editor, data) -> uploadActiveStorage(editor, data)
16
34
  }
17
35
 
18
- ArticleEditor($element, options)
36
+ options['filelink'] = {
37
+ upload: (editor, data) -> uploadActiveStorage(editor, data)
38
+ }
39
+
40
+ editor = ArticleEditor($element, options)
41
+ editor.app.image.insertByDrop = insertUploadByDrop
@@ -4,19 +4,27 @@ if <%= !!EffectiveBootstrap.use_custom_data_confirm %> && (window.Rails || $.rai
4
4
  $(document).on 'confirm', (event) ->
5
5
  $obj = $(event.target)
6
6
 
7
- if $obj.data('confirmed')
8
- true
9
- else
10
- $obj.data('confirm-original', $obj.html())
11
- $obj.html($obj.data('confirm'))
12
- $obj.data('confirmed', true)
7
+ # Already confirmed
8
+ return true if $obj.data('confirmed')
9
+
10
+ # Otherwise unconfirmed
11
+ $obj.data('confirm-original', $obj.html())
12
+ $obj.html($obj.data('confirm'))
13
+ $obj.data('confirmed', true)
14
+
15
+ # When using the direct to s3 active storage javascript library
16
+ $activeStorageUpload = $obj.closest('form').find('input[type=file][data-direct-upload-url]')
17
+
18
+ if $activeStorageUpload.length == 0
13
19
  setTimeout(
14
20
  (->
15
21
  $obj.data('confirmed', false)
16
22
  $obj.html($obj.data('confirm-original'))
17
23
  )
18
24
  , 4000)
19
- false # don't show the confirmation dialog
25
+
26
+ # Do not display the confirmation dialog
27
+ false
20
28
 
21
29
  if window.Rails
22
30
  window.Rails.confirm = (message) -> true
@@ -13,7 +13,12 @@ $(document).on 'direct-upload:error', (event) ->
13
13
  $("[data-direct-upload-id=#{event.detail.id}]").addClass('direct-upload--error').attr('title', event.detail.error)
14
14
 
15
15
  $(document).on 'direct-upload:end', (event) ->
16
- $("[data-direct-upload-id=#{event.detail.id}]").addClass('direct-upload--complete')
16
+ $obj = $("[data-direct-upload-id=#{event.detail.id}]")
17
+
18
+ $obj.addClass('direct-upload--complete')
19
+
20
+ # Rails UJS fix
21
+ $obj.closest('form').find('[type=submit][data-confirm]').data('confirmed', true)
17
22
 
18
23
  $(document).on 'change', "input[type='file'][data-click-submit]", (event) ->
19
24
  $(event.currentTarget).closest('form').find('button[type=submit],input[type=submit]').first().click()
@@ -68,7 +68,9 @@ $(document).on 'click', '[data-effective-form-has-many-remove]', (event) ->
68
68
  event.preventDefault()
69
69
 
70
70
  $obj = $(event.currentTarget)
71
- return unless $obj.data('confirmed') if $obj.data('confirm')
71
+
72
+ if (window.Rails && window.Rails.effective_bootstrap_custom_data_confirm) || ($.rails && $.rails.effective_bootstrap_custom_data_confirm)
73
+ return unless $obj.data('confirmed') if $obj.data('confirm')
72
74
 
73
75
  $hasMany = $obj.closest('.form-has-many')
74
76
  return unless $hasMany.length > 0
@@ -1,4 +1,4 @@
1
+ @import './collapse';
1
2
  @import './forms';
2
3
  @import './icons';
3
4
  @import './overrides';
4
-
@@ -0,0 +1,7 @@
1
+ .effective-collapse-actions {
2
+ .collapse-label-expand { display: none; }
3
+ .collapse-label-collapse { display: inline-block; }
4
+
5
+ &.collapsed .collapse-label-expand { display: inline-block; }
6
+ &.collapsed .collapse-label-collapse { display: none; }
7
+ }
@@ -18,6 +18,31 @@ module EffectiveBootstrapHelper
18
18
  content
19
19
  end
20
20
 
21
+ def accordion_collapse(label, opts = {}, &block)
22
+ raise 'expected a block' unless block_given?
23
+
24
+ id = "collapse-#{effective_bootstrap_unique_id}"
25
+ show = (opts.delete(:show) == true)
26
+
27
+ link_opts = { 'data-toggle': 'collapse', role: 'button', href: "##{id}", 'aria-controls': "##{id}", 'aria-expanded': show }
28
+
29
+ link_opts[:class] = opts.delete(:link_class) || 'btn btn-link'
30
+ div_class = opts.delete(:div_class)
31
+ card_class = opts.delete(:card_class) || 'card card-body my-2'
32
+
33
+ # Accordion collapse
34
+ content_tag(:div, class: "card mb-0") do
35
+ content_tag(:div, class: "card-header") do
36
+ content_tag(:h2, class: "mb-0") do
37
+ content_tag(:button, label, link_opts.merge(class: "btn btn-link"))
38
+ end
39
+ end +
40
+ content_tag(:div, id: id, class: ['collapse', div_class, ('show' if show)].compact.join(' '), "data-parent": "##{@_accordion_active}") do
41
+ content_tag(:div, capture(&block), class: "card-body")
42
+ end
43
+ end
44
+ end
45
+
21
46
  # https://getbootstrap.com/docs/4.0/components/card/
22
47
  # = card('title do')
23
48
  # %p Stuff
@@ -56,40 +81,67 @@ module EffectiveBootstrapHelper
56
81
  # = collapse('already expanded', show: true) do
57
82
  # %p Something Expanded
58
83
 
84
+ # the word 'show' will automatically be replaced with hide and an icon added
85
+ # = collapse('show items') do
86
+ # %p Something Expanded
87
+
88
+ # Override the expand and collapse labels directly
89
+ # = collapse('show items', expand: "Show items" + icon('ok'), collapse: "Hide items" + icon('x')) do
90
+ # %p Something Expanded
91
+
59
92
  # collapse(items.length, class: 'btn btn-primary', class: 'mt-2') do
60
93
  # items.map { |item| content_tag(:div, item.to_s) }.join.html_safe
61
94
  # end
95
+
96
+ COLLAPSE_SUBSTITUTIONS = {
97
+ 'Show ' => 'Hide ',
98
+ 'show ' => 'hide ',
99
+ 'Expand ' => 'Collapse ',
100
+ 'expand ' => 'collapse ',
101
+ ' More' => ' Less',
102
+ ' more' => ' less'
103
+ }
104
+
62
105
  def collapse(label, opts = {}, &block)
63
106
  raise 'expected a block' unless block_given?
64
107
 
108
+ return accordian_collapse(label, opts, &block) if @_accordion_active
109
+
65
110
  id = "collapse-#{effective_bootstrap_unique_id}"
66
111
  show = (opts.delete(:show) == true)
67
112
 
113
+ # Figure out all the button / link options
68
114
  link_opts = { 'data-toggle': 'collapse', role: 'button', href: "##{id}", 'aria-controls': "##{id}", 'aria-expanded': show }
69
115
 
116
+ # Two link labels
117
+ label_expand = opts.delete(:expand) || label.to_s.tap do |label|
118
+ COLLAPSE_SUBSTITUTIONS.each { |show, hide| label.sub!(hide, show) }
119
+ end + icon('chevron-down')
120
+
121
+ label_collapse = opts.delete(:collapse) || label.to_s.tap do |label|
122
+ COLLAPSE_SUBSTITUTIONS.each { |show, hide| label.sub!(show, hide) }
123
+ end + icon('chevron-up')
124
+
125
+ # The link html classes
70
126
  link_opts[:class] = opts.delete(:link_class) || 'btn btn-link'
127
+ link_opts[:class] += ' effective-collapse-actions hidden-print'
128
+ link_opts[:class] += ' collapsed' unless show
129
+
130
+ # The div and the card now
71
131
  div_class = opts.delete(:div_class)
72
132
  card_class = opts.delete(:card_class) || 'card card-body my-2'
73
133
 
74
- if @_accordion_active
75
- # Accordion collapse
76
- content_tag(:div, class: "card mb-0") do
77
- content_tag(:div, class: "card-header") do
78
- content_tag(:h2, class: "mb-0") do
79
- content_tag(:button, label, link_opts.merge(class: "btn btn-link"))
80
- end
81
- end +
82
- content_tag(:div, id: id, class: ['collapse', div_class, ('show' if show)].compact.join(' '), "data-parent": "##{@_accordion_active}") do
83
- content_tag(:div, capture(&block), class: "card-body")
84
- end
85
- end
86
- else
87
- # Normal collapse
88
- content_tag(:a, label, link_opts) +
89
- content_tag(:div, id: id, class: ['collapse', div_class, ('show' if show)].compact.join(' ')) do
90
- content_tag(:div, capture(&block), class: card_class)
91
- end
134
+ # Normal collapse
135
+ link_tag = content_tag(:a, link_opts) do
136
+ content_tag(:div, label_expand.html_safe, class: 'collapse-label-expand') +
137
+ content_tag(:div, label_collapse.html_safe, class: 'collapse-label-collapse')
138
+ end
139
+
140
+ div_tag = content_tag(:div, id: id, class: ['effective-collapse collapse', div_class, ('show' if show)].compact.join(' ')) do
141
+ content_tag(:div, capture(&block), class: card_class)
92
142
  end
143
+
144
+ link_tag + div_tag
93
145
  end
94
146
 
95
147
  # Button Dropdowns
@@ -14,6 +14,7 @@ module Effective
14
14
  body: 'article-editor-body',
15
15
  table: 'table'
16
16
  },
17
+ filelink: nil,
17
18
  grid: {
18
19
  classname: 'row',
19
20
  columns: 12,
@@ -40,7 +41,7 @@ module Effective
40
41
  '12': 'col-sm-12'
41
42
  }
42
43
  },
43
- plugins: ['blockcode', 'cellcolor', 'imageposition', 'imageresize', 'inlineformat', 'listitem', 'removeformat', 'reorder', 'style'],
44
+ plugins: ['blockcode', 'cellcolor', 'imageposition', 'imageresize', 'inlineformat', 'listitem', 'removeformat', 'reorder', 'style', 'filelink'],
44
45
  quote: {
45
46
  template: '<blockquote><p></p></blockquote>'
46
47
  },
@@ -1,3 +1,3 @@
1
1
  module EffectiveBootstrap
2
- VERSION = '0.9.39'.freeze
2
+ VERSION = '0.9.43'.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.9.39
4
+ version: 0.9.43
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: 2021-07-28 00:00:00.000000000 Z
11
+ date: 2021-09-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -615,6 +615,7 @@ files:
615
615
  - app/assets/stylesheets/effective_article_editor/input.scss
616
616
  - app/assets/stylesheets/effective_bootstrap.scss
617
617
  - app/assets/stylesheets/effective_bootstrap/base.scss
618
+ - app/assets/stylesheets/effective_bootstrap/collapse.scss
618
619
  - app/assets/stylesheets/effective_bootstrap/forms.scss
619
620
  - app/assets/stylesheets/effective_bootstrap/icons.scss
620
621
  - app/assets/stylesheets/effective_bootstrap/overrides.scss