|
14 | 14 | circular: false, // go to first slide after last one
|
15 | 15 | autoplay: 0, // auto-advance interval (0: no autoplay)
|
16 | 16 | pauseAutoplayOnHover: true,
|
17 |
| - keyboardNav: true // enable arrow and [p][n] keys for prev / next actions |
| 17 | + keyboardNav: true, // enable arrow and [p][n] keys for prev / next actions |
| 18 | + groupedHandles: true // combine handles to group if visibleSlides > 1 (e.g. "1-3", "4-6", "7") |
18 | 19 | },
|
19 | 20 | elements: { // which navigational elements to show
|
20 | 21 | prevNext: true, // buttons for previous / next slide
|
|
327 | 328 | if (this.settings.elements.handles) {
|
328 | 329 | this.$dom.handles.on(events, function(event){
|
329 | 330 | var $this = $(this),
|
330 |
| - handleIndex = $this.index(), |
| 331 | + handleIndex = $this.data(namespace +'-handle-index') || $this.index(), |
331 | 332 | slideIndex = self._getCurrentSlideIndex(handleIndex),
|
332 | 333 | callback = function(){
|
333 | 334 | self.goTo(slideIndex);
|
|
586 | 587 |
|
587 | 588 | // Return a group of handles (one for each slide)
|
588 | 589 | _getHandles: function(){
|
589 |
| - var fragment = document.createDocumentFragment(); |
| 590 | + var fragment = document.createDocumentFragment(), |
| 591 | + slideGroups; |
590 | 592 |
|
591 |
| - for (var i = 0; i < this.props.total; i++) { |
592 |
| -// var handle = document.createElement('span'); |
593 |
| -// |
594 |
| -// handle.className = namespace + '-handle'; |
595 |
| -// handle.innerHTML = this.settings.text.handle.replace('%index%', (i+1)); |
596 |
| -// handle.setAttribute('role', 'button'); |
597 |
| -// handle.setAttribute('tabindex', 0); |
| 593 | + if (!this.settings.behavior.groupedHandles) { |
| 594 | + for (var i = 0; i < this.props.total; i++) { |
| 595 | + // var handle = document.createElement('span'); |
598 | 596 |
|
599 |
| - var text = this.settings.text.handle.replace('%index%', (i+1)), |
600 |
| - handle = this.$dom.handle.clone().text(text).get(0); |
| 597 | + // handle.className = namespace + '-handle'; |
| 598 | + // handle.innerHTML = this.settings.text.handle.replace('%index%', (i+1)); |
| 599 | + // handle.setAttribute('role', 'button'); |
| 600 | + // handle.setAttribute('tabindex', 0); |
601 | 601 |
|
602 |
| - fragment.appendChild(handle); |
| 602 | + var text = this.settings.text.handle.replace('%index%', (i+1)), |
| 603 | + handle = this.$dom.handle.clone().text(text).get(0); |
| 604 | + |
| 605 | + fragment.appendChild(handle); |
| 606 | + } |
| 607 | + } else { |
| 608 | + slideGroups = this.props.total / this.props.visible; |
| 609 | + |
| 610 | + for (var i = 0; i < slideGroups; i++) { |
| 611 | + var minIndex = i * this.props.visible + 1, |
| 612 | + maxIndex = (i+1) * this.props.visible, |
| 613 | + $handle = this.$dom.handle.clone(), |
| 614 | + handle, text; |
| 615 | + |
| 616 | + if (maxIndex > this.props.total) { |
| 617 | + maxIndex = this.props.total; |
| 618 | + } |
| 619 | + |
| 620 | + if (minIndex < maxIndex) { |
| 621 | + text = minIndex +' - '+ maxIndex; |
| 622 | + } else { |
| 623 | + text = maxIndex; |
| 624 | + } |
| 625 | + |
| 626 | + text = this.settings.text.handle.replace('%index%', text); |
| 627 | + |
| 628 | + handle = $handle.text(text).data(namespace + '-handle-index', minIndex-1).get(0); |
| 629 | + |
| 630 | + fragment.appendChild(handle); |
| 631 | + } |
603 | 632 | }
|
604 | 633 |
|
605 | 634 | return $(fragment);
|
|
908 | 937 | var currentIndex = this._getOriginalSlideIndex(this.props.currentDomIndex),
|
909 | 938 | currentHandles = (currentIndex > 0) ? ':gt(' + (currentIndex - 1) + '):lt(' + this.props.visible + ')' : ':lt(' + (currentIndex + this.props.visible) + ')';
|
910 | 939 |
|
| 940 | + if (this.settings.behavior.groupedHandles) { |
| 941 | + currentHandles = ':eq(' + Math.ceil(currentIndex/this.props.visible) + ')'; |
| 942 | + } |
| 943 | + |
911 | 944 | utils.enableButton(this.$dom.handles);
|
912 | 945 |
|
913 | 946 | this.$dom.handles.removeClass('state-current');
|
|
0 commit comments