diff --git a/Makefile b/Makefile index c348794..628e4f4 100644 --- a/Makefile +++ b/Makefile @@ -12,6 +12,7 @@ coffees= src/core/core.coffee\ src/core/BaseApplication.coffee\ src/core/BaseService.coffee\ src/core/BaseEvent.coffee\ + src/core/BaseDialog.coffee\ src/antos.coffee diff --git a/src/core/BaseApplication.coffee b/src/core/BaseApplication.coffee index ec99f8f..77495fc 100644 --- a/src/core/BaseApplication.coffee +++ b/src/core/BaseApplication.coffee @@ -1,7 +1,4 @@ self = this -_PM = self.OS.PM -_APP = self.OS.APP -_MAIL = self.OS.courrier class BaseApplication extends this.OS.GUI.BaseModel constructor: (name) -> super name @@ -16,9 +13,11 @@ class BaseApplication extends this.OS.GUI.BaseModel me.appmenu.set "items", (me.baseMenu() || []) me.appmenu.set "onmenuselect", (d) -> me.trigger("menuselect", d) + me.dialog.show() if me.dialog @on "hide", () -> me.sysdock.set "selectedApp", null me.appmenu.set "items", [] + me.dialog.hide() if me.dialog @on "menuselect", (d) -> switch d.e.item.data.dataid when "#{me.name}-about" then alert "About " + me.pid + me.name diff --git a/src/core/BaseDialog.coffee b/src/core/BaseDialog.coffee new file mode 100644 index 0000000..fff5004 --- /dev/null +++ b/src/core/BaseDialog.coffee @@ -0,0 +1,85 @@ +class BaseDialog extends this.OS.GUI.BaseModel + constructor: (name) -> + super name + @parent = undefined + @modal = false + @handler = undefined + quit: () -> + evt = new _GUI.BaseEvent("exit") + @onexit(evt) + if not evt.prevent + delete @.observable + @parent.dialog = undefined if @parent + ($ @scheme).remove() if @scheme + @dialog.quit() if @dialog + meta: () -> + @parent.meta() + show: () -> + @trigger 'focus' + ($ @scheme).css "z-index", window._zindex+2 + hide: () -> + @trigger 'hide' + +BaseDialog.type = 3 +this.OS.GUI.BaseDialog = BaseDialog +### + this dialog rende a tag as main content + and a list of buttons, the behaviour of + the button is specified by user. The conf + object is in the follow form + { + tag: , + buttons:[ + { + label: 'buton label', + onclick: function(d){...} + }, ... + ] + } +### +class BasicDialog extends BaseDialog + constructor: ( name, @conf ) -> + super name + html = " + " + html += "<#{@conf.tag} data-id = 'content'>" + html += "
" + html += "" for k,v of @conf.buttons + html += "
" + #render the html + _GUI.htmlToScheme html, @, @host + + main: () -> + @scheme.set "minimizable", false + me = @ + f = (_v) -> () -> _v.onclick me + # bind action to button + ( (me.find "bt#{k}").set "onbtclick", f(v) ) for k, v of @conf.buttons + +this.OS.GUI.BasicDialog = BasicDialog + +class CalendarDialog extends BasicDialog + constructor: () -> + super "CalendarDialog", { + tag: 'afx-calendar-view', + width: 300, + height: 220, + buttons: [ + { + label: 'Ok', + onclick: (d) -> + date = (d.find "content").get "selectedDate" + if date + d.handler date if d.handler + d.quit() + else + d.notify "Please select a date" + }, + { + label: 'Cancel', + onclick: (d) -> d.quit() + } + ] + } +this.OS.register "CalendarDialog", CalendarDialog + diff --git a/src/core/BaseModel.coffee b/src/core/BaseModel.coffee index 3f986f7..89a7b8b 100644 --- a/src/core/BaseModel.coffee +++ b/src/core/BaseModel.coffee @@ -1,24 +1,21 @@ -self = this -_PM = self.OS.PM -_APP = self.OS.APP -_MAIL = self.OS.courrier -_GUI = self.OS.GUI class BaseModel constructor: (@name) -> @observable = riot.observable() @_api = self.OS.API me = @ @on "exit", () -> me.quit() - @parent = "#desktop" + @host = "#desktop" + @dialog = undefined render: (p) -> - _GUI.loadScheme p, @, @parent + _GUI.loadScheme p, @, @host quit: () -> evt = new _GUI.BaseEvent("exit") @onexit(evt) if not evt.prevent delete @.observable + @dialog.quit() if @dialog _PM.kill @ init: -> @@ -29,11 +26,23 @@ class BaseModel trigger: (e, d) -> @observable.trigger e, d - subscribe: (e, f) -> _MAIL.on e, f, @ + subscribe: (e, f) -> _courrier.on e, f, @ + + openDialog: (d, f) -> + if @dialog + @dialog.show() + return + if not _GUI.dialog[d] + @error "Dialog #{d} not found" + return + @dialog = new _GUI.dialog[d]() + @dialog.parent = @ + @dialog.handler = f + @dialog.pid = @pid publish: (t, m) -> mt = @meta() - _MAIL.trigger t, { id: @pid, name: @name, data: { m: m, icon: mt.icon, iconclass: mt.iconclass } } + _courrier.trigger t, { id: @pid, name: @name, data: { m: m, icon: mt.icon, iconclass: mt.iconclass } } notify: (m) -> @publish "notification", m diff --git a/src/core/BaseService.coffee b/src/core/BaseService.coffee index f201bea..7b7b453 100644 --- a/src/core/BaseService.coffee +++ b/src/core/BaseService.coffee @@ -1,5 +1,3 @@ -MAIL = this.OS.courrier -_API = this.OS.API class BaseService extends this.OS.GUI.BaseModel constructor: (name) -> super name @@ -13,7 +11,8 @@ class BaseService extends this.OS.GUI.BaseModel #implement by user # event registe, etc # scheme loader - + meta: () -> + @ attach: (h) -> @holder = h diff --git a/src/core/core.coffee b/src/core/core.coffee index 106f0d3..a664256 100644 --- a/src/core/core.coffee +++ b/src/core/core.coffee @@ -19,7 +19,8 @@ self.OS or= _courrier.observable.off i.e, i.f for i in _courrier.listeners[app.pid] delete _courrier.listeners[app.pid] _courrier.listeners[app.pid] = [] - register: (name, x) -> _APP[name] = x + register: (name, x) -> + if x.type is 3 then self.OS.GUI.dialog[name] = x else _APP[name] = x PM: pidalloc: 0 diff --git a/src/core/gui.coffee b/src/core/gui.coffee index 6507a80..f86b3e3 100644 --- a/src/core/gui.coffee +++ b/src/core/gui.coffee @@ -1,20 +1,22 @@ self.OS.GUI = + dialog: new Object() init: () -> query = path: 'VFS/get' data: "#{_GUI.tagPath}/tags.json" self.OS.API.request query, ()-> - + htmlToScheme: (html, app, parent) -> + scheme = $.parseHTML html + ($ parent).append scheme + riot.mount ($ scheme), { observable: app.observable } + app.scheme = scheme[0] + app.main() + app.show() loadScheme: (path, app, parent) -> _API.get path, (x) -> return null unless x - scheme = $.parseHTML x - ($ parent).append scheme - riot.mount ($ scheme), { observable: app.observable } - app.scheme = scheme[0] - app.main() - app.show() + _GUI.htmlToScheme x, app, parent , (f) -> _courrier.trigger "fail", {id: 0, data: { diff --git a/src/core/tags/afx-app-window.js b/src/core/tags/afx-app-window.js index 6587a79..8d38950 100644 --- a/src/core/tags/afx-app-window.js +++ b/src/core/tags/afx-app-window.js @@ -2,8 +2,8 @@
@@ -15,6 +15,8 @@ \ No newline at end of file diff --git a/src/core/tags/afx-grid-view.js b/src/core/tags/afx-grid-view.js index 9ddbaa1..12b9c9e 100644 --- a/src/core/tags/afx-grid-view.js +++ b/src/core/tags/afx-grid-view.js @@ -2,7 +2,7 @@
- +
-
+
{child.value} @@ -100,58 +93,112 @@ this.cols = opts.cols || [] var self = this this.rid = opts.rootid - this.observable = opts.observable + this.index = opts.index this.header = opts.header||false - this.calibrate_size = function() + this.head = opts.head + this.selidx = -1; + self.observable = opts.observable + this.colssize = [] + var update_header_size = function() { - if(!self.cols || self.cols.length == 0 || !self.observable) return + if(!self.cols || self.cols.length == 0) return var totalw = $(self.root).parent().width() + if(totalw == 0) return var ocw = 0 var nauto = 0 - var dist = [] + self.colssize = [] $.each(self.cols, function(i,e){ if(e.width) { - dist.push(e.width) + self.colssize.push(e.width) ocw += e.width } else { - dist.push(-1) + self.colssize.push(-1) nauto++ } }) if(nauto > 0) { - var cellw = (totalw - ocw)/ nauto - $.each(dist,function(i,e){ - if(e == -1) dist[i] = cellw - }) + var cellw = parseInt((totalw - ocw)/ nauto) + $.each(self.colssize,function(i,e){if(e == -1) self.colssize[i] = cellw}) } - - self.observable.trigger("cellresize",{id:self.rid,data:dist}) + calibrate_size() } - - self.observable.on("cellresize",function(d){ - if(d.id && d.id == self.rid) - { - var i = 0 - $(self.root) - .children() - .each(function(){ - $(this).css("width", d.data[i]+"px") - i++ - }) - } - }) - - this.on("mount", function(){ + var calibrate_size = function() + { + var i = 0 $(self.root) - .css("display","flex") - .css("flex-direction","row") - .css("width","100%") + .children() + .each(function(){ + $(this).css("width", self.colssize[i]+"px") + i++ + }) + } + this.on("updated", function(){ if(self.header) - self.calibrate_size() + update_header_size() + else if(self.head && self.index == 0) + { + self.colssize = self.head.colssize + calibrate_size() + } + }) + this.on("mount", function(){ + if (self.header) + { + $(self.root) + .css("display", "flex") + .css("flex-direction", "row") + update_header_size() + } + else + { + $(self.root) + .css("display","table-row") + //.css("flex-direction","row") + .css("width","100%") + if(self.head && self.index == 0) + { + self.colssize = self.head.colssize + calibrate_size() + } + } + self.observable.on("gridcellselect", function(data){ + if(data.id != self.rid || self.selidx == -1) return; + if(data.row != self.index) + { + self.cols[self.selidx].selected = false + self.selidx = -1 + } + }) + }) + _cell_select(event) + { + if(self.header) return; + if(self.selidx != -1) + { + self.cols[self.selidx].selected = false + self.selidx = -1 + } + self.cols[event.item.i].selected = true + + } + _auto_cell_select(child,i) + { + if(!child.selected || self.header) return false; + if(self.selidx == i) return true; + var data = { + id:self.rid, + data:child, + col:i, + row:self.index} + + self.selidx = i + self.observable.trigger("gridcellselect",data) + return true; + } \ No newline at end of file diff --git a/src/packages/ActivityMonitor/scheme.html b/src/packages/ActivityMonitor/scheme.html index 19f9a0f..5c66f43 100644 --- a/src/packages/ActivityMonitor/scheme.html +++ b/src/packages/ActivityMonitor/scheme.html @@ -1,5 +1,4 @@ - diff --git a/src/packages/DummyApp/main.coffee b/src/packages/DummyApp/main.coffee index a7fac90..ce801f6 100644 --- a/src/packages/DummyApp/main.coffee +++ b/src/packages/DummyApp/main.coffee @@ -5,8 +5,8 @@ class DummyApp extends this.OS.GUI.BaseApplication main: () -> self = @ @on "btclick", (e)-> - self.notify "this is a dummy notify" - _GUI.pushService "Budgy" + #_GUI.pushService "Budgy" + self.openDialog "CalendarDialog", (d) -> console.log d @on "resize", (w,h)-> console.log "#{self.name}: resize" #@on "listselect", (i)-> @@ -15,6 +15,8 @@ class DummyApp extends this.OS.GUI.BaseApplication console.log self.name,i @on "focus", ()-> console.log self.name, "is focused" + @on "dayselect", (e) -> console.log "cellselected", e + @on "gridselect", (e) -> console.log "GRID selected", e tree = @find "mytree" @scheme.set "apptitle", "Terminal" diff --git a/src/packages/DummyApp/scheme.html b/src/packages/DummyApp/scheme.html index 476001a..8e02afd 100644 --- a/src/packages/DummyApp/scheme.html +++ b/src/packages/DummyApp/scheme.html @@ -1,4 +1,4 @@ - + diff --git a/src/packages/NotePad/main.coffee b/src/packages/NotePad/main.coffee index 022218c..0117d0e 100644 --- a/src/packages/NotePad/main.coffee +++ b/src/packages/NotePad/main.coffee @@ -37,7 +37,6 @@ class NotePad extends this.OS.GUI.BaseApplication mode: m.theme, selected: if m.theme is "ace/theme/monokai" then true else false } for k, m of themes.themesByName - console.log themes.themesByName themelist.set "items", ldata themelist.set "onlistselect", (e) -> me.editor.setTheme e.data.mode @@ -49,7 +48,7 @@ class NotePad extends this.OS.GUI.BaseApplication l = me.editor.session.getLength() $(stat).html "Row #{c.row}, col #{c.column}, lines: #{l}" stup(0) - @.editor.getSession().selection.on "changeCursor", (e)->stup(e) + @.editor.getSession().selection.on "changeCursor", (e) -> stup(e) @on "resize", () -> me.editor.resize() @on "focus", () -> me.editor.focus() @@ -64,4 +63,4 @@ class NotePad extends this.OS.GUI.BaseApplication }] menu NotePad.singleton = false -this.OS.register "NotePad",NotePad \ No newline at end of file +this.OS.register "NotePad", NotePad \ No newline at end of file diff --git a/src/services/Calendar.coffee b/src/services/Calendar.coffee index af17866..270ff2e 100644 --- a/src/services/Calendar.coffee +++ b/src/services/Calendar.coffee @@ -14,7 +14,7 @@ class Calendar extends this.OS.GUI.BaseService me.update() awake: (e) -> - console.log @name,@pid + @.openDialog "CalendarDialog", (d) -> # do nothing cleanup: (evt) -> console.log "cleanup for quit" diff --git a/src/services/PushNotification.coffee b/src/services/PushNotification.coffee index 2a66fd5..a39b92f 100644 --- a/src/services/PushNotification.coffee +++ b/src/services/PushNotification.coffee @@ -12,46 +12,44 @@ class PushNotification extends this.OS.GUI.BaseService main: -> me = @ - mfeed = @find "notifeed" + @mlist = @find "notifylist" + @mfeed = @find "notifeed" @nzone = @find "notifyzone" - mlist = @find "notifylist" - (@find "btclear").set "onbtclick", (e) -> mlist.set "items", [] + (@find "btclear").set "onbtclick", (e) -> me.mlist.set "items", [] #mlist.set "onlistselect", (e) -> console.log e - @subscribe "notification", (o) -> - d = { - header: "#{o.name} (#{o.id})" - text: "INFO: #{o.name} (#{o.id}): #{o.data.m}", - lite: o.data.m - icon: o.data.icon, - iconclass: o.data.iconclass, - closable: true } - mlist.push d, true - me.notifeed d, mfeed - - @subscribe "fail", (o) -> - d = { - header: "#{o.name} (#{o.id})" - text: "FAIL: #{o.name} (#{o.id}): #{o.data.m}", - lite: o.data.m - icon: o.data.icon, - iconclass: o.data.iconclass, - closable: true } - mlist.push d, true - me.notifeed d, mfeed + @subscribe "notification", (o) -> me.pushout 'INFO', o + @subscribe "fail", (o) -> me.pushout 'FAIL', o + @subscribe "error", (o) -> me.pushout 'ERROR', o ($ @nzone).css "right", 0 .css "top", "-3px" .css "height", "" .css "bottom", "0" .hide() - ($ mfeed).css "right", "5px" + ($ @mfeed).css "right", "5px" .css "top", "0" - notifeed: (d, mfeed) -> - mfeed.push d, true - ($ mfeed).show() + pushout: (s, o, mfeed) -> + d = { + text: "#{o.name} (#{o.id}) - #{s}: #{o.data.m}", + icon: o.data.icon, + iconclass: o.data.iconclass, + closable: true } + d1 = { + header: "#{o.name} (#{o.id})" + text: "#{s}: #{o.data.m}", + icon: o.data.icon, + iconclass: o.data.iconclass, + closable: true } + @mlist.push d, true + @notifeed d1 + + notifeed: (d) -> + me = @ + @mfeed.push d, true + ($ @mfeed).show() timer = setTimeout () -> - mfeed.remove d, true + me.mfeed.remove d, true clearTimeout timer , 3000 diff --git a/src/themes/antos/afx-calendar-view.css b/src/themes/antos/afx-calendar-view.css new file mode 100644 index 0000000..66701ac --- /dev/null +++ b/src/themes/antos/afx-calendar-view.css @@ -0,0 +1,53 @@ +afx-calendar-view div{ + text-align: center; + background-color: white; +} +afx-calendar-view > div { + font-weight: bold; +} + +afx-calendar-view i.prevmonth, afx-calendar-view i.nextmonth{ + display: inline-block; + width: 16px; + height: 16px; + cursor: pointer; +} +afx-calendar-view i.prevmonth{ + margin-right: 20px; +} +afx-calendar-view i.nextmonth{ + margin-left: 20px; +} + +afx-calendar-view i.prevmonth:before{ + content: "\f104"; + font-family: "FontAwesome"; + font-size: 16px; + font-style: normal; + color: #414339; + /*position:absolute; + top:25%; + right:5px;*/ +} +afx-calendar-view i.nextmonth:before{ + content: "\f105"; + font-family: "FontAwesome"; + font-size: 16px; + font-style: normal; + color: #414339; + margin-left: 20px; + /*position:absolute; + top:25%; + right:5px;*/ +} + +afx-calendar-view afx-grid-view afx-grid-row.selected{ + background-color: white; + color:#414339; +} + +afx-calendar-view afx-grid-view afx-grid-row .cellselected{ + background-color: #116cd6; + color:white; + border-radius: 6px; +} \ No newline at end of file diff --git a/src/themes/antos/antos.css b/src/themes/antos/antos.css index cef5bf6..b36b6d5 100644 --- a/src/themes/antos/antos.css +++ b/src/themes/antos/antos.css @@ -7,6 +7,7 @@ html,body{ height: 100%; background-image: url(wallpaper.jpg); background-size: cover; + overflow: hidden; } #wrapper{ margin: 0;