fix minor error

This commit is contained in:
Xuan Sang LE 2018-01-30 19:06:30 +01:00
parent 02422319ca
commit de387ece25
23 changed files with 190 additions and 95 deletions

View File

@ -46,11 +46,11 @@ class BasicDialog extends BaseDialog
init: () ->
@title = @name if not @title
html = "<afx-app-window data-id = 'dia-window' apptitle='#{@title}' width='#{@conf.width}' height='#{@conf.height}'>
<afx-hbox>"
<afx-vbox>"
html += "<#{@conf.tag} #{@conf.att} data-id = 'content'></#{@conf.tag}>"
html += "<div data-height = '40' style=' text-align:right;padding-top:3px;'>"
html += "<afx-button data-id = 'bt#{k}' text = '#{v.label}' style='margin-right:5px;'></afx-button>" for k,v of @conf.buttons
html += "</div></afx-hbox></afx-app-window>"
html += "</div></afx-vbox></afx-app-window>"
#render the html
_GUI.htmlToScheme html, @, @host
@ -62,6 +62,7 @@ class BasicDialog extends BaseDialog
# bind action to button
( (me.find "bt#{k}").set "onbtclick", f(v) ) for k, v of @conf.buttons
@conf.filldata @ if @conf.filldata
@conf.xtra @ if @conf.xtra
this.OS.GUI.BasicDialog = BasicDialog
@ -90,6 +91,9 @@ class PromptDialog extends BasicDialog
filldata: (d) ->
return unless d.data
(d.find "content").value = d.data
xtra: (d) ->
$( d.find "content" ).keyup (e) ->
(d.find "bt0").trigger() if e.which is 13
}
this.OS.register "PromptDialog", PromptDialog
@ -157,7 +161,7 @@ class InfoDialog extends BasicDialog
filldata: (d) ->
return unless d.data
rows = []
rows.push [ { value: k }, { value: v } ] for k, v of d.data
rows.push [ { value: k }, { value: v } ] for v, k in d.data
(d.find "content").set "rows", rows
}
this.OS.register "InfoDialog", InfoDialog
@ -213,6 +217,10 @@ class SelectionDialog extends BasicDialog
filldata: (d) ->
return unless d.data
(d.find "content").set "items", d.data
xtra: (d) ->
( d.find "content" ).set "onlistdbclick", (e) ->
(d.find "bt0").trigger()
}
this.OS.register "SelectionDialog", SelectionDialog

View File

@ -77,10 +77,16 @@ self.OS.GUI =
( f m, i if m ) for m, i in mimes
return apps
appsWithServices: () ->
o = {}
o[k] = v for k, v of _OS.setting.system.packages when v.services and v.services.length > 0
o
openWith: (it) ->
return unless it
return _GUI.launch it.app if it.type is "app" and it.app
return _courrier.osinfo "Application#{it.text} is not executable" if it.type is "app"
apps = _GUI.appsByMime ( if it.type is "dir" then "dir" else it.mime )
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
@ -169,6 +175,7 @@ self.OS.GUI =
handler p if p isnt ($ "#workspace").get(0)
handler event.target
event.preventDefault()
initDM: ->
# check login first
_API.resource "schemes/dm.html", (x) ->
@ -236,7 +243,25 @@ self.OS.GUI =
desktop[0].contextmenuHandler = (e, m) ->
desktop[0].set "selected", -1 if e.target is desktop[0]
($ "#sysdock").get(0).set "selectedApp", null
console.log "context menu handler for desktop"
menu = [
{ text: "Open", dataid: "desktop-open" },
{ text: "Refresh", dataid: "desktop-refresh" }
]
menu = menu.concat _OS.setting.desktop.menu
m.set "items", menu
m.set "onmenuselect", (evt) ->
switch evt.item.data.dataid
when "desktop-open"
it = desktop[0].get "selected"
return _GUI.openWith it if it
it = _OS.setting.desktop.path.asFileHandler()
it.mime = "dir"
_GUI.openWith it
when "desktop-refresh"
desktop[0].fetch()
else
_GUI.launch evt.item.data.app if evt.item.data.app
m.show(e)
desktop[0].fetch()
_courrier.observable.on "VFS", (d) ->
@ -303,12 +328,14 @@ self.OS.GUI =
_OS.setting.appearance = conf.appearance if conf.appearance
_OS.setting.user = conf.user
_OS.setting.VFS = conf.VFS if conf.VFS
_OS.setting.desktop.path = "home:///.desktop" unless _OS.setting.desktop.path
_OS.setting.desktop.menu = [] unless _OS.setting.desktop.menu
_OS.setting.VFS.mountpoints = [
#TODO: multi app try to write to this object, it neet to be cloned
{ text: "Applications", path: 'app:///', iconclass: "fa fa-adn", type: "app" },
{ text: "Home", path: 'home:///', iconclass: "fa fa-home", type: "fs" },
{ text: "OS", path: 'os:///', iconclass: "fa fa-inbox", type: "fs" },
{ text: "Desktop", path: 'home:///.desktop', iconclass: "fa fa-desktop", type: "fs" },
{ text: "Desktop", path: _OS.setting.desktop.path , iconclass: "fa fa-desktop", type: "fs" },
] if not _OS.setting.VFS.mountpoints
_OS.setting.system = conf.system if conf.system
@ -317,7 +344,7 @@ self.OS.GUI =
"os:///packages"
] unless _OS.setting.system.pkgpaths
_OS.setting.system.menu = [] unless _OS.setting.system.menu
_OS.setting.desktop.path = "home:///.desktop" unless _OS.setting.desktop.path
_OS.setting.appearance.theme = "antos" unless _OS.setting.appearance.theme
# load theme
_GUI.loadTheme _OS.setting.appearance.theme

View File

@ -1,5 +1,5 @@
<afx-app-window data-id = 'about-window' width='300' height='200'>
<afx-hbox>
<afx-vbox>
<div style="text-align:center; margin-top:10px;" data-height="50">
<h3 style = "margin:0;padding:0;">
<afx-label data-id = 'mylabel'></afx-label>
@ -7,5 +7,5 @@
<i><p style = "margin:0; padding:0" data-id = 'mydesc'></p></i>
</div>
<afx-grid-view data-id = 'mygrid'></afx-grid-view>
</afx-hbox>
</afx-vbox>
</afx-app-window>

View File

@ -1,13 +1,13 @@
<afx-app-window data-id = 'file-dialog-window' width='400' height='300'>
<afx-vbox>
<afx-hbox>
<afx-list-view data-id = "location" dropdown = "false" data-width = "120"></afx-list-view>
<afx-hbox>
<afx-vbox>
<afx-file-view data-id = "fileview" view='tree' status = false></afx-file-view>
<input data-height = '26' type = "text" data-id = "filename" style="margin-left:5px; margin-right:5px;display:none;" />
<div data-height = '30' style=' text-align:right;padding-top:3px;'>
<afx-button data-id = "bt-ok" text = "Ok"></afx-button>
<afx-button data-id = "bt-cancel" text = "Cancel"></afx-button>
</div>
</afx-hbox>
</afx-vbox>
</afx-vbox>
</afx-hbox>
</afx-app-window>

View File

@ -1,5 +1,5 @@
<afx-button>
<button disabled={ enable == "false" } onclick="{ _onbtclick }" >
<button disabled={ enable == "false" } onclick="{ _onbtclick }" ref = "mybtn" >
<afx-label color = {color} icon={icon} iconclass = {iconclass} text = {text} ></afx-label>
</button>
<script>
@ -19,6 +19,10 @@
self[k] = v
self.update()
}
self.root.trigger = function()
{
$(self.refs.mybtn).trigger("click")
}
self.root.get = function(k)
{
return self[k]

View File

@ -169,7 +169,14 @@
}
self.refs.treeview.ontreeselect = function(d)
{
if(!d.data) return;
if(!d) return;
if(!d.data)// select the root
{
var r = self.path.asFileHandler()
r.size = 0
r.filename = r.path
d.data = { child: r , i:0 }
}
var data = {id:self.rid, data:d.data.child, idx:d.data.i}
self.root.observable.trigger("fileselect",data)
}

View File

@ -21,7 +21,10 @@
{
if(self.selidx != -1)
self.items[self.selidx].selected =false
if(self.items[v]) self.items[v].selected = true
if(v == -1)
self.selidx = -1
else
if(self.items[v]) self.items[v].selected = true
}
else if(k == "*")
for(var i in v)

View File

@ -1,5 +1,5 @@
<afx-hbox style = "display:block;">
<div ref = "container" class="afx-hbox-container">
<div ref = "container" class="afx-vbox-container">
<yield/>
</div>
<script>
@ -7,27 +7,24 @@
this.on('mount', function(){
$(self.refs.container)
.css("display","flex")
.css("flex-direction","column")
.css("flex-direction","row")
.css("width","100%")
//.css("background-color","red")
//.css("overflow", "hidden")
calibrate_size()
calibrate_size()
if(self.root.observable)
{
self.root.observable.on("resize", function(w,h){
calibrate_size()
})
}
if(self.root.observable)
{
self.root.observable.on("resize", function(w,h){
calibrate_size()
})
}
})
var calibrate_size = function()
{
var auto_height = []
var csize, ocheight = 0, avaiheight;
var auto_width = []
var csize, ocwidth = 0, avaiheight;
avaiheight = $(self.root).height()
avaiwidth = $(self.root).width()
avaiWidth = $(self.root).width()
$(self.refs.container).css("height",avaiheight + "px")
$(self.refs.container)
.children()
@ -36,25 +33,25 @@
this.observable = self.root.observable
$(this)
.css("flex-grow","1")
//.css("border","1px solid black")
var dw = $(this).attr("data-height")
//.css("height",avaiheight + "px")
var dw = $(this).attr("data-width")
if(dw)
{
$(this).css("height",dw + "px")
ocheight += Number(dw)
$(this).css("width",dw + "px")
ocwidth += Number(dw)
}
else
{
auto_height.push(this)
auto_width.push(this)
}
})
csize = (avaiheight - ocheight)/ (auto_height.length)
$.each(auto_height, function(i,v)
csize = (avaiWidth - ocwidth)/ (auto_width.length)
$.each(auto_width, function(i,v)
{
$(v).css("height", csize + "px")
$(v).css("width", csize + "px")
})
self.root.observable.trigger("hboxchange",
{id:$(self.root).attr("data-id"), w:avaiwidth, h:csize})
self.root.observable.trigger("vboxchange",
{id:$(self.root).attr("data-id"), w:csize, h:avaiheight})
}
</script>
</afx-hbox>

View File

@ -24,7 +24,10 @@
{
if(self.selidx != -1)
self.items[self.selidx].selected =false
if(self.items[v]) self.items[v].selected = true
if(v == -1)
self.selidx = -1
else
if(self.items[v]) self.items[v].selected = true
}
else if(k == "*")
for(var i in v)

View File

@ -7,7 +7,7 @@
<afx-label color = {data.color} iconclass = {data.iconclass} icon = {data.icon} text = {data.text} ></afx-label>
</a>
<afx-menu if={data.child != null} child={data.child} onmenuselect = {data.onmenuselect} observable = {parent.root.observable} rootid = {parent.rid}></afx-menu>
<afx-menu if={data.child != null} child={data.child.constructor === Array?data.child:data.child()} onmenuselect = {data.onmenuselect} observable = {parent.root.observable} rootid = {parent.rid}></afx-menu>
</li>
<li class="afx-corner-fix"></li>
</ul>

View File

@ -1,5 +1,5 @@
<afx-vbox style = "display:block;">
<div ref = "container" class="afx-vbox-container">
<div ref = "container" class="afx-hbox-container">
<yield/>
</div>
<script>
@ -7,24 +7,27 @@
this.on('mount', function(){
$(self.refs.container)
.css("display","flex")
.css("flex-direction","row")
.css("flex-direction","column")
.css("width","100%")
//.css("background-color","red")
//.css("overflow", "hidden")
calibrate_size()
calibrate_size()
if(self.root.observable)
{
self.root.observable.on("resize", function(w,h){
calibrate_size()
})
}
if(self.root.observable)
{
self.root.observable.on("resize", function(w,h){
calibrate_size()
})
}
})
var calibrate_size = function()
{
var auto_width = []
var csize, ocwidth = 0, avaiheight;
var auto_height = []
var csize, ocheight = 0, avaiheight;
avaiheight = $(self.root).height()
avaiWidth = $(self.root).width()
avaiwidth = $(self.root).width()
$(self.refs.container).css("height",avaiheight + "px")
$(self.refs.container)
.children()
@ -33,25 +36,25 @@
this.observable = self.root.observable
$(this)
.css("flex-grow","1")
//.css("height",avaiheight + "px")
var dw = $(this).attr("data-width")
//.css("border","1px solid black")
var dw = $(this).attr("data-height")
if(dw)
{
$(this).css("width",dw + "px")
ocwidth += Number(dw)
$(this).css("height",dw + "px")
ocheight += Number(dw)
}
else
{
auto_width.push(this)
auto_height.push(this)
}
})
csize = (avaiWidth - ocwidth)/ (auto_width.length)
$.each(auto_width, function(i,v)
csize = (avaiheight - ocheight)/ (auto_height.length)
$.each(auto_height, function(i,v)
{
$(v).css("width", csize + "px")
$(v).css("height", csize + "px")
})
self.root.observable.trigger("vboxchange",
{id:$(self.root).attr("data-id"), w:csize, h:avaiheight})
self.root.observable.trigger("hboxchange",
{id:$(self.root).attr("data-id"), w:avaiwidth, h:csize})
}
</script>
</afx-vbox>

View File

@ -1,6 +1,6 @@
<afx-app-window data-id = "am-window" apptitle="" width="400" height="300">
<afx-hbox>
<afx-vbox>
<afx-grid-view data-id = "mygrid"></afx-grid-view>
<afx-button data-height="30" data-id = "btkill" text = "Kill process" iconclass="fa fa-times"></afx-button>
</afx-hbox>
</afx-vbox>
</afx-app-window>

View File

@ -1,5 +1,6 @@
{
"app":null,
"services": [ "Calendar", "PushNotification", "Spotlight" ]
"name":"CoreServices",
"description":"This is the core services",
"info":{

View File

@ -11,5 +11,5 @@
"version":"0.1a",
"category":"System",
"iconclass":"fa fa-user-circle-o",
"mimes":[".*"]
"mimes":["none"]
}

View File

@ -1,13 +1,15 @@
<afx-app-window apptitle="Preview" width="650" height="500">
<afx-vbox>
<afx-tab-container data-id="mytabs" closable = true></afx-tab-container>
<afx-tree-view data-id="mytree"> </afx-tree-view>
<afx-hbox>
<afx-hbox>
<afx-vbox>
<afx-tab-container data-height = "50" data-id="mytabs" closable = true></afx-tab-container>
<afx-tree-view data-id="mytree"> </afx-tree-view>
</afx-vbox>
<afx-vbox>
<afx-button data-height="30" text="Read more" iconclass="fa fa-camera-retro fa-lg" id="button"></afx-button>
<afx-switch enable= true data-height="30"></afx-switch>
<afx-calendar-view></afx-calendar-view>
<afx-color-picker></afx-color-picker>
<afx-list-view data-id = "mylist" dropdown = "true" width="200" data-height = "40"></afx-list-view>
</afx-hbox>
</afx-vbox>
</afx-vbox>
</afx-hbox>
</afx-app-window>

View File

@ -81,13 +81,20 @@ class Files extends this.OS.GUI.BaseApplication
me.view.set "data", d.result
mnFile:() ->
#console.log file
me = @
f = () ->
console.log "called"
file = me.view.get "selectedFile"
return undefined unless file
return me._gui.appsByMime file.mime
{
text: "File",
child: [
{ text: "New file", dataid: "#{@name}-mkf" },
{ text: "New folder", dataid: "#{@name}-mkdir" },
{ text: "Open", dataid: "#{@name}-open" },
{ text: "Open with", dataid: "#{@name}-open", child: f },
{ text: "Upload", dataid: "#{@name}-upload" },
{ text: "Download", dataid: "#{@name}-download" },
{ text: "Properties", dataid: "#{@name}-info" }

View File

@ -1,14 +1,14 @@
<afx-app-window data-id = "files-app-window" apptitle="Files" width="600" height="400">
<afx-hbox>
<afx-vbox data-height = "30" data-id = "nav-bar">
<afx-vbox>
<afx-hbox data-height = "30" data-id = "nav-bar">
<afx-button data-width = "30" data-id = "btback" iconclass = "fa fa-arrow-left"></afx-button>
<input type = "text" data-id = "navinput"></input>
<div data-width = "5"></div>
</afx-vbox>
<afx-vbox>
</afx-hbox>
<afx-hbox>
<afx-list-view data-id = "favouri" data-width = "150">
</afx-list-view>
<afx-file-view data-id = "fileview"></afx-file-view>
</afx-vbox>
</afx-hbox>
</afx-hbox>
</afx-vbox>
</afx-app-window>

View File

@ -8,6 +8,7 @@ class MarkOn extends this.OS.GUI.BaseApplication
@container = @find "mycontainer"
@previewOn = false
@currfile = if @args and @args.length > 0 then @args[0].asFileHandler() else "Untitled".asFileHandler()
@editormux = false
@editor = new SimpleMDE
element: markarea
autofocus: true
@ -38,7 +39,10 @@ class MarkOn extends this.OS.GUI.BaseApplication
]
@editor.codemirror.on "change", () ->
console.log "thing changed"
return if me.editormux
if me.currfile.dirty is false
me.currfile.dirty = true
me.scheme.set "apptitle", "#{me.currfile.basename}*"
@on "vboxchange", (e) -> me.resizeContent()
@resizeContent()
@open @currfile
@ -53,9 +57,14 @@ class MarkOn extends this.OS.GUI.BaseApplication
open: (file) ->
#find table
return if file.path is "Untitled"
me = @
file.dirty = false
file.read (d) ->
me.editormux = true
me.editor.value d
me.scheme.set "apptitle", "#{me.currfile.basename}"
me.editormux = false
save: (file) ->
@ -64,6 +73,7 @@ class MarkOn extends this.OS.GUI.BaseApplication
return me.error "Error saving file #{file.basename}" if d.error
file.dirty = false
file.text = file.basename
me.scheme.set "apptitle", "#{me.currfile.basename}"
menu: () ->
me = @
@ -97,4 +107,15 @@ class MarkOn extends this.OS.GUI.BaseApplication
when "#{@name}-Saveas"
@currfile.cache = @editor.value()
saveas()
cleanup: (evt) ->
return unless @currfile.dirty
me = @
evt.preventDefault()
@.openDialog "YesNoDialog", (d) ->
if d
me.currfile.dirty = false
me.quit()
, "Quit", { text: "Quit without saving ?" }
this.OS.register "MarkOn", MarkOn

View File

@ -1,7 +1,7 @@
<afx-app-window data-id = "markon-win" apptitle="Markon" width="600" height="450">
<afx-vbox >
<afx-hbox >
<div data-id = "mycontainer">
<textarea data-id="markarea" ></textarea>
</div>
</afx-vbox>
</afx-hbox>
</afx-app-window>

View File

@ -215,7 +215,17 @@ class NotePad extends this.OS.GUI.BaseApplication
when "#{@name}-Saveas"
@currfile.cache = @editor.getValue()
saveas()
cleanup: (evt) ->
dirties = ( v for v in @tabarea.get "items" when v.dirty )
return if dirties.length is 0
me = @
evt.preventDefault()
@.openDialog "YesNoDialog", (d) ->
if d
v.dirty = false for v in dirties
me.quit()
, "Quit", { text: "Ignore all #{dirties.length} unsaved files ?" }
NotePad.singleton = false
this.OS.register "NotePad", NotePad

View File

@ -1,18 +1,18 @@
<afx-app-window apptitle="" width="600" height="400" data-id="notepad">
<afx-vbox>
<afx-hbox data-width = "175" data-id = "sidebar">
<afx-hbox>
<afx-vbox data-width = "175" data-id = "sidebar">
<afx-list-view data-id = "location" dropdown = "true" data-height= "30" width = "150"></afx-list-view>
<afx-file-view data-id = "fileview" view='tree' status = false></afx-file-view>
</afx-hbox>
<afx-hbox>
</afx-vbox>
<afx-vbox>
<afx-tab-container data-id="tabarea" data-height="26" closable = true></afx-tab-container>
<div data-id="datarea"></div>
<afx-vbox data-height="30" data-id="bottom-vbox">
<afx-hbox data-height="30" data-id="bottom-vbox">
<div ><span data-id = "editorstat"></span></div>
<afx-list-view data-width="160" data-id = "themelist" dropdown = "true" width="135"></afx-list-view>
<afx-list-view data-width="125" data-id = "modelist" dropdown = "true" width="100"></afx-list-view>
</afx-vbox>
</afx-hbox>
</afx-vbox>
</afx-hbox>
</afx-vbox>
</afx-hbox>
</afx-app-window>

View File

@ -31,6 +31,8 @@ class wTerm extends this.OS.GUI.BaseApplication
end = if (i + 1) * 1000 > len then len else (i + 1) * 1000
me.term.write pastedText.substring i * 1000, end
#self.socket.send("i"+ substr.replace(/\n/g,"\r\n"))
# make desktop menu if not exist
@systemsetting.desktop.menu.push { text: "Open terminal", app: "wTerm" }
@openSession()
@on "vboxchange", (e) -> me.resizeContent e.w, e.h

View File

@ -1,5 +1,5 @@
<afx-app-window apptitle="Preview" width="600" height="400">
<afx-vbox data-id = "mybox">
<afx-hbox data-id = "mybox">
<div data-id="myterm" ></div>
</afx-vbox>
</afx-hbox>
</afx-app-window>