diff --git a/README.md b/README.md index d2434bd..0987d6c 100644 --- a/README.md +++ b/README.md @@ -29,14 +29,15 @@ mixed and matched within the select or Javascript. The current options are: | `textLength` | UInt | 45 | Maximum text length of when the element should contain title-attributes. | | `moveAllBtn` | Boolean | true | Whether to display the move all button (from left to right or vice-versa). | | `maxAllBtn` | UInt | 500 | Integer to determine from which length to display the warning message below. | +| `iconSet` | String | glyphicon | Icon set: glyphicon or fontawesome | | `warning` | String | <...> | Warning message that is displayed when trying to move large amounts of elements. | | `availableText` | String | Available | Text shown for available options | | `selectedText` | String | Selected | Text shown for selected options | | `beforeCount` | String | - | Opening separator for `showingText`and element count. Could be a dash or an opening bracket. | | `afterCount` | String | | Closing separator for `showingText`and element count. Could be empty or a closing bracket. | | `showingText` | String | showing | Text shown for how many elements there are in the list | -| `filterText` | String | Filter | Filter text -| `changeCallback` | Function| Empty function | Function to call when the selected options changes +| `filterText` | String | Filter | Filter text | +| `changeCallback` | Function| Empty function | Function to call when the selected options changes | ## Example I want to: diff --git a/dist/dual-list-box.js b/dist/dual-list-box.js index 7fc8cf8..7000255 100644 --- a/dist/dual-list-box.js +++ b/dist/dual-list-box.js @@ -38,6 +38,7 @@ textLength: 45, // Maximum text length that is displayed in the select. moveAllBtn: true, // Whether the append all button is available. maxAllBtn: 500, // Maximum size of list in which the all button works without warning. See below. + iconSet: 'glyphicon', // Icon set: glyphicon or fontawesome selectClass:'form-control', warning: 'Are you sure you want to move this many items? Doing so can cause your browser to become unresponsive.', availableText: 'Available', @@ -63,6 +64,7 @@ textLength: $(this).data('textLength'), moveAllBtn: $(this).data('moveAllBtn'), maxAllBtn: $(this).data('maxAllBtn'), + iconSet: $(this).data('iconSet'), selectClass: $(this).data('selectClass'), availableText:$(this).data('availableText'), selectedText: $(this).data('selectedText'), @@ -281,14 +283,14 @@ (options.horizontal == false ? '
' : '
') + '

' + countArea('unselected', options, 'unselected-count') + '

' + ' ' + - (options.horizontal == false ? '' : createHorizontalButtons(1, options.moveAllBtn)) + + (options.horizontal == false ? '' : createHorizontalButtons(1, options.moveAllBtn, getButtonClasses(options.iconSet))) + ' ' + '
' + - (options.horizontal == false ? createVerticalButtons(options.moveAllBtn) : '') + + (options.horizontal == false ? createVerticalButtons(options.moveAllBtn, getButtonClasses(options.iconSet)) : '') + (options.horizontal == false ? '
' : '
') + '

' + countArea('selected', options, 'selected-count') + '

' + ' ' + - (options.horizontal == false ? '' : createHorizontalButtons(2, options.moveAllBtn)) + + (options.horizontal == false ? '' : createHorizontalButtons(2, options.moveAllBtn, getButtonClasses(options.iconSet))) + ' ' + '
'); @@ -305,25 +307,43 @@ } /** Creates the buttons when the dual list box is set in horizontal mode. */ - function createHorizontalButtons(number, copyAllBtn) { + function createHorizontalButtons(number, copyAllBtn, buttonClass) { if (number == 1) { - return (copyAllBtn ? ' ': '') + - ' '; + return (copyAllBtn ? ' ': '') + + ' '; } else { - return ' ' + - (copyAllBtn ? ' ' : ''); + return ' ' + + (copyAllBtn ? ' ' : ''); } } /** Creates the buttons when the dual list box is set in vertical mode. */ - function createVerticalButtons(copyAllBtn) { + function createVerticalButtons(copyAllBtn, buttonClass) { return '
' + - (copyAllBtn ? ' ' : '') + - ' ' + - ' ' + - (copyAllBtn ? ' ' : '') + + (copyAllBtn ? ' ' : '') + + ' ' + + ' ' + + (copyAllBtn ? ' ' : '') + '
'; } + + function getButtonClasses(iconSet) { + if (iconSet === 'fontawesome') { + return { + addAll: 'fa fa-angle-double-right', + addSelected: 'fa fa-angle-right', + removeSelected: 'fa fa-angle-left', + removeAll: 'fa fa-angle-double-left' + }; + } else { // default icon set + return { + addAll: 'glyphicon glyphicons-fast-forward', + addSelected: 'glyphicon glyphicon-chevron-right', + removeSelected: 'glyphicon glyphicon-chevron-left', + removeAll: 'glyphicon glyphicons-fast-backward' + }; + } + } /** Specifically handles the movement when one or more elements are moved. */ function handleMovement(options) {