mirror of
https://github.com/lxsang/antos-frontend.git
synced 2025-07-19 15:29:51 +02:00
add calendar view & stuff
This commit is contained in:
@ -45,7 +45,7 @@ class BaseApplication extends this.OS.GUI.BaseModel
|
||||
if not evt.prevent
|
||||
@.appmenu.set "items", [] if @.pid == @.appmenu.pid
|
||||
($ @scheme).remove()
|
||||
|
||||
meta: () -> _APP[@name].meta
|
||||
baseMenu: ->
|
||||
mn =
|
||||
[{
|
||||
|
@ -6,7 +6,6 @@ _GUI = self.OS.GUI
|
||||
class BaseModel
|
||||
constructor: (@name) ->
|
||||
@observable = riot.observable()
|
||||
@pid = 0
|
||||
@_api = self.OS.API
|
||||
me = @
|
||||
@on "exit", () -> me.quit()
|
||||
@ -31,16 +30,20 @@ class BaseModel
|
||||
trigger: (e, d) -> @observable.trigger e, d
|
||||
|
||||
subscribe: (e, f) -> _MAIL.on e, f, @
|
||||
meta: () -> _APP[@name].meta
|
||||
|
||||
publish: (t, m) ->
|
||||
mt = @meta()
|
||||
_MAIL.trigger t, { id: @pid, name: @name, data: { m: m, icon: mt.icon, iconclass: mt.iconclass } }
|
||||
|
||||
notify: (m) ->
|
||||
@publish "notification", m
|
||||
|
||||
warn: (m) ->
|
||||
@publish "warning", m
|
||||
|
||||
error: (m) ->
|
||||
@publish "error", m
|
||||
|
||||
fail: (m) ->
|
||||
@publish "fail", m
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
<afx-dummy>
|
||||
<afx-overlay data-id = "notifyzone" width = "250">
|
||||
<afx-button text = "Clear all" data-id = "btclear"></afx-button>
|
||||
<afx-list-view data-id="notifylist"></afx-list-view>
|
||||
<style>
|
||||
afx-overlay[data-id = "notifyzone"]{
|
||||
@ -10,6 +11,13 @@
|
||||
padding:3px;
|
||||
margin: 0;
|
||||
}
|
||||
afx-overlay[data-id = "notifyzone"] afx-button button{
|
||||
width: 250px;
|
||||
background-color: rgba(215,215,215,0.9);
|
||||
}
|
||||
afx-overlay[data-id = "notifyzone"] afx-button button:active{
|
||||
color:#414339;
|
||||
}
|
||||
afx-list-view[data-id = "notifylist"]
|
||||
{
|
||||
padding:0;
|
||||
@ -21,7 +29,7 @@
|
||||
}
|
||||
</style>
|
||||
</afx-overlay>
|
||||
<afx-feed data-id = "notifeed" style = "display: none;" closable="true">
|
||||
<afx-feed data-id = "notifeed" style = "display: none;">
|
||||
<!--afx-button text = "click me"></afx-button-->
|
||||
<style>
|
||||
afx-feed[data-id = "notifeed"]{
|
||||
|
@ -9,7 +9,7 @@
|
||||
this.icon = opts.icon
|
||||
this.iconclass = opts.iconclass
|
||||
var self = this
|
||||
|
||||
this.onbtclick = opts.onbtclick
|
||||
self.root.set = function(k,v)
|
||||
{
|
||||
if(k == "*")
|
||||
@ -25,10 +25,10 @@
|
||||
}
|
||||
this._onbtclick = function(e)
|
||||
{
|
||||
if(typeof opts.onbtclick == 'string')
|
||||
eval(opts.onbtclick())
|
||||
else if(opts.onbtclick)
|
||||
opts.onbtclick()
|
||||
if(typeof self.onbtclick == 'string')
|
||||
eval(self.onbtclick)
|
||||
else if(self.onbtclick)
|
||||
self.onbtclick(e)
|
||||
if(self.root.observable)
|
||||
{
|
||||
self.root.observable.trigger("btclick",{id:$(self.root).attr("data-id"),data:self.root})
|
||||
|
@ -1,5 +1,5 @@
|
||||
<afx-feed>
|
||||
<div>
|
||||
<div each = {items}>
|
||||
<p>
|
||||
<i if={iconclass} class = {iconclass} ></i>
|
||||
<i if={icon} class="icon-style" style = { "background: url("+icon+");background-size: 100% 100%;background-repeat: no-repeat;" }></i>
|
||||
@ -13,11 +13,7 @@
|
||||
</div>
|
||||
<script>
|
||||
var self = this
|
||||
this.icon = opts.icon
|
||||
this.iconclass = opts.iconclass
|
||||
this.closable = opts.closable
|
||||
this.header = opts.header||""
|
||||
this.text = opts.text || ""
|
||||
self.items = opts.items || []
|
||||
self.root.set = function(k,v)
|
||||
{
|
||||
if(k == "*")
|
||||
@ -27,6 +23,24 @@
|
||||
self[k] = v
|
||||
self.update()
|
||||
}
|
||||
self.root.push = function(i,u)
|
||||
{
|
||||
self.items.push(i)
|
||||
if(u) self.update()
|
||||
}
|
||||
self.root.remove = function(e,u)
|
||||
{
|
||||
var i = self.items.indexOf(e)
|
||||
if(i >= 0)
|
||||
self.items.splice(i, 1)
|
||||
if(u)
|
||||
self.update()
|
||||
}
|
||||
self.root.unshift = function(i,u)
|
||||
{
|
||||
self.items.unshift(i)
|
||||
if(u) self.update()
|
||||
}
|
||||
self.root.get = function(k)
|
||||
{
|
||||
return self[k]
|
||||
|
@ -6,14 +6,10 @@
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
this.rows= []
|
||||
if(opts.data)
|
||||
{
|
||||
this.header = opts.data.header
|
||||
this.rows = opts.data.data
|
||||
}
|
||||
this.header = opts.header
|
||||
this.rows = opts.rows || []
|
||||
var self = this
|
||||
this.rid = $(self.root).attr("data-id")
|
||||
this.rid = $(self.root).attr("data-id") || Math.floor(Math.random() * 100000) + 1
|
||||
self.selidx = -1
|
||||
self.nrow = 0
|
||||
self.root.set = function(k,v)
|
||||
@ -27,7 +23,7 @@
|
||||
self[k] = v
|
||||
self.update()
|
||||
}
|
||||
var calibrate_size = function()
|
||||
this.calibrate_size = function()
|
||||
{
|
||||
if(self.header)
|
||||
{
|
||||
@ -58,10 +54,10 @@
|
||||
.css("display","flex")
|
||||
.css("flex-direction","column")
|
||||
.css("width","100%")
|
||||
calibrate_size()
|
||||
self.calibrate_size()
|
||||
|
||||
this.root.observable.on("resize",function(){
|
||||
calibrate_size()
|
||||
self.calibrate_size()
|
||||
if(self.refs.gridhead)
|
||||
self.refs.gridhead.calibrate_size()
|
||||
})
|
||||
@ -71,7 +67,7 @@
|
||||
self.selidx = -1
|
||||
if(self.nrow == self.rows.length) return
|
||||
self.nrow = self.rows.length
|
||||
calibrate_size()
|
||||
self.calibrate_size()
|
||||
if(self.refs.gridhead)
|
||||
self.refs.gridhead.calibrate_size()
|
||||
})
|
||||
|
@ -1,14 +1,13 @@
|
||||
<afx-list-view class = {dropdown: opts.dropdown == "true"}>
|
||||
<div class = "list-container" ref = "container">
|
||||
<div if = {opts.dropdown == "true"} ref = "current" style = {opts.width?"min-width:" + opts.width + "px;":"min-width:150px;"} onclick = {show_list}>
|
||||
{selectedText}
|
||||
</div>
|
||||
<ul ref = "mlist">
|
||||
<li each={ items } class={selected: selected} onclick = {parent._select}>
|
||||
<i if={iconclass} class = {iconclass} ></i>
|
||||
<i if={icon} class="icon-style" style = { "background: url("+icon+");background-size: 100% 100%;background-repeat: no-repeat;" }></i>
|
||||
{ text }
|
||||
<i if = {closable} class = "closable" click = {parent._remove}></i>
|
||||
<li each={item,i in items } class={selected: parent._autoselect(item,i)} onclick = {parent._select}>
|
||||
<i if={item.iconclass} class = {item.iconclass} ></i>
|
||||
<i if={item.icon} class="icon-style" style = { "background: url("+item.icon+");background-size: 100% 100%;background-repeat: no-repeat;" }></i>
|
||||
{ item.text }
|
||||
<i if = {item.closable} class = "closable" click = {parent._remove}></i>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
@ -16,12 +15,16 @@
|
||||
this.items = opts.child || []
|
||||
var self = this
|
||||
self.selidx = -1
|
||||
self.selectedText = ""
|
||||
self.onlistselect = opts.onlistselect
|
||||
var onclose = false
|
||||
self.root.set = function(k,v)
|
||||
{
|
||||
if(k == "selected")
|
||||
self._select({item:self.items[v], preventDefault:function(){}})
|
||||
{
|
||||
if(self.selidx != -1)
|
||||
self.items[self.selidx].selected =false
|
||||
self.items[v].selected = true
|
||||
}
|
||||
else if(k == "*")
|
||||
for(var i in v)
|
||||
self[i] = v[i]
|
||||
@ -71,7 +74,7 @@
|
||||
.css("left","0")
|
||||
}
|
||||
})
|
||||
show_list()
|
||||
show_list(event)
|
||||
{
|
||||
var desktoph = $("#desktop").height()
|
||||
var off = $(self.root).offset().top + $(self.refs.mlist).height()
|
||||
@ -81,6 +84,8 @@
|
||||
else
|
||||
$(self.refs.mlist).css("top","100%")
|
||||
$(self.refs.mlist).show()
|
||||
//event.preventDefault()
|
||||
event.preventUpdate = true
|
||||
}
|
||||
_remove(event)
|
||||
{
|
||||
@ -90,20 +95,48 @@
|
||||
self.selidx = -1
|
||||
}
|
||||
self.items.splice(self.items.indexOf(event.item),1)
|
||||
event.target = self.root
|
||||
self.update()
|
||||
onclose = true
|
||||
}
|
||||
_autoselect(it,i)
|
||||
{
|
||||
if(!it.selected || it.selected == false) return false
|
||||
var data = {
|
||||
id:$(self.root).attr("data-id"),
|
||||
data:it,
|
||||
idx:i}
|
||||
//if(self.selidx != -1)
|
||||
// self.items[self.selidx].selected =false
|
||||
self.selidx = i
|
||||
if(opts.dropdown == "true")
|
||||
{
|
||||
$(self.refs.mlist).hide()
|
||||
$(self.refs.current).html(it.text)
|
||||
}
|
||||
if(self.onlistselect)
|
||||
self.onlistselect(data)
|
||||
this.root.observable.trigger('listselect',data)
|
||||
return true
|
||||
}
|
||||
_select(event)
|
||||
{
|
||||
var data = {
|
||||
id:$(self.root).attr("data-id"),
|
||||
data:event.item,
|
||||
idx:self.items.indexOf(event.item)}
|
||||
if(onclose)
|
||||
{
|
||||
onclose = false
|
||||
event.preventUpdate = true
|
||||
return
|
||||
}
|
||||
if(self.selidx != -1)
|
||||
self.items[self.selidx].selected =false
|
||||
event.item.item.selected = true
|
||||
/*var data = {
|
||||
id:$(self.root).attr("data-id"),
|
||||
data:event.item.item,
|
||||
idx:event.item.i}
|
||||
|
||||
self.selidx = data.idx
|
||||
if(!self.items[self.selidx])
|
||||
return
|
||||
return
|
||||
|
||||
self.items[self.selidx].selected = true
|
||||
if(opts.dropdown == "true")
|
||||
@ -111,10 +144,10 @@
|
||||
$(self.refs.mlist).hide()
|
||||
self.selectedText = self.items[self.selidx].text
|
||||
}
|
||||
if(self.onlistselect)
|
||||
self.onlistselect(data)
|
||||
|
||||
this.root.observable.trigger('listselect',data)
|
||||
//event.preventDefault()
|
||||
//event.preventDefault()*/
|
||||
|
||||
}
|
||||
</script>
|
||||
</afx-list-view>
|
Reference in New Issue
Block a user