mirror of
https://github.com/TracksApp/tracks.git
synced 2026-01-18 07:05:28 +01:00
implement go to project with autocomplete
This commit is contained in:
parent
01005cc3d3
commit
79fdd5d625
12 changed files with 210 additions and 100 deletions
|
|
@ -47,12 +47,14 @@ $ ->
|
|||
# ADD: a is bound in navbar
|
||||
|
||||
# GO TO
|
||||
# Mousetrap.bind 'g h', TracksApp.go_home
|
||||
Mousetrap.bind 'G', -> TracksApp.go_menu()
|
||||
Mousetrap.bind 'g h', -> TracksApp.go_home()
|
||||
Mousetrap.bind 'g c', -> alert("go context")
|
||||
# Mousetrap.bind 'g C', TracksApp.go_contexts
|
||||
Mousetrap.bind 'g C', -> TracksApp.go_contexts()
|
||||
Mousetrap.bind 'g t', -> alert("go tag")
|
||||
Mousetrap.bind 'g p', -> alert("go project")
|
||||
# Mousetrap.bind 'g P', TracksApp.go_projects
|
||||
Mousetrap.bind 'g p', -> TracksApp.go_project()
|
||||
Mousetrap.bind 'g P', -> TracksApp.go_projects()
|
||||
Mousetrap.bind 'g s', -> TracksApp.go_starred()
|
||||
|
||||
# VIEW
|
||||
Mousetrap.bind 'v p', -> alert("group by project")
|
||||
|
|
|
|||
|
|
@ -1,80 +1,104 @@
|
|||
# Tracks specific coffeescript
|
||||
# TracksApp =
|
||||
# goto_page: (page) -> window.location.href = page
|
||||
# go_home: this.goto_page "/"
|
||||
# go_contexts: this.goto_page "/contexts"
|
||||
# go_projects: this.goto_page "/projects"
|
||||
|
||||
TracksApp =
|
||||
goto_page: (page) -> window.location.href = page
|
||||
go_home: -> TracksApp.goto_page "/"
|
||||
go_contexts: -> TracksApp.goto_page "/contexts"
|
||||
go_projects: -> TracksApp.goto_page "/projects"
|
||||
go_starred: -> TracksApp.goto_page "/tag/starred"
|
||||
|
||||
createSubmenu: (todo, itemToAddBefore) ->
|
||||
template_clone = $("div.todo-sub-menu-template").clone()
|
||||
itemToAddBefore.before(template_clone)
|
||||
todo_menu = todo.find("div.todo-sub-menu-template")
|
||||
todo_menu.removeClass("todo-sub-menu-template")
|
||||
todo_menu.addClass("todo-sub-menu")
|
||||
todo_menu.removeClass("hide")
|
||||
go_project: ->
|
||||
$("input#tracks-goto-project").val("")
|
||||
$('div#tracks-go-project-dialog').on 'shown', -> $("input#tracks-goto-project").focus()
|
||||
$('div#tracks-go-project-dialog').modal()
|
||||
|
||||
appendTodoSubMenu: (todo) ->
|
||||
if todo.find("div.todo-sub-menu").length is 0
|
||||
notes_row = todo.find(".todo-notes").parent()
|
||||
submenu = TracksApp.createSubmenu(todo, notes_row)
|
||||
else
|
||||
todo.find("div.todo-sub-menu").removeClass("hide")
|
||||
go_menu: -> $('div#tracks-goto-dialog').modal()
|
||||
add_todo: -> $('div#tracks-add-action-dialog').modal()
|
||||
|
||||
selectTodo: (new_todo) ->
|
||||
selected_item = $("div.todo-item.selected-item")
|
||||
selected_item.find("div.todo-sub-menu").addClass("hide")
|
||||
selected_item.find("span.todo-item-detail").addClass("hide")
|
||||
selected_item.removeClass("selected-item")
|
||||
TracksApp.appendTodoSubMenu(new_todo)
|
||||
new_todo.find("span.todo-item-detail").removeClass("hide")
|
||||
new_todo.addClass("selected-item")
|
||||
createSubmenu: (todo, itemToAddBefore) ->
|
||||
template_clone = $("div.todo-sub-menu-template").clone()
|
||||
itemToAddBefore.before(template_clone)
|
||||
todo_menu = todo.find("div.todo-sub-menu-template")
|
||||
todo_menu.removeClass("todo-sub-menu-template")
|
||||
todo_menu.addClass("todo-sub-menu")
|
||||
todo_menu.removeClass("hide")
|
||||
|
||||
selectPrevNext: (go_next) ->
|
||||
current = prev = next = null
|
||||
stop = false
|
||||
$("div.todo-item").each ->
|
||||
if stop
|
||||
next = $(this)
|
||||
return false
|
||||
appendTodoSubMenu: (todo) ->
|
||||
if todo.find("div.todo-sub-menu").length is 0
|
||||
notes_row = todo.find(".todo-notes").parent()
|
||||
submenu = TracksApp.createSubmenu(todo, notes_row)
|
||||
else
|
||||
todo.find("div.todo-sub-menu").removeClass("hide")
|
||||
|
||||
prev = current
|
||||
current = $(this)
|
||||
selectTodo: (new_todo) ->
|
||||
selected_item = $("div.todo-item.selected-item")
|
||||
selected_item.find("div.todo-sub-menu").addClass("hide")
|
||||
selected_item.find("span.todo-item-detail").addClass("hide")
|
||||
selected_item.removeClass("selected-item")
|
||||
TracksApp.appendTodoSubMenu(new_todo)
|
||||
new_todo.find("span.todo-item-detail").removeClass("hide")
|
||||
new_todo.addClass("selected-item")
|
||||
|
||||
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())
|
||||
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#menu-keyboard-shotcuts").click -> $('div#tracks-shortcuts-dialog').modal()
|
||||
|
||||
$("a.button-add-todo").click -> $('div#tracks-add-action-dialog').modal()
|
||||
$("a.button-add-todo").click -> TracksApp.add_todo()
|
||||
$("a.button-home").click -> TracksApp.go_home()
|
||||
$("a.button-goto").click -> TracksApp.go_menu()
|
||||
|
||||
$("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)
|
||||
$("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)
|
||||
|
||||
$("span.todo-item-description-container").click ->
|
||||
TracksApp.selectTodo( $(this).parent().parent().parent() )
|
||||
$("span.todo-item-description-container").click ->
|
||||
TracksApp.selectTodo( $(this).parent().parent().parent() )
|
||||
|
||||
$('.ajax-typeahead').typeahead
|
||||
minLength: 3,
|
||||
source: (query, process) ->
|
||||
typeaheadURL = $(this)[0].$element[0].dataset.link
|
||||
return $.ajax
|
||||
url: typeaheadURL,
|
||||
type: 'get',
|
||||
data: {"query": query},
|
||||
dataType: 'json',
|
||||
success: (json) ->
|
||||
$("input#tracks-json-result").val(json)
|
||||
map = $.map json, (data, item) -> data.value
|
||||
return process(map)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue