mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-21 07:46:58 +02:00
Dojo broke.
This commit is contained in:
+6
-10
@@ -2,11 +2,11 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<script src="http://ajax.googleapis.com/ajax/libs/dojo/1.8/dojo/dojo.js" data-dojo-config="async: true, parseOnLoad: true, baseUrl: 'js/iD/'"></script>
|
||||
<title>iD</title>
|
||||
<!-- load Dojo -->
|
||||
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/dojo/1.8/dijit/themes/claro/claro.css">
|
||||
<link rel="stylesheet" href="css/app.css">
|
||||
<script src="http://ajax.googleapis.com/ajax/libs/dojo/1.8/dojo/dojo.js" data-dojo-config="async: true, parseOnLoad: true, baseUrl: 'js/iD/'"></script>
|
||||
</head>
|
||||
<body class="claro">
|
||||
<div id="appLayout" class="demoLayout">
|
||||
@@ -20,19 +20,18 @@
|
||||
<script type="text/javascript" src="js/iD/Entity.js"></script>
|
||||
<script type="text/javascript" src="js/iD/Way.js"></script>
|
||||
<script type="text/javascript" src="js/iD/Connection.js"></script>
|
||||
<script type="text/javascript" src="js/iD/Controller.js"></script>
|
||||
<script>
|
||||
|
||||
require(["dojo/dom-geometry","dojo/dom-class","dojo/on","dojo/dom","dojo/Evented",
|
||||
require(["dojo/on", "dojo/dom", "dojo/Evented",
|
||||
"iD/actions/UndoStack",
|
||||
"iD/actions/CreatePOIAction",
|
||||
"iD/actions/AddNodeToWayAction",
|
||||
"iD/Controller",
|
||||
"iD/actions/CreateEntityAction",
|
||||
"iD/controller/edit/NoSelection",
|
||||
"iD/controller/shape/NoSelection",
|
||||
"iD/renderer/Map","iD/styleparser/RuleSet",
|
||||
"iD/ui/DragAndDrop","iD/ui/StepPane",
|
||||
"dojo/domReady!"], function(domGeom,domClass,on,dom,Evented){
|
||||
"dojo/domReady!"], function(on, dom, Evented){
|
||||
|
||||
var ruleset = new iD.styleparser.RuleSet();
|
||||
var connection = new iD.Connection("http://www.overpass-api.de/api/xapi?");
|
||||
@@ -48,8 +47,8 @@ require(["dojo/dom-geometry","dojo/dom-class","dojo/on","dojo/dom","dojo/Evented
|
||||
zoom: 17,
|
||||
div: "map",
|
||||
connection: connection,
|
||||
width: dom.byId('map').offsetWidth,
|
||||
height: dom.byId('map').offsetHeight
|
||||
width: $('#map').width(),
|
||||
height: $('#map').height()
|
||||
});
|
||||
map.ruleset = ruleset;
|
||||
|
||||
@@ -63,9 +62,6 @@ require(["dojo/dom-geometry","dojo/dom-class","dojo/on","dojo/dom","dojo/Evented
|
||||
// Initialise drag-and-drop icons
|
||||
new iD.ui.DragAndDrop("map", map, "dndgrid");
|
||||
|
||||
// Initialise help pane
|
||||
controller.setStepper(new iD.ui.StepPane());
|
||||
|
||||
// Set initial controllerState
|
||||
controller.setState(new iD.controller.edit.NoSelection());
|
||||
|
||||
|
||||
+22
-47
@@ -1,54 +1,29 @@
|
||||
define(['dojo/_base/declare','dojo/on','dojo/Evented',
|
||||
'iD/actions/UndoStack','iD/tags/PresetList'], function(declare,on,Evented){
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Controller base class
|
||||
if (typeof iD === 'undefined') iD = {};
|
||||
|
||||
declare("iD.Controller", [Evented], {
|
||||
state: null, // current ControllerState
|
||||
map: null, // current Map
|
||||
stepper: null, // current StepPane
|
||||
undoStack: null, // main undoStack
|
||||
editorCache: null, // cache of tag editor objects, means we don't have to repeatedly load them
|
||||
|
||||
constructor:function(map) {
|
||||
// summary: The Controller marshalls ControllerStates and passes events to them.
|
||||
this.map = map;
|
||||
this.undoStack = new iD.UndoStack();
|
||||
this.editorCache = {};
|
||||
},
|
||||
iD.Controller = function(map) {
|
||||
var controller = {};
|
||||
|
||||
setStepper: function(stepper) {
|
||||
// summary: Set reference for the singleton-like class for the step-by-step instruction panel.
|
||||
this.stepper = stepper;
|
||||
},
|
||||
controller.editorCache = {};
|
||||
controller.undoStack = new iD.UndoStack();
|
||||
controller.stepper = new iD.ui.StepPane();
|
||||
|
||||
setState:function(newState) {
|
||||
// summary: Enter a new ControllerState, firing exitState on the old one, and enterState on the new one.
|
||||
if (newState === this.state) { return; }
|
||||
if (this.state) {
|
||||
this.emit("exitState", {
|
||||
bubbles: true,
|
||||
cancelable: true
|
||||
});
|
||||
}
|
||||
newState.controller = this;
|
||||
this.state = newState;
|
||||
newState.enterState();
|
||||
this.emit("enterState", {
|
||||
bubbles: true,
|
||||
cancelable: true
|
||||
});
|
||||
},
|
||||
controller.setState = function(newState) {
|
||||
// summary: Enter a new ControllerState, firing exitState on the old one, and enterState on the new one.
|
||||
if (newState === state) { return; }
|
||||
if (state) state.exitState();
|
||||
newState.controller = controller;
|
||||
state = newState;
|
||||
newState.enterState();
|
||||
};
|
||||
|
||||
entityMouseEvent:function(event,entityUI) {
|
||||
// summary: Pass a MouseEvent on an EntityUI (e.g. clicking a way) to the current ControllerState.
|
||||
if (!this.state) { return; }
|
||||
var newState = this.state.processMouseEvent(event,entityUI);
|
||||
this.setState(newState);
|
||||
}
|
||||
});
|
||||
controller.entityMouseEvent = function(event, entityUI) {
|
||||
// summary: Pass a MouseEvent on an EntityUI (e.g. clicking a way) to the current ControllerState.
|
||||
if (!this.state) { return; }
|
||||
var newState = this.state.processMouseEvent(event,entityUI);
|
||||
this.setState(newState);
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// End of module
|
||||
});
|
||||
return controller;
|
||||
};
|
||||
|
||||
@@ -7,57 +7,56 @@ define(['dojo/_base/declare','iD/controller/edit/EditBaseState'], function(decla
|
||||
|
||||
declare("iD.controller.edit.SelectedWay", [iD.controller.edit.EditBaseState], {
|
||||
|
||||
way: null,
|
||||
wayUI: null,
|
||||
entryevent: null,
|
||||
way: null,
|
||||
wayUI: null,
|
||||
entryevent: null,
|
||||
|
||||
constructor:function(way, event) {
|
||||
// summary: In 'Edit object' mode and a way is selected.
|
||||
this.way = way;
|
||||
this.entryevent = event;
|
||||
},
|
||||
enterState:function() {
|
||||
this.wayUI = this.controller.map.getUI(this.way);
|
||||
this.wayUI.setStateClass('selected');
|
||||
this.wayUI.setStateClass('shownodes');
|
||||
if (this.entryevent) {
|
||||
constructor:function(way, event) {
|
||||
// summary: In 'Edit object' mode and a way is selected.
|
||||
this.way = way;
|
||||
this.entryevent = event;
|
||||
},
|
||||
enterState:function() {
|
||||
this.wayUI = this.controller.map.getUI(this.way);
|
||||
this.wayUI.setStateClass('selected');
|
||||
this.wayUI.setStateClass('shownodes');
|
||||
if (this.entryevent) {
|
||||
this.openEditorTooltip(this.entryevent.clientX, this.entryevent.clientY, this.way);
|
||||
}
|
||||
this.wayUI.redraw();
|
||||
},
|
||||
exitState:function() {
|
||||
this.wayUI.resetStateClass('selected');
|
||||
this.wayUI.resetStateClass('shownodes');
|
||||
this.wayUI.redraw();
|
||||
this.closeEditorTooltip();
|
||||
},
|
||||
|
||||
processMouseEvent:function(event, entityUI) {
|
||||
var entity = entityUI ? entityUI.entity : null;
|
||||
var entityType = entity ? entity.entityType : null;
|
||||
this.wayUI.redraw();
|
||||
},
|
||||
exitState:function() {
|
||||
this.wayUI.resetStateClass('selected');
|
||||
this.wayUI.resetStateClass('shownodes');
|
||||
this.wayUI.redraw();
|
||||
this.closeEditorTooltip();
|
||||
},
|
||||
|
||||
processMouseEvent:function(event, entityUI) {
|
||||
var entity = entityUI ? entityUI.entity : null;
|
||||
var entityType = entity ? entity.entityType : null;
|
||||
|
||||
if (event.type === 'click') {
|
||||
switch (entityType) {
|
||||
case null:
|
||||
return new iD.controller.edit.NoSelection();
|
||||
case 'node':
|
||||
var ways = entity.entity.parentWays();
|
||||
if (entity.entity.hasParent(this.way)) {
|
||||
return new iD.controller.edit.SelectedWayNode(entity, this.way);
|
||||
} else if (!ways.length) {
|
||||
return new iD.controller.edit.SelectedPOINode(entity);
|
||||
} else {
|
||||
return new iD.controller.edit.SelectedWayNode(entity, ways[0]);
|
||||
}
|
||||
break;
|
||||
case 'way':
|
||||
return new iD.controller.edit.SelectedWay(entityUI.entity, event);
|
||||
}
|
||||
} else { }
|
||||
return this;
|
||||
}
|
||||
|
||||
if (event.type === 'click') {
|
||||
switch (entityType) {
|
||||
case null:
|
||||
return new iD.controller.edit.NoSelection();
|
||||
case 'node':
|
||||
var ways = entity.entity.parentWays();
|
||||
if (entity.entity.hasParent(this.way)) {
|
||||
return new iD.controller.edit.SelectedWayNode(entity, this.way);
|
||||
} else if (!ways.length) {
|
||||
return new iD.controller.edit.SelectedPOINode(entity);
|
||||
} else {
|
||||
return new iD.controller.edit.SelectedWayNode(entity, ways[0]);
|
||||
}
|
||||
break;
|
||||
case 'way':
|
||||
return new iD.controller.edit.SelectedWay(entityUI.entity, event);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
@@ -229,7 +229,6 @@ function(declare, Event, domGeom, Gfx, Matrix){
|
||||
return '' + e.id;
|
||||
}, this)).value();
|
||||
_.each(_.difference(_.keys(this.uis), touch), _.bind(function(k) {
|
||||
console.log(k);
|
||||
this.deleteUI(k);
|
||||
}, this));
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user