|
1 | 1 | /*! |
2 | | - * Fuel UX v3.15.9 |
| 2 | + * Fuel UX EDGE - Built 2016/12/15, 3:42:46 PM |
| 3 | + * Previous release: v3.15.9 |
3 | 4 | * Copyright 2012-2016 ExactTarget |
4 | 5 | * Licensed under the BSD-3-Clause license (https://github.com/ExactTarget/fuelux/blob/master/LICENSE) |
5 | 6 | */ |
|
986 | 987 | return ( true === md.isValid() ) ? md.toDate() : BAD_DATE; |
987 | 988 | }; |
988 | 989 |
|
989 | | - tryMomentParseAll = function( d, parseFunc1, parseFunc2 ) { |
990 | | - var pd = parseFunc1( d ); |
| 990 | + tryMomentParseAll = function( rawDateString, parseFunc1, parseFunc2 ) { |
| 991 | + var pd = parseFunc1( rawDateString ); |
991 | 992 | if ( !self.isInvalidDate( pd ) ) { |
992 | 993 | return pd; |
993 | 994 | } |
994 | 995 |
|
995 | | - pd = parseFunc2( pd ); |
| 996 | + pd = parseFunc2( rawDateString ); |
996 | 997 | if ( !self.isInvalidDate( pd ) ) { |
997 | 998 | return pd; |
998 | 999 | } |
|
4453 | 4454 | this.$element.addClass( 'pills-editable' ); |
4454 | 4455 | this.$element.on( 'blur.fu.pillbox', '.pillbox-add-item', $.proxy( this.cancelEdit, this ) ); |
4455 | 4456 | } |
| 4457 | + this.$element.on( 'blur.fu.pillbox', '.pillbox-add-item', $.proxy( this.inputEvent, this ) ); |
4456 | 4458 | }; |
4457 | 4459 |
|
4458 | 4460 | Pillbox.prototype = { |
|
4718 | 4720 | inputEvent: function inputEvent( e ) { |
4719 | 4721 | var self = this; |
4720 | 4722 | var text = self.options.cleanInput( this.$addItem.val() ); |
4721 | | - |
| 4723 | + var isFocusOutEvent = e.type === 'focusout'; |
| 4724 | + var blurredAfterInput = ( isFocusOutEvent && text.length > 0 ); |
4722 | 4725 | // If we test for keycode only, it will match for `<` & `,` instead of just `,` |
4723 | 4726 | // This way users can type `<3` and `1 < 3`, etc... |
4724 | | - if ( this.acceptKeyCodes[ e.keyCode ] && !isShiftHeld( e ) ) { |
| 4727 | + var acceptKeyPressed = ( this.acceptKeyCodes[ e.keyCode ] && !isShiftHeld( e ) ); |
| 4728 | + |
| 4729 | + if ( acceptKeyPressed || blurredAfterInput ) { |
4725 | 4730 | var attr; |
4726 | 4731 | var value; |
4727 | 4732 |
|
|
4738 | 4743 | // ignore comma and make sure text that has been entered (protects against " ,". https://github.com/ExactTarget/fuelux/issues/593), unless allowEmptyPills is true. |
4739 | 4744 | if ( text.replace( /[ ]*\,[ ]*/, '' ).match( /\S/ ) || ( this.options.allowEmptyPills && text.length ) ) { |
4740 | 4745 | this._closeSuggestions(); |
4741 | | - this.$addItem.hide(); |
| 4746 | + this.$addItem.hide().val( '' ); |
4742 | 4747 |
|
4743 | 4748 | if ( attr ) { |
4744 | 4749 | this.addItems( { |
|
4754 | 4759 | } |
4755 | 4760 |
|
4756 | 4761 | setTimeout( function clearAddItemInput() { |
4757 | | - self.$addItem.show().val( '' ).attr( { |
| 4762 | + self.$addItem.show().attr( { |
4758 | 4763 | size: 10 |
4759 | | - } ); |
| 4764 | + } ).focus(); |
4760 | 4765 | }, 0 ); |
4761 | 4766 | } |
4762 | 4767 |
|
|
4794 | 4799 |
|
4795 | 4800 | this.$pillGroup.find( '.pill' ).removeClass( 'pillbox-highlight' ); |
4796 | 4801 |
|
4797 | | - if ( this.options.onKeyDown ) { |
| 4802 | + if ( this.options.onKeyDown && !isFocusOutEvent ) { |
4798 | 4803 | if ( |
4799 | 4804 | isTabKey( e ) || |
4800 | 4805 | isUpArrow( e ) || |
|
0 commit comments