fix File bug

This commit is contained in:
Xuan Sang LE 2018-03-12 22:47:23 +01:00
parent d2677eb380
commit 56cf8ea770
3 changed files with 40 additions and 11 deletions

View File

@ -310,4 +310,33 @@ self.OS.API =
catch e
err = e
return "" if not err
return err
return err
# utilities functioncs
switcher: () ->
o = {}
p = {}
p[arguments[i]] = false for i in [0..arguments.length - 1 ]
Object.defineProperty o, "__p", {
enumerable: false,
value: p
}
fn = (o, v) ->
Object.defineProperty o, v, {
enumerable: true,
set: (value) ->
for k,l of @__p
@__p[k] = false
o.__p[v] = value
, get: () ->
return o.__p[v]
}
for k, v of o.__p
fn o, k
Object.defineProperty o, "selected", {
configurable: true,
enumerable: false,
get: () ->
for k,v of o.__p
return k if v
}
return o

View File

@ -32,11 +32,10 @@
self.update()
}
/*this.on("mount", function(){
self.root.observable = (self.parent && self.parent.root && self.parent.root.observable) || opts.observable || riot.observable()
})*/
this.on("update", function(e){
self.swon = opts.swon
self.onchange = opts.onchange
self.swon = typeof opts.swon == "function"?opts.swon():opts.swon
})
toggle(e)
{

View File

@ -11,7 +11,8 @@ class Files extends this.OS.GUI.BaseApplication
@currdir = if @args and @args.length > 0 then @args[0].asFileHandler() else "home://".asFileHandler()
@favo = @find "favouri"
@clipboard = undefined
@viewType = @_api.switcher "icon", "list", "tree"
@viewType.list = true
@apps = []
@view.contextmenuHandler = (e, m) ->
@ -79,10 +80,10 @@ class Files extends this.OS.GUI.BaseApplication
(@find "btgrid").set "onbtclick", (e) ->
me.view.set 'view', "icon"
me.setting.view = "icon"
me.viewType.icon = true
(@find "btlist").set "onbtclick", (e) ->
me.view.set 'view', "list"
me.setting.view = "list"
me.viewType.list = true
@chdir null
applySetting: (k) ->
@ -153,12 +154,12 @@ class Files extends this.OS.GUI.BaseApplication
{ text: "__(Navigation bar)", switch: true, checked: @setting.nav, dataid: "#{@name}-nav" },
{ text: "__(Hidden files)", switch: true, checked: @setting.showhidden, dataid: "#{@name}-hidden" },
{ text: "__(Type)", child: [
{ text: "__(Icon view)", radio: true, checked: @setting.view is 'icon', dataid: "#{@name}-icon", type: 'icon' },
{ text: "__(List view)", radio:true, checked: @setting.view is 'list' or not @setting.view, dataid: "#{@name}-list", type: 'list' },
{ text: "__(Tree view)", radio:true, checked: @setting.view is 'tree', dataid: "#{@name}-tree", type: 'tree' }
{ text: "__(Icon view)", radio: true, checked: (() -> me.viewType.icon), dataid: "#{@name}-icon", type: 'icon' },
{ text: "__(List view)", radio:true, checked: (() -> me.viewType.list), dataid: "#{@name}-list", type: 'list' },
{ text: "__(Tree view)", radio:true, checked: (() -> me.viewType.tree), dataid: "#{@name}-tree", type: 'tree' }
], onmenuselect: (e) ->
me.view.set 'view', e.item.data.type
me.setting.view = e.item.data.type
me.viewType[e.item.data.type] = true
},
], onmenuselect: (e) -> me.actionView e
},