mirror of
https://github.com/TracksApp/tracks.git
synced 2026-01-04 00:08:50 +01:00
add keyboard shortcuts and make todos selectable useing j and k
This commit is contained in:
parent
b725b7b137
commit
db29b84f69
17 changed files with 217 additions and 99 deletions
|
|
@ -41,8 +41,11 @@ $ ->
|
|||
|
||||
mouseTrapRails.toggleHints() if mouseTrapRails.showOnLoad
|
||||
|
||||
# HELP
|
||||
Mousetrap.bind '?', -> $('div#tracks-shortcuts-dialog').modal()
|
||||
Mousetrap.bind 'a', -> $('div#tracks-add-action-dialog').modal()
|
||||
|
||||
# ADD: a is bound in navbar
|
||||
|
||||
# GO TO
|
||||
# Mousetrap.bind 'g h', TracksApp.go_home
|
||||
Mousetrap.bind 'g c', -> alert("go context")
|
||||
|
|
@ -50,6 +53,11 @@ $ ->
|
|||
Mousetrap.bind 'g t', -> alert("go tag")
|
||||
Mousetrap.bind 'g p', -> alert("go project")
|
||||
# Mousetrap.bind 'g P', TracksApp.go_projects
|
||||
|
||||
# VIEW
|
||||
Mousetrap.bind 'v p', -> alert("group by project")
|
||||
Mousetrap.bind 'v c', -> alert("group by context")
|
||||
|
||||
# Item Selection
|
||||
Mousetrap.bind 'j', -> TracksApp.selectNext()
|
||||
Mousetrap.bind 'k', -> TracksApp.selectPrev()
|
||||
|
|
@ -3,4 +3,68 @@
|
|||
# goto_page: (page) -> window.location.href = page
|
||||
# go_home: this.goto_page "/"
|
||||
# go_contexts: this.goto_page "/contexts"
|
||||
# go_projects: this.goto_page "/projects"
|
||||
# go_projects: this.goto_page "/projects"
|
||||
|
||||
TracksApp =
|
||||
currentPosition: 0
|
||||
|
||||
updateCurrentPosition: ->
|
||||
this.currentPosition = 0
|
||||
$("div.todo-item").each ->
|
||||
if $(this).hasClass("selected-item")
|
||||
return false
|
||||
else
|
||||
this.currentPosition++
|
||||
|
||||
selectTodo: (new_todo) ->
|
||||
$("div.todo-item.selected-item").removeClass("selected-item")
|
||||
new_todo.addClass("selected-item")
|
||||
TracksApp.updateCurrentPosition()
|
||||
|
||||
selectPrevNext: (go_next) ->
|
||||
current = prev = next = null
|
||||
stop = false
|
||||
$("div.todo-item").each ->
|
||||
if stop
|
||||
next = $(this)
|
||||
return false
|
||||
|
||||
prev = current
|
||||
current = $(this)
|
||||
|
||||
if $(this).hasClass("selected-item")
|
||||
stop = true
|
||||
|
||||
if go_next
|
||||
TracksApp.selectTodo(prev) if prev?
|
||||
return prev
|
||||
else
|
||||
TracksApp.selectTodo(next) if next?
|
||||
return next
|
||||
|
||||
selectPrev: ->
|
||||
unless TracksApp.selectPrevNext(true)?
|
||||
TracksApp.selectTodo($("div.todo-item").last())
|
||||
|
||||
selectNext: ->
|
||||
unless TracksApp.selectPrevNext(false)?
|
||||
TracksApp.selectTodo($("div.todo-item").first())
|
||||
|
||||
# Make TracksApp globally accessible. From http://stackoverflow.com/questions/4214731/coffeescript-global-variables
|
||||
root = exports ? this
|
||||
root.TracksApp = TracksApp
|
||||
|
||||
$ ->
|
||||
$("a#menu-keyboard-shotcuts").click -> $('div#tracks-shortcuts-dialog').modal()
|
||||
|
||||
$("a.button-add-todo").click -> $('div#tracks-add-action-dialog').modal()
|
||||
|
||||
$("i.icon-book").click ->
|
||||
notes_id = $( this ).attr("data-note-id")
|
||||
notes_div = $("div#" + notes_id )
|
||||
notes_div.toggleClass("hide")
|
||||
todo_item = $(this).parent().parent().parent().parent()
|
||||
TracksApp.selectTodo(todo_item)
|
||||
|
||||
$("div.todo-item-description-container").click ->
|
||||
TracksApp.selectTodo( $(this).parent().parent().parent() )
|
||||
Loading…
Add table
Add a link
Reference in a new issue