nl_tokens: Private function - updates model
pl_tokens: function ( newModel ) { var oldPos ; for ( var i = 0 ; i < newModel . length ; i ++ ) { oldPos = this . model . indexOf ( newModel [ i ] ) ; if ( oldPos >= 0 ) { // model already in the DOM if ( i != oldPos ) { // adjust template this . moveTemplateNodes ( oldPos , i ) ; // and model this . model . splice ( i , 0 , this . model . splice ( oldPos , 1 ) [ 0 ] ) ; } } else { // check whether current old model is in a new model array if ( this . templateNodes [ i ] && newModel . indexOf ( this . model [ i ] ) == - 1 ) { // just replace model at i this . model [ i ] = newModel [ i ] ; // bind model and template nodes this . bindModel ( i ) ; } else { // insert templateNodes at i this . cloneTemplateNodes ( i ) ; // insert model at i this . model . splice ( i , 0 , newModel [ i ] ) ; // bind model and template nodes this . bindModel ( i ) ; } } } if ( this . model . length > newModel . length ) { // remove redundant template nodes for ( var i = this . templateNodes . length - 1 ; newModel . length <= i ; i -- ) { this . unbindModel ( i ) ; this . removeTemplateNodes ( i ) ; } // and models this . <mask> . splice ( newModel . length , this . model . length - newModel . length ) ; } }