mirror of
https://github.com/lxsang/antos-frontend.git
synced 2024-12-26 09:28:21 +01:00
add float list
This commit is contained in:
parent
8a441e5a59
commit
c46049fd0c
1
Makefile
1
Makefile
@ -40,6 +40,7 @@ coffees= src/core/core.coffee \
|
||||
src/core/tags/TabContainer.coffee \
|
||||
src/core/tags/TreeViewTag.coffee \
|
||||
src/core/tags/SliderTag.coffee \
|
||||
src/core/tags/FloatListTag.coffee \
|
||||
src/antos.coffee
|
||||
|
||||
|
||||
|
14
src/core/tags/CalendarTag.coffee
Normal file
14
src/core/tags/CalendarTag.coffee
Normal file
@ -0,0 +1,14 @@
|
||||
class CalendarTag extends Ant.OS.GUI.BaseTag
|
||||
constructor: (r, o) ->
|
||||
super r, o
|
||||
|
||||
layout: () ->
|
||||
[{
|
||||
el: "div", children: [
|
||||
{ el: "i", class: "prevmonth", ref: "prev" },
|
||||
{ el: "afx-label", ref: "mlbl" },
|
||||
{ el: "afx-label", ref: "ylbl" },
|
||||
{ el: "i", class: "nextmonth", ref: "next" },
|
||||
{ el: "afx-grid-view", ref: "grid" }
|
||||
]
|
||||
}]
|
@ -2,24 +2,87 @@ class FloatListTag extends ListViewTag
|
||||
constructor: (r, o) ->
|
||||
super r, o
|
||||
me = @
|
||||
@root.refresh = () ->
|
||||
me.refresh()
|
||||
|
||||
@setopt "dir", "horizontal"
|
||||
@root.refresh = () -> me.refresh()
|
||||
@root.push = (e) -> me.refs.mlist.push(e)
|
||||
@root.unshift = (e) -> me.refs.mlist.unshift(e)
|
||||
@root.remove = (e) -> me.refs.mlist.remove(e)
|
||||
|
||||
# disable some uneccessary functions
|
||||
__dropdown__: (v) ->
|
||||
@set "dropdown", false if v
|
||||
__dropdown__: (v) -> @set "dropdown", false if v
|
||||
__buttons__: (v) ->
|
||||
showlist: (e) ->
|
||||
dropoff: (e) ->
|
||||
calibrate: (e) ->
|
||||
__data__: (v) ->
|
||||
super.__data__(v)
|
||||
@refresh()
|
||||
__dir__: (v) ->
|
||||
@refresh()
|
||||
calibrate: (e) -> @refresh()
|
||||
mount: () ->
|
||||
@refresh()
|
||||
$(@refs.container)
|
||||
.css "width", "100%"
|
||||
.css "height", "100%"
|
||||
$(@refs.mlist)
|
||||
.css "position", "absolute"
|
||||
.css "display", "block"
|
||||
.css "width", "100%"
|
||||
|
||||
push: (v) ->
|
||||
el = super.push(v)
|
||||
@enable_drag el
|
||||
el
|
||||
|
||||
enable_drag: (el) ->
|
||||
globalof = $(@refs.mlist).offset()
|
||||
$(el)
|
||||
.css "user-select", "none"
|
||||
.css "cursor", "default"
|
||||
.css "display", "block"
|
||||
.css "position", "absolute"
|
||||
.on "mousedown", (evt) ->
|
||||
evt.preventDefault()
|
||||
offset = $(el).offset()
|
||||
offset.top = evt.clientY - offset.top
|
||||
offset.left = evt.clientX - offset.left
|
||||
mouse_move = (e) ->
|
||||
top = e.clientY - offset.top - globalof.top
|
||||
left = e.clientX - globalof.top - offset.left
|
||||
left = if left < 0 then 0 else left
|
||||
top = if top < 0 then 0 else top
|
||||
$(el)
|
||||
.css "top", "#{top}px"
|
||||
.css "left", "#{left}px"
|
||||
|
||||
mouse_up = (e) ->
|
||||
$(window).unbind "mousemove", mouse_move
|
||||
$(window).unbind "mouseup", mouse_up
|
||||
$(window).on "mousemove", mouse_move
|
||||
$(window).on "mouseup", mouse_up
|
||||
|
||||
refresh: () ->
|
||||
ctop = 20
|
||||
cleft = 20
|
||||
$(@refs.mlist)
|
||||
.css "height", "#{$(@refs.container).height()}px"
|
||||
gw = $(@refs.mlist).width()
|
||||
gh = $(@refs.mlist).height()
|
||||
me = @
|
||||
$(@refs.mlist).children().each (e) ->
|
||||
$(@)
|
||||
.css "top", "#{ctop}px"
|
||||
.css "left", "#{cleft}px"
|
||||
w = $(@).width()
|
||||
h = $(@).height()
|
||||
if me.get("dir") is "vertical"
|
||||
ctop += h + 20
|
||||
if ctop > gh
|
||||
ctop = 20
|
||||
cleft += w + 20
|
||||
else
|
||||
cleft += w + 20
|
||||
if cleft > gw
|
||||
cleft = 20
|
||||
ctop += h + 20
|
||||
|
||||
|
||||
layout: () ->
|
||||
[{
|
||||
el: "div", ref: "mlist"
|
||||
}]
|
||||
Ant.OS.GUI.define "afx-float-list1", FloatListTag
|
||||
|
@ -160,6 +160,11 @@ class GridViewTag extends Ant.OS.GUI.BaseTag
|
||||
|
||||
mount: () ->
|
||||
me = @
|
||||
$(@root)
|
||||
.css "overflow", "hidden"
|
||||
.css "display", "block"
|
||||
.css "padding", "5px"
|
||||
|
||||
$(@refs.grid).css "display", "grid"
|
||||
$(@refs.header).css "display", "grid"
|
||||
@observable.on "resize", (e) -> me.calibrate()
|
||||
|
@ -70,7 +70,7 @@ class ShowCase extends this.OS.GUI.BaseApplication
|
||||
</afx-hbox>
|
||||
|
||||
<afx-hbox title="Virtual desktop">
|
||||
<div data-height="200">desktop</div>
|
||||
<afx-float-list1 data-id = "flist"/>
|
||||
</afx-hbox>
|
||||
|
||||
</afx-tab-container>
|
||||
@ -198,6 +198,14 @@ class ShowCase extends this.OS.GUI.BaseApplication
|
||||
slider[0].set "onchanging", (v) ->
|
||||
console.log v
|
||||
|
||||
|
||||
list = $ "[data-id='flist']", scheme[0]
|
||||
list[0].set "data", [
|
||||
{ text: "File.txt" },
|
||||
{ text: "FileB.doc" },
|
||||
{ text: "Data.doc", iconclass: "fa fa-camera-retro fa-lg" }
|
||||
]
|
||||
|
||||
mnFile: () ->
|
||||
#console.log file
|
||||
me = @
|
||||
|
14
src/themes/antos/afx-float-list.css
Normal file
14
src/themes/antos/afx-float-list.css
Normal file
@ -0,0 +1,14 @@
|
||||
|
||||
afx-float-list1 div.list-container > ul{
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
|
||||
afx-float-list1 div.list-container > ul li{
|
||||
padding: 0;
|
||||
background-color: transparent;
|
||||
list-style: none;
|
||||
max-width: 100px;
|
||||
}
|
@ -1,8 +1,3 @@
|
||||
afx-grid-view{
|
||||
overflow: hidden;
|
||||
padding:5px;
|
||||
display: block;
|
||||
}
|
||||
afx-grid-view afx-grid-row div{
|
||||
padding:3px;
|
||||
padding-left: 5px;
|
||||
|
Loading…
Reference in New Issue
Block a user