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

Commit

Permalink
improving appearance of disabled sub-controls in repeater-list and re…
Browse files Browse the repository at this point in the history
…peater-thumbnail
  • Loading branch information
kevinparkerson committed Dec 9, 2015
1 parent 6fdd98a commit 8171a28
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 14 deletions.
41 changes: 27 additions & 14 deletions js/repeater-list.js
Expand Up @@ -244,7 +244,7 @@
}

var selectlist = '<div class="btn-group">' +
'<button type="button" class="btn btn-xs btn-default dropdown-toggle" data-toggle="dropdown" data-flip="auto" aria-expanded="false">' +
'<button type="button" class="btn btn-xs btn-default dropdown-toggle repeater-actions-button" data-toggle="dropdown" data-flip="auto" aria-expanded="false">' +
'<span class="caret"></span>' +
'</button>' +
'<ul class="dropdown-menu dropdown-menu-right" role="menu">' +
Expand Down Expand Up @@ -449,6 +449,16 @@
}
return options;
},
enabled: function (helpers) {
if (this.viewOptions.list_actions) {
if (!helpers.status) {
this.$canvas.find('.repeater-actions-button').attr('disabled', 'disabled');
} else {
this.$canvas.find('.repeater-actions-button').removeAttr('disabled');
toggleActionsHeaderButton.call(this);
}
}
},
initialize: function (helpers, callback) {
this.list_sortDirection = null;
this.list_sortProperty = null;
Expand Down Expand Up @@ -546,7 +556,7 @@
}

//ADDITIONAL METHODS
var areDifferentColumns = function areDifferentColumns (oldCols, newCols) {
function areDifferentColumns (oldCols, newCols) {
if (!newCols) {
return false;
}
Expand All @@ -567,7 +577,7 @@

}
return false;
};
}

function renderColumn ($row, rows, rowIndex, columns, columnIndex) {
var className = columns[columnIndex].className;
Expand All @@ -589,7 +599,7 @@
$row.append($col);

if (this.viewOptions.list_selectable === 'multi' && columns[columnIndex].property === '@_CHECKBOX_@') {
var checkBoxMarkup = '<label data-row="'+ rowIndex +'" class="checkbox-custom checkbox-inline body-checkbox">' +
var checkBoxMarkup = '<label data-row="'+ rowIndex +'" class="checkbox-custom checkbox-inline body-checkbox repeater-select-checkbox">' +
'<input class="sr-only" type="checkbox"></label>';

$col.html(checkBoxMarkup);
Expand All @@ -610,7 +620,7 @@
var chevron = '.glyphicon.rlc:first';
var chevUp = 'glyphicon-chevron-up';
var $div = $('<div class="repeater-list-heading"><span class="glyphicon rlc"></span></div>');
var checkBoxMarkup = '<div class="repeater-list-heading header-checkbox"><label class="checkbox-custom checkbox-inline">' +
var checkBoxMarkup = '<div class="repeater-list-heading header-checkbox"><label class="checkbox-custom checkbox-inline repeater-select-checkbox">' +
'<input class="sr-only" type="checkbox"></label><div class="clearfix"></div></div>';
var $header = $('<th></th>');
var self = this;
Expand Down Expand Up @@ -752,15 +762,8 @@
}
self.$element.trigger('selected.fu.repeaterList', $item);
}
var $selected = self.$canvas.find('.repeater-list-wrapper > table .selected');
var $actionsColumn = self.$element.find('.table-actions');

if ($selected.length > 0) {
$actionsColumn.find('thead .btn').removeAttr('disabled');
}
else {
$actionsColumn.find('thead .btn').attr('disabled', 'disabled');
}
toggleActionsHeaderButton.call(self);
}
});

Expand Down Expand Up @@ -912,7 +915,7 @@
}
}

function specialBrowserClass() {
function specialBrowserClass () {
var ua = window.navigator.userAgent;
var msie = ua.indexOf("MSIE ");
var firefox = ua.indexOf('Firefox');
Expand All @@ -926,6 +929,16 @@
}
}

function toggleActionsHeaderButton () {
var $selected = this.$canvas.find('.repeater-list-wrapper > table .selected');
var $actionsColumn = this.$element.find('.table-actions');
if ($selected.length > 0) {
$actionsColumn.find('thead .btn').removeAttr('disabled');
} else {
$actionsColumn.find('thead .btn').attr('disabled', 'disabled');
}
}

// -- BEGIN UMD WRAPPER AFTERWORD --
}));
// -- END UMD WRAPPER AFTERWORD --
14 changes: 14 additions & 0 deletions js/repeater.js
Expand Up @@ -221,6 +221,7 @@
disable: function() {
var disable = 'disable';
var disabled = 'disabled';
var viewTypeObj = $.fn.repeater.viewTypes[this.viewType] || {};

this.$search.search(disable);
this.$filters.selectlist(disable);
Expand All @@ -231,6 +232,12 @@
this.$prevBtn.attr(disabled, disabled);
this.$nextBtn.attr(disabled, disabled);

if (viewTypeObj.enabled) {
viewTypeObj.enabled.call(this, {
status: false
});
}

this.isDisabled = true;
this.$element.addClass('disabled');
this.$element.trigger('disabled.fu.repeater');
Expand All @@ -240,6 +247,7 @@
var disabled = 'disabled';
var enable = 'enable';
var pageEnd = 'page-end';
var viewTypeObj = $.fn.repeater.viewTypes[this.viewType] || {};

this.$search.search(enable);
this.$filters.selectlist(enable);
Expand Down Expand Up @@ -269,6 +277,12 @@
this.$pageSize.selectlist('disable');
}

if (viewTypeObj.enabled) {
viewTypeObj.enabled.call(this, {
status: true
});
}

this.isDisabled = false;
this.$element.removeClass('disabled');
this.$element.trigger('enabled.fu.repeater');
Expand Down
38 changes: 38 additions & 0 deletions less/repeater-list.less
Expand Up @@ -25,6 +25,44 @@

.fuelux {
.repeater[data-viewtype="list"] {
&.disabled { //overrides for disabled stuff
.repeater-canvas {
&.actions-enabled {
.repeater-list .actions-column-wrapper table.table-actions tr.selectable {
&:hover td, &.hovered td {
background: #fff;
}
}
}

.repeater-list {
.repeater-select-checkbox {
cursor: not-allowed;
}

.repeater-list-wrapper table thead tr th {
&.sortable, .repeater-list-heading.sortable{
background: @gray98;
cursor: auto;
}
}

.repeater-list-wrapper table tbody tr.selectable {
&:hover, &.hovered {
&.selected td {
background: #eee;
}

td {
background: #fff;
cursor: auto;
}
}
}
}
}
}

.repeater-canvas {
&.scrolling {
overflow: visible;
Expand Down
12 changes: 12 additions & 0 deletions less/repeater-thumbnail.less
@@ -1,5 +1,17 @@
@import "fuelux-core.less";
.fuelux {
.repeater.disabled { //overrides for disabled stuff
.repeater-thumbnail.selectable {
&:hover {
background: #fff;
cursor: auto;
}

&.selected:hover {
background: @selected;
}
}
}

.repeater-thumbnail {
border: 1px solid @gray87;
Expand Down

0 comments on commit 8171a28

Please sign in to comment.