mirror of
https://github.com/lxsang/antos-frontend.git
synced 2024-12-27 01:38:21 +01:00
fix
This commit is contained in:
parent
328a37320e
commit
4fda59a964
@ -20,11 +20,11 @@ class Announcer
|
||||
@observable = {}
|
||||
|
||||
on: (evtName, callback) ->
|
||||
@observable[evtName] = { one: [], many: [] } unless @observable[evtName]
|
||||
@observable[evtName] = { one: new Set(), many: new Set() } unless @observable[evtName]
|
||||
@observable[evtName].many.push callback
|
||||
|
||||
one: (evtName, callback) ->
|
||||
@observable[evtName] = { one: [], many: [] } unless @observable[evtName]
|
||||
@observable[evtName] = { one: new Set(), many: new Set() } unless @observable[evtName]
|
||||
@observable[evtName].one.push callback
|
||||
|
||||
off: (evtName, callback) ->
|
||||
@ -53,7 +53,7 @@ class Announcer
|
||||
continue unless me.observable[evt]
|
||||
for f, i in me.observable[evt].one
|
||||
f data
|
||||
me.observable[evt].one = []
|
||||
me.observable[evt].one = new Set()
|
||||
for f, i in me.observable[evt].many
|
||||
f data
|
||||
|
||||
@ -68,7 +68,7 @@ Ant.OS.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] = new Set() 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
|
||||
|
@ -7,6 +7,7 @@ class MenuEntryTag extends Ant.OS.GUI.BaseTag
|
||||
@setopt "children", undefined
|
||||
@setopt "child", undefined
|
||||
@setopt "parent", undefined
|
||||
@setopt "rootid", undefined
|
||||
|
||||
on_data_changed: (data) ->
|
||||
@set k, v for k, v of data
|
||||
@ -110,7 +111,7 @@ class SimpleMenuEntryTag extends MenuEntryTag
|
||||
evt = { id: @aid(), data: e }
|
||||
e.preventDefault()
|
||||
children = @get("children")
|
||||
if @is_root() and @has_children()
|
||||
if @is_root() and @has_children() and not @get "context"
|
||||
$(@refs.submenu).show()
|
||||
else
|
||||
@submenuoff()
|
||||
@ -145,12 +146,32 @@ class MenuTag extends Ant.OS.GUI.BaseTag
|
||||
@setopt "parent", undefined
|
||||
@setopt "contentag", "afx-menu-entry"
|
||||
@setopt "items", []
|
||||
me = @
|
||||
@root.show = (e) ->
|
||||
me.showctxmenu e
|
||||
|
||||
showctxmenu: (e) ->
|
||||
return unless @get "context"
|
||||
#console.log
|
||||
$(@root)
|
||||
.css("top", e.clientY - 15 + "px")
|
||||
.css("left", e.clientX - 5 + "px")
|
||||
.show()
|
||||
|
||||
isctxmenu: () ->
|
||||
return @get "context"
|
||||
|
||||
mount: () ->
|
||||
me = @
|
||||
|
||||
on_context_changed: (v) ->
|
||||
$(@refs.container).removeClass("context")
|
||||
$(@refs.container).addClass("context") if v
|
||||
return unless v
|
||||
$(@refs.container).addClass("context")
|
||||
$(@root).hide()
|
||||
@observable.on "menuselect", (e) ->
|
||||
console.log e.data.item
|
||||
console.log e.data.item.get("rootid")
|
||||
|
||||
on_items_changed: (data) ->
|
||||
me = @
|
||||
@ -161,6 +182,7 @@ class MenuTag extends Ant.OS.GUI.BaseTag
|
||||
el[0].uify @observable
|
||||
el[0].set "data", item
|
||||
el[0].set "parent", me.get("parent")
|
||||
el[0].set "rootid", if me.get("parent") then me.get("parent").get("rootid") else me.aid()
|
||||
item.domel = el[0]
|
||||
$("<li>").appendTo(@refs.container).addClass("afx-corner-fix")
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
<afx-app-window apptitle="Preview" width="650" height="500">
|
||||
<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>
|
||||
|
@ -33,6 +33,7 @@ class ShowCase extends this.OS.GUI.BaseApplication
|
||||
console.log tag
|
||||
###
|
||||
openwin: () ->
|
||||
me = @
|
||||
scheme = $.parseHTML """
|
||||
<afx-app-window apptitle="Preview" width="650" height="500">
|
||||
<afx-vbox>
|
||||
@ -54,7 +55,7 @@ class ShowCase extends this.OS.GUI.BaseApplication
|
||||
</afx-hbox>
|
||||
<afx-resizer data-height="5" />
|
||||
<afx-hbox>
|
||||
<afx-list-view data-id="list" dropdown="true" multiselect="false" />
|
||||
<afx-list-view data-id="list" dropdown="false" multiselect="false" />
|
||||
</afx-hbox>
|
||||
<afx-hbox data-height="150">
|
||||
<div>box center 3</div>
|
||||
@ -63,13 +64,15 @@ class ShowCase extends this.OS.GUI.BaseApplication
|
||||
</afx-vbox>
|
||||
<afx-vbox data-width="150">
|
||||
<div data-height="grow">box 3</div>
|
||||
<div data-height="200">box 4</div>
|
||||
<div data-height="200">box 4
|
||||
</afx-vbox>
|
||||
</afx-hbox>
|
||||
</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]
|
||||
obj = scheme[0].uify()
|
||||
bt = $ "[data-id='bttest']", scheme[0]
|
||||
bt[0].set "onbtclick", (e) ->
|
||||
@ -77,9 +80,9 @@ class ShowCase extends this.OS.GUI.BaseApplication
|
||||
obj.set "resizable", true
|
||||
obj.set "minimizable", false
|
||||
obj.observable.on "exit", () ->
|
||||
console.log "exit"
|
||||
obj.observable.off "*"
|
||||
$(obj).remove()
|
||||
me.quit()
|
||||
|
||||
obj.observable.on "btclick", (e) ->
|
||||
console.log "button clicked"
|
||||
@ -98,6 +101,7 @@ class ShowCase extends this.OS.GUI.BaseApplication
|
||||
list[0].set "onlistselect", (e) ->
|
||||
console.log(e.data.items)
|
||||
|
||||
|
||||
sw = $ "[data-id='switch']", scheme[0]
|
||||
sw[0].set "onchange", (e) ->
|
||||
console.log e.data
|
||||
@ -108,6 +112,11 @@ class ShowCase extends this.OS.GUI.BaseApplication
|
||||
|
||||
menu = $ "[data-id='menu']", scheme[0]
|
||||
menu[0].set "items", @menu()
|
||||
ctmenu = ctmenu[0].uify(obj.observable)
|
||||
ctmenu.set "items", @menu()
|
||||
list[0].contextmenuHandle = (e) ->
|
||||
console.log e
|
||||
ctmenu.show e
|
||||
mnFile:() ->
|
||||
#console.log file
|
||||
me = @
|
||||
|
Loading…
Reference in New Issue
Block a user