Skip to content

Commit

Permalink
Added experimental webgl support, see phetsims/fluid-pressure-and-flo…
Browse files Browse the repository at this point in the history
  • Loading branch information
samreid committed Nov 4, 2014
1 parent cd8041b commit da85ea4
Showing 1 changed file with 43 additions and 43 deletions.
86 changes: 43 additions & 43 deletions js/SubSupText.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,49 +69,49 @@ define( function( require ) {
*/
update: function() {

var thisNode = this;
var options = thisNode._options;

thisNode._textParent.removeAllChildren();

var node, previousNode, previousNodeType;
$( $.parseHTML( thisNode._text ) ).each( function( index, element ) {
if ( element.nodeType === 3 ) {
// Text
node = new Text( element.nodeValue, { font: options.font, fill: options.fill } );
thisNode._textParent.addChild( node );
if ( previousNode ) {
node.left = previousNode.right + options.textXSpacing;
}
}
else if ( element.nodeType === 1 ) {
// Element
if ( previousNodeType !== 3 ) {
throw new Error( 'sub or sup element must be preceded by text' );
}

if ( element.tagName === 'SUB' ) { // HTML spec says that element names are uppercase
node = new Text( element.innerHTML, { font: options.font, fill: options.fill, scale: options.subScale } );
thisNode._textParent.addChild( node );
node.left = previousNode.right + options.subXSpacing;
node.centerY = previousNode.y + options.subYOffset; // center on baseline
}
else if ( element.tagName === 'SUP' ) { // HTML spec says that element names are uppercase
node = new Text( element.innerHTML, { font: options.font, fill: options.fill, scale: options.supScale } );
thisNode._textParent.addChild( node );
node.left = previousNode.right + options.supXSpacing;
node.centerY = previousNode.y + thisNode._capLineYOffset + options.supYOffset; // center on cap line
}
else {
throw new Error( 'unsupported tagName: ' + element.tagName );
}
}
else {
throw new Error( 'unsupported nodeType: ' + element.nodeType );
}
previousNode = node;
previousNodeType = element.nodeType;
} );
// var thisNode = this;
// var options = thisNode._options;
//
// thisNode._textParent.removeAllChildren();
//
// var node, previousNode, previousNodeType;
// $( $.parseHTML( thisNode._text ) ).each( function( index, element ) {
// if ( element.nodeType === 3 ) {
// // Text
// node = new Text( element.nodeValue, { font: options.font, fill: options.fill } );
// thisNode._textParent.addChild( node );
// if ( previousNode ) {
// node.left = previousNode.right + options.textXSpacing;
// }
// }
// else if ( element.nodeType === 1 ) {
// // Element
// if ( previousNodeType !== 3 ) {
// throw new Error( 'sub or sup element must be preceded by text' );
// }
//
// if ( element.tagName === 'SUB' ) { // HTML spec says that element names are uppercase
// node = new Text( element.innerHTML, { font: options.font, fill: options.fill, scale: options.subScale } );
// thisNode._textParent.addChild( node );
// node.left = previousNode.right + options.subXSpacing;
// node.centerY = previousNode.y + options.subYOffset; // center on baseline
// }
// else if ( element.tagName === 'SUP' ) { // HTML spec says that element names are uppercase
// node = new Text( element.innerHTML, { font: options.font, fill: options.fill, scale: options.supScale } );
// thisNode._textParent.addChild( node );
// node.left = previousNode.right + options.supXSpacing;
// node.centerY = previousNode.y + thisNode._capLineYOffset + options.supYOffset; // center on cap line
// }
// else {
// throw new Error( 'unsupported tagName: ' + element.tagName );
// }
// }
// else {
// throw new Error( 'unsupported nodeType: ' + element.nodeType );
// }
// previousNode = node;
// previousNodeType = element.nodeType;
// } );
},

// text ----------------------------------------------------------
Expand Down

0 comments on commit da85ea4

Please sign in to comment.