mirror of
https://github.com/lxsang/antos-frontend.git
synced 2025-02-22 09:52:47 +01:00
add file sync mechanism between apps
This commit is contained in:
parent
1311ea2a88
commit
02422319ca
@ -88,7 +88,15 @@ self.OS or=
|
|||||||
($ "#wrapper").empty()
|
($ "#wrapper").empty()
|
||||||
_GUI.clearTheme()
|
_GUI.clearTheme()
|
||||||
_courrier.observable = riot.observable()
|
_courrier.observable = riot.observable()
|
||||||
|
_courrier.quota = 0
|
||||||
_OS.APP = {}
|
_OS.APP = {}
|
||||||
|
_OS.setting =
|
||||||
|
user: {}
|
||||||
|
applications: {}
|
||||||
|
desktop: {}
|
||||||
|
appearance: {}
|
||||||
|
VFS: {}
|
||||||
|
system: {}
|
||||||
_PM.processes = {}
|
_PM.processes = {}
|
||||||
_PM.pidalloc = 0
|
_PM.pidalloc = 0
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ self.OS.GUI =
|
|||||||
_courrier.osfail "Cannot read service script: #{srv} ", e, s
|
_courrier.osfail "Cannot read service script: #{srv} ", e, s
|
||||||
|
|
||||||
appsByMime: (mime) ->
|
appsByMime: (mime) ->
|
||||||
metas = ( a.meta for k, a of _OS.APP when a and a.type is 1)
|
metas = ( v for k, v of _OS.setting.system.packages when v.app )
|
||||||
mimes = ( m.mimes for m in metas when m)
|
mimes = ( m.mimes for m in metas when m)
|
||||||
apps = []
|
apps = []
|
||||||
# search app by mimes
|
# search app by mimes
|
||||||
@ -80,9 +80,9 @@ self.OS.GUI =
|
|||||||
|
|
||||||
openWith: (it) ->
|
openWith: (it) ->
|
||||||
return unless it
|
return unless it
|
||||||
console.log "open #{it.path}"
|
return _GUI.launch it.app if it.type is "app" and it.app
|
||||||
apps = _GUI.appsByMime ( if it.type is "dir" then "dir" else it.mime )
|
apps = _GUI.appsByMime ( if it.type is "dir" then "dir" else it.mime )
|
||||||
return OS.info "No application available to open #{it.filename}" if apps.length is 0
|
return _courrier.osinfo "No application available to open #{it.filename}" if apps.length is 0
|
||||||
return _GUI.launch apps[0].app, [it.path] if apps.length is 1
|
return _GUI.launch apps[0].app, [it.path] if apps.length is 1
|
||||||
list = ( { text: e.app, icon: e.icon, iconclass: e.iconclass } for e in apps )
|
list = ( { text: e.app, icon: e.icon, iconclass: e.iconclass } for e in apps )
|
||||||
_GUI.openDialog "SelectionDialog", ( d ) ->
|
_GUI.openDialog "SelectionDialog", ( d ) ->
|
||||||
@ -186,8 +186,8 @@ self.OS.GUI =
|
|||||||
|
|
||||||
# desktop default file manager
|
# desktop default file manager
|
||||||
desktop = $ "#desktop"
|
desktop = $ "#desktop"
|
||||||
|
fp = _OS.setting.desktop.path.asFileHandler()
|
||||||
desktop[0].fetch = () ->
|
desktop[0].fetch = () ->
|
||||||
fp = _OS.setting.desktop.path.asFileHandler()
|
|
||||||
fn = () ->
|
fn = () ->
|
||||||
fp.read (d) ->
|
fp.read (d) ->
|
||||||
return _courrier.osfail d.error, (_API.throwe "OS.VFS"), d.error if d.error
|
return _courrier.osfail d.error, (_API.throwe "OS.VFS"), d.error if d.error
|
||||||
@ -239,7 +239,9 @@ self.OS.GUI =
|
|||||||
console.log "context menu handler for desktop"
|
console.log "context menu handler for desktop"
|
||||||
|
|
||||||
desktop[0].fetch()
|
desktop[0].fetch()
|
||||||
_courrier.trigger "desktoploaded"
|
_courrier.observable.on "VFS", (d) ->
|
||||||
|
desktop[0].fetch() if d.data.file.hash() is fp.hash() or d.data.file.parent().hash() is fp.hash()
|
||||||
|
_courrier.ostrigger "desktoploaded"
|
||||||
# mount it
|
# mount it
|
||||||
riot.mount desktop
|
riot.mount desktop
|
||||||
, (e, s) ->
|
, (e, s) ->
|
||||||
@ -256,7 +258,7 @@ self.OS.GUI =
|
|||||||
child: [
|
child: [
|
||||||
{
|
{
|
||||||
text: "Application",
|
text: "Application",
|
||||||
child: [],
|
child: ( v for k, v of _OS.setting.system.packages when v.app ),
|
||||||
dataid: "sys-apps"
|
dataid: "sys-apps"
|
||||||
iconclass: "fa fa-adn",
|
iconclass: "fa fa-adn",
|
||||||
onmenuselect: (d) ->
|
onmenuselect: (d) ->
|
||||||
@ -273,13 +275,7 @@ self.OS.GUI =
|
|||||||
return _API.handler.logout() if d.item.data.dataid is "sys-logout"
|
return _API.handler.logout() if d.item.data.dataid is "sys-logout"
|
||||||
_GUI.launch d.item.data.app unless d.item.data.dataid
|
_GUI.launch d.item.data.app unless d.item.data.dataid
|
||||||
|
|
||||||
#now get app list
|
($ "[data-id = 'os_menu']", "#syspanel")[0].set "items", [menu]
|
||||||
_API.packages.fetch (r) ->
|
|
||||||
if r.result
|
|
||||||
r.result = ( it for it in r.result when it.app )
|
|
||||||
v.text = v.name for k, v of r.result
|
|
||||||
menu.child[0].child = r.result if r.result
|
|
||||||
($ "[data-id = 'os_menu']", "#syspanel")[0].set "items", [menu]
|
|
||||||
#console.log menu
|
#console.log menu
|
||||||
|
|
||||||
|
|
||||||
@ -329,14 +325,23 @@ self.OS.GUI =
|
|||||||
_GUI.initDM()
|
_GUI.initDM()
|
||||||
_courrier.observable.one "syspanelloaded", () ->
|
_courrier.observable.one "syspanelloaded", () ->
|
||||||
# TODO load packages list then build system menu
|
# TODO load packages list then build system menu
|
||||||
# push startup services
|
_API.packages.fetch (r) ->
|
||||||
# TODO: get services list from user setting
|
if r.result
|
||||||
_GUI.buildSystemMenu()
|
for k, v of r.result
|
||||||
_GUI.pushServices [
|
v.text = v.name
|
||||||
"CoreServices/PushNotification",
|
v.filename = k
|
||||||
"CoreServices/Spotlight",
|
v.type = "app"
|
||||||
"CoreServices/Calendar"
|
v.mime = "antos/app"
|
||||||
]
|
v.iconclass = "fa fa-adn" unless v.iconclass or v.icon
|
||||||
|
_OS.setting.system.packages = if r.result then r.result else
|
||||||
|
_GUI.buildSystemMenu()
|
||||||
|
# push startup services
|
||||||
|
# TODO: get services list from user setting
|
||||||
|
_GUI.pushServices [
|
||||||
|
"CoreServices/PushNotification",
|
||||||
|
"CoreServices/Spotlight",
|
||||||
|
"CoreServices/Calendar"
|
||||||
|
]
|
||||||
|
|
||||||
# startup application here
|
# startup application here
|
||||||
_courrier.observable.one "desktoploaded", () ->
|
_courrier.observable.one "desktoploaded", () ->
|
||||||
|
@ -62,7 +62,8 @@
|
|||||||
v.text = v.filename
|
v.text = v.filename
|
||||||
if(v.text.length > 10)
|
if(v.text.length > 10)
|
||||||
v.text = v.text.substring(0,9) + "..."
|
v.text = v.text.substring(0,9) + "..."
|
||||||
v.iconclass = v.type
|
v.iconclass = v.iconclass?v.iconclass:v.type
|
||||||
|
v.icon = v.icon
|
||||||
items.push(v)
|
items.push(v)
|
||||||
})
|
})
|
||||||
self.refs.listview.root.set("items", items)
|
self.refs.listview.root.set("items", items)
|
||||||
@ -71,7 +72,7 @@
|
|||||||
var rows = []
|
var rows = []
|
||||||
$.each(self.data, function(i,v){
|
$.each(self.data, function(i,v){
|
||||||
if(v.filename[0] == '.' && !self.showhidden) return
|
if(v.filename[0] == '.' && !self.showhidden) return
|
||||||
var row = [{value:v.filename, iconclass: v.type},{value:v.mime},{value:v.size},{idx:i}]
|
var row = [{value:v.filename, iconclass: v.iconclass?v.iconclass:v.type, icon:v.icon},{value:v.mime},{value:v.size},{idx:i}]
|
||||||
rows.push(row)
|
rows.push(row)
|
||||||
})
|
})
|
||||||
self.refs.gridview.root.set("rows",rows)
|
self.refs.gridview.root.set("rows",rows)
|
||||||
@ -94,7 +95,8 @@
|
|||||||
v.nodes = []
|
v.nodes = []
|
||||||
v.open = false
|
v.open = false
|
||||||
}
|
}
|
||||||
v.iconclass = v.type
|
v.iconclass = v.iconclass?v.iconclass:v.type
|
||||||
|
v.icon = v.icon
|
||||||
nodes.push(v)
|
nodes.push(v)
|
||||||
})
|
})
|
||||||
return nodes
|
return nodes
|
||||||
@ -186,7 +188,7 @@
|
|||||||
})
|
})
|
||||||
self.root.observable.on("filedbclick", function(e){
|
self.root.observable.on("filedbclick", function(e){
|
||||||
if(e.id != self.rid ) return
|
if(e.id != self.rid ) return
|
||||||
if(e.data.type == "file" && self.onfileopen)
|
if(e.data.type != "dir" && self.onfileopen)
|
||||||
self.onfileopen(e.data)
|
self.onfileopen(e.data)
|
||||||
else if(self.chdir && e.data.type == "dir")
|
else if(self.chdir && e.data.type == "dir")
|
||||||
self.chdir(e.data.path)
|
self.chdir(e.data.path)
|
||||||
|
@ -64,7 +64,7 @@ class BasicFileHandler
|
|||||||
me.meta (d) ->
|
me.meta (d) ->
|
||||||
if d.error
|
if d.error
|
||||||
return if err then err d else _courrier.osfail d.error, (_API.throwe "OS.VFS"), d.error
|
return if err then err d else _courrier.osfail d.error, (_API.throwe "OS.VFS"), d.error
|
||||||
me.meta = d.result
|
me.info = d.result
|
||||||
me.ready = true
|
me.ready = true
|
||||||
f()
|
f()
|
||||||
|
|
||||||
@ -73,19 +73,28 @@ class BasicFileHandler
|
|||||||
@onready (() -> me.action "read", null, f)
|
@onready (() -> me.action "read", null, f)
|
||||||
|
|
||||||
write: (d, f) ->
|
write: (d, f) ->
|
||||||
@action "write", d, f
|
me = @
|
||||||
|
@action "write", d, (r) ->
|
||||||
|
_courrier.ostrigger "VFS", { m: "write", file: me } if r.result
|
||||||
|
f r
|
||||||
|
|
||||||
mk: (d, f) ->
|
mk: (d, f) ->
|
||||||
me = @
|
me = @
|
||||||
@onready (() -> me.action "mk", d, f)
|
@onready (() -> me.action "mk", d, (r) ->
|
||||||
|
_courrier.ostrigger "VFS", { m: "mk", file: me } if r.result
|
||||||
|
f r)
|
||||||
|
|
||||||
remove: (f) ->
|
remove: (f) ->
|
||||||
me = @
|
me = @
|
||||||
@onready (() -> me.action "remove", null, f)
|
@onready (() -> me.action "remove", null, (r) ->
|
||||||
|
_courrier.ostrigger "VFS", { m: "remove", file: me } if r.result
|
||||||
|
f r)
|
||||||
|
|
||||||
upload: (f) ->
|
upload: (f) ->
|
||||||
me = @
|
me = @
|
||||||
@onready (() -> me.action "upload", null, f)
|
@onready (() -> me.action "upload", null, (r) ->
|
||||||
|
_courrier.ostrigger "VFS", { m: "upload", file: me } if r.result
|
||||||
|
f r)
|
||||||
|
|
||||||
download: (f) ->
|
download: (f) ->
|
||||||
me = @
|
me = @
|
||||||
@ -93,7 +102,9 @@ class BasicFileHandler
|
|||||||
|
|
||||||
move: (d, f) ->
|
move: (d, f) ->
|
||||||
me = @
|
me = @
|
||||||
@onready (() -> me.action "move", d, f)
|
@onready (() -> me.action "move", d, (r) ->
|
||||||
|
_courrier.ostrigger "VFS", { m: "move", file: d.asFileHandler() } if r.result
|
||||||
|
f r)
|
||||||
|
|
||||||
execute: (f) ->
|
execute: (f) ->
|
||||||
me = @
|
me = @
|
||||||
@ -123,21 +134,21 @@ class RemoteFileHandler extends self.OS.API.VFS.BasicFileHandler
|
|||||||
me = @
|
me = @
|
||||||
switch n
|
switch n
|
||||||
when "read"
|
when "read"
|
||||||
return _API.handler.scandir @path, f if @meta.type is "dir"
|
return _API.handler.scandir @path, f if @info.type is "dir"
|
||||||
#read the file
|
#read the file
|
||||||
_API.handler.readfile @path, f
|
_API.handler.readfile @path, f
|
||||||
when "mk"
|
when "mk"
|
||||||
return f { error: "#{@path} is not a directory" } if @meta.type is "file"
|
return f { error: "#{@path} is not a directory" } if @info.type is "file"
|
||||||
_API.handler.mkdir "#{@path}/#{p}", f
|
_API.handler.mkdir "#{@path}/#{p}", f
|
||||||
when "write"
|
when "write"
|
||||||
_API.handler.write @path, p, f
|
_API.handler.write @path, p, f
|
||||||
when "upload"
|
when "upload"
|
||||||
return if @meta.type is "file"
|
return if @info.type is "file"
|
||||||
_API.handler.upload @path, f
|
_API.handler.upload @path, f
|
||||||
when "remove"
|
when "remove"
|
||||||
_API.handler.delete @path, f
|
_API.handler.delete @path, f
|
||||||
when "download"
|
when "download"
|
||||||
return if @meta.type is "dir"
|
return if @info.type is "dir"
|
||||||
_API.handler.fileblob @path, (d) ->
|
_API.handler.fileblob @path, (d) ->
|
||||||
blob = new Blob [d], { type: "octet/stream" }
|
blob = new Blob [d], { type: "octet/stream" }
|
||||||
_API.saveblob me.basename, blob
|
_API.saveblob me.basename, blob
|
||||||
@ -152,6 +163,41 @@ self.OS.API.VFS.RemoteFileHandler = RemoteFileHandler
|
|||||||
class ApplicationHandler extends self.OS.API.VFS.BasicFileHandler
|
class ApplicationHandler extends self.OS.API.VFS.BasicFileHandler
|
||||||
constructor: (path) ->
|
constructor: (path) ->
|
||||||
super path
|
super path
|
||||||
|
@info = _OS.setting.system.packages[@basename] if @basename
|
||||||
|
@ready = true
|
||||||
|
|
||||||
|
meta: (f) ->
|
||||||
|
f()
|
||||||
|
|
||||||
|
action: (n, p, f) ->
|
||||||
|
me = @
|
||||||
|
switch n
|
||||||
|
when "read"
|
||||||
|
return f { result: @info } if @info
|
||||||
|
return unless @isRoot()
|
||||||
|
f { result: ( v for k, v of _OS.setting.system.packages ) }
|
||||||
|
|
||||||
|
when "mk"
|
||||||
|
return
|
||||||
|
|
||||||
|
when "write"
|
||||||
|
return
|
||||||
|
|
||||||
|
when "upload"
|
||||||
|
# install
|
||||||
|
return
|
||||||
|
|
||||||
|
when "remove"
|
||||||
|
#uninstall
|
||||||
|
return
|
||||||
|
|
||||||
|
when "download"
|
||||||
|
return
|
||||||
|
|
||||||
|
when "move"
|
||||||
|
return
|
||||||
|
else
|
||||||
|
return _courrier.osfail "VFS unknown action: #{n}", (_API.throwe "OS.VFS"), n
|
||||||
|
|
||||||
self.OS.API.VFS.ApplicationHandler = ApplicationHandler
|
self.OS.API.VFS.ApplicationHandler = ApplicationHandler
|
||||||
|
|
||||||
|
@ -32,6 +32,7 @@ class PushNotification extends this.OS.GUI.BaseService
|
|||||||
@subscribe "fail", (o) -> me.pushout 'FAIL', o
|
@subscribe "fail", (o) -> me.pushout 'FAIL', o
|
||||||
@subscribe "error", (o) -> me.pushout 'ERROR', o
|
@subscribe "error", (o) -> me.pushout 'ERROR', o
|
||||||
@subscribe "info", (o) -> me.pushout 'INFO', o
|
@subscribe "info", (o) -> me.pushout 'INFO', o
|
||||||
|
@subscribe "VFS", (o) -> me.pushout 'INFO', o
|
||||||
|
|
||||||
@subscribe "loading", (o) ->
|
@subscribe "loading", (o) ->
|
||||||
me.pending.push o.id
|
me.pending.push o.id
|
||||||
|
@ -19,7 +19,6 @@ class Files extends this.OS.GUI.BaseApplication
|
|||||||
@view.set "onfileopen", (e) ->
|
@view.set "onfileopen", (e) ->
|
||||||
return unless e
|
return unless e
|
||||||
return if e.type is "dir"
|
return if e.type is "dir"
|
||||||
#console.log e
|
|
||||||
me._gui.openWith e
|
me._gui.openWith e
|
||||||
|
|
||||||
@favo.set "onlistselect", (e) ->
|
@favo.set "onlistselect", (e) ->
|
||||||
@ -52,6 +51,8 @@ class Files extends this.OS.GUI.BaseApplication
|
|||||||
@favo.set "items", mntpoints
|
@favo.set "items", mntpoints
|
||||||
#@favo.set "selected", -1
|
#@favo.set "selected", -1
|
||||||
@applySetting()
|
@applySetting()
|
||||||
|
@subscribe "VFS", (d) ->
|
||||||
|
me.chdir null if d.data.file.hash() is me.currdir.hash() or d.data.file.parent().hash() is me.currdir.hash()
|
||||||
@chdir null
|
@chdir null
|
||||||
|
|
||||||
applySetting: (k) ->
|
applySetting: (k) ->
|
||||||
@ -86,7 +87,7 @@ class Files extends this.OS.GUI.BaseApplication
|
|||||||
child: [
|
child: [
|
||||||
{ text: "New file", dataid: "#{@name}-mkf" },
|
{ text: "New file", dataid: "#{@name}-mkf" },
|
||||||
{ text: "New folder", dataid: "#{@name}-mkdir" },
|
{ text: "New folder", dataid: "#{@name}-mkdir" },
|
||||||
{ text: "Open with", dataid: "#{@name}-open" },
|
{ text: "Open", dataid: "#{@name}-open" },
|
||||||
{ text: "Upload", dataid: "#{@name}-upload" },
|
{ text: "Upload", dataid: "#{@name}-upload" },
|
||||||
{ text: "Download", dataid: "#{@name}-download" },
|
{ text: "Download", dataid: "#{@name}-download" },
|
||||||
{ text: "Properties", dataid: "#{@name}-info" }
|
{ text: "Properties", dataid: "#{@name}-info" }
|
||||||
@ -165,7 +166,7 @@ class Files extends this.OS.GUI.BaseApplication
|
|||||||
return if d is file.filename
|
return if d is file.filename
|
||||||
file.path.asFileHandler()
|
file.path.asFileHandler()
|
||||||
.move "#{me.currdir.path}/#{d}", (r) ->
|
.move "#{me.currdir.path}/#{d}", (r) ->
|
||||||
if r.result then me.chdir null else me.error "Fail to rename to #{d}: #{r.error}"
|
me.error "Fail to rename to #{d}: #{r.error}" if r.error
|
||||||
, "Rename", file.filename
|
, "Rename", file.filename
|
||||||
|
|
||||||
when "#{@name}-rm"
|
when "#{@name}-rm"
|
||||||
@ -175,7 +176,7 @@ class Files extends this.OS.GUI.BaseApplication
|
|||||||
return unless d
|
return unless d
|
||||||
file.path.asFileHandler()
|
file.path.asFileHandler()
|
||||||
.remove (r) ->
|
.remove (r) ->
|
||||||
if r.result then me.chdir null else me.error "Fail to delete #{file.filename}: #{r.error}"
|
me.error "Fail to delete #{file.filename}: #{r.error}" if r.error
|
||||||
, "Delete" ,
|
, "Delete" ,
|
||||||
{ iconclass: "fa fa-question-circle", text: "Do you really want to delete: #{file.filename} ?" }
|
{ iconclass: "fa fa-question-circle", text: "Do you really want to delete: #{file.filename} ?" }
|
||||||
|
|
||||||
@ -200,7 +201,7 @@ class Files extends this.OS.GUI.BaseApplication
|
|||||||
@clipboard.file # duplicate file check
|
@clipboard.file # duplicate file check
|
||||||
.move "#{me.currdir.path}/#{@clipboard.file.basename}", (r) ->
|
.move "#{me.currdir.path}/#{@clipboard.file.basename}", (r) ->
|
||||||
me.clipboard = undefined
|
me.clipboard = undefined
|
||||||
if r.result then me.chdir null else me.error "Fail to paste: #{r.error}"
|
me.error "Fail to paste: #{r.error}" if r.error
|
||||||
else
|
else
|
||||||
@notify "Copy not yet implemented"
|
@notify "Copy not yet implemented"
|
||||||
@clipboard = undefined
|
@clipboard = undefined
|
||||||
@ -216,7 +217,7 @@ class Files extends this.OS.GUI.BaseApplication
|
|||||||
@openDialog "PromptDialog",
|
@openDialog "PromptDialog",
|
||||||
(d) ->
|
(d) ->
|
||||||
me.currdir.mk d, (r) ->
|
me.currdir.mk d, (r) ->
|
||||||
if r.result then me.chdir null else me.error "Fail to create #{d}: #{r.error}"
|
me.error "Fail to create #{d}: #{r.error}" if r.error
|
||||||
, "New folder"
|
, "New folder"
|
||||||
|
|
||||||
when "#{@name}-mkf"
|
when "#{@name}-mkf"
|
||||||
@ -224,7 +225,7 @@ class Files extends this.OS.GUI.BaseApplication
|
|||||||
(d) ->
|
(d) ->
|
||||||
fp = "#{me.currdir.path}/#{d}".asFileHandler()
|
fp = "#{me.currdir.path}/#{d}".asFileHandler()
|
||||||
fp.write "", (r) ->
|
fp.write "", (r) ->
|
||||||
if r.result then me.chdir null else me.error "Fail to create #{d}: #{r.error}"
|
me.error "Fail to create #{d}: #{r.error}" if r.error
|
||||||
, "New file"
|
, "New file"
|
||||||
|
|
||||||
when "#{@name}-info"
|
when "#{@name}-info"
|
||||||
@ -234,11 +235,14 @@ class Files extends this.OS.GUI.BaseApplication
|
|||||||
when "#{@name}-upload"
|
when "#{@name}-upload"
|
||||||
me = @
|
me = @
|
||||||
@currdir.upload (r) ->
|
@currdir.upload (r) ->
|
||||||
if r.result then me.chdir null else me.error "Faile to upload to: #{d}: #{r.error}"
|
me.error "Faile to upload to: #{d}: #{r.error}" if r.error
|
||||||
|
|
||||||
when "#{@name}-download"
|
when "#{@name}-download"
|
||||||
return unless file
|
return unless file
|
||||||
file.path.asFileHandler().download ()->
|
file.path.asFileHandler().download ()->
|
||||||
|
when "#{@name}-open"
|
||||||
|
return unless file
|
||||||
|
@_gui.openWith file
|
||||||
else
|
else
|
||||||
console.log e
|
console.log e
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@ class MarkOn extends this.OS.GUI.BaseApplication
|
|||||||
markarea = @find "markarea"
|
markarea = @find "markarea"
|
||||||
@container = @find "mycontainer"
|
@container = @find "mycontainer"
|
||||||
@previewOn = false
|
@previewOn = false
|
||||||
|
@currfile = if @args and @args.length > 0 then @args[0].asFileHandler() else "Untitled".asFileHandler()
|
||||||
@editor = new SimpleMDE
|
@editor = new SimpleMDE
|
||||||
element: markarea
|
element: markarea
|
||||||
autofocus: true
|
autofocus: true
|
||||||
@ -35,11 +36,13 @@ class MarkOn extends this.OS.GUI.BaseApplication
|
|||||||
#}
|
#}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
@editor.codemirror.on "change", () ->
|
@editor.codemirror.on "change", () ->
|
||||||
console.log "thing changed"
|
console.log "thing changed"
|
||||||
@on "vboxchange", (e) -> me.resizeContent()
|
@on "vboxchange", (e) -> me.resizeContent()
|
||||||
@resizeContent()
|
@resizeContent()
|
||||||
|
@open @currfile
|
||||||
|
|
||||||
resizeContent: () ->
|
resizeContent: () ->
|
||||||
children = ($ @container).children()
|
children = ($ @container).children()
|
||||||
titlebar = (($ @scheme).find ".afx-window-top")[0]
|
titlebar = (($ @scheme).find ".afx-window-top")[0]
|
||||||
@ -47,5 +50,51 @@ class MarkOn extends this.OS.GUI.BaseApplication
|
|||||||
statusbar = children[4]
|
statusbar = children[4]
|
||||||
cheight = ($ @scheme).height() - ($ titlebar).height() - ($ toolbar).height() - ($ statusbar).height() - 40
|
cheight = ($ @scheme).height() - ($ titlebar).height() - ($ toolbar).height() - ($ statusbar).height() - 40
|
||||||
($ children[2]).css("height", cheight + "px")
|
($ children[2]).css("height", cheight + "px")
|
||||||
#($ children[2]).css("height", )
|
|
||||||
|
open: (file) ->
|
||||||
|
#find table
|
||||||
|
me = @
|
||||||
|
file.read (d) ->
|
||||||
|
me.editor.value d
|
||||||
|
|
||||||
|
|
||||||
|
save: (file) ->
|
||||||
|
me = @
|
||||||
|
file.write (file.getb64 "text/plain"), (d) ->
|
||||||
|
return me.error "Error saving file #{file.basename}" if d.error
|
||||||
|
file.dirty = false
|
||||||
|
file.text = file.basename
|
||||||
|
|
||||||
|
menu: () ->
|
||||||
|
me = @
|
||||||
|
menu = [{
|
||||||
|
text: "File",
|
||||||
|
child: [
|
||||||
|
{ text: "Open", dataid: "#{@name}-Open" },
|
||||||
|
{ text: "Save", dataid: "#{@name}-Save" },
|
||||||
|
{ text: "Save as", dataid: "#{@name}-Saveas" }
|
||||||
|
],
|
||||||
|
onmenuselect: (e) -> me.actionFile e
|
||||||
|
}]
|
||||||
|
menu
|
||||||
|
|
||||||
|
actionFile: (e) ->
|
||||||
|
me = @
|
||||||
|
saveas = () ->
|
||||||
|
me.openDialog "FileDiaLog", (d, n) ->
|
||||||
|
me.currfile.setPath "#{d}/#{n}"
|
||||||
|
me.save me.currfile
|
||||||
|
, "Save as", { file: me.currfile }
|
||||||
|
switch e.item.data.dataid
|
||||||
|
when "#{@name}-Open"
|
||||||
|
@openDialog "FileDiaLog", ( d, f ) ->
|
||||||
|
me.open "#{d}/#{f}".asFileHandler()
|
||||||
|
, "Open file"
|
||||||
|
when "#{@name}-Save"
|
||||||
|
@currfile.cache = @editor.value()
|
||||||
|
return @save @currfile if @currfile.basename
|
||||||
|
saveas()
|
||||||
|
when "#{@name}-Saveas"
|
||||||
|
@currfile.cache = @editor.value()
|
||||||
|
saveas()
|
||||||
this.OS.register "MarkOn", MarkOn
|
this.OS.register "MarkOn", MarkOn
|
@ -9,5 +9,5 @@
|
|||||||
"version":"0.1a",
|
"version":"0.1a",
|
||||||
"category":"System",
|
"category":"System",
|
||||||
"iconclass":"fa fa-pencil-square-o",
|
"iconclass":"fa fa-pencil-square-o",
|
||||||
"mimes":[".*"]
|
"mimes":["text/.*"]
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user