Skip to content

Commit

Permalink
Merge pull request #53 from ondras/master
Browse files Browse the repository at this point in the history
Update
  • Loading branch information
ondras authored Jul 22, 2016
2 parents e44f946 + fe7a43d commit 83ec128
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 32 deletions.
46 changes: 30 additions & 16 deletions my-mind.js
Original file line number Diff line number Diff line change
Expand Up @@ -2840,8 +2840,8 @@ MM.Format.FreeMind = Object.create(MM.Format, {
mime: {value: "application/x-freemind"}
});

MM.Format.FreeMind.to = function(data) {
var doc = document.implementation.createDocument(null, null);
MM.Format.FreeMind.to = function(data) {
var doc = document.implementation.createDocument("", "", null);
var map = doc.createElement("map");

map.setAttribute("version", "0.9.0");
Expand Down Expand Up @@ -4783,12 +4783,12 @@ MM.Mouse.handleEvent = function(e) {
if (MM.App.editing && item == MM.App.current) { return; } /* ignore on edited node */
if (item) { MM.App.select(item); }
break;

case "dblclick":
var item = MM.App.map.getItemFor(e.target);
if (item) { MM.Command.Edit.execute(); }
break;

case "contextmenu":
this._endDrag();
e.preventDefault();
Expand All @@ -4811,17 +4811,17 @@ MM.Mouse.handleEvent = function(e) {
}

if (e.type == "mousedown") { e.preventDefault(); } /* to prevent blurring the clipboard node */

if (e.type == "touchstart") { /* context menu here, after we have the item */
this._touchTimeout = setTimeout(function() {
this._touchTimeout = setTimeout(function() {
item && MM.App.select(item);
MM.Menu.open(e.clientX, e.clientY);
}, this.TOUCH_DELAY);
}

this._startDrag(e, item);
break;

case "touchmove":
if (e.touches.length > 1) { return; }
e.clientX = e.touches[0].clientX;
Expand All @@ -4830,7 +4830,7 @@ MM.Mouse.handleEvent = function(e) {
case "mousemove":
this._processDrag(e);
break;

case "touchend":
clearTimeout(this._touchTimeout);
case "mouseup":
Expand All @@ -4839,10 +4839,24 @@ MM.Mouse.handleEvent = function(e) {

case "wheel":
case "mousewheel":
var dir = 1;
if (e.wheelDelta && e.wheelDelta < 0) { dir = -1; }
if (e.deltaY && e.deltaY > 0) { dir = -1; }
MM.App.adjustFontSize(dir);
var dir = 0;
if (e.wheelDelta) {
if (e.wheelDelta < 0) {
dir = -1;
} else if (e.wheelDelta > 0) {
dir = 1;
}
}
if (e.deltaY) {
if (e.deltaY > 0) {
dir = -1;
} else if (e.deltaY < 0) {
dir = 1;
}
}
if (dir) {
MM.App.adjustFontSize(dir);
}
break;
}
}
Expand All @@ -4861,7 +4875,7 @@ MM.Mouse._startDrag = function(e, item) {
this._cursor[0] = e.clientX;
this._cursor[1] = e.clientY;

if (item && !item.isRoot()) {
if (item && !item.isRoot()) {
this._mode = "drag";
this._item = item;
} else {
Expand All @@ -4879,9 +4893,9 @@ MM.Mouse._processDrag = function(e) {

switch (this._mode) {
case "drag":
if (!this._ghost) {
if (!this._ghost) {
this._port.style.cursor = "move";
this._buildGhost(dx, dy);
this._buildGhost(dx, dy);
}
this._moveGhost(dx, dy);
var state = this._computeDragState();
Expand Down Expand Up @@ -4972,7 +4986,7 @@ MM.Mouse._computeDragState = function() {
if (tmp == this._item) { return state; } /* drop on a child or self */
tmp = tmp.getParent();
}

var w1 = this._item.getDOM().content.offsetWidth;
var w2 = target.getDOM().content.offsetWidth;
var w = Math.max(w1, w2);
Expand Down
4 changes: 2 additions & 2 deletions src/format.freemind.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ MM.Format.FreeMind = Object.create(MM.Format, {
mime: {value: "application/x-freemind"}
});

MM.Format.FreeMind.to = function(data) {
var doc = document.implementation.createDocument(null, null);
MM.Format.FreeMind.to = function(data) {
var doc = document.implementation.createDocument("", "", null);
var map = doc.createElement("map");

map.setAttribute("version", "0.9.0");
Expand Down
42 changes: 28 additions & 14 deletions src/mouse.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ MM.Mouse.handleEvent = function(e) {
if (MM.App.editing && item == MM.App.current) { return; } /* ignore on edited node */
if (item) { MM.App.select(item); }
break;

case "dblclick":
var item = MM.App.map.getItemFor(e.target);
if (item) { MM.Command.Edit.execute(); }
break;

case "contextmenu":
this._endDrag();
e.preventDefault();
Expand All @@ -56,17 +56,17 @@ MM.Mouse.handleEvent = function(e) {
}

if (e.type == "mousedown") { e.preventDefault(); } /* to prevent blurring the clipboard node */

if (e.type == "touchstart") { /* context menu here, after we have the item */
this._touchTimeout = setTimeout(function() {
this._touchTimeout = setTimeout(function() {
item && MM.App.select(item);
MM.Menu.open(e.clientX, e.clientY);
}, this.TOUCH_DELAY);
}

this._startDrag(e, item);
break;

case "touchmove":
if (e.touches.length > 1) { return; }
e.clientX = e.touches[0].clientX;
Expand All @@ -75,7 +75,7 @@ MM.Mouse.handleEvent = function(e) {
case "mousemove":
this._processDrag(e);
break;

case "touchend":
clearTimeout(this._touchTimeout);
case "mouseup":
Expand All @@ -84,10 +84,24 @@ MM.Mouse.handleEvent = function(e) {

case "wheel":
case "mousewheel":
var dir = 1;
if (e.wheelDelta && e.wheelDelta < 0) { dir = -1; }
if (e.deltaY && e.deltaY > 0) { dir = -1; }
MM.App.adjustFontSize(dir);
var dir = 0;
if (e.wheelDelta) {
if (e.wheelDelta < 0) {
dir = -1;
} else if (e.wheelDelta > 0) {
dir = 1;
}
}
if (e.deltaY) {
if (e.deltaY > 0) {
dir = -1;
} else if (e.deltaY < 0) {
dir = 1;
}
}
if (dir) {
MM.App.adjustFontSize(dir);
}
break;
}
}
Expand All @@ -106,7 +120,7 @@ MM.Mouse._startDrag = function(e, item) {
this._cursor[0] = e.clientX;
this._cursor[1] = e.clientY;

if (item && !item.isRoot()) {
if (item && !item.isRoot()) {
this._mode = "drag";
this._item = item;
} else {
Expand All @@ -124,9 +138,9 @@ MM.Mouse._processDrag = function(e) {

switch (this._mode) {
case "drag":
if (!this._ghost) {
if (!this._ghost) {
this._port.style.cursor = "move";
this._buildGhost(dx, dy);
this._buildGhost(dx, dy);
}
this._moveGhost(dx, dy);
var state = this._computeDragState();
Expand Down Expand Up @@ -217,7 +231,7 @@ MM.Mouse._computeDragState = function() {
if (tmp == this._item) { return state; } /* drop on a child or self */
tmp = tmp.getParent();
}

var w1 = this._item.getDOM().content.offsetWidth;
var w2 = target.getDOM().content.offsetWidth;
var w = Math.max(w1, w2);
Expand Down

0 comments on commit 83ec128

Please sign in to comment.