From b20443a0db990241d2b9028e1fbfdbc41ec179e5 Mon Sep 17 00:00:00 2001 From: Felix Niklas Date: Sat, 12 Jul 2014 18:36:23 +0200 Subject: [PATCH] navbar: tasks and search --- app/assets/images/sprite.svg | 6 +- .../app/controllers/navigation.js.coffee | 39 +++-- .../javascripts/app/views/navigation.jst.eco | 96 ++++++++--- .../app/views/navigation/result.jst.eco | 19 ++- app/assets/stylesheets/zzz.css.erb | 149 ++++++++++++++---- 5 files changed, 239 insertions(+), 70 deletions(-) diff --git a/app/assets/images/sprite.svg b/app/assets/images/sprite.svg index 6329f7e3f..9596376cd 100644 --- a/app/assets/images/sprite.svg +++ b/app/assets/images/sprite.svg @@ -1,5 +1,5 @@ - + sprite Created with Sketch (http://www.bohemiancoding.com/sketch) @@ -13,5 +13,9 @@ + + + + \ No newline at end of file diff --git a/app/assets/javascripts/app/controllers/navigation.js.coffee b/app/assets/javascripts/app/controllers/navigation.js.coffee index ef79f1b06..5c798cdea 100644 --- a/app/assets/javascripts/app/controllers/navigation.js.coffee +++ b/app/assets/javascripts/app/controllers/navigation.js.coffee @@ -49,7 +49,7 @@ class App.Navigation extends App.Controller # remove result if not result exists if _.isEmpty( result ) - @el.find('.dropdown').removeClass('open') + @el.find('.search').removeClass('open') el.html( '' ) # remove old popovers @@ -63,7 +63,7 @@ class App.Navigation extends App.Controller el.html( html ) # show result list - @el.find('.dropdown').addClass('open') + @el.find('.search').addClass('open') # start ticket popups @ticketPopups() @@ -136,30 +136,34 @@ class App.Navigation extends App.Controller ticket = App.Ticket.find( id ) ticket.humanTime = @humanTime(ticket.created_at) data = - display: "##{ticket.number} - #{ticket.title} - #{ticket.humanTime}" - id: ticket.id - class: "ticket-popover" - url: ticket.uiUrl() + display: "##{ticket.number} - #{ticket.title}" + createt_at: "#{ticket.created_at}" + humanTime: "#{ticket.humanTime}" + id: ticket.id + class: "task level-1 ticket-popover" + url: ticket.uiUrl() + iconClass: "priority" area.result.push data else if area.name is 'User' area.result = [] for id in area.ids user = App.User.find( id ) data = - display: "#{user.displayName()}" - id: user.id - class: "user-popover" - url: user.uiUrl() + display: "#{user.displayName()}" + id: user.id + class: "user user-popover" + iconClass: "user" area.result.push data else if area.name is 'Organization' area.result = [] for id in area.ids organization = App.Organization.find( id ) data = - display: "#{organization.displayName()}" - id: organization.id - class: "organization-popover" - url: organization.uiUrl() + display: "#{organization.displayName()}" + id: organization.id + class: "organisation organization-popover" + url: organization.uiUrl() + iconClass: "organisation" area.result.push data @renderResult(result) @@ -171,6 +175,8 @@ class App.Navigation extends App.Controller # remember to set search box @searchFocus = true + @el.find('.search').addClass('focused') + # check if search is needed @term = @el.find('#global-search').val() return if @searchFocusSet @@ -180,6 +186,8 @@ class App.Navigation extends App.Controller # remove search result @el.find('#global-search').bind( 'focusout', (e) => + @el.find('.search').removeClass('focused') + @delay( => @searchFocus = false @@ -189,13 +197,14 @@ class App.Navigation extends App.Controller ) # prevent submit of search box - @el.find('#global-search').parent().bind( 'submit', (e) => + @el.find('form.search').bind( 'submit', (e) => e.preventDefault() ) # start search @el.find('#global-search').bind( 'keyup', (e) => @term = @el.find('#global-search').val() + return if !@term return if @term is search @delay( searchFunction, 220, 'search' ) diff --git a/app/assets/javascripts/app/views/navigation.jst.eco b/app/assets/javascripts/app/views/navigation.jst.eco index 023eb59f0..7d0dcb21b 100644 --- a/app/assets/javascripts/app/views/navigation.jst.eco +++ b/app/assets/javascripts/app/views/navigation.jst.eco @@ -1,16 +1,66 @@ -
+ + +
-