Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trac 34893: Improve Customizer setting validation model #136

Closed
wants to merge 22 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
04bc5da
Initial WP_Customize_Setting::validate() method
westonruter Dec 8, 2015
a371d73
Add $strict param to WP_Customize_Setting::sanitize() and customize_s…
westonruter Dec 8, 2015
35333c6
Add validate_callback to WP_Customize_Setting
westonruter Dec 8, 2015
e6052b1
Validate settings upon save
westonruter Dec 8, 2015
d76859f
Add support for custom settingConstructors
westonruter Dec 15, 2015
49dca60
Export setting types to JS
westonruter Dec 15, 2015
d5446dc
Merge branch 'master' of https://github.com/xwp/wordpress-develop int…
westonruter May 12, 2016
0ce46cd
Redoing setting validation to separate validate method and filter
westonruter May 12, 2016
92186c0
Merge branch 'master' of https://github.com/xwp/wordpress-develop int…
westonruter May 15, 2016
7e2160c
Merge branch 'master' of https://github.com/xwp/wordpress-develop int…
westonruter May 15, 2016
2cc2157
Add qunit tests
westonruter May 16, 2016
3f060ed
Merge branch 'master' into trac-34893
westonruter May 16, 2016
febe39e
Clean up CSS
May 16, 2016
3af6b10
Prepend notifications container if no title
westonruter May 16, 2016
61ed673
Replace customize-control-has-notifications class name with has-notif…
westonruter May 16, 2016
0235dec
Remove error class from notifications container, move to data-type at…
westonruter May 16, 2016
2d7ea4b
Improve accessibility
westonruter May 16, 2016
81549ca
Use number_format_i18n
westonruter May 16, 2016
7724130
Re-use existing notice styles and support notice-alt for widget controls
westonruter May 16, 2016
bde80f7
Incorporate design refinements as discussed in #design in slack, and …
May 17, 2016
f86adb3
Flesh out php/js-doc; only remove error notifications at save; fix qu…
westonruter May 17, 2016
f75bada
Add unit tests for changes to WP_Customize_Manager
westonruter May 18, 2016
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

Remove error class from notifications container, move to data-type at…

…tribute on list item.

* Add data-code attribute to notification list items.
* Use compact list styles.
* Let default Notification type be error.
  • Loading branch information...
westonruter committed May 16, 2016
commit 0235decc780b1b155f1cfa8c1897f93ac70e18a6
@@ -629,7 +629,7 @@ p.customize-section-description {

#customize-controls .customize-control-notifications-container { /* Scoped to #customize-controls for specificity over notification styles in common.css. */
margin: 4px 0 8px 0;
padding: 5px 10px;
padding: 5px 0;
display: none;
cursor: default;
}
@@ -640,11 +640,17 @@ p.customize-section-description {
}

.customize-control-notifications-container li {
list-style: disc;
list-style: disc inside;
margin-bottom: 0;
margin-left: 1em;
margin-left: 0;
border-left: solid 4px transparent;
padding-left: 8px;
padding-top: 4px;
padding-bottom: 4px;
}
.customize-control-notifications-container li[data-type="error"] {
border-left-color: #dc3232;
}

.customize-control-notifications-container li:only-child {
list-style: none;
margin-left: 0;
@@ -1630,7 +1630,7 @@
return notificationsContainer;
}

notificationsContainer = $( '<div class="customize-control-notifications-container error" aria-live="assertive"></div>' );
notificationsContainer = $( '<div class="customize-control-notifications-container" aria-live="assertive"></div>' );

if ( control.container.hasClass( 'customize-control-nav_menu_item' ) ) {
control.container.find( '.menu-item-settings:first' ).prepend( notificationsContainer );
@@ -1487,7 +1487,7 @@ public function render_control_templates() {
<script type="text/html" id="tmpl-customize-control-notifications">
<ul>
<# _.each( data.notifications, function( notification ) { #>
<li class="notification-code-{{ notification.code }}">{{ notification.message || notification.code }}</li>
<li data-code="{{ notification.code }}" data-type="{{ notification.type }}">{{ notification.message || notification.code }}</li>
<# } ); #>
</ul>
</script>
@@ -761,17 +761,17 @@ window.wp = window.wp || {};
* @class
* @augments wp.customize.Class
*
* @param {string} code The error code.
* @param {object} params Params.
* @param {string} params.message The error message.
* @param {string} [params.type] The notification type.
* @param {*} [params.data] Any additional data.
* @param {string} code The error code.
* @param {object} params Params.
* @param {string} params.message The error message.
* @param {string} [params.type=error] The notification type.
* @param {*} [params.data] Any additional data.
*/
api.Notification = api.Class.extend({
initialize: function( code, params ) {
this.code = code;
this.message = params.message;
this.type = params.type || null;
this.type = params.type || 'error';
this.data = params.data || null;
}
});
@@ -129,7 +129,7 @@ <h3 class="accordion-section-title" tabindex="0">
<script type="text/html" id="tmpl-customize-control-notifications">
<ul>
<# _.each( data.notifications, function( notification ) { #>
<li class="notification-code-{{ notification.code }}">{{ notification.message || notification.code }}</li>
<li data-code="{{ notification.code }}" data-type="{{ notification.type }}">{{ notification.message || notification.code }}</li>
<# } ); #>
</ul>
</script>
@@ -163,21 +163,21 @@ jQuery( function( $ ) {
test( 'Notification object exists and has expected properties', function ( assert ) {
var notification = new wp.customize.Notification( 'mycode', {
'message': 'Hello World',
'type': 'error',
'type': 'update',
'data': { 'foo': 'bar' }
} );

assert.equal( 'mycode', notification.code );
assert.equal( 'Hello World', notification.message );
assert.equal( 'error', notification.type );
assert.equal( 'update', notification.type );
assert.deepEqual( { 'foo': 'bar' }, notification.data );

notification = new wp.customize.Notification( 'mycode2', {
'message': 'Hello Space'
} );
assert.equal( 'mycode2', notification.code );
assert.equal( 'Hello Space', notification.message );
assert.equal( null, notification.type );
assert.equal( 'error', notification.type );
assert.equal( null, notification.data );
} );
});
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.