mirror of
https://github.com/lxsang/antos-frontend.git
synced 2024-12-26 17:38:20 +01:00
gui
This commit is contained in:
parent
d50d884733
commit
2656c21cdb
10
Makefile
10
Makefile
@ -15,6 +15,7 @@ coffees= src/core/core.coffee\
|
|||||||
src/core/api.coffee\
|
src/core/api.coffee\
|
||||||
src/core/settings.coffee\
|
src/core/settings.coffee\
|
||||||
src/core/handles/RemoteHandle.coffee\
|
src/core/handles/RemoteHandle.coffee\
|
||||||
|
src/core/Announcerment.coffee\
|
||||||
src/core/vfs.coffee\
|
src/core/vfs.coffee\
|
||||||
src/core/vfs/GoogleDriveHandle.coffee\
|
src/core/vfs/GoogleDriveHandle.coffee\
|
||||||
src/core/db.coffee\
|
src/core/db.coffee\
|
||||||
@ -24,12 +25,13 @@ coffees= src/core/core.coffee\
|
|||||||
src/core/BaseService.coffee\
|
src/core/BaseService.coffee\
|
||||||
src/core/BaseEvent.coffee\
|
src/core/BaseEvent.coffee\
|
||||||
src/core/BaseDialog.coffee\
|
src/core/BaseDialog.coffee\
|
||||||
|
src/core/tag.coffee\
|
||||||
src/antos.coffee
|
src/antos.coffee
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
packages = CoreServices ActivityMonitor Setting # Files MarkOn MarketPlace Preview NotePad wTerm
|
packages = CoreServices ActivityMonitor Setting ShowCase # Files MarkOn MarketPlace Preview NotePad wTerm
|
||||||
|
|
||||||
main: initd build_coffees build_tags build_themes schemes libs build_packages languages
|
main: initd build_coffees build_tags build_themes schemes libs build_packages languages
|
||||||
- cp src/index.html $(BUILDDIR)/
|
- cp src/index.html $(BUILDDIR)/
|
||||||
@ -68,7 +70,7 @@ build_tags:
|
|||||||
@echo "$(BLUE)Building tag files$(NC)"
|
@echo "$(BLUE)Building tag files$(NC)"
|
||||||
-mkdir $(BUILDDIR)/resources
|
-mkdir $(BUILDDIR)/resources
|
||||||
-rm $(BUILDDIR)/resources/antos_tags.js
|
-rm $(BUILDDIR)/resources/antos_tags.js
|
||||||
for f in src/core/tags/*; do (cat "$${f}"; echo) >> $(BUILDDIR)/resources/antos_tags.js; done
|
for f in src/core/tags/*.tag; do (cat "$${f}"; echo) >> $(BUILDDIR)/resources/antos_tags.js; done
|
||||||
|
|
||||||
languages:
|
languages:
|
||||||
-mkdir $(BUILDDIR)/resources
|
-mkdir $(BUILDDIR)/resources
|
||||||
@ -104,7 +106,7 @@ package:
|
|||||||
cd src/packages/$$PKG && make;\
|
cd src/packages/$$PKG && make;\
|
||||||
cd ../../../;\
|
cd ../../../;\
|
||||||
test -d $(BUILDDIR)/packages/$$PKG || mkdir -p $(BUILDDIR)/packages/$$PKG;\
|
test -d $(BUILDDIR)/packages/$$PKG || mkdir -p $(BUILDDIR)/packages/$$PKG;\
|
||||||
cp -rf src/packages/$$PKG/build/* $(BUILDDIR)/packages/$$PKG/;\
|
cp -rfv src/packages/$$PKG/build/* $(BUILDDIR)/packages/$$PKG/;\
|
||||||
test -d src/packages/$$PKG/build && rm -r src/packages/$$PKG/build;
|
test -d src/packages/$$PKG/build && rm -r src/packages/$$PKG/build;
|
||||||
|
|
||||||
pkgar:
|
pkgar:
|
||||||
@ -142,4 +144,4 @@ uglify:
|
|||||||
release: main uglify
|
release: main uglify
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf $(BUILDDIR)/*
|
rm -rf $(BUILDDIR)/{resources,scripts,packages,index.html}
|
||||||
|
90
src/core/Announcerment.coffee
Normal file
90
src/core/Announcerment.coffee
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
# Copyright 2017-2018 Xuan Sang LE <xsang.le AT gmail DOT com>
|
||||||
|
|
||||||
|
# AnTOS Web desktop is is licensed under the GNU General Public
|
||||||
|
# License v3.0, see the LICENCE file for more information
|
||||||
|
|
||||||
|
# This program is free software: you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU General Public License as
|
||||||
|
# published by the Free Software Foundation, either version 3 of
|
||||||
|
# the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
# General Public License for more details.
|
||||||
|
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
#along with this program. If not, see https://www.gnu.org/licenses/.
|
||||||
|
class Announcer
|
||||||
|
constructor: () ->
|
||||||
|
@observable = {}
|
||||||
|
|
||||||
|
on: (evtName, callback) ->
|
||||||
|
@observable[evtName] = { one: [], many: [] } unless @observable[evtName]
|
||||||
|
@observable[evtName].many.push callback
|
||||||
|
|
||||||
|
one: (evtName, callback) ->
|
||||||
|
@observable[evtName] = { one: [], many: [] } unless @observable[evtName]
|
||||||
|
@observable[evtName].one.push callback
|
||||||
|
|
||||||
|
off: (evtName, callback) ->
|
||||||
|
me = @
|
||||||
|
fn = (evt, cb) ->
|
||||||
|
return unless me.observable[evt]
|
||||||
|
if cb
|
||||||
|
for f, i in me.observable[evt].one
|
||||||
|
if f == cb
|
||||||
|
me.observable[evt].one.splice i, 1
|
||||||
|
break
|
||||||
|
|
||||||
|
for f, i in me.observable[evt].many
|
||||||
|
if f == cb
|
||||||
|
me.observable[evt].many.splice i, 1
|
||||||
|
break
|
||||||
|
else
|
||||||
|
delete me.observable[evt] if me.observable[evt]
|
||||||
|
if evtName is "*" then fn k, callback for k, v of me.observable else fn evtName, callback
|
||||||
|
|
||||||
|
trigger: (evtName, data) ->
|
||||||
|
me = @
|
||||||
|
trig = (name, d) ->
|
||||||
|
names = [name, "*"]
|
||||||
|
for evt in names
|
||||||
|
continue unless me.observable[evt]
|
||||||
|
for f, i in me.observable[evt].one
|
||||||
|
f data
|
||||||
|
me.observable[evt].one = []
|
||||||
|
for f, i in me.observable[evt].many
|
||||||
|
f data
|
||||||
|
|
||||||
|
if evtName is "*"
|
||||||
|
trig k, data for k, v of me.observable when k isnt "*"
|
||||||
|
else
|
||||||
|
trig evtName, data
|
||||||
|
|
||||||
|
Ant.OS.API.Announcer = Announcer
|
||||||
|
Ant.OS.announcer =
|
||||||
|
observable: new Ant.OS.API.Announcer()
|
||||||
|
quota: 0
|
||||||
|
listeners: {}
|
||||||
|
on: (e, f, a) ->
|
||||||
|
Ant.OS.announcer.listeners[a.pid] = [] unless Ant.OS.announcer.listeners[a.pid]
|
||||||
|
Ant.OS.announcer.listeners[a.pid].push { e: e, f: f }
|
||||||
|
Ant.OS.announcer.observable.on e, f
|
||||||
|
trigger: (e, d) -> Ant.OS.announcer.observable.trigger e, d
|
||||||
|
osfail: (m, e, s) ->
|
||||||
|
Ant.OS.announcer.ostrigger "fail", { m: m, e: e, s: s }
|
||||||
|
oserror: (m, e, s) ->
|
||||||
|
Ant.OS.announcer.ostrigger "error", { m: m, e: e, s: s }
|
||||||
|
osinfo: (m) ->
|
||||||
|
Ant.OS.announcer.ostrigger "info", { m: m, e: null, s: null }
|
||||||
|
ostrigger: (e, d) ->
|
||||||
|
Ant.OS.announcer.trigger e, { id: 0, data: d, name: "OS" }
|
||||||
|
unregister: (app) ->
|
||||||
|
return unless Ant.OS.announcer.listeners[app.pid] and Ant.OS.announcer.listeners[app.pid].length > 0
|
||||||
|
Ant.OS.announcer.observable.off i.e, i.f for i in Ant.OS.announcer.listeners[app.pid]
|
||||||
|
delete Ant.OS.announcer.listeners[app.pid]
|
||||||
|
# Ant.OS.announcer.listeners[app.pid]
|
||||||
|
getMID: () ->
|
||||||
|
Ant.OS.announcer.quota += 1
|
||||||
|
Ant.OS.announcer.quota
|
@ -31,31 +31,6 @@ Ant.OS or=
|
|||||||
appearance: {}
|
appearance: {}
|
||||||
VFS: {}
|
VFS: {}
|
||||||
system: {}
|
system: {}
|
||||||
announcer:
|
|
||||||
observable: riot.observable()
|
|
||||||
quota: 0
|
|
||||||
listeners: {}
|
|
||||||
on: (e, f, a) ->
|
|
||||||
Ant.OS.announcer.listeners[a.pid] = [] unless Ant.OS.announcer.listeners[a.pid]
|
|
||||||
Ant.OS.announcer.listeners[a.pid].push { e: e, f: f }
|
|
||||||
Ant.OS.announcer.observable.on e, f
|
|
||||||
trigger: (e, d) -> Ant.OS.announcer.observable.trigger e, d
|
|
||||||
osfail: (m, e, s) ->
|
|
||||||
Ant.OS.announcer.ostrigger "fail", { m: m, e: e, s: s }
|
|
||||||
oserror: (m, e, s) ->
|
|
||||||
Ant.OS.announcer.ostrigger "error", { m: m, e: e, s: s }
|
|
||||||
osinfo: (m) ->
|
|
||||||
Ant.OS.announcer.ostrigger "info", { m: m, e: null, s: null }
|
|
||||||
ostrigger: (e, d) ->
|
|
||||||
Ant.OS.announcer.trigger e, { id: 0, data: d, name: "OS" }
|
|
||||||
unregister: (app) ->
|
|
||||||
return unless Ant.OS.announcer.listeners[app.pid] and Ant.OS.announcer.listeners[app.pid].length > 0
|
|
||||||
Ant.OS.announcer.observable.off i.e, i.f for i in Ant.OS.announcer.listeners[app.pid]
|
|
||||||
delete Ant.OS.announcer.listeners[app.pid]
|
|
||||||
# Ant.OS.announcer.listeners[app.pid]
|
|
||||||
getMID: () ->
|
|
||||||
Ant.OS.announcer.quota += 1
|
|
||||||
Ant.OS.announcer.quota
|
|
||||||
register: (name, x) ->
|
register: (name, x) ->
|
||||||
if x.type is 3 then Ant.OS.GUI.subwindows[name] = x else Ant.OS.APP[name] = x
|
if x.type is 3 then Ant.OS.GUI.subwindows[name] = x else Ant.OS.APP[name] = x
|
||||||
|
|
||||||
|
9
src/core/tags/tag.coffee
Normal file
9
src/core/tags/tag.coffee
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
Ant.OS.GUI.tag = {}
|
||||||
|
|
||||||
|
Element.prototype.mount = () ->
|
||||||
|
Ant.OS.GUI.tag[@tagName](@) if RegExp('afx-*').test(@tagName) and Ant.OS.GUI.tag[@tagName]
|
||||||
|
|
||||||
|
Ant.OS.GUI.tag.define = (name, fn) ->
|
||||||
|
Ant.OS.GUI.tag[name] = fn
|
||||||
|
|
||||||
|
Ant.OS.GUI.tag.mount = (obj) ->
|
8
src/core/tags/window-tag.coffee
Normal file
8
src/core/tags/window-tag.coffee
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
|
||||||
|
Ant.OS.GUI.tag.define "afx-window", (tag) ->
|
||||||
|
childen = $(tag).childen()
|
||||||
|
@(tag).empty()
|
||||||
|
$(tag).append(
|
||||||
|
$("<div>")
|
||||||
|
.addClass("afx-window-wrapper")
|
||||||
|
.append())
|
11
src/packages/ShowCase/Makefile
Normal file
11
src/packages/ShowCase/Makefile
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
coffee_files = coffees/main.coffee
|
||||||
|
|
||||||
|
jsfiles =
|
||||||
|
|
||||||
|
cssfiles =
|
||||||
|
|
||||||
|
copyfiles = assets/scheme.html package.json
|
||||||
|
|
||||||
|
|
||||||
|
PKG_NAME=ShowCase
|
||||||
|
include ../pkg.mk
|
5
src/packages/ShowCase/assets/scheme.html
Normal file
5
src/packages/ShowCase/assets/scheme.html
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<afx-app-window apptitle="Preview" width="650" height="500">
|
||||||
|
<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>
|
36
src/packages/ShowCase/coffees/main.coffee
Normal file
36
src/packages/ShowCase/coffees/main.coffee
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
Ant = this
|
||||||
|
class ShowCase extends this.OS.GUI.BaseApplication
|
||||||
|
constructor: (args) ->
|
||||||
|
super "ShowCase", args
|
||||||
|
|
||||||
|
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.announcer.trigger("evt1", "Hello 1")
|
||||||
|
me.announcer.off("*")
|
||||||
|
me.announcer.trigger("evt2", "Hello 2")
|
||||||
|
console.log me.announcer
|
||||||
|
me.notify "Hello"
|
||||||
|
tag = new Ant.OS.GUI.tags["afx-window"]()
|
||||||
|
console.log tag
|
||||||
|
|
||||||
|
|
||||||
|
ShowCase.singleton = false
|
||||||
|
this.OS.register "ShowCase", ShowCase
|
13
src/packages/ShowCase/package.json
Normal file
13
src/packages/ShowCase/package.json
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"app":"ShowCase",
|
||||||
|
"name": "ShowCase",
|
||||||
|
"description":"AntOS 1.1.0a features showcase",
|
||||||
|
"info":{
|
||||||
|
"author": "Xuan Sang LE",
|
||||||
|
"email": "xsang.le@gmail.com",
|
||||||
|
"licences": "GPLv3"
|
||||||
|
},
|
||||||
|
"version":"0.0.1-a",
|
||||||
|
"category":"Other",
|
||||||
|
"mimes":["none"]
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user