add search mechanism to API

This commit is contained in:
Xuan Sang LE
2018-03-03 13:44:52 +01:00
parent 685301e793
commit 35c068ede8
6 changed files with 88 additions and 9 deletions

View File

@ -9,8 +9,7 @@ class Calendar extends this.OS.GUI.BaseService
me = @
@watch 1000, () ->
now = new Date
me.text = "#{now.getDate()}/#{(now.getMonth()+1)}/#{now.getFullYear()} " +
"#{now.getHours()}:#{now.getMinutes()}:#{now.getSeconds()}"
me.text = now.toString()
me.update()
awake: (e) ->

View File

@ -8,6 +8,7 @@ class SpotlightDialog extends this.OS.GUI.BaseDialog
main: () ->
me = @
@height = ($ @scheme).css("height")
@container = @find "container"
($ @scheme).css("height", "45px")
#fn = (e) ->
# if e.keyCode is 27
@ -25,9 +26,41 @@ class SpotlightDialog extends this.OS.GUI.BaseDialog
($ @searchbox).focus()
($ @searchbox).keyup (e) ->
me.search e
@container.set "onlistdbclick", (e)->
return if e.data.dataid and e.data.dataid is "header"
me._gui.openWith e.data
me.handler(e) if me.handler
search: (e) ->
($ @scheme).css("height", @height)
switch e.which
when 37
e.preventDefault()
when 38
@container.selectPrev()
e.preventDefault()
when 39
e.preventDefault()
when 40
@container.selectNext()
e.preventDefault()
when 13
e.preventDefault()
sel = @container.get "selected"
return unless sel
return if sel.dataid and sel.dataid is "header"
@._gui.openWith sel
@.handler(e) if @.handler
else
text = @searchbox.value
($ @scheme).css("height", "45px")
return unless text.length > 3
result = @_api.search text
return if result.length is 0
@container.set "items", result
($ @scheme).css("height", @height)
this.OS.register "SpotlightDialog", SpotlightDialog

View File

@ -85,7 +85,9 @@ afx-app-window[data-id = "spotlight-win"] .afx-window-content{
afx-app-window[data-id = "spotlight-win"] afx-list-view[data-id="container"]{
border-top:1px solid #cacaca;
}
afx-app-window[data-id = "spotlight-win"] afx-list-view[data-id="container"] afx-label.search-header{
font-weight: bold;
}
afx-app-window[data-id = "spotlight-win"] afx-resizer{
background-color: transparent;
border-left: 1px solid #cacaca;