Skip to content

Commit

Permalink
A bit of cleanup and generate minified file.
Browse files Browse the repository at this point in the history
  • Loading branch information
jtsternberg committed Aug 18, 2015
1 parent 3f11bdd commit d035cfb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
21 changes: 12 additions & 9 deletions js/cmb2.js
Original file line number Diff line number Diff line change
Expand Up @@ -626,11 +626,13 @@ window.CMB2 = (function(window, document, $, undefined){
// Loop this items fields
$parent.find( cmb.repeatEls ).each( function() {
var $element = $(this);
var elType = $element.attr( 'type' );
var val;

if ( $element.hasClass('cmb2-media-status') ) {
// special case for image previews
val = $element.html();
} else if ( 'checkbox' === $element.attr('type') || 'radio' === $element.attr('type') ) {
} else if ( 'checkbox' === elType || 'radio' === elType ) {
val = $element.is(':checked');
} else if ( 'select' === $element.prop('tagName') ) {
val = $element.is(':selected');
Expand All @@ -643,6 +645,7 @@ window.CMB2 = (function(window, document, $, undefined){
// And swap them all
$goto.find( cmb.repeatEls ).each( function( index ) {
var $element = $(this);
var elType = $element.attr( 'type' );
var val;

if ( $element.hasClass('cmb2-media-status') ) {
Expand All @@ -653,17 +656,17 @@ window.CMB2 = (function(window, document, $, undefined){

}
// handle checkbox swapping
else if ( 'checkbox' === $element.attr('type') ) {
else if ( 'checkbox' === elType ) {
inputVals[ index ].$.prop( 'checked', $element.is(':checked') );
$element.prop( 'checked', inputVals[ index ].val );
}
// handle radio swapping
else if ( 'radio' === $element.attr( 'type' ) ) {
if ($element.is(':checked')) {
inputVals[ index ].$.attr('data-checked', 'true');
else if ( 'radio' === elType ) {
if ( $element.is( ':checked' ) ) {
inputVals[ index ].$.attr( 'data-checked', 'true' );
}
if (inputVals[ index ].$.is(':checked')) {
$element.attr('data-checked', 'true');
if ( inputVals[ index ].$.is( ':checked' ) ) {
$element.attr( 'data-checked', 'true' );
}
}
// handle select swapping
Expand All @@ -678,8 +681,8 @@ window.CMB2 = (function(window, document, $, undefined){
}
});

$parent.find("input[data-checked=true]").prop('checked', true).removeAttr('data-checked');
$goto.find("input[data-checked=true]").prop('checked', true).removeAttr('data-checked');
$parent.find( 'input[data-checked=true]' ).prop( 'checked', true ).removeAttr( 'data-checked' );
$goto.find( 'input[data-checked=true]' ).prop( 'checked', true ).removeAttr( 'data-checked' );

// shift done
$self.trigger( 'cmb2_shift_rows_complete', $self );
Expand Down
Loading

0 comments on commit d035cfb

Please sign in to comment.