1111
1212/* global MathJax:false */
1313
14- var Plotly = require ( '../plotly' ) ;
1514var d3 = require ( 'd3' ) ;
1615
1716var Lib = require ( '../lib' ) ;
1817var xmlnsNamespaces = require ( '../constants/xmlns_namespaces' ) ;
1918
20- var util = module . exports = { } ;
21-
2219// Append SVG
2320
2421d3 . selection . prototype . appendSVG = function ( _svgString ) {
@@ -45,7 +42,7 @@ d3.selection.prototype.appendSVG = function(_svgString) {
4542
4643// Text utilities
4744
48- util . html_entity_decode = function ( s ) {
45+ exports . html_entity_decode = function ( s ) {
4946 var hiddenDiv = d3 . select ( 'body' ) . append ( 'div' ) . style ( { display : 'none' } ) . html ( '' ) ;
5047 var replaced = s . replace ( / ( & [ ^ ; ] * ; ) / gi, function ( d ) {
5148 if ( d === '<' ) { return '<' ; } // special handling for brackets
@@ -56,7 +53,7 @@ util.html_entity_decode = function(s) {
5653 return replaced ;
5754} ;
5855
59- util . xml_entity_encode = function ( str ) {
56+ exports . xml_entity_encode = function ( str ) {
6057 return str . replace ( / & (? ! \w + ; | \# [ 0 - 9 ] + ; | \# x [ 0 - 9 A - F ] + ; ) / g, '&' ) ;
6158} ;
6259
@@ -66,7 +63,7 @@ function getSize(_selection, _dimension) {
6663 return _selection . node ( ) . getBoundingClientRect ( ) [ _dimension ] ;
6764}
6865
69- util . convertToTspans = function ( _context , _callback ) {
66+ exports . convertToTspans = function ( _context , _callback ) {
7067 var str = _context . text ( ) ;
7168 var converted = convertToSVG ( str ) ;
7269 var that = _context ;
@@ -112,7 +109,7 @@ util.convertToTspans = function(_context, _callback) {
112109 }
113110
114111 if ( tex ) {
115- var td = Plotly . Lib . getPlotDiv ( that . node ( ) ) ;
112+ var td = Lib . getPlotDiv ( that . node ( ) ) ;
116113 ( ( td && td . _promises ) || [ ] ) . push ( new Promise ( function ( resolve ) {
117114 that . style ( { visibility : 'hidden' } ) ;
118115 var config = { fontSize : parseInt ( that . style ( 'font-size' ) , 10 ) } ;
@@ -195,7 +192,7 @@ function cleanEscapesForTex(s) {
195192}
196193
197194function texToSVG ( _texString , _config , _callback ) {
198- var randomID = 'math-output-' + Plotly . Lib . randstr ( [ ] , 64 ) ;
195+ var randomID = 'math-output-' + Lib . randstr ( [ ] , 64 ) ;
199196 var tmpDiv = d3 . select ( 'body' ) . append ( 'div' )
200197 . attr ( { id : randomID } )
201198 . style ( { visibility : 'hidden' , position : 'absolute' } )
@@ -236,7 +233,7 @@ var PROTOCOLS = ['http:', 'https:', 'mailto:'];
236233
237234var STRIP_TAGS = new RegExp ( '</?(' + Object . keys ( TAG_STYLES ) . join ( '|' ) + ')( [^>]*)?/?>' , 'g' ) ;
238235
239- util . plainText = function ( _str ) {
236+ exports . plainText = function ( _str ) {
240237 // strip out our pseudo-html so we have a readable
241238 // version to put into text fields
242239 return ( _str || '' ) . replace ( STRIP_TAGS , ' ' ) ;
@@ -316,7 +313,7 @@ function convertToSVG(_str) {
316313 }
317314 }
318315 else {
319- return Plotly . util . xml_entity_encode ( d ) . replace ( / < / g, '<' ) ;
316+ return exports . xml_entity_encode ( d ) . replace ( / < / g, '<' ) ;
320317 }
321318 } ) ;
322319
@@ -397,7 +394,7 @@ function alignHTMLWith(_base, container, options) {
397394
398395// Editable title
399396
400- util . makeEditable = function ( context , _delegate , options ) {
397+ exports . makeEditable = function ( context , _delegate , options ) {
401398 if ( ! options ) options = { } ;
402399 var that = this ;
403400 var dispatch = d3 . dispatch ( 'edit' , 'input' , 'cancel' ) ;
@@ -431,7 +428,7 @@ util.makeEditable = function(context, _delegate, options) {
431428 }
432429
433430 function appendEditable ( ) {
434- var plotDiv = d3 . select ( Plotly . Lib . getPlotDiv ( that . node ( ) ) ) ,
431+ var plotDiv = d3 . select ( Lib . getPlotDiv ( that . node ( ) ) ) ,
435432 container = plotDiv . select ( '.svg-container' ) ,
436433 div = container . append ( 'div' ) ;
437434 div . classed ( 'plugin-editable editable' , true )
0 commit comments