mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-04-08 14:52:08 -04:00
feat(Notepad): Implement tab reordering via drag-and-drop functionality
This commit is contained in:
@@ -241,6 +241,28 @@ Singleton {
|
||||
saveMetadata()
|
||||
}
|
||||
|
||||
function reorderTab(fromIndex, toIndex) {
|
||||
if (fromIndex < 0 || fromIndex >= tabs.length || toIndex < 0 || toIndex >= tabs.length)
|
||||
return
|
||||
if (fromIndex === toIndex)
|
||||
return
|
||||
|
||||
var newTabs = tabs.slice()
|
||||
var moved = newTabs.splice(fromIndex, 1)[0]
|
||||
newTabs.splice(toIndex, 0, moved)
|
||||
tabs = newTabs
|
||||
|
||||
if (currentTabIndex === fromIndex) {
|
||||
currentTabIndex = toIndex
|
||||
} else if (fromIndex < currentTabIndex && toIndex >= currentTabIndex) {
|
||||
currentTabIndex--
|
||||
} else if (fromIndex > currentTabIndex && toIndex <= currentTabIndex) {
|
||||
currentTabIndex++
|
||||
}
|
||||
|
||||
saveMetadata()
|
||||
}
|
||||
|
||||
function saveTabAs(tabIndex, userPath) {
|
||||
if (tabIndex < 0 || tabIndex >= tabs.length) return
|
||||
|
||||
|
||||
Reference in New Issue
Block a user