From c46049fd0c9b5e09c00b4aba7748023da45829d0 Mon Sep 17 00:00:00 2001 From: mrsang Date: Mon, 27 Apr 2020 18:50:52 +0200 Subject: [PATCH] add float list --- Makefile | 1 + src/core/tags/CalendarTag.coffee | 14 ++++ src/core/tags/FloatListTag.coffee | 87 +++++++++++++++++++---- src/core/tags/GridView.coffee | 5 ++ src/packages/ShowCase/coffees/main.coffee | 10 ++- src/themes/antos/afx-float-list.css | 14 ++++ src/themes/antos/afx-grid-view.css | 5 -- 7 files changed, 118 insertions(+), 18 deletions(-) create mode 100644 src/core/tags/CalendarTag.coffee create mode 100644 src/themes/antos/afx-float-list.css diff --git a/Makefile b/Makefile index a465c7b..5645eaa 100644 --- a/Makefile +++ b/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 diff --git a/src/core/tags/CalendarTag.coffee b/src/core/tags/CalendarTag.coffee new file mode 100644 index 0000000..dbc18e8 --- /dev/null +++ b/src/core/tags/CalendarTag.coffee @@ -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" } + ] + }] \ No newline at end of file diff --git a/src/core/tags/FloatListTag.coffee b/src/core/tags/FloatListTag.coffee index a53cf10..7e7e19a 100644 --- a/src/core/tags/FloatListTag.coffee +++ b/src/core/tags/FloatListTag.coffee @@ -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" - }] \ No newline at end of file +Ant.OS.GUI.define "afx-float-list1", FloatListTag diff --git a/src/core/tags/GridView.coffee b/src/core/tags/GridView.coffee index 120991b..4bc3318 100644 --- a/src/core/tags/GridView.coffee +++ b/src/core/tags/GridView.coffee @@ -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() diff --git a/src/packages/ShowCase/coffees/main.coffee b/src/packages/ShowCase/coffees/main.coffee index f1cdda5..849f11d 100644 --- a/src/packages/ShowCase/coffees/main.coffee +++ b/src/packages/ShowCase/coffees/main.coffee @@ -70,7 +70,7 @@ class ShowCase extends this.OS.GUI.BaseApplication -
desktop
+
@@ -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 = @ diff --git a/src/themes/antos/afx-float-list.css b/src/themes/antos/afx-float-list.css new file mode 100644 index 0000000..c03ceda --- /dev/null +++ b/src/themes/antos/afx-float-list.css @@ -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; +} \ No newline at end of file diff --git a/src/themes/antos/afx-grid-view.css b/src/themes/antos/afx-grid-view.css index 5a3c206..c6d9807 100644 --- a/src/themes/antos/afx-grid-view.css +++ b/src/themes/antos/afx-grid-view.css @@ -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;