mirror of
https://github.com/lxsang/antos-frontend.git
synced 2024-12-27 17:58:22 +01:00
use fat arrow for this reference
This commit is contained in:
parent
95cfddb389
commit
fa22fc5413
@ -35,30 +35,28 @@ class Announcer
|
|||||||
@observable[evtName].one.add callback
|
@observable[evtName].one.add callback
|
||||||
|
|
||||||
off: (evtName, callback) ->
|
off: (evtName, callback) ->
|
||||||
me = @
|
fn = (evt, cb) =>
|
||||||
fn = (evt, cb) ->
|
return unless @observable[evt]
|
||||||
return unless me.observable[evt]
|
|
||||||
if cb
|
if cb
|
||||||
me.observable[evt].one.delete(cb)
|
@observable[evt].one.delete(cb)
|
||||||
me.observable[evt].many.delete(cb)
|
@observable[evt].many.delete(cb)
|
||||||
else
|
else
|
||||||
delete me.observable[evt] if me.observable[evt]
|
delete @observable[evt] if @observable[evt]
|
||||||
if evtName is "*" then fn k, callback for k, v of me.observable else fn evtName, callback
|
if evtName is "*" then fn k, callback for k, v of @observable else fn evtName, callback
|
||||||
|
|
||||||
trigger: (evtName, data) ->
|
trigger: (evtName, data) ->
|
||||||
me = @
|
trig = (name, d) =>
|
||||||
trig = (name, d) ->
|
|
||||||
names = [name, "*"]
|
names = [name, "*"]
|
||||||
for evt in names
|
for evt in names
|
||||||
continue unless me.observable[evt]
|
continue unless @observable[evt]
|
||||||
me.observable[evt].one.forEach (f) ->
|
@observable[evt].one.forEach (f) ->
|
||||||
f d
|
f d
|
||||||
me.observable[evt].one = new Set()
|
@observable[evt].one = new Set()
|
||||||
me.observable[evt].many.forEach (f) ->
|
@observable[evt].many.forEach (f) ->
|
||||||
f d
|
f d
|
||||||
|
|
||||||
if evtName is "*"
|
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
|
else
|
||||||
trig evtName, data
|
trig evtName, data
|
||||||
|
|
||||||
|
@ -26,28 +26,26 @@ class BaseApplication extends this.OS.GUI.BaseModel
|
|||||||
CTRL: {}
|
CTRL: {}
|
||||||
SHIFT: {}
|
SHIFT: {}
|
||||||
META: {}
|
META: {}
|
||||||
me = @
|
|
||||||
init: ->
|
init: ->
|
||||||
me = @
|
|
||||||
@off "*"
|
@off "*"
|
||||||
@on "exit", () -> me.quit()
|
@on "exit", () => @quit()
|
||||||
# first register some base event to the app
|
# first register some base event to the app
|
||||||
@on "focus", () ->
|
@on "focus", () =>
|
||||||
me.sysdock.set "selectedApp", me
|
@sysdock.set "selectedApp", @
|
||||||
me.appmenu.pid = me.pid
|
@appmenu.pid = @pid
|
||||||
me.appmenu.set "items", (me.baseMenu() || [])
|
@appmenu.set "items", (@baseMenu() || [])
|
||||||
me.appmenu.set "onmenuselect", (d) ->
|
@appmenu.set "onmenuselect", (d) =>
|
||||||
me.trigger("menuselect", d)
|
@trigger("menuselect", d)
|
||||||
me.dialog.show() if me.dialog
|
@dialog.show() if @dialog
|
||||||
@on "hide", () ->
|
@on "hide", () =>
|
||||||
me.sysdock.set "selectedApp", null
|
@sysdock.set "selectedApp", null
|
||||||
me.appmenu.set "items", []
|
@appmenu.set "items", []
|
||||||
me.dialog.hide() if me.dialog
|
@dialog.hide() if @dialog
|
||||||
@on "menuselect", (d) ->
|
@on "menuselect", (d) =>
|
||||||
switch d.data.item.get("data").dataid
|
switch d.data.item.get("data").dataid
|
||||||
when "#{me.name}-about" then me.openDialog "AboutDialog", ()->
|
when "#{@name}-about" then @openDialog "AboutDialog"
|
||||||
when "#{me.name}-exit" then me.trigger "exit"
|
when "#{@name}-exit" then @trigger "exit"
|
||||||
@on "apptitlechange", () -> me.sysdock.update()
|
@on "apptitlechange", () => @sysdock.update()
|
||||||
@loadScheme()
|
@loadScheme()
|
||||||
|
|
||||||
loadScheme: () ->
|
loadScheme: () ->
|
||||||
|
@ -74,16 +74,15 @@ class PromptDialog extends BasicDialog
|
|||||||
|
|
||||||
init: () ->
|
init: () ->
|
||||||
super.init()
|
super.init()
|
||||||
me = @
|
|
||||||
@find("lbl").set "text", @data.label if @data and @data.label
|
@find("lbl").set "text", @data.label if @data and @data.label
|
||||||
$(@find "txtInput").val @data.value if @data and @data.value
|
$(@find "txtInput").val @data.value if @data and @data.value
|
||||||
|
|
||||||
(@find "btnOk").set "onbtclick", (e) ->
|
(@find "btnOk").set "onbtclick", (e) =>
|
||||||
me.handle($(me.find "txtInput").val()) if me.handle
|
@handle($(@find "txtInput").val()) if @handle
|
||||||
me.quit()
|
@quit()
|
||||||
|
|
||||||
(@find "btnCancel").set "onbtclick", (e) ->
|
(@find "btnCancel").set "onbtclick", (e) =>
|
||||||
me.quit()
|
@quit()
|
||||||
|
|
||||||
|
|
||||||
PromptDialog.scheme = """
|
PromptDialog.scheme = """
|
||||||
@ -115,15 +114,14 @@ class CalendarDialog extends BasicDialog
|
|||||||
|
|
||||||
init: () ->
|
init: () ->
|
||||||
super.init()
|
super.init()
|
||||||
me = @
|
(@find "btnOk").set "onbtclick", (e) =>
|
||||||
(@find "btnOk").set "onbtclick", (e) ->
|
date = (@find "cal").get "selectedDate"
|
||||||
date = (me.find "cal").get "selectedDate"
|
return @notify __("Please select a day") unless date
|
||||||
return me.notify __("Please select a day") unless date
|
@handle(date) if @handle
|
||||||
me.handle(date) if me.handle
|
@quit()
|
||||||
me.quit()
|
|
||||||
|
|
||||||
(@find "btnCancel").set "onbtclick", (e) ->
|
(@find "btnCancel").set "onbtclick", (e) =>
|
||||||
me.quit()
|
@quit()
|
||||||
|
|
||||||
CalendarDialog.scheme = """
|
CalendarDialog.scheme = """
|
||||||
<afx-app-window width='300' height='230' apptitle = "Calendar" >
|
<afx-app-window width='300' height='230' apptitle = "Calendar" >
|
||||||
@ -155,15 +153,14 @@ class ColorPickerDialog extends BasicDialog
|
|||||||
|
|
||||||
init: () ->
|
init: () ->
|
||||||
super.init()
|
super.init()
|
||||||
me = @
|
(@find "btnOk").set "onbtclick", (e) =>
|
||||||
(@find "btnOk").set "onbtclick", (e) ->
|
color = (@find "cpicker").get "selectedColor"
|
||||||
color = (me.find "cpicker").get "selectedColor"
|
return @notify __("Please select color") unless color
|
||||||
return me.notify __("Please select color") unless color
|
@handle(color) if @handle
|
||||||
me.handle(color) if me.handle
|
@quit()
|
||||||
me.quit()
|
|
||||||
|
|
||||||
(@find "btnCancel").set "onbtclick", (e) ->
|
(@find "btnCancel").set "onbtclick", (e) =>
|
||||||
me.quit()
|
@quit()
|
||||||
|
|
||||||
ColorPickerDialog.scheme = """
|
ColorPickerDialog.scheme = """
|
||||||
<afx-app-window width='320' height='250' apptitle = "Color picker" >
|
<afx-app-window width='320' height='250' apptitle = "Color picker" >
|
||||||
@ -195,14 +192,13 @@ class InfoDialog extends BasicDialog
|
|||||||
|
|
||||||
init: () ->
|
init: () ->
|
||||||
super.init()
|
super.init()
|
||||||
me = @
|
|
||||||
rows = []
|
rows = []
|
||||||
delete @data.title if @data and @data.title
|
delete @data.title if @data and @data.title
|
||||||
rows.push [ { text: k }, { text: v } ] for k, v of @data
|
rows.push [ { text: k }, { text: v } ] for k, v of @data
|
||||||
(@find "grid").set "header", [ { text: __("Name"), width: 70 }, { text: __("Value") } ]
|
(@find "grid").set "header", [ { text: __("Name"), width: 70 }, { text: __("Value") } ]
|
||||||
(@find "grid").set "rows", rows
|
(@find "grid").set "rows", rows
|
||||||
(@find "btnCancel").set "onbtclick", (e) ->
|
(@find "btnCancel").set "onbtclick", (e) =>
|
||||||
me.quit()
|
@quit()
|
||||||
|
|
||||||
InfoDialog.scheme = """
|
InfoDialog.scheme = """
|
||||||
<afx-app-window width='250' height='300' apptitle = "Info" >
|
<afx-app-window width='250' height='300' apptitle = "Info" >
|
||||||
@ -234,14 +230,13 @@ class YesNoDialog extends BasicDialog
|
|||||||
|
|
||||||
init: () ->
|
init: () ->
|
||||||
super.init()
|
super.init()
|
||||||
me = @
|
|
||||||
@find("lbl").set "*", @data if @data
|
@find("lbl").set "*", @data if @data
|
||||||
(@find "btnYes").set "onbtclick", (e) ->
|
(@find "btnYes").set "onbtclick", (e) =>
|
||||||
me.handle(true) if me.handle
|
@handle(true) if @handle
|
||||||
me.quit()
|
@quit()
|
||||||
(@find "btnNo").set "onbtclick", (e) ->
|
(@find "btnNo").set "onbtclick", (e) =>
|
||||||
me.handle(false) if me.handle
|
@handle(false) if @handle
|
||||||
me.quit()
|
@quit()
|
||||||
|
|
||||||
YesNoDialog.scheme = """
|
YesNoDialog.scheme = """
|
||||||
<afx-app-window width='200' height='150' apptitle = "Prompt">
|
<afx-app-window width='200' height='150' apptitle = "Prompt">
|
||||||
@ -271,18 +266,17 @@ class SelectionDialog extends BasicDialog
|
|||||||
|
|
||||||
init: () ->
|
init: () ->
|
||||||
super.init()
|
super.init()
|
||||||
me = @
|
|
||||||
(@find "list").set "data", @data.data if @data and @data.data
|
(@find "list").set "data", @data.data if @data and @data.data
|
||||||
fn = (e) ->
|
fn = (e) =>
|
||||||
data = (me.find "list").get "selectedItem"
|
data = (@find "list").get "selectedItem"
|
||||||
return me.notify __("Please select an item") unless data
|
return @notify __("Please select an item") unless data
|
||||||
me.handle(data.get("data")) if me.handle
|
@handle(data.get("data")) if @handle
|
||||||
me.quit()
|
@quit()
|
||||||
(@find "list").set "onlistdbclick", fn
|
(@find "list").set "onlistdbclick", fn
|
||||||
(@find "btnOk").set "onbtclick", fn
|
(@find "btnOk").set "onbtclick", fn
|
||||||
|
|
||||||
(@find "btnCancel").set "onbtclick", (e) ->
|
(@find "btnCancel").set "onbtclick", (e) =>
|
||||||
me.quit()
|
@quit()
|
||||||
|
|
||||||
SelectionDialog.scheme = """
|
SelectionDialog.scheme = """
|
||||||
<afx-app-window width='250' height='300' apptitle = "Selection">
|
<afx-app-window width='250' height='300' apptitle = "Selection">
|
||||||
@ -312,7 +306,6 @@ class AboutDialog extends BasicDialog
|
|||||||
|
|
||||||
init: () ->
|
init: () ->
|
||||||
mt = @meta()
|
mt = @meta()
|
||||||
me = @
|
|
||||||
@scheme.set "apptitle", __("About: {0}", mt.name)
|
@scheme.set "apptitle", __("About: {0}", mt.name)
|
||||||
(@find "mylabel").set "*", {
|
(@find "mylabel").set "*", {
|
||||||
icon: mt.icon,
|
icon: mt.icon,
|
||||||
@ -326,8 +319,8 @@ class AboutDialog extends BasicDialog
|
|||||||
rows.push [ { text: k }, { text: v } ] for k, v of mt.info
|
rows.push [ { text: k }, { text: v } ] for k, v of mt.info
|
||||||
(@find "mygrid").set "header", [ { text: "", width: 100 }, { text: "" } ]
|
(@find "mygrid").set "header", [ { text: "", width: 100 }, { text: "" } ]
|
||||||
(@find "mygrid").set "rows", rows
|
(@find "mygrid").set "rows", rows
|
||||||
(@find "btnCancel").set "onbtclick", (e) ->
|
(@find "btnCancel").set "onbtclick", (e) =>
|
||||||
me.quit()
|
@quit()
|
||||||
|
|
||||||
AboutDialog.scheme = """
|
AboutDialog.scheme = """
|
||||||
<afx-app-window data-id = 'about-window' width='300' height='200'>
|
<afx-app-window data-id = 'about-window' width='300' height='200'>
|
||||||
@ -338,7 +331,11 @@ AboutDialog.scheme = """
|
|||||||
</h3>
|
</h3>
|
||||||
<i><p style = "margin:0; padding:0" data-id = 'mydesc'></p></i>
|
<i><p style = "margin:0; padding:0" data-id = 'mydesc'></p></i>
|
||||||
</div>
|
</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">
|
<afx-hbox data-height="30">
|
||||||
<div />
|
<div />
|
||||||
<afx-button data-id = "btnCancel" text = "__(Cancel)" data-width = "60" />
|
<afx-button data-id = "btnCancel" text = "__(Cancel)" data-width = "60" />
|
||||||
@ -358,7 +355,6 @@ class FileDialog extends BasicDialog
|
|||||||
fileview = @find "fileview"
|
fileview = @find "fileview"
|
||||||
location = @find "location"
|
location = @find "location"
|
||||||
filename = @find "filename"
|
filename = @find "filename"
|
||||||
me = @
|
|
||||||
fileview.set "fetch", (path) ->
|
fileview.set "fetch", (path) ->
|
||||||
new Promise (resolve, reject) ->
|
new Promise (resolve, reject) ->
|
||||||
return resolve() unless path
|
return resolve() unless path
|
||||||
@ -367,10 +363,10 @@ class FileDialog extends BasicDialog
|
|||||||
return reject d if d.error
|
return reject d if d.error
|
||||||
resolve d.result
|
resolve d.result
|
||||||
.catch (e) -> reject e
|
.catch (e) -> reject e
|
||||||
setroot = (path) ->
|
setroot = (path) =>
|
||||||
path.asFileHandle().read().then (d) ->
|
path.asFileHandle().read().then (d) =>
|
||||||
if(d.error)
|
if(d.error)
|
||||||
return me.error __("Resource not found: {0}", path)
|
return @error __("Resource not found: {0}", path)
|
||||||
fileview.set "path", path
|
fileview.set "path", path
|
||||||
|
|
||||||
if not @data or not @data.root
|
if not @data or not @data.root
|
||||||
@ -385,27 +381,27 @@ class FileDialog extends BasicDialog
|
|||||||
setroot @data.root
|
setroot @data.root
|
||||||
fileview.set "onfileselect", (e) ->
|
fileview.set "onfileselect", (e) ->
|
||||||
($ filename).val e.data.filename if e.data.type is "file"
|
($ 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"
|
f = fileview.get "selectedFile"
|
||||||
return me.notify __("Please select a file/fofler") unless f
|
return @notify __("Please select a file/fofler") unless f
|
||||||
if me.data and me.data.type and me.data.type isnt f.type
|
if @data and @data.type and @data.type isnt f.type
|
||||||
return me.notify __("Please select {0} only", me.data.type)
|
return @notify __("Please select {0} only", @data.type)
|
||||||
if me.data and me.data.mimes
|
if @data and @data.mimes
|
||||||
#verify the mime
|
#verify the mime
|
||||||
m = false
|
m = false
|
||||||
if f.mime
|
if f.mime
|
||||||
for v in me.data.mimes
|
for v in @data.mimes
|
||||||
if f.mime.match (new RegExp v, "g")
|
if f.mime.match (new RegExp v, "g")
|
||||||
m = true
|
m = true
|
||||||
break
|
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()
|
name = $(filename).val()
|
||||||
me.handle { file: f, name: name } if me.handle
|
@handle { file: f, name: name } if @handle
|
||||||
me.quit()
|
@quit()
|
||||||
|
|
||||||
(@find "bt-cancel").set "onbtclick", (e) ->
|
(@find "bt-cancel").set "onbtclick", (e) =>
|
||||||
me.quit()
|
@quit()
|
||||||
if @data and @data.file
|
if @data and @data.file
|
||||||
($ filename).css("display", "block").val @data.file.basename or "Untitled"
|
($ filename).css("display", "block").val @data.file.basename or "Untitled"
|
||||||
@trigger "resize"
|
@trigger "resize"
|
||||||
|
@ -18,13 +18,11 @@
|
|||||||
|
|
||||||
class BaseModel
|
class BaseModel
|
||||||
constructor: (@name, @args) ->
|
constructor: (@name, @args) ->
|
||||||
me = @
|
|
||||||
@observable = new Announcer()
|
@observable = new Announcer()
|
||||||
@_api = Ant.OS.API
|
@_api = Ant.OS.API
|
||||||
@_gui = Ant.OS.GUI
|
@_gui = Ant.OS.GUI
|
||||||
@systemsetting = Ant.OS.setting
|
@systemsetting = Ant.OS.setting
|
||||||
me = @
|
@on "exit", () => @quit()
|
||||||
@on "exit", () -> me.quit()
|
|
||||||
@host = @_gui.workspace
|
@host = @_gui.workspace
|
||||||
@dialog = undefined
|
@dialog = undefined
|
||||||
render: (p) ->
|
render: (p) ->
|
||||||
@ -68,26 +66,25 @@ class BaseModel
|
|||||||
Ant.OS.announcer.on e, f, @
|
Ant.OS.announcer.on e, f, @
|
||||||
|
|
||||||
openDialog: (d, data) ->
|
openDialog: (d, data) ->
|
||||||
me = @
|
new Promise (resolve, reject) =>
|
||||||
new Promise (resolve, reject) ->
|
if @dialog
|
||||||
if me.dialog
|
@dialog.show()
|
||||||
me.dialog.show()
|
|
||||||
return
|
return
|
||||||
if typeof d is "string"
|
if typeof d is "string"
|
||||||
if not Ant.OS.GUI.subwindows[d]
|
if not Ant.OS.GUI.subwindows[d]
|
||||||
me.error __("Dialog {0} not found", d)
|
@error __("Dialog {0} not found", d)
|
||||||
return
|
return
|
||||||
me.dialog = new Ant.OS.GUI.subwindows[d]()
|
@dialog = new Ant.OS.GUI.subwindows[d]()
|
||||||
else
|
else
|
||||||
me.dialog = d
|
@dialog = d
|
||||||
#@dialog.observable = riot.observable() unless @dialog
|
#@dialog.observable = riot.observable() unless @dialog
|
||||||
me.dialog.parent = me
|
@dialog.parent = @
|
||||||
me.dialog.handle = resolve
|
@dialog.handle = resolve
|
||||||
me.dialog.reject = reject
|
@dialog.reject = reject
|
||||||
me.dialog.pid = me.pid
|
@dialog.pid = @pid
|
||||||
me.dialog.data = data
|
@dialog.data = data
|
||||||
me.dialog.title = data.title if data and data.title
|
@dialog.title = data.title if data and data.title
|
||||||
me.dialog.init()
|
@dialog.init()
|
||||||
|
|
||||||
ask: (t, m, f) ->
|
ask: (t, m, f) ->
|
||||||
@._gui.openDialog "YesNoDialog", (d) ->
|
@._gui.openDialog "YesNoDialog", (d) ->
|
||||||
|
@ -24,9 +24,8 @@ class BaseService extends this.OS.GUI.BaseModel
|
|||||||
@text = ""
|
@text = ""
|
||||||
@timer = undefined
|
@timer = undefined
|
||||||
@holder = undefined
|
@holder = undefined
|
||||||
me = @
|
@onmenuselect = (d) =>
|
||||||
@onmenuselect = (d) ->
|
@awake d
|
||||||
me.awake d
|
|
||||||
|
|
||||||
init: ()->
|
init: ()->
|
||||||
#implement by user
|
#implement by user
|
||||||
@ -42,10 +41,9 @@ class BaseService extends this.OS.GUI.BaseModel
|
|||||||
@holder = h
|
@holder = h
|
||||||
|
|
||||||
watch: ( t, f) ->
|
watch: ( t, f) ->
|
||||||
me = @
|
func = () =>
|
||||||
func = () ->
|
|
||||||
f()
|
f()
|
||||||
me.timer = setTimeout (() -> func()), t
|
@timer = setTimeout (() -> func()), t
|
||||||
func()
|
func()
|
||||||
onexit: (evt) ->
|
onexit: (evt) ->
|
||||||
console.log "clean timer" if @timer
|
console.log "clean timer" if @timer
|
||||||
|
@ -23,9 +23,8 @@ class FormatedString
|
|||||||
toString: () ->
|
toString: () ->
|
||||||
@__()
|
@__()
|
||||||
__: () ->
|
__: () ->
|
||||||
me = @
|
return @fs.l().replace /{(\d+)}/g, (match, number) =>
|
||||||
return @fs.l().replace /{(\d+)}/g, (match, number) ->
|
return if typeof @values[number] != 'undefined' then @values[number].__() else match
|
||||||
return if typeof me.values[number] != 'undefined' then me.values[number].__() else match
|
|
||||||
hash: () ->
|
hash: () ->
|
||||||
@__().hash()
|
@__().hash()
|
||||||
|
|
||||||
@ -321,7 +320,7 @@ Ant.OS.API =
|
|||||||
.catch (e) ->
|
.catch (e) ->
|
||||||
reject e
|
reject e
|
||||||
else
|
else
|
||||||
reject e
|
reject Ant.OS.API.throwe __("Invalid library: {0}", l)
|
||||||
else
|
else
|
||||||
console.log l, "Library exist, no need to load"
|
console.log l, "Library exist, no need to load"
|
||||||
Ant.OS.announcer.trigger "sharedlibraryloaded", l
|
Ant.OS.announcer.trigger "sharedlibraryloaded", l
|
||||||
|
@ -4,9 +4,8 @@ class AppDockTag extends Ant.OS.GUI.BaseTag
|
|||||||
@setopt "onappselect", (e) ->
|
@setopt "onappselect", (e) ->
|
||||||
@setopt "items", []
|
@setopt "items", []
|
||||||
@setopt "selectedApp", undefined
|
@setopt "selectedApp", undefined
|
||||||
me = @
|
@root.newapp = (a) => @addApp a
|
||||||
@root.newapp = (a) -> me.addApp a
|
@root.removeapp = (a) => @removeApp a
|
||||||
@root.removeapp = (a) -> me.removeApp a
|
|
||||||
|
|
||||||
__selectedApp__: (v) ->
|
__selectedApp__: (v) ->
|
||||||
el = undefined
|
el = undefined
|
||||||
@ -26,9 +25,8 @@ class AppDockTag extends Ant.OS.GUI.BaseTag
|
|||||||
el[0].set "*", item
|
el[0].set "*", item
|
||||||
el.attr "tooltip", "cr:#{item.app.title()}"
|
el.attr "tooltip", "cr:#{item.app.title()}"
|
||||||
item.domel = el[0]
|
item.domel = el[0]
|
||||||
me = @
|
el[0].set "onbtclick", (e) =>
|
||||||
el[0].set "onbtclick", (e) ->
|
e.id = @aid()
|
||||||
e.id = me.aid()
|
|
||||||
e.data.app = item
|
e.data.app = item
|
||||||
item.app.show()
|
item.app.show()
|
||||||
@set "selectedApp", item.app
|
@set "selectedApp", item.app
|
||||||
@ -47,9 +45,8 @@ class AppDockTag extends Ant.OS.GUI.BaseTag
|
|||||||
$($(@root).children()[i]).remove()
|
$($(@root).children()[i]).remove()
|
||||||
|
|
||||||
mount: () ->
|
mount: () ->
|
||||||
me = @
|
@root.contextmenuHandle = (e, m) =>
|
||||||
@root.contextmenuHandle = (e, m) ->
|
return if e.target is @root
|
||||||
return if e.target is me.root
|
|
||||||
bt = $(e.target).closest "afx-button"
|
bt = $(e.target).closest "afx-button"
|
||||||
app = bt[0].get "app"
|
app = bt[0].get "app"
|
||||||
m.set "items", [
|
m.set "items", [
|
||||||
|
@ -31,12 +31,11 @@ class ButtonTag extends Ant.OS.GUI.BaseTag
|
|||||||
$(@button).addClass "selected" if v
|
$(@button).addClass "selected" if v
|
||||||
|
|
||||||
mount: () ->
|
mount: () ->
|
||||||
me = @
|
@root.trigger = () =>
|
||||||
@root.trigger = () ->
|
$(@refs.button).trigger "click"
|
||||||
($me.refs.button).trigger "click"
|
|
||||||
|
|
||||||
$(@refs.button).click (e) ->
|
$(@refs.button).click (e) =>
|
||||||
me.btclickhd e
|
@btclickhd e
|
||||||
|
|
||||||
btclickhd: (e) ->
|
btclickhd: (e) ->
|
||||||
hd = @get "onbtclick"
|
hd = @get "onbtclick"
|
||||||
|
@ -9,11 +9,10 @@ class CalendarTag extends Ant.OS.GUI.BaseTag
|
|||||||
@year = 0
|
@year = 0
|
||||||
|
|
||||||
mount: () ->
|
mount: () ->
|
||||||
me = @
|
|
||||||
$(@root).css "height", "100%"
|
$(@root).css "height", "100%"
|
||||||
$(@refs.grid).css "width", "100%"
|
$(@refs.grid).css "width", "100%"
|
||||||
$(@refs.prev).click (e) -> me.prevmonth()
|
$(@refs.prev).click (e) => @prevmonth()
|
||||||
$(@refs.next).click (e) -> me.nextmonth()
|
$(@refs.next).click (e) => @nextmonth()
|
||||||
@refs.grid.set "header", [
|
@refs.grid.set "header", [
|
||||||
{ text: "__(Sun)" },
|
{ text: "__(Sun)" },
|
||||||
{ text: "__(Mon)" },
|
{ text: "__(Mon)" },
|
||||||
@ -23,10 +22,10 @@ class CalendarTag extends Ant.OS.GUI.BaseTag
|
|||||||
{ text: "__(Fri)" },
|
{ text: "__(Fri)" },
|
||||||
{ text: "__(Sat)" }
|
{ text: "__(Sat)" }
|
||||||
]
|
]
|
||||||
@refs.grid.set "oncellselect", (e) ->
|
@refs.grid.set "oncellselect", (e) =>
|
||||||
me.dateselect(e)
|
@dateselect(e)
|
||||||
|
|
||||||
@observable.on "resize", (e) -> me.calibrate()
|
@observable.on "resize", (e) => @calibrate()
|
||||||
@calibrate()
|
@calibrate()
|
||||||
@calendar null
|
@calendar null
|
||||||
|
|
||||||
|
@ -34,7 +34,6 @@ class ColorPickerTag extends Ant.OS.GUI.BaseTag
|
|||||||
@build_palette()
|
@build_palette()
|
||||||
|
|
||||||
build_palette: () ->
|
build_palette: () ->
|
||||||
me = @
|
|
||||||
colorctx = $(@refs.palette).get(0).getContext('2d')
|
colorctx = $(@refs.palette).get(0).getContext('2d')
|
||||||
gradient = colorctx.createLinearGradient(0, 0, $(@refs.palette).width(), 0)
|
gradient = colorctx.createLinearGradient(0, 0, $(@refs.palette).width(), 0)
|
||||||
# fill color
|
# fill color
|
||||||
@ -65,9 +64,9 @@ class ColorPickerTag extends Ant.OS.GUI.BaseTag
|
|||||||
s = "0" + s if s.length is 1
|
s = "0" + s if s.length is 1
|
||||||
s
|
s
|
||||||
|
|
||||||
pick_color = (e) ->
|
pick_color = (e) =>
|
||||||
$(me.refs.palette).css("cursor", "crosshair")
|
$(@refs.palette).css("cursor", "crosshair")
|
||||||
offset = $(me.refs.palette).offset()
|
offset = $(@refs.palette).offset()
|
||||||
x = e.pageX - offset.left
|
x = e.pageX - offset.left
|
||||||
y = e.pageY - offset.top
|
y = e.pageY - offset.top
|
||||||
color = colorctx.getImageData(x, y, 1, 1)
|
color = colorctx.getImageData(x, y, 1, 1)
|
||||||
@ -80,26 +79,26 @@ class ColorPickerTag extends Ant.OS.GUI.BaseTag
|
|||||||
}
|
}
|
||||||
data
|
data
|
||||||
|
|
||||||
mouse_move_h = (e) ->
|
mouse_move_h = (e) =>
|
||||||
data = pick_color(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) ->
|
$(@refs.palette).mouseenter (e) =>
|
||||||
$(me.refs.palette).on("mousemove", mouse_move_h)
|
$(@refs.palette).on("mousemove", mouse_move_h)
|
||||||
|
|
||||||
$(me.refs.palette).mouseout (e) ->
|
$(@refs.palette).mouseout (e) =>
|
||||||
$(me.refs.palette).unbind("mousemove", mouse_move_h)
|
$(@refs.palette).unbind("mousemove", mouse_move_h)
|
||||||
if me.get "selectedColor"
|
if @get "selectedColor"
|
||||||
$(me.refs.colorval).css("background-color", me.get("selectedColor").text)
|
$(@refs.colorval).css("background-color", @get("selectedColor").text)
|
||||||
|
|
||||||
$(@refs.palette).on "click", (e) ->
|
$(@refs.palette).on "click", (e) =>
|
||||||
data = pick_color(e)
|
data = pick_color(e)
|
||||||
$(me.refs.rgbtext).html(data.text)
|
$(@refs.rgbtext).html(data.text)
|
||||||
$(me.refs.hextext).val(data.hex)
|
$(@refs.hextext).val(data.hex)
|
||||||
me.set "selectedColor", data
|
@set "selectedColor", data
|
||||||
evt = { id: me.aid(), data: data }
|
evt = { id: @aid(), data: data }
|
||||||
me.get("oncolorselect") evt
|
@get("oncolorselect") evt
|
||||||
me.observable.trigger "colorselect", data
|
@observable.trigger "colorselect", data
|
||||||
|
|
||||||
layout: () ->
|
layout: () ->
|
||||||
[{
|
[{
|
||||||
|
@ -33,13 +33,12 @@ class FileViewTag extends Ant.OS.GUI.BaseTag
|
|||||||
|
|
||||||
__path__: (v) ->
|
__path__: (v) ->
|
||||||
return unless v
|
return unless v
|
||||||
me = @
|
|
||||||
return unless @get "fetch"
|
return unless @get "fetch"
|
||||||
@get("fetch")(v)
|
@get("fetch")(v)
|
||||||
.then (data) ->
|
.then (data) =>
|
||||||
return unless data
|
return unless data
|
||||||
me.set "data", data
|
@set "data", data
|
||||||
me.refs.status.set("text", " ") if me.get "status"
|
@refs.status.set("text", " ") if @get "status"
|
||||||
.catch (e) ->
|
.catch (e) ->
|
||||||
# this should be handled by the OS
|
# this should be handled by the OS
|
||||||
Ant.OS.announcer.oserror e
|
Ant.OS.announcer.oserror e
|
||||||
@ -69,9 +68,8 @@ class FileViewTag extends Ant.OS.GUI.BaseTag
|
|||||||
|
|
||||||
refreshList: () ->
|
refreshList: () ->
|
||||||
items = []
|
items = []
|
||||||
me = @
|
$.each @get("data"), (i, v) =>
|
||||||
$.each @get("data"), (i, v) ->
|
return if v.filename[0] is '.' and not @get("showhidden")
|
||||||
return if v.filename[0] is '.' and not me.get("showhidden")
|
|
||||||
v.text = v.filename
|
v.text = v.filename
|
||||||
v.text = v.text.substring(0, 9) + "..." if v.text.length > 10
|
v.text = v.text.substring(0, 9) + "..." if v.text.length > 10
|
||||||
v.iconclass = if v.iconclass then v.iconclass else v.type
|
v.iconclass = if v.iconclass then v.iconclass else v.type
|
||||||
@ -81,9 +79,8 @@ class FileViewTag extends Ant.OS.GUI.BaseTag
|
|||||||
|
|
||||||
refreshGrid: () ->
|
refreshGrid: () ->
|
||||||
rows = []
|
rows = []
|
||||||
me = @
|
$.each @get("data"), (i, v) =>
|
||||||
$.each @get("data"), (i, v) ->
|
return if v.filename[0] is '.' and not @get("showhidden")
|
||||||
return if v.filename[0] is '.' and not me.get("showhidden")
|
|
||||||
v.text = v.filename
|
v.text = v.filename
|
||||||
v.iconclass = if v.iconclass then v.iconclass else v.type
|
v.iconclass = if v.iconclass then v.iconclass else v.type
|
||||||
row = [
|
row = [
|
||||||
@ -112,8 +109,8 @@ class FileViewTag extends Ant.OS.GUI.BaseTag
|
|||||||
getTreeData: (data) ->
|
getTreeData: (data) ->
|
||||||
nodes = []
|
nodes = []
|
||||||
me = @
|
me = @
|
||||||
$.each data, (i, v) ->
|
$.each data, (i, v) =>
|
||||||
return if v.filename[0] is '.' and not me.get("showhidden")
|
return if v.filename[0] is '.' and not @get("showhidden")
|
||||||
v.name = v.filename
|
v.name = v.filename
|
||||||
if v.type is 'dir'
|
if v.type is 'dir'
|
||||||
v.nodes = []
|
v.nodes = []
|
||||||
@ -176,30 +173,29 @@ class FileViewTag extends Ant.OS.GUI.BaseTag
|
|||||||
@observable.trigger "fileopen", evt
|
@observable.trigger "fileopen", evt
|
||||||
|
|
||||||
mount: () ->
|
mount: () ->
|
||||||
me = @
|
@observable.on "resize", (e) => @calibrate()
|
||||||
@observable.on "resize", (e) -> me.calibrate()
|
@refs.treeview.set "fetch", (v) =>
|
||||||
@refs.treeview.set "fetch", (v) ->
|
new Promise (resolve, reject) =>
|
||||||
new Promise (resolve, reject) ->
|
return resolve undefined unless @get("fetch")
|
||||||
return resolve undefined unless me.get("fetch")
|
|
||||||
return resolve undefined unless v.get("data").path
|
return resolve undefined unless v.get("data").path
|
||||||
me.get("fetch")(v.get("data").path)
|
@get("fetch")(v.get("data").path)
|
||||||
.then (d) -> resolve me.getTreeData(d.sort me.sortByType)
|
.then (d) => resolve @getTreeData(d.sort @sortByType)
|
||||||
.catch (e) -> reject e
|
.catch (e) -> reject e
|
||||||
@refs.gridview.set "header", @header
|
@refs.gridview.set "header", @header
|
||||||
# even handles
|
# even handles
|
||||||
@refs.listview.set "onlistselect", (e) ->
|
@refs.listview.set "onlistselect", (e) =>
|
||||||
me.fileselect e.data.item.get("data")
|
@fileselect e.data.item.get("data")
|
||||||
@refs.gridview.set "onrowselect", (e) ->
|
@refs.gridview.set "onrowselect", (e) =>
|
||||||
me.fileselect $(e.data.item).children()[0].get("data")
|
@fileselect $(e.data.item).children()[0].get("data")
|
||||||
@refs.treeview.set "ontreeselect", (e) ->
|
@refs.treeview.set "ontreeselect", (e) =>
|
||||||
me.fileselect e.data.item.get("data")
|
@fileselect e.data.item.get("data")
|
||||||
# dblclick
|
# dblclick
|
||||||
@refs.listview.set "onlistdbclick", (e) ->
|
@refs.listview.set "onlistdbclick", (e) =>
|
||||||
me.filedbclick e.data.item.get("data")
|
@filedbclick e.data.item.get("data")
|
||||||
@refs.gridview.set "oncelldbclick", (e) ->
|
@refs.gridview.set "oncelldbclick", (e) =>
|
||||||
me.filedbclick e.data.item.get("data")
|
@filedbclick e.data.item.get("data")
|
||||||
@refs.treeview.set "ontreedbclick", (e) ->
|
@refs.treeview.set "ontreedbclick", (e) =>
|
||||||
me.filedbclick e.data.item.get("data")
|
@filedbclick e.data.item.get("data")
|
||||||
@switchView()
|
@switchView()
|
||||||
|
|
||||||
layout: () ->
|
layout: () ->
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
class FloatListTag extends ListViewTag
|
class FloatListTag extends ListViewTag
|
||||||
constructor: (r, o) ->
|
constructor: (r, o) ->
|
||||||
super r, o
|
super r, o
|
||||||
me = @
|
|
||||||
@setopt "dir", "horizontal"
|
@setopt "dir", "horizontal"
|
||||||
@root.refresh = () -> me.calibrate()
|
@root.refresh = () => @calibrate()
|
||||||
@root.push = (e) -> me.refs.mlist.push(e)
|
@root.push = (e) => @refs.mlist.push(e)
|
||||||
@root.unshift = (e) -> me.refs.mlist.unshift(e)
|
@root.unshift = (e) => @refs.mlist.unshift(e)
|
||||||
@root.remove = (e) -> me.refs.mlist.remove(e)
|
@root.remove = (e) => @refs.mlist.remove(e)
|
||||||
|
|
||||||
# disable some uneccessary functions
|
# disable some uneccessary functions
|
||||||
__dropdown__: (v) -> @set "dropdown", false if v
|
__dropdown__: (v) -> @set "dropdown", false if v
|
||||||
@ -20,7 +20,6 @@ class FloatListTag extends ListViewTag
|
|||||||
@calibrate()
|
@calibrate()
|
||||||
|
|
||||||
mount: () ->
|
mount: () ->
|
||||||
me = @
|
|
||||||
$(@refs.container)
|
$(@refs.container)
|
||||||
.css "width", "100%"
|
.css "width", "100%"
|
||||||
.css "height", "100%"
|
.css "height", "100%"
|
||||||
@ -28,7 +27,7 @@ class FloatListTag extends ListViewTag
|
|||||||
.css "position", "absolute"
|
.css "position", "absolute"
|
||||||
.css "display", "block"
|
.css "display", "block"
|
||||||
.css "width", "100%"
|
.css "width", "100%"
|
||||||
@observable.on "resize", (e) -> me.calibrate()
|
@observable.on "resize", (e) => @calibrate()
|
||||||
@root.ready(@root) if @root.ready
|
@root.ready(@root) if @root.ready
|
||||||
|
|
||||||
push: (v) ->
|
push: (v) ->
|
||||||
@ -37,14 +36,13 @@ class FloatListTag extends ListViewTag
|
|||||||
el
|
el
|
||||||
|
|
||||||
enable_drag: (el) ->
|
enable_drag: (el) ->
|
||||||
me = @
|
|
||||||
$(el)
|
$(el)
|
||||||
.css "user-select", "none"
|
.css "user-select", "none"
|
||||||
.css "cursor", "default"
|
.css "cursor", "default"
|
||||||
.css "display", "block"
|
.css "display", "block"
|
||||||
.css "position", "absolute"
|
.css "position", "absolute"
|
||||||
.on "mousedown", (evt) ->
|
.on "mousedown", (evt) =>
|
||||||
globalof = $(me.refs.mlist).offset()
|
globalof = $(@refs.mlist).offset()
|
||||||
evt.preventDefault()
|
evt.preventDefault()
|
||||||
offset = $(el).offset()
|
offset = $(el).offset()
|
||||||
offset.top = evt.clientY - offset.top
|
offset.top = evt.clientY - offset.top
|
||||||
@ -71,14 +69,14 @@ class FloatListTag extends ListViewTag
|
|||||||
.css "height", "#{$(@refs.container).height()}px"
|
.css "height", "#{$(@refs.container).height()}px"
|
||||||
gw = $(@refs.mlist).width()
|
gw = $(@refs.mlist).width()
|
||||||
gh = $(@refs.mlist).height()
|
gh = $(@refs.mlist).height()
|
||||||
me = @
|
|
||||||
$(@refs.mlist).children().each (e) ->
|
$(@refs.mlist).children().each (i, e) =>
|
||||||
$(@)
|
$(e)
|
||||||
.css "top", "#{ctop}px"
|
.css "top", "#{ctop}px"
|
||||||
.css "left", "#{cleft}px"
|
.css "left", "#{cleft}px"
|
||||||
w = $(@).width()
|
w = $(e).width()
|
||||||
h = $(@).height()
|
h = $(e).height()
|
||||||
if me.get("dir") is "vertical"
|
if @get("dir") is "vertical"
|
||||||
ctop += h + 20
|
ctop += h + 20
|
||||||
if ctop > gh
|
if ctop > gh
|
||||||
ctop = 20
|
ctop = 20
|
||||||
|
@ -26,12 +26,11 @@ class GridCellPrototype extends Ant.OS.GUI.BaseTag
|
|||||||
@set "data", @get("data")
|
@set "data", @get("data")
|
||||||
|
|
||||||
mount: () ->
|
mount: () ->
|
||||||
me = @
|
|
||||||
$(@root).css "display", "block"
|
$(@root).css "display", "block"
|
||||||
$(@root).click (e) ->
|
$(@root).click (e) =>
|
||||||
me.cellseleck e, false
|
@cellseleck e, false
|
||||||
$(@root).dblclick (e) ->
|
$(@root).dblclick (e) =>
|
||||||
me.cellseleck e, true
|
@cellseleck e, true
|
||||||
|
|
||||||
|
|
||||||
cellseleck: (e, flag) ->
|
cellseleck: (e, flag) ->
|
||||||
@ -73,10 +72,9 @@ class GridViewTag extends Ant.OS.GUI.BaseTag
|
|||||||
@setopt "onrowselect", (e) ->
|
@setopt "onrowselect", (e) ->
|
||||||
@setopt "oncelldbclick", (e) ->
|
@setopt "oncelldbclick", (e) ->
|
||||||
@setopt "multiselect", false
|
@setopt "multiselect", false
|
||||||
me = @
|
@root.push = (r) => @push r, false
|
||||||
@root.push = (r) -> me.push r, false
|
@root.unshift = (r) => @unshift r
|
||||||
@root.unshift = (r) -> me.unshift r
|
@root.remove = (r) => @remove r
|
||||||
@root.remove = (r) -> me.remove r
|
|
||||||
|
|
||||||
__header__: (v) ->
|
__header__: (v) ->
|
||||||
return $(@refs.header).hide() if not v or v.length is 0
|
return $(@refs.header).hide() if not v or v.length is 0
|
||||||
@ -89,7 +87,6 @@ class GridViewTag extends Ant.OS.GUI.BaseTag
|
|||||||
@calibrate()
|
@calibrate()
|
||||||
|
|
||||||
__rows__: (rows) ->
|
__rows__: (rows) ->
|
||||||
me = @
|
|
||||||
$(@refs.grid).empty()
|
$(@refs.grid).empty()
|
||||||
for row in rows
|
for row in rows
|
||||||
@push row, false
|
@push row, false
|
||||||
@ -108,7 +105,6 @@ class GridViewTag extends Ant.OS.GUI.BaseTag
|
|||||||
|
|
||||||
|
|
||||||
push: (row, flag) ->
|
push: (row, flag) ->
|
||||||
me = @
|
|
||||||
rowel = $("<afx-grid-row>")
|
rowel = $("<afx-grid-row>")
|
||||||
.css "display", "contents"
|
.css "display", "contents"
|
||||||
rowel[0].uify undefined
|
rowel[0].uify undefined
|
||||||
@ -119,8 +115,8 @@ class GridViewTag extends Ant.OS.GUI.BaseTag
|
|||||||
el = $("<#{@get("cellitem")}>").appendTo rowel
|
el = $("<#{@get("cellitem")}>").appendTo rowel
|
||||||
cell.domel = el[0]
|
cell.domel = el[0]
|
||||||
el[0].uify undefined
|
el[0].uify undefined
|
||||||
el[0].set "oncellselect", (e) -> me.cellselect e, false
|
el[0].set "oncellselect", (e) => @cellselect e, false
|
||||||
el[0].set "oncelldbclick", (e) -> me.cellselect e, true
|
el[0].set "oncelldbclick", (e) => @cellselect e, true
|
||||||
el[0].set "data", cell
|
el[0].set "data", cell
|
||||||
if flag
|
if flag
|
||||||
$(@refs.grid).prepend rowel[0]
|
$(@refs.grid).prepend rowel[0]
|
||||||
@ -208,13 +204,12 @@ class GridViewTag extends Ant.OS.GUI.BaseTag
|
|||||||
$(@refs.header).css "grid-template-columns", template
|
$(@refs.header).css "grid-template-columns", template
|
||||||
|
|
||||||
mount: () ->
|
mount: () ->
|
||||||
me = @
|
|
||||||
$(@root)
|
$(@root)
|
||||||
.css "overflow", "hidden"
|
.css "overflow", "hidden"
|
||||||
|
|
||||||
$(@refs.grid).css "display", "grid"
|
$(@refs.grid).css "display", "grid"
|
||||||
$(@refs.header).css "display", "grid"
|
$(@refs.header).css "display", "grid"
|
||||||
@observable.on "resize", (e) -> me.calibrate()
|
@observable.on "resize", (e) => @calibrate()
|
||||||
$(@refs.container)
|
$(@refs.container)
|
||||||
.css "width", "100%"
|
.css "width", "100%"
|
||||||
.css "overflow-x", "hidden"
|
.css "overflow-x", "hidden"
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
class ListViewItemTag extends Ant.OS.GUI.BaseTag
|
class ListViewItemTag extends Ant.OS.GUI.BaseTag
|
||||||
constructor: (r, o) ->
|
constructor: (r, o) ->
|
||||||
super r, o
|
super r, o
|
||||||
me = @
|
|
||||||
@setopt "data", {}
|
@setopt "data", {}
|
||||||
@setopt "oncontextmenu", (e) ->
|
@setopt "oncontextmenu", (e) ->
|
||||||
@setopt "onclick", (e) ->
|
@setopt "onclick", (e) ->
|
||||||
@ -11,6 +10,7 @@ class ListViewItemTag extends Ant.OS.GUI.BaseTag
|
|||||||
@setopt "index", 0
|
@setopt "index", 0
|
||||||
@setopt "closable", false
|
@setopt "closable", false
|
||||||
@setopt "selected", false
|
@setopt "selected", false
|
||||||
|
|
||||||
__closable__: (v) ->
|
__closable__: (v) ->
|
||||||
if v then $(@refs.btcl).show() else $(@refs.btcl).hide()
|
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 })
|
@get("onselect")({ item: @root })
|
||||||
|
|
||||||
mount: () ->
|
mount: () ->
|
||||||
me = @
|
$(@refs.item).contextmenu (e) =>
|
||||||
$(@refs.item).contextmenu (e) ->
|
e.item = @root
|
||||||
e.item = me.root
|
@get("oncontextmenu")(e)
|
||||||
me.get("oncontextmenu")(e)
|
|
||||||
|
|
||||||
$(@refs.item).click (e) ->
|
$(@refs.item).click (e) =>
|
||||||
e.item = me.root
|
e.item = @root
|
||||||
me.get("onclick")(e)
|
@get("onclick")(e)
|
||||||
|
|
||||||
$(@refs.item).dblclick (e) ->
|
$(@refs.item).dblclick (e) =>
|
||||||
e.item = me.root
|
e.item = @root
|
||||||
me.get("ondbclick")(e)
|
@get("ondbclick")(e)
|
||||||
$(@refs.btcl).click (e) ->
|
$(@refs.btcl).click (e) =>
|
||||||
e.item = me.root
|
e.item = @root
|
||||||
me.get("onclose")(e)
|
@get("onclose")(e)
|
||||||
layout: () ->
|
layout: () ->
|
||||||
[{
|
[{
|
||||||
el: "li", ref: "item", children: [
|
el: "li", ref: "item", children: [
|
||||||
@ -60,6 +59,9 @@ class SimpleListItemTag extends ListViewItemTag
|
|||||||
@set "selected", v.selected if v.selected
|
@set "selected", v.selected if v.selected
|
||||||
@set "closable", v.closable if v.closable
|
@set "closable", v.closable if v.closable
|
||||||
|
|
||||||
|
__selected: (v) ->
|
||||||
|
@get("data").selected = v
|
||||||
|
|
||||||
update: () ->
|
update: () ->
|
||||||
@set "data", @get("data")
|
@set "data", @get("data")
|
||||||
|
|
||||||
@ -83,13 +85,12 @@ class ListViewTag extends Ant.OS.GUI.BaseTag
|
|||||||
$(@root)
|
$(@root)
|
||||||
.css "display", "flex"
|
.css "display", "flex"
|
||||||
.css "flex-direction", "column"
|
.css "flex-direction", "column"
|
||||||
me = @
|
@root.push = (e) => @push e
|
||||||
@root.push = (e) -> me.push e
|
@root.remove = (e) => @remove e
|
||||||
@root.remove = (e) -> me.remove e
|
@root.unshift = (e) => @unshift e
|
||||||
@root.unshift = (e) -> me.unshift e
|
@root.unselect = () => @unselect()
|
||||||
@root.unselect = () -> me.unselect()
|
@root.selectNext = () => @selectNext()
|
||||||
@root.selectNext = () -> me.selectNext()
|
@root.selectPrev = () => @selectPrev()
|
||||||
@root.selectPrev = () -> me.selectPrev()
|
|
||||||
|
|
||||||
multiselect: () ->
|
multiselect: () ->
|
||||||
return false if @get "dropdown"
|
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
|
@get("data").push item if not @has_data item
|
||||||
el.appendTo @refs.mlist
|
el.appendTo @refs.mlist
|
||||||
el[0].uify @observable
|
el[0].uify @observable
|
||||||
me = @
|
|
||||||
el[0]
|
el[0]
|
||||||
.set "oncontextmenu", (e) ->
|
.set "oncontextmenu", (e) =>
|
||||||
me.iclick e, true
|
@iclick e, true
|
||||||
.set "ondbclick", (e) ->
|
.set "ondbclick", (e) =>
|
||||||
me.idbclick e, false
|
@idbclick e, false
|
||||||
.set "onclick", (e) ->
|
.set "onclick", (e) =>
|
||||||
me.iclick e, false
|
@iclick e, false
|
||||||
.set "onselect", (e) ->
|
.set "onselect", (e) =>
|
||||||
me.iselect e
|
@iselect e
|
||||||
.set "onclose", (e) ->
|
.set "onclose", (e) =>
|
||||||
me.iclose e
|
@iclose e
|
||||||
.set "data", item
|
.set "data", item
|
||||||
item.domel = el[0]
|
item.domel = el[0]
|
||||||
el[0]
|
el[0]
|
||||||
@ -221,9 +221,8 @@ class ListViewTag extends Ant.OS.GUI.BaseTag
|
|||||||
@observable.trigger "listselect", evt
|
@observable.trigger "listselect", evt
|
||||||
|
|
||||||
mount: () ->
|
mount: () ->
|
||||||
me = @
|
|
||||||
$(@refs.btlist).hide()
|
$(@refs.btlist).hide()
|
||||||
@observable.on "resize", (e) -> me.calibrate()
|
@observable.on "resize", (e) => @calibrate()
|
||||||
@calibrate()
|
@calibrate()
|
||||||
|
|
||||||
iclose: (e) ->
|
iclose: (e) ->
|
||||||
@ -239,11 +238,10 @@ class ListViewTag extends Ant.OS.GUI.BaseTag
|
|||||||
$(@refs.mlist).removeAttr "style"
|
$(@refs.mlist).removeAttr "style"
|
||||||
$(@refs.container).css "flex", 1
|
$(@refs.container).css "flex", 1
|
||||||
$(@root).removeClass()
|
$(@root).removeClass()
|
||||||
me = @
|
drop = (e) =>
|
||||||
drop = (e) ->
|
@dropoff e
|
||||||
me.dropoff e
|
show = (e) =>
|
||||||
show = (e) ->
|
@showlist e
|
||||||
me.showlist e
|
|
||||||
if v
|
if v
|
||||||
$(@root).addClass "dropdown"
|
$(@root).addClass "dropdown"
|
||||||
$(@refs.current).show()
|
$(@refs.current).show()
|
||||||
|
@ -33,7 +33,6 @@ class MenuEntryTag extends Ant.OS.GUI.BaseTag
|
|||||||
]
|
]
|
||||||
}]
|
}]
|
||||||
__children__: (v) ->
|
__children__: (v) ->
|
||||||
me = @
|
|
||||||
$(@refs.container).removeClass("afx_submenu")
|
$(@refs.container).removeClass("afx_submenu")
|
||||||
return $(@refs.submenu).hide() unless v and v.length > 0
|
return $(@refs.submenu).hide() unless v and v.length > 0
|
||||||
$(@refs.container).addClass("afx_submenu")
|
$(@refs.container).addClass("afx_submenu")
|
||||||
@ -41,15 +40,14 @@ class MenuEntryTag extends Ant.OS.GUI.BaseTag
|
|||||||
.show()
|
.show()
|
||||||
.attr("style", "")
|
.attr("style", "")
|
||||||
@refs.submenu.set "parent", @
|
@refs.submenu.set "parent", @
|
||||||
@refs.submenu.set "root", me.get("root")
|
@refs.submenu.set "root", @get("root")
|
||||||
@refs.submenu.set "items", v
|
@refs.submenu.set "items", v
|
||||||
if @is_root()
|
if @is_root()
|
||||||
$(@refs.container).mouseleave (e) ->
|
$(@refs.container).mouseleave (e) =>
|
||||||
$(me.refs.submenu).attr("style", "")
|
$(@refs.submenu).attr("style", "")
|
||||||
|
|
||||||
mount: () ->
|
mount: () ->
|
||||||
me = @
|
$(@refs.entry).click (e) => @select e
|
||||||
$(@refs.entry).click (e) -> me.select e
|
|
||||||
|
|
||||||
submenuoff: () ->
|
submenuoff: () ->
|
||||||
p = @get "parent"
|
p = @get "parent"
|
||||||
@ -57,7 +55,6 @@ class MenuEntryTag extends Ant.OS.GUI.BaseTag
|
|||||||
p.submenuoff()
|
p.submenuoff()
|
||||||
|
|
||||||
select: (e) ->
|
select: (e) ->
|
||||||
me = @
|
|
||||||
e.item = @root
|
e.item = @root
|
||||||
evt = { id: @aid(), data: e }
|
evt = { id: @aid(), data: e }
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
@ -134,7 +131,6 @@ class SimpleMenuEntryTag extends MenuEntryTag
|
|||||||
|
|
||||||
mount: () ->
|
mount: () ->
|
||||||
super.mount()
|
super.mount()
|
||||||
me = @
|
|
||||||
@refs.switch.set "enable", false
|
@refs.switch.set "enable", false
|
||||||
|
|
||||||
select: (e) ->
|
select: (e) ->
|
||||||
@ -156,19 +152,18 @@ class SimpleMenuEntryTag extends MenuEntryTag
|
|||||||
class MenuTag extends Ant.OS.GUI.BaseTag
|
class MenuTag extends Ant.OS.GUI.BaseTag
|
||||||
constructor: (r, o) ->
|
constructor: (r, o) ->
|
||||||
super r, o
|
super r, o
|
||||||
me = @
|
|
||||||
@setopt "context", false
|
@setopt "context", false
|
||||||
@setopt "parent", undefined
|
@setopt "parent", undefined
|
||||||
@setopt "root", undefined
|
@setopt "root", undefined
|
||||||
@setopt "contentag", "afx-menu-entry"
|
@setopt "contentag", "afx-menu-entry"
|
||||||
@setopt "onmenuitemselect", (e) -> me.handleselect e
|
@setopt "onmenuitemselect", (e) => @handleselect e
|
||||||
@setopt "onmenuselect", (e) ->
|
@setopt "onmenuselect", (e) ->
|
||||||
@setopt "items", []
|
@setopt "items", []
|
||||||
@root.show = (e) ->
|
@root.show = (e) =>
|
||||||
me.showctxmenu e
|
@showctxmenu e
|
||||||
@root.push = (e) -> me.push e
|
@root.push = (e) => @push e
|
||||||
@root.remove = (e) -> me.remove e
|
@root.remove = (e) => @remove e
|
||||||
@root.unshift = (e) -> me.unshift e
|
@root.unshift = (e) => @unshift e
|
||||||
|
|
||||||
handleselect: (e) ->
|
handleselect: (e) ->
|
||||||
$(@root).hide() if @isctxmenu()
|
$(@root).hide() if @isctxmenu()
|
||||||
@ -190,12 +185,11 @@ class MenuTag extends Ant.OS.GUI.BaseTag
|
|||||||
return @get("root") is undefined
|
return @get("root") is undefined
|
||||||
|
|
||||||
mount: () ->
|
mount: () ->
|
||||||
me = @
|
|
||||||
$(@refs.container).css "display", "contents"
|
$(@refs.container).css "display", "contents"
|
||||||
return unless me.isctxmenu()
|
return unless @isctxmenu()
|
||||||
$(@refs.wrapper).mouseleave (e) ->
|
$(@refs.wrapper).mouseleave (e) =>
|
||||||
return unless me.is_root()
|
return unless @is_root()
|
||||||
$(me.root).hide()
|
$(@root).hide()
|
||||||
|
|
||||||
__context__: (v) ->
|
__context__: (v) ->
|
||||||
$(@refs.wrapper).removeClass("context")
|
$(@refs.wrapper).removeClass("context")
|
||||||
|
@ -7,24 +7,23 @@ class NSpinnerTag extends Ant.OS.GUI.BaseTag
|
|||||||
@setopt "step", 1
|
@setopt "step", 1
|
||||||
|
|
||||||
mount: () ->
|
mount: () ->
|
||||||
me = @
|
|
||||||
$(@refs.holder).attr "type", "text"
|
$(@refs.holder).attr "type", "text"
|
||||||
$(@refs.incr).click (e) ->
|
$(@refs.incr).click (e) =>
|
||||||
me.set "value", (me.get("value") + me.get("step") )
|
@set "value", (@get("value") + @get("step") )
|
||||||
|
|
||||||
$(@refs.decr).click (e) ->
|
$(@refs.decr).click (e) =>
|
||||||
me.set "value", (me.get("value") - me.get("step") )
|
@set "value", (@get("value") - @get("step") )
|
||||||
|
|
||||||
# @observable.on "calibrate", () -> me.calibrate()
|
# @observable.on "calibrate", () -> @calibrate()
|
||||||
@observable.on "resize", () -> me.calibrate()
|
@observable.on "resize", () => @calibrate()
|
||||||
|
|
||||||
$(@refs.holder).on 'keyup', (e) ->
|
$(@refs.holder).on 'keyup', (e) =>
|
||||||
if e.keyCode is 13
|
if e.keyCode is 13
|
||||||
val = me.refs.holder.value
|
val = @refs.holder.value
|
||||||
if not isNaN(val)
|
if not isNaN(val)
|
||||||
val = parseInt(val)
|
val = parseInt(val)
|
||||||
val = me.value if val < 0
|
val = @value if val < 0
|
||||||
me.set "value", val
|
@set "value", val
|
||||||
@calibrate()
|
@calibrate()
|
||||||
|
|
||||||
calibrate: () ->
|
calibrate: () ->
|
||||||
|
@ -28,16 +28,15 @@ class ResizerTag extends Ant.OS.GUI.BaseTag
|
|||||||
@draggable()
|
@draggable()
|
||||||
|
|
||||||
draggable: () ->
|
draggable: () ->
|
||||||
me = @
|
|
||||||
$(@root).css "user-select", "none"
|
$(@root).css "user-select", "none"
|
||||||
$(@root).on "mousedown", (e) ->
|
$(@root).on "mousedown", (e) =>
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
$(window).on "mousemove", (evt) ->
|
$(window).on "mousemove", (evt) =>
|
||||||
return unless me.resizable_el
|
return unless @resizable_el
|
||||||
if me.dir is "hz"
|
if @dir is "hz"
|
||||||
me.horizontalResize evt
|
@horizontalResize evt
|
||||||
else if me.dir is "ve"
|
else if @dir is "ve"
|
||||||
me.verticalResize evt
|
@verticalResize evt
|
||||||
|
|
||||||
$(window).on "mouseup", (evt) ->
|
$(window).on "mouseup", (evt) ->
|
||||||
$(window).unbind "mousemove", null
|
$(window).unbind "mousemove", null
|
||||||
|
@ -16,12 +16,11 @@ class SliderTag extends Ant.OS.GUI.BaseTag
|
|||||||
|
|
||||||
__dragable__: (v) ->
|
__dragable__: (v) ->
|
||||||
if v
|
if v
|
||||||
me = @
|
|
||||||
$(@root)
|
$(@root)
|
||||||
.mouseover () ->
|
.mouseover () =>
|
||||||
$(me.refs.point).show()
|
$(@refs.point).show()
|
||||||
.mouseout () ->
|
.mouseout () =>
|
||||||
$(me.refs.point).hide()
|
$(@refs.point).hide()
|
||||||
else
|
else
|
||||||
$(@refs.point).hide()
|
$(@refs.point).hide()
|
||||||
$(@root)
|
$(@root)
|
||||||
@ -29,21 +28,20 @@ class SliderTag extends Ant.OS.GUI.BaseTag
|
|||||||
.ubbind("mouseout")
|
.ubbind("mouseout")
|
||||||
|
|
||||||
mount: () ->
|
mount: () ->
|
||||||
me = @
|
|
||||||
@enable_dragging()
|
@enable_dragging()
|
||||||
$(@refs.point).css "position", "absolute"
|
$(@refs.point).css "position", "absolute"
|
||||||
$(@refs.point).hide()
|
$(@refs.point).hide()
|
||||||
@observable.on "resize", (e) ->
|
@observable.on "resize", (e) =>
|
||||||
me.calibrate()
|
@calibrate()
|
||||||
$(@refs.container).click (e) ->
|
$(@refs.container).click (e) =>
|
||||||
offset = $(me.refs.container).offset()
|
offset = $(@refs.container).offset()
|
||||||
left = e.clientX - offset.left
|
left = e.clientX - offset.left
|
||||||
maxw = $(me.refs.container).width()
|
maxw = $(@refs.container).width()
|
||||||
me.set "value", left * me.get("max") / maxw
|
@set "value", left * @get("max") / maxw
|
||||||
me.calibrate()
|
@calibrate()
|
||||||
evt = { id: me.aid(), data: me.get("value") }
|
evt = { id: @aid(), data: @get("value") }
|
||||||
me.get("onchange") evt
|
@get("onchange") evt
|
||||||
me.get("onchanging") evt
|
@get("onchanging") evt
|
||||||
@calibrate()
|
@calibrate()
|
||||||
|
|
||||||
calibrate: () ->
|
calibrate: () ->
|
||||||
@ -61,24 +59,23 @@ class SliderTag extends Ant.OS.GUI.BaseTag
|
|||||||
.css "top", top + "px"
|
.css "top", top + "px"
|
||||||
|
|
||||||
enable_dragging: () ->
|
enable_dragging: () ->
|
||||||
me = @
|
|
||||||
$(@refs.point)
|
$(@refs.point)
|
||||||
.css "user-select", "none"
|
.css "user-select", "none"
|
||||||
.css "cursor", "default"
|
.css "cursor", "default"
|
||||||
$(@refs.point).on "mousedown", (e) ->
|
$(@refs.point).on "mousedown", (e) =>
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
offset = $(me.refs.container).offset()
|
offset = $(@refs.container).offset()
|
||||||
$(window).on "mousemove", (e) ->
|
$(window).on "mousemove", (e) =>
|
||||||
left = e.clientX - offset.left
|
left = e.clientX - offset.left
|
||||||
left = if left < 0 then 0 else 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
|
left = if left > maxw then maxw else left
|
||||||
me.set "value", left * me.get("max") / maxw
|
@set "value", left * @get("max") / maxw
|
||||||
me.calibrate()
|
@calibrate()
|
||||||
me.get("onchanging") { id: me.aid(), data: me.get("value") }
|
@get("onchanging") { id: @aid(), data: @get("value") }
|
||||||
|
|
||||||
$(window).on "mouseup", (e) ->
|
$(window).on "mouseup", (e) =>
|
||||||
me.get("onchange") { id: me.aid(), data: me.get("value") }
|
@get("onchange") { id: @aid(), data: @get("value") }
|
||||||
$(window).unbind("mousemove", null)
|
$(window).unbind("mousemove", null)
|
||||||
$(window).unbind("mouseup", null)
|
$(window).unbind("mouseup", null)
|
||||||
|
|
||||||
|
@ -7,9 +7,8 @@ class SwitchTag extends Ant.OS.GUI.BaseTag
|
|||||||
@setopt "onchange", (e) ->
|
@setopt "onchange", (e) ->
|
||||||
|
|
||||||
mount: () ->
|
mount: () ->
|
||||||
me = @
|
$(@refs.switch).click (e) =>
|
||||||
$(@refs.switch).click (e) ->
|
@onchange(e)
|
||||||
me.onchange(e)
|
|
||||||
|
|
||||||
onchange: (e) ->
|
onchange: (e) ->
|
||||||
return unless @get "enable"
|
return unless @get "enable"
|
||||||
|
@ -1,15 +1,14 @@
|
|||||||
class SystemPanelTag extends Ant.OS.GUI.BaseTag
|
class SystemPanelTag extends Ant.OS.GUI.BaseTag
|
||||||
constructor: (r, o) ->
|
constructor: (r, o) ->
|
||||||
super r, o
|
super r, o
|
||||||
me = @
|
|
||||||
@setopt "osmenu", {
|
@setopt "osmenu", {
|
||||||
text: __("Start"),
|
text: __("Start"),
|
||||||
iconclass: "fa fa-eercast"
|
iconclass: "fa fa-eercast"
|
||||||
}
|
}
|
||||||
@setopt "appmenu", []
|
@setopt "appmenu", []
|
||||||
@setopt "systray", []
|
@setopt "systray", []
|
||||||
@root.attachservice = (s) -> me.attachservice s
|
@root.attachservice = (s) => @attachservice s
|
||||||
@root.detachservice = (s) -> me.detachservice s
|
@root.detachservice = (s) => @detachservice s
|
||||||
@view = false
|
@view = false
|
||||||
|
|
||||||
__osmenu__: (v) ->
|
__osmenu__: (v) ->
|
||||||
@ -118,50 +117,49 @@ class SystemPanelTag extends Ant.OS.GUI.BaseTag
|
|||||||
@refs.overlay.set "height", "#{$(window).height() - $(@refs.panel).height()}px"
|
@refs.overlay.set "height", "#{$(window).height() - $(@refs.panel).height()}px"
|
||||||
|
|
||||||
mount: () ->
|
mount: () ->
|
||||||
me = @
|
@cb = (e) =>
|
||||||
@cb = (e) ->
|
if not ($ e.target).closest($ @refs.overlay).length and not ($ e.target).closest(@refs.osmenu).length
|
||||||
if not ($ e.target).closest($ me.refs.overlay).length and not ($ e.target).closest(me.refs.osmenu).length
|
@toggle false
|
||||||
me.toggle false
|
|
||||||
else
|
else
|
||||||
$(me.refs.search).focus()
|
$(@refs.search).focus()
|
||||||
$(@refs.appmenu).css("z-index", 1000000)
|
$(@refs.appmenu).css("z-index", 1000000)
|
||||||
$(@refs.systray).css("z-index", 1000000)
|
$(@refs.systray).css("z-index", 1000000)
|
||||||
@refs.btscreen.set "*", {
|
@refs.btscreen.set "*", {
|
||||||
iconclass: "fa fa-tv",
|
iconclass: "fa fa-tv",
|
||||||
onbtclick: (e) ->
|
onbtclick: (e) =>
|
||||||
me.toggle false
|
@toggle false
|
||||||
Ant.OS.GUI.toggleFullscreen()
|
Ant.OS.GUI.toggleFullscreen()
|
||||||
}
|
}
|
||||||
@refs.btuser.set "*", {
|
@refs.btuser.set "*", {
|
||||||
iconclass: "fa fa-user-circle-o",
|
iconclass: "fa fa-user-circle-o",
|
||||||
onbtclick: (e) ->
|
onbtclick: (e) =>
|
||||||
me.toggle false
|
@toggle false
|
||||||
Ant.OS.GUI.openDialog("InfoDialog", Ant.OS.setting.user)
|
Ant.OS.GUI.openDialog("InfoDialog", Ant.OS.setting.user)
|
||||||
}
|
}
|
||||||
@refs.btlogout.set "*", {
|
@refs.btlogout.set "*", {
|
||||||
iconclass: "fa fa-power-off",
|
iconclass: "fa fa-power-off",
|
||||||
onbtclick: (e) ->
|
onbtclick: (e) =>
|
||||||
me.toggle false
|
@toggle false
|
||||||
Ant.OS.exit()
|
Ant.OS.exit()
|
||||||
}
|
}
|
||||||
@refs.osmenu.set "onmenuselect", (e) ->
|
@refs.osmenu.set "onmenuselect", (e) =>
|
||||||
me.toggle true
|
@toggle true
|
||||||
|
|
||||||
($ @refs.overlay).css "left", 0
|
($ @refs.overlay).css "left", 0
|
||||||
.css "top", "#{$(@refs.panel).height()}px"
|
.css "top", "#{$(@refs.panel).height()}px"
|
||||||
.css "bottom", "0"
|
.css "bottom", "0"
|
||||||
.hide()
|
.hide()
|
||||||
($ @refs.search).keyup (e) ->
|
($ @refs.search).keyup (e) =>
|
||||||
me.search e
|
@search e
|
||||||
|
|
||||||
$(@refs.applist).click (e) ->
|
$(@refs.applist).click (e) =>
|
||||||
me.open()
|
@open()
|
||||||
Ant.OS.GUI.bindKey "CTRL- ", (e) ->
|
Ant.OS.GUI.bindKey "CTRL- ", (e) =>
|
||||||
if me.view is false
|
if @view is false
|
||||||
me.toggle true
|
@toggle true
|
||||||
else
|
else
|
||||||
me.toggle false
|
@toggle false
|
||||||
me.view = not me.view
|
@view = not @view
|
||||||
Ant.OS.announcer.trigger("syspanelloaded")
|
Ant.OS.announcer.trigger("syspanelloaded")
|
||||||
|
|
||||||
Ant.OS.GUI.define "afx-sys-panel", SystemPanelTag
|
Ant.OS.GUI.define "afx-sys-panel", SystemPanelTag
|
@ -6,15 +6,14 @@ class TabBarTag extends Ant.OS.GUI.BaseTag
|
|||||||
@setopt "ontabclose", (e) ->
|
@setopt "ontabclose", (e) ->
|
||||||
@setopt "items", []
|
@setopt "items", []
|
||||||
@setopt "selected", -1
|
@setopt "selected", -1
|
||||||
me = @
|
@root.push = (e) =>
|
||||||
@root.push = (e) ->
|
e.closable = @get "closable"
|
||||||
e.closable = me.get "closable"
|
@refs.list.push e
|
||||||
me.refs.list.push e
|
@root.remove = (e) => @refs.list.remove e
|
||||||
@root.remove = (e) -> me.refs.list.remove e
|
@root.unshift = (e) => @refs.list.unshift e
|
||||||
@root.unshift = (e) -> me.refs.list.unshift e
|
@refs.list.set "onlistselect", (e) =>
|
||||||
@refs.list.set "onlistselect", (e) ->
|
@get("ontabselect") e
|
||||||
me.get("ontabselect") e
|
@observable.trigger "tabselect", e
|
||||||
me.observable.trigger "tabselect", e
|
|
||||||
|
|
||||||
__items__: (v) ->
|
__items__: (v) ->
|
||||||
i.closable = @get "closable" for i in 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
|
@refs.list.set "selected", v
|
||||||
|
|
||||||
mount: () ->
|
mount: () ->
|
||||||
me = @
|
|
||||||
$(@refs.list).css "height", "100%"
|
$(@refs.list).css "height", "100%"
|
||||||
@refs.list.set "onitemclose", (e) ->
|
@refs.list.set "onitemclose", (e) =>
|
||||||
e.id = me.aid()
|
e.id = @aid()
|
||||||
me.get("ontabclose") e
|
@get("ontabclose") e
|
||||||
|
|
||||||
layout: () ->
|
layout: () ->
|
||||||
[{
|
[{
|
||||||
|
@ -6,11 +6,10 @@ class TabContainerTag extends Ant.OS.GUI.BaseTag
|
|||||||
@setopt "tabbarwidth", undefined
|
@setopt "tabbarwidth", undefined
|
||||||
@setopt "tabbarheight", undefined
|
@setopt "tabbarheight", undefined
|
||||||
@setopt "ontabselect", () ->
|
@setopt "ontabselect", () ->
|
||||||
me = @
|
@refs.bar.set "ontabselect", (e) =>
|
||||||
@refs.bar.set "ontabselect", (e) ->
|
|
||||||
data = e.data.item.get "data"
|
data = e.data.item.get "data"
|
||||||
me.set "selectedTab", data
|
@set "selectedTab", data
|
||||||
me.get("ontabselect") { data: data, id: me.aid() }
|
@get("ontabselect") { data: data, id: @aid() }
|
||||||
|
|
||||||
__selectedTab: (v) ->
|
__selectedTab: (v) ->
|
||||||
return unless v
|
return unless v
|
||||||
@ -34,19 +33,18 @@ class TabContainerTag extends Ant.OS.GUI.BaseTag
|
|||||||
@set "tabsize", @get("tabsize")
|
@set "tabsize", @get("tabsize")
|
||||||
|
|
||||||
mount: () ->
|
mount: () ->
|
||||||
me = @
|
$(@children).each (i, e) =>
|
||||||
$(@children).each () ->
|
|
||||||
item = {}
|
item = {}
|
||||||
item.text = $(@).attr "tabname" if $(@).attr "tabname"
|
item.text = $(e).attr "tabname" if $(e).attr "tabname"
|
||||||
item.icon = $(@).attr "icon" if $(@).attr "icon"
|
item.icon = $(e).attr "icon" if $(e).attr "icon"
|
||||||
item.iconclass = $(@).attr "iconclass" if $(@).attr "iconclass"
|
item.iconclass = $(e).attr "iconclass" if $(e).attr "iconclass"
|
||||||
item.container = @
|
item.container = e
|
||||||
$(@)
|
$(e)
|
||||||
.css "width", "100%"
|
.css "width", "100%"
|
||||||
.css "height", "100%"
|
.css "height", "100%"
|
||||||
el = me.refs.bar.push item
|
el = @refs.bar.push item
|
||||||
el.set "selected", true
|
el.set "selected", true
|
||||||
@observable.on "resize", (e) -> me.calibrate()
|
@observable.on "resize", (e) => @calibrate()
|
||||||
@calibrate()
|
@calibrate()
|
||||||
|
|
||||||
calibrate: () ->
|
calibrate: () ->
|
||||||
|
@ -23,8 +23,7 @@ class TileLayoutTag extends Ant.OS.GUI.BaseTag
|
|||||||
@calibrate()
|
@calibrate()
|
||||||
|
|
||||||
mount: () ->
|
mount: () ->
|
||||||
me = @
|
@observable.on "resize", (e) => @calibrate()
|
||||||
@observable.on "resize", (e) -> me.calibrate()
|
|
||||||
@calibrate()
|
@calibrate()
|
||||||
|
|
||||||
calibrate: () ->
|
calibrate: () ->
|
||||||
|
@ -22,16 +22,15 @@ class TreeViewItemPrototype extends Ant.OS.GUI.BaseTag
|
|||||||
return $(@refs.wrapper).addClass("afx_tree_item_selected") if v
|
return $(@refs.wrapper).addClass("afx_tree_item_selected") if v
|
||||||
|
|
||||||
__open__: (v) ->
|
__open__: (v) ->
|
||||||
me = @
|
|
||||||
return unless @is_folder()
|
return unless @is_folder()
|
||||||
$(@refs.toggle)
|
$(@refs.toggle)
|
||||||
.removeClass()
|
.removeClass()
|
||||||
if(v)
|
if(v)
|
||||||
if @get("fetch")
|
if @get("fetch")
|
||||||
@get("fetch")(@root)
|
@get("fetch")(@root)
|
||||||
.then (d) ->
|
.then (d) =>
|
||||||
return unless d
|
return unless d
|
||||||
me.set "nodes", d
|
@.set "nodes", d
|
||||||
.catch (e) -> Ant.OS.announcer.oserror e
|
.catch (e) -> Ant.OS.announcer.oserror e
|
||||||
$(@refs.childnodes).show()
|
$(@refs.childnodes).show()
|
||||||
else
|
else
|
||||||
@ -76,7 +75,6 @@ class TreeViewItemPrototype extends Ant.OS.GUI.BaseTag
|
|||||||
|
|
||||||
|
|
||||||
mount: () ->
|
mount: () ->
|
||||||
me = @
|
|
||||||
super.mount()
|
super.mount()
|
||||||
$(@refs.container)
|
$(@refs.container)
|
||||||
.css "padding", 0
|
.css "padding", 0
|
||||||
@ -85,20 +83,20 @@ class TreeViewItemPrototype extends Ant.OS.GUI.BaseTag
|
|||||||
$(@refs.itemholder)
|
$(@refs.itemholder)
|
||||||
.css "display", "inline-block"
|
.css "display", "inline-block"
|
||||||
$(@refs.wrapper)
|
$(@refs.wrapper)
|
||||||
.click (e) ->
|
.click (e) =>
|
||||||
e.item = me.root
|
e.item = @root
|
||||||
me.get("treeroot").itemclick e, false
|
@get("treeroot").itemclick e, false
|
||||||
$(@refs.wrapper)
|
$(@refs.wrapper)
|
||||||
.dblclick (e) ->
|
.dblclick (e) =>
|
||||||
e.item = me.root
|
e.item = @root
|
||||||
me.get("treeroot").itemclick e, true
|
@get("treeroot").itemclick e, true
|
||||||
|
|
||||||
$(@refs.toggle)
|
$(@refs.toggle)
|
||||||
.css "display", "inline-block"
|
.css "display", "inline-block"
|
||||||
.css "width", "15px"
|
.css "width", "15px"
|
||||||
.addClass "afx-tree-view-item"
|
.addClass "afx-tree-view-item"
|
||||||
.click (e) ->
|
.click (e) =>
|
||||||
me.set "open", not me.get("open")
|
@set "open", not @get("open")
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
e.stopPropagation()
|
e.stopPropagation()
|
||||||
|
|
||||||
|
@ -19,16 +19,15 @@ class WindowTag extends Ant.OS.GUI.BaseTag
|
|||||||
$(this).css "height", "#{ch}px"
|
$(this).css "height", "#{ch}px"
|
||||||
|
|
||||||
mount: () ->
|
mount: () ->
|
||||||
me = @
|
|
||||||
@root.contextmenuHandle = (e) ->
|
@root.contextmenuHandle = (e) ->
|
||||||
$(@refs["minbt"]).click (e) ->
|
$(@refs["minbt"]).click (e) =>
|
||||||
me.observable.trigger "hide", { id: me.aid() }
|
@observable.trigger "hide", { id: @aid() }
|
||||||
|
|
||||||
$(@refs["maxbt"]).click (e) ->
|
$(@refs["maxbt"]).click (e) =>
|
||||||
me.toggle_window()
|
@toggle_window()
|
||||||
|
|
||||||
$(@refs["closebt"]).click (e) ->
|
$(@refs["closebt"]).click (e) =>
|
||||||
me.observable.trigger("exit", { id: me.aid() })
|
@observable.trigger("exit", { id: @aid() })
|
||||||
left = ($(@desktop).width() - (@get "width")) / 2
|
left = ($(@desktop).width() - (@get "width")) / 2
|
||||||
top = ($(@desktop).height() - (@get "height")) / 2
|
top = ($(@desktop).height() - (@get "height")) / 2
|
||||||
$(@root)
|
$(@root)
|
||||||
@ -36,41 +35,41 @@ class WindowTag extends Ant.OS.GUI.BaseTag
|
|||||||
.css("left", "#{left}px")
|
.css("left", "#{left}px")
|
||||||
.css("top", "#{top}px")
|
.css("top", "#{top}px")
|
||||||
.css("z-index", Ant.OS.GUI.zindex++)
|
.css("z-index", Ant.OS.GUI.zindex++)
|
||||||
$(@root).on "mousedown", (e) ->
|
$(@root).on "mousedown", (e) =>
|
||||||
return if me.shown
|
return if @shown
|
||||||
me.observable.trigger "focus", { id: me.aid() }
|
@observable.trigger "focus", { id: @aid() }
|
||||||
|
|
||||||
$(@refs["dragger"]).dblclick (e) ->
|
$(@refs["dragger"]).dblclick (e) =>
|
||||||
me.toggle_window()
|
@toggle_window()
|
||||||
|
|
||||||
|
|
||||||
@observable.on "resize", (e) -> me.resize()
|
@observable.on "resize", (e) => @resize()
|
||||||
|
|
||||||
@observable.on "focus", () ->
|
@observable.on "focus", () =>
|
||||||
Ant.OS.GUI.zindex++
|
Ant.OS.GUI.zindex++
|
||||||
$(me.root)
|
$(@root)
|
||||||
.show()
|
.show()
|
||||||
.css("z-index", Ant.OS.GUI.zindex)
|
.css("z-index", Ant.OS.GUI.zindex)
|
||||||
.removeClass("unactive")
|
.removeClass("unactive")
|
||||||
me.shown = true
|
@shown = true
|
||||||
|
|
||||||
@observable.on "blur", () ->
|
@observable.on "blur", () =>
|
||||||
me.shown = false
|
@shown = false
|
||||||
$(me.root)
|
$(@root)
|
||||||
.addClass("unactive")
|
.addClass("unactive")
|
||||||
@observable.on "hide", () ->
|
@observable.on "hide", () =>
|
||||||
$(me.root).hide()
|
$(@root).hide()
|
||||||
me.shown = false
|
@shown = false
|
||||||
|
|
||||||
@observable.on "toggle", () ->
|
@observable.on "toggle", () =>
|
||||||
if me.shown
|
if @shown
|
||||||
me.observable.trigger "hide", { id: me.aid() }
|
@observable.trigger "hide", { id: @aid() }
|
||||||
else
|
else
|
||||||
me.observable.trigger "focus", { id: me.aid() }
|
@observable.trigger "focus", { id: @aid() }
|
||||||
@enable_dragging()
|
@enable_dragging()
|
||||||
@enable_resize()
|
@enable_resize()
|
||||||
@setsize { w: (@get "width"), h: (@get "height") }
|
@setsize { w: (@get "width"), h: (@get "height") }
|
||||||
@observable.trigger "rendered", { id: me.aid() }
|
@observable.trigger "rendered", { id: @aid() }
|
||||||
|
|
||||||
__minimizable__: (value) ->
|
__minimizable__: (value) ->
|
||||||
if value then $(@refs["minbt"]).show() else $(@refs["minbt"]).hide()
|
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
|
$(@refs["dragger"]).text value.__() if value
|
||||||
|
|
||||||
enable_dragging: () ->
|
enable_dragging: () ->
|
||||||
me = @
|
|
||||||
$(@refs["dragger"])
|
$(@refs["dragger"])
|
||||||
.css("user-select", "none")
|
.css("user-select", "none")
|
||||||
.css("cursor", "default")
|
.css("cursor", "default")
|
||||||
$(@refs["dragger"]).on "mousedown", (e) ->
|
$(@refs["dragger"]).on "mousedown", (e) =>
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
offset = $(me.root).offset()
|
offset = $(@root).offset()
|
||||||
offset.top = e.clientY - offset.top
|
offset.top = e.clientY - offset.top
|
||||||
offset.left = e.clientX - offset.left
|
offset.left = e.clientX - offset.left
|
||||||
$(window).on "mousemove", (e) ->
|
$(window).on "mousemove", (e) =>
|
||||||
if me.isMaxi
|
if @isMaxi
|
||||||
me.toggle_window()
|
@toggle_window()
|
||||||
top = 0
|
top = 0
|
||||||
letf = e.clientX - $(me.root).width() / 2
|
letf = e.clientX - $(@root).width() / 2
|
||||||
offset.top = 10
|
offset.top = 10
|
||||||
offset.left = $(me.root).width() / 2
|
offset.left = $(@root).width() / 2
|
||||||
else
|
else
|
||||||
top = e.clientY - offset.top - me.desktop_pos.top
|
top = e.clientY - offset.top - @desktop_pos.top
|
||||||
left = e.clientX - me.desktop_pos.top - offset.left
|
left = e.clientX - @desktop_pos.top - offset.left
|
||||||
left = if left < 0 then 0 else left
|
left = if left < 0 then 0 else left
|
||||||
top = if top < 0 then 0 else top
|
top = if top < 0 then 0 else top
|
||||||
|
|
||||||
$(me.root)
|
$(@root)
|
||||||
.css("top", "#{top}px")
|
.css("top", "#{top}px")
|
||||||
.css("left", "#{left}px")
|
.css("left", "#{left}px")
|
||||||
$(window).on "mouseup", (e) ->
|
$(window).on "mouseup", (e) ->
|
||||||
@ -134,7 +132,6 @@ class WindowTag extends Ant.OS.GUI.BaseTag
|
|||||||
$(window).unbind "mouseup", null
|
$(window).unbind "mouseup", null
|
||||||
|
|
||||||
enable_resize: () ->
|
enable_resize: () ->
|
||||||
me = @
|
|
||||||
$(@refs["grip"])
|
$(@refs["grip"])
|
||||||
.css("user-select", "none")
|
.css("user-select", "none")
|
||||||
.css("cursor", "default")
|
.css("cursor", "default")
|
||||||
@ -143,20 +140,20 @@ class WindowTag extends Ant.OS.GUI.BaseTag
|
|||||||
.css("right", "0")
|
.css("right", "0")
|
||||||
.css("cursor", "nwse-resize")
|
.css("cursor", "nwse-resize")
|
||||||
|
|
||||||
$(@refs["grip"]).on "mousedown", (e) ->
|
$(@refs["grip"]).on "mousedown", (e) =>
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
offset = { top: 0, left: 0 }
|
offset = { top: 0, left: 0 }
|
||||||
offset.top = e.clientY
|
offset.top = e.clientY
|
||||||
offset.left = e.clientX
|
offset.left = e.clientX
|
||||||
$(window).on "mousemove", (e) ->
|
$(window).on "mousemove", (e) =>
|
||||||
w = $(me.root).width() + e.clientX - offset.left
|
w = $(@root).width() + e.clientX - offset.left
|
||||||
h = $(me.root).height() + e.clientY - offset.top
|
h = $(@root).height() + e.clientY - offset.top
|
||||||
w = if w < 100 then 100 else w
|
w = if w < 100 then 100 else w
|
||||||
h = if h < 100 then 100 else h
|
h = if h < 100 then 100 else h
|
||||||
offset.top = e.clientY
|
offset.top = e.clientY
|
||||||
offset.left = e.clientX
|
offset.left = e.clientX
|
||||||
me.isMaxi = false
|
@isMaxi = false
|
||||||
me.setsize { w: w, h: h }
|
@setsize { w: w, h: h }
|
||||||
|
|
||||||
$(window).on "mouseup", (e) ->
|
$(window).on "mouseup", (e) ->
|
||||||
$(window).unbind "mousemove", null
|
$(window).unbind "mousemove", null
|
||||||
@ -164,7 +161,6 @@ class WindowTag extends Ant.OS.GUI.BaseTag
|
|||||||
|
|
||||||
toggle_window: () ->
|
toggle_window: () ->
|
||||||
return unless @get "resizable"
|
return unless @get "resizable"
|
||||||
me = @
|
|
||||||
if @isMaxi is false
|
if @isMaxi is false
|
||||||
@history = {
|
@history = {
|
||||||
top: $(@root).css("top"),
|
top: $(@root).css("top"),
|
||||||
|
@ -3,17 +3,16 @@ Ant.OS.GUI.zindex = 10
|
|||||||
class Ant.OS.GUI.BaseTag
|
class Ant.OS.GUI.BaseTag
|
||||||
constructor: (@root, @observable) ->
|
constructor: (@root, @observable) ->
|
||||||
@opts = {}
|
@opts = {}
|
||||||
me = @
|
|
||||||
@observable = new Ant.OS.API.Announcer() unless @observable
|
@observable = new Ant.OS.API.Announcer() unless @observable
|
||||||
# export to rootnode
|
# export to rootnode
|
||||||
@root.observable = @observable
|
@root.observable = @observable
|
||||||
@root.set = (k, v) -> me.set k, v
|
@root.set = (k, v) => @set k, v
|
||||||
@root.get = (k) -> me.get k
|
@root.get = (k) => @get k
|
||||||
@root.aid = () -> me.aid()
|
@root.aid = () => @aid()
|
||||||
@root.calibrate = () -> me.calibrate()
|
@root.calibrate = () => @calibrate()
|
||||||
@root.sync = () -> me.sync()
|
@root.sync = () => @sync()
|
||||||
@mounted = false
|
@mounted = false
|
||||||
@root.setup = () -> me.setup()
|
@root.setup = () => @setup()
|
||||||
@refs = {}
|
@refs = {}
|
||||||
@setopt "data-id", (Math.floor(Math.random() * 100000) + 1).toString()
|
@setopt "data-id", (Math.floor(Math.random() * 100000) + 1).toString()
|
||||||
@setopt "tooltip", undefined
|
@setopt "tooltip", undefined
|
||||||
@ -28,7 +27,7 @@ class Ant.OS.GUI.BaseTag
|
|||||||
$(v).detach().appendTo @refs.yield for v in @children
|
$(v).detach().appendTo @refs.yield for v in @children
|
||||||
else
|
else
|
||||||
@children = []
|
@children = []
|
||||||
$(@root).children().each () -> @.mkui me.observable
|
$(@root).children().each (i, e) => e.mkui @observable
|
||||||
|
|
||||||
__: (k, v) ->
|
__: (k, v) ->
|
||||||
@set k, v if v
|
@set k, v if v
|
||||||
|
@ -75,20 +75,19 @@ class BaseFileHandle
|
|||||||
|
|
||||||
b64: (t) ->
|
b64: (t) ->
|
||||||
# t is object or mime type
|
# 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
|
m = if t is "object" then "text/plain" else t
|
||||||
return resolve "" unless me.cache
|
return resolve "" unless @cache
|
||||||
if t is "object" or typeof me.cache is "string"
|
if t is "object" or typeof @cache is "string"
|
||||||
if t is "object"
|
if t is "object"
|
||||||
b64 = (JSON.stringify me.cache).asBase64()
|
b64 = (JSON.stringify @cache).asBase64()
|
||||||
else
|
else
|
||||||
b64 = me.cache.asBase64()
|
b64 = @cache.asBase64()
|
||||||
b64 = "data:#{m};base64,#{b64}"
|
b64 = "data:#{m};base64,#{b64}"
|
||||||
resolve(b64)
|
resolve(b64)
|
||||||
else
|
else
|
||||||
reader = new FileReader()
|
reader = new FileReader()
|
||||||
reader.readAsDataURL(me.cache)
|
reader.readAsDataURL(@cache)
|
||||||
reader.onload = () ->
|
reader.onload = () ->
|
||||||
resolve reader.result
|
resolve reader.result
|
||||||
reader.onerror = (e) ->
|
reader.onerror = (e) ->
|
||||||
@ -101,23 +100,21 @@ class BaseFileHandle
|
|||||||
|
|
||||||
onready: () ->
|
onready: () ->
|
||||||
# read meta data
|
# read meta data
|
||||||
me = @
|
new Promise (resolve, reject) =>
|
||||||
new Promise (resolve, reject) ->
|
return resolve(@info) if @ready
|
||||||
return resolve(me.info) if me.ready
|
@meta()
|
||||||
me.meta()
|
.then (d) =>
|
||||||
.then (d) ->
|
|
||||||
return reject d if d.errors
|
return reject d if d.errors
|
||||||
me.info = d.result
|
@info = d.result
|
||||||
me.ready = true
|
@ready = true
|
||||||
resolve(d.result)
|
resolve(d.result)
|
||||||
.catch (e) -> reject e
|
.catch (e) -> reject e
|
||||||
|
|
||||||
read: (t) ->
|
read: (t) ->
|
||||||
me = @
|
new Promise (resolve, reject) =>
|
||||||
new Promise (resolve, reject) ->
|
@onready()
|
||||||
me.onready()
|
.then (r) =>
|
||||||
.then (r) ->
|
@_rd(t)
|
||||||
me._rd(t)
|
|
||||||
.then (d) ->
|
.then (d) ->
|
||||||
# Ant.OS.announcer.ostrigger "VFS", { m: "read", file: me }
|
# Ant.OS.announcer.ostrigger "VFS", { m: "read", file: me }
|
||||||
resolve d
|
resolve d
|
||||||
@ -125,94 +122,86 @@ class BaseFileHandle
|
|||||||
.catch (e) -> reject e
|
.catch (e) -> reject e
|
||||||
|
|
||||||
write: (t) ->
|
write: (t) ->
|
||||||
me = @
|
new Promise (resolve, reject) =>
|
||||||
new Promise (resolve, reject) ->
|
@_wr(t)
|
||||||
me._wr(t)
|
.then (r) =>
|
||||||
.then (r) ->
|
Ant.OS.announcer.ostrigger "VFS", { m: "write", file: @ }
|
||||||
Ant.OS.announcer.ostrigger "VFS", { m: "write", file: me }
|
|
||||||
resolve r
|
resolve r
|
||||||
.catch (e) -> reject e
|
.catch (e) -> reject e
|
||||||
|
|
||||||
mk: (d) ->
|
mk: (d) ->
|
||||||
me = @
|
new Promise (resolve, reject) =>
|
||||||
new Promise (resolve, reject) ->
|
@onready()
|
||||||
me.onready()
|
.then (r) =>
|
||||||
.then (r) ->
|
@_mk(d)
|
||||||
me._mk(d)
|
.then (d) =>
|
||||||
.then (d) ->
|
Ant.OS.announcer.ostrigger "VFS", { m: "mk", file: @ }
|
||||||
Ant.OS.announcer.ostrigger "VFS", { m: "mk", file: me }
|
|
||||||
resolve d
|
resolve d
|
||||||
.catch (e) -> reject e
|
.catch (e) -> reject e
|
||||||
.catch (e) -> reject e
|
.catch (e) -> reject e
|
||||||
|
|
||||||
remove: () ->
|
remove: () ->
|
||||||
me = @
|
new Promise (resolve, reject) =>
|
||||||
new Promise (resolve, reject) ->
|
@onready()
|
||||||
me.onready()
|
.then (r) =>
|
||||||
.then (r) ->
|
@_rm()
|
||||||
me._rm()
|
.then (d) =>
|
||||||
.then (d) ->
|
Ant.OS.announcer.ostrigger "VFS", { m: "remove", file: @ }
|
||||||
Ant.OS.announcer.ostrigger "VFS", { m: "remove", file: me }
|
|
||||||
resolve d
|
resolve d
|
||||||
.catch (e) -> reject e
|
.catch (e) -> reject e
|
||||||
.catch (e) -> reject e
|
.catch (e) -> reject e
|
||||||
|
|
||||||
upload: () ->
|
upload: () ->
|
||||||
me = @
|
new Promise (resolve, reject) =>
|
||||||
new Promise (resolve, reject) ->
|
@onready()
|
||||||
me.onready()
|
.then (r) =>
|
||||||
.then (r) ->
|
@_up()
|
||||||
me._up()
|
.then (d) =>
|
||||||
.then (d) ->
|
Ant.OS.announcer.ostrigger "VFS", { m: "upload", file: @ }
|
||||||
Ant.OS.announcer.ostrigger "VFS", { m: "upload", file: me }
|
|
||||||
resolve d
|
resolve d
|
||||||
.catch (e) -> reject e
|
.catch (e) -> reject e
|
||||||
.catch (e) -> reject e
|
.catch (e) -> reject e
|
||||||
|
|
||||||
publish: () ->
|
publish: () ->
|
||||||
me = @
|
new Promise (resolve, reject) =>
|
||||||
new Promise (resolve, reject) ->
|
@onready()
|
||||||
me.onready()
|
.then (r) =>
|
||||||
.then (r) ->
|
@_pub()
|
||||||
me._pub()
|
.then (d) =>
|
||||||
.then (d) ->
|
Ant.OS.announcer.ostrigger "VFS", { m: "publish", file: @ }
|
||||||
Ant.OS.announcer.ostrigger "VFS", { m: "publish", file: me }
|
|
||||||
resolve d
|
resolve d
|
||||||
.catch (e) -> reject e
|
.catch (e) -> reject e
|
||||||
.catch (e) -> reject e
|
.catch (e) -> reject e
|
||||||
|
|
||||||
download: () ->
|
download: () ->
|
||||||
me = @
|
new Promise (resolve, reject) =>
|
||||||
new Promise (resolve, reject) ->
|
@onready()
|
||||||
me.onready()
|
.then (r) =>
|
||||||
.then (r) ->
|
@_down()
|
||||||
me._down()
|
.then (d) =>
|
||||||
.then (d) ->
|
Ant.OS.announcer.ostrigger "VFS", { m: "download", file: @ }
|
||||||
Ant.OS.announcer.ostrigger "VFS", { m: "download", file: me }
|
|
||||||
resolve d
|
resolve d
|
||||||
.catch (e) -> reject e
|
.catch (e) -> reject e
|
||||||
.catch (e) -> reject e
|
.catch (e) -> reject e
|
||||||
|
|
||||||
move: (d) ->
|
move: (d) ->
|
||||||
me = @
|
new Promise (resolve, reject) =>
|
||||||
new Promise (resolve, reject) ->
|
@onready()
|
||||||
me.onready()
|
.then (r) =>
|
||||||
.then (r) ->
|
@_mv(d)
|
||||||
me._mv(d)
|
.then (data) =>
|
||||||
.then (data) ->
|
Ant.OS.announcer.ostrigger "VFS", { m: "move", file: @ }
|
||||||
Ant.OS.announcer.ostrigger "VFS", { m: "move", file: me }
|
|
||||||
resolve data
|
resolve data
|
||||||
.catch (e) -> reject e
|
.catch (e) -> reject e
|
||||||
.catch (e) -> reject e
|
.catch (e) -> reject e
|
||||||
|
|
||||||
execute: () ->
|
execute: () ->
|
||||||
me = @
|
new Promise (resolve, reject) =>
|
||||||
new Promise (resolve, reject) ->
|
@onready()
|
||||||
me.onready()
|
.then (r) =>
|
||||||
.then (r) ->
|
@_exec()
|
||||||
me._exec()
|
.then (d) =>
|
||||||
.then (d) ->
|
Ant.OS.announcer.ostrigger "VFS", { m: "execute", file: @ }
|
||||||
Ant.OS.announcer.ostrigger "VFS", { m: "execute", file: me }
|
|
||||||
resolve d
|
resolve d
|
||||||
.catch (e) -> reject e
|
.catch (e) -> reject e
|
||||||
.catch (e) -> reject e
|
.catch (e) -> reject e
|
||||||
@ -220,9 +209,8 @@ class BaseFileHandle
|
|||||||
getlink: () -> @path
|
getlink: () -> @path
|
||||||
|
|
||||||
unsupported: (t) ->
|
unsupported: (t) ->
|
||||||
me = @
|
new Promise (resolve, reject) =>
|
||||||
new Promise (resolve, reject) ->
|
reject { error: __("Action {0} is unsupported on: {1}", t, @path) }
|
||||||
reject { error: __("Action {0} is unsupported on: {1}", t, me.path) }
|
|
||||||
# actions must be implemented by subclasses
|
# actions must be implemented by subclasses
|
||||||
|
|
||||||
_rd: (t) -> @unsupported "read"
|
_rd: (t) -> @unsupported "read"
|
||||||
@ -251,6 +239,10 @@ class RemoteFileHandle extends Ant.OS.API.VFS.BaseFileHandle
|
|||||||
|
|
||||||
_rd: (t) ->
|
_rd: (t) ->
|
||||||
# t: binary, text, any type
|
# 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"
|
return Ant.OS.API.handle.scandir @path if @info.type is "dir"
|
||||||
#read the file
|
#read the file
|
||||||
return Ant.OS.API.handle.fileblob @path if t is "binary"
|
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) ->
|
_wr: (t) ->
|
||||||
# t is base64 or undefined
|
# t is base64 or undefined
|
||||||
return Ant.OS.API.handle.write me.path, me.cache if t is "base64"
|
return Ant.OS.API.handle.write @path, @cache if t is "base64"
|
||||||
me = @
|
new Promise (resolve, reject) =>
|
||||||
new Promise (resolve, reject) ->
|
@b64(t)
|
||||||
me.b64(t)
|
.then (r) =>
|
||||||
.then (r) ->
|
Ant.OS.API.handle.write @path, r
|
||||||
Ant.OS.API.handle.write me.path, r
|
|
||||||
.then (result) -> resolve result
|
.then (result) -> resolve result
|
||||||
.catch (e) -> reject e
|
.catch (e) -> reject e
|
||||||
.catch (e) -> reject e
|
.catch (e) -> reject e
|
||||||
|
|
||||||
_mk: (d) ->
|
_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"
|
if @info.type is "file"
|
||||||
return new Promise (resolve, reject) ->
|
return new Promise (resolve, reject) =>
|
||||||
reject Ant.OS.API.throwe __("{0} is not a directory", me.path)
|
reject Ant.OS.API.throwe __("{0} is not a directory", @path)
|
||||||
Ant.OS.API.handle.mkdir "#{@path}/#{d}"
|
Ant.OS.API.handle.mkdir "#{@path}/#{d}"
|
||||||
|
|
||||||
_rm: () ->
|
_rm: () ->
|
||||||
@ -283,21 +277,19 @@ class RemoteFileHandle extends Ant.OS.API.VFS.BaseFileHandle
|
|||||||
|
|
||||||
|
|
||||||
_up: () ->
|
_up: () ->
|
||||||
me = @
|
|
||||||
if @info.type isnt "dir"
|
if @info.type isnt "dir"
|
||||||
return new Promise (resolve, reject) ->
|
return new Promise (resolve, reject) =>
|
||||||
reject Ant.OS.API.throwe __("{0} is not a file", me.path)
|
reject Ant.OS.API.throwe __("{0} is not a file", @path)
|
||||||
Ant.OS.API.handle.upload @path
|
Ant.OS.API.handle.upload @path
|
||||||
|
|
||||||
_down: () ->
|
_down: () ->
|
||||||
me = @
|
new Promise (resolve, reject) =>
|
||||||
new Promise (resolve, reject) ->
|
if @info.type is "dir"
|
||||||
if me.info.type is "dir"
|
return Ant.OS.API.throwe __("{0} is not a file", @path)
|
||||||
return Ant.OS.API.throwe __("{0} is not a file", me.path)
|
Ant.OS.API.handle.fileblob(@path)
|
||||||
Ant.OS.API.handle.fileblob(me.path)
|
.then (d) =>
|
||||||
.then (d) ->
|
|
||||||
blob = new Blob [d], { type: "octet/stream" }
|
blob = new Blob [d], { type: "octet/stream" }
|
||||||
Ant.OS.API.saveblob me.basename, blob
|
Ant.OS.API.saveblob @basename, blob
|
||||||
resolve()
|
resolve()
|
||||||
.catch (e) ->
|
.catch (e) ->
|
||||||
reject e
|
reject e
|
||||||
@ -315,10 +307,9 @@ class ApplicationHandle extends Ant.OS.API.VFS.BaseFileHandle
|
|||||||
@ready = true
|
@ready = true
|
||||||
|
|
||||||
_rd: (t) ->
|
_rd: (t) ->
|
||||||
me = @
|
new Promise (resolve, reject) =>
|
||||||
new Promise (resolve, reject) ->
|
return resolve { result: @info } if @info
|
||||||
return resolve { result: me.info } if me.info
|
return reject Ant.OS.API.throwe(__("Application meta data isnt found")) unless @isRoot()
|
||||||
return reject Ant.OS.API.throwe(__("Application meta data isnt found")) unless me.isRoot()
|
|
||||||
resolve { result: ( v for k, v of Ant.OS.setting.system.packages ) }
|
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"
|
type: "file"
|
||||||
|
|
||||||
_rd: (t) ->
|
_rd: (t) ->
|
||||||
me = @
|
new Promise (resolve, reject) =>
|
||||||
new Promise (resolve, reject) ->
|
resolve { result: @cache }
|
||||||
resolve { result: me.cache }
|
|
||||||
|
|
||||||
_wr: (d, t) ->
|
_wr: (d, t) ->
|
||||||
@cache = d
|
@cache = d
|
||||||
@ -347,10 +337,9 @@ class BufferFileHandle extends Ant.OS.API.VFS.BaseFileHandle
|
|||||||
resolve { result: true }
|
resolve { result: true }
|
||||||
|
|
||||||
_down: () ->
|
_down: () ->
|
||||||
me = @
|
new Promise (resolve, reject) =>
|
||||||
new Promise (resolve, reject) ->
|
blob = new Blob [@cache], { type: "octet/stream" }
|
||||||
blob = new Blob [me.cache], { type: "octet/stream" }
|
Ant.OS.API.saveblob @basename, blob
|
||||||
Ant.OS.API.saveblob me.basename, blob
|
|
||||||
resolve()
|
resolve()
|
||||||
|
|
||||||
onchange: (f) ->
|
onchange: (f) ->
|
||||||
@ -390,18 +379,16 @@ class SharedFileHandle extends Ant.OS.API.VFS.BaseFileHandle
|
|||||||
Ant.OS.API.handle.sharefile @basename, false
|
Ant.OS.API.handle.sharefile @basename, false
|
||||||
|
|
||||||
_down: () ->
|
_down: () ->
|
||||||
me = @
|
new Promise (resolve, reject) =>
|
||||||
new Promise (resolve, reject) ->
|
if @info.type is "dir"
|
||||||
if me.info.type is "dir"
|
return reject Ant.OS.API.throwe __("{0} is not a file", @path)
|
||||||
return reject Ant.OS.API.throwe __("{0} is not a file", me.path)
|
Ant.OS.API.handle.fileblob @path
|
||||||
Ant.OS.API.handle.fileblob me.path
|
.then (data) =>
|
||||||
.then (data) ->
|
|
||||||
blob = new Blob [data], { type: "octet/stream" }
|
blob = new Blob [data], { type: "octet/stream" }
|
||||||
Ant.OS.API.saveblob me.basename, blob
|
Ant.OS.API.saveblob @basename, blob
|
||||||
resolve()
|
resolve()
|
||||||
.catch (e) -> reject e
|
.catch (e) -> reject e
|
||||||
_pub: () ->
|
_pub: () ->
|
||||||
me = @
|
return new Promise (resolve, reject) => resolve { result: @basename }
|
||||||
return new Promise (resolve, reject) -> resolve { result: me.basename }
|
|
||||||
|
|
||||||
Ant.OS.API.VFS.register "^shared$", SharedFileHandle
|
Ant.OS.API.VFS.register "^shared$", SharedFileHandle
|
@ -21,12 +21,11 @@ class ActivityMonitor extends this.OS.GUI.BaseApplication
|
|||||||
constructor: (args) ->
|
constructor: (args) ->
|
||||||
super "ActivityMonitor", args
|
super "ActivityMonitor", args
|
||||||
main: () ->
|
main: () ->
|
||||||
me = @
|
|
||||||
@scheme.set "apptitle", "Activity Monitor"
|
@scheme.set "apptitle", "Activity Monitor"
|
||||||
@grid = @find "mygrid"
|
@grid = @find "mygrid"
|
||||||
@on "btclick", (e) ->
|
@on "btclick", (e) =>
|
||||||
return unless e.id == "btkill"
|
return unless e.id == "btkill"
|
||||||
item = me.grid.get "selectedRow"
|
item = @grid.get "selectedRow"
|
||||||
return unless item
|
return unless item
|
||||||
data = item.get("data")[0]
|
data = item.get("data")[0]
|
||||||
app = _PM.appByPid data.text
|
app = _PM.appByPid data.text
|
||||||
@ -57,17 +56,16 @@ class ActivityMonitor extends this.OS.GUI.BaseApplication
|
|||||||
@monitor()
|
@monitor()
|
||||||
|
|
||||||
monitor: () ->
|
monitor: () ->
|
||||||
me = @
|
|
||||||
#get all current running process
|
#get all current running process
|
||||||
me.gdata.alive = []
|
@gdata.alive = []
|
||||||
now = (new Date).getTime()
|
now = (new Date).getTime()
|
||||||
$.each _PM.processes, (i, d) ->
|
$.each _PM.processes, (i, d) =>
|
||||||
$.each d , (j, a) ->
|
$.each d , (j, a) =>
|
||||||
if me.gdata.processes[a.pid] #update it
|
if @gdata.processes[a.pid] #update it
|
||||||
me.gdata.processes[a.pid][3].text = now - a.birth
|
@gdata.processes[a.pid][3].text = now - a.birth
|
||||||
me.gdata.processes[a.pid][3].domel.update()
|
@gdata.processes[a.pid][3].domel.update()
|
||||||
else #add it
|
else #add it
|
||||||
me.gdata.processes[a.pid] = [
|
@gdata.processes[a.pid] = [
|
||||||
{ text: a.pid },
|
{ text: a.pid },
|
||||||
{
|
{
|
||||||
icon: if _APP[a.name].type == 1 then _APP[a.name].meta.icon else a.icon,
|
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
|
text: now - a.birth
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
me.grid.push me.gdata.processes[a.pid]
|
@grid.push @gdata.processes[a.pid]
|
||||||
me.gdata.alive.push a.pid
|
@gdata.alive.push a.pid
|
||||||
|
|
||||||
$.each @gdata.processes, (i, e) ->
|
$.each @gdata.processes, (i, e) =>
|
||||||
if ($.inArray (Number i), me.gdata.alive) < 0
|
if ($.inArray (Number i), @gdata.alive) < 0
|
||||||
me.grid.remove me.gdata.processes[i].domel
|
@grid.remove @gdata.processes[i].domel
|
||||||
me.gdata.processes[i] = undefined
|
@gdata.processes[i] = undefined
|
||||||
delete me.gdata.processes[i]
|
delete @gdata.processes[i]
|
||||||
|
|
||||||
@timer = setTimeout (() -> me.monitor()), 500
|
@timer = setTimeout (() => @monitor()), 500
|
||||||
|
|
||||||
cleanup: (e) ->
|
cleanup: (e) ->
|
||||||
clearTimeout @timer if @timer
|
clearTimeout @timer if @timer
|
||||||
|
@ -3,27 +3,26 @@ class CommandPalette extends this.OS.GUI.BasicDialog
|
|||||||
super "CommandPalete", CommandPalette.scheme
|
super "CommandPalete", CommandPalette.scheme
|
||||||
|
|
||||||
init: () ->
|
init: () ->
|
||||||
me = @
|
|
||||||
offset = $(".afx-window-content", @parent.scheme).offset()
|
offset = $(".afx-window-content", @parent.scheme).offset()
|
||||||
pw = @parent.scheme.get("width") / 5
|
pw = @parent.scheme.get("width") / 5
|
||||||
@scheme.set "width", 3 * pw
|
@scheme.set "width", 3 * pw
|
||||||
$(@scheme).offset { top: offset.top - 2, left: offset.left + pw }
|
$(@scheme).offset { top: offset.top - 2, left: offset.left + pw }
|
||||||
cb = (e) ->
|
cb = (e) =>
|
||||||
if ($ e.target).closest(me.scheme).length > 0
|
if ($ e.target).closest(@scheme).length > 0
|
||||||
$(me.find "searchbox").focus()
|
$(@find "searchbox").focus()
|
||||||
else
|
else
|
||||||
$(document).unbind "mousedown", cb
|
$(document).unbind "mousedown", cb
|
||||||
me.quit()
|
@quit()
|
||||||
$(document).on "mousedown", cb
|
$(document).on "mousedown", cb
|
||||||
$(me.find "searchbox").focus()
|
$(@find "searchbox").focus()
|
||||||
@cmdlist = @find("container")
|
@cmdlist = @find("container")
|
||||||
@cmdlist.set "data", (v for v in @data.child) if @data
|
@cmdlist.set "data", (v for v in @data.child) if @data
|
||||||
$(@cmdlist).click (e) ->
|
$(@cmdlist).click (e) =>
|
||||||
me.selectCommand()
|
@selectCommand()
|
||||||
|
|
||||||
@searchbox = @find "searchbox"
|
@searchbox = @find "searchbox"
|
||||||
($ @searchbox).keyup (e) ->
|
($ @searchbox).keyup (e) =>
|
||||||
me.search e
|
@search e
|
||||||
|
|
||||||
search: (e) ->
|
search: (e) ->
|
||||||
switch e.which
|
switch e.which
|
||||||
|
@ -8,42 +8,45 @@ class App.extensions.AntOSDK extends App.BaseExtension
|
|||||||
|
|
||||||
# public functions
|
# public functions
|
||||||
create: () ->
|
create: () ->
|
||||||
me = @
|
|
||||||
@app.openDialog("FileDialog", {
|
@app.openDialog("FileDialog", {
|
||||||
title: "__(New Project at)",
|
title: "__(New Project at)",
|
||||||
file: { basename: __("ProjectName") },
|
file: { basename: __("ProjectName") },
|
||||||
mimes: ["dir"]
|
mimes: ["dir"]
|
||||||
}).then (d) ->
|
}).then (d) =>
|
||||||
me.mktpl d.file.path, d.name, true
|
@mktpl d.file.path, d.name, true
|
||||||
|
|
||||||
init: () ->
|
init: () ->
|
||||||
me = @
|
|
||||||
dir = @app.currdir
|
dir = @app.currdir
|
||||||
return @create() unless dir and dir.basename
|
return @create() unless dir and dir.basename
|
||||||
dir.read()
|
dir.read()
|
||||||
.then (d) ->
|
.then (d) =>
|
||||||
return me.notify __("Cannot read folder: {0}", dir.path) if d.error
|
return @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
|
return @notify __("The folder is not empty: {0}", dir.path) unless d.result.length is 0
|
||||||
me.mktpl dir.parent().path, dir.basename
|
@mktpl dir.parent().path, dir.basename
|
||||||
|
|
||||||
build: () ->
|
buildnrun: () ->
|
||||||
console.log "build"
|
@metadata().then (meta) =>
|
||||||
|
@build(meta).then () =>
|
||||||
|
@run(meta).catch (e) => @error.toString()
|
||||||
|
.catch (e) =>
|
||||||
|
@error e.toString()
|
||||||
|
.catch (e) => @error e.toString()
|
||||||
|
|
||||||
release: () ->
|
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
|
# private functions
|
||||||
mktpl: (path, name, flag) ->
|
mktpl: (path, name, flag) ->
|
||||||
me = @
|
|
||||||
rpath = "#{path}/#{name}"
|
rpath = "#{path}/#{name}"
|
||||||
|
console.log rpath
|
||||||
dirs = [
|
dirs = [
|
||||||
"#{rpath}/build",
|
"#{rpath}/build",
|
||||||
"#{rpath}/build/release",
|
"#{rpath}/build/release",
|
||||||
@ -57,49 +60,198 @@ class App.extensions.AntOSDK extends App.BaseExtension
|
|||||||
files = [
|
files = [
|
||||||
["main.tpl", "#{rpath}/coffees/main.coffee"],
|
["main.tpl", "#{rpath}/coffees/main.coffee"],
|
||||||
["package.tpl", "#{rpath}/package.json"],
|
["package.tpl", "#{rpath}/package.json"],
|
||||||
["project.tpl", "#{rpath}/project.apj"],
|
["project.tpl", "#{rpath}/project.json"],
|
||||||
["README.tpl", "#{rpath}/README.md"],
|
["README.tpl", "#{rpath}/README.md"],
|
||||||
["scheme.tpl", "#{rpath}/assets/scheme.html"]
|
["scheme.tpl", "#{rpath}/assets/scheme.html"]
|
||||||
]
|
]
|
||||||
@mkdirAll dirs
|
@mkdirAll dirs
|
||||||
.then () ->
|
.then () =>
|
||||||
me.mkfileAll(files, path, name)
|
@mkfileAll(files, path, name)
|
||||||
.then () ->
|
.then () =>
|
||||||
me.app.currdir = rpath.asFileHandle()
|
@app.currdir = rpath.asFileHandle()
|
||||||
me.app.initSideBar()
|
@app.initSideBar()
|
||||||
me.app.openFile "#{rpath}/README.md".asFileHandle()
|
@app.openFile "#{rpath}/README.md".asFileHandle()
|
||||||
.catch (e) -> me.error e.stack
|
.catch (e) => @error e.stack
|
||||||
.catch (e) -> me.error e.stack
|
.catch (e) => @error e.stack
|
||||||
|
|
||||||
mkdirAll: (list) ->
|
mkdirAll: (list) ->
|
||||||
me = @
|
new Promise (resolve, reject) =>
|
||||||
new Promise (resolve, reject) ->
|
|
||||||
return resolve() if list.length is 0
|
return resolve() if list.length is 0
|
||||||
path = (list.splice 0, 1)[0].asFileHandle()
|
path = (list.splice 0, 1)[0].asFileHandle()
|
||||||
|
console.log path.parent().path, path.basename
|
||||||
path.parent().mk path.basename
|
path.parent().mk path.basename
|
||||||
.then () ->
|
.then (d) =>
|
||||||
me.mkdirAll list
|
@mkdirAll list
|
||||||
.then () -> resolve()
|
.then () -> resolve()
|
||||||
.catch (e) -> reject e
|
.catch (e) -> reject e
|
||||||
.catch (e) -> reject e
|
.catch (e) -> reject e
|
||||||
|
|
||||||
mkfileAll: (list, path, name) ->
|
mkfileAll: (list, path, name) ->
|
||||||
me = @
|
new Promise (resolve, reject) =>
|
||||||
new Promise (resolve, reject) ->
|
|
||||||
return resolve() if list.length is 0
|
return resolve() if list.length is 0
|
||||||
item = (list.splice 0, 1)[0]
|
item = (list.splice 0, 1)[0]
|
||||||
"#{me.basedir()}/AntOSDK/templates/#{item[0]}"
|
"#{@basedir()}/AntOSDK/templates/#{item[0]}"
|
||||||
.asFileHandle()
|
.asFileHandle()
|
||||||
.read()
|
.read()
|
||||||
.then (data) ->
|
.then (data) =>
|
||||||
file = item[1].asFileHandle()
|
file = item[1].asFileHandle()
|
||||||
.setCache(data.format name, "#{path}/#{name}")
|
.setCache(data.format name, "#{path}/#{name}")
|
||||||
.write "text/plain"
|
.write "text/plain"
|
||||||
.then () ->
|
.then () =>
|
||||||
me.mkfileAll list, path, name
|
@mkfileAll list, path, name
|
||||||
.then () -> resolve()
|
.then () -> resolve()
|
||||||
.catch (e) -> reject e
|
.catch (e) -> reject e
|
||||||
.catch (e) -> reject e
|
.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()
|
@ -13,7 +13,6 @@ class CodePad extends this.OS.GUI.BaseApplication
|
|||||||
@currdir = @currfile.parent()
|
@currdir = @currfile.parent()
|
||||||
|
|
||||||
main: () ->
|
main: () ->
|
||||||
me = @
|
|
||||||
@extensions = {}
|
@extensions = {}
|
||||||
@fileview = @find("fileview")
|
@fileview = @find("fileview")
|
||||||
@sidebar = @find("sidebar")
|
@sidebar = @find("sidebar")
|
||||||
@ -27,12 +26,10 @@ class CodePad extends this.OS.GUI.BaseApplication
|
|||||||
dir = path.asFileHandle() if typeof path is "string"
|
dir = path.asFileHandle() if typeof path is "string"
|
||||||
dir.read().then (d) ->
|
dir.read().then (d) ->
|
||||||
return reject d.error if d.error
|
return reject d.error if d.error
|
||||||
me.currdir = dir
|
|
||||||
resolve d.result
|
resolve d.result
|
||||||
@setup()
|
@setup()
|
||||||
|
|
||||||
setup: () ->
|
setup: () ->
|
||||||
me = @
|
|
||||||
ace.config.set('basePath', '/scripts/ace')
|
ace.config.set('basePath', '/scripts/ace')
|
||||||
ace.require "ace/ext/language_tools"
|
ace.require "ace/ext/language_tools"
|
||||||
@editor = ace.edit @find("datarea")
|
@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.completers.push { getCompletions: ( editor, session, pos, prefix, callback ) -> }
|
||||||
@editor.getSession().setUseWrapMode true
|
@editor.getSession().setUseWrapMode true
|
||||||
@editormux = false
|
@editormux = false
|
||||||
@editor.on "input", () ->
|
@editor.on "input", () =>
|
||||||
if me.editormux
|
if @editormux
|
||||||
me.editormux = false
|
@editormux = false
|
||||||
return false
|
return false
|
||||||
if not me.currfile.dirty
|
if not @currfile.dirty
|
||||||
me.currfile.dirty = true
|
@currfile.dirty = true
|
||||||
me.currfile.text += "*"
|
@currfile.text += "*"
|
||||||
me.tabbar.update()
|
@tabbar.update()
|
||||||
@editor.getSession().selection.on "changeCursor", (e) ->
|
@editor.getSession().selection.on "changeCursor", (e) =>
|
||||||
me.updateStatus()
|
@updateStatus()
|
||||||
|
|
||||||
@tabbar.set "ontabselect", (e) ->
|
@tabbar.set "ontabselect", (e) =>
|
||||||
me.selecteTab $(e.data.item).index()
|
@selecteTab $(e.data.item).index()
|
||||||
@tabbar.set "ontabclose", (e) ->
|
@tabbar.set "ontabclose", (e) =>
|
||||||
it = e.data.item
|
it = e.data.item
|
||||||
return false unless it
|
return false unless it
|
||||||
return me.closeTab it unless it.get("data").dirty
|
return @closeTab it unless it.get("data").dirty
|
||||||
me.openDialog("YesNoDialog", {
|
@openDialog("YesNoDialog", {
|
||||||
title: __("Close tab"),
|
title: __("Close tab"),
|
||||||
text: __("Close without saving ?")
|
text: __("Close without saving ?")
|
||||||
}).then (d) ->
|
}).then (d) =>
|
||||||
return me.closeTab it if d
|
return @closeTab it if d
|
||||||
me.editor.focus()
|
@editor.focus()
|
||||||
return false
|
return false
|
||||||
@fileview.set "onfileopen", (e) ->
|
@fileview.set "onfileopen", (e) =>
|
||||||
return if e.data.type is "dir"
|
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"
|
return unless e.data or e.data.type is "dir"
|
||||||
i = me.findTabByFile e.data.path.asFileHandle()
|
i = @findTabByFile e.data.path.asFileHandle()
|
||||||
return me.tabbar.set "selected", i if i isnt -1
|
return @tabbar.set "selected", i if i isnt -1
|
||||||
|
|
||||||
@on "resize", () -> me.editor.resize()
|
@on "resize", () => @editor.resize()
|
||||||
@on "focus", () -> me.editor.focus()
|
@on "focus", () => @editor.focus()
|
||||||
@spotlight = new CMDMenu __("Command palette")
|
@spotlight = new CMDMenu __("Command palette")
|
||||||
@bindKey "ALT-P", () -> me.spotlight.run me
|
@bindKey "ALT-P", () => @spotlight.run @
|
||||||
@find("datarea").contextmenuHandle = (e, m) ->
|
@find("datarea").contextmenuHandle = (e, m) =>
|
||||||
m.set "items", [{
|
m.set "items", [{
|
||||||
text: __("Command palete"),
|
text: __("Command palete"),
|
||||||
onmenuselect: (e) ->
|
onmenuselect: (e) =>
|
||||||
me.spotlight.run me
|
@spotlight.run @
|
||||||
}]
|
}]
|
||||||
m.show e
|
m.show e
|
||||||
|
|
||||||
@bindKey "ALT-N", () -> me.menuAction "new"
|
@bindKey "ALT-N", () => @menuAction "new"
|
||||||
@bindKey "ALT-O", () -> me.menuAction "open"
|
@bindKey "ALT-O", () => @menuAction "open"
|
||||||
@bindKey "ALT-F", () -> me.menuAction "opendir"
|
@bindKey "ALT-F", () => @menuAction "opendir"
|
||||||
@bindKey "CTRL-S", () -> me.menuAction "save"
|
@bindKey "CTRL-S", () => @menuAction "save"
|
||||||
@bindKey "ALT-W", () -> me.menuAction "saveas"
|
@bindKey "ALT-W", () => @menuAction "saveas"
|
||||||
|
|
||||||
@loadExtensionMetaData()
|
@loadExtensionMetaData()
|
||||||
@initCommandPalete()
|
@initCommandPalete()
|
||||||
@ -112,13 +109,13 @@ class CodePad extends this.OS.GUI.BaseApplication
|
|||||||
i = @findTabByFile file
|
i = @findTabByFile file
|
||||||
return @tabbar.set "selected", i if i isnt -1
|
return @tabbar.set "selected", i if i isnt -1
|
||||||
return @newTab file if file.path.toString() is "Untitled"
|
return @newTab file if file.path.toString() is "Untitled"
|
||||||
me = @
|
|
||||||
file.read()
|
file.read()
|
||||||
.then (d) ->
|
.then (d) =>
|
||||||
file.cache = d or ""
|
file.cache = d or ""
|
||||||
me.newTab file
|
@newTab file
|
||||||
.catch (e) ->
|
.catch (e) =>
|
||||||
me.error __("Unable to open: {0}", file.path)
|
@error __("Unable to open: {0}", file.path)
|
||||||
|
|
||||||
findTabByFile: (file) ->
|
findTabByFile: (file) ->
|
||||||
lst = @tabbar.get "items"
|
lst = @tabbar.get "items"
|
||||||
@ -218,38 +215,35 @@ class CodePad extends this.OS.GUI.BaseApplication
|
|||||||
@addAction CMDMenu.fromMenu @fileMenu()
|
@addAction CMDMenu.fromMenu @fileMenu()
|
||||||
|
|
||||||
loadExtensionMetaData: () ->
|
loadExtensionMetaData: () ->
|
||||||
me = @
|
|
||||||
"#{@meta().path}/extensions.json"
|
"#{@meta().path}/extensions.json"
|
||||||
.asFileHandle()
|
.asFileHandle()
|
||||||
.read("json")
|
.read("json")
|
||||||
.then (d) ->
|
.then (d) =>
|
||||||
for ext in d
|
for ext in d
|
||||||
if me.extensions[ext.name]
|
if @extensions[ext.name]
|
||||||
me.extensions[ext.name].child = {}
|
@extensions[ext.name].child = {}
|
||||||
me.extensions[ext.name].addAction v for v in ext.actions
|
@extensions[ext.name].addAction v for v in ext.actions
|
||||||
else
|
else
|
||||||
me.extensions[ext.name] = new CMDMenu ext.text
|
@extensions[ext.name] = new CMDMenu ext.text
|
||||||
me.extensions[ext.name].name = ext.name
|
@extensions[ext.name].name = ext.name
|
||||||
me.extensions[ext.name].addAction v for v in ext.actions
|
@extensions[ext.name].addAction v for v in ext.actions
|
||||||
me.spotlight.addAction me.extensions[ext.name]
|
@spotlight.addAction @extensions[ext.name]
|
||||||
me.extensions[ext.name].onchildselect (e) ->
|
@extensions[ext.name].onchildselect (e) =>
|
||||||
me.loadAndRunExtensionAction e.data.item.get "data"
|
@loadAndRunExtensionAction e.data.item.get "data"
|
||||||
.catch (e) ->
|
.catch (e) =>
|
||||||
me.error __("Cannot load extension meta data")
|
@error __("Cannot load extension meta data")
|
||||||
|
|
||||||
runExtensionAction: (name, action) ->
|
runExtensionAction: (name, action) ->
|
||||||
me = @
|
|
||||||
return @error __("Unable to find extension: {0}", name) unless CodePad.extensions[name]
|
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]
|
return @error __("Unable to find action: {0}", action) unless ext[action]
|
||||||
ext.preload()
|
ext.preload()
|
||||||
.then () ->
|
.then () ->
|
||||||
ext[action]()
|
ext[action]()
|
||||||
.catch (e) ->
|
.catch (e) =>
|
||||||
me.error e.stack
|
@error e.stack
|
||||||
|
|
||||||
loadAndRunExtensionAction: (data) ->
|
loadAndRunExtensionAction: (data) ->
|
||||||
me = @
|
|
||||||
name = data.parent.name
|
name = data.parent.name
|
||||||
action = data.name
|
action = data.name
|
||||||
#verify if the extension is load
|
#verify if the extension is load
|
||||||
@ -257,14 +251,13 @@ class CodePad extends this.OS.GUI.BaseApplication
|
|||||||
#load the extension
|
#load the extension
|
||||||
path = "#{@meta().path}/extensions/#{name}.js"
|
path = "#{@meta().path}/extensions/#{name}.js"
|
||||||
@_api.requires path
|
@_api.requires path
|
||||||
.then () -> me.runExtensionAction name, action
|
.then () => @runExtensionAction name, action
|
||||||
.catch (e) ->
|
.catch (e) =>
|
||||||
me.error __("unable to load extension: {}", name)
|
@error __("unable to load extension: {}", name)
|
||||||
else
|
else
|
||||||
@runExtensionAction name, action
|
@runExtensionAction name, action
|
||||||
|
|
||||||
fileMenu: () ->
|
fileMenu: () ->
|
||||||
me = @
|
|
||||||
{
|
{
|
||||||
text: __("File"),
|
text: __("File"),
|
||||||
child: [
|
child: [
|
||||||
@ -274,35 +267,33 @@ class CodePad extends this.OS.GUI.BaseApplication
|
|||||||
{ text: __("Save"), dataid: "save", shortcut: "C-S" },
|
{ text: __("Save"), dataid: "save", shortcut: "C-S" },
|
||||||
{ text: __("Save as"), dataid: "saveas", shortcut: "A-W" }
|
{ text: __("Save as"), dataid: "saveas", shortcut: "A-W" }
|
||||||
],
|
],
|
||||||
onchildselect: (e, r) ->
|
onchildselect: (e, r) =>
|
||||||
me.menuAction e.data.item.get("data").dataid, r
|
@menuAction e.data.item.get("data").dataid, r
|
||||||
}
|
}
|
||||||
|
|
||||||
save: (file) ->
|
save: (file) ->
|
||||||
me = @
|
|
||||||
file.write("text/plain")
|
file.write("text/plain")
|
||||||
.then (d) ->
|
.then (d) =>
|
||||||
return me.error __("Error saving file {0}: {1}", file.basename, d.error) if d.error
|
return @error __("Error saving file {0}: {1}", file.basename, d.error) if d.error
|
||||||
file.dirty = false
|
file.dirty = false
|
||||||
file.text = file.basename
|
file.text = file.basename
|
||||||
me.tabbar.update()
|
@tabbar.update()
|
||||||
me.scheme.set "apptitle", "#{me.currfile.basename}"
|
@scheme.set "apptitle", "#{@currfile.basename}"
|
||||||
.catch (e) -> me.error e.stack
|
.catch (e) => @error e.stack
|
||||||
|
|
||||||
|
|
||||||
saveAs: () ->
|
saveAs: () ->
|
||||||
me = @
|
@openDialog("FileDialog", {
|
||||||
me.openDialog("FileDialog", {
|
|
||||||
title: __("Save as"),
|
title: __("Save as"),
|
||||||
file: me.currfile
|
file: @currfile
|
||||||
})
|
})
|
||||||
.then (f) ->
|
.then (f) =>
|
||||||
d = f.file.path.asFileHandle()
|
d = f.file.path.asFileHandle()
|
||||||
d = d.parent() if f.file.type is "file"
|
d = d.parent() if f.file.type is "file"
|
||||||
me.currfile.setPath "#{d.path}/#{f.name}"
|
@currfile.setPath "#{d.path}/#{f.name}"
|
||||||
me.save me.currfile
|
@save @currfile
|
||||||
.catch (e) ->
|
.catch (e) =>
|
||||||
me.error e.stack
|
@error e.stack
|
||||||
|
|
||||||
menuAction: (dataid, r) ->
|
menuAction: (dataid, r) ->
|
||||||
me = @
|
me = @
|
||||||
@ -338,18 +329,16 @@ class CodePad extends this.OS.GUI.BaseApplication
|
|||||||
cleanup: (evt) ->
|
cleanup: (evt) ->
|
||||||
dirties = ( v for v in @tabbar.get "items" when v.dirty )
|
dirties = ( v for v in @tabbar.get "items" when v.dirty )
|
||||||
return if dirties.length is 0
|
return if dirties.length is 0
|
||||||
me = @
|
|
||||||
evt.preventDefault()
|
evt.preventDefault()
|
||||||
@.openDialog("YesNoDialog", {
|
@.openDialog("YesNoDialog", {
|
||||||
title: "__(Quit)",
|
title: "__(Quit)",
|
||||||
text: __("Ignore all {0} unsaved files ?", dirties.length)
|
text: __("Ignore all {0} unsaved files ?", dirties.length)
|
||||||
}).then (d) ->
|
}).then (d) =>
|
||||||
if d
|
if d
|
||||||
v.dirty = false for v in dirties
|
v.dirty = false for v in dirties
|
||||||
me.quit()
|
@quit()
|
||||||
|
|
||||||
menu: () ->
|
menu: () ->
|
||||||
me = @
|
|
||||||
menu = [
|
menu = [
|
||||||
@fileMenu()
|
@fileMenu()
|
||||||
{
|
{
|
||||||
@ -357,8 +346,8 @@ class CodePad extends this.OS.GUI.BaseApplication
|
|||||||
child: [
|
child: [
|
||||||
{ text: "__(Command Palette)", dataid: "cmdpalette", shortcut: "A-P" }
|
{ text: "__(Command Palette)", dataid: "cmdpalette", shortcut: "A-P" }
|
||||||
],
|
],
|
||||||
onchildselect: (e, r) ->
|
onchildselect: (e, r) =>
|
||||||
me.spotlight.run me
|
@spotlight.run @
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
menu
|
menu
|
||||||
@ -368,8 +357,10 @@ class CodePad.BaseExtension
|
|||||||
constructor: (@app) ->
|
constructor: (@app) ->
|
||||||
|
|
||||||
preload: () ->
|
preload: () ->
|
||||||
dep = ( "#{@basedir()}/#{v}" for v in @dependencies())
|
Ant.OS.API.require @dependencies()
|
||||||
Ant.OS.API.require dep
|
|
||||||
|
import: (lib) ->
|
||||||
|
Ant.OS.API.requires lib
|
||||||
|
|
||||||
basedir: () ->
|
basedir: () ->
|
||||||
"#{@app.meta().path}/extensions"
|
"#{@app.meta().path}/extensions"
|
||||||
@ -402,12 +393,11 @@ class CMDMenu
|
|||||||
@
|
@
|
||||||
|
|
||||||
run: (root) ->
|
run: (root) ->
|
||||||
me = @
|
|
||||||
root.openDialog(new CommandPalette(), @)
|
root.openDialog(new CommandPalette(), @)
|
||||||
.then (d) ->
|
.then (d) =>
|
||||||
data = d.data.item.get("data")
|
data = d.data.item.get("data")
|
||||||
return data.run root if data.run
|
return data.run root if data.run
|
||||||
me.select d, root
|
@select d, root
|
||||||
|
|
||||||
CMDMenu.fromMenu = (mn) ->
|
CMDMenu.fromMenu = (mn) ->
|
||||||
m = new CMDMenu mn.text, mn.shortcut
|
m = new CMDMenu mn.text, mn.shortcut
|
||||||
|
@ -14,15 +14,11 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"text": "__(Build and Run)",
|
"text": "__(Build and Run)",
|
||||||
"name": "build"
|
"name": "buildnrun"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"text": "__(Build release)",
|
"text": "__(Build release)",
|
||||||
"name": "release"
|
"name": "release"
|
||||||
},
|
|
||||||
{
|
|
||||||
"text": "__(Build options)",
|
|
||||||
"name": "options"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -23,11 +23,10 @@ class Calendar extends this.OS.GUI.BaseService
|
|||||||
@iconclass = "fa fa-calendar"
|
@iconclass = "fa fa-calendar"
|
||||||
init: ->
|
init: ->
|
||||||
#update time each second
|
#update time each second
|
||||||
me = @
|
@watch 1000, () =>
|
||||||
@watch 1000, () ->
|
|
||||||
now = new Date
|
now = new Date
|
||||||
me.text = now.toString()
|
@text = now.toString()
|
||||||
me.domel.set "text", me.text
|
@domel.set "text", @text
|
||||||
|
|
||||||
|
|
||||||
awake: (e) ->
|
awake: (e) ->
|
||||||
|
@ -37,27 +37,26 @@ class PushNotification extends this.OS.GUI.BaseService
|
|||||||
@update()
|
@update()
|
||||||
|
|
||||||
main: ->
|
main: ->
|
||||||
me = @
|
|
||||||
@mlist = @find "notifylist"
|
@mlist = @find "notifylist"
|
||||||
@mfeed = @find "notifeed"
|
@mfeed = @find "notifeed"
|
||||||
@nzone = @find "notifyzone"
|
@nzone = @find "notifyzone"
|
||||||
@fzone = @find "feedzone"
|
@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 "fail", (e) -> console.log e
|
||||||
@subscribe "notification", (o) -> me.pushout 'INFO', o
|
@subscribe "notification", (o) => @pushout 'INFO', o
|
||||||
@subscribe "fail", (o) -> me.pushout 'FAIL', o
|
@subscribe "fail", (o) => @pushout 'FAIL', o
|
||||||
@subscribe "error", (o) -> me.pushout 'ERROR', o
|
@subscribe "error", (o) => @pushout 'ERROR', o
|
||||||
@subscribe "info", (o) -> me.pushout 'INFO', o
|
@subscribe "info", (o) => @pushout 'INFO', o
|
||||||
@subscribe "VFS", (o) -> me.pushout 'INFO', o
|
#@subscribe "VFS", (o) => @pushout 'INFO', o
|
||||||
|
|
||||||
@subscribe "loading", (o) ->
|
@subscribe "loading", (o) =>
|
||||||
me.pending.push o.id
|
@pending.push o.id
|
||||||
me.spin true
|
@spin true
|
||||||
|
|
||||||
@subscribe "loaded", (o) ->
|
@subscribe "loaded", (o) =>
|
||||||
i = me.pending.indexOf o.id
|
i = @pending.indexOf o.id
|
||||||
me.pending.splice i, 1 if i >= 0
|
@pending.splice i, 1 if i >= 0
|
||||||
me.spin false if me.pending.length is 0
|
@spin false if @pending.length is 0
|
||||||
|
|
||||||
@nzone.set "height", "100%"
|
@nzone.set "height", "100%"
|
||||||
@fzone.set "height", "100%"
|
@fzone.set "height", "100%"
|
||||||
@ -83,25 +82,23 @@ class PushNotification extends this.OS.GUI.BaseService
|
|||||||
@notifeed d
|
@notifeed d
|
||||||
|
|
||||||
notifeed: (d) ->
|
notifeed: (d) ->
|
||||||
me = @
|
|
||||||
@mfeed.unshift d, true
|
@mfeed.unshift d, true
|
||||||
($ @fzone).show()
|
($ @fzone).show()
|
||||||
timer = setTimeout () ->
|
timer = setTimeout () =>
|
||||||
me.mfeed.remove d.domel
|
@mfeed.remove d.domel
|
||||||
($ me.fzone).hide() if me.mfeed.get("data").length is 0
|
($ @fzone).hide() if @mfeed.get("data").length is 0
|
||||||
clearTimeout timer
|
clearTimeout timer
|
||||||
, 3000
|
, 3000
|
||||||
|
|
||||||
awake: (evt) ->
|
awake: (evt) ->
|
||||||
if @view then ($ @nzone).hide() else ($ @nzone).show()
|
if @view then ($ @nzone).hide() else ($ @nzone).show()
|
||||||
@view = not @view
|
@view = not @view
|
||||||
me = @
|
|
||||||
if not @cb
|
if not @cb
|
||||||
@cb = (e) ->
|
@cb = (e) =>
|
||||||
if not ($ e.target).closest($ me.nzone).length and not ($ e.target).closest(evt.data.item).length
|
if not ($ e.target).closest($ @nzone).length and not ($ e.target).closest(evt.data.item).length
|
||||||
($ me.nzone).hide()
|
($ @nzone).hide()
|
||||||
$(document).unbind "click", me.cb
|
$(document).unbind "click", @cb
|
||||||
me.view = not me.view
|
@view = not @view
|
||||||
if @view
|
if @view
|
||||||
$(document).on "click", @cb
|
$(document).on "click", @cb
|
||||||
else
|
else
|
||||||
|
@ -21,7 +21,6 @@ class Files extends this.OS.GUI.BaseApplication
|
|||||||
super "Files", args
|
super "Files", args
|
||||||
|
|
||||||
main: () ->
|
main: () ->
|
||||||
me = @
|
|
||||||
@scheme.set "apptitle", "Files manager"
|
@scheme.set "apptitle", "Files manager"
|
||||||
@view = @find "fileview"
|
@view = @find "fileview"
|
||||||
@navinput = @find "navinput"
|
@navinput = @find "navinput"
|
||||||
@ -34,54 +33,55 @@ class Files extends this.OS.GUI.BaseApplication
|
|||||||
@clipboard = undefined
|
@clipboard = undefined
|
||||||
@viewType = @_api.switcher "icon", "list", "tree"
|
@viewType = @_api.switcher "icon", "list", "tree"
|
||||||
@viewType.list = true
|
@viewType.list = true
|
||||||
@apps = []
|
|
||||||
|
|
||||||
@view.contextmenuHandle = (e, m) ->
|
@view.contextmenuHandle = (e, m) =>
|
||||||
m.set "items", [ me.mnFile(), me.mnEdit() ]
|
file = @view.get "selectedFile"
|
||||||
# Fix m.set "onmenuselect", (evt) ->
|
apps = []
|
||||||
# me._gui.launch evt.item.data.app, evt.item.data.args if evt.item.data.app
|
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
|
m.show e
|
||||||
|
|
||||||
@view.set "onfileopen", (e) ->
|
@view.set "onfileopen", (e) =>
|
||||||
return unless e.data
|
return unless e.data
|
||||||
return if e.data.type is "dir"
|
return if e.data.type is "dir"
|
||||||
me._gui.openWith e.data
|
@_gui.openWith e.data
|
||||||
|
|
||||||
@favo.set "onlistselect", (e) ->
|
@favo.set "onlistselect", (e) =>
|
||||||
me.view.set "path", e.data.item.get("data").path
|
@view.set "path", e.data.item.get("data").path
|
||||||
|
|
||||||
($ @find "btback").click () ->
|
($ @find "btback").click () =>
|
||||||
return if me.currdir.isRoot()
|
return if @currdir.isRoot()
|
||||||
p = me.currdir.parent()
|
p = @currdir.parent()
|
||||||
me.favo.set "selected", -1
|
@favo.set "selected", -1
|
||||||
me.view.set "path", p.path
|
@view.set "path", p.path
|
||||||
|
|
||||||
($ @navinput).keyup (e) ->
|
($ @navinput).keyup (e) =>
|
||||||
me.view.set "path", ($ me.navinput).val() if e.keyCode is 13 #enter
|
@view.set "path", ($ @navinput).val() if e.keyCode is 13 #enter
|
||||||
|
|
||||||
@view.set "fetch", (path) ->
|
@view.set "fetch", (path) =>
|
||||||
new Promise (resolve, reject) ->
|
new Promise (resolve, reject) =>
|
||||||
dir = path
|
dir = path
|
||||||
dir = path.asFileHandle() if typeof path is "string"
|
dir = path.asFileHandle() if typeof path is "string"
|
||||||
dir.read().then (d) ->
|
dir.read().then (d) =>
|
||||||
return reject d.error if d.error
|
return reject d.error if d.error
|
||||||
if not dir.isRoot()
|
if not dir.isRoot()
|
||||||
p = dir.parent()
|
p = dir.parent()
|
||||||
p.filename = "[..]"
|
p.filename = "[..]"
|
||||||
p.type = "dir"
|
p.type = "dir"
|
||||||
d.result.unshift p
|
d.result.unshift p
|
||||||
me.currdir = dir
|
@currdir = dir
|
||||||
($ me.navinput).val dir.path
|
($ @navinput).val dir.path
|
||||||
resolve d.result
|
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.sidebar = true if @setting.sidebar is undefined
|
||||||
@setting.nav = true if @setting.nav is undefined
|
@setting.nav = true if @setting.nav is undefined
|
||||||
@setting.showhidden = false if @setting.showhidden 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 "data", mntpoints
|
||||||
#@favo.set "selected", -1
|
#@favo.set "selected", -1
|
||||||
@view.set "view", @setting.view if @setting.view
|
@view.set "view", @setting.view if @setting.view
|
||||||
@subscribe "VFS", (d) ->
|
@subscribe "VFS", (d) =>
|
||||||
return if ["read", "publish", "download"].includes d.data.m
|
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()
|
if d.data.file.hash() is @currdir.hash() or d.data.file.parent().hash() is @currdir.hash()
|
||||||
me.view.set "path", me.currdir
|
@view.set "path", @currdir
|
||||||
@bindKey "CTRL-F", () -> me.actionFile "#{me.name}-mkf"
|
@bindKey "CTRL-F", () => @actionFile "#{@name}-mkf"
|
||||||
@bindKey "CTRL-D", () -> me.actionFile "#{me.name}-mkdir"
|
@bindKey "CTRL-D", () => @actionFile "#{@name}-mkdir"
|
||||||
@bindKey "CTRL-U", () -> me.actionFile "#{me.name}-upload"
|
@bindKey "CTRL-U", () => @actionFile "#{@name}-upload"
|
||||||
@bindKey "CTRL-S", () -> me.actionFile "#{me.name}-share"
|
@bindKey "CTRL-S", () => @actionFile "#{@name}-share"
|
||||||
@bindKey "CTRL-I", () -> me.actionFile "#{me.name}-info"
|
@bindKey "CTRL-I", () => @actionFile "#{@name}-info"
|
||||||
|
|
||||||
@bindKey "CTRL-R", () -> me.actionEdit "#{me.name}-mv"
|
@bindKey "CTRL-R", () => @actionEdit "#{@name}-mv"
|
||||||
@bindKey "CTRL-M", () -> me.actionEdit "#{me.name}-rm"
|
@bindKey "CTRL-M", () => @actionEdit "#{@name}-rm"
|
||||||
@bindKey "CTRL-X", () -> me.actionEdit "#{me.name}-cut"
|
@bindKey "CTRL-X", () => @actionEdit "#{@name}-cut"
|
||||||
@bindKey "CTRL-C", () -> me.actionEdit "#{me.name}-copy"
|
@bindKey "CTRL-C", () => @actionEdit "#{@name}-copy"
|
||||||
@bindKey "CTRL-P", () -> me.actionEdit "#{me.name}-paste"
|
@bindKey "CTRL-P", () => @actionEdit "#{@name}-paste"
|
||||||
|
|
||||||
(@find "btgrid").set "onbtclick", (e) ->
|
(@find "btgrid").set "onbtclick", (e) =>
|
||||||
me.view.set 'view', "icon"
|
@view.set 'view', "icon"
|
||||||
me.viewType.icon = true
|
@viewType.icon = true
|
||||||
|
|
||||||
(@find "btlist").set "onbtclick", (e) ->
|
(@find "btlist").set "onbtclick", (e) =>
|
||||||
me.view.set 'view', "list"
|
@view.set 'view', "list"
|
||||||
me.viewType.list = true
|
@viewType.list = true
|
||||||
@view.set "path", @currdir
|
@view.set "path", @currdir
|
||||||
|
|
||||||
applySetting: (k) ->
|
applySetting: (k) ->
|
||||||
@ -126,22 +126,19 @@ class Files extends this.OS.GUI.BaseApplication
|
|||||||
|
|
||||||
mnFile: () ->
|
mnFile: () ->
|
||||||
#console.log file
|
#console.log file
|
||||||
me = @
|
|
||||||
arr = {
|
arr = {
|
||||||
text: "__(File)",
|
text: "__(File)",
|
||||||
child: [
|
child: [
|
||||||
{ text: "__(New file)", dataid: "#{@name}-mkf", shortcut: 'C-F' },
|
{ text: "__(New file)", dataid: "#{@name}-mkf", shortcut: 'C-F' },
|
||||||
{ text: "__(New folder)", dataid: "#{@name}-mkdir", shortcut: 'C-D' },
|
{ 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: "__(Upload)", dataid: "#{@name}-upload", shortcut: 'C-U' },
|
||||||
{ text: "__(Download)", dataid: "#{@name}-download" },
|
{ text: "__(Download)", dataid: "#{@name}-download" },
|
||||||
{ text: "__(Share file)", dataid: "#{@name}-share", shortcut: 'C-S' },
|
{ text: "__(Share file)", dataid: "#{@name}-share", shortcut: 'C-S' },
|
||||||
{ text: "__(Properties)", dataid: "#{@name}-info", shortcut: 'C-I' }
|
{ 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
|
return arr
|
||||||
mnEdit: () ->
|
mnEdit: () ->
|
||||||
me = @
|
|
||||||
{
|
{
|
||||||
text: "__(Edit)",
|
text: "__(Edit)",
|
||||||
child: [
|
child: [
|
||||||
@ -150,10 +147,10 @@ class Files extends this.OS.GUI.BaseApplication
|
|||||||
{ text: "__(Cut)", dataid: "#{@name}-cut", shortcut: 'C-X' },
|
{ text: "__(Cut)", dataid: "#{@name}-cut", shortcut: 'C-X' },
|
||||||
{ text: "__(Copy)", dataid: "#{@name}-copy", shortcut: 'C-C' },
|
{ text: "__(Copy)", dataid: "#{@name}-copy", shortcut: 'C-C' },
|
||||||
{ text: "__(Paste)", dataid: "#{@name}-paste", shortcut: 'C-P' }
|
{ 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: () ->
|
menu: () ->
|
||||||
me = @
|
|
||||||
menu = [
|
menu = [
|
||||||
@mnFile(),
|
@mnFile(),
|
||||||
@mnEdit(),
|
@mnEdit(),
|
||||||
@ -165,15 +162,15 @@ class Files extends this.OS.GUI.BaseApplication
|
|||||||
{ text: "__(Navigation bar)", switch: true, checked: @setting.nav, dataid: "#{@name}-nav" },
|
{ text: "__(Navigation bar)", switch: true, checked: @setting.nav, dataid: "#{@name}-nav" },
|
||||||
{ text: "__(Hidden files)", switch: true, checked: @setting.showhidden, dataid: "#{@name}-hidden" },
|
{ text: "__(Hidden files)", switch: true, checked: @setting.showhidden, dataid: "#{@name}-hidden" },
|
||||||
{ text: "__(Type)", child: [
|
{ text: "__(Type)", child: [
|
||||||
{ text: "__(Icon view)", radio: true, checked: me.viewType.icon, dataid: "#{@name}-icon", type: 'icon' },
|
{ text: "__(Icon view)", radio: true, checked: @viewType.icon, dataid: "#{@name}-icon", type: 'icon' },
|
||||||
{ text: "__(List view)", radio:true, checked: me.viewType.list, dataid: "#{@name}-list", type: 'list' },
|
{ text: "__(List view)", radio:true, checked: @viewType.list, dataid: "#{@name}-list", type: 'list' },
|
||||||
{ text: "__(Tree view)", radio:true, checked: me.viewType.tree, dataid: "#{@name}-tree", type: 'tree' }
|
{ text: "__(Tree view)", radio:true, checked: @viewType.tree, dataid: "#{@name}-tree", type: 'tree' }
|
||||||
], onchildselect: (e) ->
|
], onchildselect: (e) =>
|
||||||
type = e.data.item.get("data").type
|
type = e.data.item.get("data").type
|
||||||
me.view.set 'view', type
|
@view.set 'view', type
|
||||||
me.viewType[type] = true
|
@viewType[type] = true
|
||||||
},
|
},
|
||||||
], onchildselect: (e) -> me.actionView e
|
], onchildselect: (e) => @actionView e
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
menu
|
menu
|
||||||
@ -205,7 +202,6 @@ class Files extends this.OS.GUI.BaseApplication
|
|||||||
#@toggleNav e.item.data.checked
|
#@toggleNav e.item.data.checked
|
||||||
|
|
||||||
actionEdit: (e) ->
|
actionEdit: (e) ->
|
||||||
me = @
|
|
||||||
file = @view.get "selectedFile"
|
file = @view.get "selectedFile"
|
||||||
switch e
|
switch e
|
||||||
when "#{@name}-mv"
|
when "#{@name}-mv"
|
||||||
@ -215,14 +211,14 @@ class Files extends this.OS.GUI.BaseApplication
|
|||||||
label: "__(File name)",
|
label: "__(File name)",
|
||||||
value: file.filename
|
value: file.filename
|
||||||
})
|
})
|
||||||
.then (d) ->
|
.then (d) =>
|
||||||
return if d is file.filename
|
return if d is file.filename
|
||||||
file.path.asFileHandle().move "#{me.currdir.path}/#{d}"
|
file.path.asFileHandle().move "#{@currdir.path}/#{d}"
|
||||||
.then (r) ->
|
.then (r) =>
|
||||||
me.error __("Fail to rename to {0}: {1}", d, r.error) if r.error
|
@error __("Fail to rename to {0}: {1}", d, r.error) if r.error
|
||||||
.catch (e) ->
|
.catch (e) =>
|
||||||
console.log e
|
console.log e
|
||||||
me.error __("Fail to rename: {0}", e.stack)
|
@error __("Fail to rename: {0}", e.stack)
|
||||||
|
|
||||||
when "#{@name}-rm"
|
when "#{@name}-rm"
|
||||||
return unless file
|
return unless file
|
||||||
@ -231,13 +227,13 @@ class Files extends this.OS.GUI.BaseApplication
|
|||||||
iconclass: "fa fa-question-circle",
|
iconclass: "fa fa-question-circle",
|
||||||
text: __("Do you really want to delete: {0}?", file.filename)
|
text: __("Do you really want to delete: {0}?", file.filename)
|
||||||
})
|
})
|
||||||
.then (d) ->
|
.then (d) =>
|
||||||
return unless d
|
return unless d
|
||||||
file.path.asFileHandle().remove()
|
file.path.asFileHandle().remove()
|
||||||
.then (r) ->
|
.then (r) =>
|
||||||
me.error __("Fail to delete {0}: {1}", file.filename, r.error) if r.error
|
@error __("Fail to delete {0}: {1}", file.filename, r.error) if r.error
|
||||||
.catch (e) ->
|
.catch (e) =>
|
||||||
me.error __("Fail to delete: {0}", e.stack)
|
@error __("Fail to delete: {0}", e.stack)
|
||||||
|
|
||||||
when "#{@name}-cut"
|
when "#{@name}-cut"
|
||||||
return unless file
|
return unless file
|
||||||
@ -254,32 +250,30 @@ class Files extends this.OS.GUI.BaseApplication
|
|||||||
@notify __("File {0} copied", file.filename)
|
@notify __("File {0} copied", file.filename)
|
||||||
|
|
||||||
when "#{@name}-paste"
|
when "#{@name}-paste"
|
||||||
me = @
|
|
||||||
return unless @clipboard
|
return unless @clipboard
|
||||||
if @clipboard.cut
|
if @clipboard.cut
|
||||||
@clipboard.file.move "#{me.currdir.path}/#{@clipboard.file.basename}"
|
@clipboard.file.move "#{@currdir.path}/#{@clipboard.file.basename}"
|
||||||
.then (r) ->
|
.then (r) =>
|
||||||
me.clipboard = undefined
|
@clipboard = undefined
|
||||||
me.error __("Fail to paste: {0}", r.error) if r.error
|
@error __("Fail to paste: {0}", r.error) if r.error
|
||||||
.catch (e) ->
|
.catch (e) =>
|
||||||
me.error __("Fail to paste: {0}", e.stack)
|
@error __("Fail to paste: {0}", e.stack)
|
||||||
else
|
else
|
||||||
@clipboard.file.read("binary")
|
@clipboard.file.read("binary")
|
||||||
.then (d) ->
|
.then (d) =>
|
||||||
blob = new Blob [d], { type: me.clipboard.file.info.mime }
|
blob = new Blob [d], { type: @clipboard.file.info.mime }
|
||||||
fp = "#{me.currdir.path}/#{me.clipboard.file.basename}".asFileHandle()
|
fp = "#{@currdir.path}/#{@clipboard.file.basename}".asFileHandle()
|
||||||
fp.cache = blob
|
fp.cache = blob
|
||||||
fp.write(me.clipboard.file.info.mime)
|
fp.write(@clipboard.file.info.mime)
|
||||||
.then (r) ->
|
.then (r) =>
|
||||||
me.clipboard = undefined
|
@clipboard = undefined
|
||||||
me.error __("Fail to paste: {0}", r.error) if r.error
|
@error __("Fail to paste: {0}", r.error) if r.error
|
||||||
.catch (e) ->
|
.catch (e) =>
|
||||||
me.error __("Fail to paste: {0}", e.stack)
|
@error __("Fail to paste: {0}", e.stack)
|
||||||
else
|
else
|
||||||
@_api.handle.setting()
|
@_api.handle.setting()
|
||||||
|
|
||||||
actionFile: (e) ->
|
actionFile: (e) ->
|
||||||
me = @
|
|
||||||
file = @view.get "selectedFile"
|
file = @view.get "selectedFile"
|
||||||
switch e
|
switch e
|
||||||
when "#{@name}-mkdir"
|
when "#{@name}-mkdir"
|
||||||
@ -287,53 +281,51 @@ class Files extends this.OS.GUI.BaseApplication
|
|||||||
title: "__(New folder)",
|
title: "__(New folder)",
|
||||||
label: "__(Folder name)"
|
label: "__(Folder name)"
|
||||||
})
|
})
|
||||||
.then (d) ->
|
.then (d) =>
|
||||||
me.currdir.mk(d)
|
@currdir.mk(d)
|
||||||
.then (r) ->
|
.then (r) =>
|
||||||
me.error __("Fail to create {0}: {1}", d, r.error) if r.error
|
@error __("Fail to create {0}: {1}", d, r.error) if r.error
|
||||||
.catch (e) ->
|
.catch (e) =>
|
||||||
me.error __("Fail to create: {0}", e.stack)
|
@error __("Fail to create: {0}", e.stack)
|
||||||
|
|
||||||
when "#{@name}-mkf"
|
when "#{@name}-mkf"
|
||||||
@openDialog("PromptDialog", {
|
@openDialog("PromptDialog", {
|
||||||
title: "__(New file)",
|
title: "__(New file)",
|
||||||
label: "__(File name)"
|
label: "__(File name)"
|
||||||
})
|
})
|
||||||
.then (d) ->
|
.then (d) =>
|
||||||
fp = "#{me.currdir.path}/#{d}".asFileHandle()
|
fp = "#{@currdir.path}/#{d}".asFileHandle()
|
||||||
fp.write("text/plain")
|
fp.write("text/plain")
|
||||||
.then (r) ->
|
.then (r) =>
|
||||||
me.error __("Fail to create {0}: {1}", d, r.error) if r.error
|
@error __("Fail to create {0}: {1}", d, r.error) if r.error
|
||||||
.catch (e) ->
|
.catch (e) =>
|
||||||
me.error __("Fail to create: {0}", e.stack)
|
@error __("Fail to create: {0}", e.stack)
|
||||||
|
|
||||||
when "#{@name}-info"
|
when "#{@name}-info"
|
||||||
return unless file
|
return unless file
|
||||||
@openDialog "InfoDialog", file
|
@openDialog "InfoDialog", file
|
||||||
|
|
||||||
when "#{@name}-upload"
|
when "#{@name}-upload"
|
||||||
me = @
|
|
||||||
@currdir.upload()
|
@currdir.upload()
|
||||||
.then (r) ->
|
.then (r) =>
|
||||||
me.error __("Fail to upload to {0}: {1}", me.currdir.path, r.error) if r.error
|
@error __("Fail to upload to {0}: {1}", @currdir.path, r.error) if r.error
|
||||||
.catch (e) ->
|
.catch (e) =>
|
||||||
me.error __("Fail to upload: {0}", e.stack)
|
@error __("Fail to upload: {0}", e.stack)
|
||||||
|
|
||||||
when "#{@name}-share"
|
when "#{@name}-share"
|
||||||
me = @
|
|
||||||
return unless file and file.type is "file"
|
return unless file and file.type is "file"
|
||||||
file.path.asFileHandle().publish()
|
file.path.asFileHandle().publish()
|
||||||
.then (r) ->
|
.then (r) =>
|
||||||
return me.error __("Cannot share file: {0}", r.error) if r.error
|
return @error __("Cannot share file: {0}", r.error) if r.error
|
||||||
return me.notify __("Shared url: {0}", r.result)
|
return @notify __("Shared url: {0}", r.result)
|
||||||
.catch (e) ->
|
.catch (e) =>
|
||||||
me.error __("Fail to publish: {0}", e.stack)
|
@error __("Fail to publish: {0}", e.stack)
|
||||||
|
|
||||||
when "#{@name}-download"
|
when "#{@name}-download"
|
||||||
return unless file.type is "file"
|
return unless file.type is "file"
|
||||||
file.path.asFileHandle().download()
|
file.path.asFileHandle().download()
|
||||||
.catch (e) ->
|
.catch (e) =>
|
||||||
me.error __("Fail to download: {0}", e.stack)
|
@error __("Fail to download: {0}", e.stack)
|
||||||
else
|
else
|
||||||
console.log e
|
console.log e
|
||||||
|
|
||||||
|
@ -19,53 +19,52 @@
|
|||||||
class AppearanceHandle extends SettingHandle
|
class AppearanceHandle extends SettingHandle
|
||||||
constructor:(scheme, parent) ->
|
constructor:(scheme, parent) ->
|
||||||
super(scheme, parent)
|
super(scheme, parent)
|
||||||
me = @
|
|
||||||
@wplist = @find "wplist"
|
@wplist = @find "wplist"
|
||||||
@wpreview = @find "wp-preview"
|
@wpreview = @find "wp-preview"
|
||||||
@wpsize = @find "wpsize"
|
@wpsize = @find "wpsize"
|
||||||
@wprepeat = @find "wprepeat"
|
@wprepeat = @find "wprepeat"
|
||||||
@themelist = @find "theme-list"
|
@themelist = @find "theme-list"
|
||||||
@syswp = undefined
|
@syswp = undefined
|
||||||
@wplist.set "onlistselect", (e) ->
|
@wplist.set "onlistselect", (e) =>
|
||||||
data = e.data.item.get("data")
|
data = e.data.item.get("data")
|
||||||
$(me.wpreview)
|
$(@wpreview)
|
||||||
.css("background-image", "url(#{data.path.asFileHandle().getlink()})" )
|
.css("background-image", "url(#{data.path.asFileHandle().getlink()})" )
|
||||||
.css("background-size", "cover")
|
.css("background-size", "cover")
|
||||||
me.parent.systemsetting.appearance.wp.url = data.path
|
@parent.systemsetting.appearance.wp.url = data.path
|
||||||
me.parent._gui.wallpaper()
|
@parent._gui.wallpaper()
|
||||||
|
|
||||||
@wplist.set "buttons", [
|
@wplist.set "buttons", [
|
||||||
{
|
{
|
||||||
text: "+", onbtclick: (e) ->
|
text: "+", onbtclick: (e) =>
|
||||||
me.parent.openDialog("FileDialog", {
|
@parent.openDialog("FileDialog", {
|
||||||
title: __("Select image file"),
|
title: __("Select image file"),
|
||||||
mimes: ["image/.*"]
|
mimes: ["image/.*"]
|
||||||
}).then (d) ->
|
}).then (d) =>
|
||||||
me.parent.systemsetting.appearance.wps.push d.file.path
|
@parent.systemsetting.appearance.wps.push d.file.path
|
||||||
me.wplist.set "data", me.getwplist()
|
@wplist.set "data", @getwplist()
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
@wpsize.set "onlistselect", (e) ->
|
@wpsize.set "onlistselect", (e) =>
|
||||||
me.parent.systemsetting.appearance.wp.size = e.data.item.get("data").text
|
@parent.systemsetting.appearance.wp.size = e.data.item.get("data").text
|
||||||
me.parent._gui.wallpaper()
|
@parent._gui.wallpaper()
|
||||||
|
|
||||||
sizes = [
|
sizes = [
|
||||||
{ text: "cover", selected: me.parent.systemsetting.appearance.wp.size is "cover" },
|
{ text: "cover", selected: @parent.systemsetting.appearance.wp.size is "cover" },
|
||||||
{ text: "auto", selected: me.parent.systemsetting.appearance.wp.size is "auto" },
|
{ text: "auto", selected: @parent.systemsetting.appearance.wp.size is "auto" },
|
||||||
{ text: "contain", selected: me.parent.systemsetting.appearance.wp.size is "contain" }
|
{ text: "contain", selected: @parent.systemsetting.appearance.wp.size is "contain" }
|
||||||
]
|
]
|
||||||
@wpsize.set "data", sizes
|
@wpsize.set "data", sizes
|
||||||
|
|
||||||
repeats = [
|
repeats = [
|
||||||
{ text: "repeat", selected: me.parent.systemsetting.appearance.wp.repeat is "repeat" },
|
{ text: "repeat", selected: @parent.systemsetting.appearance.wp.repeat is "repeat" },
|
||||||
{ text: "repeat-x", selected: me.parent.systemsetting.appearance.wp.repeat is "repeat-x" },
|
{ text: "repeat-x", selected: @parent.systemsetting.appearance.wp.repeat is "repeat-x" },
|
||||||
{ text: "repeat-y", selected: me.parent.systemsetting.appearance.wp.repeat is "repeat-y" },
|
{ text: "repeat-y", selected: @parent.systemsetting.appearance.wp.repeat is "repeat-y" },
|
||||||
{ text: "no-repeat", selected: me.parent.systemsetting.appearance.wp.repeat is "no-repeat" }
|
{ text: "no-repeat", selected: @parent.systemsetting.appearance.wp.repeat is "no-repeat" }
|
||||||
]
|
]
|
||||||
@wprepeat.set "onlistselect", (e) ->
|
@wprepeat.set "onlistselect", (e) =>
|
||||||
me.parent.systemsetting.appearance.wp.repeat = e.data.item.get("data").text
|
@parent.systemsetting.appearance.wp.repeat = e.data.item.get("data").text
|
||||||
me.parent._gui.wallpaper()
|
@parent._gui.wallpaper()
|
||||||
@wprepeat.set "data", repeats
|
@wprepeat.set "data", repeats
|
||||||
|
|
||||||
@themelist.set "data" , [{ text: "antos", selected: true }]
|
@themelist.set "data" , [{ text: "antos", selected: true }]
|
||||||
@ -73,17 +72,17 @@ class AppearanceHandle extends SettingHandle
|
|||||||
if not @syswp
|
if not @syswp
|
||||||
path = "os://resources/themes/system/wp"
|
path = "os://resources/themes/system/wp"
|
||||||
path.asFileHandle().read()
|
path.asFileHandle().read()
|
||||||
.then (d) ->
|
.then (d) =>
|
||||||
return me.parent.error __("Cannot read wallpaper list from {0}", path) if d.error
|
return @parent.error __("Cannot read wallpaper list from {0}", path) if d.error
|
||||||
for v in d.result
|
for v in d.result
|
||||||
v.text = v.filename
|
v.text = v.filename
|
||||||
v.iconclass = "fa fa-file-image-o"
|
v.iconclass = "fa fa-file-image-o"
|
||||||
me.syswp = d.result
|
@syswp = d.result
|
||||||
me.wplist.set "data", me.getwplist()
|
@wplist.set "data", @getwplist()
|
||||||
.catch (e) -> me.parent.error e.stack
|
.catch (e) => @parent.error e.stack
|
||||||
else
|
else
|
||||||
|
|
||||||
me.wplist.set "data", me.getwplist()
|
@wplist.set "data", @getwplist()
|
||||||
|
|
||||||
getwplist: () ->
|
getwplist: () ->
|
||||||
list = []
|
list = []
|
||||||
|
@ -19,21 +19,20 @@
|
|||||||
class LocaleHandle extends SettingHandle
|
class LocaleHandle extends SettingHandle
|
||||||
constructor: (scheme, parent) ->
|
constructor: (scheme, parent) ->
|
||||||
super(scheme, parent)
|
super(scheme, parent)
|
||||||
me = @
|
|
||||||
@lglist = @find "lglist"
|
@lglist = @find "lglist"
|
||||||
@localelist = undefined
|
@localelist = undefined
|
||||||
@lglist.set "onlistselect", (e) ->
|
@lglist.set "onlistselect", (e) =>
|
||||||
me.parent._api.setLocale e.data.item.get("data").text
|
@parent._api.setLocale e.data.item.get("data").text
|
||||||
if not @localelist
|
if not @localelist
|
||||||
path = "os://resources/languages"
|
path = "os://resources/languages"
|
||||||
path.asFileHandle().read()
|
path.asFileHandle().read()
|
||||||
.then (d) ->
|
.then (d) =>
|
||||||
return me.parent.error __("Cannot fetch system locales: {0}", d.error) if d.derror
|
return @parent.error __("Cannot fetch system locales: {0}", d.error) if d.derror
|
||||||
for v in d.result
|
for v in d.result
|
||||||
v.text = v.filename.replace /\.json$/g, ""
|
v.text = v.filename.replace /\.json$/g, ""
|
||||||
v.selected = v.text is me.parent.systemsetting.system.locale
|
v.selected = v.text is @parent.systemsetting.system.locale
|
||||||
me.localelist = d.result
|
@localelist = d.result
|
||||||
me.lglist.set "data", me.localelist
|
@lglist.set "data", @localelist
|
||||||
.catch (e) -> me.parent.error e.stack
|
.catch (e) => @parent.error e.stack
|
||||||
else
|
else
|
||||||
me.lglist.set "data", me.localelist
|
@lglist.set "data", @localelist
|
||||||
|
@ -19,52 +19,51 @@
|
|||||||
class StartupHandle extends SettingHandle
|
class StartupHandle extends SettingHandle
|
||||||
constructor: (scheme, parent) ->
|
constructor: (scheme, parent) ->
|
||||||
super(scheme, parent)
|
super(scheme, parent)
|
||||||
me = @
|
|
||||||
@srvlist = @find "srvlist"
|
@srvlist = @find "srvlist"
|
||||||
@applist = @find "applist"
|
@applist = @find "applist"
|
||||||
@srvlist.set "buttons", [
|
@srvlist.set "buttons", [
|
||||||
{
|
{
|
||||||
text: "+", onbtclick: (e) ->
|
text: "+", onbtclick: (e) =>
|
||||||
services = []
|
services = []
|
||||||
for k, v of me.parent.systemsetting.system.packages
|
for k, v of @parent.systemsetting.system.packages
|
||||||
if v.services
|
if v.services
|
||||||
srvs = ({ text: "#{k}/#{x}", iconclass: "fa fa-tasks" } for x in v.services)
|
srvs = ({ text: "#{k}/#{x}", iconclass: "fa fa-tasks" } for x in v.services)
|
||||||
services = services.concat srvs
|
services = services.concat srvs
|
||||||
me.parent.openDialog("SelectionDialog", {
|
@parent.openDialog("SelectionDialog", {
|
||||||
title: "__(Add service)",
|
title: "__(Add service)",
|
||||||
data: services
|
data: services
|
||||||
}).then (d) ->
|
}).then (d) =>
|
||||||
me.parent.systemsetting.system.startup.services.push d.text
|
@parent.systemsetting.system.startup.services.push d.text
|
||||||
me.refresh()
|
@refresh()
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
text: "-", onbtclick: (e) ->
|
text: "-", onbtclick: (e) =>
|
||||||
item = me.srvlist.get "selectedItem"
|
item = @srvlist.get "selectedItem"
|
||||||
return unless item
|
return unless item
|
||||||
selidx = $(item).index()
|
selidx = $(item).index()
|
||||||
me.parent.systemsetting.system.startup.services.splice selidx, 1
|
@parent.systemsetting.system.startup.services.splice selidx, 1
|
||||||
me.refresh()
|
@refresh()
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
@applist.set "buttons", [
|
@applist.set "buttons", [
|
||||||
{
|
{
|
||||||
text: "+", onbtclick: (e) ->
|
text: "+", onbtclick: (e) =>
|
||||||
apps = ( { text: k, iconclass: v.iconclass } for k, v of me.parent.systemsetting.system.packages )
|
apps = ( { text: k, iconclass: v.iconclass } for k, v of @parent.systemsetting.system.packages )
|
||||||
me.parent.openDialog("SelectionDialog", {
|
@parent.openDialog("SelectionDialog", {
|
||||||
title: "__(Add application)",
|
title: "__(Add application)",
|
||||||
data: apps
|
data: apps
|
||||||
}).then (d) ->
|
}).then (d) =>
|
||||||
me.parent.systemsetting.system.startup.apps.push d.text
|
@parent.systemsetting.system.startup.apps.push d.text
|
||||||
me.refresh()
|
@refresh()
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
text: "-", onbtclick: (e) ->
|
text: "-", onbtclick: (e) =>
|
||||||
item = me.applist.get "selectedItem"
|
item = @applist.get "selectedItem"
|
||||||
return unless item
|
return unless item
|
||||||
selidx = $(item).index()
|
selidx = $(item).index()
|
||||||
me.parent.systemsetting.system.startup.apps.splice selidx, 1
|
@parent.systemsetting.system.startup.apps.splice selidx, 1
|
||||||
me.refresh()
|
@refresh()
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@refresh()
|
@refresh()
|
||||||
@ -72,30 +71,3 @@ class StartupHandle extends SettingHandle
|
|||||||
refresh: () ->
|
refresh: () ->
|
||||||
@srvlist.set "data", ( { text:v } for v in @parent.systemsetting.system.startup.services )
|
@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 )
|
@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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -21,28 +21,27 @@ class VFSSettingDialog extends this.OS.GUI.BasicDialog
|
|||||||
super "VFSSettingDialog", VFSSettingDialog.scheme
|
super "VFSSettingDialog", VFSSettingDialog.scheme
|
||||||
|
|
||||||
init: () ->
|
init: () ->
|
||||||
me = @
|
$(@find("txtPath")).click (e) =>
|
||||||
$(@find("txtPath")).click (e) ->
|
@openDialog("FileDialog", {
|
||||||
me.openDialog("FileDialog", {
|
|
||||||
title: "__(Select a directory)",
|
title: "__(Select a directory)",
|
||||||
mimes: ["dir"],
|
mimes: ["dir"],
|
||||||
hidden: true
|
hidden: true
|
||||||
})
|
})
|
||||||
.then (d) ->
|
.then (d) =>
|
||||||
(me.find "txtPath").value = d.file.path
|
(@find "txtPath").value = d.file.path
|
||||||
|
|
||||||
@find("btnOk").set "onbtclick", (e) ->
|
@find("btnOk").set "onbtclick", (e) =>
|
||||||
data = {
|
data = {
|
||||||
path: (me.find "txtPath").value,
|
path: (@find "txtPath").value,
|
||||||
name: (me.find "txtName").value
|
name: (@find "txtName").value
|
||||||
}
|
}
|
||||||
return me.error __("Please enter mount point name") unless data.name and data.name isnt ""
|
return @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 ""
|
return @error __("Please select a directory") unless data.path and data.path isnt ""
|
||||||
me.handle(data) if me.handle
|
@handle(data) if @handle
|
||||||
me.quit()
|
@quit()
|
||||||
|
|
||||||
(@find "btnCancel").set "onbtclick", (e) ->
|
(@find "btnCancel").set "onbtclick", (e) =>
|
||||||
me.quit()
|
@quit()
|
||||||
|
|
||||||
return unless @data
|
return unless @data
|
||||||
(@find "txtName").value = @data.text if @data.text
|
(@find "txtName").value = @data.text if @data.text
|
||||||
@ -76,75 +75,73 @@ VFSSettingDialog.scheme = """
|
|||||||
class VFSHandle extends SettingHandle
|
class VFSHandle extends SettingHandle
|
||||||
constructor: (scheme, parent) ->
|
constructor: (scheme, parent) ->
|
||||||
super(scheme, parent)
|
super(scheme, parent)
|
||||||
me = @
|
|
||||||
@mplist = @find "mplist"
|
@mplist = @find "mplist"
|
||||||
@dpath = @find "dpath"
|
@dpath = @find "dpath"
|
||||||
@ppath = @find "ppath"
|
@ppath = @find "ppath"
|
||||||
@mplist.set "buttons", [
|
@mplist.set "buttons", [
|
||||||
{
|
{
|
||||||
text: "+",
|
text: "+",
|
||||||
onbtclick: (e) ->
|
onbtclick: (e) =>
|
||||||
me.parent.openDialog(new VFSSettingDialog(), {
|
@parent.openDialog(new VFSSettingDialog(), {
|
||||||
title: "__(Add mount point)"
|
title: "__(Add mount point)"
|
||||||
})
|
})
|
||||||
.then (d) ->
|
.then (d) =>
|
||||||
me.parent.systemsetting.VFS.mountpoints.push {
|
@parent.systemsetting.VFS.mountpoints.push {
|
||||||
text: d.name, path: d.path, iconclass: "fa fa-folder", type: "fs"
|
text: d.name, path: d.path, iconclass: "fa fa-folder", type: "fs"
|
||||||
}
|
}
|
||||||
me.refresh()
|
@refresh()
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
text: "-",
|
text: "-",
|
||||||
onbtclick: (e) ->
|
onbtclick: (e) =>
|
||||||
item = me.mplist.get "selectedItem"
|
item = @mplist.get "selectedItem"
|
||||||
return unless item
|
return unless item
|
||||||
selidx = $(item).index()
|
selidx = $(item).index()
|
||||||
me.parent.openDialog("YesNoDialog", {
|
@parent.openDialog("YesNoDialog", {
|
||||||
title: "__(Remove)",
|
title: "__(Remove)",
|
||||||
text: __("Remove: {0}?", item.get("data").text)
|
text: __("Remove: {0}?", item.get("data").text)
|
||||||
}).then (d) ->
|
}).then (d) =>
|
||||||
return unless d
|
return unless d
|
||||||
me.parent.systemsetting.VFS.mountpoints.splice selidx, 1
|
@parent.systemsetting.VFS.mountpoints.splice selidx, 1
|
||||||
me.refresh()
|
@refresh()
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
text: "",
|
text: "",
|
||||||
iconclass: "fa fa-pencil",
|
iconclass: "fa fa-pencil",
|
||||||
onbtclick: (e) ->
|
onbtclick: (e) =>
|
||||||
sel = me.mplist.get "selectedItem"
|
sel = @mplist.get "selectedItem"
|
||||||
return unless sel
|
return unless sel
|
||||||
me.parent.openDialog(new VFSSettingDialog(), {
|
@parent.openDialog(new VFSSettingDialog(), {
|
||||||
title: "__(Edit mount point)",
|
title: "__(Edit mount point)",
|
||||||
text: sel.get("data").text,
|
text: sel.get("data").text,
|
||||||
path: sel.get("data").path
|
path: sel.get("data").path
|
||||||
}).then (d) ->
|
}).then (d) =>
|
||||||
sel.get("data").text = d.name
|
sel.get("data").text = d.name
|
||||||
sel.get("data").path = d.path
|
sel.get("data").path = d.path
|
||||||
me.refresh()
|
@refresh()
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
(@find "btndpath").set 'onbtclick', (e) ->
|
(@find "btndpath").set 'onbtclick', (e) =>
|
||||||
me.parent.openDialog("FileDialog", {
|
@parent.openDialog("FileDialog", {
|
||||||
title: "__(Select a directory)",
|
title: "__(Select a directory)",
|
||||||
mimes: ["dir"],
|
mimes: ["dir"],
|
||||||
hidden: true
|
hidden: true
|
||||||
}).then (d) ->
|
}).then (d) =>
|
||||||
me.parent.systemsetting.desktop.path = d.file.path
|
@parent.systemsetting.desktop.path = d.file.path
|
||||||
me.parent._gui.refreshDesktop()
|
@parent._gui.refreshDesktop()
|
||||||
me.refresh()
|
@refresh()
|
||||||
|
|
||||||
(@find "btnppath").set 'onbtclick', (e) ->
|
(@find "btnppath").set 'onbtclick', (e) =>
|
||||||
me.parent.openDialog("FileDialog", {
|
@parent.openDialog("FileDialog", {
|
||||||
title: "__(Select a directory)",
|
title: "__(Select a directory)",
|
||||||
mimes: ["dir"],
|
mimes: ["dir"],
|
||||||
hidden: true
|
hidden: true
|
||||||
}).then (d) ->
|
}).then (d) =>
|
||||||
me.parent.systemsetting.system.pkgpaths.user = d.file.path
|
@parent.systemsetting.system.pkgpaths.user = d.file.path
|
||||||
me.refresh()
|
@refresh()
|
||||||
me.refresh()
|
@refresh()
|
||||||
|
|
||||||
refresh: () ->
|
refresh: () ->
|
||||||
me = @
|
|
||||||
@mplist.set "data", @parent.systemsetting.VFS.mountpoints
|
@mplist.set "data", @parent.systemsetting.VFS.mountpoints
|
||||||
@dpath.set "text", @parent.systemsetting.desktop.path
|
@dpath.set "text", @parent.systemsetting.desktop.path
|
||||||
@ppath.set "text", @parent.systemsetting.system.pkgpaths.user
|
@ppath.set "text", @parent.systemsetting.system.pkgpaths.user
|
@ -28,7 +28,6 @@ class Setting extends this.OS.GUI.BaseApplication
|
|||||||
super "Setting", args
|
super "Setting", args
|
||||||
|
|
||||||
main: () ->
|
main: () ->
|
||||||
me = @
|
|
||||||
@container = @find "container"
|
@container = @find "container"
|
||||||
|
|
||||||
new AppearanceHandle @find("appearance"), @
|
new AppearanceHandle @find("appearance"), @
|
||||||
@ -36,12 +35,12 @@ class Setting extends this.OS.GUI.BaseApplication
|
|||||||
new LocaleHandle @find("locale"), @
|
new LocaleHandle @find("locale"), @
|
||||||
new StartupHandle @find("startup"), @
|
new StartupHandle @find("startup"), @
|
||||||
|
|
||||||
(@find "btnsave").set "onbtclick", (e) ->
|
(@find "btnsave").set "onbtclick", (e) =>
|
||||||
me._api.setting()
|
@_api.setting()
|
||||||
.then (d) ->
|
.then (d) =>
|
||||||
return me.error __("Cannot save system setting: {0}", d.error) if d.error
|
return @error __("Cannot save system setting: {0}", d.error) if d.error
|
||||||
me.notify __("System setting saved")
|
@notify __("System setting saved")
|
||||||
.catch (e) ->
|
.catch (e) =>
|
||||||
me.error __("Cannot save system setting: {0}", e.stack)
|
@error __("Cannot save system setting: {0}", e.stack)
|
||||||
Setting.singleton = true
|
Setting.singleton = true
|
||||||
this.OS.register "Setting", Setting
|
this.OS.register "Setting", Setting
|
@ -4,17 +4,16 @@ class ShowCase extends this.OS.GUI.BaseApplication
|
|||||||
super "ShowCase", args
|
super "ShowCase", args
|
||||||
|
|
||||||
main: () ->
|
main: () ->
|
||||||
me = @
|
|
||||||
|
|
||||||
bt = @find 'bttest'
|
bt = @find 'bttest'
|
||||||
bt.set "onbtclick", (e) ->
|
bt.set "onbtclick", (e) =>
|
||||||
me.notify "btclicked"
|
@notify "btclicked"
|
||||||
|
|
||||||
@observable.on "btclick", (e) ->
|
@observable.on "btclick", (e) =>
|
||||||
me.notify "button clicked"
|
@notify "button clicked"
|
||||||
|
|
||||||
@observable.on "menuselect", (e) ->
|
@observable.on "menuselect", (e) =>
|
||||||
me.notify e.id
|
@notify e.id
|
||||||
|
|
||||||
list = @find 'list'
|
list = @find 'list'
|
||||||
|
|
||||||
@ -27,28 +26,28 @@ class ShowCase extends this.OS.GUI.BaseApplication
|
|||||||
{ text: "some thing 5" }
|
{ text: "some thing 5" }
|
||||||
]
|
]
|
||||||
list.unshift { text: "shifted el" }
|
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 = @find 'switch'
|
||||||
sw.set "onchange", (e) ->
|
sw.set "onchange", (e) =>
|
||||||
me.notify e.data
|
@notify e.data
|
||||||
|
|
||||||
spin = @find 'spin'
|
spin = @find 'spin'
|
||||||
spin.set "onchange", (e) ->
|
spin.set "onchange", (e) =>
|
||||||
me.notify e.data
|
@notify e.data
|
||||||
|
|
||||||
menu = @find 'menu'
|
menu = @find 'menu'
|
||||||
menu.set "items", @menu()
|
menu.set "items", @menu()
|
||||||
|
|
||||||
list.contextmenuHandle = (e, m) ->
|
list.contextmenuHandle = (e, m) =>
|
||||||
m.set "items", me.menu()
|
m.set "items", @menu()
|
||||||
m.show e
|
m.show e
|
||||||
|
|
||||||
grid = @find 'grid'
|
grid = @find 'grid'
|
||||||
grid.set "oncelldbclick", (e) ->
|
grid.set "oncelldbclick", (e) =>
|
||||||
me.notify "on dbclick", e
|
@notify "on dbclick", e
|
||||||
grid.set "onrowselect", (e) ->
|
grid.set "onrowselect", (e) =>
|
||||||
me.notify "on rowselect", e.data.items
|
@notify "on rowselect", e.data.items
|
||||||
|
|
||||||
@observable.on "cellselect", (e) ->
|
@observable.on "cellselect", (e) ->
|
||||||
console.log "observable", e
|
console.log "observable", e
|
||||||
@ -99,30 +98,30 @@ class ShowCase extends this.OS.GUI.BaseApplication
|
|||||||
|
|
||||||
tree = @find 'tree'
|
tree = @find 'tree'
|
||||||
tree.set "data", tdata
|
tree.set "data", tdata
|
||||||
tree.set "ontreeselect", (e) ->
|
tree.set "ontreeselect", (e) =>
|
||||||
me.notify e.data.item.get "treepath"
|
@notify e.data.item.get "treepath"
|
||||||
tree.set "ontreedbclick", (e) ->
|
tree.set "ontreedbclick", (e) =>
|
||||||
me.notify "treedbclick", e
|
@notify "treedbclick", e
|
||||||
@observable.on "treedbclick", (e) ->
|
@observable.on "treedbclick", (e) =>
|
||||||
me.notify "observable treedbclick", e
|
@notify "observable treedbclick", e
|
||||||
|
|
||||||
slider = @find 'slider'
|
slider = @find 'slider'
|
||||||
slider.set "onchange", (v) ->
|
slider.set "onchange", (v) =>
|
||||||
me.notify v
|
@notify v
|
||||||
|
|
||||||
cal = @find 'cal'
|
cal = @find 'cal'
|
||||||
cal.set "ondateselect", (e) ->
|
cal.set "ondateselect", (e) =>
|
||||||
me.notify e
|
@notify e
|
||||||
|
|
||||||
pk = @find 'cpk'
|
pk = @find 'cpk'
|
||||||
pk.set "oncolorselect", (e) ->
|
pk.set "oncolorselect", (e) =>
|
||||||
me.notify e
|
@notify e
|
||||||
pk.set "oncolorselect", (e) ->
|
pk.set "oncolorselect", (e) =>
|
||||||
me.notify e
|
@notify e
|
||||||
|
|
||||||
fileview = @find 'fileview'
|
fileview = @find 'fileview'
|
||||||
fileview.set "fetch", (path) ->
|
fileview.set "fetch", (path) =>
|
||||||
new Promise (resolve, reject) ->
|
new Promise (resolve, reject) =>
|
||||||
dir = path.asFileHandle()
|
dir = path.asFileHandle()
|
||||||
dir.read().then (d) ->
|
dir.read().then (d) ->
|
||||||
p = dir.parent().asFileHandle()
|
p = dir.parent().asFileHandle()
|
||||||
@ -139,8 +138,8 @@ class ShowCase extends this.OS.GUI.BaseApplication
|
|||||||
{ text: "list" },
|
{ text: "list" },
|
||||||
{ text: "tree" }
|
{ text: "tree" }
|
||||||
]
|
]
|
||||||
viewoption.set "onlistselect", (e) ->
|
viewoption.set "onlistselect", (e) =>
|
||||||
me.notify e.data.item.get("data").text
|
@notify e.data.item.get("data").text
|
||||||
fileview.set "view", e.data.item.get("data").text
|
fileview.set "view", e.data.item.get("data").text
|
||||||
|
|
||||||
dllist = @find "dialoglist"
|
dllist = @find "dialoglist"
|
||||||
@ -157,30 +156,30 @@ class ShowCase extends this.OS.GUI.BaseApplication
|
|||||||
{ text: "File dialog", id: "file" }
|
{ text: "File dialog", id: "file" }
|
||||||
]
|
]
|
||||||
|
|
||||||
btrun.set "onbtclick", (e) ->
|
btrun.set "onbtclick", (e) =>
|
||||||
item = dllist.get "selectedItem"
|
item = dllist.get "selectedItem"
|
||||||
return unless item
|
return unless item
|
||||||
switch item.get("data").id
|
switch item.get("data").id
|
||||||
when "prompt"
|
when "prompt"
|
||||||
me.openDialog("PromptDialog", {
|
@openDialog("PromptDialog", {
|
||||||
title: "Prompt review",
|
title: "Prompt review",
|
||||||
value: "txt data",
|
value: "txt data",
|
||||||
label: "enter value"
|
label: "enter value"
|
||||||
})
|
})
|
||||||
.then (d) ->
|
.then (d) =>
|
||||||
me.notify d
|
@notify d
|
||||||
when "calendar"
|
when "calendar"
|
||||||
me.openDialog("CalendarDialog", {
|
@openDialog("CalendarDialog", {
|
||||||
title: "Calendar"
|
title: "Calendar"
|
||||||
})
|
})
|
||||||
.then (d) ->
|
.then (d) =>
|
||||||
me.notify d
|
@notify d
|
||||||
when "colorpicker"
|
when "colorpicker"
|
||||||
me.openDialog("ColorPickerDialog")
|
@openDialog("ColorPickerDialog")
|
||||||
.then (d) ->
|
.then (d) =>
|
||||||
me.notify d
|
@notify d
|
||||||
when "info"
|
when "info"
|
||||||
me.openDialog("InfoDialog", {
|
@openDialog("InfoDialog", {
|
||||||
title: "Info application",
|
title: "Info application",
|
||||||
name: "Show case",
|
name: "Show case",
|
||||||
date: "10/12/2014",
|
date: "10/12/2014",
|
||||||
@ -188,14 +187,14 @@ class ShowCase extends this.OS.GUI.BaseApplication
|
|||||||
})
|
})
|
||||||
.then (d) ->
|
.then (d) ->
|
||||||
when "yesno"
|
when "yesno"
|
||||||
me.openDialog("YesNoDialog", {
|
@openDialog("YesNoDialog", {
|
||||||
title: "Question ?",
|
title: "Question ?",
|
||||||
text: "Do you realy want to delete file ?"
|
text: "Do you realy want to delete file ?"
|
||||||
})
|
})
|
||||||
.then (d) ->
|
.then (d) =>
|
||||||
me.notify d
|
@notify d
|
||||||
when "selection"
|
when "selection"
|
||||||
me.openDialog("SelectionDialog", {
|
@openDialog("SelectionDialog", {
|
||||||
title: "Select data ?",
|
title: "Select data ?",
|
||||||
data: [
|
data: [
|
||||||
{ text: "Option 1" },
|
{ text: "Option 1" },
|
||||||
@ -203,27 +202,26 @@ class ShowCase extends this.OS.GUI.BaseApplication
|
|||||||
{ text: "Option 3", iconclass: "fa fa-camera-retro fa-lg" }
|
{ text: "Option 3", iconclass: "fa fa-camera-retro fa-lg" }
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
.then (d) ->
|
.then (d) =>
|
||||||
me.notify d.text
|
@notify d.text
|
||||||
when "about"
|
when "about"
|
||||||
me.openDialog("AboutDialog" )
|
@openDialog("AboutDialog" )
|
||||||
.then (d) ->
|
.then (d) =>
|
||||||
when "file"
|
when "file"
|
||||||
me.openDialog("FileDialog", {
|
@openDialog("FileDialog", {
|
||||||
title: "Select file ?",
|
title: "Select file ?",
|
||||||
#root: "home:///",
|
#root: "home:///",
|
||||||
mimes: ["text/*", "dir"],
|
mimes: ["text/*", "dir"],
|
||||||
file: "Untitled".asFileHandle()
|
file: "Untitled".asFileHandle()
|
||||||
})
|
})
|
||||||
.then (f, name) ->
|
.then (f, name) =>
|
||||||
me.notify f, name
|
@notify f, name
|
||||||
else return
|
else return
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
mnFile: () ->
|
mnFile: () ->
|
||||||
#me.notify file
|
#@notify file
|
||||||
me = @
|
|
||||||
arr = {
|
arr = {
|
||||||
text: "__(File)",
|
text: "__(File)",
|
||||||
child: [
|
child: [
|
||||||
@ -234,11 +232,11 @@ class ShowCase extends this.OS.GUI.BaseApplication
|
|||||||
{ text: "__(Download)", dataid: "#{@name}-download" },
|
{ text: "__(Download)", dataid: "#{@name}-download" },
|
||||||
{ text: "__(Share file)", dataid: "#{@name}-share", shortcut: 'C-S' },
|
{ text: "__(Share file)", dataid: "#{@name}-share", shortcut: 'C-S' },
|
||||||
{ text: "__(Properties)", dataid: "#{@name}-info", shortcut: 'C-I' }
|
{ text: "__(Properties)", dataid: "#{@name}-info", shortcut: 'C-I' }
|
||||||
], onchildselect: (e) -> me.notify "child", e
|
], onchildselect: (e) => @notify "child", e
|
||||||
}
|
}
|
||||||
return arr
|
return arr
|
||||||
mnEdit: () ->
|
mnEdit: () ->
|
||||||
me = @
|
|
||||||
{
|
{
|
||||||
text: "__(Edit)",
|
text: "__(Edit)",
|
||||||
child: [
|
child: [
|
||||||
@ -247,11 +245,10 @@ class ShowCase extends this.OS.GUI.BaseApplication
|
|||||||
{ text: "__(Cut)", dataid: "#{@name}-cut", shortcut: 'C-X' },
|
{ text: "__(Cut)", dataid: "#{@name}-cut", shortcut: 'C-X' },
|
||||||
{ text: "__(Copy)", dataid: "#{@name}-copy", shortcut: 'C-C' },
|
{ text: "__(Copy)", dataid: "#{@name}-copy", shortcut: 'C-C' },
|
||||||
{ text: "__(Paste)", dataid: "#{@name}-paste", shortcut: 'C-P' }
|
{ text: "__(Paste)", dataid: "#{@name}-paste", shortcut: 'C-P' }
|
||||||
], onchildselect: (e) -> console.log "child", e
|
], onchildselect: (e) => console.log "child", e
|
||||||
}
|
}
|
||||||
|
|
||||||
menu: () ->
|
menu: () ->
|
||||||
me = @
|
|
||||||
menu = [
|
menu = [
|
||||||
@mnFile(),
|
@mnFile(),
|
||||||
@mnEdit(),
|
@mnEdit(),
|
||||||
@ -268,7 +265,7 @@ class ShowCase extends this.OS.GUI.BaseApplication
|
|||||||
{ text: "__(Tree view)", radio:true, checked: false, dataid: "#{@name}-tree", type: 'tree' }
|
{ 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
|
], onchildselect: (e) => console.log "child", e
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
menu
|
menu
|
||||||
|
Loading…
Reference in New Issue
Block a user