From bd491b621961b2879df045b098d73802933763ad Mon Sep 17 00:00:00 2001 From: "Stephen W. Williams" Date: Tue, 26 Jan 2016 12:10:14 -0500 Subject: [PATCH] Revert "adds action option for list_selectable" --- js/repeater-list.js | 133 +++++++++++++++++++------------------------- 1 file changed, 57 insertions(+), 76 deletions(-) diff --git a/js/repeater-list.js b/js/repeater-list.js index 38f669eff..5c5c8257e 100755 --- a/js/repeater-list.js +++ b/js/repeater-list.js @@ -285,13 +285,10 @@ $actionsColumn.find('tr td:not(:last-child)').remove(); // Dont show actions dropdown in header if not multi select - if (this.viewOptions.list_selectable === 'multi' || this.viewOptions.list_selectable === 'action') { + if (this.viewOptions.list_selectable === 'multi') { $actionsColumn.find('thead tr').html('
' + selectlist + '
'); - - if (this.viewOptions.list_selectable !== 'action') { - //disable the header dropdown until an item is selected - $actionsColumn.find('thead .btn').attr('disabled', 'disabled'); - } + //disable the header dropdown until an item is selected + $actionsColumn.find('thead .btn').attr('disabled', 'disabled'); } else { var label = this.viewOptions.list_actions.label || 'a'; @@ -333,12 +330,7 @@ actionName: actionName, rows: [] }; - var selector = '.repeater-list-wrapper > table .selected'; - - if ( self.viewOptions.list_selectable === 'action' ) { - selector = '.repeater-list-wrapper > table tr'; - } - self.$element.find(selector).each(function() { + self.$element.find('.repeater-list-wrapper > table .selected').each(function() { var index = $(this).index(); index = index + 1; selected.rows.push(index); @@ -748,69 +740,66 @@ var isActions = this.viewOptions.list_actions; if (this.viewOptions.list_selectable) { + $row.addClass('selectable'); + $row.attr('tabindex', 0); // allow items to be tabbed to / focused on $row.data('item_data', rows[index]); - if (this.viewOptions.list_selectable !== 'action') { - $row.addClass('selectable'); - $row.attr('tabindex', 0); // allow items to be tabbed to / focused on - - $row.on('click.fu.repeaterList', function () { - if (!self.isDisabled) { - var $item = $(this); - var index = $(this).index(); - index = index + 1; - var $frozenRow = self.$element.find('.frozen-column-wrapper tr:nth-child('+ index +')'); - var $actionsRow = self.$element.find('.actions-column-wrapper tr:nth-child('+ index +')'); - var $checkBox = self.$element.find('.frozen-column-wrapper tr:nth-child('+ index +') .checkbox-inline'); - - if ($item.is('.selected')) { - $item.removeClass('selected'); - if (isMulti){ - $checkBox.checkbox('uncheck'); - $frozenRow.removeClass('selected'); - if (isActions) { - $actionsRow.removeClass('selected'); - } - } - else { - $item.find('.repeater-list-check').remove(); + $row.on('click.fu.repeaterList', function () { + if (!self.isDisabled) { + var $item = $(this); + var index = $(this).index(); + index = index + 1; + var $frozenRow = self.$element.find('.frozen-column-wrapper tr:nth-child('+ index +')'); + var $actionsRow = self.$element.find('.actions-column-wrapper tr:nth-child('+ index +')'); + var $checkBox = self.$element.find('.frozen-column-wrapper tr:nth-child('+ index +') .checkbox-inline'); + + if ($item.is('.selected')) { + $item.removeClass('selected'); + if (isMulti){ + $checkBox.checkbox('uncheck'); + $frozenRow.removeClass('selected'); + if (isActions) { + $actionsRow.removeClass('selected'); } + } + else { + $item.find('.repeater-list-check').remove(); + } - self.$element.trigger('deselected.fu.repeaterList', $item); - } else { - if (!isMulti) { - self.$canvas.find('.repeater-list-check').remove(); - self.$canvas.find('.repeater-list tbody tr.selected').each(function () { - $(this).removeClass('selected'); - self.$element.trigger('deselected.fu.repeaterList', $(this)); - }); - $item.find('td:first').prepend('
'); - $item.addClass('selected'); - $frozenRow.addClass('selected'); - } - else { - $checkBox.checkbox('check'); - $item.addClass('selected'); - $frozenRow.addClass('selected'); - if (isActions) { - $actionsRow.addClass('selected'); - } + self.$element.trigger('deselected.fu.repeaterList', $item); + } else { + if (!isMulti) { + self.$canvas.find('.repeater-list-check').remove(); + self.$canvas.find('.repeater-list tbody tr.selected').each(function () { + $(this).removeClass('selected'); + self.$element.trigger('deselected.fu.repeaterList', $(this)); + }); + $item.find('td:first').prepend('
'); + $item.addClass('selected'); + $frozenRow.addClass('selected'); + } + else { + $checkBox.checkbox('check'); + $item.addClass('selected'); + $frozenRow.addClass('selected'); + if (isActions) { + $actionsRow.addClass('selected'); } - self.$element.trigger('selected.fu.repeaterList', $item); } - - toggleActionsHeaderButton.call(self); + self.$element.trigger('selected.fu.repeaterList', $item); } - }); - // allow selection via enter key - $row.keyup(function (e) { - if (e.keyCode === 13) { - // triggering a standard click event to be caught by the row click handler above - $row.trigger('click.fu.repeaterList'); - } - }); - } + toggleActionsHeaderButton.call(self); + } + }); + + // allow selection via enter key + $row.keyup(function (e) { + if (e.keyCode === 13) { + // triggering a standard click event to be caught by the row click handler above + $row.trigger('click.fu.repeaterList'); + } + }); } if (this.viewOptions.list_actions && !this.viewOptions.list_selectable) { @@ -967,16 +956,8 @@ } function toggleActionsHeaderButton () { - var selectedSelector = '.repeater-list-wrapper > table .selected'; + var $selected = this.$canvas.find('.repeater-list-wrapper > table .selected'); var $actionsColumn = this.$element.find('.table-actions'); - var $selected; - - if (this.viewOptions.list_selectable === 'action') { - selectedSelector = '.repeater-list-wrapper > table tr'; - } - - $selected = this.$canvas.find( selectedSelector ); - if ($selected.length > 0) { $actionsColumn.find('thead .btn').removeAttr('disabled'); } else {