Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

Commit

Permalink
Merge pull request #1690 from ExactTarget/revert-1674-add-non-checkbo…
Browse files Browse the repository at this point in the history
…x-or-selectable-action-header

Revert "adds action option for list_selectable"
  • Loading branch information
swilliamset committed Jan 26, 2016
2 parents 58eee56 + bd491b6 commit 6f2f73f
Showing 1 changed file with 57 additions and 76 deletions.
133 changes: 57 additions & 76 deletions js/repeater-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -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('<th><div class="repeater-list-heading">' + selectlist + '</div></th>');

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 || '<span class="actions-hidden">a</span>';
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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('<div class="repeater-list-check"><span class="glyphicon glyphicon-ok"></span></div>');
$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('<div class="repeater-list-check"><span class="glyphicon glyphicon-ok"></span></div>');
$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) {
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 6f2f73f

Please sign in to comment.