Skip to content

Commit 1031b74

Browse files
committed
slide section: select slides on clicking header
now clicking on the section header, user can select all the slides in the section Signed-off-by: Pranam Lashkari <lpranam@collabora.com> Change-Id: I08003e8dab460a2ac7f700b2856ed3155e1c970c
1 parent f1ea882 commit 1031b74

2 files changed

Lines changed: 53 additions & 3 deletions

File tree

browser/src/control/Control.PartsPreview.js

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,15 @@ window.L.Control.PartsPreview = window.L.Control.extend({
565565
that._toggleSectionCollapse(sectionIndex);
566566
}, this);
567567

568+
// Click on the header (but not the toggle) selects all slides in the section.
569+
window.L.DomEvent.on(header, 'click', function (e) {
570+
if (toggleBtn.contains(e.target))
571+
return;
572+
window.L.DomEvent.stopPropagation(e);
573+
window.L.DomEvent.preventDefault(e);
574+
that._selectSection(sectionIndex);
575+
}, this);
576+
568577
// Section context menu
569578
if (this._map.isEditMode()) {
570579
window.L.DomEvent.on(header, 'contextmenu', function(e) {
@@ -581,6 +590,22 @@ window.L.Control.PartsPreview = window.L.Control.extend({
581590
return header;
582591
},
583592

593+
_selectSection: function (sectionIndex) {
594+
var sections = app.impress && app.impress.sections;
595+
if (!sections || !sections[sectionIndex])
596+
return;
597+
598+
var start = sections[sectionIndex].startIndex;
599+
var end = (sectionIndex + 1 < sections.length)
600+
? sections[sectionIndex + 1].startIndex - 1
601+
: this._previewTiles.length - 1;
602+
603+
if (start < 0 || end < start)
604+
return;
605+
606+
this._selectPartRange(start, end, false);
607+
},
608+
584609
_toggleSectionCollapse: function (sectionIndex) {
585610
var sections = app.impress.sections || [];
586611
var section = sections[sectionIndex];
@@ -894,7 +919,7 @@ window.L.Control.PartsPreview = window.L.Control.extend({
894919
}
895920
},
896921

897-
_selectPartRange: function (start, end) {
922+
_selectPartRange: function (start, end, scrollToEnd = true) {
898923
if (start === undefined || start === null)
899924
start = this._map._docLayer._selectedPart;
900925

@@ -919,7 +944,8 @@ window.L.Control.PartsPreview = window.L.Control.extend({
919944
}
920945
}
921946
this._selectedPartRange = [start, end];
922-
this._scrollToPart(end);
947+
if (scrollToEnd)
948+
this._scrollToPart(end);
923949
},
924950

925951
_modifySelectedPartRange: function (direction) {

cypress_test/integration_tests/desktop/impress/slide_sections_spec.js

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* -*- js-indent-level: 8 -*- */
2-
/* global describe it cy require beforeEach */
2+
/* global describe it cy require beforeEach expect */
33

44
var helper = require('../../common/helper');
55
var desktopHelper = require('../../common/desktop_helper');
@@ -115,6 +115,30 @@ describe(['tagdesktop', 'tagnextcloud', 'tagproxy'], 'Slide sections', function(
115115
assertSectionHeaders(['Section-2', 'Section-1', 'Section-3']);
116116
});
117117

118+
it('Section slide selection', function() {
119+
helper.processToIdle(this.win);
120+
121+
// 3 sections: Section-1 (slides 1-4), Section-2 (5-11), Section-3 (12-13).
122+
assertSectionHeaders(['Section-1', 'Section-2', 'Section-3']);
123+
124+
// Click the body of Section-2's header (anywhere that isn't the toggle).
125+
cy.cGet('.slide-section-header').eq(1)
126+
.find('.slide-section-name').click();
127+
helper.processToIdle(this.win);
128+
129+
cy.window().then((win) => {
130+
var impress = win['0'].app.impress;
131+
// Slides in Section-2 (indices 4-10) should be selected.
132+
for (var i = 4; i <= 10; i++)
133+
expect(impress.isSlideSelected(i)).to.be.true;
134+
135+
// Slides outside Section-2 should not be selected.
136+
[0, 1, 2, 3, 11, 12].forEach(function (i) {
137+
expect(impress.isSlideSelected(i)).to.be.false;
138+
});
139+
});
140+
});
141+
118142
it('Collapse section hides its slides', function() {
119143
helper.processToIdle(this.win);
120144

0 commit comments

Comments
 (0)