On peut enfin modifier graphiquement le contenu des bulles :)
This commit is contained in:
parent
f29607938f
commit
659b62e1fa
1 changed files with 83 additions and 16 deletions
|
|
@ -100,6 +100,63 @@
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
const svgNS = "http://www.w3.org/2000/svg";
|
const svgNS = "http://www.w3.org/2000/svg";
|
||||||
|
const xlinkns = "http://www.w3.org/1999/xlink";
|
||||||
|
const xhtmlns = "http://www.w3.org/1999/xhtml";
|
||||||
|
var root = document.documentElement;
|
||||||
|
|
||||||
|
|
||||||
|
/* Extends Element functionality to add insertElement method */
|
||||||
|
Element.prototype.constructElementNS = function( namespace, elementName, attributeObj ) {
|
||||||
|
var el = document.createElementNS( namespace, elementName );
|
||||||
|
for ( var attr in attributeObj )
|
||||||
|
{
|
||||||
|
var attrValue = attributeObj[ attr ];
|
||||||
|
if ("object" == typeof attrValue) {
|
||||||
|
el.setAttributeNS( attrValue[0], attr, attrValue[1] );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
el.setAttribute( attr, attrValue );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return el;
|
||||||
|
}
|
||||||
|
|
||||||
|
Element.prototype.constructElement = function( elementName, attributeObj ) {
|
||||||
|
var el = this.constructElementNS( this.namespaceURI, elementName, attributeObj );
|
||||||
|
return el;
|
||||||
|
}
|
||||||
|
|
||||||
|
Element.prototype.insertElementNS = function( namespace, elementName, attributeObj, index ) {
|
||||||
|
var el = this.constructElementNS( namespace, elementName, attributeObj );
|
||||||
|
|
||||||
|
// insert child at requested index, or as last child if index is too high or no index is specified
|
||||||
|
if ( null == index ) {
|
||||||
|
this.appendChild( el );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
var targetIndex = index + 1;
|
||||||
|
if ( 0 == index ) {
|
||||||
|
targetIndex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
var targetEl = this.childNodes[ targetIndex ];
|
||||||
|
if ( targetEl ) {
|
||||||
|
this.insertBefore( el, targetEl );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.appendChild( el );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return el;
|
||||||
|
}
|
||||||
|
|
||||||
|
Element.prototype.insertElement = function( elementName, attributeObj, index ) {
|
||||||
|
var el = this.insertElementNS( this.namespaceURI, elementName, attributeObj, index );
|
||||||
|
return el;
|
||||||
|
}
|
||||||
|
|
||||||
idstrip = 0;
|
idstrip = 0;
|
||||||
|
|
||||||
// Point
|
// Point
|
||||||
|
|
@ -312,21 +369,25 @@
|
||||||
this.graphic_node.bulle = this;
|
this.graphic_node.bulle = this;
|
||||||
this.path.setAttribute("style", "fill: rgb(255, 255, 255); stroke: rgb(0, 0, 0); stroke-width: 3;");
|
this.path.setAttribute("style", "fill: rgb(255, 255, 255); stroke: rgb(0, 0, 0); stroke-width: 3;");
|
||||||
this.edit_node = document.createElementNS(svgNS, "switch");
|
this.edit_node = document.createElementNS(svgNS, "switch");
|
||||||
var foreign = document.createElement("foreignObject");// why this make a "foreignobject" instead of "foreignObject" ??
|
//var foreign = document.createElementNS(svgNS,"foreignObject");// why this make a "foreignobject" instead of "foreignObject" ??
|
||||||
foreign.setAttribute('width',this.w);
|
var foreign = this.edit_node.insertElement( "foreignObject", { x:8, width:this.w, height:this.h } );
|
||||||
foreign.setAttribute('height',this.h);
|
//var p = fo.insertElementNS( xhtmlns, "p" );
|
||||||
this.edit_node.appendChild(foreign);
|
|
||||||
var body = document.createElement("body");
|
//foreign.setAttribute('width',this.w);
|
||||||
body.setAttribute('xmlns',"http://www.w3.org/1999/xhtml");
|
//foreign.setAttribute('height',this.h);
|
||||||
foreign.appendChild(body);
|
//this.edit_node.appendChild(foreign);
|
||||||
var form = document.createElement("form");
|
//var body = document.createElement("body");
|
||||||
body.appendChild(form);
|
//body.setAttribute('xmlns',"http://www.w3.org/1999/xhtml");
|
||||||
var area = document.createElement("textarea");
|
//foreign.appendChild(body);
|
||||||
|
var form = foreign.insertElementNS( xhtmlns, "form" );
|
||||||
|
//var form = document.createElement("form");
|
||||||
|
//body.appendChild(form);
|
||||||
|
var area = form.insertElement("textarea");
|
||||||
area.setAttribute("style","background:none;border:1px dashed gray;width:"+(this.w-20)+"px;");
|
area.setAttribute("style","background:none;border:1px dashed gray;width:"+(this.w-20)+"px;");
|
||||||
area.setAttribute("name","area");
|
area.setAttribute("name","area");
|
||||||
area.setAttribute("onblur","javascript:alert('this');this.node.submitForm();");
|
area.setAttribute("onblur","javascript:this.node.submitForm();");
|
||||||
area.node = this;// pourquoi ça ne permet pas de faire this.node dans le onblur?
|
area.node = this;
|
||||||
form.appendChild(area);
|
//form.appendChild(area);
|
||||||
this.actuPath = function() {
|
this.actuPath = function() {
|
||||||
this.path.setAttribute("d", new Curve([
|
this.path.setAttribute("d", new Curve([
|
||||||
PM((this.x+20),this.y),
|
PM((this.x+20),this.y),
|
||||||
|
|
@ -348,14 +409,20 @@
|
||||||
}*/
|
}*/
|
||||||
this.editForm = function() {
|
this.editForm = function() {
|
||||||
this.graphic_node.setAttribute("onclick","");
|
this.graphic_node.setAttribute("onclick","");
|
||||||
|
this.edit_node.firstElementChild.firstElementChild.firstElementChild.textContent=this.texte;
|
||||||
|
this.edit_node.firstElementChild.firstElementChild.firstElementChild.style.height=this.h+"px";
|
||||||
this.edit_node.setAttribute('transform','translate('+this.x+','+this.y+')');
|
this.edit_node.setAttribute('transform','translate('+this.x+','+this.y+')');
|
||||||
this.edit_node.childNodes[0].setAttribute('height',this.h);
|
this.edit_node.childNodes[0].setAttribute('height',this.h);
|
||||||
this.noeud.replaceChild(this.edit_node,this.noeud.childNodes[1]);
|
this.noeud.replaceChild(this.edit_node,this.noeud.childNodes[1]);
|
||||||
|
this.edit_node.firstElementChild.firstElementChild.firstElementChild.focus();
|
||||||
}
|
}
|
||||||
this.submitForm = function() {
|
this.submitForm = function() {
|
||||||
alert('submit');
|
//alert('submit');
|
||||||
this.texte = this.edit_node.childNodes[0].area.value;
|
this.texte = this.edit_node.childNodes[0].firstElementChild.firstElementChild.value;
|
||||||
this.refreshNoeud();
|
this.noeud.replaceChild(this.getNoeudTexte(),this.edit_node);
|
||||||
|
this.actuPath();
|
||||||
|
this.graphic_node.setAttribute("onclick","javascript:this.bulle.editForm();");
|
||||||
|
//this.refreshNoeud();
|
||||||
}
|
}
|
||||||
this.refreshNoeud = function() {
|
this.refreshNoeud = function() {
|
||||||
//this.noeud.appendChild(this.getNoeudTexte());
|
//this.noeud.appendChild(this.getNoeudTexte());
|
||||||
|
|
|
||||||
|
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 26 KiB |
Loading…
Add table
Add a link
Reference in a new issue