releaf-core 1.0.4 → 1.0.5
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
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1fcd7c58a85b8dc627c79cf87eb23b6ac23ffd76
|
4
|
+
data.tar.gz: ae97a97f22f3f64facb61b0eaa77b96f5210f2c0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e97a051440a22cb2ced65bc7583cc817f3ffe41a8e88215cb09d835c9f9a8da67f6f0547762c7161c1042db0587bab53f94312600d242c62a62209fc3c49d59f
|
7
|
+
data.tar.gz: 7d6f1ec452391adbf6ef7fde0da1072a62b48e506d963a12ff41dd7f4cc1ca3a6d78178f35097901cf9d83e3dd0cb7125cc8775f899e7f91ff34ba2d55bda9f4
|
@@ -10,7 +10,7 @@ var RemoteValidator = function( form )
|
|
10
10
|
v.form = form;
|
11
11
|
v.clicked_button = null;
|
12
12
|
|
13
|
-
v.form.on('click
|
13
|
+
v.form.on('click', submit_elements_selector, function( event ) {
|
14
14
|
var target = jQuery( event.target );
|
15
15
|
|
16
16
|
// webkit sends inner button elements as event targets instead of the button
|
@@ -21,14 +21,15 @@ var RemoteValidator = function( form )
|
|
21
21
|
target = closest_button;
|
22
22
|
}
|
23
23
|
|
24
|
-
// register only submit buttons - buttons with type="submit" or without type attribute at all
|
24
|
+
// register only submit buttons - buttons with type="submit" or without type attribute at all.
|
25
25
|
// direct target[0].type property is used because of inconsistent attr() method return values
|
26
26
|
// between older and newer jQuery versions
|
27
27
|
if (target.is( 'button' ) && target[0].type !== 'submit' )
|
28
28
|
{
|
29
29
|
return;
|
30
30
|
}
|
31
|
-
|
31
|
+
|
32
|
+
v.register_clicked_button( target );
|
32
33
|
});
|
33
34
|
|
34
35
|
v.form.on( 'ajax:before', function( event )
|
@@ -368,7 +369,7 @@ var RemoteValidator = function( form )
|
|
368
369
|
|
369
370
|
case 'validation:error': // validation error
|
370
371
|
|
371
|
-
v.
|
372
|
+
v.clear_clicked_button();
|
372
373
|
|
373
374
|
break;
|
374
375
|
|
@@ -381,27 +382,57 @@ var RemoteValidator = function( form )
|
|
381
382
|
});
|
382
383
|
};
|
383
384
|
|
384
|
-
RemoteValidator.prototype.
|
385
|
+
RemoteValidator.prototype.register_clicked_button = function(button)
|
385
386
|
{
|
386
387
|
var v = this;
|
387
|
-
|
388
|
-
|
389
|
-
|
388
|
+
v.clicked_button = button;
|
389
|
+
|
390
|
+
// when sending form values with FormData, the clicked button value is not included in the data
|
391
|
+
// (except on Safari, and therefore also on PhantomJS - that's why the tests worked fine even without this).
|
392
|
+
|
393
|
+
// since releaf sometimes uses the clicked button value to modify the action on the server side,
|
394
|
+
// (e.g. for "Save and create another" feature), the value of the clicked button must be appended
|
395
|
+
// to the form as a hidden field before the validation / submission starts.
|
396
|
+
|
397
|
+
// longer description:
|
398
|
+
// the algorithm to construct the form data set for a form optionally in the context
|
399
|
+
// of a submitter is as follows:
|
400
|
+
// https://www.w3.org/TR/html5/forms.html#constructing-form-data-set
|
401
|
+
// https://xhr.spec.whatwg.org/#dom-formdata
|
402
|
+
// If not specified otherwise, submitter is null.
|
403
|
+
// when this algorithm is executed from the FormData constructor, no submitter is specified,
|
404
|
+
// so no buttons are included in the form data set automatically.
|
405
|
+
|
406
|
+
var form = button.closest('form');
|
407
|
+
var hidden_field = form.find('input.submit-button-value').first();
|
408
|
+
if (hidden_field.length < 1)
|
390
409
|
{
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
410
|
+
hidden_field = jQuery('<input type="hidden" class="submit-button-value" />');
|
411
|
+
hidden_field.appendTo(form);
|
412
|
+
}
|
413
|
+
var name = button.attr('name');
|
414
|
+
if (name)
|
415
|
+
{
|
416
|
+
hidden_field.attr('name', name);
|
417
|
+
hidden_field.val(button.val());
|
418
|
+
}
|
419
|
+
else
|
420
|
+
{
|
421
|
+
// no need for the hidden field in case of nameless buttons
|
422
|
+
hidden_field.remove();
|
403
423
|
}
|
404
|
-
|
424
|
+
};
|
425
|
+
|
426
|
+
RemoteValidator.prototype.clear_clicked_button = function()
|
427
|
+
{
|
428
|
+
var v = this;
|
429
|
+
v.clicked_button = null;
|
430
|
+
v.form.find('input.submit-button-value').remove();
|
431
|
+
};
|
432
|
+
|
433
|
+
RemoteValidator.prototype.submit_form = function()
|
434
|
+
{
|
435
|
+
this.form[0].submit();
|
405
436
|
};
|
406
437
|
|
407
438
|
jQuery(function(){
|
@@ -6,6 +6,7 @@ feature "Richtext editing", js: true do
|
|
6
6
|
|
7
7
|
scenario "Image toolbar available when controller support attachments" do
|
8
8
|
visit new_admin_node_path(content_type: 'TextPage')
|
9
|
+
wait_for_all_richtexts
|
9
10
|
fill_in_richtext 'Text', with: "some text"
|
10
11
|
expect(page).to have_css("a.cke_button__image")
|
11
12
|
end
|
@@ -13,6 +14,7 @@ feature "Richtext editing", js: true do
|
|
13
14
|
scenario "Image toolbar unavailable when controller doesn't support attachments" do
|
14
15
|
allow_any_instance_of(Admin::BooksController).to receive(:releaf_richtext_attachment_upload_url).and_return("")
|
15
16
|
visit new_admin_book_path
|
17
|
+
wait_for_all_richtexts
|
16
18
|
fill_in_richtext "Summary", with: "some text"
|
17
19
|
expect(page).to_not have_css("a.cke_button__image")
|
18
20
|
end
|
@@ -20,6 +22,7 @@ feature "Richtext editing", js: true do
|
|
20
22
|
scenario "Test helper fills in correct value" do
|
21
23
|
visit new_admin_node_path(content_type: 'TextPage')
|
22
24
|
html = %Q[ <p class="xxx" id='yyy'> "HTML" 'content' </p> ]
|
25
|
+
wait_for_all_richtexts
|
23
26
|
fill_in_richtext 'Text', with: html
|
24
27
|
content = evaluate_script('CKEDITOR.instances["resource_content_attributes_text_html"].getData();')
|
25
28
|
expect(content).to match_html html
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: releaf-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- CubeSystems
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-12-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -630,7 +630,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
630
630
|
version: '0'
|
631
631
|
requirements: []
|
632
632
|
rubyforge_project:
|
633
|
-
rubygems_version: 2.
|
633
|
+
rubygems_version: 2.6.7
|
634
634
|
signing_key:
|
635
635
|
specification_version: 4
|
636
636
|
summary: core gem for releaf
|