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

Expand conditions #3

Merged
merged 16 commits into from
Nov 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
55 changes: 24 additions & 31 deletions Gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,18 @@ const config = {
};

function adminstyles() {
return gulp.src(config.styles.admin)
return gulp.src(config.styles.admin, { allowEmpty: true })
.pipe(sourcemaps.init()) // Sourcemaps need to init before compilation
.pipe(sassGlob()) // Allow for globbed @import statements in SCSS
.pipe(sass()) // Compile
.on('error', sass.logError) // Error reporting
.pipe(postcss([
autoprefixer( {
'browsers': [ 'last 2 version' ]
mqpacker( {
'sort': true
} ),
cssnano() // Minify
cssnano( {
'safe': true // Use safe optimizations.
} ) // Minify
]))
.pipe(rename({ // Rename to .min.css
suffix: '.min'
Expand All @@ -66,20 +68,19 @@ function adminstyles() {
}

function frontendstyles() {
return gulp.src(config.styles.front_end)
return gulp.src(config.styles.front_end, { allowEmpty: true } )
.pipe(sourcemaps.init()) // Sourcemaps need to init before compilation
.pipe(sassGlob()) // Allow for globbed @import statements in SCSS
.pipe(sass()) // Compile
.on('error', sass.logError) // Error reporting
.pipe(postcss([
autoprefixer( {
'browsers': [ 'last 2 version' ]
mqpacker( {
'sort': true
} ),
cssnano() // Minify
cssnano( {
'safe': true // Use safe optimizations.
} ) // Minify
]))
.pipe(rename({ // Rename to .min.css
suffix: '.min'
}))
.pipe(sourcemaps.write()) // Write the sourcemap files
.pipe(gulp.dest(config.styles.dest)) // Drop the resulting CSS file in the specified dir
.pipe(browserSync.stream());
Expand All @@ -99,11 +100,7 @@ function adminscripts() {
.pipe(babel({
presets: ['@babel/preset-env']
}))
.pipe(concat('' + packagejson.name + '-admin.js')) // Concatenate
/*.pipe(uglify()) // Minify + compress
.pipe(rename({
suffix: '.min'
}))*/
.pipe(concat(packagejson.name + '-admin.js')) // Concatenate
.pipe(sourcemaps.write())
.pipe(eslint())
.pipe(gulp.dest(config.scripts.dest))
Expand Down Expand Up @@ -175,19 +172,15 @@ function watch() {
}
}

// export tasks
exports.sasslint = sasslint;
exports.adminstyles = adminstyles;
exports.frontendstyles = frontendstyles;
exports.adminscripts = adminscripts;
exports.frontendscripts = frontendscripts;
exports.uglifyscripts = uglifyscripts;
exports.translate = translate;
exports.watch = watch;
// define complex tasks
const styles = gulp.series(sasslint, adminstyles, frontendstyles);
const scripts = gulp.series(adminscripts, frontendscripts, uglifyscripts);
const build = gulp.series(gulp.parallel(styles, scripts, translate));

// What happens when we run gulp?
gulp.task('default',
gulp.series(
gulp.parallel(adminstyles, adminscripts, translate) // run these tasks asynchronously
)
);
// export tasks
exports.styles = styles;
exports.scripts = scripts;
exports.translate = translate;
exports.watch = watch;
exports.build = build;
exports.default = build;
2 changes: 1 addition & 1 deletion assets/css/select2.min.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/css/selectwoo.min.css

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions assets/css/wp-message-inserter-plugin-admin.min.css

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

3 changes: 2 additions & 1 deletion assets/js/select2.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/js/selectwoo.min.js

Large diffs are not rendered by default.

24 changes: 24 additions & 0 deletions assets/js/src/admin/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,30 @@

if ( jQuery.fn.select2 ) {
$( '.cmb2-insertable-message select' ).select2();

// Before a new group row is added, destroy Select2. We'll reinitialise after the row is added
$( '.cmb-repeatable-group' ).on( 'cmb2_add_group_row_start', function ( event, instance ) {
var $table = $( document.getElementById( $( instance ).data( 'selector' ) ) );
var $oldRow = $table.find( '.cmb-repeatable-grouping' ).last();

$oldRow.find( '.cmb2_select' ).each( function () {
$( this ).select2( 'destroy' );
});
});

// When a new group row is added, clear selection and initialise Select2
$( '.cmb-repeatable-group' ).on('cmb2_add_row', function ( event, newRow ) {
$( newRow ).find( '.cmb2_select' ).each( function () {
$( 'option:selected', this ).removeAttr( 'selected' );
$( this ).select2();
});

// Reinitialise the field we previously destroyed
$( newRow ).prev().find( '.cmb2_select' ).each( function () {
$( this ).select2();
});
});

}

})(jQuery);
Loading