mirror of
https://github.com/lxsang/antos-frontend.git
synced 2025-07-27 11:19:47 +02:00
adapt the system with the new api
This commit is contained in:
@ -31,9 +31,9 @@ class Calendar extends this.OS.GUI.BaseService
|
||||
|
||||
|
||||
awake: (e) ->
|
||||
@.openDialog "CalendarDialog", (d) ->
|
||||
@.openDialog("CalendarDialog" )
|
||||
.then (d) ->
|
||||
console.log d
|
||||
, "Calendar"
|
||||
# do nothing
|
||||
cleanup: (evt) ->
|
||||
console.log "cleanup for quit"
|
||||
|
@ -1,5 +1,55 @@
|
||||
<afx-app-window apptitle="Preview" width="100" height="100">
|
||||
<afx-hbox>
|
||||
<afx-button data-height="30" toggle = "true" text="__(Read more)" iconclass="fa fa-camera-retro fa-lg" id="button"></afx-button>
|
||||
</afx-hbox>
|
||||
<afx-app-window data-id="example-show-case" apptitle="AntOS GUI widgets" width="650" height="500">
|
||||
<afx-vbox>
|
||||
<afx-menu data-height="30" data-id="menu" />
|
||||
<afx-tab-container data-id="tabctn" tabbarheight= "30">
|
||||
|
||||
<afx-hbox tabname="Widgets">
|
||||
<afx-vbox data-width="150">
|
||||
<afx-tree-view data-id="tree" />
|
||||
<afx-slider data-id="slider" data-height="30" value="50"/>
|
||||
</afx-vbox>
|
||||
<afx-resizer data-width="5" />
|
||||
<afx-vbox data-width="grow">
|
||||
<afx-hbox min-height="50">
|
||||
<afx-switch data-id="switch" />
|
||||
<afx-button text="__(This is the label)"
|
||||
data-id="bttest"
|
||||
iconclass="fa fa-camera-retro fa-lg"
|
||||
icon="os://packages/DummyApp/icon.png"/>
|
||||
<afx-nspinner data-id="spin" value="10" step="2" />
|
||||
</afx-hbox>
|
||||
<afx-resizer data-height="5" />
|
||||
<afx-hbox>
|
||||
<afx-list-view data-id="list" dropdown="false" multiselect="true" />
|
||||
</afx-hbox>
|
||||
<afx-hbox data-height="150">
|
||||
<afx-grid-view data-id="grid" multiselect="false" />
|
||||
</afx-hbox>
|
||||
</afx-vbox>
|
||||
</afx-hbox>
|
||||
<afx-hbox tabname="Virtual desktop">
|
||||
<afx-float-list data-id = "flist"/>
|
||||
</afx-hbox>
|
||||
<afx-hbox tabname="Calendar">
|
||||
<afx-calendar-view data-id = "cal"/>
|
||||
</afx-hbox>
|
||||
<afx-hbox tabname="Color picker">
|
||||
<afx-color-picker data-id = "cpk"/>
|
||||
</afx-hbox>
|
||||
<afx-hbox tabname="File view">
|
||||
<afx-vbox>
|
||||
<afx-file-view data-id = "fileview"/>
|
||||
<afx-list-view data-id = "viewoption" data-height="30" dropdown="true" />
|
||||
</afx-vbox>
|
||||
</afx-hbox>
|
||||
|
||||
<afx-hbox tabname="Dialogs">
|
||||
<afx-vbox>
|
||||
<afx-list-view data-id = "dialoglist"/>
|
||||
<afx-button data-id = "btrundia" text="Run dialog" data-height="30"/>
|
||||
</afx-vbox>
|
||||
</afx-hbox>
|
||||
|
||||
</afx-tab-container>
|
||||
</afx-vbox>
|
||||
</afx-app-window>
|
@ -5,107 +5,20 @@ class ShowCase extends this.OS.GUI.BaseApplication
|
||||
|
||||
main: () ->
|
||||
me = @
|
||||
@announcer = new Ant.OS.API.Announcer()
|
||||
@announcer.on "evt1", (data) ->
|
||||
console.log "evt1", data
|
||||
@announcer.on "evt1", (data) ->
|
||||
console.log "evt1 fn1: ", data
|
||||
fn = (data) ->
|
||||
console.log "evt1 fn2: ", data
|
||||
@announcer.on "evt1", fn
|
||||
@announcer.on "evt2", (data) ->
|
||||
console.log "evt2", data
|
||||
@announcer.one "evt1", (data) ->
|
||||
console.log "evt1 only one", data
|
||||
@announcer.one "*", (data) ->
|
||||
console.log "evt1 only one*", data
|
||||
@announcer.on "*", fn
|
||||
|
||||
console.log me.announcer
|
||||
@on "btclick", (e) ->
|
||||
me.openwin()
|
||||
###
|
||||
me.announcer.trigger("evt1", "Hello 1")
|
||||
me.announcer.off("*")
|
||||
me.announcer.trigger("evt2", "Hello 2")
|
||||
console.log me.announcer
|
||||
me.notify "Hello"
|
||||
console.log tag
|
||||
###
|
||||
openwin: () ->
|
||||
me = @
|
||||
scheme = $.parseHTML """
|
||||
<afx-app-window data-id="example-show-case" apptitle="Preview" width="650" height="500">
|
||||
<afx-vbox>
|
||||
<afx-menu data-height="30" data-id="menu" />
|
||||
<afx-tab-container data-id="tabctn" tabbarheight= "30">
|
||||
|
||||
<afx-hbox tabname="Widgets">
|
||||
<afx-vbox data-width="150">
|
||||
<afx-tree-view data-id="tree" />
|
||||
<afx-slider data-id="slider" data-height="30" value="50"/>
|
||||
</afx-vbox>
|
||||
<afx-resizer data-width="5" />
|
||||
<afx-vbox data-width="grow">
|
||||
<afx-hbox min-height="50">
|
||||
<afx-switch data-id="switch" />
|
||||
<afx-button text="__(This is the label)"
|
||||
data-id="bttest"
|
||||
iconclass="fa fa-camera-retro fa-lg"
|
||||
icon="os://packages/DummyApp/icon.png"/>
|
||||
<afx-nspinner data-id="spin" value="10" step="2" />
|
||||
</afx-hbox>
|
||||
<afx-resizer data-height="5" />
|
||||
<afx-hbox>
|
||||
<afx-list-view data-id="list" dropdown="false" multiselect="true" />
|
||||
</afx-hbox>
|
||||
<afx-hbox data-height="150">
|
||||
<afx-grid-view data-id="grid" multiselect="false" />
|
||||
</afx-hbox>
|
||||
</afx-vbox>
|
||||
</afx-hbox>
|
||||
<afx-hbox tabname="Virtual desktop">
|
||||
<afx-float-list data-id = "flist"/>
|
||||
</afx-hbox>
|
||||
<afx-hbox tabname="Calendar">
|
||||
<afx-calendar-view data-id = "cal"/>
|
||||
</afx-hbox>
|
||||
<afx-hbox tabname="Color picker">
|
||||
<afx-color-picker data-id = "cpk"/>
|
||||
</afx-hbox>
|
||||
<afx-hbox tabname="File view">
|
||||
<afx-vbox>
|
||||
<afx-file-view data-id = "fileview"/>
|
||||
<afx-list-view data-id = "viewoption" data-height="30" dropdown="true" />
|
||||
</afx-vbox>
|
||||
</afx-hbox>
|
||||
</afx-tab-container>
|
||||
</afx-vbox>
|
||||
</afx-app-window>
|
||||
"""
|
||||
ctmenu = $.parseHTML """<afx-menu data-id="mn-context" context="true" style="display:none;" /></div>"""
|
||||
($ "#desktop").append scheme[0]
|
||||
($ "#wrapper").append ctmenu[0]
|
||||
me.subwin = scheme[0].uify()
|
||||
bt = $ "[data-id='bttest']", scheme[0]
|
||||
bt[0].set "onbtclick", (e) ->
|
||||
|
||||
bt = @find 'bttest'
|
||||
bt.set "onbtclick", (e) ->
|
||||
console.log "btclicked"
|
||||
me.subwin.set "resizable", true
|
||||
me.subwin.set "minimizable", false
|
||||
me.subwin.observable.on "exit", () ->
|
||||
me.subwin.observable.off "*"
|
||||
$(me.subwin).remove()
|
||||
me.quit()
|
||||
|
||||
me.subwin.observable.on "btclick", (e) ->
|
||||
|
||||
@observable.on "btclick", (e) ->
|
||||
console.log "button clicked"
|
||||
|
||||
me.subwin.observable.on "menuselect", (e) ->
|
||||
@observable.on "menuselect", (e) ->
|
||||
console.log e.id
|
||||
|
||||
list = $ "[data-id='list']", scheme[0]
|
||||
list = @find 'list'
|
||||
|
||||
list[0].set "data", [
|
||||
list.set "data", [
|
||||
{ text: "some thing with avery long text" },
|
||||
{ text: "some thing 1", closable: true },
|
||||
{ text: "some thing 2", iconclass: "fa fa-camera-retro fa-lg" },
|
||||
@ -113,42 +26,39 @@ class ShowCase extends this.OS.GUI.BaseApplication
|
||||
{ text: "some thing 4" },
|
||||
{ text: "some thing 5" }
|
||||
]
|
||||
list[0].unshift { text: "shifted el" }
|
||||
console.log "after shift", list[0].get("data")
|
||||
list[0].set "onlistselect", (e) ->
|
||||
console.log(e.data.items)
|
||||
me.subwin.observable.on "itemclose", (e) ->
|
||||
console.log "remove", list[0].get("data")
|
||||
list.unshift { text: "shifted el" }
|
||||
list.set "onlistselect", (e) -> console.log(e.data.items)
|
||||
@observable.on "itemclose", (e) ->
|
||||
console.log "remove", list.get("data")
|
||||
console.log list[0].get "selectedItem"
|
||||
console.log list[0].get "selectedItems"
|
||||
|
||||
sw = $ "[data-id='switch']", scheme[0]
|
||||
sw[0].set "onchange", (e) ->
|
||||
sw = @find 'switch'
|
||||
sw.set "onchange", (e) ->
|
||||
console.log e.data
|
||||
|
||||
spin = $ "[data-id='spin']", scheme[0]
|
||||
spin[0].set "onchange", (e) ->
|
||||
spin = @find 'spin'
|
||||
spin.set "onchange", (e) ->
|
||||
console.log e.data
|
||||
|
||||
menu = $ "[data-id='menu']", scheme[0]
|
||||
menu[0].set "items", @menu()
|
||||
ctmenu = ctmenu[0].uify(me.subwin.observable)
|
||||
ctmenu.set "items", @menu()
|
||||
ctmenu.set "onmenuselect", (e) ->
|
||||
console.log "root event", e
|
||||
list[0].contextmenuHandle = (e) ->
|
||||
console.log e
|
||||
ctmenu.show e
|
||||
menu = @find 'menu'
|
||||
menu.set "items", @menu()
|
||||
|
||||
list.contextmenuHandle = (e, m) ->
|
||||
m.set "items", me.menu()
|
||||
m.show e
|
||||
|
||||
grid = $ "[data-id='grid']", scheme[0]
|
||||
grid[0].set "oncelldbclick", (e) ->
|
||||
grid = @find 'grid'
|
||||
grid.set "oncelldbclick", (e) ->
|
||||
console.log "on dbclick", e
|
||||
grid[0].set "onrowselect", (e) ->
|
||||
grid.set "onrowselect", (e) ->
|
||||
console.log "on rowselect", e.data.items
|
||||
me.subwin.observable.on "cellselect", (e) ->
|
||||
|
||||
@observable.on "cellselect", (e) ->
|
||||
console.log "observable", e
|
||||
grid[0].set "header", [{ text: "header1", width: 80 }, { text: "header2" }, { text: "header3" }]
|
||||
grid[0].set "rows", [
|
||||
|
||||
grid.set "header", [{ text: "header1", width: 80 }, { text: "header2" }, { text: "header3" }]
|
||||
grid.set "rows", [
|
||||
[{ text: "text 1" }, { text: "text 2" }, { text: "text 3" }],
|
||||
[{ text: "text 4" }, { text: "text 5" }, { text: "text 6" }],
|
||||
[{ text: "text 7" }, { text: "text 8" }, { text: "text 9" }],
|
||||
@ -191,42 +101,42 @@ class ShowCase extends this.OS.GUI.BaseApplication
|
||||
]
|
||||
}
|
||||
|
||||
tree = $ "[data-id='tree']", scheme[0]
|
||||
tree[0].set "data", tdata
|
||||
tree[0].set "ontreeselect", (e) ->
|
||||
tree = @find 'tree'
|
||||
tree.set "data", tdata
|
||||
tree.set "ontreeselect", (e) ->
|
||||
console.log e.data.item.get "treepath"
|
||||
tree[0].set "ontreedbclick", (e) ->
|
||||
tree.set "ontreedbclick", (e) ->
|
||||
console.log "treedbclick", e
|
||||
me.subwin.observable.on "treedbclick", (e) ->
|
||||
@observable.on "treedbclick", (e) ->
|
||||
console.log "observable treedbclick", e
|
||||
|
||||
slider = $ "[data-id='slider']", scheme[0]
|
||||
slider[0].set "onchanging", (v) ->
|
||||
slider = @find 'slider'
|
||||
slider.set "onchanging", (v) ->
|
||||
console.log v
|
||||
|
||||
|
||||
list = $ "[data-id='flist']", scheme[0]
|
||||
list[0].set "data", [
|
||||
flist = @find 'flist'
|
||||
flist.set "data", [
|
||||
{ text: "File.txt" },
|
||||
{ text: "FileB.doc" },
|
||||
{ text: "Data.doc", iconclass: "fa fa-camera-retro fa-lg" }
|
||||
]
|
||||
|
||||
cal = $ "[data-id='cal']", scheme[0]
|
||||
cal[0].set "ondateselect", (e) ->
|
||||
cal = @find 'cal'
|
||||
cal.set "ondateselect", (e) ->
|
||||
console.log e
|
||||
|
||||
pk = $ "[data-id='cpk']", scheme[0]
|
||||
pk[0].set "oncolorselect", (e) ->
|
||||
pk = @find 'cpk'
|
||||
pk.set "oncolorselect", (e) ->
|
||||
console.log e
|
||||
pk[0].set "oncolorselect", (e) ->
|
||||
pk.set "oncolorselect", (e) ->
|
||||
console.log e
|
||||
|
||||
fileview = $("[data-id='fileview']", scheme[0])[0]
|
||||
fileview = @find 'fileview'
|
||||
fileview.set "fetch", (path) ->
|
||||
new Promise (resolve, reject) ->
|
||||
dir = path.asFileHandle()
|
||||
dir.read (d) ->
|
||||
dir.read().then (d) ->
|
||||
p = dir.parent().asFileHandle()
|
||||
p.filename = "[..]"
|
||||
p.type = "dir"
|
||||
@ -235,7 +145,7 @@ class ShowCase extends this.OS.GUI.BaseApplication
|
||||
resolve d.result
|
||||
fileview.set "path", "home:///"
|
||||
|
||||
viewoption = $("[data-id='viewoption']", scheme[0])[0]
|
||||
viewoption = @find 'viewoption'
|
||||
viewoption.set "data", [
|
||||
{ text: "icon" },
|
||||
{ text: "list" },
|
||||
@ -245,6 +155,74 @@ class ShowCase extends this.OS.GUI.BaseApplication
|
||||
console.log e.data.item.get("data").text
|
||||
fileview.set "view", e.data.item.get("data").text
|
||||
|
||||
dllist = @find "dialoglist"
|
||||
btrun = @find "btrundia"
|
||||
|
||||
dllist.set "data", [
|
||||
{ text: "Prompt dialog", id: "prompt" },
|
||||
{ text: "Calendar dialog", id: "calendar" },
|
||||
{ text: "Color picker dialog", id: "colorpicker" },
|
||||
{ text: "Info dialog", id: "info" },
|
||||
{ text: "YesNo dialog", id: "yesno" },
|
||||
{ text: "Selection dialog", id: "selection" },
|
||||
{ text: "About dialog", id: "about" },
|
||||
{ text: "File dialog", id: "file" }
|
||||
]
|
||||
|
||||
btrun.set "onbtclick", (e) ->
|
||||
item = dllist.get "selectedItem"
|
||||
return unless item
|
||||
switch item.get("data").id
|
||||
when "prompt"
|
||||
me.openDialog("PromptDialog", {
|
||||
title: "Prompt review",
|
||||
value: "txt data",
|
||||
label: "enter value"
|
||||
})
|
||||
.then (d) ->
|
||||
console.log d
|
||||
when "calendar"
|
||||
me.openDialog("CalendarDialog", {
|
||||
title: "Calendar"
|
||||
})
|
||||
.then (d) ->
|
||||
console.log d
|
||||
when "colorpicker"
|
||||
me.openDialog("ColorPickerDialog")
|
||||
.then (d) ->
|
||||
console.log d
|
||||
when "info"
|
||||
me.openDialog("InfoDialog", {
|
||||
title: "Info application",
|
||||
name: "Show case",
|
||||
date: "10/12/2014",
|
||||
description: "the brown fox jumps over the lazy dog"
|
||||
})
|
||||
.then (d) ->
|
||||
when "yesno"
|
||||
me.openDialog("YesNoDialog", {
|
||||
title: "Question ?",
|
||||
label: "Do you realy want to delete file ?"
|
||||
})
|
||||
.then (d) ->
|
||||
console.log d
|
||||
when "selection"
|
||||
me.openDialog("SelectionDialog", {
|
||||
title: "Select data ?",
|
||||
data: [
|
||||
{ text: "Option 1" },
|
||||
{ text: "Option 2" },
|
||||
{ text: "Option 3", iconclass: "fa fa-camera-retro fa-lg" }
|
||||
]
|
||||
})
|
||||
.then (d) ->
|
||||
console.log d
|
||||
when "about"
|
||||
me.openDialog("AboutDialog" )
|
||||
.then (d) ->
|
||||
else return
|
||||
|
||||
|
||||
|
||||
mnFile: () ->
|
||||
#console.log file
|
||||
@ -274,9 +252,7 @@ class ShowCase extends this.OS.GUI.BaseApplication
|
||||
{ text: "__(Paste)", dataid: "#{@name}-paste", shortcut: 'C-P' }
|
||||
], onchildselect: (e) -> console.log "child", e
|
||||
}
|
||||
cleanup: () ->
|
||||
return unless @subwin
|
||||
$(@subwin).remove()
|
||||
|
||||
menu: () ->
|
||||
me = @
|
||||
menu = [
|
||||
|
Reference in New Issue
Block a user