diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..2ccbe465 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/node_modules/ diff --git a/Gruntfile.js b/Gruntfile.js new file mode 100644 index 00000000..9914b156 --- /dev/null +++ b/Gruntfile.js @@ -0,0 +1,39 @@ +/*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/sortable.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' ] ); + +}; diff --git a/class.cmb-meta-box.php b/class.cmb-meta-box.php index e7fd6263..59d50d54 100644 --- a/class.cmb-meta-box.php +++ b/class.cmb-meta-box.php @@ -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.8', '>=' ) ) + 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(); @@ -221,7 +226,7 @@ function show() { ?> */ static function layout_fields( array $fields ) { ?> - +
if ( $current_colspan == 0 ) : ?> -
+
args['cols']; - $classes = array('field'); + $classes = array( 'field', get_class($field) ); if ( ! empty( $field->args['repeatable'] ) ) $classes[] = 'repeatable'; - $classes[] = get_class($field); - - $classes = 'class="' . esc_attr( implode(' ', array_map( 'sanitize_html_class', $classes ) ) ) . '"'; + if ( ! empty( $field->args['sortable'] ) ) + $classes[] = 'cmb-sortable'; - $attrs = array(); + $attrs = array( + sprintf( 'id="%s"', sanitize_html_class( $field->id ) ), + sprintf( 'class="%s"', esc_attr( implode(' ', array_map( 'sanitize_html_class', $classes ) ) ) ) + ); + // Field Repeatable Max. if ( isset( $field->args['repeatable_max'] ) ) - $attrs[] = 'data-rep-max="' . intval( $field->args['repeatable_max'] ) . '"'; - - $attrs = implode( ' ', $attrs ); + $attrs[] = sprintf( 'data-rep-max="%s"', intval( $field->args['repeatable_max'] ) ); ?> -
+
+ +
> + display(); ?> +
+ + - + + -
+ - - - -
-
> - display(); ?> -
-
+ + args['sortable'] ) && $this->args['sortable'] ) + wp_enqueue_script( 'jquery-ui-sortable' ); + } /** @@ -325,7 +329,7 @@ public function display() {
args['repeatable'] ) : ?> - + html(); ?> @@ -344,7 +348,7 @@ public function display() { $this->field_index = 'x'; // x used to distinguish hidden fields. $this->value = ''; ?> -