Skip to content
Merged

MP6 #116

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
686ccbf
move to css directory and create 3.8 stylesheet
mattheu Nov 10, 2013
521c157
Merge branch 'refs/heads/jquery-ui' into MP6
mattheu Nov 10, 2013
d6e7dc0
css class namespacing
mattheu Nov 10, 2013
96f0660
cmv present field should be contained within td
mattheu Nov 10, 2013
d27b2b0
indenting
mattheu Nov 10, 2013
3510fbd
date time js for all
mattheu Nov 10, 2013
e905bb0
new CMB.css
mattheu Nov 10, 2013
3eba32b
button styles
mattheu Nov 10, 2013
ddabd3b
padding
mattheu Nov 10, 2013
f9e12e2
Display bugs for select fields (in IE mainly)
mattheu Nov 14, 2013
cba835f
tighten up the layout
mattheu Nov 14, 2013
1a7ebd0
Use divs and CSS to style grid layout instead of tables.
mattheu Nov 14, 2013
bbfac4d
Merge pull request #119 from humanmade/MP6-responsive
mattheu Nov 14, 2013
e25292b
grid wrapper el uneccessary
mattheu Nov 18, 2013
d1fdc10
Merge branch 'MP6' of github.com:humanmade/Custom-Meta-Boxes into MP6
mattheu Nov 18, 2013
0f81ece
Merge branch 'refs/heads/master' into MP6
mattheu Nov 19, 2013
3dd61b7
Merge branch 'refs/heads/master' into MP6
mattheu Nov 21, 2013
9c8f1f9
improve the use of version compare
mattheu Nov 24, 2013
9e40938
fix css bug in wysiwyg
mattheu Nov 24, 2013
c94fbd6
Fix added to core http://core.trac.wordpress.org/changeset/26364
mattheu Nov 25, 2013
4b49b24
Use grunt to concatenate CSS files
mattheu Nov 26, 2013
b925c32
Move CSS to externals/dist dir
mattheu Nov 26, 2013
44df870
Merge branch 'refs/heads/master' into MP6
mattheu Nov 26, 2013
0bdc4e3
fix jquery-ui images + cleanup old ones
mattheu Nov 26, 2013
5aa0276
Merge branch 'refs/heads/master' into MP6
mattheu Dec 1, 2013
1bcf505
Rename
mattheu Dec 1, 2013
9769f9e
fix tests for this branch
mattheu Dec 1, 2013
a34de5c
update for rename
mattheu Dec 1, 2013
74ecd07
fix unit test
mattheu Dec 1, 2013
a02d0fb
consistent height of field title & description
mattheu Dec 1, 2013
e74e689
no need to pass object by reference
mattheu Dec 2, 2013
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/node_modules/
31 changes: 31 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*global module:false*/
module.exports = function(grunt) {

// Project configuration.
grunt.initConfig({
// Metadata.
pkg: grunt.file.readJSON('package.json'),
banner: '/**\n' +
' * <%= pkg.title || pkg.name %> - v<%= pkg.version %> - <%= grunt.template.today("yyyy-mm-dd") %>\n' +
'<%= pkg.homepage ? " * " + pkg.homepage + "\\n" : "" %>' +
' * Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author %>;' + ' License: <%= pkg.license %>\n' +
' */',
cssmin: {
combine: {
options: {
banner: '<%= banner %>'
},
files: {
'css/dist/cmb.min.css': [ 'css/src/layout.css', 'css/src/generic.css', 'css/src/repeatable.css', 'css/src/group.css', 'css/src/file.css', 'css/src/misc-fields.css' ]
}
}
}
});

// These plugins provide necessary tasks.
grunt.loadNpmTasks('grunt-contrib-cssmin');

// Default task.
grunt.registerTask('default', [ 'cssmin' ] );

};
35 changes: 21 additions & 14 deletions class.cmb-meta-box.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,12 @@ function enqueue_scripts() {

function enqueue_styles() {

wp_enqueue_style( 'cmb-styles', trailingslashit( CMB_URL ) . 'style.css' );
$suffix = CMB_DEV ? '' : '.min';

if ( version_compare( get_bloginfo( 'version' ), '3.7', '>' ) )
wp_enqueue_style( 'cmb-styles', trailingslashit( CMB_URL ) . "css/dist/cmb$suffix.css" );
else
wp_enqueue_style( 'cmb-styles', trailingslashit( CMB_URL ) . 'css/legacy.css' );

foreach ( $this->fields as $field )
$field->enqueue_styles();
Expand Down Expand Up @@ -221,15 +226,15 @@ function show() { ?>
*/
static function layout_fields( array $fields ) { ?>

<table class="form-table cmb_metabox">
<div class="cmb_metabox">

<?php $current_colspan = 0;

foreach ( $fields as $field ) :

if ( $current_colspan == 0 ) : ?>

<tr>
<div class="cmb-row">

<?php endif;

Expand All @@ -253,25 +258,27 @@ static function layout_fields( array $fields ) { ?>

?>

<td style="width: <?php esc_attr_e( $field->args['cols'] / 12 * 100 ); ?>%" colspan="<?php esc_attr_e( $field->args['cols'] ); ?>">
<div <?php echo $classes; ?> <?php echo $attrs; ?>>
<?php $field->display(); ?>
</div>
</td>
<div class="cmb-cell-<?php echo intval( $field->args['cols'] ); ?>">

<div <?php echo $classes; ?> <?php echo $attrs; ?>>
<?php $field->display(); ?>
</div>

<input type="hidden" name="_cmb_present_<?php esc_attr_e( $field->id ); ?>" value="1" />

</div>

<?php if ( $current_colspan == 12 ) :
<?php if ( $current_colspan == 12 || $field === end( $fields ) ) :

$current_colspan = 0; ?>

</tr>
</div><!-- .cmb-row -->

<?php endif; ?>

<input type="hidden" name="_cmb_present_<?php esc_attr_e( $field->id ); ?>" value="1" />

<?php endforeach; ?>

</table>
</div>

<?php }

Expand Down
60 changes: 26 additions & 34 deletions classes.fields.php
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ public function display() {
<div class="field-item" data-class="<?php echo esc_attr( get_class($this) ) ?>" style="position: relative; <?php echo esc_attr( $this->args['style'] ); ?>">

<?php if ( $this->args['repeatable'] ) : ?>
<button class="cmb-delete-field" title="Remove field"><span class="cmb-delete-field-icon">&times;</span> Remove Group</button>
<button class="cmb-delete-field" title="Remove field"><span class="cmb-delete-field-icon">&times;</span></button>
<?php endif; ?>

<?php $this->html(); ?>
Expand All @@ -344,7 +344,7 @@ public function display() {
$this->field_index = 'x'; // x used to distinguish hidden fields.
$this->value = ''; ?>

<div class="field-item hidden" data-class="<?php echo esc_attr( get_class($this) ) ?>" style="position: relative">
<div class="field-item hidden" data-class="<?php echo esc_attr( get_class($this) ) ?>" style="position: relative; <?php echo esc_attr( $this->args['style'] ); ?>">

<?php if ( $this->args['repeatable'] ) : ?>
<button class="cmb-delete-field" title="Remove field"><span class="cmb-delete-field-icon">&times;</span> Remove Group</button>
Expand All @@ -369,9 +369,7 @@ public function display() {
*/
class CMB_Text_Field extends CMB_Field {

public function html() {

?>
public function html() { ?>

<input type="text" <?php $this->id_attr(); ?> <?php $this->boolean_attr(); ?> <?php $this->class_attr(); ?> <?php $this->name_attr(); ?> value="<?php echo esc_attr( $this->get_value() ); ?>" />

Expand Down Expand Up @@ -598,10 +596,10 @@ public function html() { ?>
class CMB_Date_Field extends CMB_Field {

public function enqueue_scripts() {

parent::enqueue_scripts();

wp_enqueue_style( 'cmb-jquery-ui', trailingslashit( CMB_URL ) . 'css/jquery-ui.css', '1.10.3' );
wp_enqueue_style( 'cmb-jquery-ui', trailingslashit( CMB_URL ) . 'css/vendor/jquery-ui/jquery-ui.css', '1.10.3' );

wp_enqueue_script( 'cmb-datetime', trailingslashit( CMB_URL ) . 'js/field.datetime.js', array( 'jquery', 'jquery-ui-core', 'jquery-ui-datepicker', 'cmb-scripts' ) );
}
Expand All @@ -619,7 +617,7 @@ public function enqueue_scripts() {

parent::enqueue_scripts();

wp_enqueue_style( 'cmb-jquery-ui', trailingslashit( CMB_URL ) . 'css/jquery-ui.css', '1.10.3' );
wp_enqueue_style( 'cmb-jquery-ui', trailingslashit( CMB_URL ) . 'css/vendor/jquery-ui/jquery-ui.css', '1.10.3' );

wp_enqueue_script( 'cmb-timepicker', trailingslashit( CMB_URL ) . 'js/jquery.timePicker.min.js', array( 'jquery', 'cmb-scripts' ) );
wp_enqueue_script( 'cmb-datetime', trailingslashit( CMB_URL ) . 'js/field.datetime.js', array( 'jquery', 'jquery-ui-core', 'jquery-ui-datepicker', 'cmb-scripts' ) );
Expand Down Expand Up @@ -1268,7 +1266,7 @@ function cmb_ajax_post_select() {
class CMB_Group_Field extends CMB_Field {

static $added_js;
public $fields = array();
private $fields = array();

function __construct() {

Expand Down Expand Up @@ -1309,11 +1307,11 @@ public function enqueue_styles() {
parent::enqueue_styles();

foreach ( $this->args['fields'] as $f ) {

$class = _cmb_field_class_for_type( $f['type'] );
$field = new $class( '', '', array(), $f );
$field->enqueue_styles();
}

}

public function display() {
Expand Down Expand Up @@ -1360,21 +1358,10 @@ public function display() {

}

public function add_field( CMB_Field $field ) {

$field->parent = &$this;
$this->fields[$field->id] = $field;

}

public function &get_fields() {
return $this->fields;
}

public function html() {

$fields = &$this->get_fields();
$value = $this->value;
$value = $this->value;

if ( ! empty( $value ) ) {
foreach ( $value as $field_id => $field_value ) {
Expand All @@ -1391,40 +1378,45 @@ public function html() {

?>

<div class="group <?php echo ! empty( $this->args['repeatable'] ) ? 'cloneable' : '' ?>" style="position: relative">
<?php if ( $this->args['repeatable'] ) : ?>
<button class="cmb-delete-field" title="Remove field"><span class="cmb-delete-field-icon">&times;</span> Remove Group</button>
<?php endif; ?>

<?php if ( $this->args['repeatable'] ) : ?>
<button class="cmb-delete-field" title="Remove field"><span class="cmb-delete-field-icon">&times;</span> Remove Group</button>
<?php endif; ?>

<?php CMB_Meta_Box::layout_fields( $fields ); ?>

</div>
<?php CMB_Meta_Box::layout_fields( $fields ); ?>

<?php }

public function parse_save_values() {

$fields = &$this->get_fields();
$values = &$this->get_values();

foreach ( $values as &$group_value ) {
foreach ( $group_value as $field_id => &$field_value ) {

if ( ! isset( $fields[$field_id] ) ) {
$field_value = array();
continue;
}

$field = $fields[$field_id];
$field->values = $field_value;
$field->parse_save_values();

$field_value = $field->get_values();

}
}


}

public function add_field( CMB_Field $field ) {
$field->parent = $this;
$this->fields[$field->id] = $field;
}

public function &get_fields() {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't need the & me thinks, why did you need that?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this needed in order to use the value returned by get_fields() as a reference to $this->fields right? Am I doing it wrong?

I'm going to merge anyway because this was actually added already - I just moved the function in this PR. I would like to ensure I'm doing it the right way.

return $this->fields;
}

public function set_values( array $values ) {
Expand Down
17 changes: 17 additions & 0 deletions css/dist/cmb.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* CMB Styles
*
* This file is used for development only and is loaded when CMB_DEV is defined as true.
* cmb.min.css is generated by the Grunt build process.
*/

@import '../src/layout.css';
@import '../src/generic.css';

/** Features **/
@import '../src/repeatable.css';

/** Fields **/
@import '../src/group.css';
@import '../src/file.css';
@import '../src/misc-fields.css';
6 changes: 6 additions & 0 deletions css/dist/cmb.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 6 additions & 5 deletions style.css → css/legacy.css
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ span.cmb_metabox_description { color: #AAA; font-style: italic;}
.cmb_metabox .cmb_upload_status { margin: 10px 0 0 0;}
.cmb_metabox .cmb_upload_status .img_status { position: relative; }
.cmb_metabox .cmb_upload_status .img_status img { border:1px solid #DFDFDF; background: #FAFAFA; max-width:350px; padding: 5px; -moz-border-radius: 2px; border-radius: 2px;}
.cmb_remove_file_button { text-indent: -9999px; background: url(images/ico-delete.png); width: 16px; height: 16px; position: absolute; top: -5px; left: -5px;}
.cmb_remove_file_button { text-indent: -9999px; background: url(../images/ico-delete.png); width: 16px; height: 16px; position: absolute; top: -5px; left: -5px;}
/* Sidebar placement adjustments */
.inner-sidebar table.cmb_metabox input[type=text], table.cmb_metabox textarea { width: 100%; }
.inner-sidebar table.cmb_metabox .cmb_upload_status .img_status img { width: 90%; }
Expand Down Expand Up @@ -101,14 +101,14 @@ div.time-picker li.selected { background: #0063CE; color: #fff; }
left: 50%;
margin-top: -4px;
margin-left: -4px;
background-image: url('images/cmb-icon-remove.png');
background-image: url( '../images/cmb-icon-remove.png');
background-repeat: no-repeat;
}

@media only screen and (-webkit-min-device-pixel-ratio : 1.5), only screen and (min-device-pixel-ratio : 1.5) {

.cmb-delete-field .cmb-delete-field-icon {
background-image: url('images/cmb-icon-remove@2x.png');
background-image: url( '../images/cmb-icon-remove@2x.png');
background-size: 8px 8px;
}

Expand Down Expand Up @@ -155,6 +155,7 @@ button.repeat-field { display: block !important; clear: both; }
border: 1px solid #DDD;
background: #ECECEC;
border-radius: 3px;
position: relative;
}

.CMB_Group_Field .group > .cmb-delete-field {
Expand Down Expand Up @@ -199,7 +200,7 @@ button.repeat-field { display: block !important; clear: both; }
.CMB_Color_Picker .iris-picker .iris-strip .ui-slider-handle { margin-bottom: 0; }
.CMB_Color_Picker .iris-picker .iris-strip .ui-slider-handle:focus { outline: none; }

.loading::before { content: ' '; display: block; background: url( 'images/wpspin.gif' ) no-repeat; width: 16px; height: 16px; position: absolute; top: 50%; left: 50%; margin-top: -8px; margin-left: -8px; }
.cmb-loading::before { content: ' '; display: block; background: url( '../images/wpspin.gif' ) no-repeat; width: 16px; height: 16px; position: absolute; top: 50%; left: 50%; margin-top: -8px; margin-left: -8px; }
@media only screen and (-webkit-min-device-pixel-ratio : 1.5), only screen and (min-device-pixel-ratio : 1.5) {
.loading::before { background-image: url( 'images/wpspin-2x.gif'); background-size: 16px 16px; }
.cmb-loading::before { background-image: url( '../images/wpspin-2x.gif'); background-size: 16px 16px; }
}
Loading