Browse Source

renamed option from multiselectFiltersGroup to multiselectPerGroup,

added docs
webworkersNetwork
Martin Fischer 9 years ago
parent
commit
4b414646fa
3 changed files with 17 additions and 7 deletions
  1. +10
    -0
      docs/timeline/index.html
  2. +5
    -5
      lib/timeline/component/ItemSet.js
  3. +2
    -2
      lib/timeline/optionsTimeline.js

+ 10
- 0
docs/timeline/index.html View File

@ -769,6 +769,16 @@ function (option, path) {
Only applicable when option <code>selectable</code> is <code>true</code>. Only applicable when option <code>selectable</code> is <code>true</code>.
</td> </td>
</tr> </tr>
<tr>
<td style="font-size: 0.9em">multiselectPerGroup</td>
<td>boolean</td>
<td><code>false</code></td>
<td>
If true, selecting multiple items using shift+click will only select items residing in the same group as the <i>first</i> selected item.
Only applicable when option <code>selectable</code> and <code>multiselect</code> are <code>true</code>.
</td>
</tr>
<tr> <tr>
<td>onAdd</td> <td>onAdd</td>

+ 5
- 5
lib/timeline/component/ItemSet.js View File

@ -307,7 +307,7 @@ ItemSet.prototype._create = function(){
ItemSet.prototype.setOptions = function(options) { ItemSet.prototype.setOptions = function(options) {
if (options) { if (options) {
// copy all options that we know // copy all options that we know
var fields = ['type', 'align', 'order', 'stack', 'selectable', 'multiselect', 'multiselectFiltersGroup', 'groupOrder', 'dataAttributes', 'template', 'groupTemplate', 'hide', 'snap', 'groupOrderSwap'];
var fields = ['type', 'align', 'order', 'stack', 'selectable', 'multiselect', 'multiselectPerGroup', 'groupOrder', 'dataAttributes', 'template', 'groupTemplate', 'hide', 'snap', 'groupOrderSwap'];
util.selectiveExtend(fields, this.options, options); util.selectiveExtend(fields, this.options, options);
if ('orientation' in options) { if ('orientation' in options) {
@ -1763,19 +1763,19 @@ ItemSet.prototype._onMultiSelectItem = function (event) {
// when filtering get the group of the last selected item // when filtering get the group of the last selected item
var lastSelectedGroup = undefined; var lastSelectedGroup = undefined;
if (this.options.multiselectFiltersGroup) {
if (this.options.multiselectPerGroup) {
if (selection.length > 0) { if (selection.length > 0) {
lastSelectedGroup = this.itemsData.get(selection[0]).group; lastSelectedGroup = this.itemsData.get(selection[0]).group;
} }
} }
// determine the selection range // determine the selection range
if (!this.options.multiselectFiltersGroup || lastSelectedGroup == undefined || lastSelectedGroup == itemGroup) {
if (!this.options.multiselectPerGroup || lastSelectedGroup == undefined || lastSelectedGroup == itemGroup) {
selection.push(item.id); selection.push(item.id);
} }
var range = ItemSet._getItemRange(this.itemsData.get(selection, this.itemOptions)); var range = ItemSet._getItemRange(this.itemsData.get(selection, this.itemOptions));
if (!this.options.multiselectFiltersGroup || lastSelectedGroup == itemGroup) {
if (!this.options.multiselectPerGroup || lastSelectedGroup == itemGroup) {
// select all items within the selection range // select all items within the selection range
selection = []; selection = [];
for (var id in this.items) { for (var id in this.items) {
@ -1786,7 +1786,7 @@ ItemSet.prototype._onMultiSelectItem = function (event) {
if (start >= range.min && if (start >= range.min &&
end <= range.max && end <= range.max &&
(!this.options.multiselectFiltersGroup || lastSelectedGroup == this.itemsData.get(_item.id).group) &&
(!this.options.multiselectPerGroup || lastSelectedGroup == this.itemsData.get(_item.id).group) &&
!(_item instanceof BackgroundItem)) { !(_item instanceof BackgroundItem)) {
selection.push(_item.id); // do not use id but item.id, id itself is stringified selection.push(_item.id); // do not use id but item.id, id itself is stringified
} }

+ 2
- 2
lib/timeline/optionsTimeline.js View File

@ -98,7 +98,7 @@ let allOptions = {
minHeight: {number, string}, minHeight: {number, string},
moveable: {boolean}, moveable: {boolean},
multiselect: {boolean}, multiselect: {boolean},
multiselectFiltersGroup: {boolean},
multiselectPerGroup: {boolean},
onAdd: {'function': 'function'}, onAdd: {'function': 'function'},
onUpdate: {'function': 'function'}, onUpdate: {'function': 'function'},
onMove: {'function': 'function'}, onMove: {'function': 'function'},
@ -192,7 +192,7 @@ let configureOptions = {
minHeight: '', minHeight: '',
moveable: false, moveable: false,
multiselect: false, multiselect: false,
multiselectFiltersGroup: false,
multiselectPerGroup: false,
//onAdd: {'function': 'function'}, //onAdd: {'function': 'function'},
//onUpdate: {'function': 'function'}, //onUpdate: {'function': 'function'},
//onMove: {'function': 'function'}, //onMove: {'function': 'function'},

Loading…
Cancel
Save