use fat arrow for this reference

This commit is contained in:
Xuan Sang LE 2020-05-17 17:05:12 +02:00
parent 95cfddb389
commit fa22fc5413
41 changed files with 1086 additions and 1072 deletions

View File

@ -35,30 +35,28 @@ class Announcer
@observable[evtName].one.add callback
off: (evtName, callback) ->
me = @
fn = (evt, cb) ->
return unless me.observable[evt]
fn = (evt, cb) =>
return unless @observable[evt]
if cb
me.observable[evt].one.delete(cb)
me.observable[evt].many.delete(cb)
@observable[evt].one.delete(cb)
@observable[evt].many.delete(cb)
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
delete @observable[evt] if @observable[evt]
if evtName is "*" then fn k, callback for k, v of @observable else fn evtName, callback
trigger: (evtName, data) ->
me = @
trig = (name, d) ->
trig = (name, d) =>
names = [name, "*"]
for evt in names
continue unless me.observable[evt]
me.observable[evt].one.forEach (f) ->
continue unless @observable[evt]
@observable[evt].one.forEach (f) ->
f d
me.observable[evt].one = new Set()
me.observable[evt].many.forEach (f) ->
@observable[evt].one = new Set()
@observable[evt].many.forEach (f) ->
f d
if evtName is "*"
trig k, data for k, v of me.observable when k isnt "*"
trig k, data for k, v of @observable when k isnt "*"
else
trig evtName, data

View File

@ -26,28 +26,26 @@ class BaseApplication extends this.OS.GUI.BaseModel
CTRL: {}
SHIFT: {}
META: {}
me = @
init: ->
me = @
@off "*"
@on "exit", () -> me.quit()
@on "exit", () => @quit()
# first register some base event to the app
@on "focus", () ->
me.sysdock.set "selectedApp", me
me.appmenu.pid = me.pid
me.appmenu.set "items", (me.baseMenu() || [])
me.appmenu.set "onmenuselect", (d) ->
me.trigger("menuselect", d)
me.dialog.show() if me.dialog
@on "hide", () ->
me.sysdock.set "selectedApp", null
me.appmenu.set "items", []
me.dialog.hide() if me.dialog
@on "menuselect", (d) ->
@on "focus", () =>
@sysdock.set "selectedApp", @
@appmenu.pid = @pid
@appmenu.set "items", (@baseMenu() || [])
@appmenu.set "onmenuselect", (d) =>
@trigger("menuselect", d)
@dialog.show() if @dialog
@on "hide", () =>
@sysdock.set "selectedApp", null
@appmenu.set "items", []
@dialog.hide() if @dialog
@on "menuselect", (d) =>
switch d.data.item.get("data").dataid
when "#{me.name}-about" then me.openDialog "AboutDialog", ()->
when "#{me.name}-exit" then me.trigger "exit"
@on "apptitlechange", () -> me.sysdock.update()
when "#{@name}-about" then @openDialog "AboutDialog"
when "#{@name}-exit" then @trigger "exit"
@on "apptitlechange", () => @sysdock.update()
@loadScheme()
loadScheme: () ->

View File

@ -74,16 +74,15 @@ class PromptDialog extends BasicDialog
init: () ->
super.init()
me = @
@find("lbl").set "text", @data.label if @data and @data.label
$(@find "txtInput").val @data.value if @data and @data.value
(@find "btnOk").set "onbtclick", (e) ->
me.handle($(me.find "txtInput").val()) if me.handle
me.quit()
(@find "btnOk").set "onbtclick", (e) =>
@handle($(@find "txtInput").val()) if @handle
@quit()
(@find "btnCancel").set "onbtclick", (e) ->
me.quit()
(@find "btnCancel").set "onbtclick", (e) =>
@quit()
PromptDialog.scheme = """
@ -115,15 +114,14 @@ class CalendarDialog extends BasicDialog
init: () ->
super.init()
me = @
(@find "btnOk").set "onbtclick", (e) ->
date = (me.find "cal").get "selectedDate"
return me.notify __("Please select a day") unless date
me.handle(date) if me.handle
me.quit()
(@find "btnOk").set "onbtclick", (e) =>
date = (@find "cal").get "selectedDate"
return @notify __("Please select a day") unless date
@handle(date) if @handle
@quit()
(@find "btnCancel").set "onbtclick", (e) ->
me.quit()
(@find "btnCancel").set "onbtclick", (e) =>
@quit()
CalendarDialog.scheme = """
<afx-app-window width='300' height='230' apptitle = "Calendar" >
@ -155,15 +153,14 @@ class ColorPickerDialog extends BasicDialog
init: () ->
super.init()
me = @
(@find "btnOk").set "onbtclick", (e) ->
color = (me.find "cpicker").get "selectedColor"
return me.notify __("Please select color") unless color
me.handle(color) if me.handle
me.quit()
(@find "btnOk").set "onbtclick", (e) =>
color = (@find "cpicker").get "selectedColor"
return @notify __("Please select color") unless color
@handle(color) if @handle
@quit()
(@find "btnCancel").set "onbtclick", (e) ->
me.quit()
(@find "btnCancel").set "onbtclick", (e) =>
@quit()
ColorPickerDialog.scheme = """
<afx-app-window width='320' height='250' apptitle = "Color picker" >
@ -195,14 +192,13 @@ class InfoDialog extends BasicDialog
init: () ->
super.init()
me = @
rows = []
delete @data.title if @data and @data.title
rows.push [ { text: k }, { text: v } ] for k, v of @data
(@find "grid").set "header", [ { text: __("Name"), width: 70 }, { text: __("Value") } ]
(@find "grid").set "rows", rows
(@find "btnCancel").set "onbtclick", (e) ->
me.quit()
(@find "btnCancel").set "onbtclick", (e) =>
@quit()
InfoDialog.scheme = """
<afx-app-window width='250' height='300' apptitle = "Info" >
@ -234,14 +230,13 @@ class YesNoDialog extends BasicDialog
init: () ->
super.init()
me = @
@find("lbl").set "*", @data if @data
(@find "btnYes").set "onbtclick", (e) ->
me.handle(true) if me.handle
me.quit()
(@find "btnNo").set "onbtclick", (e) ->
me.handle(false) if me.handle
me.quit()
(@find "btnYes").set "onbtclick", (e) =>
@handle(true) if @handle
@quit()
(@find "btnNo").set "onbtclick", (e) =>
@handle(false) if @handle
@quit()
YesNoDialog.scheme = """
<afx-app-window width='200' height='150' apptitle = "Prompt">
@ -271,18 +266,17 @@ class SelectionDialog extends BasicDialog
init: () ->
super.init()
me = @
(@find "list").set "data", @data.data if @data and @data.data
fn = (e) ->
data = (me.find "list").get "selectedItem"
return me.notify __("Please select an item") unless data
me.handle(data.get("data")) if me.handle
me.quit()
fn = (e) =>
data = (@find "list").get "selectedItem"
return @notify __("Please select an item") unless data
@handle(data.get("data")) if @handle
@quit()
(@find "list").set "onlistdbclick", fn
(@find "btnOk").set "onbtclick", fn
(@find "btnCancel").set "onbtclick", (e) ->
me.quit()
(@find "btnCancel").set "onbtclick", (e) =>
@quit()
SelectionDialog.scheme = """
<afx-app-window width='250' height='300' apptitle = "Selection">
@ -312,7 +306,6 @@ class AboutDialog extends BasicDialog
init: () ->
mt = @meta()
me = @
@scheme.set "apptitle", __("About: {0}", mt.name)
(@find "mylabel").set "*", {
icon: mt.icon,
@ -326,8 +319,8 @@ class AboutDialog extends BasicDialog
rows.push [ { text: k }, { text: v } ] for k, v of mt.info
(@find "mygrid").set "header", [ { text: "", width: 100 }, { text: "" } ]
(@find "mygrid").set "rows", rows
(@find "btnCancel").set "onbtclick", (e) ->
me.quit()
(@find "btnCancel").set "onbtclick", (e) =>
@quit()
AboutDialog.scheme = """
<afx-app-window data-id = 'about-window' width='300' height='200'>
@ -338,7 +331,11 @@ AboutDialog.scheme = """
</h3>
<i><p style = "margin:0; padding:0" data-id = 'mydesc'></p></i>
</div>
<afx-grid-view data-id = 'mygrid'></afx-grid-view>
<afx-hbox>
<div data-width="10"></div>
<afx-grid-view data-id = 'mygrid'></afx-grid-view>
</afx-hbox>
<afx-hbox data-height="30">
<div />
<afx-button data-id = "btnCancel" text = "__(Cancel)" data-width = "60" />
@ -358,7 +355,6 @@ class FileDialog extends BasicDialog
fileview = @find "fileview"
location = @find "location"
filename = @find "filename"
me = @
fileview.set "fetch", (path) ->
new Promise (resolve, reject) ->
return resolve() unless path
@ -367,10 +363,10 @@ class FileDialog extends BasicDialog
return reject d if d.error
resolve d.result
.catch (e) -> reject e
setroot = (path) ->
path.asFileHandle().read().then (d) ->
setroot = (path) =>
path.asFileHandle().read().then (d) =>
if(d.error)
return me.error __("Resource not found: {0}", path)
return @error __("Resource not found: {0}", path)
fileview.set "path", path
if not @data or not @data.root
@ -385,27 +381,27 @@ class FileDialog extends BasicDialog
setroot @data.root
fileview.set "onfileselect", (e) ->
($ filename).val e.data.filename if e.data.type is "file"
(@find "bt-ok").set "onbtclick", (e) ->
(@find "bt-ok").set "onbtclick", (e) =>
f = fileview.get "selectedFile"
return me.notify __("Please select a file/fofler") unless f
if me.data and me.data.type and me.data.type isnt f.type
return me.notify __("Please select {0} only", me.data.type)
if me.data and me.data.mimes
return @notify __("Please select a file/fofler") unless f
if @data and @data.type and @data.type isnt f.type
return @notify __("Please select {0} only", @data.type)
if @data and @data.mimes
#verify the mime
m = false
if f.mime
for v in me.data.mimes
for v in @data.mimes
if f.mime.match (new RegExp v, "g")
m = true
break
return me.notify __("Only {0} could be selected", me.data.mimes.join(",")) unless m
return @notify __("Only {0} could be selected", @data.mimes.join(",")) unless m
name = $(filename).val()
me.handle { file: f, name: name } if me.handle
me.quit()
@handle { file: f, name: name } if @handle
@quit()
(@find "bt-cancel").set "onbtclick", (e) ->
me.quit()
(@find "bt-cancel").set "onbtclick", (e) =>
@quit()
if @data and @data.file
($ filename).css("display", "block").val @data.file.basename or "Untitled"
@trigger "resize"

View File

@ -18,13 +18,11 @@
class BaseModel
constructor: (@name, @args) ->
me = @
@observable = new Announcer()
@_api = Ant.OS.API
@_gui = Ant.OS.GUI
@systemsetting = Ant.OS.setting
me = @
@on "exit", () -> me.quit()
@on "exit", () => @quit()
@host = @_gui.workspace
@dialog = undefined
render: (p) ->
@ -68,26 +66,25 @@ class BaseModel
Ant.OS.announcer.on e, f, @
openDialog: (d, data) ->
me = @
new Promise (resolve, reject) ->
if me.dialog
me.dialog.show()
new Promise (resolve, reject) =>
if @dialog
@dialog.show()
return
if typeof d is "string"
if not Ant.OS.GUI.subwindows[d]
me.error __("Dialog {0} not found", d)
@error __("Dialog {0} not found", d)
return
me.dialog = new Ant.OS.GUI.subwindows[d]()
@dialog = new Ant.OS.GUI.subwindows[d]()
else
me.dialog = d
@dialog = d
#@dialog.observable = riot.observable() unless @dialog
me.dialog.parent = me
me.dialog.handle = resolve
me.dialog.reject = reject
me.dialog.pid = me.pid
me.dialog.data = data
me.dialog.title = data.title if data and data.title
me.dialog.init()
@dialog.parent = @
@dialog.handle = resolve
@dialog.reject = reject
@dialog.pid = @pid
@dialog.data = data
@dialog.title = data.title if data and data.title
@dialog.init()
ask: (t, m, f) ->
@._gui.openDialog "YesNoDialog", (d) ->

View File

@ -24,9 +24,8 @@ class BaseService extends this.OS.GUI.BaseModel
@text = ""
@timer = undefined
@holder = undefined
me = @
@onmenuselect = (d) ->
me.awake d
@onmenuselect = (d) =>
@awake d
init: ()->
#implement by user
@ -42,10 +41,9 @@ class BaseService extends this.OS.GUI.BaseModel
@holder = h
watch: ( t, f) ->
me = @
func = () ->
func = () =>
f()
me.timer = setTimeout (() -> func()), t
@timer = setTimeout (() -> func()), t
func()
onexit: (evt) ->
console.log "clean timer" if @timer

View File

@ -23,9 +23,8 @@ class FormatedString
toString: () ->
@__()
__: () ->
me = @
return @fs.l().replace /{(\d+)}/g, (match, number) ->
return if typeof me.values[number] != 'undefined' then me.values[number].__() else match
return @fs.l().replace /{(\d+)}/g, (match, number) =>
return if typeof @values[number] != 'undefined' then @values[number].__() else match
hash: () ->
@__().hash()
@ -321,7 +320,7 @@ Ant.OS.API =
.catch (e) ->
reject e
else
reject e
reject Ant.OS.API.throwe __("Invalid library: {0}", l)
else
console.log l, "Library exist, no need to load"
Ant.OS.announcer.trigger "sharedlibraryloaded", l

View File

@ -4,9 +4,8 @@ class AppDockTag extends Ant.OS.GUI.BaseTag
@setopt "onappselect", (e) ->
@setopt "items", []
@setopt "selectedApp", undefined
me = @
@root.newapp = (a) -> me.addApp a
@root.removeapp = (a) -> me.removeApp a
@root.newapp = (a) => @addApp a
@root.removeapp = (a) => @removeApp a
__selectedApp__: (v) ->
el = undefined
@ -26,9 +25,8 @@ class AppDockTag extends Ant.OS.GUI.BaseTag
el[0].set "*", item
el.attr "tooltip", "cr:#{item.app.title()}"
item.domel = el[0]
me = @
el[0].set "onbtclick", (e) ->
e.id = me.aid()
el[0].set "onbtclick", (e) =>
e.id = @aid()
e.data.app = item
item.app.show()
@set "selectedApp", item.app
@ -47,9 +45,8 @@ class AppDockTag extends Ant.OS.GUI.BaseTag
$($(@root).children()[i]).remove()
mount: () ->
me = @
@root.contextmenuHandle = (e, m) ->
return if e.target is me.root
@root.contextmenuHandle = (e, m) =>
return if e.target is @root
bt = $(e.target).closest "afx-button"
app = bt[0].get "app"
m.set "items", [

View File

@ -31,12 +31,11 @@ class ButtonTag extends Ant.OS.GUI.BaseTag
$(@button).addClass "selected" if v
mount: () ->
me = @
@root.trigger = () ->
($me.refs.button).trigger "click"
@root.trigger = () =>
$(@refs.button).trigger "click"
$(@refs.button).click (e) ->
me.btclickhd e
$(@refs.button).click (e) =>
@btclickhd e
btclickhd: (e) ->
hd = @get "onbtclick"

View File

@ -9,11 +9,10 @@ class CalendarTag extends Ant.OS.GUI.BaseTag
@year = 0
mount: () ->
me = @
$(@root).css "height", "100%"
$(@refs.grid).css "width", "100%"
$(@refs.prev).click (e) -> me.prevmonth()
$(@refs.next).click (e) -> me.nextmonth()
$(@refs.prev).click (e) => @prevmonth()
$(@refs.next).click (e) => @nextmonth()
@refs.grid.set "header", [
{ text: "__(Sun)" },
{ text: "__(Mon)" },
@ -23,10 +22,10 @@ class CalendarTag extends Ant.OS.GUI.BaseTag
{ text: "__(Fri)" },
{ text: "__(Sat)" }
]
@refs.grid.set "oncellselect", (e) ->
me.dateselect(e)
@refs.grid.set "oncellselect", (e) =>
@dateselect(e)
@observable.on "resize", (e) -> me.calibrate()
@observable.on "resize", (e) => @calibrate()
@calibrate()
@calendar null

View File

@ -34,7 +34,6 @@ class ColorPickerTag extends Ant.OS.GUI.BaseTag
@build_palette()
build_palette: () ->
me = @
colorctx = $(@refs.palette).get(0).getContext('2d')
gradient = colorctx.createLinearGradient(0, 0, $(@refs.palette).width(), 0)
# fill color
@ -65,9 +64,9 @@ class ColorPickerTag extends Ant.OS.GUI.BaseTag
s = "0" + s if s.length is 1
s
pick_color = (e) ->
$(me.refs.palette).css("cursor", "crosshair")
offset = $(me.refs.palette).offset()
pick_color = (e) =>
$(@refs.palette).css("cursor", "crosshair")
offset = $(@refs.palette).offset()
x = e.pageX - offset.left
y = e.pageY - offset.top
color = colorctx.getImageData(x, y, 1, 1)
@ -80,26 +79,26 @@ class ColorPickerTag extends Ant.OS.GUI.BaseTag
}
data
mouse_move_h = (e) ->
mouse_move_h = (e) =>
data = pick_color(e)
$(me.refs.colorval).css("background-color", data.text)
$(@refs.colorval).css("background-color", data.text)
$(me.refs.palette).mouseenter (e) ->
$(me.refs.palette).on("mousemove", mouse_move_h)
$(@refs.palette).mouseenter (e) =>
$(@refs.palette).on("mousemove", mouse_move_h)
$(me.refs.palette).mouseout (e) ->
$(me.refs.palette).unbind("mousemove", mouse_move_h)
if me.get "selectedColor"
$(me.refs.colorval).css("background-color", me.get("selectedColor").text)
$(@refs.palette).mouseout (e) =>
$(@refs.palette).unbind("mousemove", mouse_move_h)
if @get "selectedColor"
$(@refs.colorval).css("background-color", @get("selectedColor").text)
$(@refs.palette).on "click", (e) ->
$(@refs.palette).on "click", (e) =>
data = pick_color(e)
$(me.refs.rgbtext).html(data.text)
$(me.refs.hextext).val(data.hex)
me.set "selectedColor", data
evt = { id: me.aid(), data: data }
me.get("oncolorselect") evt
me.observable.trigger "colorselect", data
$(@refs.rgbtext).html(data.text)
$(@refs.hextext).val(data.hex)
@set "selectedColor", data
evt = { id: @aid(), data: data }
@get("oncolorselect") evt
@observable.trigger "colorselect", data
layout: () ->
[{

View File

@ -33,13 +33,12 @@ class FileViewTag extends Ant.OS.GUI.BaseTag
__path__: (v) ->
return unless v
me = @
return unless @get "fetch"
@get("fetch")(v)
.then (data) ->
.then (data) =>
return unless data
me.set "data", data
me.refs.status.set("text", " ") if me.get "status"
@set "data", data
@refs.status.set("text", " ") if @get "status"
.catch (e) ->
# this should be handled by the OS
Ant.OS.announcer.oserror e
@ -69,9 +68,8 @@ class FileViewTag extends Ant.OS.GUI.BaseTag
refreshList: () ->
items = []
me = @
$.each @get("data"), (i, v) ->
return if v.filename[0] is '.' and not me.get("showhidden")
$.each @get("data"), (i, v) =>
return if v.filename[0] is '.' and not @get("showhidden")
v.text = v.filename
v.text = v.text.substring(0, 9) + "..." if v.text.length > 10
v.iconclass = if v.iconclass then v.iconclass else v.type
@ -81,9 +79,8 @@ class FileViewTag extends Ant.OS.GUI.BaseTag
refreshGrid: () ->
rows = []
me = @
$.each @get("data"), (i, v) ->
return if v.filename[0] is '.' and not me.get("showhidden")
$.each @get("data"), (i, v) =>
return if v.filename[0] is '.' and not @get("showhidden")
v.text = v.filename
v.iconclass = if v.iconclass then v.iconclass else v.type
row = [
@ -112,8 +109,8 @@ class FileViewTag extends Ant.OS.GUI.BaseTag
getTreeData: (data) ->
nodes = []
me = @
$.each data, (i, v) ->
return if v.filename[0] is '.' and not me.get("showhidden")
$.each data, (i, v) =>
return if v.filename[0] is '.' and not @get("showhidden")
v.name = v.filename
if v.type is 'dir'
v.nodes = []
@ -176,30 +173,29 @@ class FileViewTag extends Ant.OS.GUI.BaseTag
@observable.trigger "fileopen", evt
mount: () ->
me = @
@observable.on "resize", (e) -> me.calibrate()
@refs.treeview.set "fetch", (v) ->
new Promise (resolve, reject) ->
return resolve undefined unless me.get("fetch")
@observable.on "resize", (e) => @calibrate()
@refs.treeview.set "fetch", (v) =>
new Promise (resolve, reject) =>
return resolve undefined unless @get("fetch")
return resolve undefined unless v.get("data").path
me.get("fetch")(v.get("data").path)
.then (d) -> resolve me.getTreeData(d.sort me.sortByType)
@get("fetch")(v.get("data").path)
.then (d) => resolve @getTreeData(d.sort @sortByType)
.catch (e) -> reject e
@refs.gridview.set "header", @header
# even handles
@refs.listview.set "onlistselect", (e) ->
me.fileselect e.data.item.get("data")
@refs.gridview.set "onrowselect", (e) ->
me.fileselect $(e.data.item).children()[0].get("data")
@refs.treeview.set "ontreeselect", (e) ->
me.fileselect e.data.item.get("data")
@refs.listview.set "onlistselect", (e) =>
@fileselect e.data.item.get("data")
@refs.gridview.set "onrowselect", (e) =>
@fileselect $(e.data.item).children()[0].get("data")
@refs.treeview.set "ontreeselect", (e) =>
@fileselect e.data.item.get("data")
# dblclick
@refs.listview.set "onlistdbclick", (e) ->
me.filedbclick e.data.item.get("data")
@refs.gridview.set "oncelldbclick", (e) ->
me.filedbclick e.data.item.get("data")
@refs.treeview.set "ontreedbclick", (e) ->
me.filedbclick e.data.item.get("data")
@refs.listview.set "onlistdbclick", (e) =>
@filedbclick e.data.item.get("data")
@refs.gridview.set "oncelldbclick", (e) =>
@filedbclick e.data.item.get("data")
@refs.treeview.set "ontreedbclick", (e) =>
@filedbclick e.data.item.get("data")
@switchView()
layout: () ->

View File

@ -1,12 +1,12 @@
class FloatListTag extends ListViewTag
constructor: (r, o) ->
super r, o
me = @
@setopt "dir", "horizontal"
@root.refresh = () -> me.calibrate()
@root.push = (e) -> me.refs.mlist.push(e)
@root.unshift = (e) -> me.refs.mlist.unshift(e)
@root.remove = (e) -> me.refs.mlist.remove(e)
@root.refresh = () => @calibrate()
@root.push = (e) => @refs.mlist.push(e)
@root.unshift = (e) => @refs.mlist.unshift(e)
@root.remove = (e) => @refs.mlist.remove(e)
# disable some uneccessary functions
__dropdown__: (v) -> @set "dropdown", false if v
@ -20,7 +20,6 @@ class FloatListTag extends ListViewTag
@calibrate()
mount: () ->
me = @
$(@refs.container)
.css "width", "100%"
.css "height", "100%"
@ -28,7 +27,7 @@ class FloatListTag extends ListViewTag
.css "position", "absolute"
.css "display", "block"
.css "width", "100%"
@observable.on "resize", (e) -> me.calibrate()
@observable.on "resize", (e) => @calibrate()
@root.ready(@root) if @root.ready
push: (v) ->
@ -37,14 +36,13 @@ class FloatListTag extends ListViewTag
el
enable_drag: (el) ->
me = @
$(el)
.css "user-select", "none"
.css "cursor", "default"
.css "display", "block"
.css "position", "absolute"
.on "mousedown", (evt) ->
globalof = $(me.refs.mlist).offset()
.on "mousedown", (evt) =>
globalof = $(@refs.mlist).offset()
evt.preventDefault()
offset = $(el).offset()
offset.top = evt.clientY - offset.top
@ -71,14 +69,14 @@ class FloatListTag extends ListViewTag
.css "height", "#{$(@refs.container).height()}px"
gw = $(@refs.mlist).width()
gh = $(@refs.mlist).height()
me = @
$(@refs.mlist).children().each (e) ->
$(@)
$(@refs.mlist).children().each (i, e) =>
$(e)
.css "top", "#{ctop}px"
.css "left", "#{cleft}px"
w = $(@).width()
h = $(@).height()
if me.get("dir") is "vertical"
w = $(e).width()
h = $(e).height()
if @get("dir") is "vertical"
ctop += h + 20
if ctop > gh
ctop = 20

View File

@ -26,12 +26,11 @@ class GridCellPrototype extends Ant.OS.GUI.BaseTag
@set "data", @get("data")
mount: () ->
me = @
$(@root).css "display", "block"
$(@root).click (e) ->
me.cellseleck e, false
$(@root).dblclick (e) ->
me.cellseleck e, true
$(@root).click (e) =>
@cellseleck e, false
$(@root).dblclick (e) =>
@cellseleck e, true
cellseleck: (e, flag) ->
@ -73,10 +72,9 @@ class GridViewTag extends Ant.OS.GUI.BaseTag
@setopt "onrowselect", (e) ->
@setopt "oncelldbclick", (e) ->
@setopt "multiselect", false
me = @
@root.push = (r) -> me.push r, false
@root.unshift = (r) -> me.unshift r
@root.remove = (r) -> me.remove r
@root.push = (r) => @push r, false
@root.unshift = (r) => @unshift r
@root.remove = (r) => @remove r
__header__: (v) ->
return $(@refs.header).hide() if not v or v.length is 0
@ -89,7 +87,6 @@ class GridViewTag extends Ant.OS.GUI.BaseTag
@calibrate()
__rows__: (rows) ->
me = @
$(@refs.grid).empty()
for row in rows
@push row, false
@ -108,7 +105,6 @@ class GridViewTag extends Ant.OS.GUI.BaseTag
push: (row, flag) ->
me = @
rowel = $("<afx-grid-row>")
.css "display", "contents"
rowel[0].uify undefined
@ -119,8 +115,8 @@ class GridViewTag extends Ant.OS.GUI.BaseTag
el = $("<#{@get("cellitem")}>").appendTo rowel
cell.domel = el[0]
el[0].uify undefined
el[0].set "oncellselect", (e) -> me.cellselect e, false
el[0].set "oncelldbclick", (e) -> me.cellselect e, true
el[0].set "oncellselect", (e) => @cellselect e, false
el[0].set "oncelldbclick", (e) => @cellselect e, true
el[0].set "data", cell
if flag
$(@refs.grid).prepend rowel[0]
@ -208,13 +204,12 @@ class GridViewTag extends Ant.OS.GUI.BaseTag
$(@refs.header).css "grid-template-columns", template
mount: () ->
me = @
$(@root)
.css "overflow", "hidden"
$(@refs.grid).css "display", "grid"
$(@refs.header).css "display", "grid"
@observable.on "resize", (e) -> me.calibrate()
@observable.on "resize", (e) => @calibrate()
$(@refs.container)
.css "width", "100%"
.css "overflow-x", "hidden"

View File

@ -1,7 +1,6 @@
class ListViewItemTag extends Ant.OS.GUI.BaseTag
constructor: (r, o) ->
super r, o
me = @
@setopt "data", {}
@setopt "oncontextmenu", (e) ->
@setopt "onclick", (e) ->
@ -11,6 +10,7 @@ class ListViewItemTag extends Ant.OS.GUI.BaseTag
@setopt "index", 0
@setopt "closable", false
@setopt "selected", false
__closable__: (v) ->
if v then $(@refs.btcl).show() else $(@refs.btcl).hide()
@ -21,21 +21,20 @@ class ListViewItemTag extends Ant.OS.GUI.BaseTag
@get("onselect")({ item: @root })
mount: () ->
me = @
$(@refs.item).contextmenu (e) ->
e.item = me.root
me.get("oncontextmenu")(e)
$(@refs.item).contextmenu (e) =>
e.item = @root
@get("oncontextmenu")(e)
$(@refs.item).click (e) ->
e.item = me.root
me.get("onclick")(e)
$(@refs.item).click (e) =>
e.item = @root
@get("onclick")(e)
$(@refs.item).dblclick (e) ->
e.item = me.root
me.get("ondbclick")(e)
$(@refs.btcl).click (e) ->
e.item = me.root
me.get("onclose")(e)
$(@refs.item).dblclick (e) =>
e.item = @root
@get("ondbclick")(e)
$(@refs.btcl).click (e) =>
e.item = @root
@get("onclose")(e)
layout: () ->
[{
el: "li", ref: "item", children: [
@ -60,6 +59,9 @@ class SimpleListItemTag extends ListViewItemTag
@set "selected", v.selected if v.selected
@set "closable", v.closable if v.closable
__selected: (v) ->
@get("data").selected = v
update: () ->
@set "data", @get("data")
@ -83,13 +85,12 @@ class ListViewTag extends Ant.OS.GUI.BaseTag
$(@root)
.css "display", "flex"
.css "flex-direction", "column"
me = @
@root.push = (e) -> me.push e
@root.remove = (e) -> me.remove e
@root.unshift = (e) -> me.unshift e
@root.unselect = () -> me.unselect()
@root.selectNext = () -> me.selectNext()
@root.selectPrev = () -> me.selectPrev()
@root.push = (e) => @push e
@root.remove = (e) => @remove e
@root.unshift = (e) => @unshift e
@root.unselect = () => @unselect()
@root.selectNext = () => @selectNext()
@root.selectPrev = () => @selectPrev()
multiselect: () ->
return false if @get "dropdown"
@ -110,18 +111,17 @@ class ListViewTag extends Ant.OS.GUI.BaseTag
@get("data").push item if not @has_data item
el.appendTo @refs.mlist
el[0].uify @observable
me = @
el[0]
.set "oncontextmenu", (e) ->
me.iclick e, true
.set "ondbclick", (e) ->
me.idbclick e, false
.set "onclick", (e) ->
me.iclick e, false
.set "onselect", (e) ->
me.iselect e
.set "onclose", (e) ->
me.iclose e
.set "oncontextmenu", (e) =>
@iclick e, true
.set "ondbclick", (e) =>
@idbclick e, false
.set "onclick", (e) =>
@iclick e, false
.set "onselect", (e) =>
@iselect e
.set "onclose", (e) =>
@iclose e
.set "data", item
item.domel = el[0]
el[0]
@ -221,9 +221,8 @@ class ListViewTag extends Ant.OS.GUI.BaseTag
@observable.trigger "listselect", evt
mount: () ->
me = @
$(@refs.btlist).hide()
@observable.on "resize", (e) -> me.calibrate()
@observable.on "resize", (e) => @calibrate()
@calibrate()
iclose: (e) ->
@ -239,11 +238,10 @@ class ListViewTag extends Ant.OS.GUI.BaseTag
$(@refs.mlist).removeAttr "style"
$(@refs.container).css "flex", 1
$(@root).removeClass()
me = @
drop = (e) ->
me.dropoff e
show = (e) ->
me.showlist e
drop = (e) =>
@dropoff e
show = (e) =>
@showlist e
if v
$(@root).addClass "dropdown"
$(@refs.current).show()

View File

@ -33,7 +33,6 @@ class MenuEntryTag extends Ant.OS.GUI.BaseTag
]
}]
__children__: (v) ->
me = @
$(@refs.container).removeClass("afx_submenu")
return $(@refs.submenu).hide() unless v and v.length > 0
$(@refs.container).addClass("afx_submenu")
@ -41,15 +40,14 @@ class MenuEntryTag extends Ant.OS.GUI.BaseTag
.show()
.attr("style", "")
@refs.submenu.set "parent", @
@refs.submenu.set "root", me.get("root")
@refs.submenu.set "root", @get("root")
@refs.submenu.set "items", v
if @is_root()
$(@refs.container).mouseleave (e) ->
$(me.refs.submenu).attr("style", "")
$(@refs.container).mouseleave (e) =>
$(@refs.submenu).attr("style", "")
mount: () ->
me = @
$(@refs.entry).click (e) -> me.select e
$(@refs.entry).click (e) => @select e
submenuoff: () ->
p = @get "parent"
@ -57,7 +55,6 @@ class MenuEntryTag extends Ant.OS.GUI.BaseTag
p.submenuoff()
select: (e) ->
me = @
e.item = @root
evt = { id: @aid(), data: e }
e.preventDefault()
@ -134,7 +131,6 @@ class SimpleMenuEntryTag extends MenuEntryTag
mount: () ->
super.mount()
me = @
@refs.switch.set "enable", false
select: (e) ->
@ -156,19 +152,18 @@ class SimpleMenuEntryTag extends MenuEntryTag
class MenuTag extends Ant.OS.GUI.BaseTag
constructor: (r, o) ->
super r, o
me = @
@setopt "context", false
@setopt "parent", undefined
@setopt "root", undefined
@setopt "contentag", "afx-menu-entry"
@setopt "onmenuitemselect", (e) -> me.handleselect e
@setopt "onmenuitemselect", (e) => @handleselect e
@setopt "onmenuselect", (e) ->
@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
@root.show = (e) =>
@showctxmenu e
@root.push = (e) => @push e
@root.remove = (e) => @remove e
@root.unshift = (e) => @unshift e
handleselect: (e) ->
$(@root).hide() if @isctxmenu()
@ -190,12 +185,11 @@ class MenuTag extends Ant.OS.GUI.BaseTag
return @get("root") is undefined
mount: () ->
me = @
$(@refs.container).css "display", "contents"
return unless me.isctxmenu()
$(@refs.wrapper).mouseleave (e) ->
return unless me.is_root()
$(me.root).hide()
return unless @isctxmenu()
$(@refs.wrapper).mouseleave (e) =>
return unless @is_root()
$(@root).hide()
__context__: (v) ->
$(@refs.wrapper).removeClass("context")

View File

@ -7,24 +7,23 @@ class NSpinnerTag extends Ant.OS.GUI.BaseTag
@setopt "step", 1
mount: () ->
me = @
$(@refs.holder).attr "type", "text"
$(@refs.incr).click (e) ->
me.set "value", (me.get("value") + me.get("step") )
$(@refs.incr).click (e) =>
@set "value", (@get("value") + @get("step") )
$(@refs.decr).click (e) ->
me.set "value", (me.get("value") - me.get("step") )
$(@refs.decr).click (e) =>
@set "value", (@get("value") - @get("step") )
# @observable.on "calibrate", () -> me.calibrate()
@observable.on "resize", () -> me.calibrate()
# @observable.on "calibrate", () -> @calibrate()
@observable.on "resize", () => @calibrate()
$(@refs.holder).on 'keyup', (e) ->
$(@refs.holder).on 'keyup', (e) =>
if e.keyCode is 13
val = me.refs.holder.value
val = @refs.holder.value
if not isNaN(val)
val = parseInt(val)
val = me.value if val < 0
me.set "value", val
val = @value if val < 0
@set "value", val
@calibrate()
calibrate: () ->

View File

@ -28,16 +28,15 @@ class ResizerTag extends Ant.OS.GUI.BaseTag
@draggable()
draggable: () ->
me = @
$(@root).css "user-select", "none"
$(@root).on "mousedown", (e) ->
$(@root).on "mousedown", (e) =>
e.preventDefault()
$(window).on "mousemove", (evt) ->
return unless me.resizable_el
if me.dir is "hz"
me.horizontalResize evt
else if me.dir is "ve"
me.verticalResize evt
$(window).on "mousemove", (evt) =>
return unless @resizable_el
if @dir is "hz"
@horizontalResize evt
else if @dir is "ve"
@verticalResize evt
$(window).on "mouseup", (evt) ->
$(window).unbind "mousemove", null

View File

@ -16,12 +16,11 @@ class SliderTag extends Ant.OS.GUI.BaseTag
__dragable__: (v) ->
if v
me = @
$(@root)
.mouseover () ->
$(me.refs.point).show()
.mouseout () ->
$(me.refs.point).hide()
.mouseover () =>
$(@refs.point).show()
.mouseout () =>
$(@refs.point).hide()
else
$(@refs.point).hide()
$(@root)
@ -29,21 +28,20 @@ class SliderTag extends Ant.OS.GUI.BaseTag
.ubbind("mouseout")
mount: () ->
me = @
@enable_dragging()
$(@refs.point).css "position", "absolute"
$(@refs.point).hide()
@observable.on "resize", (e) ->
me.calibrate()
$(@refs.container).click (e) ->
offset = $(me.refs.container).offset()
@observable.on "resize", (e) =>
@calibrate()
$(@refs.container).click (e) =>
offset = $(@refs.container).offset()
left = e.clientX - offset.left
maxw = $(me.refs.container).width()
me.set "value", left * me.get("max") / maxw
me.calibrate()
evt = { id: me.aid(), data: me.get("value") }
me.get("onchange") evt
me.get("onchanging") evt
maxw = $(@refs.container).width()
@set "value", left * @get("max") / maxw
@calibrate()
evt = { id: @aid(), data: @get("value") }
@get("onchange") evt
@get("onchanging") evt
@calibrate()
calibrate: () ->
@ -61,24 +59,23 @@ class SliderTag extends Ant.OS.GUI.BaseTag
.css "top", top + "px"
enable_dragging: () ->
me = @
$(@refs.point)
.css "user-select", "none"
.css "cursor", "default"
$(@refs.point).on "mousedown", (e) ->
$(@refs.point).on "mousedown", (e) =>
e.preventDefault()
offset = $(me.refs.container).offset()
$(window).on "mousemove", (e) ->
offset = $(@refs.container).offset()
$(window).on "mousemove", (e) =>
left = e.clientX - offset.left
left = if left < 0 then 0 else left
maxw = $(me.refs.container).width()
maxw = $(@refs.container).width()
left = if left > maxw then maxw else left
me.set "value", left * me.get("max") / maxw
me.calibrate()
me.get("onchanging") { id: me.aid(), data: me.get("value") }
@set "value", left * @get("max") / maxw
@calibrate()
@get("onchanging") { id: @aid(), data: @get("value") }
$(window).on "mouseup", (e) ->
me.get("onchange") { id: me.aid(), data: me.get("value") }
$(window).on "mouseup", (e) =>
@get("onchange") { id: @aid(), data: @get("value") }
$(window).unbind("mousemove", null)
$(window).unbind("mouseup", null)

View File

@ -7,9 +7,8 @@ class SwitchTag extends Ant.OS.GUI.BaseTag
@setopt "onchange", (e) ->
mount: () ->
me = @
$(@refs.switch).click (e) ->
me.onchange(e)
$(@refs.switch).click (e) =>
@onchange(e)
onchange: (e) ->
return unless @get "enable"

View File

@ -1,15 +1,14 @@
class SystemPanelTag extends Ant.OS.GUI.BaseTag
constructor: (r, o) ->
super r, o
me = @
@setopt "osmenu", {
text: __("Start"),
iconclass: "fa fa-eercast"
}
@setopt "appmenu", []
@setopt "systray", []
@root.attachservice = (s) -> me.attachservice s
@root.detachservice = (s) -> me.detachservice s
@root.attachservice = (s) => @attachservice s
@root.detachservice = (s) => @detachservice s
@view = false
__osmenu__: (v) ->
@ -118,50 +117,49 @@ class SystemPanelTag extends Ant.OS.GUI.BaseTag
@refs.overlay.set "height", "#{$(window).height() - $(@refs.panel).height()}px"
mount: () ->
me = @
@cb = (e) ->
if not ($ e.target).closest($ me.refs.overlay).length and not ($ e.target).closest(me.refs.osmenu).length
me.toggle false
@cb = (e) =>
if not ($ e.target).closest($ @refs.overlay).length and not ($ e.target).closest(@refs.osmenu).length
@toggle false
else
$(me.refs.search).focus()
$(@refs.search).focus()
$(@refs.appmenu).css("z-index", 1000000)
$(@refs.systray).css("z-index", 1000000)
@refs.btscreen.set "*", {
iconclass: "fa fa-tv",
onbtclick: (e) ->
me.toggle false
onbtclick: (e) =>
@toggle false
Ant.OS.GUI.toggleFullscreen()
}
@refs.btuser.set "*", {
iconclass: "fa fa-user-circle-o",
onbtclick: (e) ->
me.toggle false
onbtclick: (e) =>
@toggle false
Ant.OS.GUI.openDialog("InfoDialog", Ant.OS.setting.user)
}
@refs.btlogout.set "*", {
iconclass: "fa fa-power-off",
onbtclick: (e) ->
me.toggle false
onbtclick: (e) =>
@toggle false
Ant.OS.exit()
}
@refs.osmenu.set "onmenuselect", (e) ->
me.toggle true
@refs.osmenu.set "onmenuselect", (e) =>
@toggle true
($ @refs.overlay).css "left", 0
.css "top", "#{$(@refs.panel).height()}px"
.css "bottom", "0"
.hide()
($ @refs.search).keyup (e) ->
me.search e
($ @refs.search).keyup (e) =>
@search e
$(@refs.applist).click (e) ->
me.open()
Ant.OS.GUI.bindKey "CTRL- ", (e) ->
if me.view is false
me.toggle true
$(@refs.applist).click (e) =>
@open()
Ant.OS.GUI.bindKey "CTRL- ", (e) =>
if @view is false
@toggle true
else
me.toggle false
me.view = not me.view
@toggle false
@view = not @view
Ant.OS.announcer.trigger("syspanelloaded")
Ant.OS.GUI.define "afx-sys-panel", SystemPanelTag

View File

@ -6,15 +6,14 @@ class TabBarTag extends Ant.OS.GUI.BaseTag
@setopt "ontabclose", (e) ->
@setopt "items", []
@setopt "selected", -1
me = @
@root.push = (e) ->
e.closable = me.get "closable"
me.refs.list.push e
@root.remove = (e) -> me.refs.list.remove e
@root.unshift = (e) -> me.refs.list.unshift e
@refs.list.set "onlistselect", (e) ->
me.get("ontabselect") e
me.observable.trigger "tabselect", e
@root.push = (e) =>
e.closable = @get "closable"
@refs.list.push e
@root.remove = (e) => @refs.list.remove e
@root.unshift = (e) => @refs.list.unshift e
@refs.list.set "onlistselect", (e) =>
@get("ontabselect") e
@observable.trigger "tabselect", e
__items__: (v) ->
i.closable = @get "closable" for i in v
@ -24,11 +23,10 @@ class TabBarTag extends Ant.OS.GUI.BaseTag
@refs.list.set "selected", v
mount: () ->
me = @
$(@refs.list).css "height", "100%"
@refs.list.set "onitemclose", (e) ->
e.id = me.aid()
me.get("ontabclose") e
@refs.list.set "onitemclose", (e) =>
e.id = @aid()
@get("ontabclose") e
layout: () ->
[{

View File

@ -6,11 +6,10 @@ class TabContainerTag extends Ant.OS.GUI.BaseTag
@setopt "tabbarwidth", undefined
@setopt "tabbarheight", undefined
@setopt "ontabselect", () ->
me = @
@refs.bar.set "ontabselect", (e) ->
@refs.bar.set "ontabselect", (e) =>
data = e.data.item.get "data"
me.set "selectedTab", data
me.get("ontabselect") { data: data, id: me.aid() }
@set "selectedTab", data
@get("ontabselect") { data: data, id: @aid() }
__selectedTab: (v) ->
return unless v
@ -34,19 +33,18 @@ class TabContainerTag extends Ant.OS.GUI.BaseTag
@set "tabsize", @get("tabsize")
mount: () ->
me = @
$(@children).each () ->
$(@children).each (i, e) =>
item = {}
item.text = $(@).attr "tabname" if $(@).attr "tabname"
item.icon = $(@).attr "icon" if $(@).attr "icon"
item.iconclass = $(@).attr "iconclass" if $(@).attr "iconclass"
item.container = @
$(@)
item.text = $(e).attr "tabname" if $(e).attr "tabname"
item.icon = $(e).attr "icon" if $(e).attr "icon"
item.iconclass = $(e).attr "iconclass" if $(e).attr "iconclass"
item.container = e
$(e)
.css "width", "100%"
.css "height", "100%"
el = me.refs.bar.push item
el = @refs.bar.push item
el.set "selected", true
@observable.on "resize", (e) -> me.calibrate()
@observable.on "resize", (e) => @calibrate()
@calibrate()
calibrate: () ->

View File

@ -23,8 +23,7 @@ class TileLayoutTag extends Ant.OS.GUI.BaseTag
@calibrate()
mount: () ->
me = @
@observable.on "resize", (e) -> me.calibrate()
@observable.on "resize", (e) => @calibrate()
@calibrate()
calibrate: () ->

View File

@ -22,16 +22,15 @@ class TreeViewItemPrototype extends Ant.OS.GUI.BaseTag
return $(@refs.wrapper).addClass("afx_tree_item_selected") if v
__open__: (v) ->
me = @
return unless @is_folder()
$(@refs.toggle)
.removeClass()
if(v)
if @get("fetch")
@get("fetch")(@root)
.then (d) ->
.then (d) =>
return unless d
me.set "nodes", d
@.set "nodes", d
.catch (e) -> Ant.OS.announcer.oserror e
$(@refs.childnodes).show()
else
@ -76,7 +75,6 @@ class TreeViewItemPrototype extends Ant.OS.GUI.BaseTag
mount: () ->
me = @
super.mount()
$(@refs.container)
.css "padding", 0
@ -85,20 +83,20 @@ class TreeViewItemPrototype extends Ant.OS.GUI.BaseTag
$(@refs.itemholder)
.css "display", "inline-block"
$(@refs.wrapper)
.click (e) ->
e.item = me.root
me.get("treeroot").itemclick e, false
.click (e) =>
e.item = @root
@get("treeroot").itemclick e, false
$(@refs.wrapper)
.dblclick (e) ->
e.item = me.root
me.get("treeroot").itemclick e, true
.dblclick (e) =>
e.item = @root
@get("treeroot").itemclick e, true
$(@refs.toggle)
.css "display", "inline-block"
.css "width", "15px"
.addClass "afx-tree-view-item"
.click (e) ->
me.set "open", not me.get("open")
.click (e) =>
@set "open", not @get("open")
e.preventDefault()
e.stopPropagation()

View File

@ -19,16 +19,15 @@ class WindowTag extends Ant.OS.GUI.BaseTag
$(this).css "height", "#{ch}px"
mount: () ->
me = @
@root.contextmenuHandle = (e) ->
$(@refs["minbt"]).click (e) ->
me.observable.trigger "hide", { id: me.aid() }
$(@refs["minbt"]).click (e) =>
@observable.trigger "hide", { id: @aid() }
$(@refs["maxbt"]).click (e) ->
me.toggle_window()
$(@refs["maxbt"]).click (e) =>
@toggle_window()
$(@refs["closebt"]).click (e) ->
me.observable.trigger("exit", { id: me.aid() })
$(@refs["closebt"]).click (e) =>
@observable.trigger("exit", { id: @aid() })
left = ($(@desktop).width() - (@get "width")) / 2
top = ($(@desktop).height() - (@get "height")) / 2
$(@root)
@ -36,41 +35,41 @@ class WindowTag extends Ant.OS.GUI.BaseTag
.css("left", "#{left}px")
.css("top", "#{top}px")
.css("z-index", Ant.OS.GUI.zindex++)
$(@root).on "mousedown", (e) ->
return if me.shown
me.observable.trigger "focus", { id: me.aid() }
$(@root).on "mousedown", (e) =>
return if @shown
@observable.trigger "focus", { id: @aid() }
$(@refs["dragger"]).dblclick (e) ->
me.toggle_window()
$(@refs["dragger"]).dblclick (e) =>
@toggle_window()
@observable.on "resize", (e) -> me.resize()
@observable.on "resize", (e) => @resize()
@observable.on "focus", () ->
@observable.on "focus", () =>
Ant.OS.GUI.zindex++
$(me.root)
$(@root)
.show()
.css("z-index", Ant.OS.GUI.zindex)
.removeClass("unactive")
me.shown = true
@shown = true
@observable.on "blur", () ->
me.shown = false
$(me.root)
@observable.on "blur", () =>
@shown = false
$(@root)
.addClass("unactive")
@observable.on "hide", () ->
$(me.root).hide()
me.shown = false
@observable.on "hide", () =>
$(@root).hide()
@shown = false
@observable.on "toggle", () ->
if me.shown
me.observable.trigger "hide", { id: me.aid() }
@observable.on "toggle", () =>
if @shown
@observable.trigger "hide", { id: @aid() }
else
me.observable.trigger "focus", { id: me.aid() }
@observable.trigger "focus", { id: @aid() }
@enable_dragging()
@enable_resize()
@setsize { w: (@get "width"), h: (@get "height") }
@observable.trigger "rendered", { id: me.aid() }
@observable.trigger "rendered", { id: @aid() }
__minimizable__: (value) ->
if value then $(@refs["minbt"]).show() else $(@refs["minbt"]).hide()
@ -104,29 +103,28 @@ class WindowTag extends Ant.OS.GUI.BaseTag
$(@refs["dragger"]).text value.__() if value
enable_dragging: () ->
me = @
$(@refs["dragger"])
.css("user-select", "none")
.css("cursor", "default")
$(@refs["dragger"]).on "mousedown", (e) ->
$(@refs["dragger"]).on "mousedown", (e) =>
e.preventDefault()
offset = $(me.root).offset()
offset = $(@root).offset()
offset.top = e.clientY - offset.top
offset.left = e.clientX - offset.left
$(window).on "mousemove", (e) ->
if me.isMaxi
me.toggle_window()
$(window).on "mousemove", (e) =>
if @isMaxi
@toggle_window()
top = 0
letf = e.clientX - $(me.root).width() / 2
letf = e.clientX - $(@root).width() / 2
offset.top = 10
offset.left = $(me.root).width() / 2
offset.left = $(@root).width() / 2
else
top = e.clientY - offset.top - me.desktop_pos.top
left = e.clientX - me.desktop_pos.top - offset.left
top = e.clientY - offset.top - @desktop_pos.top
left = e.clientX - @desktop_pos.top - offset.left
left = if left < 0 then 0 else left
top = if top < 0 then 0 else top
$(me.root)
$(@root)
.css("top", "#{top}px")
.css("left", "#{left}px")
$(window).on "mouseup", (e) ->
@ -134,7 +132,6 @@ class WindowTag extends Ant.OS.GUI.BaseTag
$(window).unbind "mouseup", null
enable_resize: () ->
me = @
$(@refs["grip"])
.css("user-select", "none")
.css("cursor", "default")
@ -143,20 +140,20 @@ class WindowTag extends Ant.OS.GUI.BaseTag
.css("right", "0")
.css("cursor", "nwse-resize")
$(@refs["grip"]).on "mousedown", (e) ->
$(@refs["grip"]).on "mousedown", (e) =>
e.preventDefault()
offset = { top: 0, left: 0 }
offset.top = e.clientY
offset.left = e.clientX
$(window).on "mousemove", (e) ->
w = $(me.root).width() + e.clientX - offset.left
h = $(me.root).height() + e.clientY - offset.top
$(window).on "mousemove", (e) =>
w = $(@root).width() + e.clientX - offset.left
h = $(@root).height() + e.clientY - offset.top
w = if w < 100 then 100 else w
h = if h < 100 then 100 else h
offset.top = e.clientY
offset.left = e.clientX
me.isMaxi = false
me.setsize { w: w, h: h }
@isMaxi = false
@setsize { w: w, h: h }
$(window).on "mouseup", (e) ->
$(window).unbind "mousemove", null
@ -164,7 +161,6 @@ class WindowTag extends Ant.OS.GUI.BaseTag
toggle_window: () ->
return unless @get "resizable"
me = @
if @isMaxi is false
@history = {
top: $(@root).css("top"),

View File

@ -3,17 +3,16 @@ Ant.OS.GUI.zindex = 10
class Ant.OS.GUI.BaseTag
constructor: (@root, @observable) ->
@opts = {}
me = @
@observable = new Ant.OS.API.Announcer() unless @observable
# export to rootnode
@root.observable = @observable
@root.set = (k, v) -> me.set k, v
@root.get = (k) -> me.get k
@root.aid = () -> me.aid()
@root.calibrate = () -> me.calibrate()
@root.sync = () -> me.sync()
@root.set = (k, v) => @set k, v
@root.get = (k) => @get k
@root.aid = () => @aid()
@root.calibrate = () => @calibrate()
@root.sync = () => @sync()
@mounted = false
@root.setup = () -> me.setup()
@root.setup = () => @setup()
@refs = {}
@setopt "data-id", (Math.floor(Math.random() * 100000) + 1).toString()
@setopt "tooltip", undefined
@ -28,7 +27,7 @@ class Ant.OS.GUI.BaseTag
$(v).detach().appendTo @refs.yield for v in @children
else
@children = []
$(@root).children().each () -> @.mkui me.observable
$(@root).children().each (i, e) => e.mkui @observable
__: (k, v) ->
@set k, v if v

View File

@ -75,20 +75,19 @@ class BaseFileHandle
b64: (t) ->
# t is object or mime type
me = @
new Promise (resolve, reject) ->
new Promise (resolve, reject) =>
m = if t is "object" then "text/plain" else t
return resolve "" unless me.cache
if t is "object" or typeof me.cache is "string"
return resolve "" unless @cache
if t is "object" or typeof @cache is "string"
if t is "object"
b64 = (JSON.stringify me.cache).asBase64()
b64 = (JSON.stringify @cache).asBase64()
else
b64 = me.cache.asBase64()
b64 = @cache.asBase64()
b64 = "data:#{m};base64,#{b64}"
resolve(b64)
else
reader = new FileReader()
reader.readAsDataURL(me.cache)
reader.readAsDataURL(@cache)
reader.onload = () ->
resolve reader.result
reader.onerror = (e) ->
@ -101,23 +100,21 @@ class BaseFileHandle
onready: () ->
# read meta data
me = @
new Promise (resolve, reject) ->
return resolve(me.info) if me.ready
me.meta()
.then (d) ->
new Promise (resolve, reject) =>
return resolve(@info) if @ready
@meta()
.then (d) =>
return reject d if d.errors
me.info = d.result
me.ready = true
@info = d.result
@ready = true
resolve(d.result)
.catch (e) -> reject e
read: (t) ->
me = @
new Promise (resolve, reject) ->
me.onready()
.then (r) ->
me._rd(t)
new Promise (resolve, reject) =>
@onready()
.then (r) =>
@_rd(t)
.then (d) ->
# Ant.OS.announcer.ostrigger "VFS", { m: "read", file: me }
resolve d
@ -125,94 +122,86 @@ class BaseFileHandle
.catch (e) -> reject e
write: (t) ->
me = @
new Promise (resolve, reject) ->
me._wr(t)
.then (r) ->
Ant.OS.announcer.ostrigger "VFS", { m: "write", file: me }
new Promise (resolve, reject) =>
@_wr(t)
.then (r) =>
Ant.OS.announcer.ostrigger "VFS", { m: "write", file: @ }
resolve r
.catch (e) -> reject e
mk: (d) ->
me = @
new Promise (resolve, reject) ->
me.onready()
.then (r) ->
me._mk(d)
.then (d) ->
Ant.OS.announcer.ostrigger "VFS", { m: "mk", file: me }
new Promise (resolve, reject) =>
@onready()
.then (r) =>
@_mk(d)
.then (d) =>
Ant.OS.announcer.ostrigger "VFS", { m: "mk", file: @ }
resolve d
.catch (e) -> reject e
.catch (e) -> reject e
remove: () ->
me = @
new Promise (resolve, reject) ->
me.onready()
.then (r) ->
me._rm()
.then (d) ->
Ant.OS.announcer.ostrigger "VFS", { m: "remove", file: me }
new Promise (resolve, reject) =>
@onready()
.then (r) =>
@_rm()
.then (d) =>
Ant.OS.announcer.ostrigger "VFS", { m: "remove", file: @ }
resolve d
.catch (e) -> reject e
.catch (e) -> reject e
upload: () ->
me = @
new Promise (resolve, reject) ->
me.onready()
.then (r) ->
me._up()
.then (d) ->
Ant.OS.announcer.ostrigger "VFS", { m: "upload", file: me }
new Promise (resolve, reject) =>
@onready()
.then (r) =>
@_up()
.then (d) =>
Ant.OS.announcer.ostrigger "VFS", { m: "upload", file: @ }
resolve d
.catch (e) -> reject e
.catch (e) -> reject e
publish: () ->
me = @
new Promise (resolve, reject) ->
me.onready()
.then (r) ->
me._pub()
.then (d) ->
Ant.OS.announcer.ostrigger "VFS", { m: "publish", file: me }
new Promise (resolve, reject) =>
@onready()
.then (r) =>
@_pub()
.then (d) =>
Ant.OS.announcer.ostrigger "VFS", { m: "publish", file: @ }
resolve d
.catch (e) -> reject e
.catch (e) -> reject e
download: () ->
me = @
new Promise (resolve, reject) ->
me.onready()
.then (r) ->
me._down()
.then (d) ->
Ant.OS.announcer.ostrigger "VFS", { m: "download", file: me }
new Promise (resolve, reject) =>
@onready()
.then (r) =>
@_down()
.then (d) =>
Ant.OS.announcer.ostrigger "VFS", { m: "download", file: @ }
resolve d
.catch (e) -> reject e
.catch (e) -> reject e
move: (d) ->
me = @
new Promise (resolve, reject) ->
me.onready()
.then (r) ->
me._mv(d)
.then (data) ->
Ant.OS.announcer.ostrigger "VFS", { m: "move", file: me }
new Promise (resolve, reject) =>
@onready()
.then (r) =>
@_mv(d)
.then (data) =>
Ant.OS.announcer.ostrigger "VFS", { m: "move", file: @ }
resolve data
.catch (e) -> reject e
.catch (e) -> reject e
execute: () ->
me = @
new Promise (resolve, reject) ->
me.onready()
.then (r) ->
me._exec()
.then (d) ->
Ant.OS.announcer.ostrigger "VFS", { m: "execute", file: me }
new Promise (resolve, reject) =>
@onready()
.then (r) =>
@_exec()
.then (d) =>
Ant.OS.announcer.ostrigger "VFS", { m: "execute", file: @ }
resolve d
.catch (e) -> reject e
.catch (e) -> reject e
@ -220,9 +209,8 @@ class BaseFileHandle
getlink: () -> @path
unsupported: (t) ->
me = @
new Promise (resolve, reject) ->
reject { error: __("Action {0} is unsupported on: {1}", t, me.path) }
new Promise (resolve, reject) =>
reject { error: __("Action {0} is unsupported on: {1}", t, @path) }
# actions must be implemented by subclasses
_rd: (t) -> @unsupported "read"
@ -251,6 +239,10 @@ class RemoteFileHandle extends Ant.OS.API.VFS.BaseFileHandle
_rd: (t) ->
# t: binary, text, any type
if not @info
return new Promise (resolve, reject) =>
reject Ant.OS.API.throwe __(
"file meta-data not found: {0}", @path)
return Ant.OS.API.handle.scandir @path if @info.type is "dir"
#read the file
return Ant.OS.API.handle.fileblob @path if t is "binary"
@ -258,21 +250,23 @@ class RemoteFileHandle extends Ant.OS.API.VFS.BaseFileHandle
_wr: (t) ->
# t is base64 or undefined
return Ant.OS.API.handle.write me.path, me.cache if t is "base64"
me = @
new Promise (resolve, reject) ->
me.b64(t)
.then (r) ->
Ant.OS.API.handle.write me.path, r
return Ant.OS.API.handle.write @path, @cache if t is "base64"
new Promise (resolve, reject) =>
@b64(t)
.then (r) =>
Ant.OS.API.handle.write @path, r
.then (result) -> resolve result
.catch (e) -> reject e
.catch (e) -> reject e
_mk: (d) ->
me = @
if not @info
return new Promise (resolve, reject) =>
reject Ant.OS.API.throwe __(
"file meta-data not found: {0}", @path)
if @info.type is "file"
return new Promise (resolve, reject) ->
reject Ant.OS.API.throwe __("{0} is not a directory", me.path)
return new Promise (resolve, reject) =>
reject Ant.OS.API.throwe __("{0} is not a directory", @path)
Ant.OS.API.handle.mkdir "#{@path}/#{d}"
_rm: () ->
@ -283,21 +277,19 @@ class RemoteFileHandle extends Ant.OS.API.VFS.BaseFileHandle
_up: () ->
me = @
if @info.type isnt "dir"
return new Promise (resolve, reject) ->
reject Ant.OS.API.throwe __("{0} is not a file", me.path)
return new Promise (resolve, reject) =>
reject Ant.OS.API.throwe __("{0} is not a file", @path)
Ant.OS.API.handle.upload @path
_down: () ->
me = @
new Promise (resolve, reject) ->
if me.info.type is "dir"
return Ant.OS.API.throwe __("{0} is not a file", me.path)
Ant.OS.API.handle.fileblob(me.path)
.then (d) ->
new Promise (resolve, reject) =>
if @info.type is "dir"
return Ant.OS.API.throwe __("{0} is not a file", @path)
Ant.OS.API.handle.fileblob(@path)
.then (d) =>
blob = new Blob [d], { type: "octet/stream" }
Ant.OS.API.saveblob me.basename, blob
Ant.OS.API.saveblob @basename, blob
resolve()
.catch (e) ->
reject e
@ -315,10 +307,9 @@ class ApplicationHandle extends Ant.OS.API.VFS.BaseFileHandle
@ready = true
_rd: (t) ->
me = @
new Promise (resolve, reject) ->
return resolve { result: me.info } if me.info
return reject Ant.OS.API.throwe(__("Application meta data isnt found")) unless me.isRoot()
new Promise (resolve, reject) =>
return resolve { result: @info } if @info
return reject Ant.OS.API.throwe(__("Application meta data isnt found")) unless @isRoot()
resolve { result: ( v for k, v of Ant.OS.setting.system.packages ) }
@ -336,9 +327,8 @@ class BufferFileHandle extends Ant.OS.API.VFS.BaseFileHandle
type: "file"
_rd: (t) ->
me = @
new Promise (resolve, reject) ->
resolve { result: me.cache }
new Promise (resolve, reject) =>
resolve { result: @cache }
_wr: (d, t) ->
@cache = d
@ -347,10 +337,9 @@ class BufferFileHandle extends Ant.OS.API.VFS.BaseFileHandle
resolve { result: true }
_down: () ->
me = @
new Promise (resolve, reject) ->
blob = new Blob [me.cache], { type: "octet/stream" }
Ant.OS.API.saveblob me.basename, blob
new Promise (resolve, reject) =>
blob = new Blob [@cache], { type: "octet/stream" }
Ant.OS.API.saveblob @basename, blob
resolve()
onchange: (f) ->
@ -390,18 +379,16 @@ class SharedFileHandle extends Ant.OS.API.VFS.BaseFileHandle
Ant.OS.API.handle.sharefile @basename, false
_down: () ->
me = @
new Promise (resolve, reject) ->
if me.info.type is "dir"
return reject Ant.OS.API.throwe __("{0} is not a file", me.path)
Ant.OS.API.handle.fileblob me.path
.then (data) ->
new Promise (resolve, reject) =>
if @info.type is "dir"
return reject Ant.OS.API.throwe __("{0} is not a file", @path)
Ant.OS.API.handle.fileblob @path
.then (data) =>
blob = new Blob [data], { type: "octet/stream" }
Ant.OS.API.saveblob me.basename, blob
Ant.OS.API.saveblob @basename, blob
resolve()
.catch (e) -> reject e
_pub: () ->
me = @
return new Promise (resolve, reject) -> resolve { result: me.basename }
return new Promise (resolve, reject) => resolve { result: @basename }
Ant.OS.API.VFS.register "^shared$", SharedFileHandle

View File

@ -21,12 +21,11 @@ class ActivityMonitor extends this.OS.GUI.BaseApplication
constructor: (args) ->
super "ActivityMonitor", args
main: () ->
me = @
@scheme.set "apptitle", "Activity Monitor"
@grid = @find "mygrid"
@on "btclick", (e) ->
@on "btclick", (e) =>
return unless e.id == "btkill"
item = me.grid.get "selectedRow"
item = @grid.get "selectedRow"
return unless item
data = item.get("data")[0]
app = _PM.appByPid data.text
@ -57,17 +56,16 @@ class ActivityMonitor extends this.OS.GUI.BaseApplication
@monitor()
monitor: () ->
me = @
#get all current running process
me.gdata.alive = []
@gdata.alive = []
now = (new Date).getTime()
$.each _PM.processes, (i, d) ->
$.each d , (j, a) ->
if me.gdata.processes[a.pid] #update it
me.gdata.processes[a.pid][3].text = now - a.birth
me.gdata.processes[a.pid][3].domel.update()
$.each _PM.processes, (i, d) =>
$.each d , (j, a) =>
if @gdata.processes[a.pid] #update it
@gdata.processes[a.pid][3].text = now - a.birth
@gdata.processes[a.pid][3].domel.update()
else #add it
me.gdata.processes[a.pid] = [
@gdata.processes[a.pid] = [
{ text: a.pid },
{
icon: if _APP[a.name].type == 1 then _APP[a.name].meta.icon else a.icon,
@ -81,16 +79,16 @@ class ActivityMonitor extends this.OS.GUI.BaseApplication
text: now - a.birth
}
]
me.grid.push me.gdata.processes[a.pid]
me.gdata.alive.push a.pid
@grid.push @gdata.processes[a.pid]
@gdata.alive.push a.pid
$.each @gdata.processes, (i, e) ->
if ($.inArray (Number i), me.gdata.alive) < 0
me.grid.remove me.gdata.processes[i].domel
me.gdata.processes[i] = undefined
delete me.gdata.processes[i]
$.each @gdata.processes, (i, e) =>
if ($.inArray (Number i), @gdata.alive) < 0
@grid.remove @gdata.processes[i].domel
@gdata.processes[i] = undefined
delete @gdata.processes[i]
@timer = setTimeout (() -> me.monitor()), 500
@timer = setTimeout (() => @monitor()), 500
cleanup: (e) ->
clearTimeout @timer if @timer

View File

@ -3,27 +3,26 @@ class CommandPalette extends this.OS.GUI.BasicDialog
super "CommandPalete", CommandPalette.scheme
init: () ->
me = @
offset = $(".afx-window-content", @parent.scheme).offset()
pw = @parent.scheme.get("width") / 5
@scheme.set "width", 3 * pw
$(@scheme).offset { top: offset.top - 2, left: offset.left + pw }
cb = (e) ->
if ($ e.target).closest(me.scheme).length > 0
$(me.find "searchbox").focus()
cb = (e) =>
if ($ e.target).closest(@scheme).length > 0
$(@find "searchbox").focus()
else
$(document).unbind "mousedown", cb
me.quit()
@quit()
$(document).on "mousedown", cb
$(me.find "searchbox").focus()
$(@find "searchbox").focus()
@cmdlist = @find("container")
@cmdlist.set "data", (v for v in @data.child) if @data
$(@cmdlist).click (e) ->
me.selectCommand()
$(@cmdlist).click (e) =>
@selectCommand()
@searchbox = @find "searchbox"
($ @searchbox).keyup (e) ->
me.search e
($ @searchbox).keyup (e) =>
@search e
search: (e) ->
switch e.which

View File

@ -8,42 +8,45 @@ class App.extensions.AntOSDK extends App.BaseExtension
# public functions
create: () ->
me = @
@app.openDialog("FileDialog", {
title: "__(New Project at)",
file: { basename: __("ProjectName") },
mimes: ["dir"]
}).then (d) ->
me.mktpl d.file.path, d.name, true
}).then (d) =>
@mktpl d.file.path, d.name, true
init: () ->
me = @
dir = @app.currdir
return @create() unless dir and dir.basename
dir.read()
.then (d) ->
return me.notify __("Cannot read folder: {0}", dir.path) if d.error
return me.notify __("The folder is not empty: {0}", dir.path) unless d.result.length is 0
me.mktpl dir.parent().path, dir.basename
.then (d) =>
return @notify __("Cannot read folder: {0}", dir.path) if d.error
return @notify __("The folder is not empty: {0}", dir.path) unless d.result.length is 0
@mktpl dir.parent().path, dir.basename
build: () ->
console.log "build"
buildnrun: () ->
@metadata().then (meta) =>
@build(meta).then () =>
@run(meta).catch (e) => @error.toString()
.catch (e) =>
@error e.toString()
.catch (e) => @error e.toString()
release: () ->
console.log "release"
@metadata().then (meta) =>
@build(meta).then () =>
@mkar(meta)
.then () ->
.catch (e) => @error.toString()
.catch (e) =>
@error e.toString()
.catch (e) => @error e.toString()
options: () ->
console.log "options"
dependencies: () ->
[
"AntOSDK/coffeescript.js"
]
# private functions
mktpl: (path, name, flag) ->
me = @
rpath = "#{path}/#{name}"
console.log rpath
dirs = [
"#{rpath}/build",
"#{rpath}/build/release",
@ -57,49 +60,198 @@ class App.extensions.AntOSDK extends App.BaseExtension
files = [
["main.tpl", "#{rpath}/coffees/main.coffee"],
["package.tpl", "#{rpath}/package.json"],
["project.tpl", "#{rpath}/project.apj"],
["project.tpl", "#{rpath}/project.json"],
["README.tpl", "#{rpath}/README.md"],
["scheme.tpl", "#{rpath}/assets/scheme.html"]
]
@mkdirAll dirs
.then () ->
me.mkfileAll(files, path, name)
.then () ->
me.app.currdir = rpath.asFileHandle()
me.app.initSideBar()
me.app.openFile "#{rpath}/README.md".asFileHandle()
.catch (e) -> me.error e.stack
.catch (e) -> me.error e.stack
.then () =>
@mkfileAll(files, path, name)
.then () =>
@app.currdir = rpath.asFileHandle()
@app.initSideBar()
@app.openFile "#{rpath}/README.md".asFileHandle()
.catch (e) => @error e.stack
.catch (e) => @error e.stack
mkdirAll: (list) ->
me = @
new Promise (resolve, reject) ->
new Promise (resolve, reject) =>
return resolve() if list.length is 0
path = (list.splice 0, 1)[0].asFileHandle()
console.log path.parent().path, path.basename
path.parent().mk path.basename
.then () ->
me.mkdirAll list
.then (d) =>
@mkdirAll list
.then () -> resolve()
.catch (e) -> reject e
.catch (e) -> reject e
mkfileAll: (list, path, name) ->
me = @
new Promise (resolve, reject) ->
new Promise (resolve, reject) =>
return resolve() if list.length is 0
item = (list.splice 0, 1)[0]
"#{me.basedir()}/AntOSDK/templates/#{item[0]}"
"#{@basedir()}/AntOSDK/templates/#{item[0]}"
.asFileHandle()
.read()
.then (data) ->
.then (data) =>
file = item[1].asFileHandle()
.setCache(data.format name, "#{path}/#{name}")
.write "text/plain"
.then () ->
me.mkfileAll list, path, name
.then () =>
@mkfileAll list, path, name
.then () -> resolve()
.catch (e) -> reject e
.catch (e) -> reject e
.catch (e) -> reject e
metadata: () ->
new Promise (resolve, reject) =>
if not @app.currdir
return reject @app._api.throwe __("Project folder is not found")
"#{@app.currdir.path}/project.json"
.asFileHandle()
.read("json")
.then (data) ->
resolve data
.catch (e) =>
reject @app._api.throwe __("Unable to read project meta-data")
verify: (list) ->
new Promise (resolve, reject) =>
return resolve() if list.length is 0
file = (list.splice 0, 1)[0].asFileHandle()
@notify __("Verifying: {0}", file.path)
file.read().then (data) =>
try
CoffeeScript.nodes data
@verify list
.then () -> resolve()
.catch (e) -> reject e
catch ex
reject ex
.catch (e) -> reject e
compile: (meta) ->
new Promise (resolve, reject) =>
@import("#{@basedir()}/AntOSDK/coffeescript.js").then () =>
list = ("#{meta.root}/#{v}" for v in meta.coffees)
@verify((f for f in list)).then () =>
@cat(list).then (code) =>
jsrc = CoffeeScript.compile code
@notify __("Compiled successful")
resolve jsrc
.catch (e) -> reject e
.catch (e) -> reject e
.catch (e) -> reject e
build: (meta) ->
new Promise (resolve, reject) =>
@compile(meta).then (src) =>
@cat ("#{meta.root}/#{v}" for v in meta.javascripts), src
.then (jsrc) ->
new Promise (r, e) ->
"#{meta.root}/build/debug/main.js"
.asFileHandle()
.setCache jsrc
.write("text/plain")
.then (d) ->
return e d if d.error
r()
.catch (ex) -> e ex
.then () =>
new Promise (r, e) =>
@cat ("#{meta.root}/#{v}" for v in meta.css), ""
.then (txt) ->
return r() if txt is ""
"#{meta.root}/build/debug/main.css"
.asFileHandle()
.setCache txt
.write("text/plain")
.then (d) ->
return e d if d.error
r()
.catch (ex) -> e ex
.then () =>
@copy ("#{meta.root}/#{v}" for v in meta.copies), "#{meta.root}/build/debug"
.then () -> resolve()
.catch (e) -> reject e
.catch (e) -> reject e
run: (meta) ->
"#{meta.root}/build/debug/package.json"
.asFileHandle()
.read("json")
.then (v) =>
v.text = v.name
v.path = "#{meta.root}/build/debug"
v.filename = meta.name
v.type = "app"
v.mime = "antos/app"
v.icon = "#{v.path}/#{v.icon}" if v.icon
v.iconclass = "fa fa-adn" unless v.iconclass or v.icon
@notify __("Installing...")
@app.systemsetting.system.packages[meta.name] = v
@notify __("Running {0}...", meta.name)
@app._gui.forceLaunch meta.name
cat: (list, data) ->
new Promise (resolve, reject) =>
return resolve data if list.length is 0
file = (list.splice 0, 1)[0].asFileHandle()
file
.read()
.then (text) =>
data = data + "\n" + text
@cat list, data
.then (d) -> resolve d
.catch (e) -> reject e
.catch (e) -> reject e
copy: (files, to) ->
new Promise (resolve, reject) =>
return resolve() if files.length is 0
file = (files.splice 0, 1)[0].asFileHandle()
tof = "#{to}/#{file.basename}".asFileHandle()
file.read("binary")
.then (data) =>
tof.setCache(new Blob [data], { type: file.info.mime })
.write(file.info.mime)
.then (d) =>
@copy files, to
.then () -> resolve()
.catch (e) -> reject e
.catch (e) -> reject e
mkar: (meta) ->
@notify __("Preparing for release")
new Promise (r, e) =>
@import("os://scripts/jszip.min.js").then () ->
"#{meta.root}/build/debug".asFileHandle()
.read().then (d) ->
return e d.error if d.error
r d.result
.catch (ex) -> e ex
.catch (ex) -> e ex
.then (files) =>
new Promise (r, e) =>
zip = new JSZip()
fn = (list) =>
return r zip if list.length is 0
f = (list.splice 0, 1)[0].path.asFileHandle()
return fn list if f.type is "dir"
f.read("binary").then (d) =>
zip.file f.basename, d, { binary: true }
@notify __("add {0} to zip", f.basename)
fn list
.catch (ex) -> e ex
fn files
.then (zip) =>
zip.generateAsync({ type: "base64" }).then (data) =>
"#{meta.root}/build/release/#{meta.name}.zip"
.asFileHandle()
.setCache('data:application/zip;base64,' + data)
.write("base64").then (r) =>
return @error __("Cannot save the zip file: {0}", r.error) if r.error
@notify __("Package is generated in release folder")
.catch (e) => @error e.toString()
.catch (e) => @error e.toString()

View File

@ -13,7 +13,6 @@ class CodePad extends this.OS.GUI.BaseApplication
@currdir = @currfile.parent()
main: () ->
me = @
@extensions = {}
@fileview = @find("fileview")
@sidebar = @find("sidebar")
@ -27,12 +26,10 @@ class CodePad extends this.OS.GUI.BaseApplication
dir = path.asFileHandle() if typeof path is "string"
dir.read().then (d) ->
return reject d.error if d.error
me.currdir = dir
resolve d.result
@setup()
setup: () ->
me = @
ace.config.set('basePath', '/scripts/ace')
ace.require "ace/ext/language_tools"
@editor = ace.edit @find("datarea")
@ -50,56 +47,56 @@ class CodePad extends this.OS.GUI.BaseApplication
@editor.completers.push { getCompletions: ( editor, session, pos, prefix, callback ) -> }
@editor.getSession().setUseWrapMode true
@editormux = false
@editor.on "input", () ->
if me.editormux
me.editormux = false
@editor.on "input", () =>
if @editormux
@editormux = false
return false
if not me.currfile.dirty
me.currfile.dirty = true
me.currfile.text += "*"
me.tabbar.update()
@editor.getSession().selection.on "changeCursor", (e) ->
me.updateStatus()
if not @currfile.dirty
@currfile.dirty = true
@currfile.text += "*"
@tabbar.update()
@editor.getSession().selection.on "changeCursor", (e) =>
@updateStatus()
@tabbar.set "ontabselect", (e) ->
me.selecteTab $(e.data.item).index()
@tabbar.set "ontabclose", (e) ->
@tabbar.set "ontabselect", (e) =>
@selecteTab $(e.data.item).index()
@tabbar.set "ontabclose", (e) =>
it = e.data.item
return false unless it
return me.closeTab it unless it.get("data").dirty
me.openDialog("YesNoDialog", {
return @closeTab it unless it.get("data").dirty
@openDialog("YesNoDialog", {
title: __("Close tab"),
text: __("Close without saving ?")
}).then (d) ->
return me.closeTab it if d
me.editor.focus()
}).then (d) =>
return @closeTab it if d
@editor.focus()
return false
@fileview.set "onfileopen", (e) ->
@fileview.set "onfileopen", (e) =>
return if e.data.type is "dir"
me.openFile e.data.path.asFileHandle()
@openFile e.data.path.asFileHandle()
@fileview.set "onfileselect", (e) ->
@fileview.set "onfileselect", (e) =>
return unless e.data or e.data.type is "dir"
i = me.findTabByFile e.data.path.asFileHandle()
return me.tabbar.set "selected", i if i isnt -1
i = @findTabByFile e.data.path.asFileHandle()
return @tabbar.set "selected", i if i isnt -1
@on "resize", () -> me.editor.resize()
@on "focus", () -> me.editor.focus()
@on "resize", () => @editor.resize()
@on "focus", () => @editor.focus()
@spotlight = new CMDMenu __("Command palette")
@bindKey "ALT-P", () -> me.spotlight.run me
@find("datarea").contextmenuHandle = (e, m) ->
@bindKey "ALT-P", () => @spotlight.run @
@find("datarea").contextmenuHandle = (e, m) =>
m.set "items", [{
text: __("Command palete"),
onmenuselect: (e) ->
me.spotlight.run me
onmenuselect: (e) =>
@spotlight.run @
}]
m.show e
@bindKey "ALT-N", () -> me.menuAction "new"
@bindKey "ALT-O", () -> me.menuAction "open"
@bindKey "ALT-F", () -> me.menuAction "opendir"
@bindKey "CTRL-S", () -> me.menuAction "save"
@bindKey "ALT-W", () -> me.menuAction "saveas"
@bindKey "ALT-N", () => @menuAction "new"
@bindKey "ALT-O", () => @menuAction "open"
@bindKey "ALT-F", () => @menuAction "opendir"
@bindKey "CTRL-S", () => @menuAction "save"
@bindKey "ALT-W", () => @menuAction "saveas"
@loadExtensionMetaData()
@initCommandPalete()
@ -112,13 +109,13 @@ class CodePad extends this.OS.GUI.BaseApplication
i = @findTabByFile file
return @tabbar.set "selected", i if i isnt -1
return @newTab file if file.path.toString() is "Untitled"
me = @
file.read()
.then (d) ->
.then (d) =>
file.cache = d or ""
me.newTab file
.catch (e) ->
me.error __("Unable to open: {0}", file.path)
@newTab file
.catch (e) =>
@error __("Unable to open: {0}", file.path)
findTabByFile: (file) ->
lst = @tabbar.get "items"
@ -218,38 +215,35 @@ class CodePad extends this.OS.GUI.BaseApplication
@addAction CMDMenu.fromMenu @fileMenu()
loadExtensionMetaData: () ->
me = @
"#{@meta().path}/extensions.json"
.asFileHandle()
.read("json")
.then (d) ->
.then (d) =>
for ext in d
if me.extensions[ext.name]
me.extensions[ext.name].child = {}
me.extensions[ext.name].addAction v for v in ext.actions
if @extensions[ext.name]
@extensions[ext.name].child = {}
@extensions[ext.name].addAction v for v in ext.actions
else
me.extensions[ext.name] = new CMDMenu ext.text
me.extensions[ext.name].name = ext.name
me.extensions[ext.name].addAction v for v in ext.actions
me.spotlight.addAction me.extensions[ext.name]
me.extensions[ext.name].onchildselect (e) ->
me.loadAndRunExtensionAction e.data.item.get "data"
.catch (e) ->
me.error __("Cannot load extension meta data")
@extensions[ext.name] = new CMDMenu ext.text
@extensions[ext.name].name = ext.name
@extensions[ext.name].addAction v for v in ext.actions
@spotlight.addAction @extensions[ext.name]
@extensions[ext.name].onchildselect (e) =>
@loadAndRunExtensionAction e.data.item.get "data"
.catch (e) =>
@error __("Cannot load extension meta data")
runExtensionAction: (name, action) ->
me = @
return @error __("Unable to find extension: {0}", name) unless CodePad.extensions[name]
ext = new CodePad.extensions[name](me)
ext = new CodePad.extensions[name](@)
return @error __("Unable to find action: {0}", action) unless ext[action]
ext.preload()
.then () ->
ext[action]()
.catch (e) ->
me.error e.stack
.catch (e) =>
@error e.stack
loadAndRunExtensionAction: (data) ->
me = @
name = data.parent.name
action = data.name
#verify if the extension is load
@ -257,14 +251,13 @@ class CodePad extends this.OS.GUI.BaseApplication
#load the extension
path = "#{@meta().path}/extensions/#{name}.js"
@_api.requires path
.then () -> me.runExtensionAction name, action
.catch (e) ->
me.error __("unable to load extension: {}", name)
.then () => @runExtensionAction name, action
.catch (e) =>
@error __("unable to load extension: {}", name)
else
@runExtensionAction name, action
fileMenu: () ->
me = @
{
text: __("File"),
child: [
@ -274,35 +267,33 @@ class CodePad extends this.OS.GUI.BaseApplication
{ text: __("Save"), dataid: "save", shortcut: "C-S" },
{ text: __("Save as"), dataid: "saveas", shortcut: "A-W" }
],
onchildselect: (e, r) ->
me.menuAction e.data.item.get("data").dataid, r
onchildselect: (e, r) =>
@menuAction e.data.item.get("data").dataid, r
}
save: (file) ->
me = @
file.write("text/plain")
.then (d) ->
return me.error __("Error saving file {0}: {1}", file.basename, d.error) if d.error
.then (d) =>
return @error __("Error saving file {0}: {1}", file.basename, d.error) if d.error
file.dirty = false
file.text = file.basename
me.tabbar.update()
me.scheme.set "apptitle", "#{me.currfile.basename}"
.catch (e) -> me.error e.stack
@tabbar.update()
@scheme.set "apptitle", "#{@currfile.basename}"
.catch (e) => @error e.stack
saveAs: () ->
me = @
me.openDialog("FileDialog", {
@openDialog("FileDialog", {
title: __("Save as"),
file: me.currfile
file: @currfile
})
.then (f) ->
.then (f) =>
d = f.file.path.asFileHandle()
d = d.parent() if f.file.type is "file"
me.currfile.setPath "#{d.path}/#{f.name}"
me.save me.currfile
.catch (e) ->
me.error e.stack
@currfile.setPath "#{d.path}/#{f.name}"
@save @currfile
.catch (e) =>
@error e.stack
menuAction: (dataid, r) ->
me = @
@ -338,18 +329,16 @@ class CodePad extends this.OS.GUI.BaseApplication
cleanup: (evt) ->
dirties = ( v for v in @tabbar.get "items" when v.dirty )
return if dirties.length is 0
me = @
evt.preventDefault()
@.openDialog("YesNoDialog", {
title: "__(Quit)",
text: __("Ignore all {0} unsaved files ?", dirties.length)
}).then (d) ->
}).then (d) =>
if d
v.dirty = false for v in dirties
me.quit()
@quit()
menu: () ->
me = @
menu = [
@fileMenu()
{
@ -357,8 +346,8 @@ class CodePad extends this.OS.GUI.BaseApplication
child: [
{ text: "__(Command Palette)", dataid: "cmdpalette", shortcut: "A-P" }
],
onchildselect: (e, r) ->
me.spotlight.run me
onchildselect: (e, r) =>
@spotlight.run @
}
]
menu
@ -368,8 +357,10 @@ class CodePad.BaseExtension
constructor: (@app) ->
preload: () ->
dep = ( "#{@basedir()}/#{v}" for v in @dependencies())
Ant.OS.API.require dep
Ant.OS.API.require @dependencies()
import: (lib) ->
Ant.OS.API.requires lib
basedir: () ->
"#{@app.meta().path}/extensions"
@ -402,12 +393,11 @@ class CMDMenu
@
run: (root) ->
me = @
root.openDialog(new CommandPalette(), @)
.then (d) ->
.then (d) =>
data = d.data.item.get("data")
return data.run root if data.run
me.select d, root
@select d, root
CMDMenu.fromMenu = (mn) ->
m = new CMDMenu mn.text, mn.shortcut

View File

@ -14,15 +14,11 @@
},
{
"text": "__(Build and Run)",
"name": "build"
"name": "buildnrun"
},
{
"text": "__(Build release)",
"name": "release"
},
{
"text": "__(Build options)",
"name": "options"
}
]
}

View File

@ -23,11 +23,10 @@ class Calendar extends this.OS.GUI.BaseService
@iconclass = "fa fa-calendar"
init: ->
#update time each second
me = @
@watch 1000, () ->
@watch 1000, () =>
now = new Date
me.text = now.toString()
me.domel.set "text", me.text
@text = now.toString()
@domel.set "text", @text
awake: (e) ->

View File

@ -37,27 +37,26 @@ class PushNotification extends this.OS.GUI.BaseService
@update()
main: ->
me = @
@mlist = @find "notifylist"
@mfeed = @find "notifeed"
@nzone = @find "notifyzone"
@fzone = @find "feedzone"
(@find "btclear").set "onbtclick", (e) -> me.mlist.set "data", []
(@find "btclear").set "onbtclick", (e) => @mlist.set "data", []
#@subscribe "fail", (e) -> console.log e
@subscribe "notification", (o) -> me.pushout 'INFO', o
@subscribe "fail", (o) -> me.pushout 'FAIL', o
@subscribe "error", (o) -> me.pushout 'ERROR', o
@subscribe "info", (o) -> me.pushout 'INFO', o
@subscribe "VFS", (o) -> me.pushout 'INFO', o
@subscribe "notification", (o) => @pushout 'INFO', o
@subscribe "fail", (o) => @pushout 'FAIL', o
@subscribe "error", (o) => @pushout 'ERROR', o
@subscribe "info", (o) => @pushout 'INFO', o
#@subscribe "VFS", (o) => @pushout 'INFO', o
@subscribe "loading", (o) ->
me.pending.push o.id
me.spin true
@subscribe "loading", (o) =>
@pending.push o.id
@spin true
@subscribe "loaded", (o) ->
i = me.pending.indexOf o.id
me.pending.splice i, 1 if i >= 0
me.spin false if me.pending.length is 0
@subscribe "loaded", (o) =>
i = @pending.indexOf o.id
@pending.splice i, 1 if i >= 0
@spin false if @pending.length is 0
@nzone.set "height", "100%"
@fzone.set "height", "100%"
@ -83,25 +82,23 @@ class PushNotification extends this.OS.GUI.BaseService
@notifeed d
notifeed: (d) ->
me = @
@mfeed.unshift d, true
($ @fzone).show()
timer = setTimeout () ->
me.mfeed.remove d.domel
($ me.fzone).hide() if me.mfeed.get("data").length is 0
timer = setTimeout () =>
@mfeed.remove d.domel
($ @fzone).hide() if @mfeed.get("data").length is 0
clearTimeout timer
, 3000
awake: (evt) ->
if @view then ($ @nzone).hide() else ($ @nzone).show()
@view = not @view
me = @
if not @cb
@cb = (e) ->
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
@cb = (e) =>
if not ($ e.target).closest($ @nzone).length and not ($ e.target).closest(evt.data.item).length
($ @nzone).hide()
$(document).unbind "click", @cb
@view = not @view
if @view
$(document).on "click", @cb
else

View File

@ -21,7 +21,6 @@ class Files extends this.OS.GUI.BaseApplication
super "Files", args
main: () ->
me = @
@scheme.set "apptitle", "Files manager"
@view = @find "fileview"
@navinput = @find "navinput"
@ -34,54 +33,55 @@ class Files extends this.OS.GUI.BaseApplication
@clipboard = undefined
@viewType = @_api.switcher "icon", "list", "tree"
@viewType.list = true
@apps = []
@view.contextmenuHandle = (e, m) ->
m.set "items", [ me.mnFile(), me.mnEdit() ]
# Fix m.set "onmenuselect", (evt) ->
# me._gui.launch evt.item.data.app, evt.item.data.args if evt.item.data.app
@view.contextmenuHandle = (e, m) =>
file = @view.get "selectedFile"
apps = []
if file and file.mime
file.mime = "dir" if file.type is "dir"
for v in @_gui.appsByMime file.mime
v.args = [ file.path ]
apps.push v
m.set "items", [
{ text: "__(Open with)", dataid: "#{@name}-open", child: apps },
@mnFile(),
@mnEdit()
]
m.show e
@view.set "onfileopen", (e) ->
@view.set "onfileopen", (e) =>
return unless e.data
return if e.data.type is "dir"
me._gui.openWith e.data
@_gui.openWith e.data
@favo.set "onlistselect", (e) ->
me.view.set "path", e.data.item.get("data").path
@favo.set "onlistselect", (e) =>
@view.set "path", e.data.item.get("data").path
($ @find "btback").click () ->
return if me.currdir.isRoot()
p = me.currdir.parent()
me.favo.set "selected", -1
me.view.set "path", p.path
($ @find "btback").click () =>
return if @currdir.isRoot()
p = @currdir.parent()
@favo.set "selected", -1
@view.set "path", p.path
($ @navinput).keyup (e) ->
me.view.set "path", ($ me.navinput).val() if e.keyCode is 13 #enter
($ @navinput).keyup (e) =>
@view.set "path", ($ @navinput).val() if e.keyCode is 13 #enter
@view.set "fetch", (path) ->
new Promise (resolve, reject) ->
@view.set "fetch", (path) =>
new Promise (resolve, reject) =>
dir = path
dir = path.asFileHandle() if typeof path is "string"
dir.read().then (d) ->
dir.read().then (d) =>
return reject d.error if d.error
if not dir.isRoot()
p = dir.parent()
p.filename = "[..]"
p.type = "dir"
d.result.unshift p
me.currdir = dir
($ me.navinput).val dir.path
@currdir = dir
($ @navinput).val dir.path
resolve d.result
@view.set "onfileselect", (e) ->
file = e.data
return unless file and file.mime
file.mime = "dir" if file.type is "dir"
me.apps.length = 0
for v in me._gui.appsByMime file.mime
v.args = [ file.path ]
me.apps.push v
@setting.sidebar = true if @setting.sidebar is undefined
@setting.nav = true if @setting.nav is undefined
@setting.showhidden = false if @setting.showhidden is undefined
@ -92,29 +92,29 @@ class Files extends this.OS.GUI.BaseApplication
@favo.set "data", mntpoints
#@favo.set "selected", -1
@view.set "view", @setting.view if @setting.view
@subscribe "VFS", (d) ->
@subscribe "VFS", (d) =>
return if ["read", "publish", "download"].includes d.data.m
if d.data.file.hash() is me.currdir.hash() or d.data.file.parent().hash() is me.currdir.hash()
me.view.set "path", me.currdir
@bindKey "CTRL-F", () -> me.actionFile "#{me.name}-mkf"
@bindKey "CTRL-D", () -> me.actionFile "#{me.name}-mkdir"
@bindKey "CTRL-U", () -> me.actionFile "#{me.name}-upload"
@bindKey "CTRL-S", () -> me.actionFile "#{me.name}-share"
@bindKey "CTRL-I", () -> me.actionFile "#{me.name}-info"
if d.data.file.hash() is @currdir.hash() or d.data.file.parent().hash() is @currdir.hash()
@view.set "path", @currdir
@bindKey "CTRL-F", () => @actionFile "#{@name}-mkf"
@bindKey "CTRL-D", () => @actionFile "#{@name}-mkdir"
@bindKey "CTRL-U", () => @actionFile "#{@name}-upload"
@bindKey "CTRL-S", () => @actionFile "#{@name}-share"
@bindKey "CTRL-I", () => @actionFile "#{@name}-info"
@bindKey "CTRL-R", () -> me.actionEdit "#{me.name}-mv"
@bindKey "CTRL-M", () -> me.actionEdit "#{me.name}-rm"
@bindKey "CTRL-X", () -> me.actionEdit "#{me.name}-cut"
@bindKey "CTRL-C", () -> me.actionEdit "#{me.name}-copy"
@bindKey "CTRL-P", () -> me.actionEdit "#{me.name}-paste"
@bindKey "CTRL-R", () => @actionEdit "#{@name}-mv"
@bindKey "CTRL-M", () => @actionEdit "#{@name}-rm"
@bindKey "CTRL-X", () => @actionEdit "#{@name}-cut"
@bindKey "CTRL-C", () => @actionEdit "#{@name}-copy"
@bindKey "CTRL-P", () => @actionEdit "#{@name}-paste"
(@find "btgrid").set "onbtclick", (e) ->
me.view.set 'view', "icon"
me.viewType.icon = true
(@find "btgrid").set "onbtclick", (e) =>
@view.set 'view', "icon"
@viewType.icon = true
(@find "btlist").set "onbtclick", (e) ->
me.view.set 'view', "list"
me.viewType.list = true
(@find "btlist").set "onbtclick", (e) =>
@view.set 'view', "list"
@viewType.list = true
@view.set "path", @currdir
applySetting: (k) ->
@ -126,22 +126,19 @@ class Files extends this.OS.GUI.BaseApplication
mnFile: () ->
#console.log file
me = @
arr = {
text: "__(File)",
child: [
{ text: "__(New file)", dataid: "#{@name}-mkf", shortcut: 'C-F' },
{ text: "__(New folder)", dataid: "#{@name}-mkdir", shortcut: 'C-D' },
{ text: "__(Open with)", dataid: "#{@name}-open", child: @apps },
{ text: "__(Upload)", dataid: "#{@name}-upload", shortcut: 'C-U' },
{ text: "__(Download)", dataid: "#{@name}-download" },
{ text: "__(Share file)", dataid: "#{@name}-share", shortcut: 'C-S' },
{ text: "__(Properties)", dataid: "#{@name}-info", shortcut: 'C-I' }
], onchildselect: (e) -> me.actionFile e.data.item.get("data").dataid
], onchildselect: (e) => @actionFile e.data.item.get("data").dataid
}
return arr
mnEdit: () ->
me = @
{
text: "__(Edit)",
child: [
@ -150,10 +147,10 @@ class Files extends this.OS.GUI.BaseApplication
{ text: "__(Cut)", dataid: "#{@name}-cut", shortcut: 'C-X' },
{ text: "__(Copy)", dataid: "#{@name}-copy", shortcut: 'C-C' },
{ text: "__(Paste)", dataid: "#{@name}-paste", shortcut: 'C-P' }
], onchildselect: (e) -> me.actionEdit e.data.item.get("data").dataid
], onchildselect: (e) => @actionEdit e.data.item.get("data").dataid
}
menu: () ->
me = @
menu = [
@mnFile(),
@mnEdit(),
@ -165,15 +162,15 @@ class Files extends this.OS.GUI.BaseApplication
{ text: "__(Navigation bar)", switch: true, checked: @setting.nav, dataid: "#{@name}-nav" },
{ text: "__(Hidden files)", switch: true, checked: @setting.showhidden, dataid: "#{@name}-hidden" },
{ text: "__(Type)", child: [
{ text: "__(Icon view)", radio: true, checked: me.viewType.icon, dataid: "#{@name}-icon", type: 'icon' },
{ text: "__(List view)", radio:true, checked: me.viewType.list, dataid: "#{@name}-list", type: 'list' },
{ text: "__(Tree view)", radio:true, checked: me.viewType.tree, dataid: "#{@name}-tree", type: 'tree' }
], onchildselect: (e) ->
{ text: "__(Icon view)", radio: true, checked: @viewType.icon, dataid: "#{@name}-icon", type: 'icon' },
{ text: "__(List view)", radio:true, checked: @viewType.list, dataid: "#{@name}-list", type: 'list' },
{ text: "__(Tree view)", radio:true, checked: @viewType.tree, dataid: "#{@name}-tree", type: 'tree' }
], onchildselect: (e) =>
type = e.data.item.get("data").type
me.view.set 'view', type
me.viewType[type] = true
@view.set 'view', type
@viewType[type] = true
},
], onchildselect: (e) -> me.actionView e
], onchildselect: (e) => @actionView e
},
]
menu
@ -205,7 +202,6 @@ class Files extends this.OS.GUI.BaseApplication
#@toggleNav e.item.data.checked
actionEdit: (e) ->
me = @
file = @view.get "selectedFile"
switch e
when "#{@name}-mv"
@ -215,14 +211,14 @@ class Files extends this.OS.GUI.BaseApplication
label: "__(File name)",
value: file.filename
})
.then (d) ->
.then (d) =>
return if d is file.filename
file.path.asFileHandle().move "#{me.currdir.path}/#{d}"
.then (r) ->
me.error __("Fail to rename to {0}: {1}", d, r.error) if r.error
.catch (e) ->
file.path.asFileHandle().move "#{@currdir.path}/#{d}"
.then (r) =>
@error __("Fail to rename to {0}: {1}", d, r.error) if r.error
.catch (e) =>
console.log e
me.error __("Fail to rename: {0}", e.stack)
@error __("Fail to rename: {0}", e.stack)
when "#{@name}-rm"
return unless file
@ -231,13 +227,13 @@ class Files extends this.OS.GUI.BaseApplication
iconclass: "fa fa-question-circle",
text: __("Do you really want to delete: {0}?", file.filename)
})
.then (d) ->
.then (d) =>
return unless d
file.path.asFileHandle().remove()
.then (r) ->
me.error __("Fail to delete {0}: {1}", file.filename, r.error) if r.error
.catch (e) ->
me.error __("Fail to delete: {0}", e.stack)
.then (r) =>
@error __("Fail to delete {0}: {1}", file.filename, r.error) if r.error
.catch (e) =>
@error __("Fail to delete: {0}", e.stack)
when "#{@name}-cut"
return unless file
@ -254,32 +250,30 @@ class Files extends this.OS.GUI.BaseApplication
@notify __("File {0} copied", file.filename)
when "#{@name}-paste"
me = @
return unless @clipboard
if @clipboard.cut
@clipboard.file.move "#{me.currdir.path}/#{@clipboard.file.basename}"
.then (r) ->
me.clipboard = undefined
me.error __("Fail to paste: {0}", r.error) if r.error
.catch (e) ->
me.error __("Fail to paste: {0}", e.stack)
@clipboard.file.move "#{@currdir.path}/#{@clipboard.file.basename}"
.then (r) =>
@clipboard = undefined
@error __("Fail to paste: {0}", r.error) if r.error
.catch (e) =>
@error __("Fail to paste: {0}", e.stack)
else
@clipboard.file.read("binary")
.then (d) ->
blob = new Blob [d], { type: me.clipboard.file.info.mime }
fp = "#{me.currdir.path}/#{me.clipboard.file.basename}".asFileHandle()
.then (d) =>
blob = new Blob [d], { type: @clipboard.file.info.mime }
fp = "#{@currdir.path}/#{@clipboard.file.basename}".asFileHandle()
fp.cache = blob
fp.write(me.clipboard.file.info.mime)
.then (r) ->
me.clipboard = undefined
me.error __("Fail to paste: {0}", r.error) if r.error
.catch (e) ->
me.error __("Fail to paste: {0}", e.stack)
fp.write(@clipboard.file.info.mime)
.then (r) =>
@clipboard = undefined
@error __("Fail to paste: {0}", r.error) if r.error
.catch (e) =>
@error __("Fail to paste: {0}", e.stack)
else
@_api.handle.setting()
actionFile: (e) ->
me = @
file = @view.get "selectedFile"
switch e
when "#{@name}-mkdir"
@ -287,53 +281,51 @@ class Files extends this.OS.GUI.BaseApplication
title: "__(New folder)",
label: "__(Folder name)"
})
.then (d) ->
me.currdir.mk(d)
.then (r) ->
me.error __("Fail to create {0}: {1}", d, r.error) if r.error
.catch (e) ->
me.error __("Fail to create: {0}", e.stack)
.then (d) =>
@currdir.mk(d)
.then (r) =>
@error __("Fail to create {0}: {1}", d, r.error) if r.error
.catch (e) =>
@error __("Fail to create: {0}", e.stack)
when "#{@name}-mkf"
@openDialog("PromptDialog", {
title: "__(New file)",
label: "__(File name)"
})
.then (d) ->
fp = "#{me.currdir.path}/#{d}".asFileHandle()
.then (d) =>
fp = "#{@currdir.path}/#{d}".asFileHandle()
fp.write("text/plain")
.then (r) ->
me.error __("Fail to create {0}: {1}", d, r.error) if r.error
.catch (e) ->
me.error __("Fail to create: {0}", e.stack)
.then (r) =>
@error __("Fail to create {0}: {1}", d, r.error) if r.error
.catch (e) =>
@error __("Fail to create: {0}", e.stack)
when "#{@name}-info"
return unless file
@openDialog "InfoDialog", file
when "#{@name}-upload"
me = @
@currdir.upload()
.then (r) ->
me.error __("Fail to upload to {0}: {1}", me.currdir.path, r.error) if r.error
.catch (e) ->
me.error __("Fail to upload: {0}", e.stack)
.then (r) =>
@error __("Fail to upload to {0}: {1}", @currdir.path, r.error) if r.error
.catch (e) =>
@error __("Fail to upload: {0}", e.stack)
when "#{@name}-share"
me = @
return unless file and file.type is "file"
file.path.asFileHandle().publish()
.then (r) ->
return me.error __("Cannot share file: {0}", r.error) if r.error
return me.notify __("Shared url: {0}", r.result)
.catch (e) ->
me.error __("Fail to publish: {0}", e.stack)
.then (r) =>
return @error __("Cannot share file: {0}", r.error) if r.error
return @notify __("Shared url: {0}", r.result)
.catch (e) =>
@error __("Fail to publish: {0}", e.stack)
when "#{@name}-download"
return unless file.type is "file"
file.path.asFileHandle().download()
.catch (e) ->
me.error __("Fail to download: {0}", e.stack)
.catch (e) =>
@error __("Fail to download: {0}", e.stack)
else
console.log e

View File

@ -19,53 +19,52 @@
class AppearanceHandle extends SettingHandle
constructor:(scheme, parent) ->
super(scheme, parent)
me = @
@wplist = @find "wplist"
@wpreview = @find "wp-preview"
@wpsize = @find "wpsize"
@wprepeat = @find "wprepeat"
@themelist = @find "theme-list"
@syswp = undefined
@wplist.set "onlistselect", (e) ->
@wplist.set "onlistselect", (e) =>
data = e.data.item.get("data")
$(me.wpreview)
$(@wpreview)
.css("background-image", "url(#{data.path.asFileHandle().getlink()})" )
.css("background-size", "cover")
me.parent.systemsetting.appearance.wp.url = data.path
me.parent._gui.wallpaper()
@parent.systemsetting.appearance.wp.url = data.path
@parent._gui.wallpaper()
@wplist.set "buttons", [
{
text: "+", onbtclick: (e) ->
me.parent.openDialog("FileDialog", {
text: "+", onbtclick: (e) =>
@parent.openDialog("FileDialog", {
title: __("Select image file"),
mimes: ["image/.*"]
}).then (d) ->
me.parent.systemsetting.appearance.wps.push d.file.path
me.wplist.set "data", me.getwplist()
}).then (d) =>
@parent.systemsetting.appearance.wps.push d.file.path
@wplist.set "data", @getwplist()
}
]
@wpsize.set "onlistselect", (e) ->
me.parent.systemsetting.appearance.wp.size = e.data.item.get("data").text
me.parent._gui.wallpaper()
@wpsize.set "onlistselect", (e) =>
@parent.systemsetting.appearance.wp.size = e.data.item.get("data").text
@parent._gui.wallpaper()
sizes = [
{ text: "cover", selected: me.parent.systemsetting.appearance.wp.size is "cover" },
{ text: "auto", selected: me.parent.systemsetting.appearance.wp.size is "auto" },
{ text: "contain", selected: me.parent.systemsetting.appearance.wp.size is "contain" }
{ text: "cover", selected: @parent.systemsetting.appearance.wp.size is "cover" },
{ text: "auto", selected: @parent.systemsetting.appearance.wp.size is "auto" },
{ text: "contain", selected: @parent.systemsetting.appearance.wp.size is "contain" }
]
@wpsize.set "data", sizes
repeats = [
{ text: "repeat", selected: me.parent.systemsetting.appearance.wp.repeat is "repeat" },
{ text: "repeat-x", selected: me.parent.systemsetting.appearance.wp.repeat is "repeat-x" },
{ text: "repeat-y", selected: me.parent.systemsetting.appearance.wp.repeat is "repeat-y" },
{ text: "no-repeat", selected: me.parent.systemsetting.appearance.wp.repeat is "no-repeat" }
{ text: "repeat", selected: @parent.systemsetting.appearance.wp.repeat is "repeat" },
{ text: "repeat-x", selected: @parent.systemsetting.appearance.wp.repeat is "repeat-x" },
{ text: "repeat-y", selected: @parent.systemsetting.appearance.wp.repeat is "repeat-y" },
{ text: "no-repeat", selected: @parent.systemsetting.appearance.wp.repeat is "no-repeat" }
]
@wprepeat.set "onlistselect", (e) ->
me.parent.systemsetting.appearance.wp.repeat = e.data.item.get("data").text
me.parent._gui.wallpaper()
@wprepeat.set "onlistselect", (e) =>
@parent.systemsetting.appearance.wp.repeat = e.data.item.get("data").text
@parent._gui.wallpaper()
@wprepeat.set "data", repeats
@themelist.set "data" , [{ text: "antos", selected: true }]
@ -73,17 +72,17 @@ class AppearanceHandle extends SettingHandle
if not @syswp
path = "os://resources/themes/system/wp"
path.asFileHandle().read()
.then (d) ->
return me.parent.error __("Cannot read wallpaper list from {0}", path) if d.error
.then (d) =>
return @parent.error __("Cannot read wallpaper list from {0}", path) if d.error
for v in d.result
v.text = v.filename
v.iconclass = "fa fa-file-image-o"
me.syswp = d.result
me.wplist.set "data", me.getwplist()
.catch (e) -> me.parent.error e.stack
@syswp = d.result
@wplist.set "data", @getwplist()
.catch (e) => @parent.error e.stack
else
me.wplist.set "data", me.getwplist()
@wplist.set "data", @getwplist()
getwplist: () ->
list = []

View File

@ -19,21 +19,20 @@
class LocaleHandle extends SettingHandle
constructor: (scheme, parent) ->
super(scheme, parent)
me = @
@lglist = @find "lglist"
@localelist = undefined
@lglist.set "onlistselect", (e) ->
me.parent._api.setLocale e.data.item.get("data").text
@lglist.set "onlistselect", (e) =>
@parent._api.setLocale e.data.item.get("data").text
if not @localelist
path = "os://resources/languages"
path.asFileHandle().read()
.then (d) ->
return me.parent.error __("Cannot fetch system locales: {0}", d.error) if d.derror
.then (d) =>
return @parent.error __("Cannot fetch system locales: {0}", d.error) if d.derror
for v in d.result
v.text = v.filename.replace /\.json$/g, ""
v.selected = v.text is me.parent.systemsetting.system.locale
me.localelist = d.result
me.lglist.set "data", me.localelist
.catch (e) -> me.parent.error e.stack
v.selected = v.text is @parent.systemsetting.system.locale
@localelist = d.result
@lglist.set "data", @localelist
.catch (e) => @parent.error e.stack
else
me.lglist.set "data", me.localelist
@lglist.set "data", @localelist

View File

@ -19,52 +19,51 @@
class StartupHandle extends SettingHandle
constructor: (scheme, parent) ->
super(scheme, parent)
me = @
@srvlist = @find "srvlist"
@applist = @find "applist"
@srvlist.set "buttons", [
{
text: "+", onbtclick: (e) ->
text: "+", onbtclick: (e) =>
services = []
for k, v of me.parent.systemsetting.system.packages
for k, v of @parent.systemsetting.system.packages
if v.services
srvs = ({ text: "#{k}/#{x}", iconclass: "fa fa-tasks" } for x in v.services)
services = services.concat srvs
me.parent.openDialog("SelectionDialog", {
@parent.openDialog("SelectionDialog", {
title: "__(Add service)",
data: services
}).then (d) ->
me.parent.systemsetting.system.startup.services.push d.text
me.refresh()
}).then (d) =>
@parent.systemsetting.system.startup.services.push d.text
@refresh()
},
{
text: "-", onbtclick: (e) ->
item = me.srvlist.get "selectedItem"
text: "-", onbtclick: (e) =>
item = @srvlist.get "selectedItem"
return unless item
selidx = $(item).index()
me.parent.systemsetting.system.startup.services.splice selidx, 1
me.refresh()
@parent.systemsetting.system.startup.services.splice selidx, 1
@refresh()
}
]
@applist.set "buttons", [
{
text: "+", onbtclick: (e) ->
apps = ( { text: k, iconclass: v.iconclass } for k, v of me.parent.systemsetting.system.packages )
me.parent.openDialog("SelectionDialog", {
text: "+", onbtclick: (e) =>
apps = ( { text: k, iconclass: v.iconclass } for k, v of @parent.systemsetting.system.packages )
@parent.openDialog("SelectionDialog", {
title: "__(Add application)",
data: apps
}).then (d) ->
me.parent.systemsetting.system.startup.apps.push d.text
me.refresh()
}).then (d) =>
@parent.systemsetting.system.startup.apps.push d.text
@refresh()
},
{
text: "-", onbtclick: (e) ->
item = me.applist.get "selectedItem"
text: "-", onbtclick: (e) =>
item = @applist.get "selectedItem"
return unless item
selidx = $(item).index()
me.parent.systemsetting.system.startup.apps.splice selidx, 1
me.refresh()
@parent.systemsetting.system.startup.apps.splice selidx, 1
@refresh()
}
]
@refresh()
@ -72,30 +71,3 @@ class StartupHandle extends SettingHandle
refresh: () ->
@srvlist.set "data", ( { text:v } for v in @parent.systemsetting.system.startup.services )
@applist.set "data", ( { text:v } for v in @parent.systemsetting.system.startup.apps )
mkdialog: () ->
return @parent._gui.mkdialog {
name: "StartupDialog",
layout: {
tags: [
{ tag: "afx-list-view" }
],
width: 250,
height: 200,
resizable: false,
buttons: [
{
label: "__(Ok)", onclick: (d) ->
sel = (d.find "content0").get "selected"
return d.error __("Please select an entry") unless sel
d.handler(sel.text) if d.handler
d.quit()
},
{ label: "__(Cancel)", onclick: (d) -> d.quit() }
],
filldata: (dia) ->
(dia.find "content0").set "items", dia.data if dia.data
}
}

View File

@ -21,28 +21,27 @@ class VFSSettingDialog extends this.OS.GUI.BasicDialog
super "VFSSettingDialog", VFSSettingDialog.scheme
init: () ->
me = @
$(@find("txtPath")).click (e) ->
me.openDialog("FileDialog", {
$(@find("txtPath")).click (e) =>
@openDialog("FileDialog", {
title: "__(Select a directory)",
mimes: ["dir"],
hidden: true
})
.then (d) ->
(me.find "txtPath").value = d.file.path
.then (d) =>
(@find "txtPath").value = d.file.path
@find("btnOk").set "onbtclick", (e) ->
@find("btnOk").set "onbtclick", (e) =>
data = {
path: (me.find "txtPath").value,
name: (me.find "txtName").value
path: (@find "txtPath").value,
name: (@find "txtName").value
}
return me.error __("Please enter mount point name") unless data.name and data.name isnt ""
return me .error __("Please select a directory") unless data.path and data.path isnt ""
me.handle(data) if me.handle
me.quit()
return @error __("Please enter mount point name") unless data.name and data.name isnt ""
return @error __("Please select a directory") unless data.path and data.path isnt ""
@handle(data) if @handle
@quit()
(@find "btnCancel").set "onbtclick", (e) ->
me.quit()
(@find "btnCancel").set "onbtclick", (e) =>
@quit()
return unless @data
(@find "txtName").value = @data.text if @data.text
@ -76,75 +75,73 @@ VFSSettingDialog.scheme = """
class VFSHandle extends SettingHandle
constructor: (scheme, parent) ->
super(scheme, parent)
me = @
@mplist = @find "mplist"
@dpath = @find "dpath"
@ppath = @find "ppath"
@mplist.set "buttons", [
{
text: "+",
onbtclick: (e) ->
me.parent.openDialog(new VFSSettingDialog(), {
onbtclick: (e) =>
@parent.openDialog(new VFSSettingDialog(), {
title: "__(Add mount point)"
})
.then (d) ->
me.parent.systemsetting.VFS.mountpoints.push {
.then (d) =>
@parent.systemsetting.VFS.mountpoints.push {
text: d.name, path: d.path, iconclass: "fa fa-folder", type: "fs"
}
me.refresh()
@refresh()
},
{
text: "-",
onbtclick: (e) ->
item = me.mplist.get "selectedItem"
onbtclick: (e) =>
item = @mplist.get "selectedItem"
return unless item
selidx = $(item).index()
me.parent.openDialog("YesNoDialog", {
@parent.openDialog("YesNoDialog", {
title: "__(Remove)",
text: __("Remove: {0}?", item.get("data").text)
}).then (d) ->
}).then (d) =>
return unless d
me.parent.systemsetting.VFS.mountpoints.splice selidx, 1
me.refresh()
@parent.systemsetting.VFS.mountpoints.splice selidx, 1
@refresh()
},
{
text: "",
iconclass: "fa fa-pencil",
onbtclick: (e) ->
sel = me.mplist.get "selectedItem"
onbtclick: (e) =>
sel = @mplist.get "selectedItem"
return unless sel
me.parent.openDialog(new VFSSettingDialog(), {
@parent.openDialog(new VFSSettingDialog(), {
title: "__(Edit mount point)",
text: sel.get("data").text,
path: sel.get("data").path
}).then (d) ->
}).then (d) =>
sel.get("data").text = d.name
sel.get("data").path = d.path
me.refresh()
@refresh()
}
]
(@find "btndpath").set 'onbtclick', (e) ->
me.parent.openDialog("FileDialog", {
(@find "btndpath").set 'onbtclick', (e) =>
@parent.openDialog("FileDialog", {
title: "__(Select a directory)",
mimes: ["dir"],
hidden: true
}).then (d) ->
me.parent.systemsetting.desktop.path = d.file.path
me.parent._gui.refreshDesktop()
me.refresh()
}).then (d) =>
@parent.systemsetting.desktop.path = d.file.path
@parent._gui.refreshDesktop()
@refresh()
(@find "btnppath").set 'onbtclick', (e) ->
me.parent.openDialog("FileDialog", {
(@find "btnppath").set 'onbtclick', (e) =>
@parent.openDialog("FileDialog", {
title: "__(Select a directory)",
mimes: ["dir"],
hidden: true
}).then (d) ->
me.parent.systemsetting.system.pkgpaths.user = d.file.path
me.refresh()
me.refresh()
}).then (d) =>
@parent.systemsetting.system.pkgpaths.user = d.file.path
@refresh()
@refresh()
refresh: () ->
me = @
@mplist.set "data", @parent.systemsetting.VFS.mountpoints
@dpath.set "text", @parent.systemsetting.desktop.path
@ppath.set "text", @parent.systemsetting.system.pkgpaths.user

View File

@ -28,7 +28,6 @@ class Setting extends this.OS.GUI.BaseApplication
super "Setting", args
main: () ->
me = @
@container = @find "container"
new AppearanceHandle @find("appearance"), @
@ -36,12 +35,12 @@ class Setting extends this.OS.GUI.BaseApplication
new LocaleHandle @find("locale"), @
new StartupHandle @find("startup"), @
(@find "btnsave").set "onbtclick", (e) ->
me._api.setting()
.then (d) ->
return me.error __("Cannot save system setting: {0}", d.error) if d.error
me.notify __("System setting saved")
.catch (e) ->
me.error __("Cannot save system setting: {0}", e.stack)
(@find "btnsave").set "onbtclick", (e) =>
@_api.setting()
.then (d) =>
return @error __("Cannot save system setting: {0}", d.error) if d.error
@notify __("System setting saved")
.catch (e) =>
@error __("Cannot save system setting: {0}", e.stack)
Setting.singleton = true
this.OS.register "Setting", Setting

View File

@ -4,17 +4,16 @@ class ShowCase extends this.OS.GUI.BaseApplication
super "ShowCase", args
main: () ->
me = @
bt = @find 'bttest'
bt.set "onbtclick", (e) ->
me.notify "btclicked"
bt.set "onbtclick", (e) =>
@notify "btclicked"
@observable.on "btclick", (e) ->
me.notify "button clicked"
@observable.on "btclick", (e) =>
@notify "button clicked"
@observable.on "menuselect", (e) ->
me.notify e.id
@observable.on "menuselect", (e) =>
@notify e.id
list = @find 'list'
@ -27,28 +26,28 @@ class ShowCase extends this.OS.GUI.BaseApplication
{ text: "some thing 5" }
]
list.unshift { text: "shifted el" }
list.set "onlistselect", (e) -> me.notify(e.data.items)
list.set "onlistselect", (e) => @notify(e.data.items)
sw = @find 'switch'
sw.set "onchange", (e) ->
me.notify e.data
sw.set "onchange", (e) =>
@notify e.data
spin = @find 'spin'
spin.set "onchange", (e) ->
me.notify e.data
spin.set "onchange", (e) =>
@notify e.data
menu = @find 'menu'
menu.set "items", @menu()
list.contextmenuHandle = (e, m) ->
m.set "items", me.menu()
list.contextmenuHandle = (e, m) =>
m.set "items", @menu()
m.show e
grid = @find 'grid'
grid.set "oncelldbclick", (e) ->
me.notify "on dbclick", e
grid.set "onrowselect", (e) ->
me.notify "on rowselect", e.data.items
grid.set "oncelldbclick", (e) =>
@notify "on dbclick", e
grid.set "onrowselect", (e) =>
@notify "on rowselect", e.data.items
@observable.on "cellselect", (e) ->
console.log "observable", e
@ -99,30 +98,30 @@ class ShowCase extends this.OS.GUI.BaseApplication
tree = @find 'tree'
tree.set "data", tdata
tree.set "ontreeselect", (e) ->
me.notify e.data.item.get "treepath"
tree.set "ontreedbclick", (e) ->
me.notify "treedbclick", e
@observable.on "treedbclick", (e) ->
me.notify "observable treedbclick", e
tree.set "ontreeselect", (e) =>
@notify e.data.item.get "treepath"
tree.set "ontreedbclick", (e) =>
@notify "treedbclick", e
@observable.on "treedbclick", (e) =>
@notify "observable treedbclick", e
slider = @find 'slider'
slider.set "onchange", (v) ->
me.notify v
slider.set "onchange", (v) =>
@notify v
cal = @find 'cal'
cal.set "ondateselect", (e) ->
me.notify e
cal.set "ondateselect", (e) =>
@notify e
pk = @find 'cpk'
pk.set "oncolorselect", (e) ->
me.notify e
pk.set "oncolorselect", (e) ->
me.notify e
pk.set "oncolorselect", (e) =>
@notify e
pk.set "oncolorselect", (e) =>
@notify e
fileview = @find 'fileview'
fileview.set "fetch", (path) ->
new Promise (resolve, reject) ->
fileview.set "fetch", (path) =>
new Promise (resolve, reject) =>
dir = path.asFileHandle()
dir.read().then (d) ->
p = dir.parent().asFileHandle()
@ -139,8 +138,8 @@ class ShowCase extends this.OS.GUI.BaseApplication
{ text: "list" },
{ text: "tree" }
]
viewoption.set "onlistselect", (e) ->
me.notify e.data.item.get("data").text
viewoption.set "onlistselect", (e) =>
@notify e.data.item.get("data").text
fileview.set "view", e.data.item.get("data").text
dllist = @find "dialoglist"
@ -157,30 +156,30 @@ class ShowCase extends this.OS.GUI.BaseApplication
{ text: "File dialog", id: "file" }
]
btrun.set "onbtclick", (e) ->
btrun.set "onbtclick", (e) =>
item = dllist.get "selectedItem"
return unless item
switch item.get("data").id
when "prompt"
me.openDialog("PromptDialog", {
@openDialog("PromptDialog", {
title: "Prompt review",
value: "txt data",
label: "enter value"
})
.then (d) ->
me.notify d
.then (d) =>
@notify d
when "calendar"
me.openDialog("CalendarDialog", {
@openDialog("CalendarDialog", {
title: "Calendar"
})
.then (d) ->
me.notify d
.then (d) =>
@notify d
when "colorpicker"
me.openDialog("ColorPickerDialog")
.then (d) ->
me.notify d
@openDialog("ColorPickerDialog")
.then (d) =>
@notify d
when "info"
me.openDialog("InfoDialog", {
@openDialog("InfoDialog", {
title: "Info application",
name: "Show case",
date: "10/12/2014",
@ -188,14 +187,14 @@ class ShowCase extends this.OS.GUI.BaseApplication
})
.then (d) ->
when "yesno"
me.openDialog("YesNoDialog", {
@openDialog("YesNoDialog", {
title: "Question ?",
text: "Do you realy want to delete file ?"
})
.then (d) ->
me.notify d
.then (d) =>
@notify d
when "selection"
me.openDialog("SelectionDialog", {
@openDialog("SelectionDialog", {
title: "Select data ?",
data: [
{ text: "Option 1" },
@ -203,27 +202,26 @@ class ShowCase extends this.OS.GUI.BaseApplication
{ text: "Option 3", iconclass: "fa fa-camera-retro fa-lg" }
]
})
.then (d) ->
me.notify d.text
.then (d) =>
@notify d.text
when "about"
me.openDialog("AboutDialog" )
.then (d) ->
@openDialog("AboutDialog" )
.then (d) =>
when "file"
me.openDialog("FileDialog", {
@openDialog("FileDialog", {
title: "Select file ?",
#root: "home:///",
mimes: ["text/*", "dir"],
file: "Untitled".asFileHandle()
})
.then (f, name) ->
me.notify f, name
.then (f, name) =>
@notify f, name
else return
mnFile: () ->
#me.notify file
me = @
#@notify file
arr = {
text: "__(File)",
child: [
@ -234,11 +232,11 @@ class ShowCase extends this.OS.GUI.BaseApplication
{ text: "__(Download)", dataid: "#{@name}-download" },
{ text: "__(Share file)", dataid: "#{@name}-share", shortcut: 'C-S' },
{ text: "__(Properties)", dataid: "#{@name}-info", shortcut: 'C-I' }
], onchildselect: (e) -> me.notify "child", e
], onchildselect: (e) => @notify "child", e
}
return arr
mnEdit: () ->
me = @
{
text: "__(Edit)",
child: [
@ -247,11 +245,10 @@ class ShowCase extends this.OS.GUI.BaseApplication
{ text: "__(Cut)", dataid: "#{@name}-cut", shortcut: 'C-X' },
{ text: "__(Copy)", dataid: "#{@name}-copy", shortcut: 'C-C' },
{ text: "__(Paste)", dataid: "#{@name}-paste", shortcut: 'C-P' }
], onchildselect: (e) -> console.log "child", e
], onchildselect: (e) => console.log "child", e
}
menu: () ->
me = @
menu = [
@mnFile(),
@mnEdit(),
@ -268,7 +265,7 @@ class ShowCase extends this.OS.GUI.BaseApplication
{ text: "__(Tree view)", radio:true, checked: false, dataid: "#{@name}-tree", type: 'tree' }
], onchildselect: (e) -> console.log "child", e
},
], onchildselect: (e) -> console.log "child", e
], onchildselect: (e) => console.log "child", e
},
]
menu