dtable-utils
Version:
dtable common utils
27 lines (22 loc) • 736 B
JavaScript
;
Object.defineProperty(exports, '__esModule', { value: true });
var sort = require('../../constants/sort.js');
/**
* Sort checkbox
* @param {bool} leftChecked
* @param {bool} rightChecked
* @param {string} sortType e.g. 'up' | 'down
* @returns number
*/
var sortCheckbox = function sortCheckbox(leftChecked, rightChecked, sortType) {
var normalizedCurrChecked = leftChecked ? 1 : -1;
var normalizedNextChecked = rightChecked ? 1 : -1;
if (normalizedCurrChecked > normalizedNextChecked) {
return sortType === sort.SORT_TYPE.UP ? 1 : -1;
}
if (normalizedCurrChecked < normalizedNextChecked) {
return sortType === sort.SORT_TYPE.UP ? -1 : 1;
}
return 0;
};
exports.sortCheckbox = sortCheckbox;