add search mechanism to API

This commit is contained in:
Xuan Sang LE 2018-03-03 14:23:38 +01:00
parent e0581b71ec
commit f5d4e87828
2 changed files with 18 additions and 12 deletions

View File

@ -35,7 +35,7 @@ class BaseModel
trigger: (e, d) -> @observable.trigger e, d
subscribe: (e, f) ->
subscribe: (e, f) ->
_courrier.on e, f, @
openDialog: (d, f, title, data) ->
@ -46,6 +46,7 @@ class BaseModel
@error "Dialog #{d} not found"
return
@dialog = new _GUI.subwindows[d]()
#@dialog.observable = riot.observable() unless @dialog
@dialog.parent = @
@dialog.handler = f
@dialog.pid = @pid

View File

@ -9,19 +9,15 @@ class SpotlightDialog extends this.OS.GUI.BaseDialog
me = @
@height = ($ @scheme).css("height")
@container = @find "container"
@container.set "selected", -1
console.log "new dia"
($ @scheme).css("height", "45px")
#fn = (e) ->
# if e.keyCode is 27
# ($ document).unbind "keyup", fn
# me.handler(e) if me.handler
#($ document).keyup fn
fn1 = (e) ->
if not $(e.target).closest(me.scheme).length
($ document).unbind "click", fn1
me.handler(e) if me.handler
($ document).click fn1
($ document).click @clickHandler
@searchbox = @find "searchbox"
($ @searchbox).focus()
($ @searchbox).keyup (e) ->
@ -30,8 +26,15 @@ class SpotlightDialog extends this.OS.GUI.BaseDialog
return if e.data.dataid and e.data.dataid is "header"
me.handler(e) if me.handler
me._gui.openWith e.data
($ document).unbind "click", me.clickHandler
me.quit()
clickHandler: (e) ->
me = @
if not $(e.target).closest(me.scheme).length
($ document).unbind "click", me.clickHandler
me.handler(e) if me.handler
me.quit()
search: (e) ->
switch e.which
@ -52,6 +55,8 @@ class SpotlightDialog extends this.OS.GUI.BaseDialog
return if sel.dataid and sel.dataid is "header"
@.handler(e) if @.handler
@._gui.openWith sel
($ document).unbind "click", @clickHandler
@.quit()
else
text = @searchbox.value
($ @scheme).css("height", "45px")
@ -81,13 +86,13 @@ class Spotlight extends this.OS.GUI.BaseService
awake: (e) ->
me = @
@show = not @show
if @show
if not @show
me.show = true
@openDialog "SpotlightDialog", (d) ->
me.show = false
me.dialog.quit() if me.dialog
me.dialog = undefined
else
me.show = false
@dialog.quit() if @dialog
cleanup: (evt) ->