From e3aa2d7b9ff89d504669c0707bd7188af2f33ec4 Mon Sep 17 00:00:00 2001 From: Ondrej Zara Date: Tue, 14 Jan 2014 15:29:07 +0100 Subject: [PATCH 01/10] dragdrop, github --- css/ui.css | 26 ++++++++++++++++++-------- github.png | Bin 0 -> 1714 bytes index.html | 7 ++++--- js/action.js | 6 +++++- js/app.js | 46 ++++++++++++++++++++++++---------------------- 5 files changed, 51 insertions(+), 34 deletions(-) create mode 100644 github.png diff --git a/css/ui.css b/css/ui.css index 875742a..5cea699 100644 --- a/css/ui.css +++ b/css/ui.css @@ -103,22 +103,32 @@ border-color: #000; } +.ui #github { + position: absolute; + right: 160px; + bottom: 6px; +} + +.ui #github img { + vertical-align: middle; +} + .ui ~ #toggle { position: fixed; - bottom: 25px; - right: 75px; - width: 50px; - height: 50px; - line-height: 30px; + bottom: 6px; + right: 10px; + width: 32px; + height: 32px; + line-height: 18px; margin: auto; border-radius: 50%; box-shadow: 0 0 2px 3px #ccf; } .ui ~ #toggle:after { - content: "◀"; + content: "←"; font-weight: bold; - font-size: 28px; + font-size: 22px; } .ui.visible ~ #toggle { @@ -126,7 +136,7 @@ } .ui.visible ~ #toggle:after { - content: "▶"; + content: "→"; } .ui#help { diff --git a/github.png b/github.png new file mode 100644 index 0000000000000000000000000000000000000000..8b25551a97921681334176ee143b41510a117d86 GIT binary patch literal 1714 zcmaJ?X;2eq7*4oFu!ne{XxAht2qc?8LXr|_LPCfTpaBK7K$c{I0Ld=NLIOeuC;@2) zZ$K%a)k+m-s0>xHmKxL%0V&0TRzzznhgyqrIC$F)0{WwLXLrBvd*^wc_uSc%h%m9E z{W5z3f#4_!7RvAyFh6!S_*<8qJ%KOIm?#E|L=rJQq=gB5C6WLG5;c?r%V0>EmEH#X z5eSwPRa6WXBMs#$5H%GtW2go-in9p>zW@UYDNNWc^XOXZQ? z1QjEV00I#$3^1wQUJ8&-2UsjB-G|9y(LDhMNN3PM{APL4eYi{(m*ERcUnJa{R+-3^ z34^A6;U^v`8N*O6ji%S@sd{fJqD`XFIUJ5zgTe5^5nj414F(y!G&=H(f)Lgzv?>%+ zAsWD}2qhpH7>|TU`X&W6IxDNuO_vET7|j5oG&&VDr!)hUO8+0KR?nh!m<)a!?|%yG zqOwq!CWCcIhE{<$E|F|@g>nP6FoYr6C<8>D?ID9%&5J(4oSbR1I^byW*g@__U z4QsF&uJSEcFeleM3~ChjEQGbHOjsGDMbyAl(p=Ttv9RaVo8~I#js@@Y9C^_2U})yn zzSHU%6FxuY?d;&65MyR({^lU*3$z$ZllDb(o&<7d;A_`h2U+3~BJ2Hv`{W}KEU801#cv_B|9Cm!ynR{S`AMsSn z;7E=B;mb!wx$L;S>yGXG^6=&WlQn9$s?&L%Y1D8TI^MlKB1DqsEng$>f4=xYWBoPI z_S1p!sJ#d2?YI4kPA{k}Eby?F=f-J9zIc`YDl^pzjVm~9ebE?Hn?t0Nx+la|D0MB; z9)2xv1G>a1|A9kQ>~DV<=X3-4yC&n!m8-3K#P z{X@0zRuQsy$+N ziSCoLJU{Z$nQy4A4Y5UJ07$5FA~qL2%Q+cLaqDU?Lz3?=BC5;Nk6BbTmmceEaM>-Z zi>O&-dSE=%ex;vcvCOk{*JQ5^_4M z4lW7%l9IqY(z7pV(?I@@8=KPFO82)O{VDI18-*d-k$YmI^XiuPs_LuFw<^ZcD}yP5 c*NrbeloN*74g`U%%F6r~k%+>C^#XapzmV0H-2eap literal 0 HcmV?d00001 diff --git a/index.html b/index.html index e5c9a60..a2ba7ca 100644 --- a/index.html +++ b/index.html @@ -117,9 +117,11 @@

Item

+ + GitHub project page - +

@@ -230,12 +232,11 @@

Help

TODO: shortterm: - firebase auth - - dragdrop + - docka (github wiki) longterm: - firebase realtime - (custom) icons - - docka (github wiki) bugs: diff --git a/js/action.js b/js/action.js index 2bfa8e7..f5baeef 100644 --- a/js/action.js +++ b/js/action.js @@ -46,15 +46,18 @@ MM.Action.RemoveItem.prototype.undo = function() { MM.App.select(this._item); } -MM.Action.MoveItem = function(item, newParent, newIndex) { +MM.Action.MoveItem = function(item, newParent, newIndex, newSide) { this._item = item; this._newParent = newParent; this._newIndex = (arguments.length < 3 ? null : newIndex); + this._newSide = newSide || ""; this._oldParent = item.getParent(); this._oldIndex = this._oldParent.getChildren().indexOf(item); + this._oldSide = item.getSide(); } MM.Action.MoveItem.prototype = Object.create(MM.Action.prototype); MM.Action.MoveItem.prototype.perform = function() { + this._item.setSide(this._newSide); if (this._newIndex === null) { this._newParent.insertChild(this._item); } else { @@ -63,6 +66,7 @@ MM.Action.MoveItem.prototype.perform = function() { MM.App.select(this._item); } MM.Action.MoveItem.prototype.undo = function() { + this._item.setSide(this._oldSide); this._oldParent.insertChild(this._item, this._oldIndex); MM.App.select(this._newParent); } diff --git a/js/app.js b/js/app.js index b6273b7..88ccb1d 100644 --- a/js/app.js +++ b/js/app.js @@ -85,7 +85,6 @@ MM.App = { case "mousedown": e.preventDefault(); - this._port.style.cursor = "move"; this._port.addEventListener("mousemove", this); this._port.addEventListener("mouseup", this); this._drag.mouse[0] = e.clientX; @@ -94,14 +93,8 @@ MM.App = { var item = this.map.getItemFor(e.target); if (item && !item.isRoot()) { this._drag.item = item; - var content = item.getDOM().content; - this._drag.ghost = content.cloneNode(true); - this._drag.ghost.classList.add("ghost"); - this._drag.pos[0] = content.offsetLeft; - this._drag.pos[1] = content.offsetTop; - this._drag.ghost.style.left = this._drag.pos[0] + "px"; - this._drag.ghost.style.top = this._drag.pos[1] + "px"; - content.parentNode.appendChild(this._drag.ghost); + } else { + this._port.style.cursor = "move"; } break; @@ -111,10 +104,22 @@ MM.App = { this._drag.mouse[0] = e.clientX; this._drag.mouse[1] = e.clientY; if (this._drag.item) { - this._drag.pos[0] += dx; - this._drag.pos[1] += dy; - this._drag.ghost.style.left = this._drag.pos[0] + "px"; - this._drag.ghost.style.top = this._drag.pos[1] + "px"; + if (this._drag.ghost) { + this._drag.pos[0] += dx; + this._drag.pos[1] += dy; + this._drag.ghost.style.left = this._drag.pos[0] + "px"; + this._drag.ghost.style.top = this._drag.pos[1] + "px"; + } else { + var content = this._drag.item.getDOM().content; + this._drag.ghost = content.cloneNode(true); + this._drag.ghost.classList.add("ghost"); + this._drag.pos[0] = content.offsetLeft + dx; + this._drag.pos[1] = content.offsetTop + dy; + this._drag.ghost.style.left = this._drag.pos[0] + "px"; + this._drag.ghost.style.top = this._drag.pos[1] + "px"; + content.parentNode.appendChild(this._drag.ghost); + this._port.style.cursor = "move"; + } } else { this.map.moveBy(dx, dy); } @@ -125,16 +130,16 @@ MM.App = { this._port.removeEventListener("mousemove", this); this._port.removeEventListener("mouseup", this); - if (this._drag.item) { + if (this._drag.ghost) { var rect = this._drag.ghost.getBoundingClientRect(); this._drag.ghost.parentNode.removeChild(this._drag.ghost); var nearest = this.map.getClosestItem(rect.left + rect.width/2, rect.top + rect.height/2); this._finishDragDrop(this._drag.item, nearest); - - this._drag.item = null; - this._drag.ghost = null; } + + this._drag.item = null; + this._drag.ghost = null; break; } /* switch */ }, @@ -177,7 +182,7 @@ MM.App = { tmp = tmp.getParent(); } - var w1 = item.getDOM().content.offsetWidth; + var w1 = item.getDOM().content.offsetWidth; var w2 = target.getDOM().content.offsetWidth; var w = Math.max(w1, w2); var h1 = item.getDOM().content.offsetHeight; @@ -188,15 +193,12 @@ MM.App = { } else if (Math.abs(nearest.dx) < w && Math.abs(nearest.dy) < h) { /* append here */ var action = new MM.Action.MoveItem(item, target); } else { -// debugger; var dir = target.getParent().getLayout().getChildDirection(target); var diff = -1 * (dir == "top" || dir == "bottom" ? nearest.dx : nearest.dy); var index = target.getParent().getChildren().indexOf(target); var targetIndex = index + (diff > 0 ? 1 : 0); - var action = new MM.Action.MoveItem(item, target.getParent(), targetIndex); - /* FIXME side + side in action */ - + var action = new MM.Action.MoveItem(item, target.getParent(), targetIndex, target.getSide()); } this.action(action); From 06ee7dd5463bf29cb91777517d72648e54f67138 Mon Sep 17 00:00:00 2001 From: Ondrej Zara Date: Tue, 14 Jan 2014 15:32:03 +0100 Subject: [PATCH 02/10] gdrive fix --- js/ui.io.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/js/ui.io.js b/js/ui.io.js index 87bab2a..c45ac21 100644 --- a/js/ui.io.js +++ b/js/ui.io.js @@ -44,6 +44,8 @@ MM.UI.IO.prototype.restore = function() { id: state.ids[0] }; MM.UI.Backend.GDrive.setState(state); + } else { + history.replaceState(null, "", "."); } return; } catch (e) { } From 00c9a4ef40b2a05e5cb0e6e9c43aa0b4a6a1a08d Mon Sep 17 00:00:00 2001 From: Ondrej Zara Date: Tue, 14 Jan 2014 16:39:38 +0100 Subject: [PATCH 03/10] firebase auth --- index.html | 12 +++++++++- js/backend.firebase.js | 33 ++++++++++++++++++++-------- js/ui.backend.firebase.js | 46 +++++++++++++++++++++++++++++++-------- 3 files changed, 72 insertions(+), 19 deletions(-) diff --git a/index.html b/index.html index a2ba7ca..17eec8f 100644 --- a/index.html +++ b/index.html @@ -49,6 +49,7 @@ + @@ -158,6 +159,16 @@

Server

+

+ Auth + +

Saved maps @@ -231,7 +242,6 @@

Help