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 +4 -4
- data/app/assets/javascripts/effective_article_editor/initialize.js.coffee +25 -2
- data/app/assets/javascripts/effective_bootstrap/confirm.js.coffee.erb +15 -7
- data/app/assets/javascripts/effective_file/initialize.js.coffee +6 -1
- data/app/assets/javascripts/effective_has_many/initialize.js.coffee +3 -1
- data/app/assets/stylesheets/effective_bootstrap/base.scss +1 -1
- data/app/assets/stylesheets/effective_bootstrap/collapse.scss +7 -0
- data/app/helpers/effective_bootstrap_helper.rb +70 -18
- data/app/models/effective/form_inputs/article_editor.rb +2 -1
- data/lib/effective_bootstrap/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8f0ef370fca1da439ea16cd2708d95e49a7783097817ba724c54a4da175188fe
|
4
|
+
data.tar.gz: 33471717cd69b0cba4eff2122ad7fb7c638393df3114fbccb3c0c1f60b9f7849
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
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
|
-
|
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}]")
|
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
|
-
|
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
|
@@ -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
|
-
|
75
|
-
|
76
|
-
content_tag(:div, class:
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
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
|
},
|
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.
|
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-
|
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
|