|
1 | 1 | /*! |
2 | | - * Fuel UX v3.15.3 |
| 2 | + * Fuel UX v3.15.4 |
3 | 3 | * Copyright 2012-2016 ExactTarget |
4 | 4 | * Licensed under the BSD-3-Clause license (https://github.com/ExactTarget/fuelux/blob/master/LICENSE) |
5 | 5 | */ |
|
298 | 298 | }, |
299 | 299 |
|
300 | 300 | doSelect: function( $item ) { |
| 301 | + |
301 | 302 | if ( typeof $item[ 0 ] !== 'undefined' ) { |
302 | | - $item.addClass( 'selected' ); |
| 303 | + // remove selection from old item, may result in remove and |
| 304 | + // re-addition of class if item is the same |
| 305 | + this.$element.find( 'li.selected:first' ).removeClass( 'selected' ); |
| 306 | + |
| 307 | + // add selection to new item |
303 | 308 | this.$selectedItem = $item; |
| 309 | + this.$selectedItem.addClass( 'selected' ); |
| 310 | + |
| 311 | + // update input |
304 | 312 | this.$input.val( this.$selectedItem.text().trim() ); |
305 | 313 | } else { |
| 314 | + // this is a custom input, not in the menu |
306 | 315 | this.$selectedItem = null; |
| 316 | + this.$element.find( 'li.selected:first' ).removeClass( 'selected' ); |
307 | 317 | } |
308 | 318 | }, |
309 | 319 |
|
|
335 | 345 | }, this.$selectedItem.data() ); |
336 | 346 | } else { |
337 | 347 | data = { |
338 | | - text: this.$input.val().trim() |
| 348 | + text: this.$input.val().trim(), |
| 349 | + notFound: true |
339 | 350 | }; |
340 | 351 | } |
341 | 352 |
|
|
447 | 458 | } |
448 | 459 |
|
449 | 460 | this.$inputGroupBtn.removeClass( 'open' ); |
450 | | - this.inputchanged( e ); |
451 | 461 | } else if ( e.which === ESC ) { |
452 | 462 | e.preventDefault(); |
453 | 463 | this.clearSelection(); |
|
471 | 481 | $selected = this.$dropMenu.find( 'li:not(.hidden):last' ); |
472 | 482 | } |
473 | 483 | } |
474 | | - this.$dropMenu.find( 'li' ).removeClass( 'selected' ); |
475 | | - $selected.addClass( 'selected' ); |
| 484 | + this.doSelect( $selected ); |
476 | 485 | } |
477 | 486 | } |
478 | 487 |
|
|
485 | 494 | }, |
486 | 495 |
|
487 | 496 | inputchanged: function( e, extra ) { |
| 497 | + var val = $( e.target ).val(); |
488 | 498 | // skip processing for internally-generated synthetic event |
489 | 499 | // to avoid double processing |
490 | | - if ( extra && extra.synthetic ) return; |
491 | | - var val = $( e.target ).val(); |
| 500 | + if ( extra && extra.synthetic ) { |
| 501 | + this.selectByText( val ); |
| 502 | + return; |
| 503 | + } |
492 | 504 | this.selectByText( val ); |
493 | 505 |
|
494 | 506 | // find match based on input |
|
2761 | 2773 | this.$element.on( 'keydown.fu.spinbox', this.$input, $.proxy( this.keydown, this ) ); |
2762 | 2774 | this.$element.on( 'keyup.fu.spinbox', this.$input, $.proxy( this.keyup, this ) ); |
2763 | 2775 |
|
2764 | | - this.bindMousewheelListeners(); |
2765 | | - this.mousewheelTimeout = {}; |
2766 | | - |
2767 | 2776 | if ( this.options.hold ) { |
2768 | 2777 | this.$element.on( 'mousedown.fu.spinbox', '.spinbox-up', $.proxy( function() { |
2769 | 2778 | this.startSpin( true ); |
|
3068 | 3077 | if ( keyCode === 38 || keyCode === 40 ) { |
3069 | 3078 | this.triggerChangedEvent(); |
3070 | 3079 | } |
3071 | | - }, |
3072 | | - |
3073 | | - bindMousewheelListeners: function bindMousewheelListeners() { |
3074 | | - var inputEl = this.$input.get( 0 ); |
3075 | | - if ( inputEl.addEventListener ) { |
3076 | | - //IE 9, Chrome, Safari, Opera |
3077 | | - inputEl.addEventListener( 'mousewheel', $.proxy( this.mousewheelHandler, this ), false ); |
3078 | | - // Firefox |
3079 | | - inputEl.addEventListener( 'DOMMouseScroll', $.proxy( this.mousewheelHandler, this ), false ); |
3080 | | - } else { |
3081 | | - // IE <9 |
3082 | | - inputEl.attachEvent( 'onmousewheel', $.proxy( this.mousewheelHandler, this ) ); |
3083 | | - } |
3084 | | - }, |
3085 | | - |
3086 | | - mousewheelHandler: function mousewheelHandler( event ) { |
3087 | | - if ( !this.options.disabled ) { |
3088 | | - var e = window.event || event; // old IE support |
3089 | | - var delta = Math.max( -1, Math.min( 1, ( e.wheelDelta || -e.detail ) ) ); |
3090 | | - var self = this; |
3091 | | - |
3092 | | - clearTimeout( this.mousewheelTimeout ); |
3093 | | - this.mousewheelTimeout = setTimeout( function() { |
3094 | | - self.triggerChangedEvent(); |
3095 | | - }, 300 ); |
3096 | | - |
3097 | | - if ( delta < 0 ) { |
3098 | | - this.step( true ); |
3099 | | - } else { |
3100 | | - this.step( false ); |
3101 | | - } |
3102 | | - |
3103 | | - if ( e.preventDefault ) { |
3104 | | - e.preventDefault(); |
3105 | | - } else { |
3106 | | - e.returnValue = false; |
3107 | | - } |
3108 | | - |
3109 | | - return false; |
3110 | | - } |
3111 | 3080 | } |
| 3081 | + |
3112 | 3082 | }; |
3113 | 3083 |
|
3114 | 3084 |
|
|
5251 | 5221 | } ); |
5252 | 5222 | this.$prevBtn.on( 'click.fu.repeater', $.proxy( this.previous, this ) ); |
5253 | 5223 | this.$primaryPaging.find( '.combobox' ).on( 'changed.fu.combobox', function( evt, data ) { |
5254 | | - self.$element.trigger( 'pageChanged.fu.repeater', [ data.text, data ] ); |
5255 | | - self.pageInputChange( data.text ); |
| 5224 | + self.pageInputChange( data.text, data ); |
5256 | 5225 | } ); |
5257 | 5226 | this.$search.on( 'searched.fu.search cleared.fu.search', function( e, value ) { |
5258 | 5227 | self.$element.trigger( 'searchChanged.fu.repeater', value ); |
|
5628 | 5597 | } ); |
5629 | 5598 | }, |
5630 | 5599 |
|
5631 | | - pageInputChange: function( val ) { |
| 5600 | + pageInputChange: function( val, dataFromCombobox ) { |
| 5601 | + // dataFromCombobox is a proxy for data from combobox's changed event, |
| 5602 | + // if no combobox is present data will be undefined |
5632 | 5603 | var pageInc; |
5633 | 5604 | if ( val !== this.lastPageInput ) { |
5634 | 5605 | this.lastPageInput = val; |
5635 | 5606 | val = parseInt( val, 10 ) - 1; |
5636 | 5607 | pageInc = val - this.currentPage; |
5637 | | - this.$element.trigger( 'pageChanged.fu.repeater', val ); |
| 5608 | + this.$element.trigger( 'pageChanged.fu.repeater', [ val, dataFromCombobox ] ); |
5638 | 5609 | this.render( { |
5639 | 5610 | pageIncrement: pageInc |
5640 | 5611 | } ); |
|
6568 | 6539 | var self = this; |
6569 | 6540 | var $table; |
6570 | 6541 |
|
| 6542 | + // this is a patch, it was pulled out of `renderThead` |
| 6543 | + if ( helpers.data.count > 0 ) { |
| 6544 | + this.list_noItems = false; |
| 6545 | + } else { |
| 6546 | + this.list_noItems = true; |
| 6547 | + } |
| 6548 | + |
6571 | 6549 | if ( $listContainer.length < 1 ) { |
6572 | 6550 | $listContainer = $( '<div class="repeater-list ' + this.list_specialBrowserClass + '" data-preserve="shallow"><div class="repeater-list-wrapper" data-infinite="true" data-preserve="shallow"><table aria-readonly="true" class="table" data-preserve="shallow" role="grid"></table></div></div>' ); |
6573 | 6551 | $listContainer.find( '.repeater-list-wrapper' ).on( 'scroll.fu.repeaterList', function() { |
|
6896 | 6874 | if ( this.list_firstRender || areDifferentColumns( this.list_columns, columns ) || $thead.length === 0 ) { |
6897 | 6875 | $thead.remove(); |
6898 | 6876 |
|
6899 | | - if ( data.count < 1 ) { |
6900 | | - this.list_noItems = true; |
6901 | | - } |
| 6877 | + // list_noItems is set in `before` method |
6902 | 6878 |
|
6903 | 6879 | if ( this.viewOptions.list_selectable === 'multi' && !this.list_noItems ) { |
6904 | 6880 | var checkboxColumn = { |
|
6913 | 6889 | this.list_firstRender = false; |
6914 | 6890 | this.$loader.removeClass( 'noHeader' ); |
6915 | 6891 |
|
6916 | | - if ( this.viewOptions.list_actions && !this.list_noItems ) { |
| 6892 | + // keep action column header even when empty, you'll need it later.... |
| 6893 | + if ( this.viewOptions.list_actions ) { |
6917 | 6894 | var actionsColumn = { |
6918 | 6895 | label: this.viewOptions.list_actions.label || '<span class="actions-hidden">a</span>', |
6919 | 6896 | property: '@_ACTIONS_@', |
|
0 commit comments