Skip to content

Commit c7df25c

Browse files
committed
Merge branch 'master' into 51_repeatable_grid
2 parents 40e1d33 + 458f7e1 commit c7df25c

10 files changed

+623
-292
lines changed

.travis.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ matrix:
1616
env: WP_VERSION=nightly
1717
- php: 5.6
1818
env: WP_TRAVISCI=phpcs
19-
allow_failures:
20-
- php: 7.0
2119
fast_finish: true
2220

2321
branches:
@@ -37,6 +35,7 @@ before_script:
3735
fi
3836
3937
script:
38+
- find . -path ./vendor -prune -o -type "f" -iname "*.php" | xargs -L "1" php -l
4039
- |
4140
if [[ ! -z "$WP_VERSION" ]] ; then
4241
phpunit

js/fieldmanager-group-tabs.js

+40-6
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,33 @@ var FieldmanagerGroupTabs;
1919
*/
2020
bindEvents: function() {
2121

22-
$( '.fm-tab-bar a' ).on( 'click', $.proxy( function( e ) {
23-
e.preventDefault();
24-
this.selectTab( $( e.currentTarget ) );
22+
$('.fm-tab-bar').each( $.proxy( function( k, el ) {
23+
this.bindClickEvents( $( el ) );
2524
}, this ) );
26-
$( '.fm-tab-bar li' ).on( 'click', $.proxy( function( e ) {
27-
e.preventDefault();
28-
this.selectTab( $( e.currentTarget ).children('a') );
25+
$( document ).on( 'fm_added_element', $.proxy( function( e ) {
26+
var el = $( e.target );
27+
if ( ! $( '.fm-tab-bar a', el ).length ) {
28+
return;
29+
}
30+
counter = el.parent().data( 'fm-group-counter' );
31+
if ( ! counter ) {
32+
counter = el.siblings( '.fm-item' ).length - 1;
33+
} else {
34+
counter++;
35+
}
36+
el.parent().data( 'fm-group-counter', counter );
37+
var replaceProto = function( el, attr ) {
38+
el.attr( attr, el.attr( attr ).replace( '-proto-', '-' + counter + '-' ) );
39+
};
40+
41+
// We also need to set these unique IDs, because FM doesn't do it for us.
42+
$( '.fm-tab-bar a', el ).each( function() {
43+
replaceProto( $( this ), 'href' );
44+
});
45+
$( '.wp-tabs-panel', el ).each( function() {
46+
replaceProto( $( this ), 'id' );
47+
});
48+
this.bindClickEvents( el );
2949
}, this ) );
3050

3151
if ( this.supportsLocalStorage() ) {
@@ -83,6 +103,20 @@ var FieldmanagerGroupTabs;
83103

84104
},
85105

106+
/**
107+
* Bind tab item click events
108+
*/
109+
bindClickEvents: function( el ) {
110+
$( 'a', el ).on( 'click.fm-select-tab', $.proxy( function( e ) {
111+
e.preventDefault();
112+
this.selectTab( $( e.currentTarget ) );
113+
}, this ) );
114+
$( 'li', el ).on( 'click.fm-select-tab', $.proxy( function( e ) {
115+
e.preventDefault();
116+
this.selectTab( $( e.currentTarget ).children('a') );
117+
}, this ) );
118+
},
119+
86120
/**
87121
* Select a given tab
88122
*/

js/richtext.js

+5
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@
4848
try {
4949
if ( typeof tinyMCEPreInit.qtInit[ ed_id ] !== 'undefined' ) {
5050
quicktags( tinyMCEPreInit.qtInit[ ed_id ] );
51+
// _buttonsInit() only needs to be called on dynamic editors
52+
// quicktags() handles it for us on the first initialization
53+
if ( typeof QTags !== 'undefined' && -1 !== ed_id.indexOf( '-dynamic-' ) ) {
54+
QTags._buttonsInit();
55+
}
5156
}
5257
} catch(e){};
5358
}

php/class-fieldmanager-options.php

+15
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,21 @@ public function option_selected( $current_option, $options, $attribute ) {
184184
else return '';
185185
}
186186

187+
/**
188+
* Override presave_all to handle special cases associated with multiple options fields.
189+
* @input mixed[] $values
190+
* @return mixed[] sanitized values
191+
*/
192+
public function presave_all( $values, $current_values ) {
193+
// Multiple select and radio fields with no values chosen are left out of
194+
// the post request altogether, requiring special case handling.
195+
if ( 1 !== $this->limit && '' === $values ) {
196+
$values = null;
197+
}
198+
199+
return parent::presave_all( $values, $current_values );
200+
}
201+
187202
/**
188203
* Presave function, which handles sanitization and validation
189204
* @param mixed $value If a single field expects to manage an array, it must override presave()

tests/js/index.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
<title>Fieldmanager QUnit Test Suite</title>
66

77
<!-- QUnit -->
8-
<link rel="stylesheet" href="vendor/qunit-1.19.0.css">
9-
<script src="vendor/qunit-1.19.0.js"></script>
8+
<link rel="stylesheet" href="vendor/qunit-1.21.0.css">
9+
<script src="vendor/qunit-1.21.0.js"></script>
1010

1111
<script>
1212
var scripts = [];

tests/js/vendor/qunit-1.19.0.css tests/js/vendor/qunit-1.21.0.css

+17-7
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
/*!
2-
* QUnit 1.19.0
3-
* http://qunitjs.com/
2+
* QUnit 1.21.0
3+
* https://qunitjs.com/
44
*
55
* Copyright jQuery Foundation and other contributors
66
* Released under the MIT license
7-
* http://jquery.org/license
7+
* https://jquery.org/license
88
*
9-
* Date: 2015-09-01T15:00Z
9+
* Date: 2016-02-01T13:07Z
1010
*/
1111

1212
/** Font Family and Sizes */
1313

14-
#qunit-tests, #qunit-header, #qunit-banner, #qunit-testrunner-toolbar, #qunit-userAgent, #qunit-testresult {
14+
#qunit-tests, #qunit-header, #qunit-banner, #qunit-testrunner-toolbar, #qunit-filteredTest, #qunit-userAgent, #qunit-testresult {
1515
font-family: "Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial, sans-serif;
1616
}
1717

18-
#qunit-testrunner-toolbar, #qunit-userAgent, #qunit-testresult, #qunit-tests li { font-size: small; }
18+
#qunit-testrunner-toolbar, #qunit-filteredTest, #qunit-userAgent, #qunit-testresult, #qunit-tests li { font-size: small; }
1919
#qunit-tests { font-size: smaller; }
2020

2121

2222
/** Resets */
2323

24-
#qunit-tests, #qunit-header, #qunit-banner, #qunit-userAgent, #qunit-testresult, #qunit-modulefilter {
24+
#qunit-tests, #qunit-header, #qunit-banner, #qunit-filteredTest, #qunit-userAgent, #qunit-testresult, #qunit-modulefilter {
2525
margin: 0;
2626
padding: 0;
2727
}
@@ -68,6 +68,12 @@
6868
overflow: hidden;
6969
}
7070

71+
#qunit-filteredTest {
72+
padding: 0.5em 1em 0.5em 1em;
73+
background-color: #F4FF77;
74+
color: #366097;
75+
}
76+
7177
#qunit-userAgent {
7278
padding: 0.5em 1em 0.5em 1em;
7379
background-color: #2B81AF;
@@ -114,6 +120,10 @@
114120
display: list-item;
115121
}
116122

123+
#qunit-tests.hidepass {
124+
position: relative;
125+
}
126+
117127
#qunit-tests.hidepass li.running,
118128
#qunit-tests.hidepass li.pass {
119129
visibility: hidden;

0 commit comments

Comments
 (0)