|
285 | 285 | $actionsColumn.find('tr td:not(:last-child)').remove(); |
286 | 286 |
|
287 | 287 | // Dont show actions dropdown in header if not multi select |
288 | | - if (this.viewOptions.list_selectable === 'multi' || this.viewOptions.list_selectable === 'action') { |
| 288 | + if (this.viewOptions.list_selectable === 'multi') { |
289 | 289 | $actionsColumn.find('thead tr').html('<th><div class="repeater-list-heading">' + selectlist + '</div></th>'); |
290 | | - |
291 | | - if (this.viewOptions.list_selectable !== 'action') { |
292 | | - //disable the header dropdown until an item is selected |
293 | | - $actionsColumn.find('thead .btn').attr('disabled', 'disabled'); |
294 | | - } |
| 290 | + //disable the header dropdown until an item is selected |
| 291 | + $actionsColumn.find('thead .btn').attr('disabled', 'disabled'); |
295 | 292 | } |
296 | 293 | else { |
297 | 294 | var label = this.viewOptions.list_actions.label || '<span class="actions-hidden">a</span>'; |
|
333 | 330 | actionName: actionName, |
334 | 331 | rows: [] |
335 | 332 | }; |
336 | | - var selector = '.repeater-list-wrapper > table .selected'; |
337 | | - |
338 | | - if ( self.viewOptions.list_selectable === 'action' ) { |
339 | | - selector = '.repeater-list-wrapper > table tr'; |
340 | | - } |
341 | | - self.$element.find(selector).each(function() { |
| 333 | + self.$element.find('.repeater-list-wrapper > table .selected').each(function() { |
342 | 334 | var index = $(this).index(); |
343 | 335 | index = index + 1; |
344 | 336 | selected.rows.push(index); |
|
748 | 740 | var isActions = this.viewOptions.list_actions; |
749 | 741 |
|
750 | 742 | if (this.viewOptions.list_selectable) { |
| 743 | + $row.addClass('selectable'); |
| 744 | + $row.attr('tabindex', 0); // allow items to be tabbed to / focused on |
751 | 745 | $row.data('item_data', rows[index]); |
752 | 746 |
|
753 | | - if (this.viewOptions.list_selectable !== 'action') { |
754 | | - $row.addClass('selectable'); |
755 | | - $row.attr('tabindex', 0); // allow items to be tabbed to / focused on |
756 | | - |
757 | | - $row.on('click.fu.repeaterList', function () { |
758 | | - if (!self.isDisabled) { |
759 | | - var $item = $(this); |
760 | | - var index = $(this).index(); |
761 | | - index = index + 1; |
762 | | - var $frozenRow = self.$element.find('.frozen-column-wrapper tr:nth-child('+ index +')'); |
763 | | - var $actionsRow = self.$element.find('.actions-column-wrapper tr:nth-child('+ index +')'); |
764 | | - var $checkBox = self.$element.find('.frozen-column-wrapper tr:nth-child('+ index +') .checkbox-inline'); |
765 | | - |
766 | | - if ($item.is('.selected')) { |
767 | | - $item.removeClass('selected'); |
768 | | - if (isMulti){ |
769 | | - $checkBox.checkbox('uncheck'); |
770 | | - $frozenRow.removeClass('selected'); |
771 | | - if (isActions) { |
772 | | - $actionsRow.removeClass('selected'); |
773 | | - } |
774 | | - } |
775 | | - else { |
776 | | - $item.find('.repeater-list-check').remove(); |
| 747 | + $row.on('click.fu.repeaterList', function () { |
| 748 | + if (!self.isDisabled) { |
| 749 | + var $item = $(this); |
| 750 | + var index = $(this).index(); |
| 751 | + index = index + 1; |
| 752 | + var $frozenRow = self.$element.find('.frozen-column-wrapper tr:nth-child('+ index +')'); |
| 753 | + var $actionsRow = self.$element.find('.actions-column-wrapper tr:nth-child('+ index +')'); |
| 754 | + var $checkBox = self.$element.find('.frozen-column-wrapper tr:nth-child('+ index +') .checkbox-inline'); |
| 755 | + |
| 756 | + if ($item.is('.selected')) { |
| 757 | + $item.removeClass('selected'); |
| 758 | + if (isMulti){ |
| 759 | + $checkBox.checkbox('uncheck'); |
| 760 | + $frozenRow.removeClass('selected'); |
| 761 | + if (isActions) { |
| 762 | + $actionsRow.removeClass('selected'); |
777 | 763 | } |
| 764 | + } |
| 765 | + else { |
| 766 | + $item.find('.repeater-list-check').remove(); |
| 767 | + } |
778 | 768 |
|
779 | | - self.$element.trigger('deselected.fu.repeaterList', $item); |
780 | | - } else { |
781 | | - if (!isMulti) { |
782 | | - self.$canvas.find('.repeater-list-check').remove(); |
783 | | - self.$canvas.find('.repeater-list tbody tr.selected').each(function () { |
784 | | - $(this).removeClass('selected'); |
785 | | - self.$element.trigger('deselected.fu.repeaterList', $(this)); |
786 | | - }); |
787 | | - $item.find('td:first').prepend('<div class="repeater-list-check"><span class="glyphicon glyphicon-ok"></span></div>'); |
788 | | - $item.addClass('selected'); |
789 | | - $frozenRow.addClass('selected'); |
790 | | - } |
791 | | - else { |
792 | | - $checkBox.checkbox('check'); |
793 | | - $item.addClass('selected'); |
794 | | - $frozenRow.addClass('selected'); |
795 | | - if (isActions) { |
796 | | - $actionsRow.addClass('selected'); |
797 | | - } |
| 769 | + self.$element.trigger('deselected.fu.repeaterList', $item); |
| 770 | + } else { |
| 771 | + if (!isMulti) { |
| 772 | + self.$canvas.find('.repeater-list-check').remove(); |
| 773 | + self.$canvas.find('.repeater-list tbody tr.selected').each(function () { |
| 774 | + $(this).removeClass('selected'); |
| 775 | + self.$element.trigger('deselected.fu.repeaterList', $(this)); |
| 776 | + }); |
| 777 | + $item.find('td:first').prepend('<div class="repeater-list-check"><span class="glyphicon glyphicon-ok"></span></div>'); |
| 778 | + $item.addClass('selected'); |
| 779 | + $frozenRow.addClass('selected'); |
| 780 | + } |
| 781 | + else { |
| 782 | + $checkBox.checkbox('check'); |
| 783 | + $item.addClass('selected'); |
| 784 | + $frozenRow.addClass('selected'); |
| 785 | + if (isActions) { |
| 786 | + $actionsRow.addClass('selected'); |
798 | 787 | } |
799 | | - self.$element.trigger('selected.fu.repeaterList', $item); |
800 | 788 | } |
801 | | - |
802 | | - toggleActionsHeaderButton.call(self); |
| 789 | + self.$element.trigger('selected.fu.repeaterList', $item); |
803 | 790 | } |
804 | | - }); |
805 | 791 |
|
806 | | - // allow selection via enter key |
807 | | - $row.keyup(function (e) { |
808 | | - if (e.keyCode === 13) { |
809 | | - // triggering a standard click event to be caught by the row click handler above |
810 | | - $row.trigger('click.fu.repeaterList'); |
811 | | - } |
812 | | - }); |
813 | | - } |
| 792 | + toggleActionsHeaderButton.call(self); |
| 793 | + } |
| 794 | + }); |
| 795 | + |
| 796 | + // allow selection via enter key |
| 797 | + $row.keyup(function (e) { |
| 798 | + if (e.keyCode === 13) { |
| 799 | + // triggering a standard click event to be caught by the row click handler above |
| 800 | + $row.trigger('click.fu.repeaterList'); |
| 801 | + } |
| 802 | + }); |
814 | 803 | } |
815 | 804 |
|
816 | 805 | if (this.viewOptions.list_actions && !this.viewOptions.list_selectable) { |
|
967 | 956 | } |
968 | 957 |
|
969 | 958 | function toggleActionsHeaderButton () { |
970 | | - var selectedSelector = '.repeater-list-wrapper > table .selected'; |
| 959 | + var $selected = this.$canvas.find('.repeater-list-wrapper > table .selected'); |
971 | 960 | var $actionsColumn = this.$element.find('.table-actions'); |
972 | | - var $selected; |
973 | | - |
974 | | - if (this.viewOptions.list_selectable === 'action') { |
975 | | - selectedSelector = '.repeater-list-wrapper > table tr'; |
976 | | - } |
977 | | - |
978 | | - $selected = this.$canvas.find( selectedSelector ); |
979 | | - |
980 | 961 | if ($selected.length > 0) { |
981 | 962 | $actionsColumn.find('thead .btn').removeAttr('disabled'); |
982 | 963 | } else { |
|
0 commit comments