mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-08-28 13:58:19 +02:00
much better interaction on levels keys with tabs
This commit is contained in:
parent
12e921a781
commit
c522722513
4 changed files with 56 additions and 2 deletions
|
|
@ -89,6 +89,10 @@ var LevelDropdownView = ContainedBase.extend({
|
|||
if (id === this.JSON.selectedTab) {
|
||||
return;
|
||||
}
|
||||
this.updateTabTo(id);
|
||||
},
|
||||
|
||||
updateTabTo: function(id) {
|
||||
this.JSON.selectedTab = id;
|
||||
this.render();
|
||||
if (this.selectedID) {
|
||||
|
|
@ -119,7 +123,24 @@ var LevelDropdownView = ContainedBase.extend({
|
|||
|
||||
leftOrRight: function(delta) {
|
||||
this.deselectIconByID(this.selectedID);
|
||||
this.selectedIndex = this.wrapIndex(this.selectedIndex + delta, this.getCurrentSequence());
|
||||
var index = this.selectedIndex + delta;
|
||||
|
||||
var sequence = this.getCurrentSequence();
|
||||
var tabs = this.JSON.tabs;
|
||||
// switch tabs now if needed / possible
|
||||
if (index >= sequence.length &&
|
||||
this.getTabIndex() + 1 < tabs.length) {
|
||||
this.switchToTabIndex(this.getTabIndex() + 1);
|
||||
this.selectedIndex = 0;
|
||||
} else if (index < 0 &&
|
||||
this.getTabIndex() - 1 >= 0) {
|
||||
this.switchToTabIndex(this.getTabIndex() - 1);
|
||||
this.selectedIndex = 0;
|
||||
} else {
|
||||
this.selectedIndex = this.wrapIndex(
|
||||
this.selectedIndex + delta, this.getCurrentSequence()
|
||||
);
|
||||
}
|
||||
this.updateSelectedIcon();
|
||||
},
|
||||
|
||||
|
|
@ -168,6 +189,18 @@ var LevelDropdownView = ContainedBase.extend({
|
|||
this.selectedSequence = undefined;
|
||||
},
|
||||
|
||||
getTabIndex: function() {
|
||||
var ids = _.map(this.JSON.tabs, function(tab) {
|
||||
return tab.id;
|
||||
});
|
||||
return ids.indexOf(this.JSON.selectedTab);
|
||||
},
|
||||
|
||||
switchToTabIndex: function(index) {
|
||||
var tabID = this.JSON.tabs[index].id;
|
||||
this.updateTabTo(tabID);
|
||||
},
|
||||
|
||||
wrapIndex: function(index, arr) {
|
||||
index = (index >= arr.length) ? 0 : index;
|
||||
index = (index < 0) ? arr.length - 1 : index;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue