Skip to content

Commit

Permalink
Merge branch 'au-triggers' of https://github.com/AlchemyUnited/CMB2 i…
Browse files Browse the repository at this point in the history
…nto AlchemyUnited-au-triggers

Conflicts:
	js/cmb2.js
  • Loading branch information
jtsternberg committed Dec 20, 2014
2 parents bb18732 + 134ac37 commit 98d9779
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
17 changes: 17 additions & 0 deletions js/cmb2.js
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,7 @@ window.CMB2 = (function(window, document, $, undefined){
};

cmb.afterRowInsert = function( $row, group ) {

var $focus = $row.find('input:not([type="button"]), textarea, select').first();
if ( $focus.length ) {
if ( group ) {
Expand Down Expand Up @@ -466,6 +467,10 @@ window.CMB2 = (function(window, document, $, undefined){
evt.preventDefault();

var $self = $(this);

// before anything significant happens
$self.trigger( 'cmb2_add_group_row_start', $self );

var $table = $id( $self.data('selector') );
var $oldRow = $table.find('.cmb-repeatable-grouping').last();
var prevNum = parseInt( $oldRow.data('iterator') );
Expand Down Expand Up @@ -524,6 +529,9 @@ window.CMB2 = (function(window, document, $, undefined){
var number = $table.find('.cmb-repeatable-grouping').length;

if ( number > 1 ) {

$table.trigger( 'cmb2_remove_group_row_start', $self );

// when a group is removed loop through all next groups and update fields names
$parent.nextAll( '.cmb-repeatable-grouping' ).find( cmb.repeatEls ).each( cmb.updateNameAttr );

Expand Down Expand Up @@ -573,13 +581,19 @@ window.CMB2 = (function(window, document, $, undefined){
evt.preventDefault();

var $self = $(this);
// before anything signif happens
$self.trigger( 'cmb2_shift_rows_enter', $self );

var $parent = $self.parents( '.cmb-repeatable-grouping' );
var $goto = $self.hasClass( 'move-up' ) ? $parent.prev( '.cmb-repeatable-grouping' ) : $parent.next( '.cmb-repeatable-grouping' );

if ( ! $goto.length ) {
return;
}

// we're gonna shift
$self.trigger( 'cmb2_shift_rows_start', $self );

var inputVals = [];
// Loop this items fields
$parent.find( cmb.repeatEls ).each( function() {
Expand Down Expand Up @@ -626,6 +640,9 @@ window.CMB2 = (function(window, document, $, undefined){
$element.val( inputVals[ index ]['val'] );
}
});

// shift done
$self.trigger( 'cmb2_shift_rows_complete', $self );
};

cmb.initPickers = function( $timePickers, $datePickers, $colorPickers ) {
Expand Down
Loading

0 comments on commit 98d9779

Please sign in to comment.