mirror of
https://github.com/lxsang/antos-frontend.git
synced 2025-07-19 23:40:00 +02:00
add float list
This commit is contained in:
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()
|
||||
|
Reference in New Issue
Block a user