mirror of
https://github.com/lxsang/antos-frontend.git
synced 2024-12-27 17:58:22 +01:00
add tab bar
This commit is contained in:
parent
5b21696fa1
commit
8b44c3b3c0
1
Makefile
1
Makefile
@ -36,6 +36,7 @@ coffees= src/core/core.coffee \
|
|||||||
src/core/tags/NSpinnerTag.coffee \
|
src/core/tags/NSpinnerTag.coffee \
|
||||||
src/core/tags/MenuTag.coffee \
|
src/core/tags/MenuTag.coffee \
|
||||||
src/core/tags/GridView.coffee \
|
src/core/tags/GridView.coffee \
|
||||||
|
src/core/tags/TabBarTag.coffee \
|
||||||
src/antos.coffee
|
src/antos.coffee
|
||||||
|
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ class ListViewTag extends Ant.OS.GUI.BaseTag
|
|||||||
super r, o
|
super r, o
|
||||||
@setopt "onlistselect", () ->
|
@setopt "onlistselect", () ->
|
||||||
@setopt "onlistdbclick", () ->
|
@setopt "onlistdbclick", () ->
|
||||||
@setopt "onitemclose", () ->
|
@setopt "onitemclose", () -> true
|
||||||
@setopt "buttons", []
|
@setopt "buttons", []
|
||||||
@setopt "data", {}
|
@setopt "data", {}
|
||||||
@setopt "dropdown", false
|
@setopt "dropdown", false
|
||||||
@ -76,19 +76,29 @@ 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) -> me.push e
|
||||||
|
@root.remove = (e) -> me.remove e
|
||||||
|
@root.unshift = (e) -> me.unshift e
|
||||||
|
|
||||||
multiselect: () ->
|
multiselect: () ->
|
||||||
return false if @get "dropdown"
|
return false if @get "dropdown"
|
||||||
@get "multiselect"
|
@get "multiselect"
|
||||||
|
|
||||||
|
unshift: (item) ->
|
||||||
|
@push item, true
|
||||||
|
|
||||||
__buttons__: (v) ->
|
has_data: (v) ->
|
||||||
return if @get "dropdown"
|
@get("data").includes v
|
||||||
|
|
||||||
__data__: (data) ->
|
push: (item, flag) ->
|
||||||
$( @refs.mlist).empty()
|
el = $("<#{@get "itemtag"}>")
|
||||||
for item in data
|
if flag
|
||||||
el = $("<#{@get "itemtag"}>").appendTo @refs.mlist
|
@get("data").unshift item if not @has_data item
|
||||||
|
$(@refs.mlist).prepend el[0]
|
||||||
|
else
|
||||||
|
@get("data").push item if not @has_data item
|
||||||
|
el.appendTo @refs.mlist
|
||||||
el[0].uify @observable
|
el[0].uify @observable
|
||||||
me = @
|
me = @
|
||||||
el[0]
|
el[0]
|
||||||
@ -104,6 +114,24 @@ class ListViewTag extends Ant.OS.GUI.BaseTag
|
|||||||
.set "onclose", (e) ->
|
.set "onclose", (e) ->
|
||||||
me.iclose e
|
me.iclose e
|
||||||
|
|
||||||
|
remove: (item) ->
|
||||||
|
el = item.get "data"
|
||||||
|
data = @get "data"
|
||||||
|
@set "selectedItem", undefined if @get("selectedItem") is item
|
||||||
|
list = @get("selectedItems")
|
||||||
|
list.splice(list.indexOf(item), 1) if list.includes(item)
|
||||||
|
if data.includes el
|
||||||
|
data.splice data.indexOf(el), 1
|
||||||
|
$(item).remove()
|
||||||
|
|
||||||
|
__buttons__: (v) ->
|
||||||
|
return if @get "dropdown"
|
||||||
|
|
||||||
|
__data__: (data) ->
|
||||||
|
$( @refs.mlist).empty()
|
||||||
|
for item in data
|
||||||
|
@push item, false
|
||||||
|
|
||||||
iclick: (e) ->
|
iclick: (e) ->
|
||||||
return if not e.item
|
return if not e.item
|
||||||
list = @get("selectedItems")
|
list = @get("selectedItems")
|
||||||
@ -140,7 +168,11 @@ class ListViewTag extends Ant.OS.GUI.BaseTag
|
|||||||
|
|
||||||
iclose: (e) ->
|
iclose: (e) ->
|
||||||
return unless e.item
|
return unless e.item
|
||||||
$(e.item).remove()
|
evt = { id: @aid(), data: e }
|
||||||
|
r = @get("onitemclose") evt
|
||||||
|
return unless r
|
||||||
|
@observable.trigger "itemclose", evt
|
||||||
|
@remove(e.item)
|
||||||
|
|
||||||
__dropdown__: (v) ->
|
__dropdown__: (v) ->
|
||||||
$(@refs.container).removeAttr "style"
|
$(@refs.container).removeAttr "style"
|
||||||
|
26
src/core/tags/TabBarTag.coffee
Normal file
26
src/core/tags/TabBarTag.coffee
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
class TabBarTag extends Ant.OS.GUI.BaseTag
|
||||||
|
constructor: (r, o) ->
|
||||||
|
super r, o
|
||||||
|
@setopt "closable", false
|
||||||
|
@setopt "ontabselect", (e) ->
|
||||||
|
@setopt "items", []
|
||||||
|
|
||||||
|
__items__: (v) ->
|
||||||
|
@refs.list.set "data", v
|
||||||
|
|
||||||
|
mount: () ->
|
||||||
|
me = @
|
||||||
|
@refs.list.set "onlistselect", (e) ->
|
||||||
|
me.get("ontabselect") e
|
||||||
|
me.observable.trigger "tabselect", e
|
||||||
|
@root.push = (e) -> me.refs.list.push e
|
||||||
|
@root.unshift = (e) -> me.refs.list.unshift e
|
||||||
|
@root.remove = (e) -> me.refs.list.remove e
|
||||||
|
$(@refs.list).css "height", "100%"
|
||||||
|
|
||||||
|
layout: () ->
|
||||||
|
[{
|
||||||
|
el: "afx-list-view", ref: "list"
|
||||||
|
}]
|
||||||
|
|
||||||
|
Ant.OS.GUI.define "afx-tab-bar", TabBarTag
|
@ -38,6 +38,7 @@ class ShowCase extends this.OS.GUI.BaseApplication
|
|||||||
<afx-app-window data-id="example-show-case" apptitle="Preview" width="650" height="500">
|
<afx-app-window data-id="example-show-case" apptitle="Preview" width="650" height="500">
|
||||||
<afx-vbox>
|
<afx-vbox>
|
||||||
<afx-menu data-height="30" data-id="menu" />
|
<afx-menu data-height="30" data-id="menu" />
|
||||||
|
<afx-tab-bar data-height="30" data-id="tab" />
|
||||||
<afx-hbox>
|
<afx-hbox>
|
||||||
<afx-vbox data-width="150">
|
<afx-vbox data-width="150">
|
||||||
<div>box 2</div>
|
<div>box 2</div>
|
||||||
@ -89,6 +90,12 @@ class ShowCase extends this.OS.GUI.BaseApplication
|
|||||||
me.subwin.observable.on "menuselect", (e) ->
|
me.subwin.observable.on "menuselect", (e) ->
|
||||||
console.log e.id
|
console.log e.id
|
||||||
|
|
||||||
|
tab = $ "[data-id='tab']", scheme[0]
|
||||||
|
tab[0].set "items", [
|
||||||
|
{ text: "data.txt" },
|
||||||
|
{ text: "antos.conf", closable: true }
|
||||||
|
]
|
||||||
|
|
||||||
list = $ "[data-id='list']", scheme[0]
|
list = $ "[data-id='list']", scheme[0]
|
||||||
|
|
||||||
list[0].set "data", [
|
list[0].set "data", [
|
||||||
@ -99,9 +106,14 @@ class ShowCase extends this.OS.GUI.BaseApplication
|
|||||||
{ text: "some thing 4" },
|
{ text: "some thing 4" },
|
||||||
{ text: "some thing 5" }
|
{ text: "some thing 5" }
|
||||||
]
|
]
|
||||||
|
list[0].unshift { text: "shifted el" }
|
||||||
|
console.log "after shift", list[0].get("data")
|
||||||
list[0].set "onlistselect", (e) ->
|
list[0].set "onlistselect", (e) ->
|
||||||
console.log(e.data.items)
|
console.log(e.data.items)
|
||||||
|
me.subwin.observable.on "itemclose", (e) ->
|
||||||
|
console.log "remove", list[0].get("data")
|
||||||
|
console.log list[0].get "selectedItem"
|
||||||
|
console.log list[0].get "selectedItems"
|
||||||
|
|
||||||
sw = $ "[data-id='switch']", scheme[0]
|
sw = $ "[data-id='switch']", scheme[0]
|
||||||
sw[0].set "onchange", (e) ->
|
sw[0].set "onchange", (e) ->
|
||||||
|
@ -11,6 +11,10 @@ afx-list-view div.list-container{
|
|||||||
position: relative;
|
position: relative;
|
||||||
background-color: red;
|
background-color: red;
|
||||||
}*/
|
}*/
|
||||||
|
afx-list-view afx-list-item
|
||||||
|
{
|
||||||
|
display: contents;
|
||||||
|
}
|
||||||
afx-list-view > div.list-container{
|
afx-list-view > div.list-container{
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
}
|
}
|
||||||
@ -33,7 +37,8 @@ afx-list-view > div.list-container > ul li{
|
|||||||
-webkit-user-select:none;
|
-webkit-user-select:none;
|
||||||
cursor:default;
|
cursor:default;
|
||||||
}
|
}
|
||||||
afx-list-view > div.list-container > ul li:nth-of-type(odd){
|
afx-list-view > div.list-container > ul afx-list-item:nth-child(even) li,
|
||||||
|
afx-list-view > div.list-container > ul li:nth-child(even){
|
||||||
background-color:#f5F5F5;
|
background-color:#f5F5F5;
|
||||||
}
|
}
|
||||||
afx-list-view i.closable{
|
afx-list-view i.closable{
|
||||||
@ -58,6 +63,7 @@ afx-list-view > div.list-container > ul li > i {
|
|||||||
margin-right: 3px;
|
margin-right: 3px;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
afx-list-view > div.list-container > ul > afx-list-item > li.selected,
|
||||||
afx-list-view > div.list-container > ul li.selected {
|
afx-list-view > div.list-container > ul li.selected {
|
||||||
background-color: #116cd6;
|
background-color: #116cd6;
|
||||||
color:white;
|
color:white;
|
||||||
|
@ -7,7 +7,7 @@ afx-tab-bar afx-list-view {
|
|||||||
padding:0;
|
padding:0;
|
||||||
margin:0;
|
margin:0;
|
||||||
}
|
}
|
||||||
afx-tab-bar afx-list-view > div.list-container > ul > li{
|
afx-tab-bar afx-list-view > div.list-container > ul li{
|
||||||
float:left;
|
float:left;
|
||||||
border-top-left-radius: 5px;
|
border-top-left-radius: 5px;
|
||||||
border-top-right-radius: 5px;
|
border-top-right-radius: 5px;
|
||||||
|
Loading…
Reference in New Issue
Block a user