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

@ -45,6 +45,8 @@ coffees= src/core/core.coffee \
src/core/tags/ColorPickerTag.coffee \
src/core/tags/FileViewTag.coffee \
src/core/tags/OverlayTag.coffee \
src/core/tags/AppDockTag.coffee \
src/core/tags/SystemPanelTag.coffee \
src/antos.coffee

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
@ -34,10 +37,6 @@ class BaseService extends this.OS.GUI.BaseModel
attach: (h) ->
@holder = h
update: () ->
@holder.update() if @holder
@scheme.update() if @scheme
watch: ( t, f) ->
me = @
func = () ->

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()
__items__: (data) ->
me = @
$(@refs.container).empty()
$("<li>").appendTo(@refs.container).addClass("afx-corner-fix")
for item in data
el = $("<#{@get("contentag")}>").appendTo @refs.container
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", me.get("parent")
el[0].set "root", if me.get("parent") then me.get("parent").get("root") else me
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]
$("<li>").appendTo(@refs.container).addClass("afx-corner-fix")
el[0]
__items__: (data) ->
$(@refs.container).empty()
for item in data
@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

View File

@ -27,7 +27,8 @@ class Calendar extends this.OS.GUI.BaseService
@watch 1000, () ->
now = new Date
me.text = now.toString()
me.update()
me.domel.set "text", me.text
awake: (e) ->
@.openDialog "CalendarDialog", (d) ->

View File

@ -20,7 +20,6 @@ class PushNotification extends this.OS.GUI.BaseService
constructor: (args) ->
super "PushNotification", args
@iconclass = "fa fa-bars"
@onmenuselect = (e) -> console.log e
@cb = undefined
@pending = []
init: ->
@ -45,7 +44,7 @@ class PushNotification extends this.OS.GUI.BaseService
@mfeed = @find "notifeed"
@nzone = @find "notifyzone"
@fzone = @find "feedzone"
(@find "btclear").set "onbtclick", (e) -> me.mlist.set "items", []
(@find "btclear").set "onbtclick", (e) -> me.mlist.set "data", []
#@subscribe "fail", (e) -> console.log e
@subscribe "notification", (o) -> me.pushout 'INFO', o
@subscribe "fail", (o) -> me.pushout 'FAIL', o
@ -64,15 +63,21 @@ class PushNotification extends this.OS.GUI.BaseService
($ @nzone).css "right", 0
.css "top", "-3px"
.css "height", ""
.css "height", "100%"
.css "bottom", "0"
.css "z-index", 1000000
.css "display", "flex"
.css "flex-direction", "column"
.hide()
($ @mlist).css "flex", "1"
($ @fzone)
#.css("z-index", 99999)
.css("bottom", "0")
.css("height", "")
.css("height", "100%")
.css "display", "flex"
.css "flex-direction", "column"
.hide()
($ @mfeed).css "flex", "1"
pushout: (s, o, mfeed) ->
d = {
@ -82,7 +87,7 @@ class PushNotification extends this.OS.GUI.BaseService
closable: true }
#console.log o.data.s
#console.log o.data.e
@mlist.unshift d, true
@mlist.unshift d
@notifeed d
notifeed: (d) ->
@ -90,18 +95,17 @@ class PushNotification extends this.OS.GUI.BaseService
@mfeed.unshift d, true
($ @fzone).show()
timer = setTimeout () ->
me.mfeed.remove d, true
me.mfeed.remove d.domel
clearTimeout timer
, 3000
awake: (e) ->
awake: (evt) ->
if @view then ($ @nzone).hide() else ($ @nzone).show()
@view = not @view
me = @
if not @cb
@cb = (e) ->
return if e.originalEvent.item and e.originalEvent.item.i isnt undefined
if not ($ e.target).closest($ me.nzone).length and not ($ e.target).closest($ me.holder.root).length
if not ($ e.target).closest($ me.nzone).length and not ($ e.target).closest(evt.data.item).length
($ me.nzone).hide()
$(document).unbind "click", me.cb
me.view = not me.view
@ -113,7 +117,7 @@ class PushNotification extends this.OS.GUI.BaseService
cleanup: (evt) ->
# do nothing
PushNotification.scheme = """
<afx-dummy>
<divs>
<afx-overlay data-id = "notifyzone" width = "250">
<afx-button text = "__(Clear all)" data-id = "btclear" ></afx-button>
<afx-list-view data-id="notifylist"></afx-list-view>
@ -122,6 +126,6 @@ PushNotification.scheme = """
<afx-list-view data-id = "notifeed">
</afx-list-view>
</afx-overlay>
</afx-dummy>
</div>
"""
this.OS.register "PushNotification", PushNotification

View File

@ -37,7 +37,7 @@ class SpotlightDialog extends this.OS.GUI.BaseDialog
($ document).keyup @fn
@fn1 = (e) ->
return if $(e.target).closest(me.parent.holder.root).length
return if $(e.target).closest(me.parent.holder).length
if not $(e.target).closest(me.scheme).length
($ document).unbind "click", me.fn1
($ document).unbind "keyup", me.fn
@ -86,11 +86,14 @@ class SpotlightDialog extends this.OS.GUI.BaseDialog
return unless text.length >= 3
result = @_api.search text
return if result.length is 0
@container.set "items", result
@container.set "data", result
console.log result
($ @scheme).css("height", @height)
SpotlightDialog.scheme = """
<afx-app-window data-id = "spotlight-win" apptitle="" minimizable="false" resizable = "false" width="500" height="300">
<afx-app-window data-id = "spotlight-win"
apptitle="" minimizable="false"
resizable = "false" width="500" height="300">
<afx-vbox>
<afx-hbox data-height="45">
<div data-id = "searchicon" data-width="45"></div>
@ -111,13 +114,7 @@ class Spotlight extends this.OS.GUI.BaseService
me = @
@_gui.bindKey "CTRL- ", (e) ->
me.awake(e)
#@child = [
# {
# text: "#{@.name} (#{@.pid}): dummy notif",
# child: [ { text: "submenu" } ]
# }
#]
# do nothing
main: ->
awake: (e) ->

View File

@ -21,21 +21,22 @@ class UserService extends this.OS.GUI.BaseService
super "UserService", args
@text = @systemsetting.user.username
@iconclass = undefined
init: ->
me = @
@child = [
@children = [
{
text: "__(About)", dataid: "user-about",
iconclass: "fa fa-user-circle-o"
},
{
text: "__(Logout)", dataid: "sys-logout",
iconclass: "fa fa-user-times"
iconclass: "fa fa-user-times",
onmenuselect: (d) ->
me.notify __("This feature is not implemented yet")
}
]
@onmenuselect = (d) ->
return window.OS.exit() if d.item.data.dataid is "sys-logout"
me.notify __("This feature is not implemented yet")
init: ->
awake: (e) ->
cleanup: (evt) ->

View File

@ -65,7 +65,7 @@ class ShowCase extends this.OS.GUI.BaseApplication
</afx-vbox>
</afx-hbox>
<afx-hbox tabname="Virtual desktop">
<afx-float-list1 data-id = "flist"/>
<afx-float-list data-id = "flist"/>
</afx-hbox>
<afx-hbox tabname="Calendar">
<afx-calendar-view data-id = "cal"/>

View File

@ -1,11 +1,11 @@
afx-float-list1 div.list-container > ul{
afx-float-list div.list-container > ul{
padding: 0;
margin: 0;
background-color: transparent;
}
afx-float-list1 div.list-container > ul li{
afx-float-list div.list-container > ul li{
padding: 0;
margin: 0;
background-color: transparent;

View File

@ -2,7 +2,7 @@
afx-menu {
position:relative;
display:inline-block;
/*z-index: 100000;*/
z-index: 100000;
}
afx-menu a{
text-decoration: none;
@ -54,15 +54,16 @@ afx-menu ul li /*, afx-menu ul >afx-menu-entry > li*/{
padding:3px;
padding-left: 5px;
padding-right: 5px;
cursor:default;
}
afx-menu ul > li.fix_padding{
afx-menu ul li.fix_padding{
padding-top:1px;
padding-bottom: 0;
padding-left: 5px;
padding-right: 5px;
}
afx-menu afx-menu ul > li.fix_padding{
afx-menu afx-menu ul li.fix_padding{
padding:3px;
padding-left: 5px;
padding-right: 5px;
@ -79,6 +80,7 @@ afx-menu afx-menu i{
afx-menu afx-menu li{
float:none;
min-width: 150px;
cursor:default;
}
afx-menu afx-menu afx-menu, afx-menu ul.context afx-menu{
top:-4px;