3.0.2-beta • Published 7 years ago

row-selection v3.0.2-beta

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

row-selection

Summary

jQuery based plugin enabling click, ctrl + click, shift + click behaviour using table/list like elements.

Install

$ npm install row-selection --save

Usage

<table class="facts-table">
    <tbody>
        <tr>
            <td>1.</td>
            <td>There are more lifeforms living on your skin than there are people on the planet.</td>
        </tr>
        <tr>
            <td>2.</td>
            <td>Bolts of lightning can shoot out of an erupting volcano.</td>
        </tr>
        <tr>
            <td>3.</td>
            <td>Chewing gum while you cut an onion will help keep you from crying.</td>
        </tr>
        <tr>
            <td>4.</td>
            <td>Earth has traveled more than 5,000 miles in the past 5 minutes.</td>
        </tr>
    </tbody>
</table>
'use strict';
$('.facts-table').uiSelectableRow({
  rowIdentifier: 'tr',
  selectRowIfTargetIs: 'td',
  selectedRowClass: 'fact-selected'
});
.fact-selected {
    background: #87ceeb;
    color: #fff;
}

Option

PropertyTypeUsageDefaultRequired
rowIdentifierstringCSS selector targeting the row. In case of table, it's usually 'tr', in case of list, it usually 'li'. This is element to which the 'selected' row class is attached totbody tryes
selectRowIfTargetIsarrayArray of CSS selector, which if matches will select the row; selectRowIfTargetIs takes priority over selectRowIfTargetIsNot.[]optional
selectRowIfTargetIsNotarrayArray of CSS selector, which if matched will not select the row.[]optional
toggleOnClickbooleantoggle selection on shift clickfalseoptional
filterSelectionfunctioncallback to filter selected rows; doesn't filter, if toggleOnClick is trueoptional
eventNsstringevent namespaceuiSelectableRowoptional
eventType.toggleSelectionstringname for custom event type, 'toggleSelection'toggle-selectionoptional
eventType.enablestringname for custom event type, 'enable'enableoptional
eventType.disablestringname for custom event type, 'disable'disableoptional
eventType.destroystringname for custom event type, 'destroy'destroyoptional
eventType.destroyedstringname for custom event type, 'destroyed'destroyedoptional
eventType.shiftSelectablestringname for custom event type, 'shiftSelectable'bashift-selectableoptional
eventType.ctrlSelectablestringname for custom event type, 'ctrlSelectable'ctrl-selectableoptional
dataAttr.rowIdentifierstringname for custom data attribute, 'rowIdentifier'data-row-identifieroptional
dataAttr.selectRowIfTargetIsstringname for custom data attribute, 'selectRowIfTargetIs'data-select-row-if-target-isoptional
dataAttr.selectRowIfTargetIsNotstringname for custom data attribute, 'selectRowIfTargetIsNot'data-select-row-if-target-is-notoptional
dataAttr.disabledstringname for custom data attribute, 'disabled'data-disabledoptional
dataAttr.shiftSelectablestringname for custom data attribute, 'shiftSelectable'data-shift-selectableoptional
dataAttr.ctrlSelectablestringname for custom data attribute, 'ctrlSelectable'data-ctrl-selectableoptional
dataAttr.selectedRowClassstringname for custom data attribute, 'selectedRowClass'data-selected-classoptional
isDisabledbooleanenable/disable the pluginfalseoptional
isShiftSelectablebooleanenable/disable shift selectabletrueoptional
isCtrlSelectablebooleanenable/disable ctrl selectabletrueoptional
selectedRowClassstringname of the selected row classui-selectable-row-selectedoptional
containerHoverClassstringname of the hover classui-selectable-row-hoveroptional
disableTextSelectionClassstringname of the text selection disable classui-selectable-row-disable-text-selectionoptional

Example(s)

build example by running the following command and navigate to http://localhost:8080/example/index.html; ensure you run the example using a local server;

$ npm install
$ npm start

License

MIT

3.0.2-beta

7 years ago

3.0.1-beta

7 years ago

3.0.0-beta

7 years ago