From 8bca6bc40e643e78e9415f6a49dccaaa9d47108b Mon Sep 17 00:00:00 2001 From: Brian Lomeland Date: Sun, 4 Dec 2011 18:30:27 -0800 Subject: [PATCH] added old client code --- src/client-flex/ElucioCanvas.mxml | 302 +++++++++++++ src/client-flex/ElucioFacebook.mxml | 56 +++ src/client-flex/ElucioLogin.mxml | 8 + src/client-flex/ElucioProjects.mxml | 23 + src/client-flex/ElucioTasks.mxml | 23 + src/client-flex/ElucioWeb.css | 9 + src/client-flex/ElucioWeb.mxml | 84 ++++ .../assets/elucio_300x80_black.png | Bin 0 -> 3597 bytes .../assets/elucio_logo_header_133.png | Bin 0 -> 2924 bytes src/client-flex/assets/elucio_sun5.png | Bin 0 -> 8977 bytes src/client-flex/com/elucio/CellSprite.as | 10 + .../com/elucio/DateTimePicker.mxml | 90 ++++ src/client-flex/com/elucio/ElucioAddTask.mxml | 34 ++ src/client-flex/com/elucio/Projects.as | 70 +++ src/client-flex/com/elucio/Tasks.as | 70 +++ src/client-svg/application.js | 427 ++++++++++++++++++ 16 files changed, 1206 insertions(+) create mode 100644 src/client-flex/ElucioCanvas.mxml create mode 100644 src/client-flex/ElucioFacebook.mxml create mode 100644 src/client-flex/ElucioLogin.mxml create mode 100644 src/client-flex/ElucioProjects.mxml create mode 100644 src/client-flex/ElucioTasks.mxml create mode 100644 src/client-flex/ElucioWeb.css create mode 100644 src/client-flex/ElucioWeb.mxml create mode 100644 src/client-flex/assets/elucio_300x80_black.png create mode 100644 src/client-flex/assets/elucio_logo_header_133.png create mode 100644 src/client-flex/assets/elucio_sun5.png create mode 100644 src/client-flex/com/elucio/CellSprite.as create mode 100644 src/client-flex/com/elucio/DateTimePicker.mxml create mode 100644 src/client-flex/com/elucio/ElucioAddTask.mxml create mode 100644 src/client-flex/com/elucio/Projects.as create mode 100644 src/client-flex/com/elucio/Tasks.as create mode 100644 src/client-svg/application.js diff --git a/src/client-flex/ElucioCanvas.mxml b/src/client-flex/ElucioCanvas.mxml new file mode 100644 index 0000000..96826bb --- /dev/null +++ b/src/client-flex/ElucioCanvas.mxml @@ -0,0 +1,302 @@ + + + + + + + + 30) CELL_BORDER = 30; + zoom = 0; + } + + cell_width = canvas_width / (matrix_width + CELL_BORDER + CELL_BORDER); + cell_height = (canvas_height / (matrix_height + CELL_BORDER + CELL_BORDER)) * HEIGHT_TO_WIDTH_RATIO; + cell_width_margin = cell_width * CELL_MARGIN; + cell_height_margin = cell_height * CELL_MARGIN; + trace("matrix_width = " + matrix_width + " matrix_height = " + matrix_height); + trace("cell_width = " + cell_width + " cell_height = " + cell_height); + trace("CELL_BORDER = " + CELL_BORDER + " CELL_MARGIN = " + CELL_MARGIN); + } + + private function draw_matrix():void { + var cell_side_width:int = cell_width - (2 * cell_width_margin); + var cell_side_height:int = cell_height - (2 * cell_height_margin); + + var full_matrix_width:int = matrix_width + CELL_BORDER + CELL_BORDER; + var full_matrix_height:int = matrix_height + CELL_BORDER + CELL_BORDER; + + trace("ElucioCanvas:draw_matrix called()"); + + var sve:SpriteVisualElement; + var mySprite:CellSprite; + + for (var w:int = 0; w < full_matrix_width; w++) { + for (var h:int = 0; h < full_matrix_height; h++) { + sve = new SpriteVisualElement(); + mySprite = new CellSprite(); + + mySprite.graphics.beginFill(0xcdc9c9); + mySprite.graphics.drawRoundRect(w * cell_width + cell_width_margin, h * cell_height + cell_height_margin, cell_side_width, cell_side_height, 60, 60); + mySprite.graphics.endFill(); + mySprite.graphics.drawRect(x, y, cell_side_width, cell_side_height); + mySprite.graphics.endFill(); + mySprite.task = new Object(); + mySprite.task.matrix_x = w - CELL_BORDER; + mySprite.task.matrix_y = h - CELL_BORDER; + mySprite.addEventListener(MouseEvent.CLICK, cellAddTaskHandler); + sve.addChild(mySprite); + this.addElement(sve); + } + } + } + + private function draw_tasks():void { + var cell_side_width:int = cell_width - (2 * cell_width_margin); + var cell_side_height:int = cell_height - (2 * cell_height_margin); + + trace("cell_side_width = " + cell_side_width + " cell_side_height = " + cell_side_height); + trace("cell_width_margin = " + cell_width_margin + " cell_height_margin = " + cell_height_margin); + + if (!tasks) { + return; + } + + var textfield:TextField = new TextField; + var bitmapdata:BitmapData = new BitmapData(cell_side_width, cell_side_height, true, 0x00000000); + var sve:SpriteVisualElement; + var mySprite:CellSprite; + + for (var i:int = 0; i < tasks.length; i++) { + + if (tasks[i].project_id != current_project) { + continue; + } + + var x:int = (tasks[i].matrix_x + CELL_BORDER) * cell_width + cell_width_margin; + var y:int = (tasks[i].matrix_y + CELL_BORDER) * cell_height + cell_height_margin; + // TODO: not very efficent, but to save them somewhere are resuse + sve = new SpriteVisualElement(); + mySprite = new CellSprite(); + + textfield.text = "id = " + tasks[i].id; + + var task_state:String = tasks[i].status; + + if (!task_state) { + task_state = "Open"; + } + + mySprite.graphics.beginFill(0x00ff00); + mySprite.graphics.drawRoundRect(x, y, cell_side_width, cell_side_height, 60, 60); + mySprite.graphics.endFill(); + bitmapdata.draw(textfield); + mySprite.graphics.beginBitmapFill(bitmapdata); + mySprite.graphics.drawRect(x, y, cell_side_width, cell_side_height); + mySprite.graphics.endFill(); + mySprite.task = tasks[i]; + mySprite.addEventListener(MouseEvent.CLICK, function(event:MouseEvent):void { + var sprite:CellSprite = mySprite; + cellClickHandler(event, sprite); + }); + sve.addChild(mySprite); + this.addElement(sve); + + //shape.attr({fill: this.STATE_COLORS[task_state], stroke: this.STATE_COLORS[task_state], "fill-opacity": 50, "stroke-width": 2, cursor: "move"}); + + } + } + + private function get_project_matrix_size():Object { + var max_x:int = 0; + var max_y:int = 0; + + var current_project:int = get_current_project(); + trace("current_project = " + current_project); + + if (!tasks) { + return {x: 0, y:0}; + } + + for (var i:int = 0; i < tasks.length; i++) { + + if (tasks[i].project_id != current_project) { + continue; + } + + if (tasks[i].matrix_x > max_x) { + max_x = tasks[i].matrix_x; + } + if (tasks[i].matrix_y > max_y) { + max_y = tasks[i].matrix_y; + } + } + + // adjust for zero based index + max_x++; + max_y++; + + return {x: max_x, y: max_y}; + } + + private function get_current_project():int { + import flash.net.SharedObject; + + var sharedObj:SharedObject = SharedObject.getLocal("elucio"); + var project_id:int = 0; + + tasks = Tasks.get_instance().tasks; + + if (sharedObj.size > 0) { + project_id = sharedObj.data.current_project; + trace("get_current_project:project_id = " + project_id); + } + + // check if that project still exists + if (project_id > 0) { + for (var i:int = 0; i < tasks.length; i++) { + if (tasks[i].project_id == project_id) { + trace("get_current_project:project_id = " + project_id); + current_project = project_id; + return project_id; + } + } + } + + // no project id or a stale id so pick the first good project id + if (tasks) { + for (var j:int = 0; j < tasks.length; j++) { + trace("get_curren_project:tasks:value: " + tasks[j].project_id); + project_id = tasks[j].project_id; + } + + } + else { + project_id = 0; // no projects or tasks found + } + + current_project = project_id; + sharedObj.data.current_project = project_id; + sharedObj.flush(); + + return project_id; + } + + private function cellClickHandler(event:MouseEvent, sprite:CellSprite):void { + trace("sprite clicked: x = " + sprite.task.matrix_x + " y = " + sprite.task.matrix_y); + } + + private function cellAddTaskHandler(event:MouseEvent):void { + trace("sprite clicked: x = " + event.target.task.matrix_x + " y = " + event.target.task.matrix_y); + addTaskPopup.button_cancel.addEventListener(MouseEvent.CLICK, cellCancelAddTask); + PopUpManager.addPopUp(addTaskPopup, this, true); + PopUpManager.centerPopUp(addTaskPopup); + } + + public function cellCancelAddTask(event:MouseEvent):void { + PopUpManager.removePopUp(addTaskPopup); + } + + private function mouseWheelHandler(event:MouseEvent):void { + trace("mousewheel = " + event.delta); + zoom = zoom + event.delta; + invalidateDisplayList(); + } + + ]]> + + + + diff --git a/src/client-flex/ElucioFacebook.mxml b/src/client-flex/ElucioFacebook.mxml new file mode 100644 index 0000000..029dcd3 --- /dev/null +++ b/src/client-flex/ElucioFacebook.mxml @@ -0,0 +1,56 @@ + + + + + + + + + + + diff --git a/src/client-flex/ElucioLogin.mxml b/src/client-flex/ElucioLogin.mxml new file mode 100644 index 0000000..0714903 --- /dev/null +++ b/src/client-flex/ElucioLogin.mxml @@ -0,0 +1,8 @@ + + + + + + diff --git a/src/client-flex/ElucioProjects.mxml b/src/client-flex/ElucioProjects.mxml new file mode 100644 index 0000000..03d2b91 --- /dev/null +++ b/src/client-flex/ElucioProjects.mxml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + diff --git a/src/client-flex/ElucioTasks.mxml b/src/client-flex/ElucioTasks.mxml new file mode 100644 index 0000000..9974e86 --- /dev/null +++ b/src/client-flex/ElucioTasks.mxml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + diff --git a/src/client-flex/ElucioWeb.css b/src/client-flex/ElucioWeb.css new file mode 100644 index 0000000..2a2400e --- /dev/null +++ b/src/client-flex/ElucioWeb.css @@ -0,0 +1,9 @@ +/* CSS file */ +@namespace s "library://ns.adobe.com/flex/spark"; +@namespace mx "library://ns.adobe.com/flex/mx"; + + +global +{ +} + \ No newline at end of file diff --git a/src/client-flex/ElucioWeb.mxml b/src/client-flex/ElucioWeb.mxml new file mode 100644 index 0000000..4904c58 --- /dev/null +++ b/src/client-flex/ElucioWeb.mxml @@ -0,0 +1,84 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/client-flex/assets/elucio_300x80_black.png b/src/client-flex/assets/elucio_300x80_black.png new file mode 100644 index 0000000000000000000000000000000000000000..29bc2a746dc4ad87b7932ff714443a195aa23cc5 GIT binary patch literal 3597 zcmV+o4)XDdP)Px?$4Nv%RCwC$ooSF&#T9_Rfni^R`q7o3%1Su;OafxvWM&lA=Qfe$Q zt|?+vj9C=RXkwXCOC+XZ45p$~Dr$@p6&JP`7Z6cd6a@i?MHm@m$d5ixXT~@0z3x8u zy?clARoxnDhTG@#x#ynSeR>1KFbu;m3`3WyU8J5JfNnr{&!5Hq&r85~b0eb&-GTFg zlYn7BAD|9c3_J$h3v4zs898<)co{|^z6Go<;zJ(+r<$n@3s^=anG7_R=tqsfm1Z)- z0+vw;PVopLZdaRupE}5OD|ly zA;h270zJ)yMjlNlDUj7oBbbn}XJ15Y3MSgu;WID~X3@TpuIfK|W;xU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eUe~!8XW3 z&Lc z&*w9A!Kv!j%$NjT%Xc8c^Mf$7e7?QF=`-D0{ooMU_oD zOU|20ElB1ih$H~`enA-Vy8zbhz~GA%6zJD!9)OvVydY z8_Z8zT0l}hK%<5jSYTsANOkLh`MdFHBw~Yd0I4sX1)1P27M%s11oTXVK$Npy1ghU8qwD_BFa2L89)~umouiPXj`P?pw-rOdV zUWoMG>p;U`Wq1;e+$$Ia^yO7Q;mP|C*EW;DXh~{&zb;(b04Yl(sO8*6>uPjvjrfJ2 z1E<(aD0S_4u5_v_X|cf~{EAyV#c2gE4N0y|e#R;$fnq=!WLE*wUQ+ zyhE0I4>X|Y>)%r#=eK`fg|sjHp2&yX=dF@Ks-jR5X#iQ*ry0^on$o_@F+__8QGi?| zrP;y!VWk@+FE8{^HftdCH$Xk-h!w|<3$j65t=_yaD+Q>KGiW|?O9jCc4V3_`%H4U% z|La#bP_F=4eV5a?IPHhuCxOo%d}ptC{wdfLH1Y~0FjwbV0zm;IdN}8?Xy`+Peg&w_ zl|sfGobw%%kWCJ1){thx0&m5@n+_lFrW?v14Eevmc=7*v1dqij``3x&RC)O8w?xsJ MYPVHOl+l>~0Xe|aU;qFB literal 0 HcmV?d00001 diff --git a/src/client-flex/com/elucio/CellSprite.as b/src/client-flex/com/elucio/CellSprite.as new file mode 100644 index 0000000..b0972d9 --- /dev/null +++ b/src/client-flex/com/elucio/CellSprite.as @@ -0,0 +1,10 @@ +package com.elucio { + import flash.display.Sprite; + + public class CellSprite extends Sprite { + public var task:Object; + + public function CellSprite() { + } + } +} \ No newline at end of file diff --git a/src/client-flex/com/elucio/DateTimePicker.mxml b/src/client-flex/com/elucio/DateTimePicker.mxml new file mode 100644 index 0000000..e7e09b8 --- /dev/null +++ b/src/client-flex/com/elucio/DateTimePicker.mxml @@ -0,0 +1,90 @@ + + + + + [Event(name="change", type="flash.events.Event")] + + + + = 12) + { + this.ampm.selectedValue = 2; + } + else + { + this.ampm.selectedValue = 1; + } + + if(value.getHours() < 13 ) + this.hours.value = value.getHours() + else + this.hours.value = value.getHours() - 12 + + if(value.getHours() == 0) + this.hours.value = 12; + + this.minutes.value = value.getMinutes() + this.validateNow(); + } + + override public function validateProperties():void + { + super.validateProperties(); + + } + + public function handleChange():void + { + + var militaryHours:int = hours.value; + if(ampm.selectedValue == 2 && hours.value != 12) + militaryHours = hours.value+12; + else if(ampm.selectedValue == 1 && hours.value == 12) + militaryHours = 0; + var selDate:Date = this.date.selectedDate; + var date:Date = new Date( + selDate.getFullYear(), + selDate.getMonth(), + selDate.getDate(), + militaryHours, + minutes.value) + this.selectedDate = date; + + this.invalidateProperties(); + this.validateNow(); + this.dispatchEvent(new Event("change")); + + } + ]]> + + + + + + + + + + + + diff --git a/src/client-flex/com/elucio/ElucioAddTask.mxml b/src/client-flex/com/elucio/ElucioAddTask.mxml new file mode 100644 index 0000000..ee3a610 --- /dev/null +++ b/src/client-flex/com/elucio/ElucioAddTask.mxml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/client-flex/com/elucio/Projects.as b/src/client-flex/com/elucio/Projects.as new file mode 100644 index 0000000..cded88f --- /dev/null +++ b/src/client-flex/com/elucio/Projects.as @@ -0,0 +1,70 @@ +package com.elucio { + import com.adobe.serialization.json.JSON; + + import flash.events.Event; + import flash.net.URLLoader; + import flash.net.URLRequest; + + import mx.collections.ArrayCollection; + import mx.rpc.events.FaultEvent; + import mx.rpc.events.ResultEvent; + + public final class Projects { + private static var _instance:Projects = new Projects(); + + [Bindable] + public var projects:ArrayCollection = null; + + public function Projects() { + if (_instance != null) { + throw new Error("Projects can only be accessed through Projects.instance"); + } + _instance = this; + load_projects(); + } + + public static function get_instance():Projects { + if (_instance == null) _instance = new Projects(); + return _instance; + } + + public function get_projects():ArrayCollection { + return projects; + } + + public function load_projects():void { + var url:String = "http://elucio.com/projects.json?" + new Date().getTime().toString(); + sendJSONRequest(url); + } + + public function sendJSONRequest(url:String):void { + var jsonURLLoader:URLLoader = new URLLoader(); + var jsonURLRequest:URLRequest = new URLRequest(); + jsonURLRequest.url = url; + jsonURLLoader.load(jsonURLRequest); + jsonURLLoader.addEventListener(Event.COMPLETE, onJSONLoad); + } + + public function onJSONLoad(event:Event):void { + trace("projects:onJSONLoad:" + String(event.target.data)); + var rawData:String = String(event.target.data); + var arr:Array = (JSON.decode(rawData)); + var narr:Array = new Array(); + + trace("projects array length = " + arr.length); + for (var i:int = 0; i < arr.length; i++) { + for each (var value:Object in arr[i]) { + trace("project value: " + value.name); + narr.push(value); + } + } + projects = new ArrayCollection(narr); + } + + private function onJSONFault(event:FaultEvent):void { + trace("onJSONFault Error:" + event.message); + } + + } + +} \ No newline at end of file diff --git a/src/client-flex/com/elucio/Tasks.as b/src/client-flex/com/elucio/Tasks.as new file mode 100644 index 0000000..da2ddc0 --- /dev/null +++ b/src/client-flex/com/elucio/Tasks.as @@ -0,0 +1,70 @@ +package com.elucio { + import com.adobe.serialization.json.JSON; + + import flash.events.Event; + import flash.net.URLLoader; + import flash.net.URLRequest; + + import mx.collections.ArrayCollection; + import mx.rpc.events.FaultEvent; + import mx.rpc.events.ResultEvent; + + public class Tasks { + private static var _instance:Tasks = new Tasks(); + + [Bindable] + public var tasks:ArrayCollection = null; + + public function Tasks() { + if (_instance != null) { + throw new Error("Tasks can only be accessed through Tasks.instance"); + } + _instance = this; + load_tasks(); + } + + public static function get_instance():Tasks { + if (_instance == null) _instance = new Tasks(); + return _instance; + } + + public function get_tasks():ArrayCollection { + return tasks; + } + + public function load_tasks():void { + var url:String = "http://elucio.com/tasks.json?" + new Date().getTime().toString(); + sendJSONRequest(url); + } + + public function sendJSONRequest(url:String):void { + var jsonURLLoader:URLLoader = new URLLoader(); + var jsonURLRequest:URLRequest = new URLRequest(); + jsonURLRequest.url = url; + jsonURLLoader.load(jsonURLRequest); + jsonURLLoader.addEventListener(Event.COMPLETE, onJSONLoad); + } + + private function onJSONLoad(event:Event):void { + trace("tasks:onJSONLoad:" + String(event.target.data)); + var rawData:String = String(event.target.data); + var arr:Array = (JSON.decode(rawData)); + var narr:Array = new Array(); + + trace("tasks array length = " + arr.length); + for (var i:int = 0; i < arr.length; i++) { + for each (var value:Object in arr[i]) { + trace("task value: " + value.name); + narr.push(value); + } + } + tasks = new ArrayCollection(narr); + } + + private function onJSONFault(event:FaultEvent):void { + trace("onJSONFault Error:" + event.message); + } + + } + +} \ No newline at end of file diff --git a/src/client-svg/application.js b/src/client-svg/application.js new file mode 100644 index 0000000..b93ab2d --- /dev/null +++ b/src/client-svg/application.js @@ -0,0 +1,427 @@ +// deck + +function projects_itemLoadCallback(carousel, state) { + if (state != 'init') + return; + + jQuery.getJSON('/projects.json' + '?' + Math.round(new Date().getTime()), function(data) { + projects_itemAddCallback(carousel, carousel.first, carousel.last, data); + }); +}; + +function projects_itemAddCallback(carousel, first, last, data) { + // Simply add all items at once and set the size accordingly. + var items = []; + + for (i = 0; i < data.length; i++) { + items.push(data[i].project.name); + } + + for (i = 0; i < items.length; i++) { + carousel.add(i+1, mycarousel_getItemHTML(items[i])); + } + + carousel.size(items.length); +}; + +// Item html creation helper. +function mycarousel_getItemHTML(s) { + return '
  • ' + s + '
  • '; +}; + +// +// matrix +// + +var elucio = { + // TODO: too many globals + STATE_COLORS: ({ Done: "green", Open: "white", Late: "yellow", Started: "blue", Blocked: "red", New: "light blue" }), + HEIGHT_TO_WIDTH_RATIO: 0.6, + CELL_MARGIN: 0.1, + CELL_BORDER: 1, + paper: null, + div: null, + canvas_width: 0, + canvas_height: 0, + tasks: [], + zoom: 0, + zoom_factor: 0, + matrix_width: 0, + matrix_height: 0, + cell_width: 0, + cell_height: 0, + cell_width_margin: 0, + cell_height_margin: 0, + + init: function(div, canvas_width, canvas_height) { + elucio.get_tasks(div, canvas_width, canvas_height); + }, + + setup: function(div, canvas_width, canvas_height, tasks) { + this.div = div; + this.canvas_width = canvas_width; + this.canvas_height = canvas_height; + this.tasks = tasks; + this.paper = Raphael(div, canvas_width, canvas_height); + elucio.matrix(); + }, + + matrix: function() { + this.adjust_sizes(); + + if (this.paper) { + this.paper.clear(); + } + + elucio.draw_matrix(this.paper); + elucio.draw_tasks(this.paper, this.tasks); + elucio.draw_controls(this.paper, this.canvas_width - 60, 0); + }, + + adjust_sizes: function() { + var max_coord = elucio.get_project_matrix_size(this.tasks); + this.matrix_width = max_coord.x; + this.matrix_height = max_coord.y; + + if (this.zoom) { + this.zoom_factor+= this.zoom; + this.CELL_BORDER += this.zoom; + this.zoom = 0; + } + + // figure our matrix size based on needed dimensions plus a buffer + this.cell_width = this.canvas_width / (this.matrix_width + this.CELL_BORDER + this.CELL_BORDER); + this.cell_height = (this.canvas_height / (this.matrix_height + this.CELL_BORDER + this.CELL_BORDER)) * this.HEIGHT_TO_WIDTH_RATIO; + this.cell_width_margin = this.cell_width * this.CELL_MARGIN; + this.cell_height_margin = this.cell_height * this.CELL_MARGIN; + }, + + // draw empty matrix + draw_matrix: function(r) { + var cell_side_width = this.cell_width - (2 * this.cell_width_margin); + var cell_side_height = this.cell_height - (2 * this.cell_height_margin); + var full_cell_width = this.cell_width + this.cell_width_margin; + var full_cell_height = this.cell_height + this.cell_height_margin; + var full_matrix_width = this.matrix_width + this.CELL_BORDER + this.CELL_BORDER; + var full_matrix_height = this.matrix_height + this.CELL_BORDER + this.CELL_BORDER; + + for (var w = 0; w < full_matrix_width; w++) { + for (var h = 0; h < full_matrix_height; h++) { + var shape = r.rect(w * full_cell_width, h * full_cell_height, cell_side_width, cell_side_height, 10); + shape.attr({fill: "gray", stroke: "gray", "fill-opacity": 0, "stroke-width": 1, cursor: "move"}); + + // save values which are relative to the tasks and not the matrix + shape.node.matrix_x = w - this.CELL_BORDER; + shape.node.matrix_y = h - this.CELL_BORDER; + shape.dblclick(elucio.handler_doubleclick_add_task); + } + } + }, + + // draw tasks on matrix + draw_tasks: function(r, tasks) { + var cell_side_width = this.cell_width - (2 * this.cell_width_margin); + var cell_side_height = this.cell_height - (2 * this.cell_height_margin); + var full_cell_width = this.cell_width + this.cell_width_margin; + var full_cell_height = this.cell_height + this.cell_height_margin; + + for (var i = 0; i < tasks.length; i++) { + //alert("coords:" + tasks[i].task.matrix_x + "," + tasks[i].task.matrix_y); + var x = (tasks[i].task.matrix_x + this.CELL_BORDER) * full_cell_width; + var y = (tasks[i].task.matrix_y + this.CELL_BORDER) * full_cell_height; + var shape = r.rect(x, y, cell_side_width, cell_side_height, 10); + + shape.node.id = tasks[i].task.id; + + // task cells overwrite the empty shape so set these again + // these are relative to the tasks and not the matrix + shape.node.matrix_x = tasks[i].task.matrix_x; + shape.node.matrix_y = tasks[i].task.matrix_y; + + var task_state = tasks[i].task.status; + + if (!task_state) { + task_state = "Open"; + } + + shape.attr({fill: this.STATE_COLORS[task_state], stroke: this.STATE_COLORS[task_state], "fill-opacity": 50, "stroke-width": 2, cursor: "move"}); + + // add text + var bbox = shape.getBBox(); + + if (bbox.width > 50 || bbox.height > 50) { + t = r.text(x + (2 * this.cell_width_margin), y + this.cell_height_margin, tasks[i].task.name); // BUG: offset don't make sense, but are working + } + + // attach an event + shape.dblclick(elucio.handler_doubleclick_task); + } + }, + + draw_controls: function(r, x, y) { + icon_plus = "M25.979,12.896 19.312,12.896 19.312,6.229 12.647,6.229 12.647,12.896 5.979,12.896 5.979,19.562 12.647,19.562 12.647,26.229 19.312,26.229 19.312,19.562 25.979,19.562z"; + icon_minus = "M25.979,12.896,19.312,12.896,5.979,12.896,5.979,19.562,25.979,19.562z"; + + shape = r.rect(x, 0, 25, 25); + shape.attr({fill: "white" , stroke: "white" , "fill-opacity": 50, "stroke-width": 2, cursor: "move"}); + icon = r.path(icon_plus).attr({fill: "#000", stroke: "none"}); + icon.translate(x - 3, -4); + shape.click(elucio.handler_click_zoomin); + icon.click(elucio.handler_click_zoomin); + + shape = r.rect(x+28, 0, 25, 25); + shape.attr({fill: "white" , stroke: "white" , "fill-opacity": 50, "stroke-width": 2, cursor: "move"}); + icon = r.path(icon_minus).attr({fill: "#000", stroke: "none"}); + icon.translate(x+25, -4); + shape.click(elucio.handler_click_zoomout); + icon.click(elucio.handler_click_zoomout); + }, + + // + // event handlers + // + + handler_click_zoomin: function(event) { + elucio.zoom++; + elucio.matrix(); + }, + + handler_click_zoomout: function(event) { + elucio.zoom--; + elucio.matrix(); + }, + + handler_doubleclick_task: function(event) { + var task_id = this.node.id; + var matrix_x = this.node.matrix_x; + var matrix_y = this.node.matrix_y; + + $('
    ').dialog({ + width: 320, + height: 720, + title: 'Task Editor - Edit Task' + }) + + }, + + handler_doubleclick_add_task: function(event) { + var matrix_x = this.node.matrix_x; + var matrix_y = this.node.matrix_y; + + $('
    ').dialog({ + width: 320, + height: 720, + title: 'Task Editor - New Task' + }) + }, + + // figure out the cell width and height of the project + get_project_matrix_size: function(tasks) { + var max_x = 0; + var max_y = 0; + + for (var i = 0; i < tasks.length; i++) { + if (tasks[i].task.matrix_x > max_x) { + max_x = tasks[i].task.matrix_x; + } + if (tasks[i].task.matrix_y > max_y) { + max_y = tasks[i].task.matrix_y; + } + } + + // adjust for zero based index + max_x++; + max_y++; + + return {x: max_x, y: max_y}; + }, + + get_tasks: function(div, canvas_width, canvas_height) { + jQuery.getJSON('/tasks.json' + '?' + Math.round(new Date().getTime()), function(data) { + elucio.get_tasks_callback(div, canvas_width, canvas_height, data); + }); + }, + + get_tasks_callback: function(div, canvas_width, canvas_height, data) { + + //for (i = 0; i < data.length; i++) { + // alert("get_tasks_callback: " + data[i].task.name); + //} + + elucio.setup(div, canvas_width, canvas_height, data); + } + +} + +/* +var el; +function initMatrix(div, canvas_width, canvas_height) { + getTasks(div, canvas_width, canvas_height); +} + +CELL_BORDER = 2; // should be an even number + +function elucioMatrix(div, canvas_width, canvas_height, tasks, zoom) { + STATE_COLORS = ({ Done: "green", Open: "white", Late: "yellow", Started: "blue", Blocked: "red", New: "light blue" }); + HEIGHT_TO_WIDTH_RATIO = 0.6; + CELL_MARGIN = 0.1; + zoom = 6; // for testing + + r = Raphael(div, canvas_width, canvas_height); + + // TODO: adjust for odd sizes + + var max_coord = get_project_matrix_size(tasks); + matrix_width = max_coord.x; + matrix_height = max_coord.y; + + if (zoom != null) { + CELL_BORDER += zoom; + } + + // figure our matrix size based on needed dimensions plus a buffer + cell_width = canvas_width / (matrix_width + CELL_BORDER); + cell_height = (canvas_height / (matrix_height + CELL_BORDER)) * HEIGHT_TO_WIDTH_RATIO; + cell_width_margin = cell_width * CELL_MARGIN; + cell_height_margin = cell_height * CELL_MARGIN; + + // draw empty matrix + for (var w = 0; w < matrix_width + CELL_BORDER; w++) { + for (var h = 0; h < matrix_height + CELL_BORDER; h++) { + shape = r.rect(w * cell_width + cell_width_margin, h * cell_height + cell_height_margin, cell_width - (2 * cell_width_margin), cell_height - (2 * cell_height_margin), 10); + shape.attr({fill: "gray", stroke: "gray", "fill-opacity": 0, "stroke-width": 1, cursor: "move"}); + // these are relative to the tasks and not the matrix + shape.node.matrix_x = w - CELL_BORDER / 2; + shape.node.matrix_y = h - CELL_BORDER / 2; + shape.dblclick(handler_doubleclick_add_task); + } + } + + // draw tasks on matrix + for (var i = 0; i < tasks.length; i++) { + //alert("coords:" + tasks[i].task.matrix_x + "," + tasks[i].task.matrix_y); + x = (tasks[i].task.matrix_x + CELL_BORDER/2) * cell_width + cell_width_margin; + y = (tasks[i].task.matrix_y + CELL_BORDER/2) * cell_height + cell_height_margin; + shape = r.rect(x, y, cell_width - (2 * cell_width_margin), cell_height - (2 * cell_height_margin), 10); + shape.node.id = tasks[i].task.id; + task_state = tasks[i].task.status; + // task cells overwrite the empty shape so set these again + // these are relative to the tasks and not the matrix + shape.node.matrix_x = tasks[i].task.matrix_x; + shape.node.matrix_y = tasks[i].task.matrix_y; + if (task_state == null) { + task_state = "Open"; + } + shape.attr({fill: STATE_COLORS[task_state], stroke: STATE_COLORS[task_state], "fill-opacity": 50, "stroke-width": 2, cursor: "move"}); + // add text + var bbox = shape.getBBox(); + if (bbox.width > 50 || bbox.height > 50) { + t = r.text(x + (2 * cell_width_margin), y + cell_height_margin, tasks[i].task.name); // BUG: offset don't make sense, but are working + } + // attach an event + shape.dblclick(handler_doubleclick_task); + } + + zoom_buttons(r, canvas_width - 60, 0, div, canvas_width, canvas_height, tasks); +}; + +function zoom_buttons(r, x, y) { + icon_plus = "M25.979,12.896 19.312,12.896 19.312,6.229 12.647,6.229 12.647,12.896 5.979,12.896 5.979,19.562 12.647,19.562 12.647,26.229 19.312,26.229 19.312,19.562 25.979,19.562z"; + icon_minus = "M25.979,12.896,19.312,12.896,5.979,12.896,5.979,19.562,25.979,19.562z"; + + shape = r.rect(x, 0, 25, 25); + shape.attr({fill: "white" , stroke: "white" , "fill-opacity": 50, "stroke-width": 2, cursor: "move"}); + icon = r.path(icon_plus).attr({fill: "#000", stroke: "none"}); + icon.translate(x - 3, -4); + shape.click(handler_click_zoomin); + icon.click(handler_click_zoomin); + + shape = r.rect(x+28, 0, 25, 25); + shape.attr({fill: "white" , stroke: "white" , "fill-opacity": 50, "stroke-width": 2, cursor: "move"}); + icon = r.path(icon_minus).attr({fill: "#000", stroke: "none"}); + icon.translate(x+25, -4); + shape.click(handler_click_zoomout); + icon.click(handler_click_zoomout); + +} + +function handler_doubleclick_task(event) { + task_id = this.node.id; + matrix_x = this.node.matrix_x; + matrix_y = this.node.matrix_y; + + $('
    ').dialog({ + width: 320, + height: 720, + title: 'Task Editor - Edit Task' + }) + +} + +function handler_doubleclick_add_task(event) { + matrix_x = this.node.matrix_x; + matrix_y = this.node.matrix_y; + + $('
    ').dialog({ + width: 320, + height: 720, + title: 'Task Editor - New Task' + }) +} + +function handler_click_on_matrix(event) { + alert(event.which); +} + +// figure out the cell width and height of the project +function get_project_matrix_size(tasks) { + var max_x = 0; + var max_y = 0; + for (var i = 0; i < tasks.length; i++) { + if (tasks[i].task.matrix_x > max_x) { + max_x = tasks[i].task.matrix_x; + } + if (tasks[i].task.matrix_y > max_y) { + max_y = tasks[i].task.matrix_y; + } + } + // adjust for zero based index + max_x++; + max_y++; + + return {x: max_x, y: max_y}; +} + + +// Misc Calls + +function getTasks(div, canvas_width, canvas_height) { + jQuery.getJSON('/tasks.json' + '?' + Math.round(new Date().getTime()), function(data) { + get_tasks_callback(div, canvas_width, canvas_height, data); + }); +}; + +function get_tasks_callback(div, canvas_width, canvas_height, data) { + // Simply add all items at once and set the size accordingly. + var items = []; + + //for (i = 0; i < data.length; i++) { + // alert("get_tasks_callback: " + data[i].task.name); + //} + + var tasks = data; + elucioMatrix(div, canvas_width, canvas_height, tasks); + +}; + + +// OLD +function elucioProjectCanvas() { + var canvas = document.getElementById("elucioCanvas"); + var ctx = canvas.getContext("2d"); + ctx.fillRect(160, 120, 320, 480); +} +*/