Adapt highlighting of objects: Difference between revisions

From JSXGraph Wiki
No edit summary
No edit summary
 
(50 intermediate revisions by 2 users not shown)
Line 2: Line 2:
<div id="myinfobox"  
<div id="myinfobox"  
     style="
     style="
        z-Index:99;
         display:none;
         display:none;
         position:absolute;  
         position:absolute;  
        left:0px;
        top:0px;
        width:50px;
         background-color:#ffff88;
         background-color:#ffff88;
         padding:10px;
         padding:5px;
         // Cross-browser opacity:
        text-align:center;
         -ms-filter:'progid:DXImageTransform.Microsoft.Alpha(Opacity=50)';  
         /* Cross-browser opacity:*/
         filter: alpha(opacity=50);
         -ms-filter:'progid:DXImageTransform.Microsoft.Alpha(Opacity=70)';  
         opacity:.5;
         filter: alpha(opacity=70);
         opacity:.7;
     "
     "
></div>  
></div>  
</html>
</html>
<jsxgraph width="600" height="600">
<jsxgraph width="600" height="600">
// A simple construction, consisting of three points , two lines, one circle.
var brd = JXG.JSXGraph.initBoard('jxgbox', {boundingbox: [-5, 5, 5, -5], grid: false});
var brd = JXG.JSXGraph.initBoard('jxgbox', {boundingbox: [-5, 5, 5, -5], grid: false});
var p1 = brd.create('point',[3,0]);
var p1 = brd.create('point',[3,0]);
Line 23: Line 29:
var c = brd.create('circle',[p2,p3]);
var c = brd.create('circle',[p2,p3]);


// First, we overwrite the highling method for ALL lines
var infobox = document.getElementById('myinfobox');
var infobox = document.getElementById('myinfobox');
JXG.Line.prototype.highlight = function(){
JXG.Line.prototype.highlight = function(){
     infobox.innerHTML = this.name;
    var pos = this.getMousePosition
     infobox.style.left = this.board.mousePosAbs[0]+20;
     infobox.innerHTML = this.board.mousePosRel.toString()+'<hr noshade>'+this.name;
     infobox.style.top = this.board.mousePosAbs[1]-20;
     infobox.style.left = (this.board.mousePosRel[0]+0)+'px';
     infobox.style.top = (this.board.mousePosRel[1]+0)+'px';
     infobox.style.display = 'block';
     infobox.style.display = 'block';
    this.board.renderer.highlight(this); // highlight the line
}
}
JXG.Line.prototype.noHighlight = function(){
JXG.Line.prototype.noHighlight = function(){
     infobox.style.display = 'none';
     infobox.style.display = 'none';
    this.board.renderer.noHighlight(this); // dehighlight the line
}
}
//Second, we overwrite the highlighting method just for the circle c.
c.highlight = function(){
c.highlight = function(){
     infobox.innerHTML = 'circle '+this.name;
     infobox.innerHTML = this.board.mousePosRel.toString();
     infobox.style.left = this.board.mousePosAbs[0]+20;
     infobox.style.left = (this.board.mousePosRel[0]+0)+'px';
     infobox.style.top = this.board.mousePosAbs[1]-20;
     infobox.style.top = (this.board.mousePosRel[0]+0)+'px';
     infobox.style.display = 'block';
     infobox.style.display = 'block';
}
}
Line 46: Line 59:


===The JavaScript code===
===The JavaScript code===
Create an invisible divsion:
<source lang="html4strict">
<div id="myinfobox"
    style="
        z-Index:99;
        display:none;
        position:absolute;
        left:0px;
        top:0px;
        width:50px;
        background-color:#ffff88;
        padding:5px;
        text-align:center;
        /* Cross-browser opacity:*/
        -ms-filter:'progid:DXImageTransform.Microsoft.Alpha(Opacity=70)';
        filter: alpha(opacity=70);
        opacity:.7;
    "
></div>
</source>
<source lang="javascript">
<source lang="javascript">
// A simple construction, consisting of three points , two lines, one circle.
var brd = JXG.JSXGraph.initBoard('jxgbox', {boundingbox: [-5, 5, 5, -5], grid: false});
var p1 = brd.create('point',[3,0]);
var p2 = brd.create('point',[-1,0]);
var p3 = brd.create('point',[0,4]);
var l1 = brd.create('line',[p1,p2]);
var l2 = brd.create('line',[p1,p3]);
var c = brd.create('circle',[p2,p3]);
// First, we overwrite the highling method for ALL lines
var infobox = document.getElementById('myinfobox');
JXG.Line.prototype.highlight = function(){
    infobox.innerHTML = this.board.mousePosRel.toString()+'<hr noshade>'+this.name;
    infobox.style.left = (this.board.mousePosRel[0]+0)+'px';
    infobox.style.top =  (this.board.mousePosRel[1]+0)+'px';
    infobox.style.display = 'block';
    this.board.renderer.highlight(this); // highlight the line
}
JXG.Line.prototype.noHighlight = function(){
    infobox.style.display = 'none';
    this.board.renderer.noHighlight(this); // dehighlight the line
}


//Second, we overwrite the highlighting method just for the circle c.
c.highlight = function(){
    infobox.innerHTML = this.board.mousePosRel.toString();
    infobox.style.left = (this.board.mousePosRel[0]+0)+'px';
    infobox.style.top =  (this.board.mousePosRel[1]+0)+'px';
    infobox.style.display = 'block';
}
c.noHighlight = function(){
    infobox.style.display = 'none';
}
</source>
</source>
[[Category:Examples]]
 
[[Category:Austragungsstueberl]]

Latest revision as of 15:05, 24 February 2015

The JavaScript code

Create an invisible divsion:

<div id="myinfobox" 
    style="
        z-Index:99;
        display:none;
        position:absolute; 
        left:0px;
        top:0px;
        width:50px;
        background-color:#ffff88;
        padding:5px;
        text-align:center;
        /* Cross-browser opacity:*/
        -ms-filter:'progid:DXImageTransform.Microsoft.Alpha(Opacity=70)'; 
        filter: alpha(opacity=70);
        opacity:.7;
    "
></div>
// A simple construction, consisting of three points , two lines, one circle.
var brd = JXG.JSXGraph.initBoard('jxgbox', {boundingbox: [-5, 5, 5, -5], grid: false});
var p1 = brd.create('point',[3,0]);
var p2 = brd.create('point',[-1,0]);
var p3 = brd.create('point',[0,4]);
var l1 = brd.create('line',[p1,p2]);
var l2 = brd.create('line',[p1,p3]);

var c = brd.create('circle',[p2,p3]);

// First, we overwrite the highling method for ALL lines
var infobox = document.getElementById('myinfobox');
JXG.Line.prototype.highlight = function(){
    infobox.innerHTML = this.board.mousePosRel.toString()+'<hr noshade>'+this.name;
    infobox.style.left = (this.board.mousePosRel[0]+0)+'px';
    infobox.style.top =  (this.board.mousePosRel[1]+0)+'px';
    infobox.style.display = 'block';
    this.board.renderer.highlight(this); // highlight the line

}
JXG.Line.prototype.noHighlight = function(){
    infobox.style.display = 'none';
    this.board.renderer.noHighlight(this); // dehighlight the line
}

//Second, we overwrite the highlighting method just for the circle c.
c.highlight = function(){
    infobox.innerHTML = this.board.mousePosRel.toString();
    infobox.style.left = (this.board.mousePosRel[0]+0)+'px';
    infobox.style.top =  (this.board.mousePosRel[1]+0)+'px';
    infobox.style.display = 'block';
}
c.noHighlight = function(){
    infobox.style.display = 'none';
}