formstrap 0.4.3 → 0.4.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/formstrap/controllers/select_controller.js +8 -1
- data/app/assets/javascripts/formstrap/vendor/redactor/plugins/linkstyles.js +17 -2
- data/app/assets/javascripts/formstrap.js +20 -3
- data/app/models/formstrap/select_view.rb +2 -1
- data/app/views/formstrap/_link.html.erb +3 -0
- data/lib/formstrap/form_builder.rb +5 -5
- data/lib/formstrap/version.rb +1 -1
- data/package.json +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: '0379b9b80ad9551b56d07884264fcc37132b72d5539976ec4034800a09adaeb2'
|
4
|
+
data.tar.gz: bbd8d0892fce51fa07375b3e6a414e169344825f5da142c5a06ab87a7696424b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0788d10916489c6fabe8798a87ffa10a75d46a4e57a2cd8c73455cc64630414ebbdbcfe213041437b22d108df2a3fa986e3692e8ea46ba25fdc28bb068142a42'
|
7
|
+
data.tar.gz: 3fba876a0ce0c7be868100726d60af6b1b5aae1b8af675e4861b9ba016405920b1ff35f537a12ce9aa10865fb1e599662170446d999a9bc6e69752f9cf2dc252
|
@@ -3,6 +3,10 @@ import TomSelect from 'tom-select'
|
|
3
3
|
import I18n from '../config/i18n'
|
4
4
|
|
5
5
|
export default class extends Controller {
|
6
|
+
static values = {
|
7
|
+
selected: Array
|
8
|
+
}
|
9
|
+
|
6
10
|
connect () {
|
7
11
|
if (this.element.hasAttribute('multiple') || this.element.dataset.tomSelect === 'true') {
|
8
12
|
this.initTomSelect()
|
@@ -45,7 +49,10 @@ export default class extends Controller {
|
|
45
49
|
|
46
50
|
initTomSelect () {
|
47
51
|
const defaultOptions = this.defaultOptions()
|
48
|
-
const options = {
|
52
|
+
const options = {
|
53
|
+
create: this.hasTags(),
|
54
|
+
items: this.selectedValue
|
55
|
+
}
|
49
56
|
|
50
57
|
/* eslint-disable no-new */
|
51
58
|
new TomSelect(this.element, { ...defaultOptions, ...options })
|
@@ -31,11 +31,13 @@ Redactor.add('plugin', 'linkstyles', {
|
|
31
31
|
}
|
32
32
|
},
|
33
33
|
'link.change': function (e) {
|
34
|
-
|
34
|
+
let link = e.params.element.nodes[0]
|
35
|
+
link = this.ensureValidProtocol(link)
|
35
36
|
this.applyStylingToLink(link)
|
36
37
|
},
|
37
38
|
'link.add': function (e) {
|
38
|
-
|
39
|
+
let link = e.params.element.nodes[0]
|
40
|
+
link = this.ensureValidProtocol(link)
|
39
41
|
this.applyStylingToLink(link)
|
40
42
|
}
|
41
43
|
},
|
@@ -47,6 +49,7 @@ Redactor.add('plugin', 'linkstyles', {
|
|
47
49
|
const stack = this.app.modal.getStack()
|
48
50
|
|
49
51
|
const item = stack.getFormItem('url')
|
52
|
+
|
50
53
|
const box = this.dom('<div>').addClass('rx-form-item')
|
51
54
|
|
52
55
|
// Add a select
|
@@ -69,6 +72,18 @@ Redactor.add('plugin', 'linkstyles', {
|
|
69
72
|
link.classList.add(className)
|
70
73
|
})
|
71
74
|
},
|
75
|
+
ensureValidProtocol (link) {
|
76
|
+
let url = link.getAttribute('href')
|
77
|
+
|
78
|
+
// Match valid protocols
|
79
|
+
const regex = /^(https?:\/\/|mailto:|ftp:\/\/)/i
|
80
|
+
if (!regex.test(url)) {
|
81
|
+
url = `https://${url}`
|
82
|
+
}
|
83
|
+
|
84
|
+
link.setAttribute('href', url)
|
85
|
+
return link
|
86
|
+
},
|
72
87
|
buildSelect () {
|
73
88
|
// Create a select node
|
74
89
|
const select = this.dom('<select>').addClass('rx-form-select')
|
@@ -13435,10 +13435,16 @@ var select_controller_default = class extends Controller {
|
|
13435
13435
|
}
|
13436
13436
|
initTomSelect() {
|
13437
13437
|
const defaultOptions = this.defaultOptions();
|
13438
|
-
const options = {
|
13438
|
+
const options = {
|
13439
|
+
create: this.hasTags(),
|
13440
|
+
items: this.selectedValue
|
13441
|
+
};
|
13439
13442
|
new import_tom_select.default(this.element, { ...defaultOptions, ...options });
|
13440
13443
|
}
|
13441
13444
|
};
|
13445
|
+
__publicField(select_controller_default, "values", {
|
13446
|
+
selected: Array
|
13447
|
+
});
|
13442
13448
|
|
13443
13449
|
// app/assets/javascripts/formstrap/controllers/textarea_controller.js
|
13444
13450
|
var textarea_controller_default = class extends Controller {
|
@@ -14456,11 +14462,13 @@ Redactor.add("plugin", "linkstyles", {
|
|
14456
14462
|
}
|
14457
14463
|
},
|
14458
14464
|
"link.change": function(e) {
|
14459
|
-
|
14465
|
+
let link = e.params.element.nodes[0];
|
14466
|
+
link = this.ensureValidProtocol(link);
|
14460
14467
|
this.applyStylingToLink(link);
|
14461
14468
|
},
|
14462
14469
|
"link.add": function(e) {
|
14463
|
-
|
14470
|
+
let link = e.params.element.nodes[0];
|
14471
|
+
link = this.ensureValidProtocol(link);
|
14464
14472
|
this.applyStylingToLink(link);
|
14465
14473
|
}
|
14466
14474
|
},
|
@@ -14484,6 +14492,15 @@ Redactor.add("plugin", "linkstyles", {
|
|
14484
14492
|
link.classList.add(className);
|
14485
14493
|
});
|
14486
14494
|
},
|
14495
|
+
ensureValidProtocol(link) {
|
14496
|
+
let url = link.getAttribute("href");
|
14497
|
+
const regex = /^(https?:\/\/|mailto:|ftp:\/\/)/i;
|
14498
|
+
if (!regex.test(url)) {
|
14499
|
+
url = `https://${url}`;
|
14500
|
+
}
|
14501
|
+
link.setAttribute("href", url);
|
14502
|
+
return link;
|
14503
|
+
},
|
14487
14504
|
buildSelect() {
|
14488
14505
|
const select = this.dom("<select>").addClass("rx-form-select");
|
14489
14506
|
const items = this.opts.get("linkstyles.items");
|
@@ -11,15 +11,15 @@ module Formstrap
|
|
11
11
|
render_input(:association, attribute, options)
|
12
12
|
end
|
13
13
|
|
14
|
-
def preview_button(
|
14
|
+
def preview_button(url = nil, options = {}, &block)
|
15
15
|
default_options = {
|
16
16
|
data: {
|
17
17
|
controller: "preview",
|
18
|
-
|
19
|
-
}
|
20
|
-
type: nil
|
18
|
+
preview_url_value: url
|
19
|
+
}
|
21
20
|
}
|
22
|
-
|
21
|
+
|
22
|
+
@template.render("formstrap/link", form: self, url: url, options: default_options.deep_merge(options), &block)
|
23
23
|
end
|
24
24
|
|
25
25
|
def checkbox(attribute, formstrap: true, **options)
|
data/lib/formstrap/version.rb
CHANGED
data/package.json
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: formstrap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jef Vlamings
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-11-21 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: An extensive Bootstrap form library to power your Ruby On Rails application.
|
14
14
|
email:
|
@@ -142,6 +142,7 @@ files:
|
|
142
142
|
- app/views/formstrap/_hint.html.erb
|
143
143
|
- app/views/formstrap/_input_group.html.erb
|
144
144
|
- app/views/formstrap/_label.html.erb
|
145
|
+
- app/views/formstrap/_link.html.erb
|
145
146
|
- app/views/formstrap/_media.html.erb
|
146
147
|
- app/views/formstrap/_number.html.erb
|
147
148
|
- app/views/formstrap/_password.html.erb
|