remove riot and use the new tag engine

This commit is contained in:
lxsang
2020-05-09 23:32:26 +02:00
parent 6c0f304767
commit ae54c9a10c
18 changed files with 163 additions and 83 deletions

View File

@ -19,7 +19,7 @@
class BaseModel
constructor: (@name, @args) ->
me = @
@observable = riot.observable()
@observable = new Announcer()
@_api = Ant.OS.API
@_gui = Ant.OS.GUI
@systemsetting = Ant.OS.setting

View File

@ -24,6 +24,9 @@ class BaseService extends this.OS.GUI.BaseModel
@text = ""
@timer = undefined
@holder = undefined
me = @
@onmenuselect = (d) ->
me.awake d
init: ()->
#implement by user
@ -33,10 +36,6 @@ class BaseService extends this.OS.GUI.BaseModel
Ant.OS.APP[@name].meta
attach: (h) ->
@holder = h
update: () ->
@holder.update() if @holder
@scheme.update() if @scheme
watch: ( t, f) ->
me = @

View File

@ -31,10 +31,10 @@ Ant.OS.GUI =
text: "",
iconclass: "fa fa-eercast",
dataid: "sys-menu-root",
child: [
children: [
{
text: "__(Applications)",
child: [],
children: [],
dataid: "sys-apps"
iconclass: "fa fa-adn",
onmenuselect: (d) ->
@ -53,7 +53,7 @@ Ant.OS.GUI =
$(app.scheme).remove() if app.scheme
($ parent).append scheme
app.scheme = scheme[0]
riot.mount ($ scheme), { observable: app.observable }
scheme[0].uify app.observable
app.main()
app.show()
loadScheme: (path, app, parent) ->
@ -319,11 +319,15 @@ Ant.OS.GUI =
Ant.OS.GUI.shortcut[fnk][c](event)
event.preventDefault()
# system menu and dock
riot.mount ($ "#syspanel", $ "#wrapper")
riot.mount ($ "#sysdock", $ "#workspace"), { items: [] }
riot.mount ($ "#systooltip", $ "#wrapper")
$("#syspanel")[0].uify()
$("#sysdock")[0].uify()
$("#systooltip")[0].uify()
$("#contextmenu")[0].uify()
#riot.mount ($ "#syspanel", $ "#wrapper")
#riot.mount ($ "#sysdock", $ "#workspace"), { items: [] }
#riot.mount ($ "#systooltip", $ "#wrapper")
# context menu
riot.mount ($ "#contextmenu", $ "#wrapper")
#riot.mount ($ "#contextmenu", $ "#wrapper")
($ "#workspace").contextmenu (e) -> Ant.OS.GUI.bindContextMenu e
# tooltip
($ "#workspace").mouseover (e) ->
@ -409,7 +413,8 @@ Ant.OS.GUI =
desktop[0].fetch() if d.data.file.hash() is fp.hash() or d.data.file.parent().hash() is fp.hash()
Ant.OS.announcer.ostrigger "desktoploaded"
# mount it
riot.mount desktop
desktop[0].uify()
# riot.mount desktop
, (e, s) ->
alert __("System fail: Cannot init desktop manager")
console.log s, e
@ -417,21 +422,21 @@ Ant.OS.GUI =
($ Ant.OS.GUI.workspace)[0].fetch()
refreshSystemMenu: () ->
Ant.OS.GUI.SYS_MENU[0].child.length = 1
Ant.OS.GUI.SYS_MENU[0].child[0].child.length = 0
Ant.OS.GUI.SYS_MENU[0].child[0].child.push v for k, v of Ant.OS.setting.system.packages when (v and v.app)
Ant.OS.GUI.SYS_MENU[0].child.push v for k, v of Ant.OS.setting.system.menu
Ant.OS.GUI.SYS_MENU[0].child.push
Ant.OS.GUI.SYS_MENU[0].children.length = 1
Ant.OS.GUI.SYS_MENU[0].children[0].children.length = 0
Ant.OS.GUI.SYS_MENU[0].children[0].children.push v for k, v of Ant.OS.setting.system.packages when (v and v.app)
Ant.OS.GUI.SYS_MENU[0].children.push v for k, v of Ant.OS.setting.system.menu
Ant.OS.GUI.SYS_MENU[0].children.push
text: "__(Toggle Full screen)",
dataid: "os-fullsize",
iconclass: "fa fa-tv"
Ant.OS.GUI.SYS_MENU[0].child.push
Ant.OS.GUI.SYS_MENU[0].children.push
text: "__(Log out)",
dataid: "sys-logout",
iconclass: "fa fa-user-times"
($ "[data-id = 'os_menu']", "#syspanel")[0].update()
# Ant.OS.GUI.buildSystemMenu()
buildSystemMenu: () ->
($ "[data-id = 'os_menu']", "#syspanel")[0].set "items", Ant.OS.GUI.SYS_MENU
($ "[data-id = 'osmenu']", "#syspanel")[0].set "items", Ant.OS.GUI.SYS_MENU
#console.log menu

View File

@ -86,4 +86,4 @@ class FloatListTag extends ListViewTag
cleft = 20
ctop += h + 20
Ant.OS.GUI.define "afx-float-list1", FloatListTag
Ant.OS.GUI.define "afx-float-list", FloatListTag

View File

@ -70,7 +70,7 @@ class ListViewTag extends Ant.OS.GUI.BaseTag
@setopt "onlistdbclick", () ->
@setopt "onitemclose", () -> true
@setopt "buttons", []
@setopt "data", {}
@setopt "data", []
@setopt "dropdown", false
@setopt "itemtag", "afx-list-item"
@setopt "multiselect", false
@ -116,6 +116,7 @@ class ListViewTag extends Ant.OS.GUI.BaseTag
.set "onclose", (e) ->
me.iclose e
.set "data", item
item.domel = el[0]
el[0]
remove: (item) ->

View File

@ -162,6 +162,9 @@ class MenuTag extends Ant.OS.GUI.BaseTag
@setopt "items", []
@root.show = (e) ->
me.showctxmenu e
@root.push = (e) -> me.push e
@root.remove = (e) -> me.remove e
@root.unshift = (e) -> me.unshift e
handleselect: (e) ->
$(@root).hide() if @isctxmenu()
@ -184,31 +187,54 @@ class MenuTag extends Ant.OS.GUI.BaseTag
mount: () ->
me = @
$(@refs.container).css "display", "contents"
return unless me.isctxmenu()
$(@refs.container).mouseleave (e) ->
$(@refs.wrapper).mouseleave (e) ->
return unless me.is_root()
$(me.root).hide()
__context__: (v) ->
$(@refs.container).removeClass("context")
$(@refs.wrapper).removeClass("context")
return unless v
$(@refs.container).addClass("context")
$(@refs.wrapper).addClass("context")
$(@root).hide()
unshift: (item) ->
@push item, true
remove: (item) ->
el = item.get "data"
data = @get "items"
if data.includes el
data.splice data.indexOf(el), 1
$(item).remove()
push: (item, flag) ->
el = $("<#{@get("contentag")}>")
if flag
$(@refs.container).prepend el[0]
@get("items").unshift item
else
el.appendTo @refs.container
@get("items").push item
el[0].uify undefined
el[0].set "parent", @get("parent")
el[0].set "root", if @get("parent") then @get("parent").get("root") else @
el[0].set "data", item
item.domel = el[0]
el[0]
__items__: (data) ->
me = @
$(@refs.container).empty()
$("<li>").appendTo(@refs.container).addClass("afx-corner-fix")
for item in data
el = $("<#{@get("contentag")}>").appendTo @refs.container
el[0].uify undefined
el[0].set "parent", me.get("parent")
el[0].set "root", if me.get("parent") then me.get("parent").get("root") else me
el[0].set "data", item
item.domel = el[0]
$("<li>").appendTo(@refs.container).addClass("afx-corner-fix")
@push item, false
layout: () ->
[{ el: "ul", ref: "container" }]
[{ el: "ul", ref: "wrapper", children: [
{ el: "li", class: "afx-corner-fix" },
{ el: "div", ref: "container" },
{ el: "li", class: "afx-corner-fix" }
] }]
Ant.OS.GUI.define "afx-menu", MenuTag
Ant.OS.GUI.define "afx-menu-entry-proto", MenuEntryTag

View File

@ -28,7 +28,6 @@ class OverlayTag extends Ant.OS.GUI.BaseTag
}
layout: () ->
[{
el: "div", ref: "yield"
}]
@refs.yield = @root
[]
Ant.OS.GUI.define "afx-overlay", OverlayTag

View File

@ -0,0 +1,42 @@
class SystemPanelTag extends Ant.OS.GUI.BaseTag
constructor: (r, o) ->
super r, o
me = @
@setopt "osmenu", { children: [] }
@setopt "appmenu", []
@setopt "systray", []
@root.attachservice = (s) -> me.attachservice s
@root.detachservice = (s) -> me.detachservice s
__osmenu__: (v) ->
@refs.osmenu.set "items", [v]
__appmenu__: (v) ->
@refs.appmenu.set "items", v
__systray__: (v) ->
@refs.systray.set "items", [v]
attachservice: (s) ->
@refs.systray.unshift s
s.attach @refs.systray
detachservice: (s) ->
@refs.systray.remove s
layout: () ->
[{
el: "div", children: [
{ el: "afx-menu", id: "osmenu", ref: "osmenu", class: "afx-panel-os-menu" },
{ el: "afx-menu", id: "appmenu", ref: "appmenu", class: "afx-panel-os-app" },
{ el: "afx-menu", id: "systray", ref: "systray", class: "afx-panel-os-stray" }
]
}]
mount: () ->
$(@refs.osmenu).css("z-index", 1000000)
$(@refs.appmenu).css("z-index", 1000000)
$(@refs.systray).css("z-index", 1000000)
Ant.OS.announcer.trigger("syspanelloaded")
Ant.OS.GUI.define "afx-sys-panel", SystemPanelTag

View File

@ -77,6 +77,7 @@ class Ant.OS.GUI.BaseTag
return undefined unless tag
dom = $("<#{tag.el}>")
$(dom).addClass tag.class if tag.class
$(dom).attr "data-id", tag.id if tag.id
if tag.children
$(@mkui(v)).appendTo(dom) for v in tag.children
if tag.ref
@ -102,7 +103,7 @@ Element.prototype.mount = () ->
Element.prototype.uify = (observable) ->
@mkui(observable)
@sync()
@mount()
Ant.OS.GUI.define = (name, cls) ->
Ant.OS.GUI.tag[name] = cls